Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cCLISetup
  • cSetupLanguageChooser
  • cSetupNotInstallable
  • cSetupTypeChooser

Functions

  • checkAndInclude
  • checkExistingPlugin
  • checkInstallationSettings
  • findSimilarText
  • getArgs
  • getContenidoVersion
  • getSystemDirectories
  • initializeVariables
  • listClients
  • passwordPrompt
  • printHelpText
  • prnt
  • prntln
  • prntst
  • progressBar
  • stripLastSlash
  • updateClientPath
  • updateContenidoVersion
  • updateSysadminPassword
  • updateSystemProperties
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains various functions for the setup process.
  4:  *
  5:  * @package    Setup
  6:  * @subpackage Setup
  7:  * @version    SVN Revision $Rev:$
  8:  *
  9:  * @author     Unknown
 10:  * @copyright  four for business AG <www.4fb.de>
 11:  * @license    http://www.contenido.org/license/LIZENZ.txt
 12:  * @link       http://www.4fb.de
 13:  * @link       http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Checks if a plugin is already installed
 20:  * @param   cDb  $db
 21:  * @param   string  $sPluginname
 22:  * @return  bool
 23:  */
 24: function checkExistingPlugin($db, $sPluginname) {
 25:     global $cfg;
 26: 
 27:     #new install: all plugins are checked
 28:     if ($_SESSION["setuptype"] == "setup") {
 29:         return true;
 30:     }
 31: 
 32:     $sPluginname = (string) $sPluginname;
 33:     $sTable = $cfg['tab']['nav_sub'];
 34:     $sSql = '';
 35: 
 36:     switch ($sPluginname) {
 37:         case 'plugin_cronjob_overview':
 38:             $sSql = "SELECT * FROM %s WHERE idnavs=950";
 39:             break;
 40:         case 'plugin_conman':
 41:             $sSql = "SELECT * FROM %s WHERE idnavs=900";
 42:             break;
 43:         case 'plugin_content_allocation':
 44:             $sSql = "SELECT * FROM %s WHERE idnavs=800";
 45:             break;
 46:         case 'plugin_newsletter':
 47:             $sSql = "SELECT * FROM %s WHERE idnavs=610";
 48:             break;
 49:         case 'plugin_mod_rewrite':
 50:             $sSql = "SELECT * FROM %s WHERE idnavs=700 OR location='mod_rewrite/xml/;navigation/content/mod_rewrite'";
 51:             break;
 52:         default:
 53:             $sSql = '';
 54:             break;
 55:     }
 56: 
 57:     if ($sSql) {
 58:         $db->query($sSql, $sTable);
 59:         if ($db->nextRecord()) {
 60:             return true;
 61:         }
 62:     }
 63: 
 64:     return false;
 65: }
 66: 
 67: /**
 68:  * Updates system properties
 69:  * @param  cDb $db
 70:  * @param  string  $table  DB table name
 71:  */
 72: function updateSystemProperties($db, $table) {
 73:     $table = $db->escape($table);
 74: 
 75:     $aStandardvalues = array(
 76:         array('type' => 'pw_request', 'name' => 'enable', 'value' => 'true'),
 77:         array('type' => 'system', 'name' => 'mail_sender_name', 'value' => 'CONTENIDO Backend'),
 78:         array('type' => 'system', 'name' => 'mail_sender', 'value' => 'info@contenido.org'),
 79:         array('type' => 'system', 'name' => 'mail_host', 'value' => 'localhost'),
 80:         array('type' => 'maintenance', 'name' => 'mode', 'value' => 'disabled'),
 81:         array('type' => 'codemirror', 'name' => 'activated', 'value' => 'true'),
 82:         array('type' => 'update', 'name' => 'check', 'value' => 'false'),
 83:         array('type' => 'update', 'name' => 'news_feed', 'value' => 'false'),
 84:         array('type' => 'update', 'name' => 'check_period', 'value' => '60'),
 85:         array('type' => 'system', 'name' => 'clickmenu', 'value' => 'false'),
 86:         array('type' => 'versioning', 'name' => 'activated', 'value' => 'true'),
 87:         array('type' => 'versioning', 'name' => 'prune_limit', 'value' => ''),
 88:         array('type' => 'versioning', 'name' => 'path', 'value' => ''),
 89:         array('type' => 'system', 'name' => 'insite_editing_activated', 'value' => 'true'),
 90:         array('type' => 'backend', 'name' => 'backend_label', 'value' => ''),
 91:         array('type' => 'generator', 'name' => 'xhtml', 'value' => 'true'),
 92:         array('type' => 'generator', 'name' => 'basehref', 'value' => 'true'),
 93:         array('type' => 'debug', 'name' => 'module_translation_message', 'value' => 'true'),
 94:         array('type' => 'debug', 'name' => 'debug_for_plugins', 'value' => 'true')
 95:     );
 96: 
 97:     foreach ($aStandardvalues as $aData) {
 98:         $sql = "SELECT `value` FROM `%s` WHERE `type` = '%s' AND `name` = '%s'";
 99:         $db->query(sprintf($sql, $table, $aData['type'], $aData['name']));
100:         if ($db->nextRecord()) {
101:             $sValue = $db->f('value');
102:             if ($sValue == '') {
103:                 $sql = "UPDATE `%s` SET `value` = '%s' WHERE `type` = '%s' AND `name` = '%s'";
104:                 $sql = sprintf($sql, $table, $aData['value'], $aData['type'], $aData['name']);
105:                 $db->query($sql);
106:             }
107:         } else {
108:             $sql = "INSERT INTO `%s` SET `type` = '%s', `name` = '%s', `value` = '%s'";
109:             $sql = sprintf($sql, $table, $aData['type'], $aData['name'], $aData['value']);
110:             $db->query($sql);
111:         }
112: 
113:         if ($db->getErrorNumber() != 0) {
114:             logSetupFailure("Unable to execute SQL statement:\n" . $sql . "\nMysql Error: " . $db->getErrorMessage() . " (" . $db->getErrorNumber() . ")");
115:         }
116:     }
117: }
118: 
119: /**
120:  * Updates contenido version in given table
121:  * @param  cDb $db
122:  * @param  string  $table  DB table name
123:  * @param  string  $version  Version
124:  */
125: function updateContenidoVersion($db, $table, $version) {
126:     $sql = "SELECT `idsystemprop` FROM `%s` WHERE `type` = 'system' AND `name` = 'version'";
127:     $db->query(sprintf($sql, $db->escape($table)));
128: 
129:     if ($db->nextRecord()) {
130:         $sql = "UPDATE `%s` SET `value` = '%s' WHERE `type` = 'system' AND `name` = 'version'";
131:         $db->query(sprintf($sql, $db->escape($table), $db->escape($version)));
132:     } else {
133:         //$id = $db->nextid($table);
134:         $sql = "INSERT INTO `%s` SET `type` = 'system', `name` = 'version', `value` = '%s'";
135:         $db->query(sprintf($sql, $db->escape($table), $db->escape($version)));
136:     }
137: }
138: 
139: /**
140:  * Returns current version
141:  * @param  cDb $db
142:  * @param  string  $table  DB table name
143:  * @return string
144:  */
145: function getContenidoVersion($db, $table) {
146:     $sql = "SELECT `value` FROM `%s` WHERE `type` = 'system' AND `name` = 'version'";
147:     $db->query(sprintf($sql, $db->escape($table)));
148: 
149:     if ($db->nextRecord()) {
150:         return $db->f("value");
151:     } else {
152:         return false;
153:     }
154: }
155: 
156: // @FIXME: Comment me plz!
157: function updateSysadminPassword($db, $table, $password, $mail) {
158:     $sql = "SELECT password FROM %s WHERE username='sysadmin'";
159:     $db->query(sprintf($sql, $db->escape($table)));
160: 
161:     if ($db->nextRecord()) {
162:         $sql = "UPDATE %s SET password='%s', email='%s' WHERE username='sysadmin'";
163:         $db->query(sprintf($sql, $db->escape($table), md5($password), $mail));
164:         return true;
165:     } else {
166: 
167:         return false;
168:     }
169: }
170: 
171: // @FIXME: Comment me plz!
172: function listClients($db, $table) {
173:     global $cfgClient;
174: 
175:     $sql = "SELECT idclient, name FROM %s";
176: 
177:     $db->query(sprintf($sql, $db->escape($table)));
178: 
179:     $clients = array();
180: 
181:     while ($db->nextRecord()) {
182:         $frontendPath = $cfgClient[$db->f('idclient')]['path']['frontend'];
183:         $htmlPath = $cfgClient[$db->f('idclient')]['path']['htmlpath'];
184:         $clients[$db->f("idclient")] = array("name" => $db->f("name"), "frontendpath" => $frontendPath, "htmlpath" => $htmlPath);
185:     }
186: 
187:     return $clients;
188: }
189: 
190: // @FIXME: Comment me plz!
191: function updateClientPath($db, $table, $idclient, $frontendpath, $htmlpath) {
192:     global $cfg, $cfgClient;
193:     checkAndInclude($cfg['path']['contenido'] . 'includes/functions.general.php');
194: 
195:     updateClientCache($idclient, $htmlpath, $frontendpath);
196: }
197: 
198: // @FIXME: Comment me plz!
199: function stripLastSlash($sInput) {
200:     if (substr($sInput, strlen($sInput) - 1, 1) == "/") {
201:         $sInput = substr($sInput, 0, strlen($sInput) - 1);
202:     }
203: 
204:     return $sInput;
205: }
206: 
207: // @FIXME: Comment me plz!
208: function getSystemDirectories($bOriginalPath = false) {
209:     $root_path = stripLastSlash(CON_FRONTEND_PATH);
210: 
211:     $root_http_path = dirname(dirname($_SERVER["PHP_SELF"]));
212:     $root_http_path = str_replace("\\", "/", $root_http_path);
213: 
214:     $port = "";
215:     $protocol = "http://";
216: 
217:     if ($_SERVER["SERVER_PORT"] != 80) {
218:         if ($_SERVER["SERVER_PORT"] == 443) {
219:             $protocol = "https://";
220:         } else {
221:             $port = ":" . $_SERVER["SERVER_PORT"];
222:         }
223:     }
224: 
225:     $root_http_path = $protocol . $_SERVER["SERVER_NAME"] . $port . $root_http_path;
226: 
227:     if (substr($root_http_path, strlen($root_http_path) - 1, 1) == "/") {
228:         $root_http_path = substr($root_http_path, 0, strlen($root_http_path) - 1);
229:     }
230: 
231:     if ($bOriginalPath == true) {
232:         return array($root_path, $root_http_path);
233:     }
234: 
235:     if (isset($_SESSION["override_root_path"])) {
236:         $root_path = $_SESSION["override_root_path"];
237:     }
238: 
239:     if (isset($_SESSION["override_root_http_path"])) {
240:         $root_http_path = $_SESSION["override_root_http_path"];
241:     }
242: 
243:     $root_path = stripLastSlash($root_path);
244:     $root_http_path = stripLastSlash($root_http_path);
245: 
246:     return array($root_path, $root_http_path);
247: }
248: 
249: // @FIXME: Comment me plz!
250: function findSimilarText($string1, $string2) {
251:     for ($i = 0; $i < strlen($string1); $i++) {
252:         if (substr($string1, 0, $i) != substr($string2, 0, $i)) {
253:             return $i - 1;
254:         }
255:     }
256: 
257:     return $i - 1;
258: }
259: 
260: ?>
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0