Source for file control-panel.php

Documentation is available at control-panel.php

  1. <?php
  2. /* ******************************************************************** */
  3. /* CATALYST PHP Source Code */
  4. /* -------------------------------------------------------------------- */
  5. /* This program is free software; you can redistribute it and/or modify */
  6. /* it under the terms of the GNU General Public License as published by */
  7. /* the Free Software Foundation; either version 2 of the License, or */
  8. /* (at your option) any later version. */
  9. /* */
  10. /* This program is distributed in the hope that it will be useful, */
  11. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  12. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  13. /* GNU General Public License for more details. */
  14. /* */
  15. /* You should have received a copy of the GNU General Public License */
  16. /* along with this program; if not, write to: */
  17. /* The Free Software Foundation, Inc., 59 Temple Place, Suite 330, */
  18. /* Boston, MA 02111-1307 USA */
  19. /* -------------------------------------------------------------------- */
  20. /* */
  21. /* Filename: control-panel.php */
  22. /* Author: Paul Waite */
  23. /* Description: Axyl control panel */
  24. /* */
  25. /* ******************************************************************** */
  26. /** @package core */$LIBDIR = "/lib";
  27.  
  28. // Axyl installation settings..
  29. $AXYL_HOME = "";
  30. $AXYL_CONF = "/etc/axyl/axyl.conf";
  31. if (file_exists($AXYL_CONF)) {
  32. $result = exec("grep \"AXYL_HOME=\" $AXYL_CONF");
  33. if ($result != "") {
  34. $bits = explode("=", $result);
  35. if (is_dir($bits[1])) {
  36. $AXYL_HOME = $bits[1];
  37. }
  38. }
  39. }
  40.  
  41. // ----------------------------------------------------------------------
  42. // Include required modules..
  43.  
  44. /** Sundry contants & defs */
  45. ("constants.php");
  46. /** Renderable module defs */
  47. ("renderable.php");
  48. /** Form handling */
  49. ("form-defs.php");
  50. /** Utilities */
  51. ("utils.php");
  52. /** Debugger defs */
  53. ("debugger.php");
  54. /** Record maintainer module */
  55. ("recmaint-defs.php");
  56. /** Application setup */
  57. ("application-defs.php");
  58.  
  59. // ----------------------------------------------------------------------
  60. // FUNCTIONS
  61.  
  62. /**
  63. * Determine the index of Nth database entry..
  64. * @access private
  65. */
  66. function getdbindex($Nth) {
  67. global $app;
  68. $dbix = -1; $dbpos = 0;
  69. for ($ix = 0; $ix < count($app->settings); $ix++) {
  70. $setting = $app->settings[$ix];
  71. if ($setting->name == "database") {
  72. if ($dbpos == $Nth) {
  73. $dbix = $ix;
  74. break;
  75. }
  76. else {
  77. $dbpos += 1;
  78. }
  79. }
  80. }
  81. return $dbix;
  82. }
  83. /**
  84. * Determine the index of last database entry..
  85. * @access private
  86. */
  87. function getlastdbindex() {
  88. global $app;
  89. $dbix = -1;
  90. for ($ix = 0; $ix < count($app->settings); $ix++) {
  91. $setting = $app->settings[$ix];
  92. if ($setting->name == "database") {
  93. $dbix = $ix;
  94. }
  95. }
  96. return $dbix;
  97. }
  98. /**
  99. * Delete the Nth database entry. Database entries are numbered
  100. * from zero (first database entry) upwards..
  101. * @access private
  102. */
  103. function deletedbentry($Nth) {
  104. global $app;
  105. $dbix = getdbindex($Nth);
  106. if ($dbix != -1) {
  107. $setting = $app->settings[$dbix];
  108. if ($setting->name == "database") {
  109. unset($app->settings[$dbix]);
  110. }
  111. }
  112. return $dbix;
  113. }
  114.  
  115. // ----------------------------------------------------------------------
  116. // CONVERSION OF OLD APPLICATION.PHP FILE TO NEW XML SCHEMA
  117.  
  118. $error = false;
  119. $user_msg = "";
  120. $appfile = new inputfile("application.php");
  121. if ($appfile->opened) {
  122. $appfile->readall();
  123. $appfile->closefile();
  124. $appstuff = $appfile->content;
  125. if (strstr($appstuff, "\$TEMPLATESDIR =")) {
  126. if (file_exists("$AXYL_HOME/lib/default-application.xml")) {
  127. copy("application.php", "application.php.bak");
  128. if (file_exists("application.php.bak")) {
  129.  
  130. if (is_writeable("application.php")) {
  131. copy("$AXYL_HOME/lib/application.php", "application.php");
  132. copy("$AXYL_HOME/lib/default-application.xml", "application.xml");
  133.  
  134. if (file_exists("application.xml")) {
  135.  
  136. $app = new application("application.xml");
  137. //echo "converting..<br>";
  138. // DEFINITIONS
  139. if (preg_match("/define\(\"APP_NAME\",[\s]*\"(.*?)\"/", $appstuff, $matches)) {
  140. $app->definitions["APP_NAME"] = $matches[1];
  141. //echo "setting APP_NAME to [" . $matches[1] . "]<br>";
  142. }
  143. if (preg_match("/define\(\"APP_PREFIX\",[\s]*\"(.*?)\"/", $appstuff, $matches)) {
  144. $app->definitions["APP_PREFIX"] = $matches[1];
  145. //echo "setting APP_PREFIX to [" . $matches[1] . "]<br>";
  146. }
  147.  
  148. // GLOBALS
  149. if (preg_match("/^[$]TEMPLATESDIR[\s]*\=[\s]*\"(.*?)\"/m", $appstuff, $matches)) {
  150. $app->globals["TEMPLATESDIR"] = $matches[1];
  151. //echo "setting TEMPLATESDIR to [" . $matches[1] . "]<br>";
  152. }
  153. if (preg_match("/^[$]IMAGESDIR[\s]*\=[\s]*\"(.*?)\"/m", $appstuff, $matches)) {
  154. $app->globals["IMAGESDIR"] = $matches[1];
  155. //echo "setting IMAGESDIR to [" . $matches[1] . "]<br>";
  156. }
  157. if (preg_match("/^[$]WEBMASTER_PERSON[\s]*\=[\s]*\"(.*?)\"/m", $appstuff, $matches)) {
  158. $app->globals["WEBMASTER_PERSON"] = $matches[1];
  159. //echo "setting WEBMASTER_PERSON to [" . $matches[1] . "]<br>";
  160. }
  161. if (preg_match("/^[$]WEBMASTER_EMAIL[\s]*\=[\s]*\"(.*?)\"/m", $appstuff, $matches)) {
  162. $app->globals["WEBMASTER_EMAIL"] = $matches[1];
  163. //echo "setting WEBMASTER_EMAIL to [" . $matches[1] . "]<br>";
  164. }
  165.  
  166. // SETTINGS
  167. if (preg_match("/^[$]RESPONSE->set_encoding\(\"(.*?)\"\)/m", $appstuff, $matches)) {
  168. $app->setparameter($matches[1], "encoding", "encoding");
  169. //echo "setting char encoding to [" . $matches[1] . "]<br>";
  170. }
  171. //else {
  172. // echo "char encoding defaulted<br>";
  173. //}
  174.  
  175.  
  176. if (preg_match("/^[$]RESPONSE->set_blocked_ips\((.*?)\)/m", $appstuff, $matches)) {
  177. $app->setparameter($matches[1], "badips", "badips");
  178. //echo "setting blocked ips to [" . $matches[1] . "]<br>";
  179. }
  180. //else {
  181. // echo "blocked ips defaulted<br>";
  182. //}
  183.  
  184.  
  185. if (preg_match("/^[$]RESPONSE->set_sessiontype\((.*?)\)/m", $appstuff, $matches)) {
  186. $app->setparameter(($matches[1] == "SESS_DATABASE_BACKED"), "database_backed", "database_backed");
  187. //echo "setting database-backed is " . ($matches[1] == "SESS_DATABASE_BACKED" ? "true" : "false") . "<br>";
  188. }
  189.  
  190. if (preg_match("/^[$]RESPONSE->set_lifetime\((.*?)\)/m", $appstuff, $matches)) {
  191. switch ($matches[1]) {
  192. case "SESS_FOREVER": $life = 315360000; break;
  193. case "SESS_1_YEAR": $life = 31536000; break;
  194. case "SESS_1_MONTH": $life = 2592000; break;
  195. case "SESS_1_WEEK": $life = 604800; break;
  196. case "SESS_1_DAY": $life = 86400; break;
  197. case "SESS_12_HOURS": $life = 43200; break;
  198. case "SESS_8_HOURS": $life = 28800; break;
  199. case "SESS_4_HOURS": $life = 14400; break;
  200. case "SESS_1_HOUR": $life = 3600; break;
  201. case "SESS_20_MINS": $life = 1200; break;
  202. case "SESS_BROWSER_LIFETIME": $life = -1; break;
  203. case "SESS_ZERO_LIFETIME": $life = 0; break;
  204. default: $life = -1;
  205. }
  206. $app->setparameter($life, "lifetime", "lifetime");
  207. //echo "setting cookie life to [" . $matches[1] . "($life)]<br>";
  208. }
  209.  
  210. if (preg_match("/^[$]RESPONSE->set_cookiename\((.*?)\)/m", $appstuff, $matches)) {
  211. if ($matches[1] != "APP_PREFIX . \"_session_id\"") {
  212. $app->setparameter($matches[1], "cookiename", "cookiename");
  213. //echo "setting cookiename to [" . $matches[1] . "]<br>";
  214. }
  215. //else {
  216. // echo "setting cookiename to default<br>";
  217. //}
  218. }
  219.  
  220. if (preg_match("/^[$]RESPONSE->set_keep\((.*?)\)/m", $appstuff, $matches)) {
  221. $app->setparameter(($matches[1] == "KEEP_ENABLED"), "keep", "keep");
  222. //echo "setting keep status " . ($matches[1] == "KEEP_ENABLED" ? "ON" : "OFF") . "<br>";
  223. }
  224.  
  225. if (preg_match("/^[$]RESPONSE->globalise_all\(\)/m", $appstuff, $matches)) {
  226. $app->setparameter(true, "globalise", "globalise");
  227. //echo "setting globalise all ON<br>";
  228. }
  229. else {
  230. $app->setparameter(false, "globalise", "globalise");
  231. //echo "setting globalise all OFF<br>";
  232. }
  233.  
  234. if (preg_match("/^[$]RESPONSE->set_compression_type\((.*?)\)/m", $appstuff, $matches)) {
  235. switch ($matches[1]) {
  236. case "NO_COMPRESSION": $comp = 0; break;
  237. case "BUILTIN_COMPRESSION": $comp = 1; break;
  238. case "CUSTOM_COMPRESSION": $comp = 2; break;
  239. default: $comp = 0;
  240. }
  241. $app->setparameter($comp, "compression_type", "compression_type");
  242. //echo "setting compression type to [" . $matches[1] . "($comp)]<br>";
  243. }
  244.  
  245. if (preg_match("/^[$]RESPONSE->set_compression_minsize\((.*?)\)/m", $appstuff, $matches)) {
  246. $app->setparameter($matches[1], "compression_threshold", "compression_threshold");
  247. //echo "setting compression threshold to [" . $matches[1] . "]<br>";
  248. }
  249. else {
  250. //echo "compression threshold is defaulted (0)<br>";
  251. }
  252.  
  253. if (preg_match("/^[$]RESPONSE->set_buffering_mode\((.*?)\)/m", $appstuff, $matches)) {
  254. $app->setparameter(($matches[1] == "BUFFERED"), "buffered_output", "buffered_output");
  255. //echo "setting buffered output " . ($matches[1] == "BUFFERED" ? "ON" : "OFF") . "<br>";
  256. }
  257.  
  258. if (preg_match("/^[$]RESPONSE->set_page_expirysecs\((.*?)\)/m", $appstuff, $matches)) {
  259. $app->setparameter($matches[1], "expiry", "expiry");
  260. //echo "setting page expiry to [" . $matches[1] . "]<br>";
  261. }
  262. //else {
  263. // echo "compression page expiry is defaulted (-1)<br>";
  264. //}
  265.  
  266.  
  267. if (preg_match("/^[$]RESPONSE->set_authentication_type\((.*?)\)/m", $appstuff, $matches)) {
  268. switch ($matches[1]) {
  269. case "NO_AUTHENTICATION": $auth = 0; break;
  270. case "HTTP_AUTHENTICATION": $auth = 1; break;
  271. case "FORM_AUTHENTICATION": $auth = 2; break;
  272. default: $auth = 2;
  273. }
  274. $app->setparameter($auth, "authtype", "authtype");
  275. //echo "setting authentication type to [" . $matches[1] . "($auth)]<br>";
  276. }
  277.  
  278. if (preg_match("/^[$]RESPONSE->on_authentication_fail\((.*?)(,(.*?))*?\)/m", $appstuff, $matches)) {
  279. switch ($matches[1]) {
  280. case "AUTHFAIL_DIE_MSG": $authf = 0; break;
  281. case "AUTHFAIL_DIE_SILENT": $authf = 1; break;
  282. case "AUTHFAIL_REDIRECT": $authf = 2; break;
  283. case "AUTHFAIL_GUEST": $authf = 3; break;
  284. default: $authf = 0;
  285. }
  286. $app->setparameter($authf, "authfail", "authfailopt");
  287. //echo "setting auth fail option to [" . $matches[1] . "($authf)]<br>";
  288. }
  289.  
  290. if (isset($matches[3])) {
  291. $authurl = preg_replace("/['\"]/", "", $matches[3]);
  292. $app->setparameter($authurl, "authfail", "authfailurl");
  293. //echo "setting auth fail URL to [$authurl]<br>";
  294. }
  295. //else {
  296. // echo "no URL<br>";
  297. //}
  298.  
  299.  
  300. if (preg_match("/^[$]RESPONSE->on_logins_exceeded\((.*?)(,(.*?))*?\)/m", $appstuff, $matches)) {
  301. switch ($matches[1]) {
  302. case "SESS_ALLOW": $logexc = 0; break;
  303. case "SESS_ALLOW_CULL": $logexc = 1; break;
  304. case "SESS_BLOCK_MSG": $logexc = 2; break;
  305. case "SESS_BLOCK_SILENT": $logexc = 3; break;
  306. case "SESS_BLOCK_REDIRECT": $logexc = 4; break;
  307. case "SESS_BLOCK_GUEST": $logexc = 5; break;
  308. default: $logexc = 0;
  309. }
  310. $app->setparameter($logexc, "loglimit", "logexceedopt");
  311. //echo "setting logins exceeded option to [" . $matches[1] . "]<br>";
  312. }
  313.  
  314. if (isset($matches[3])) {
  315. $logexcurl = preg_replace("/['\"]/", "", $matches[3]);
  316. $app->setparameter($logexcurl, "loglimit", "logexceedurl");
  317. //echo "setting logins exceeded URL to [$logexcurl]<br>";
  318. }
  319. //else {
  320. // echo "no URL<br>";
  321. //}
  322.  
  323.  
  324. if (preg_match("/^[$]RESPONSE->set_persistent_hosts\((.*?)\)/m", $appstuff, $matches)) {
  325. if ($matches[1] != "\"\"") {
  326. $app->setparameter($matches[1], "permhosts", "permhosts");
  327. //echo "setting persistent hosts list to [" . $matches[1] . "]<br>";
  328. }
  329. //else {
  330. // echo "null persistent hosts list.<br>";
  331. //}
  332. }
  333. //else {
  334. // echo "no persistent hosts.<br>";
  335. //}
  336.  
  337.  
  338. $patt = "RESPONSE->add_database\(\n";
  339. $patt .= "[\s]*?\"(.*?)\",.*\n"; // DB type
  340. $patt .= "[\s]*?\"(.*?)\",.*\n"; // name
  341. $patt .= "[\s]*?\"(.*?)\",.*\n"; // user
  342. $patt .= "[\s]*?\"(.*?)\",.*\n"; // password
  343. $patt .= "[\s]*?\"(.*?)\",.*\n"; // host
  344. $patt .= "[\s]*?\"(.*?)\".*\n"; // port
  345. $patt .= "(([\s])*?(DEFAULT_DATASOURCE))*"; // default flag
  346. // Purge existing database settings..
  347. $newsettings = array();
  348. for ($ix=0; $ix < count($app->settings); $ix++) {
  349. $setting = $app->settings[$ix];
  350. if ($setting->name != "database") {
  351. $newsettings[] = $setting;
  352. }
  353. }
  354. $app->settings = $newsettings;
  355.  
  356. preg_match_all("/$patt/", $appstuff, $matches);
  357. for ($i=0; $i < count($matches[0]); $i++) {
  358. /*
  359. echo "database defs:<br>";
  360. echo " type: " . $matches[1][$i] . "<br>";
  361. echo " name: " . $matches[2][$i] . "<br>";
  362. echo " user: " . $matches[3][$i] . "<br>";
  363. echo " pass: " . $matches[4][$i] . "<br>";
  364. echo " host: " . $matches[5][$i] . "<br>";
  365. echo " port: " . $matches[6][$i] . "<br>";
  366. */
  367. $dbsetting = new setting("database", "add_database");
  368. $parameter = new parameter("type", "string");
  369. $parameter->setvalue($matches[1][$i]);
  370. $dbsetting->addparameter($parameter->name, $parameter);
  371.  
  372. $parameter = new parameter("name", "string");
  373. $parameter->setvalue($matches[2][$i]);
  374. $dbsetting->addparameter($parameter->name, $parameter);
  375.  
  376. $parameter = new parameter("user", "string");
  377. $parameter->setvalue($matches[3][$i]);
  378. $dbsetting->addparameter($parameter->name, $parameter);
  379.  
  380. $parameter = new parameter("password", "string");
  381. $parameter->setvalue($matches[4][$i]);
  382. $dbsetting->addparameter($parameter->name, $parameter);
  383.  
  384. $parameter = new parameter("host", "string");
  385. $parameter->setvalue($matches[5][$i]);
  386. $dbsetting->addparameter($parameter->name, $parameter);
  387.  
  388. $parameter = new parameter("port", "integer");
  389. $parameter->setvalue($matches[6][$i]);
  390. $dbsetting->addparameter($parameter->name, $parameter);
  391. if (isset($matches[9][$i]) && $matches[9][$i] == "DEFAULT_DATASOURCE") {
  392. $defaultdb = $dbsetting;
  393. //echo "default DB<br>";
  394. }
  395. else {
  396. $secdbs[] = $dbsetting;
  397. //echo "secondary DB<br>";
  398. }
  399. } // for
  400.  
  401. if (isset($defaultdb)) {
  402. $app->settings[] = $defaultdb;
  403. }
  404. if (isset($secdbs)) {
  405. foreach ($secdbs as $db) {
  406. $app->settings[] = $db;
  407. }
  408. }
  409.  
  410. // Save all conversion changes..
  411. $app->save();
  412. $user_msg = "Your application configuration has been converted to XML format. ";
  413. $user_msg .= "The old file has been saved as 'application.php.bak'. A new file ";
  414. $user_msg .= "'application.xml' has been created, which should only ever be ";
  415. $user_msg .= "changed by using this Control Panel.";
  416. }
  417. else {
  418. $error = true;
  419. $user_msg = "Conversion aborted due to problems creating XML file."
  420. . "<br>Please fix & retry.";
  421. }
  422. }
  423. else {
  424. $error = true;
  425. $user_msg = "Conversion aborted. File 'application.php must be "
  426. . "writeable by webserver.<br>Please fix & retry.";
  427. }
  428. } // // application.php.bak exists
  429. else {
  430. $error = true;
  431. $user_msg = "Conversion aborted due to problems backing up data."
  432. . "<br>Please fix & retry.";
  433. }
  434. } // lib/default-application.xml exists
  435. } // old format file
  436. } // appfile opened
  437. // ----------------------------------------------------------------------
  438. // FAILSAFE TO DEFAULT
  439. // Failsafe - if no application XML file, copy default into place..
  440.  
  441. if (!file_exists("application.xml")) {
  442. if (file_exists("$AXYL_HOME/lib/default-application.xml")) {
  443. copy("$AXYL_HOME/lib/default-application.xml", "application.xml");
  444. }
  445. }
  446.  
  447. // ----------------------------------------------------------------------
  448. // READ XML APPLICATION SETTINGS
  449. // Read in current application..
  450.  
  451. if (file_exists("application.xml") && is_writeable("application.xml")) {
  452. $app = new application();
  453. }
  454. else {
  455. $error = true;
  456. $user_msg = "Error: Please make 'application.xml' writeable to the webserver.";
  457. }
  458.  
  459. // ----------------------------------------------------------------------
  460. // SYNCHRONIZE
  461. // Make sure that the current application XML file has all the required
  462. // defs, globals & settings. For this we have to refer to the Axyl HOME
  463. // file default-application.xml, so find Axyl HOME first of all..
  464.  
  465. if (!$error) {
  466. if (is_dir($AXYL_HOME)) {
  467. $defaultapp = new application("$AXYL_HOME/lib/default-application.xml");
  468. $synced = $app->synchronize($defaultapp);
  469. if ($synced) {
  470. $app->save();
  471. $app = new application();
  472. }
  473. }
  474. }
  475.  
  476. // ----------------------------------------------------------------------
  477. // POST ACTION
  478. // Check if they opted to set things to default..
  479.  
  480. if (!$error) {
  481. if (isset($_default_x)) {
  482. if (file_exists("$AXYL_HOME/lib/default-application.xml")) {
  483. copy("$AXYL_HOME/lib/default-application.xml", "application.xml");
  484. $app = new application();
  485. }
  486. }
  487. elseif (isset($_recmaintpost_form) && $_recmaintpost_form == "cpform") {
  488. /*
  489. // DEBUGGING: POSTED VARS DUMP
  490. $s .= "<table border=1 cellpadding=2 cellspacing=0>";
  491. if (isset($HTTP_POST_VARS)) {
  492. $s .= "<tr><td colspan=2><h4>POSTed Vars</h4></td></tr>";
  493. reset($HTTP_POST_VARS);
  494. while (list($key, $val) = each($HTTP_POST_VARS)) {
  495. $s .= "<tr><td>$key</td><td>" . displayvar($val) . "</td></tr>";
  496. }
  497. }
  498. $s .= "</table>";
  499. */
  500. // Database Definition Deletes
  501. if (isset($_recmaintpost_dels) && $_recmaintpost_dels != "") {
  502. $delids = explode(FIELD_DELIM, $_recmaintpost_dels);
  503. $delixs = array();
  504. foreach ($delids as $dbid) {
  505. $ix = getdbindex($dbid);
  506. if ($ix != -1) {
  507. $delixs[] = $ix;
  508. }
  509. }
  510. foreach ($delixs as $ix) {
  511. unset($app->settings[$ix]);
  512. }
  513. }
  514.  
  515. // DEFINITIONS
  516. $app->definitions["APP_PREFIX"] = $cp_app_prefix;
  517. $app->definitions["APP_NAME"] = $cp_app_name;
  518.  
  519. // GLOBALS
  520. $app->globals["TEMPLATESDIR"] = $cp_templatesdir;
  521. $app->globals["IMAGESDIR"] = $cp_imagesdir;
  522. $app->globals["CACHEDIR"] = $cp_cachedir;
  523. $app->globals["CATALOGDIR"] = $cp_catalogdir;
  524. $app->globals["CMDIR"] = $cp_cmdir;
  525. $app->globals["INCDIR"] = $cp_incdir;
  526. $app->globals["WEBMASTER_PERSON"] = $cp_webmaster_person;
  527. $app->globals["WEBMASTER_EMAIL"] = $cp_webmaster_email;
  528. $app->globals["SQL_EXEC_THRESHOLD"] = $cp_sql_exec_threshold;
  529.  
  530. // DATABASES
  531. if (isset($_recmaintpost_data) && $_recmaintpost_data != "") {
  532. $dbrecs = explode(RECORD_DELIM, $_recmaintpost_data);
  533. $dbfields = explode(",", $_recmaintpost_flds);
  534. foreach ($dbrecs as $dbrec) {
  535. $dbvalues = explode(FIELD_DELIM, $dbrec);
  536. $dbid = array_shift($dbvalues);
  537. $dbsetting = new setting("database", "add_database");
  538. $pos = 0;
  539. foreach ($dbfields as $dbfield) {
  540. $value = $dbvalues[$pos++];
  541. switch ($dbfield) {
  542. case "dbname":
  543. $parameter = new parameter("name", "string");
  544. $dbname = $value;
  545. break;
  546. case "dbtype":
  547. $parameter = new parameter("type", "string");
  548. break;
  549. case "dbuser":
  550. $parameter = new parameter("user", "string");
  551. break;
  552. case "dbpassword":
  553. $parameter = new parameter("password", "string");
  554. break;
  555. case "dbhost":
  556. $parameter = new parameter("host", "string");
  557. break;
  558. case "dbport":
  559. $parameter = new parameter("port", "integer");
  560. break;
  561. }
  562. $parameter->setvalue($value);
  563. $dbsetting->addparameter($parameter->name, $parameter);
  564. }
  565.  
  566. $ix = get_settingindex($app, $dbname);
  567. if ($ix > -1) {
  568. $app->settings[$ix] = $dbsetting;
  569. }
  570. else {
  571. // Insert new database at end of existing databases
  572. // so that they stay pleasingly grouped..
  573. $lastdbix = getlastdbindex();
  574. if ($lastdbix == -1) {
  575. $app->settings[] = $dbsetting;
  576. }
  577. else {
  578. $ix = 0;
  579. $settings = array();
  580. foreach ($app->settings as $setting) {
  581. $settings[] = $setting;
  582. if ($ix == $lastdbix) {
  583. $settings[] = $dbsetting;
  584. }
  585. $ix += 1;
  586. }
  587. $app->settings = $settings;
  588. }
  589. }
  590. } // foreach dbrecs
  591. } // database save
  592. // Database ordering - determines default database
  593. elseif (isset($_recmaintpost_order) && $_recmaintpost_order != "") {
  594. $dborderings = explode(FIELD_DELIM, $_recmaintpost_order);
  595. $dbsettings = array();
  596. foreach ($dborderings as $dborder) {
  597. $ix = getdbindex($dborder);
  598. $dbsettings[] = $app->settings[$ix];
  599. }
  600. $firstdbix = getdbindex(0);
  601. for ($ix=0; $ix < count($dbsettings); $ix++) {
  602. $app->settings[$ix + $firstdbix] = $dbsettings[$ix];
  603. }
  604. }
  605.  
  606. // SETTINGS
  607. $app->setparameter($cp_dtd_html, "dtd", "dtd", "html");
  608. $app->setparameter($cp_dtd_wml, "dtd", "dtd", "wml");
  609. if (isset($cp_multilang)) {
  610. $app->setparameter(true, "multilang", "multilang");
  611. $app->setparameter("UTF-8", "encoding", "encoding");
  612. }
  613. else {
  614. $app->setparameter(false, "multilang", "multilang");
  615. $app->setparameter($cp_encoding, "encoding", "encoding");
  616. }
  617. $app->setparameter(isset($cp_database_backed), "database_backed", "database_backed");
  618. $app->setparameter($cp_permhosts, "permhosts", "permhosts");
  619. $app->setparameter($cp_cookiename, "cookiename", "cookiename");
  620. $app->setparameter($cp_lifetime, "lifetime", "lifetime");
  621. $app->setparameter(isset($cp_guest_browser_lifetime), "guest_browser_lifetime", "guest_browser_lifetime");
  622. $app->setparameter($cp_expiry, "expiry", "expiry");
  623. $app->setparameter(isset($cp_microsites_enabled), "microsites_enabled", "microsites_enabled");
  624. $app->setparameter(isset($cp_metadata_enabled), "metadata_enabled", "metadata_enabled");
  625. $app->setparameter(isset($cp_buffered_output), "buffered_output", "buffered_output");
  626. $app->setparameter($cp_compression_type, "compression_type", "compression_type");
  627. $app->setparameter($cp_compression_threshold, "compression_threshold", "compression_threshold");
  628. $app->setparameter(isset($cp_keep), "keep", "keep");
  629. $app->setparameter(isset($cp_globalise), "globalise", "globalise");
  630. $app->setparameter($cp_authtype, "authtype", "authtype");
  631. $app->setparameter($cp_authfailopt, "authfail", "authfailopt");
  632. $app->setparameter($cp_authfailurl, "authfail", "authfailurl");
  633. $app->setparameter(isset($cp_encrypted_passwords), "encrypted_passwords", "encrypted_passwords");
  634. $app->setparameter($cp_logexceedopt, "loginlimit", "logexceedopt");
  635. $app->setparameter($cp_logexceedurl, "loginlimit", "logexceedurl");
  636. $app->setparameter($cp_badips, "badips", "badips");
  637. $app->setparameter(isset($cp_debug_on), "debug_on", "debug_on");
  638. // Unpack debug classes..
  639. $debug_classes = 0;
  640. foreach ($cp_debug_classes as $class) {
  641. $debug_classes |= $class;
  642. }
  643. $app->setparameter($debug_classes, "debug_classes", "debug_classes");
  644. // Unpack debug outputs..
  645. $debug_output = 0;
  646. foreach ($cp_debug_output as $output) {
  647. $debug_output |= $output;
  648. }
  649. $app->setparameter($debug_output, "debug_output", "debug_output");
  650.  
  651. // Save it
  652. $app->save();
  653. $app = new application();
  654. }
  655. }
  656.  
  657. // ----------------------------------------------------------------------
  658. // BOILERPLATING
  659.  
  660. $s = <<< EOS
  661. <html>
  662. <head>
  663. <title>Axyl Control Panel</title>
  664. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  665. <meta name="generator" content="Catalyst IT Axyl">
  666. <style type="text/css">
  667. margin: 0px 0px 0px 0px;
  668. font-family: Verdana, Arial, Helvetica, sans-serif;
  669. color: #605728;
  670. font-size: 9pt;
  671. font-style: normal;
  672. font-weight: normal;
  673. scrollbar-face-color: #f7f7f7;
  674. scrollbar-highlight-color: #b2b1b1;
  675. scrollbar-shadow-color: #b2b1b1;
  676. scrollbar-3dlight-color: white;
  677. scrollbar-arrow-color: #c9c9c9;
  678. scrollbar-track-color: #f5f5f5;
  679. scrollbar-darkshadow-color: white;
  680. }
  681. p, td, th, ol, ul, li, input, textarea, select {
  682. font-family: Arial, Helvetica, sans-serif;
  683. font-size: 9pt;
  684. font-style: normal;
  685. font-weight: normal;
  686. color: #605728;
  687. }
  688. input, textarea, select {
  689. font-family: Arial, Helvetica, sans-serif;
  690. font-size: 9pt;
  691. font-style: normal;
  692. font-weight: normal;
  693. }
  694. p {
  695. line-height: 115%;
  696. }
  697. hr {
  698. height: 1px;
  699. color: black;
  700. margin-top: 0;
  701. margin-bottom: 0;
  702. }
  703. form {
  704. margin: 0px;
  705. padding: 0px;
  706. }
  707. a {
  708. color: #AC9D46;
  709. text-decoration: none;
  710. }
  711. a:hover {
  712. color: #AC9D46;
  713. text-decoration: underline;
  714. }
  715. a:active {
  716. color: #AC9D46;
  717. }
  718. a:visited {
  719. color: #AC9D46;
  720. }
  721. th {
  722. text-align: left;
  723. }
  724.  
  725. h1, h2, h5, h3, h4, h6 {
  726. font-family: Verdana, Arial, Helvetica, sans-serif;
  727. font-weight: bold;
  728. margin-top: 2px;
  729. margin-bottom: 2px;
  730. }
  731. h1 { color:#605728; font-size:125%; text-transform:capitalize; }
  732. h2 { color:#605728; font-size:120%; }
  733. h3 { color:#605728; font-size:115%; font-weight:bold;}
  734. h4 { color:#605728; font-size:105%; font-weight:bold;}
  735. h5 { color:#605728; font-size:100%; font-weight:bold;}
  736. h6 { color:#605728; font-size:96%; font-weight:bold;}
  737. .axform {
  738. font-family: Arial, Helvetica, sans-serif;
  739. font-size: 95%;
  740. padding: 0px;
  741. }
  742. .axcombo {
  743. font-family: Arial, Helvetica, sans-serif;
  744. font-size: 95%;
  745. height: 20px;
  746. padding-left: 2px;
  747. }
  748. .axlistbox {
  749. font-family: Arial, Helvetica, sans-serif;
  750. font-size: 95%;
  751. padding-left: 2px;
  752. }
  753. .axtxtbox {
  754. font-family: Arial, Helvetica, sans-serif;
  755. font-size: 95%;
  756. width: 250px;
  757. height: 22px;
  758. padding-left: 2px;
  759. vertical-align: middle;
  760. }
  761. .axmemo {
  762. font-family: Arial, Helvetica, sans-serif;
  763. font-size: 95%;
  764. width: 250px;
  765. height: 100px;
  766. padding-left: 2px;
  767. }
  768. .axdatetime {
  769. font-family: Arial, Helvetica, sans-serif;
  770. font-size: 95%;
  771. width: 150px;
  772. height: 22px;
  773. padding-left: 2px;
  774. }
  775. .axnumbox {
  776. font-family: Arial, Helvetica, sans-serif;
  777. font-size: 95%;
  778. width: 80px;
  779. height: 22px;
  780. padding-left: 2px;
  781. padding-right: 2px;
  782. vertical-align: middle;
  783. text-align: right;
  784. }
  785. .axchkbox {
  786. vertical-align: middle;
  787. }
  788. .axfmlbl {
  789. font-family: Arial, Helvetica, sans-serif;
  790. font-size: 95%;
  791. font-weight: normal;
  792. vertical-align: top;
  793. color: black;
  794. }
  795. .axtitle {
  796. font-family: Arial, Helvetica, sans-serif;
  797. font-size:110%;
  798. color: white;
  799. background-color: #66700F;
  800. font-weight: bold;
  801. }
  802. .axfoot {
  803. height: 12px;
  804. background-color: #66700F;
  805. }
  806. .axhdg {
  807. font-family: Arial, Helvetica, sans-serif;
  808. font-size:100%;
  809. color: white;
  810. background-color: #898437;
  811. font-weight: bold;
  812. }
  813. .axsubhdg {
  814. font-family: Arial, Helvetica, sans-serif;
  815. font-size:100%;
  816. color: white;
  817. background-color: #66700F;
  818. font-weight: bold;
  819. }
  820. .axfg {
  821. color: #605728;
  822. font-weight: normal;
  823. }
  824. .axhl {
  825. color: red;
  826. font-weight: bold;
  827. }
  828. .axerror {
  829. color: red;
  830. }
  831. .axbgwhite {
  832. color: black;
  833. background-color: white;
  834. }
  835. .axbglite {
  836. color: black;
  837. background-color: #EAEBDF;
  838. }
  839. .axbgdark {
  840. color: white;
  841. background-color: #DEDFD4;
  842. }
  843. .axbgdarker {
  844. color: white;
  845. background-color: #66700F;
  846. }
  847. </style>
  848. <script language="javascript">
  849. var keyfield = new Array();
  850. var curid = new Array();
  851. var newid = new Array();
  852. function setUTF8mode(multilang) {
  853. if (multilang) {
  854. document.forms.cpform.cp_encoding.value='UTF-8';
  855. document.forms.cpform.cp_encoding.disabled=true;
  856. }
  857. else {
  858. document.forms.cpform.cp_encoding.readonly=false;
  859. document.forms.cpform.cp_encoding.disabled=false;
  860. }
  861. return true;
  862. }
  863. </script>
  864. <script type="text/javascript" src="$LIBDIR/js/recmaint.js"></script>
  865. <script type="text/javascript" src="$LIBDIR/js/fieldvalidation.js"></script>
  866. </head>
  867. <body>
  868. EOS;
  869. // ----------------------------------------------------------------------
  870. // MAIN FORM GENERATION
  871.  
  872. // Width of large form elements..
  873.  
  874. $fullwidth = 540;
  875. $halfwidth = ceil($fullwidth * 0.50);
  876. $thirdwidth = ceil($fullwidth * 0.37);
  877. $quartwidth = ceil($fullwidth * 0.25);
  878. $ewidth = $halfwidth . "px"; // Normal text fields
  879. $awidth = $fullwidth . "px"; // Full field width
  880. $cbowidth = $quartwidth . "px"; // Normal combos
  881. $cwidth = $thirdwidth . "px"; // Wide combos
  882. // DATABASE LISTBOX
  883. // Defined early so that buttons can be registered..
  884.  
  885. $database_listbox = new form_combofield("dbid");
  886. $database_listbox->setclass("axlistbox");
  887. // Make a new record maintainer, and attach the buttons..
  888. $maintainer = new recmaintainer("cpform", $database_listbox);
  889.  
  890. $bup = new form_imagebutton("_up", "", "", "$LIBDIR/img/_up.gif", "Move up", 57, 15);
  891. $bdown = new form_imagebutton("_down", "", "", "$LIBDIR/img/_down.gif", "Move down", 57, 15);
  892. $bdel = new form_imagebutton("_del", "", "", "$LIBDIR/img/_delete.gif", "Delete database", 57, 15);
  893. $badd = new form_imagebutton("_add", "", "", "$LIBDIR/img/_add.gif", "Add new database", 57, 15);
  894. $bsave = new form_imagebutton("_save", "", "", "$LIBDIR/img/_save.gif", "Save your settings", 57, 15);
  895. $breset = new form_imagebutton("_reset", "", "", "$LIBDIR/img/_reset.gif", "Reverse your changes", 57, 15);
  896. $breset->set_onclick("document.forms.cpform.reset()");
  897. $bdef = new form_imagebutton("_default", "", "", "$LIBDIR/img/_default.gif", "Apply default configuration", 57, 15);
  898. $bdef->set_confirm_text("This will over-write the current configuration. Continue?");
  899.  
  900. // Register all relevant buttons to the maintainer..
  901. $maintainer->register_button("up" , $bup);
  902. $maintainer->register_button("down", $bdown);
  903. $maintainer->register_button("del", $bdel);
  904. $maintainer->register_button("add", $badd);
  905. $maintainer->register_button("save", $bsave);
  906.  
  907. $Tapp = new table();
  908. $Tapp->setwidth($fullwidth);
  909. $Tapp->setalign("center");
  910.  
  911. // ......................................................................
  912. // Heading
  913.  
  914. $Tapp->tr("axtitle");
  915. $Tapp->td("<b>AXYL CONTROL PANEL</b>", "axtitle");
  916. $Tapp->td_css("vertical-align:center;height:30px;padding-left:5px;");
  917. if ($user_msg != "") {
  918. $Tapp->tr("axsubhdg");
  919. $Tapp->td($user_msg, "color:#F5DD64;text-align:center;");
  920. }
  921. elseif ($synced) {
  922. $Tapp->tr("axsubhdg");
  923. $Tapp->td("The Axyl configuration structure was successfully updated.", "color:#F5DD64;text-align:center;");
  924. }
  925.  
  926. if (!$error) {
  927. // ......................................................................
  928. // Toolbar..
  929. $toolbar = array();
  930. $toolbar[] = $breset;
  931. $toolbar[] = $bdef;
  932. $toolbar[] = $bsave;
  933. $Tbar = new table("toolbar");
  934. $Tbar->tr();
  935. $tools = "";
  936. foreach ($toolbar as $tool) {
  937. $tools .= $tool->render();
  938. }
  939. $Tbar->th($tools, "text-align:right");
  940. $Tapp->tr("axbglite");
  941. $Tapp->td( $Tbar->render() );
  942.  
  943. $tbox = new form_textfield();
  944. $tbox->setstyle("width:$ewidth");
  945. $tbox->setclass("axtxtbox");
  946.  
  947. $chkbox = new form_checkbox();
  948. $chkbox->setclass("axchkbox");
  949. $chkbox->setvalue("yes");
  950. $chkbox->checked = false;
  951.  
  952. // ......................................................................
  953. // DEFINITIONS
  954. $Tapp->tr("axhdg");
  955. $Tapp->td("<b>DEFINITIONS</b>", "axhdg");
  956.  
  957. $Tin = new table("definitions");
  958. $Tin->setpadding(2);
  959.  
  960. // Installs text field in $Tin table..
  961. function entryField($label, $fieldname, &$valarray) {
  962. global $app, $Tin, $tbox, $bg;
  963. $mybox = $tbox;
  964. $bg = ($bg == "axbgdark" ? "axbglite" : "axbgdark");
  965. $Tin->tr($bg);
  966. $Tin->td( $label, "axfg" );
  967. $mybox->setvalue($valarray[$fieldname]);
  968. $Tin->td( $mybox->render("cp_" . strtolower($fieldname)) );
  969. }
  970. // Installs info row in $Tin table..
  971. function infoField($info) {
  972. global $app, $Tin, $tbox, $bg;
  973. $bg = ($bg == "axbgdark" ? "axbglite" : "axbgdark");
  974. $Tin->tr($bg);
  975. $Tin->td();
  976. $Tin->td($info, "axfg");
  977. $Tin->td_css("font-style:italic;font-size:80%");
  978. }
  979. // Installs text field in $Tin table..
  980. function integerField($label, $fieldname, &$valarray, $intlimit, $pxwidth=100) {
  981. global $app, $Tin, $tbox, $bg;
  982. $mybox = $tbox;
  983. $bg = ($bg == "axbgdark" ? "axbglite" : "axbgdark");
  984. $Tin->tr($bg);
  985. $Tin->td( $label, "axfg" );
  986. $mybox->setstyle("width:" . $pxwidth . "px");
  987. $mybox->set_onblur("limitInt(this, 0, $intlimit)");
  988. $mybox->setvalue($valarray[$fieldname]);
  989. $Tin->td( $mybox->render("cp_" . strtolower($fieldname)) );
  990. }
  991.  
  992. $bg = "axbgdark";
  993. entryField("Application Name:", "APP_NAME", $app->definitions);
  994. entryField("Application Prefix:", "APP_PREFIX", $app->definitions);
  995.  
  996. $Tin->set_width_profile("50%,50%");
  997. $Tapp->tr();
  998. $Tapp->td( $Tin->render() );
  999.  
  1000. // ......................................................................
  1001. // GLOBALS
  1002. $Tapp->tr("axhdg");
  1003. $Tapp->td("<b>GLOBALS</b>", "axhdg");
  1004.  
  1005. $Tin = new table("globals");
  1006. $Tin->setpadding(2);
  1007. $Tin->tbody("fmlook");
  1008. $bg = "axbgdark";
  1009. entryField("Templates directory:", "TEMPLATESDIR", $app->globals);
  1010. entryField("Images directory:", "IMAGESDIR", $app->globals);
  1011. entryField("Cached files directory:", "CACHEDIR", $app->globals);
  1012. entryField("Media catalog directory:", "CATALOGDIR", $app->globals);
  1013. entryField("Managed content directory:", "CMDIR", $app->globals);
  1014. entryField("Includes directory:", "INCDIR", $app->globals);
  1015. infoField(
  1016. "NB: all directories specified above should be relative to the "
  1017. . "website root directory. Additionally, if they are to be writeable "
  1018. . "then they should be under the 'var' subdirectory."
  1019. );
  1020. entryField("Webmaster name:", "WEBMASTER_PERSON", $app->globals);
  1021. entryField("Webmaster e-mail:", "WEBMASTER_EMAIL", $app->globals);
  1022.  
  1023. $Tin->set_width_profile("50%,50%");
  1024. $Tapp->tr();
  1025. $Tapp->td( $Tin->render() );
  1026.  
  1027. // ......................................................................
  1028. // SETTINGS
  1029.  
  1030.  
  1031. $Tapp->tr("axhdg");
  1032. $Tapp->td("<b>WEBSITE SETTINGS</b>", "axhdg");
  1033.  
  1034. // ......................................................................
  1035. // DTD & ENCODING
  1036. $Tapp->tr("axsubhdg");
  1037. $Tapp->td("<b>Default DTD and Encoding</b>", "axsubhdg");
  1038.  
  1039. $Tin = new table("dtd_enc");
  1040. $Tin->setpadding(2);
  1041.  
  1042. $cboHTMLDTD = new form_combofield();
  1043. $cboHTMLDTD->setclass("axcombo");
  1044. $cboHTMLDTD->additem("", "None");
  1045. $cboHTMLDTD->additem(
  1046. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"),
  1047. "HTML 3.2 Strict"
  1048. );
  1049. $cboHTMLDTD->additem(
  1050. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"),
  1051. "HTML 4.01 Transitional"
  1052. );
  1053. $cboHTMLDTD->additem(
  1054. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"),
  1055. "HTML 4.01 Strict"
  1056. );
  1057. $cboHTMLDTD->additem(
  1058. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">"),
  1059. "HTML 4.01 with Frameset"
  1060. );
  1061. $cboHTMLDTD->additem(
  1062. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">"),
  1063. "XHTML 1.0 Transitional"
  1064. );
  1065. $cboHTMLDTD->additem(
  1066. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\">"),
  1067. "XHTML 1.0 Strict"
  1068. );
  1069. $cboHTMLDTD->additem(
  1070. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\">"),
  1071. "XHTML 1.0 with Frameset"
  1072. );
  1073. $cboHTMLDTD->setvalue($app->getparameter("dtd", "dtd", "html"));
  1074.  
  1075. $cboWMLDTD = new form_combofield();
  1076. $cboWMLDTD->setclass("axcombo");
  1077. //$cboWMLDTD->setstyle("width:$cbowidth");
  1078. $cboWMLDTD->additem("", "None");
  1079. $cboWMLDTD->additem(
  1080. rawurlencode("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1_1.xml\">"),
  1081. "WML 1.1"
  1082. );
  1083. $cboWMLDTD->additem(
  1084. rawurlencode("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.xml\">"),
  1085. "WML 1.2"
  1086. );
  1087. $cboWMLDTD->setvalue($app->getparameter("dtd", "dtd", "wml"));
  1088.  
  1089. $cboENC = new form_combofield();
  1090. $cboENC->setclass("axcombo");
  1091. $cboENC->additem("ISO-8859-1", "ISO-8859-1 Latin 1 (Western)");
  1092. $cboENC->additem("US-ASCII", "US-ASCII");
  1093. $cboENC->additem("UTF-8", "UTF-8 (Unicode)");
  1094. $setting = $app->get_setting("encoding");
  1095. $cboENC->setvalue($app->getparameter("encoding", "encoding"));
  1096. if ($app->getparameter("multilang", "multilang")) {
  1097. $cboENC->disabled = true;
  1098. }
  1099.  
  1100. $Tin->tr("axbgdark");
  1101. $Tin->td( "DTD for HTML content:", "axfg" );
  1102. $Tin->td( $cboHTMLDTD->render("cp_dtd_html") );
  1103.  
  1104. $Tin->tr("axbglite");
  1105. $Tin->td( "DTD for WAP content:", "axfg" );
  1106. $Tin->td( $cboWMLDTD->render("cp_dtd_wml") );
  1107.  
  1108. $Tin->tr("axbgdark");
  1109. $Tin->td( "Character Encoding:", "axfg" );
  1110. $Tin->td( $cboENC->render("cp_encoding") );
  1111.  
  1112. $mychkbox = $chkbox;
  1113. $mychkbox->checked = $app->getparameter("multilang", "multilang");
  1114. $mychkbox->set_onclick("setUTF8mode(this.checked)");
  1115. $Tin->tr("axbglite");
  1116. $Tin->td( "Website uses multiple languages:", "axfg" );
  1117. $Tin->td( $mychkbox->render("cp_multilang") . "&nbsp;(requires UTF-8 encoding above)" );
  1118. $Tin->td_css("font-style:italic;font-size:80%");
  1119.  
  1120. $Tin->set_width_profile("50%,50%");
  1121. $Tapp->tr();
  1122. $Tapp->td( $Tin->render() );
  1123.  
  1124. // ......................................................................
  1125. // DATABASE SETTINGS
  1126. $Tapp->tr("axsubhdg");
  1127. $Tapp->td("<b>Database settings</b>", "axsubhdg");
  1128.  
  1129. $Tin = new table("dbsettings");
  1130. $Tin->setpadding(2);
  1131.  
  1132. $mychkbox = $chkbox;
  1133. $mychkbox->checked = $app->getparameter("database_backed", "database_backed");
  1134. $Tin->tr("axbgdark");
  1135. $Tin->td( "Website uses a Database:", "axfg" );
  1136. $Tin->td( $mychkbox->render("cp_database_backed") );
  1137.  
  1138. $Tin->tr("axbglite");
  1139. $Tin->td( "Hosts for persistent DB connection:", "axfg" );
  1140. $tbox->setvalue(str_replace("\"", "", $app->getparameter("permhosts", "permhosts")));
  1141. $Tin->td( $tbox->render("cp_permhosts") );
  1142. $Tin->tr("axbglite");
  1143. $Tin->td();
  1144. $Tin->td(
  1145. "A comma-delimited list of hostnames which will use persistent "
  1146. . "database connections. Usually these would be your production "
  1147. . "web-servers.",
  1148. "axfg"
  1149. );
  1150. $Tin->td_css("font-style:italic;font-size:80%");
  1151. $Tin->set_width_profile("50%,50%");
  1152. $Tapp->tr();
  1153. $Tapp->td( $Tin->render() );
  1154.  
  1155. // ......................................................................
  1156. // DATABASES
  1157. $Tapp->tr("axsubhdg");
  1158. $Tapp->td("<b>Databases</b>", "axsubhdg");
  1159.  
  1160. $Tin = new table("dbsettings");
  1161. $Tin->setpadding(2);
  1162.  
  1163. $database_listbox->setstyle("width:$ewidth;");
  1164. $database_listbox->size = 6;
  1165.  
  1166. // Get defined databases..
  1167. $dbs = $app->get_setting("database");
  1168. if ($dbs === false) $databases = array();
  1169. elseif (is_array($dbs)) $databases = $dbs;
  1170. else $databases[0] = $dbs;
  1171.  
  1172. $dbid = 0;
  1173. foreach ($databases as $database) {
  1174. // Populate listbox..
  1175. $dbname = $database->getparameter("name");
  1176. $database_listbox->additem($dbid, $dbname);
  1177.  
  1178. // Populate maintainer data. The maintainer add_record method
  1179. // requires an associative array keyed on listbox key id..
  1180. $rec = array(
  1181. "dbtype" => $database->getparameter("type"),
  1182. "dbname" => $dbname,
  1183. "dbuser" => $database->getparameter("user"),
  1184. "dbpassword" => $database->getparameter("password"),
  1185. "dbhost" => $database->getparameter("host"),
  1186. "dbport" => $database->getparameter("port")
  1187. );
  1188. $maintainer->add_record($dbid, $rec);
  1189. if (!isset($firstrec)) {
  1190. $firstrec = $rec;
  1191. }
  1192. $dbid += 1;
  1193. } // foreach
  1194. // Now set the defaults for each of the fields. These are
  1195. // necessary for when a new record is created..
  1196. $defaults = array(
  1197. "dbtype" => "postgres",
  1198. "dbname" => "",
  1199. "dbuser" => "",
  1200. "dbpassword" => "",
  1201. "dbhost" => "",
  1202. "dbport" => ""
  1203. );
  1204. $maintainer->add_defaults($defaults);
  1205. if (!isset($firstrec)) {
  1206. $firstrec = $defaults;
  1207. }
  1208.  
  1209. // The listbox field..
  1210. $database_listbox->setvalue($firstrec["dbname"]);
  1211. $Tin->tr("axbgdark");
  1212. $Tin->td( $database_listbox->render() );
  1213. $Tin->td_width("50%");
  1214.  
  1215. $Tin2 = new table();
  1216. $Tin2->td(
  1217. "NB: The ordering of this list is important. The first "
  1218. . "database will be the default connection.",
  1219. "axfg"
  1220. );
  1221. $Tin2->td_css("font-style:italic;font-size:80%");
  1222. $Tin2->td_alignment("", "top");
  1223. $Tin2->td(
  1224. $bup->render() . "<br>"
  1225. . $bdown->render() . "<br>"
  1226. . $bdel->render() . "<br>"
  1227. . $badd->render()
  1228. );
  1229. $Tin2->td_alignment("right", "top");
  1230. $Tin->td( $Tin2->render() );
  1231. $Tin->td_width("50%");
  1232. $Tin->td_alignment("", "top");
  1233. // ..................................................................
  1234. // Database type field..
  1235. $Fdbtype = new form_combofield("dbtype", "", $firstrec["dbtype"]);
  1236. $Fdbtype->setclass("axcombo");
  1237. $maintainer->register_field($Fdbtype);
  1238. $Fdbtype->additem("postgres", "Postgres");
  1239. $Fdbtype->additem("odbc", "ODBC");
  1240. $Fdbtype->additem("mssql", "MS SQL Server");
  1241. $Fdbtype->additem("mysql", "MySQL");
  1242. $Fdbtype->additem("oracle", "Oracle");
  1243. $Fdbtype->setstyle("width:$cbowidth;");
  1244. $Tin->tr("axbglite");
  1245. $Tin->td( "Database type:", "axfg" );
  1246. $Tin->td( $Fdbtype->render() );
  1247. // ..................................................................
  1248. // Database name field..
  1249. $Fdbname = new form_textfield("dbname", "", $firstrec["dbname"]);
  1250. $maintainer->register_field($Fdbname);
  1251. $Fdbname->setstyle("width:$ewidth;");
  1252. $Fdbname->setclass("axtxtbox");
  1253. $Tin->tr("axbgdark");
  1254. $Tin->td( "Database name:", "axfg" );
  1255. $Tin->td( $Fdbname->render() );
  1256. // ..................................................................
  1257. // Database user field..
  1258. $Fdbuser = new form_textfield("dbuser", "", $firstrec["dbuser"]);
  1259. $maintainer->register_field($Fdbuser);
  1260. $Fdbuser->setstyle("width:$ewidth;");
  1261. $Fdbuser->setclass("axtxtbox");
  1262. $Tin->tr("axbglite");
  1263. $Tin->td( "Username:", "axfg" );
  1264. $Tin->td( $Fdbuser->render() );
  1265. // ..................................................................
  1266. // Database password field..
  1267. $Fdbpassword = new form_textfield("dbpassword", "", $firstrec["dbpassword"]);
  1268. $maintainer->register_field($Fdbpassword);
  1269. $Fdbpassword->setstyle("width:$ewidth;");
  1270. $Fdbpassword->setclass("axtxtbox");
  1271. $Tin->tr("axbgdark");
  1272. $Tin->td( "User password:", "axfg" );
  1273. $Tin->td( $Fdbpassword->render() );
  1274. // ..................................................................
  1275. // Database host field..
  1276. $Fdbhost = new form_textfield("dbhost", "", $firstrec["dbhost"]);
  1277. $maintainer->register_field($Fdbhost);
  1278. $Fdbhost->setstyle("width:$ewidth;");
  1279. $Fdbhost->setclass("axtxtbox");
  1280. $Tin->tr("axbglite");
  1281. $Tin->td( "Hostname:", "axfg" );
  1282. $Tin->td( $Fdbhost->render() );
  1283. // ..................................................................
  1284. // Database port field..
  1285. $Fdbport = new form_textfield("dbport", "", $firstrec["dbport"]);
  1286. $maintainer->register_field($Fdbport);
  1287. $Fdbport->setstyle("width:$ewidth;");
  1288. $Fdbport->setclass("axtxtbox");
  1289. $Tin->tr("axbgdark");
  1290. $Tin->td( "Port number:", "axfg" );
  1291. $Tin->td( $Fdbport->render() );
  1292. $Tin->set_width_profile("50%,50%");
  1293. $Tapp->tr();
  1294. $Tapp->td( $Tin->render() );
  1295.  
  1296. // ......................................................................
  1297. // SESSION
  1298. $Tapp->tr("axsubhdg");
  1299. $Tapp->td("<b>Session</b>", "axsubhdg");
  1300.  
  1301. $Tin = new table("session");
  1302. $Tin->setpadding(2);
  1303.  
  1304. $Tin->tr("axbgdark");
  1305. $Tin->td( "Cookie name:", "axfg" );
  1306. $cookiename = $app->getparameter("cookiename", "cookiename");
  1307. if ($cookiename == "") {
  1308. $cookiename = $app->definitions["APP_PREFIX"] . "_session_id";
  1309. }
  1310. $tbox->setvalue($cookiename);
  1311. $Tin->td( $tbox->render("cp_cookiename") );
  1312.  
  1313. $Tin->tr("axbglite");
  1314. $Tin->td( "Cookie/session lifetime:", "axfg" );
  1315. $Flife = new form_combofield();
  1316. $Flife->setclass("axcombo");
  1317. $Flife->setstyle("width:$cwidth");
  1318. $Flife->additem(-1, "Until browser closed");
  1319. $Flife->additem(315360000, "Forever and a day");
  1320. $Flife->additem(31536000, "A year");
  1321. $Flife->additem(2592000, "A month");
  1322. $Flife->additem(604800, "A week");
  1323. $Flife->additem(86400, "24 hours");
  1324. $Flife->additem(43200, "12 hours");
  1325. $Flife->additem(28800, "8 hours");
  1326. $Flife->additem(14400, "4 hours");
  1327. $Flife->additem(3600, "An hour");
  1328. $Flife->additem(1200, "20 minutes");
  1329. $Flife->additem(0, "Immediate expiry");
  1330. $Flife->setvalue($app->getparameter("lifetime", "lifetime"));
  1331. $Tin->td( $Flife->render("cp_lifetime") );
  1332.  
  1333. $Tin->tr("axbgdark");
  1334. $Tin->td( "Page expiry (seconds):", "axfg" );
  1335.  
  1336. $Fexpiry = new form_combofield();
  1337. $Fexpiry->setclass("axcombo");
  1338. $Fexpiry->setstyle("width:$cwidth");
  1339. $Fexpiry->additem(-1, "Immediate (dynamic content)");
  1340. $Fexpiry->additem(60, "1 minute");
  1341. $Fexpiry->additem(120, "2 minutes");
  1342. $Fexpiry->additem(180, "3 minutes");
  1343. $Fexpiry->additem(240, "4 minutes");
  1344. $Fexpiry->additem(300, "5 minutes");
  1345. $Fexpiry->additem(600, "10 minutes");
  1346. $Fexpiry->additem(1800, "30 minutes");
  1347. $Fexpiry->additem(3600, "1 hour");
  1348. $Fexpiry->additem(14400, "4 hours");
  1349. $Fexpiry->additem(28800, "8 hours");
  1350. $Fexpiry->additem(86400, "24 hours");
  1351. $Fexpiry->additem(315360000, "Never (static content)");
  1352. $Fexpiry->setvalue($app->getparameter("expiry", "expiry"));
  1353. $Tin->td( $Fexpiry->render("cp_expiry") );
  1354.  
  1355. $mychkbox = $chkbox;
  1356. $mychkbox->checked = $app->getparameter("guest_browser_lifetime", "guest_browser_lifetime");
  1357. $Tin->tr("axbglite");
  1358. $Tin->td( "Guest cookies browser lifetime:", "axfg" );
  1359. $Tin->td( $mychkbox->render("cp_guest_browser_lifetime") );
  1360.  
  1361. $Tin->set_width_profile("50%,50%");
  1362. $Tapp->tr();
  1363. $Tapp->td( $Tin->render() );
  1364.  
  1365. // ......................................................................
  1366. // CONTENT
  1367. $Tapp->tr("axsubhdg");
  1368. $Tapp->td("<b>Content settings</b>", "axsubhdg");
  1369.  
  1370. $Tin = new table("content");
  1371. $Tin->setpadding(2);
  1372.  
  1373. $mychkbox = $chkbox;
  1374. $mychkbox->checked = $app->getparameter("metadata_enabled", "metadata_enabled");
  1375. $Tin->tr("axbglite");
  1376. $Tin->td( "Enable metadata edit/generation:", "axfg" );
  1377. $Tin->td( $mychkbox->render("cp_metadata_enabled") );
  1378.  
  1379. $mychkbox = $chkbox;
  1380. $mychkbox->checked = $app->getparameter("microsites_enabled", "microsites_enabled");
  1381. $mychkbox->set_onchange(
  1382. "if(this.checked) "
  1383. . "alert("
  1384. . "'NOTICE:\\n\\n"
  1385. . "For microsite creation to work you must be running \'pg-microsites-installer.php\' from cron.\\n"
  1386. . "The crontab for this can be found in the \'scripts/cron\' sub-directory of your Axyl installation,\\n"
  1387. . "and should have been automatically installed into /etc/cron.d by your Debian package.\\n\\n"
  1388. . "')"
  1389. );
  1390. $Tin->tr("axbglite");
  1391. $Tin->td( "Enable microsite(s) creation:", "axfg" );
  1392. $Tin->td( $mychkbox->render("cp_microsites_enabled") );
  1393.  
  1394. $mychkbox = $chkbox;
  1395. $mychkbox->checked = $app->getparameter("buffered_output", "buffered_output");
  1396. $Tin->tr("axbgdark");
  1397. $Tin->td( "Buffered output (recommended):", "axfg" );
  1398. $Tin->td( $mychkbox->render("cp_buffered_output") );
  1399.  
  1400. $Tin->tr("axbglite");
  1401. $Tin->td( "Compression type:", "axfg" );
  1402. $Fcomp = new form_combofield();
  1403. $Fcomp->setclass("axcombo");
  1404. $Fcomp->setstyle("width:$cwidth");
  1405. $Fcomp->additem(0, "No compression");
  1406. $Fcomp->additem(1, "Built-in compression (Php >= 4.0.4)");
  1407. $Fcomp->additem(2, "Axyl custom compression");
  1408. $Fcomp->setvalue($app->getparameter("compression_type", "compression_type"));
  1409. $Tin->td( $Fcomp->render("cp_compression_type") );
  1410.  
  1411. $Tin->tr("axbgdark");
  1412. $Tin->td( "Compression threshold:", "axfg" );
  1413. $Fcomp = new form_combofield();
  1414. $Fcomp->setclass("axcombo");
  1415. $Fcomp->setstyle("width:$cwidth");
  1416. $Fcomp->additem(0, "None (compress all content)");
  1417. $Fcomp->additem(1024, "Over 1Kb");
  1418. $Fcomp->additem(4096, "Over 4Kb");
  1419. $Fcomp->additem(8192, "Over 8Kb");
  1420. $Fcomp->additem(16384, "Over 16Kb");
  1421. $Fcomp->additem(32768, "Over 32Kb");
  1422. $Fcomp->additem(65536, "Over 64Kb");
  1423. $Fcomp->additem(262144, "Over 256Kb");
  1424. $Fcomp->setvalue($app->getparameter("compression_threshold", "compression_threshold"));
  1425. $Tin->td( $Fcomp->render("cp_compression_threshold") );
  1426.  
  1427. $Tin->set_width_profile("50%,50%");
  1428. $Tapp->tr();
  1429. $Tapp->td( $Tin->render() );
  1430.  
  1431. // ......................................................................
  1432. // GET/POST settings
  1433. $Tapp->tr("axsubhdg");
  1434. $Tapp->td("<b>GET/POST settings</b>", "axsubhdg");
  1435.  
  1436. $Tin = new table("getpost");
  1437. $Tin->setpadding(2);
  1438.  
  1439. $mychkbox = $chkbox;
  1440. $mychkbox->checked = $app->getparameter("keep", "keep");
  1441. $Tin->tr("axbgdark");
  1442. $Tin->td( "Enable Axyl KEEP feature:", "axfg" );
  1443. $Tin->td( $mychkbox->render("cp_keep") );
  1444.  
  1445. $mychkbox = $chkbox;
  1446. $mychkbox->checked = $app->getparameter("globalise", "globalise");
  1447. $Tin->tr("axbglite");
  1448. $Tin->td( "Auto-globalise all GET/POST vars:", "axfg" );
  1449. $Tin->td( $mychkbox->render("cp_globalise") );
  1450.  
  1451. $Tin->set_width_profile("50%,50%");
  1452. $Tapp->tr();
  1453. $Tapp->td( $Tin->render() );
  1454.  
  1455. // ......................................................................
  1456. // AUTHENTICATION
  1457. $Tapp->tr("axsubhdg");
  1458. $Tapp->td("<b>Authentication</b>", "axsubhdg");
  1459.  
  1460. $Tin = new table("authentication");
  1461. $Tin->setpadding(2);
  1462.  
  1463. $mychkbox = $chkbox;
  1464. $mychkbox->checked = $app->getparameter("encrypted_passwords", "encrypted_passwords");
  1465. $Tin->tr("axbgdark");
  1466. $Tin->td( "Encrypted passwords:", "axfg" );
  1467. $Tin->td( $mychkbox->render("cp_encrypted_passwords") );
  1468.  
  1469. $Tin->tr("axbglite");
  1470. $Tin->td( "Authentication type:", "axfg" );
  1471. $Fcomp = new form_combofield();
  1472. $Fcomp->setclass("axcombo");
  1473. $Fcomp->setstyle("width:$cwidth");
  1474. $Fcomp->additem(0, "No authentication");
  1475. $Fcomp->additem(1, "HTTP authentication");
  1476. $Fcomp->additem(2, "Axyl login form");
  1477. $Fcomp->setvalue($app->getparameter("authtype", "authtype"));
  1478. $Tin->td( $Fcomp->render("cp_authtype") );
  1479.  
  1480. $Tin->tr("axbgdark");
  1481. $Tin->td( "On failed authentication:", "axfg" );
  1482. $Fcomp = new form_combofield();
  1483. $Fcomp->setclass("axcombo");
  1484. $Fcomp->setstyle("width:$cwidth");
  1485. $Fcomp->additem(0, "Display basic fail message");
  1486. $Fcomp->additem(1, "Die silently");
  1487. $Fcomp->additem(2, "Re-direct to URL (below)");
  1488. $Fcomp->additem(3, "Login as guest instead");
  1489. $Fcomp->setvalue($app->getparameter("authfail", "authfailopt"));
  1490. $Tin->td( $Fcomp->render("cp_authfailopt") );
  1491.  
  1492. $Tin->tr("axbgdark");
  1493. $Tin->td( "Failed re-direct URL:", "axfg" );
  1494. $tbox->setvalue($app->getparameter("authfail", "authfailurl"));
  1495. $Tin->td( $tbox->render("cp_authfailurl") );
  1496.  
  1497. $Tin->tr("axbglite");
  1498. $Tin->td( "On login limit exceeded:", "axfg" );
  1499. $Flogexc = new form_combofield();
  1500. $Flogexc->setclass("axcombo");
  1501. $Flogexc->setstyle("width:$cwidth");
  1502. $Flogexc->additem(0, "Take no action");
  1503. $Flogexc->additem(1, "Allow, cull oldest sessions");
  1504. $Flogexc->additem(2, "Deny access, display message");
  1505. $Flogexc->additem(3, "Deny access silently");
  1506. $Flogexc->additem(4, "Redirect to a URL (below)");
  1507. $Flogexc->additem(5, "Login as guest instead");
  1508. $Flogexc->setvalue($app->getparameter("loginlimit", "logexceedopt"));
  1509. $Tin->td( $Flogexc->render("cp_logexceedopt") );
  1510.  
  1511. $Tin->tr("axbglite");
  1512. $Tin->td( "Login excess re-direct URL:", "axfg" );
  1513. $tbox->setvalue($app->getparameter("loginlimit", "logexceedurl"));
  1514. $Tin->td( $tbox->render("cp_logexceedurl") );
  1515.  
  1516. $Tin->set_width_profile("50%,50%");
  1517. $Tapp->tr();
  1518. $Tapp->td( $Tin->render() );
  1519.  
  1520. // ......................................................................
  1521. // MISC SETTINGS
  1522. $Tapp->tr("axsubhdg");
  1523. $Tapp->td("<b>Miscellaneous settings</b>", "axsubhdg");
  1524.  
  1525. $Tin = new table("misc");
  1526. $Tin->setpadding(2);
  1527.  
  1528. $Tin->tr("axbglite");
  1529. $Tin->td( "IP addresses to block:", "axfg" );
  1530. $tbox->setvalue(str_replace("\"", "", $app->getparameter("badips", "badips")));
  1531. $Tin->td( $tbox->render("cp_badips") );
  1532. $Tin->tr("axbglite");
  1533. $Tin->td();
  1534. $Tin->td(
  1535. "A comma-delimited list of IP addresses which are to be denied access.",
  1536. "axfg"
  1537. );
  1538. $Tin->td_css("font-style:italic;font-size:80%");
  1539. $Tin->set_width_profile("50%,50%");
  1540. $Tapp->tr();
  1541. $Tapp->td( $Tin->render() );
  1542.  
  1543. // ......................................................................
  1544. // DEBUGGING
  1545. $Tapp->tr("axhdg");
  1546. $Tapp->td("<b>DEBUGGING</b>", "axhdg");
  1547.  
  1548. $Tin = new table("debugging");
  1549. $Tin->setpadding(2);
  1550.  
  1551. $debugging = $app->getparameter("debug_on", "debug_on");
  1552. $mychkbox = $chkbox;
  1553. $mychkbox->checked = $debugging;
  1554. $Tin->tr("axbgdark");
  1555. $Tin->td( "Enable debugging:", "axfg" );
  1556. $Tin->td( $mychkbox->render("cp_debug_on") );
  1557.  
  1558. $Tin->tr("axbglite");
  1559. $Tin->td( "Classes of output to show:", "axfg");
  1560. $Tin->td_alignment("", "top");
  1561. $Fdebugcl = new form_combofield();
  1562. $Fdebugcl->multiselect = true;
  1563. $Fdebugcl->set_size(6);
  1564. $Fdebugcl->setstyle("width:$cwidth");
  1565. $Fdebugcl->additem(2, "User diagnostics (default)");
  1566. $Fdebugcl->additem(4, "SQL statements");
  1567. $Fdebugcl->additem(8, "All SQL data (verbose)");
  1568. $Fdebugcl->additem(16, "Dump of GET/POST vars etc.");
  1569. $Fdebugcl->additem(32, "Include traceback info");
  1570. $Fdebugcl->additem(64, "Show table outlines");
  1571. $Fdebugcl->additem(128, "Execution profiler");
  1572. $Fdebugcl->additem(1, "System diagnostics");
  1573. // Build value as array of set bits..
  1574. $debugcl = $app->getparameter("debug_classes", "debug_classes");
  1575. $debug_value = array();
  1576. for ($i=1; $i < 256; $i*=2) {
  1577. if ($debugcl & $i) {
  1578. $debug_value[] = $i;
  1579. }
  1580. }
  1581. $Fdebugcl->setvalue($debug_value);
  1582. $Tin->td( $Fdebugcl->render("cp_debug_classes") );
  1583.  
  1584. $Tin->tr("axbgdark");
  1585. $Tin->td( "Output modes:", "axfg");
  1586. $Tin->td_alignment("", "top");
  1587. $Fdebugop = new form_combofield();
  1588. $Fdebugop->multiselect = true;
  1589. $Fdebugop->set_size(6);
  1590. $Fdebugop->setstyle("width:$cwidth");
  1591. $Fdebugop->additem(1, "Standard (default)");
  1592. $Fdebugop->additem(2, "Unbuffered echo");
  1593. $Fdebugop->additem(4, "CLI output (non-web mode)");
  1594. $Fdebugop->additem(8, "To system logfile");
  1595. // Build value as array of set bits..
  1596. $debugop = $app->getparameter("debug_output", "debug_output");
  1597. $debugop_value = array();
  1598. for ($i=1; $i < 256; $i*=2) {
  1599. if ($debugop & $i) {
  1600. $debugop_value[] = $i;
  1601. }
  1602. }
  1603. $Fdebugop->setvalue($debugop_value);
  1604. $Tin->td( $Fdebugop->render("cp_debug_output") );
  1605.  
  1606. $bg = "axbgdark";
  1607. integerField("SQL Execution log threshold:", "SQL_EXEC_THRESHOLD", $app->globals, 60000, 80);
  1608. infoField(
  1609. "SQL queries exeeding the specified number of milliseconds will "
  1610. . "be logged in the system log. To disable, set to zero."
  1611. );
  1612.  
  1613. $Tin->set_width_profile("50%,50%");
  1614. $Tapp->tr();
  1615. $Tapp->td( $Tin->render() );
  1616.  
  1617. $Tapp->tr("axfoot");
  1618. $Tapp->td("&nbsp;", "axfoot");
  1619.  
  1620. } // if no errors
  1621. // ----------------------------------------------------------------------
  1622. // Finish and return the page..
  1623.  
  1624. $s .= "<form name=\"cpform\" method=\"post\">\n";
  1625. $s .= $Tapp->render();
  1626. $s .= $maintainer->render();
  1627. $s .= "</form>\n";
  1628.  
  1629. //echo $app->htmldump();
  1630.  
  1631. $s .= "</body>\n";
  1632. $s .= "</html>\n";
  1633. echo $s;
  1634. // ----------------------------------------------------------------------
  1635. ?>

Documentation generated by phpDocumentor 1.3.0RC3