1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: function checkExistingPlugin($db, $sPluginname) {
25: global $cfg;
26:
27:
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: 69: 70: 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: );
94:
95: foreach ($aStandardvalues as $aData) {
96: $sql = "SELECT `value` FROM `%s` WHERE `type` = '%s' AND `name` = '%s'";
97: $db->query(sprintf($sql, $table, $aData['type'], $aData['name']));
98: if ($db->nextRecord()) {
99: $sValue = $db->f('value');
100: if ($sValue == '') {
101: $sql = "UPDATE `%s` SET `value` = '%s' WHERE `type` = '%s' AND `name` = '%s'";
102: $sql = sprintf($sql, $table, $aData['value'], $aData['type'], $aData['name']);
103: $db->query($sql);
104: }
105: } else {
106: $sql = "INSERT INTO `%s` SET `type` = '%s', `name` = '%s', `value` = '%s'";
107: $sql = sprintf($sql, $table, $aData['type'], $aData['name'], $aData['value']);
108: $db->query($sql);
109: }
110:
111: if ($db->getErrorNumber() != 0) {
112: logSetupFailure("Unable to execute SQL statement:\n" . $sql . "\nMysql Error: " . $db->getErrorMessage() . " (" . $db->getErrorNumber() . ")");
113: }
114: }
115: }
116:
117: 118: 119: 120: 121: 122:
123: function updateContenidoVersion($db, $table, $version) {
124: $sql = "SELECT `idsystemprop` FROM `%s` WHERE `type` = 'system' AND `name` = 'version'";
125: $db->query(sprintf($sql, $db->escape($table)));
126:
127: if ($db->nextRecord()) {
128: $sql = "UPDATE `%s` SET `value` = '%s' WHERE `type` = 'system' AND `name` = 'version'";
129: $db->query(sprintf($sql, $db->escape($table), $db->escape($version)));
130: } else {
131:
132: $sql = "INSERT INTO `%s` SET `type` = 'system', `name` = 'version', `value` = '%s'";
133: $db->query(sprintf($sql, $db->escape($table), $db->escape($version)));
134: }
135: }
136:
137: 138: 139: 140: 141: 142:
143: function getContenidoVersion($db, $table) {
144: $sql = "SELECT `value` FROM `%s` WHERE `type` = 'system' AND `name` = 'version'";
145: $db->query(sprintf($sql, $db->escape($table)));
146:
147: if ($db->nextRecord()) {
148: return $db->f("value");
149: } else {
150: return false;
151: }
152: }
153:
154:
155: function updateSysadminPassword($db, $table, $password, $mail) {
156: $sql = "SELECT password FROM %s WHERE username='sysadmin'";
157: $db->query(sprintf($sql, $db->escape($table)));
158:
159: if ($db->nextRecord()) {
160: $sql = "UPDATE %s SET password='%s', email='%s' WHERE username='sysadmin'";
161: $db->query(sprintf($sql, $db->escape($table), md5($password), $mail));
162: return true;
163: } else {
164:
165: return false;
166: }
167: }
168:
169:
170: function listClients($db, $table) {
171: global $cfgClient;
172:
173: $sql = "SELECT idclient, name FROM %s";
174:
175: $db->query(sprintf($sql, $db->escape($table)));
176:
177: $clients = array();
178:
179: while ($db->nextRecord()) {
180: $frontendPath = $cfgClient[$db->f('idclient')]['path']['frontend'];
181: $htmlPath = $cfgClient[$db->f('idclient')]['path']['htmlpath'];
182: $clients[$db->f("idclient")] = array("name" => $db->f("name"), "frontendpath" => $frontendPath, "htmlpath" => $htmlPath);
183: }
184:
185: return $clients;
186: }
187:
188:
189: function updateClientPath($db, $table, $idclient, $frontendpath, $htmlpath) {
190: global $cfg, $cfgClient;
191: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.general.php');
192:
193: updateClientCache($idclient, $htmlpath, $frontendpath);
194: }
195:
196:
197: function stripLastSlash($sInput) {
198: if (substr($sInput, strlen($sInput) - 1, 1) == "/") {
199: $sInput = substr($sInput, 0, strlen($sInput) - 1);
200: }
201:
202: return $sInput;
203: }
204:
205:
206: function getSystemDirectories($bOriginalPath = false) {
207: $root_path = stripLastSlash(CON_FRONTEND_PATH);
208:
209: $root_http_path = dirname(dirname($_SERVER["PHP_SELF"]));
210: $root_http_path = str_replace("\\", "/", $root_http_path);
211:
212: $port = "";
213: $protocol = "http://";
214:
215: if ($_SERVER["SERVER_PORT"] != 80) {
216: if ($_SERVER["SERVER_PORT"] == 443) {
217: $protocol = "https://";
218: } else {
219: $port = ":" . $_SERVER["SERVER_PORT"];
220: }
221: }
222:
223: $root_http_path = $protocol . $_SERVER["SERVER_NAME"] . $port . $root_http_path;
224:
225: if (substr($root_http_path, strlen($root_http_path) - 1, 1) == "/") {
226: $root_http_path = substr($root_http_path, 0, strlen($root_http_path) - 1);
227: }
228:
229: if ($bOriginalPath == true) {
230: return array($root_path, $root_http_path);
231: }
232:
233: if (isset($_SESSION["override_root_path"])) {
234: $root_path = $_SESSION["override_root_path"];
235: }
236:
237: if (isset($_SESSION["override_root_http_path"])) {
238: $root_http_path = $_SESSION["override_root_http_path"];
239: }
240:
241: $root_path = stripLastSlash($root_path);
242: $root_http_path = stripLastSlash($root_http_path);
243:
244: return array($root_path, $root_http_path);
245: }
246:
247:
248: function findSimilarText($string1, $string2) {
249: for ($i = 0; $i < strlen($string1); $i++) {
250: if (substr($string1, 0, $i) != substr($string2, 0, $i)) {
251: return $i - 1;
252: }
253: }
254:
255: return $i - 1;
256: }
257:
258: ?>