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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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:     );
 95: 
 96:     foreach ($aStandardvalues as $aData) {
 97:         $sql = "SELECT `value` FROM `%s` WHERE `type` = '%s' AND `name` = '%s'";
 98:         $db->query(sprintf($sql, $table, $aData['type'], $aData['name']));
 99:         if ($db->nextRecord()) {
100:             $sValue = $db->f('value');
101:             if ($sValue == '') {
102:                 $sql = "UPDATE `%s` SET `value` = '%s' WHERE `type` = '%s' AND `name` = '%s'";
103:                 $sql = sprintf($sql, $table, $aData['value'], $aData['type'], $aData['name']);
104:                 $db->query($sql);
105:             }
106:         } else {
107:             $sql = "INSERT INTO `%s` SET `type` = '%s', `name` = '%s', `value` = '%s'";
108:             $sql = sprintf($sql, $table, $aData['type'], $aData['name'], $aData['value']);
109:             $db->query($sql);
110:         }
111: 
112:         if ($db->getErrorNumber() != 0) {
113:             logSetupFailure("Unable to execute SQL statement:\n" . $sql . "\nMysql Error: " . $db->getErrorMessage() . " (" . $db->getErrorNumber() . ")");
114:         }
115:     }
116: }
117: 
118: /**
119:  * Updates contenido version in given table
120:  * @param  cDb $db
121:  * @param  string  $table  DB table name
122:  * @param  string  $version  Version
123:  */
124: function updateContenidoVersion($db, $table, $version) {
125:     $sql = "SELECT `idsystemprop` FROM `%s` WHERE `type` = 'system' AND `name` = 'version'";
126:     $db->query(sprintf($sql, $db->escape($table)));
127: 
128:     if ($db->nextRecord()) {
129:         $sql = "UPDATE `%s` SET `value` = '%s' WHERE `type` = 'system' AND `name` = 'version'";
130:         $db->query(sprintf($sql, $db->escape($table), $db->escape($version)));
131:     } else {
132:         //$id = $db->nextid($table);
133:         $sql = "INSERT INTO `%s` SET `type` = 'system', `name` = 'version', `value` = '%s'";
134:         $db->query(sprintf($sql, $db->escape($table), $db->escape($version)));
135:     }
136: }
137: 
138: /**
139:  * Returns current version
140:  * @param  cDb $db
141:  * @param  string  $table  DB table name
142:  * @return string
143:  */
144: function getContenidoVersion($db, $table) {
145:     $sql = "SELECT `value` FROM `%s` WHERE `type` = 'system' AND `name` = 'version'";
146:     $db->query(sprintf($sql, $db->escape($table)));
147: 
148:     if ($db->nextRecord()) {
149:         return $db->f("value");
150:     } else {
151:         return false;
152:     }
153: }
154: 
155: // @FIXME: Comment me plz!
156: function updateSysadminPassword($db, $table, $password, $mail) {
157:     $sql = "SELECT password FROM %s WHERE username='sysadmin'";
158:     $db->query(sprintf($sql, $db->escape($table)));
159: 
160:     if ($db->nextRecord()) {
161:         $sql = "UPDATE %s SET password='%s', email='%s' WHERE username='sysadmin'";
162:         $db->query(sprintf($sql, $db->escape($table), md5($password), $mail));
163:         return true;
164:     } else {
165: 
166:         return false;
167:     }
168: }
169: 
170: // @FIXME: Comment me plz!
171: function listClients($db, $table) {
172:     global $cfgClient;
173: 
174:     $sql = "SELECT idclient, name FROM %s";
175: 
176:     $db->query(sprintf($sql, $db->escape($table)));
177: 
178:     $clients = array();
179: 
180:     while ($db->nextRecord()) {
181:         $frontendPath = $cfgClient[$db->f('idclient')]['path']['frontend'];
182:         $htmlPath = $cfgClient[$db->f('idclient')]['path']['htmlpath'];
183:         $clients[$db->f("idclient")] = array("name" => $db->f("name"), "frontendpath" => $frontendPath, "htmlpath" => $htmlPath);
184:     }
185: 
186:     return $clients;
187: }
188: 
189: // @FIXME: Comment me plz!
190: function updateClientPath($db, $table, $idclient, $frontendpath, $htmlpath) {
191:     global $cfg, $cfgClient;
192:     checkAndInclude($cfg['path']['contenido'] . 'includes/functions.general.php');
193: 
194:     updateClientCache($idclient, $htmlpath, $frontendpath);
195: }
196: 
197: // @FIXME: Comment me plz!
198: function stripLastSlash($sInput) {
199:     if (substr($sInput, strlen($sInput) - 1, 1) == "/") {
200:         $sInput = substr($sInput, 0, strlen($sInput) - 1);
201:     }
202: 
203:     return $sInput;
204: }
205: 
206: // @FIXME: Comment me plz!
207: function getSystemDirectories($bOriginalPath = false) {
208:     $root_path = stripLastSlash(CON_FRONTEND_PATH);
209: 
210:     $root_http_path = dirname(dirname($_SERVER["PHP_SELF"]));
211:     $root_http_path = str_replace("\\", "/", $root_http_path);
212: 
213:     $port = "";
214:     $protocol = "http://";
215: 
216:     if ($_SERVER["SERVER_PORT"] != 80) {
217:         if ($_SERVER["SERVER_PORT"] == 443) {
218:             $protocol = "https://";
219:         } else {
220:             $port = ":" . $_SERVER["SERVER_PORT"];
221:         }
222:     }
223: 
224:     $root_http_path = $protocol . $_SERVER["SERVER_NAME"] . $port . $root_http_path;
225: 
226:     if (substr($root_http_path, strlen($root_http_path) - 1, 1) == "/") {
227:         $root_http_path = substr($root_http_path, 0, strlen($root_http_path) - 1);
228:     }
229: 
230:     if ($bOriginalPath == true) {
231:         return array($root_path, $root_http_path);
232:     }
233: 
234:     if (isset($_SESSION["override_root_path"])) {
235:         $root_path = $_SESSION["override_root_path"];
236:     }
237: 
238:     if (isset($_SESSION["override_root_http_path"])) {
239:         $root_http_path = $_SESSION["override_root_http_path"];
240:     }
241: 
242:     $root_path = stripLastSlash($root_path);
243:     $root_http_path = stripLastSlash($root_http_path);
244: 
245:     return array($root_path, $root_http_path);
246: }
247: 
248: // @FIXME: Comment me plz!
249: function findSimilarText($string1, $string2) {
250:     for ($i = 0; $i < strlen($string1); $i++) {
251:         if (substr($string1, 0, $i) != substr($string2, 0, $i)) {
252:             return $i - 1;
253:         }
254:     }
255: 
256:     return $i - 1;
257: }
258: 
259: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen