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