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_transport', 'value' => 'smtp'),
75: array('type' => 'system', 'name' => 'mail_sender_name', 'value' => 'CONTENIDO Backend'),
76: array('type' => 'system', 'name' => 'mail_sender', 'value' => 'info@contenido.org'),
77: array('type' => 'system', 'name' => 'mail_host', 'value' => 'localhost'),
78: array('type' => 'maintenance', 'name' => 'mode', 'value' => 'disabled'),
79: array('type' => 'codemirror', 'name' => 'activated', 'value' => 'true'),
80: array('type' => 'update', 'name' => 'check', 'value' => 'false'),
81: array('type' => 'update', 'name' => 'news_feed', 'value' => 'false'),
82: array('type' => 'update', 'name' => 'check_period', 'value' => '60'),
83: array('type' => 'system', 'name' => 'clickmenu', 'value' => 'false'),
84: array('type' => 'versioning', 'name' => 'activated', 'value' => 'true'),
85: array('type' => 'versioning', 'name' => 'prune_limit', 'value' => ''),
86: array('type' => 'versioning', 'name' => 'path', 'value' => ''),
87: array('type' => 'system', 'name' => 'insite_editing_activated', 'value' => 'true'),
88: array('type' => 'backend', 'name' => 'backend_label', 'value' => ''),
89: array('type' => 'generator', 'name' => 'xhtml', 'value' => 'true'),
90: array('type' => 'generator', 'name' => 'basehref', 'value' => 'true'),
91: array('type' => 'debug', 'name' => 'module_translation_message', 'value' => 'true'),
92: array('type' => 'debug', 'name' => 'debug_for_plugins', 'value' => 'true'),
93: array('type' => 'stats', 'name' => 'tracking', 'value' => 'disabled')
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: 120: 121: 122: 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:
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: 140: 141: 142: 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: 156: 157: 158: 159: 160: 161: 162: 163: 164:
165: function updateSysadminPassword($db, $table, $password, $mail) {
166: $sql = "SELECT password FROM %s WHERE username='sysadmin'";
167: $db->query(sprintf($sql, $db->escape($table)));
168:
169: if ($db->nextRecord()) {
170: $sql = "UPDATE %s SET password='%s', email='%s' WHERE username='sysadmin'";
171: $db->query(sprintf($sql, $db->escape($table), md5($password), $mail));
172: return true;
173: } else {
174:
175: return false;
176: }
177: }
178:
179: 180: 181: 182: 183: 184: 185:
186: function listClients($db, $table) {
187: global $cfgClient;
188:
189: $sql = "SELECT idclient, name FROM %s";
190:
191: $db->query(sprintf($sql, $db->escape($table)));
192:
193: $clients = array();
194:
195: while ($db->nextRecord()) {
196: $frontendPath = $cfgClient[$db->f('idclient')]['path']['frontend'];
197: $htmlPath = $cfgClient[$db->f('idclient')]['path']['htmlpath'];
198: $clients[$db->f("idclient")] = array("name" => $db->f("name"), "frontendpath" => $frontendPath, "htmlpath" => $htmlPath);
199: }
200:
201: return $clients;
202: }
203:
204: 205: 206: 207: 208: 209: 210: 211:
212: function updateClientPath($db, $table, $idclient, $frontendpath, $htmlpath) {
213: global $cfg, $cfgClient;
214: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.general.php');
215:
216: updateClientCache($idclient, $htmlpath, $frontendpath);
217: }
218:
219: 220: 221: 222: 223: 224:
225: function stripLastSlash($sInput) {
226: if (cString::getPartOfString($sInput, cString::getStringLength($sInput) - 1, 1) == "/") {
227: $sInput = cString::getPartOfString($sInput, 0, cString::getStringLength($sInput) - 1);
228: }
229:
230: return $sInput;
231: }
232:
233: 234: 235: 236: 237: 238:
239: function getSystemDirectories($bOriginalPath = false) {
240: $root_path = stripLastSlash(CON_FRONTEND_PATH);
241:
242: $root_http_path = dirname(dirname($_SERVER["REQUEST_URI"]));
243: $root_http_path = str_replace("\\", "/", $root_http_path);
244:
245: $port = "";
246: $protocol = "http://";
247:
248: if ($_SERVER["SERVER_PORT"] != 80) {
249: if ($_SERVER["SERVER_PORT"] == 443) {
250: $protocol = "https://";
251: } else {
252: $port = ":" . $_SERVER["SERVER_PORT"];
253: }
254: }
255:
256: $root_http_path = $protocol . $_SERVER["SERVER_NAME"] . $port . $root_http_path;
257:
258: if (cString::getPartOfString($root_http_path, cString::getStringLength($root_http_path) - 1, 1) == "/") {
259: $root_http_path = cString::getPartOfString($root_http_path, 0, cString::getStringLength($root_http_path) - 1);
260: }
261:
262: if ($bOriginalPath == true) {
263: return array($root_path, $root_http_path);
264: }
265:
266: if (isset($_SESSION["override_root_path"])) {
267: $root_path = $_SESSION["override_root_path"];
268: }
269:
270: if (isset($_SESSION["override_root_http_path"])) {
271: $root_http_path = $_SESSION["override_root_http_path"];
272: }
273:
274: $root_path = stripLastSlash($root_path);
275: $root_http_path = stripLastSlash($root_http_path);
276:
277: return array($root_path, $root_http_path);
278: }
279:
280: 281: 282: 283: 284: 285: 286:
287: function findSimilarText($string1, $string2) {
288: for ($i = 0; $i < cString::getStringLength($string1); $i++) {
289: if (cString::getPartOfString($string1, 0, $i) != cString::getPartOfString($string2, 0, $i)) {
290: return $i - 1;
291: }
292: }
293:
294: return $i - 1;
295: }
296:
297: ?>