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_metadata_enabled), "metadata_enabled", "metadata_enabled");
  624. $app->setparameter(isset($cp_buffered_output), "buffered_output", "buffered_output");
  625. $app->setparameter($cp_compression_type, "compression_type", "compression_type");
  626. $app->setparameter($cp_compression_threshold, "compression_threshold", "compression_threshold");
  627. $app->setparameter(isset($cp_keep), "keep", "keep");
  628. $app->setparameter(isset($cp_globalise), "globalise", "globalise");
  629. $app->setparameter($cp_authtype, "authtype", "authtype");
  630. $app->setparameter($cp_authfailopt, "authfail", "authfailopt");
  631. $app->setparameter($cp_authfailurl, "authfail", "authfailurl");
  632. $app->setparameter(isset($cp_encrypted_passwords), "encrypted_passwords", "encrypted_passwords");
  633. $app->setparameter($cp_logexceedopt, "loginlimit", "logexceedopt");
  634. $app->setparameter($cp_logexceedurl, "loginlimit", "logexceedurl");
  635. $app->setparameter($cp_badips, "badips", "badips");
  636. $app->setparameter(isset($cp_debug_on), "debug_on", "debug_on");
  637. // Unpack debug classes..
  638. $debug_classes = 0;
  639. foreach ($cp_debug_classes as $class) {
  640. $debug_classes |= $class;
  641. }
  642. $app->setparameter($debug_classes, "debug_classes", "debug_classes");
  643. // Unpack debug outputs..
  644. $debug_output = 0;
  645. foreach ($cp_debug_output as $output) {
  646. $debug_output |= $output;
  647. }
  648. $app->setparameter($debug_output, "debug_output", "debug_output");
  649.  
  650. // Save it
  651. $app->save();
  652. $app = new application();
  653. }
  654. }
  655.  
  656. // ----------------------------------------------------------------------
  657. // BOILERPLATING
  658.  
  659. $s = <<< EOS
  660. <html>
  661. <head>
  662. <title>Axyl Control Panel</title>
  663. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  664. <meta name="generator" content="Catalyst IT Axyl">
  665. <style type="text/css">
  666. margin: 0px 0px 0px 0px;
  667. font-family: Verdana, Arial, Helvetica, sans-serif;
  668. color: #605728;
  669. font-size: 9pt;
  670. font-style: normal;
  671. font-weight: normal;
  672. scrollbar-face-color: #f7f7f7;
  673. scrollbar-highlight-color: #b2b1b1;
  674. scrollbar-shadow-color: #b2b1b1;
  675. scrollbar-3dlight-color: white;
  676. scrollbar-arrow-color: #c9c9c9;
  677. scrollbar-track-color: #f5f5f5;
  678. scrollbar-darkshadow-color: white;
  679. }
  680. p, td, th, ol, ul, li, input, textarea, select {
  681. font-family: Arial, Helvetica, sans-serif;
  682. font-size: 9pt;
  683. font-style: normal;
  684. font-weight: normal;
  685. color: #605728;
  686. }
  687. input, textarea, select {
  688. font-family: Arial, Helvetica, sans-serif;
  689. font-size: 9pt;
  690. font-style: normal;
  691. font-weight: normal;
  692. }
  693. p {
  694. line-height: 115%;
  695. }
  696. hr {
  697. height: 1px;
  698. color: black;
  699. margin-top: 0;
  700. margin-bottom: 0;
  701. }
  702. form {
  703. margin: 0px;
  704. padding: 0px;
  705. }
  706. a {
  707. color: #AC9D46;
  708. text-decoration: none;
  709. }
  710. a:hover {
  711. color: #AC9D46;
  712. text-decoration: underline;
  713. }
  714. a:active {
  715. color: #AC9D46;
  716. }
  717. a:visited {
  718. color: #AC9D46;
  719. }
  720. th {
  721. text-align: left;
  722. }
  723.  
  724. h1, h2, h5, h3, h4, h6 {
  725. font-family: Verdana, Arial, Helvetica, sans-serif;
  726. font-weight: bold;
  727. margin-top: 2px;
  728. margin-bottom: 2px;
  729. }
  730. h1 { color:#605728; font-size:125%; text-transform:capitalize; }
  731. h2 { color:#605728; font-size:120%; }
  732. h3 { color:#605728; font-size:115%; font-weight:bold;}
  733. h4 { color:#605728; font-size:105%; font-weight:bold;}
  734. h5 { color:#605728; font-size:100%; font-weight:bold;}
  735. h6 { color:#605728; font-size:96%; font-weight:bold;}
  736. .axform {
  737. font-family: Arial, Helvetica, sans-serif;
  738. font-size: 95%;
  739. padding: 0px;
  740. }
  741. .axcombo {
  742. font-family: Arial, Helvetica, sans-serif;
  743. font-size: 95%;
  744. height: 20px;
  745. padding-left: 2px;
  746. }
  747. .axlistbox {
  748. font-family: Arial, Helvetica, sans-serif;
  749. font-size: 95%;
  750. padding-left: 2px;
  751. }
  752. .axtxtbox {
  753. font-family: Arial, Helvetica, sans-serif;
  754. font-size: 95%;
  755. width: 250px;
  756. height: 22px;
  757. padding-left: 2px;
  758. vertical-align: middle;
  759. }
  760. .axmemo {
  761. font-family: Arial, Helvetica, sans-serif;
  762. font-size: 95%;
  763. width: 250px;
  764. height: 100px;
  765. padding-left: 2px;
  766. }
  767. .axdatetime {
  768. font-family: Arial, Helvetica, sans-serif;
  769. font-size: 95%;
  770. width: 150px;
  771. height: 22px;
  772. padding-left: 2px;
  773. }
  774. .axnumbox {
  775. font-family: Arial, Helvetica, sans-serif;
  776. font-size: 95%;
  777. width: 80px;
  778. height: 22px;
  779. padding-left: 2px;
  780. padding-right: 2px;
  781. vertical-align: middle;
  782. text-align: right;
  783. }
  784. .axchkbox {
  785. vertical-align: middle;
  786. }
  787. .axfmlbl {
  788. font-family: Arial, Helvetica, sans-serif;
  789. font-size: 95%;
  790. font-weight: normal;
  791. vertical-align: top;
  792. color: black;
  793. }
  794. .axtitle {
  795. font-family: Arial, Helvetica, sans-serif;
  796. font-size:110%;
  797. color: white;
  798. background-color: #66700F;
  799. font-weight: bold;
  800. }
  801. .axfoot {
  802. height: 12px;
  803. background-color: #66700F;
  804. }
  805. .axhdg {
  806. font-family: Arial, Helvetica, sans-serif;
  807. font-size:100%;
  808. color: white;
  809. background-color: #898437;
  810. font-weight: bold;
  811. }
  812. .axsubhdg {
  813. font-family: Arial, Helvetica, sans-serif;
  814. font-size:100%;
  815. color: white;
  816. background-color: #66700F;
  817. font-weight: bold;
  818. }
  819. .axfg {
  820. color: #605728;
  821. font-weight: normal;
  822. }
  823. .axhl {
  824. color: red;
  825. font-weight: bold;
  826. }
  827. .axerror {
  828. color: red;
  829. }
  830. .axbgwhite {
  831. color: black;
  832. background-color: white;
  833. }
  834. .axbglite {
  835. color: black;
  836. background-color: #EAEBDF;
  837. }
  838. .axbgdark {
  839. color: white;
  840. background-color: #DEDFD4;
  841. }
  842. .axbgdarker {
  843. color: white;
  844. background-color: #66700F;
  845. }
  846. </style>
  847. <script language="javascript">
  848. var keyfield = new Array();
  849. var curid = new Array();
  850. var newid = new Array();
  851. function setUTF8mode(multilang) {
  852. if (multilang) {
  853. document.forms.cpform.cp_encoding.value='UTF-8';
  854. document.forms.cpform.cp_encoding.disabled=true;
  855. }
  856. else {
  857. document.forms.cpform.cp_encoding.readonly=false;
  858. document.forms.cpform.cp_encoding.disabled=false;
  859. }
  860. return true;
  861. }
  862. </script>
  863. <script type="text/javascript" src="$LIBDIR/js/recmaint.js"></script>
  864. <script type="text/javascript" src="$LIBDIR/js/fieldvalidation.js"></script>
  865. </head>
  866. <body>
  867. EOS;
  868. // ----------------------------------------------------------------------
  869. // MAIN FORM GENERATION
  870.  
  871. // Width of large form elements..
  872.  
  873. $fullwidth = 540;
  874. $halfwidth = ceil($fullwidth * 0.50);
  875. $thirdwidth = ceil($fullwidth * 0.37);
  876. $quartwidth = ceil($fullwidth * 0.25);
  877. $ewidth = $halfwidth . "px"; // Normal text fields
  878. $awidth = $fullwidth . "px"; // Full field width
  879. $cbowidth = $quartwidth . "px"; // Normal combos
  880. $cwidth = $thirdwidth . "px"; // Wide combos
  881. // DATABASE LISTBOX
  882. // Defined early so that buttons can be registered..
  883.  
  884. $database_listbox = new form_combofield("dbid");
  885. $database_listbox->setclass("axlistbox");
  886. // Make a new record maintainer, and attach the buttons..
  887. $maintainer = new recmaintainer("cpform", $database_listbox);
  888.  
  889. $bup = new form_imagebutton("_up", "", "", "$LIBDIR/img/_up.gif", "Move up", 57, 15);
  890. $bdown = new form_imagebutton("_down", "", "", "$LIBDIR/img/_down.gif", "Move down", 57, 15);
  891. $bdel = new form_imagebutton("_del", "", "", "$LIBDIR/img/_delete.gif", "Delete database", 57, 15);
  892. $badd = new form_imagebutton("_add", "", "", "$LIBDIR/img/_add.gif", "Add new database", 57, 15);
  893. $bsave = new form_imagebutton("_save", "", "", "$LIBDIR/img/_save.gif", "Save your settings", 57, 15);
  894. $breset = new form_imagebutton("_reset", "", "", "$LIBDIR/img/_reset.gif", "Reverse your changes", 57, 15);
  895. $breset->set_onclick("document.forms.cpform.reset()");
  896. $bdef = new form_imagebutton("_default", "", "", "$LIBDIR/img/_default.gif", "Apply default configuration", 57, 15);
  897. $bdef->set_confirm_text("This will over-write the current configuration. Continue?");
  898.  
  899. // Register all relevant buttons to the maintainer..
  900. $maintainer->register_button("up" , $bup);
  901. $maintainer->register_button("down", $bdown);
  902. $maintainer->register_button("del", $bdel);
  903. $maintainer->register_button("add", $badd);
  904. $maintainer->register_button("save", $bsave);
  905.  
  906. $Tapp = new table();
  907. $Tapp->setwidth($fullwidth);
  908. $Tapp->setalign("center");
  909.  
  910. // ......................................................................
  911. // Heading
  912.  
  913. $Tapp->tr("axtitle");
  914. $Tapp->td("<b>AXYL CONTROL PANEL</b>", "axtitle");
  915. $Tapp->td_css("vertical-align:center;height:30px;padding-left:5px;");
  916. if ($user_msg != "") {
  917. $Tapp->tr("axsubhdg");
  918. $Tapp->td($user_msg, "color:#F5DD64;text-align:center;");
  919. }
  920. elseif ($synced) {
  921. $Tapp->tr("axsubhdg");
  922. $Tapp->td("The Axyl configuration structure was successfully updated.", "color:#F5DD64;text-align:center;");
  923. }
  924.  
  925. if (!$error) {
  926. // ......................................................................
  927. // Toolbar..
  928. $toolbar = array();
  929. $toolbar[] = $breset;
  930. $toolbar[] = $bdef;
  931. $toolbar[] = $bsave;
  932. $Tbar = new table("toolbar");
  933. $Tbar->tr();
  934. $tools = "";
  935. foreach ($toolbar as $tool) {
  936. $tools .= $tool->render();
  937. }
  938. $Tbar->th($tools, "text-align:right");
  939. $Tapp->tr("axbglite");
  940. $Tapp->td( $Tbar->render() );
  941.  
  942. $tbox = new form_textfield();
  943. $tbox->setstyle("width:$ewidth");
  944. $tbox->setclass("axtxtbox");
  945.  
  946. $chkbox = new form_checkbox();
  947. $chkbox->setclass("axchkbox");
  948. $chkbox->setvalue("yes");
  949. $chkbox->checked = false;
  950.  
  951. // ......................................................................
  952. // DEFINITIONS
  953. $Tapp->tr("axhdg");
  954. $Tapp->td("<b>DEFINITIONS</b>", "axhdg");
  955.  
  956. $Tin = new table("definitions");
  957. $Tin->setpadding(2);
  958.  
  959. // Installs text field in $Tin table..
  960. function entryField($label, $fieldname, &$valarray) {
  961. global $app, $Tin, $tbox, $bg;
  962. $mybox = $tbox;
  963. $bg = ($bg == "axbgdark" ? "axbglite" : "axbgdark");
  964. $Tin->tr($bg);
  965. $Tin->td( $label, "axfg" );
  966. $mybox->setvalue($valarray[$fieldname]);
  967. $Tin->td( $mybox->render("cp_" . strtolower($fieldname)) );
  968. }
  969. // Installs info row in $Tin table..
  970. function infoField($info) {
  971. global $app, $Tin, $tbox, $bg;
  972. $bg = ($bg == "axbgdark" ? "axbglite" : "axbgdark");
  973. $Tin->tr($bg);
  974. $Tin->td();
  975. $Tin->td($info, "axfg");
  976. $Tin->td_css("font-style:italic;font-size:80%");
  977. }
  978. // Installs text field in $Tin table..
  979. function integerField($label, $fieldname, &$valarray, $intlimit, $pxwidth=100) {
  980. global $app, $Tin, $tbox, $bg;
  981. $mybox = $tbox;
  982. $bg = ($bg == "axbgdark" ? "axbglite" : "axbgdark");
  983. $Tin->tr($bg);
  984. $Tin->td( $label, "axfg" );
  985. $mybox->setstyle("width:" . $pxwidth . "px");
  986. $mybox->set_onblur("limitInt(this, 0, $intlimit)");
  987. $mybox->setvalue($valarray[$fieldname]);
  988. $Tin->td( $mybox->render("cp_" . strtolower($fieldname)) );
  989. }
  990.  
  991. $bg = "axbgdark";
  992. entryField("Application Name:", "APP_NAME", $app->definitions);
  993. entryField("Application Prefix:", "APP_PREFIX", $app->definitions);
  994.  
  995. $Tin->set_width_profile("50%,50%");
  996. $Tapp->tr();
  997. $Tapp->td( $Tin->render() );
  998.  
  999. // ......................................................................
  1000. // GLOBALS
  1001. $Tapp->tr("axhdg");
  1002. $Tapp->td("<b>GLOBALS</b>", "axhdg");
  1003.  
  1004. $Tin = new table("globals");
  1005. $Tin->setpadding(2);
  1006. $Tin->tbody("fmlook");
  1007. $bg = "axbgdark";
  1008. entryField("Templates directory:", "TEMPLATESDIR", $app->globals);
  1009. entryField("Images directory:", "IMAGESDIR", $app->globals);
  1010. entryField("Cached files directory:", "CACHEDIR", $app->globals);
  1011. entryField("Media catalog directory:", "CATALOGDIR", $app->globals);
  1012. entryField("Managed content directory:", "CMDIR", $app->globals);
  1013. entryField("Includes directory:", "INCDIR", $app->globals);
  1014. infoField(
  1015. "NB: all directories specified above should be relative to the "
  1016. . "website root directory. Additionally, if they are to be writeable "
  1017. . "then they should be under the 'var' subdirectory."
  1018. );
  1019. entryField("Webmaster name:", "WEBMASTER_PERSON", $app->globals);
  1020. entryField("Webmaster e-mail:", "WEBMASTER_EMAIL", $app->globals);
  1021.  
  1022. $Tin->set_width_profile("50%,50%");
  1023. $Tapp->tr();
  1024. $Tapp->td( $Tin->render() );
  1025.  
  1026. // ......................................................................
  1027. // SETTINGS
  1028.  
  1029.  
  1030. $Tapp->tr("axhdg");
  1031. $Tapp->td("<b>WEBSITE SETTINGS</b>", "axhdg");
  1032.  
  1033. // ......................................................................
  1034. // DTD & ENCODING
  1035. $Tapp->tr("axsubhdg");
  1036. $Tapp->td("<b>Default DTD and Encoding</b>", "axsubhdg");
  1037.  
  1038. $Tin = new table("dtd_enc");
  1039. $Tin->setpadding(2);
  1040.  
  1041. $cboHTMLDTD = new form_combofield();
  1042. $cboHTMLDTD->setclass("axcombo");
  1043. $cboHTMLDTD->additem("", "None");
  1044. $cboHTMLDTD->additem(
  1045. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"),
  1046. "HTML 3.2 Strict"
  1047. );
  1048. $cboHTMLDTD->additem(
  1049. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"),
  1050. "HTML 4.01 Transitional"
  1051. );
  1052. $cboHTMLDTD->additem(
  1053. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"),
  1054. "HTML 4.01 Strict"
  1055. );
  1056. $cboHTMLDTD->additem(
  1057. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">"),
  1058. "HTML 4.01 with Frameset"
  1059. );
  1060. $cboHTMLDTD->additem(
  1061. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">"),
  1062. "XHTML 1.0 Transitional"
  1063. );
  1064. $cboHTMLDTD->additem(
  1065. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\">"),
  1066. "XHTML 1.0 Strict"
  1067. );
  1068. $cboHTMLDTD->additem(
  1069. rawurlencode("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\">"),
  1070. "XHTML 1.0 with Frameset"
  1071. );
  1072. $cboHTMLDTD->setvalue($app->getparameter("dtd", "dtd", "html"));
  1073.  
  1074. $cboWMLDTD = new form_combofield();
  1075. $cboWMLDTD->setclass("axcombo");
  1076. //$cboWMLDTD->setstyle("width:$cbowidth");
  1077. $cboWMLDTD->additem("", "None");
  1078. $cboWMLDTD->additem(
  1079. rawurlencode("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1_1.xml\">"),
  1080. "WML 1.1"
  1081. );
  1082. $cboWMLDTD->additem(
  1083. rawurlencode("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.xml\">"),
  1084. "WML 1.2"
  1085. );
  1086. $cboWMLDTD->setvalue($app->getparameter("dtd", "dtd", "wml"));
  1087.  
  1088. $cboENC = new form_combofield();
  1089. $cboENC->setclass("axcombo");
  1090. $cboENC->additem("ISO-8859-1", "ISO-8859-1 Latin 1 (Western)");
  1091. $cboENC->additem("US-ASCII", "US-ASCII");
  1092. $cboENC->additem("UTF-8", "UTF-8 (Unicode)");
  1093. $setting = $app->get_setting("encoding");
  1094. $cboENC->setvalue($app->getparameter("encoding", "encoding"));
  1095. if ($app->getparameter("multilang", "multilang")) {
  1096. $cboENC->disabled = true;
  1097. }
  1098.  
  1099. $Tin->tr("axbgdark");
  1100. $Tin->td( "DTD for HTML content:", "axfg" );
  1101. $Tin->td( $cboHTMLDTD->render("cp_dtd_html") );
  1102.  
  1103. $Tin->tr("axbglite");
  1104. $Tin->td( "DTD for WAP content:", "axfg" );
  1105. $Tin->td( $cboWMLDTD->render("cp_dtd_wml") );
  1106.  
  1107. $Tin->tr("axbgdark");
  1108. $Tin->td( "Character Encoding:", "axfg" );
  1109. $Tin->td( $cboENC->render("cp_encoding") );
  1110.  
  1111. $mychkbox = $chkbox;
  1112. $mychkbox->checked = $app->getparameter("multilang", "multilang");
  1113. $mychkbox->set_onclick("setUTF8mode(this.checked)");
  1114. $Tin->tr("axbglite");
  1115. $Tin->td( "Website uses multiple languages:", "axfg" );
  1116. $Tin->td( $mychkbox->render("cp_multilang") . "&nbsp;(requires UTF-8 encoding above)" );
  1117. $Tin->td_css("font-style:italic;font-size:80%");
  1118.  
  1119. $Tin->set_width_profile("50%,50%");
  1120. $Tapp->tr();
  1121. $Tapp->td( $Tin->render() );
  1122.  
  1123. // ......................................................................
  1124. // DATABASE SETTINGS
  1125. $Tapp->tr("axsubhdg");
  1126. $Tapp->td("<b>Database settings</b>", "axsubhdg");
  1127.  
  1128. $Tin = new table("dbsettings");
  1129. $Tin->setpadding(2);
  1130.  
  1131. $chkbox->checked = $app->getparameter("database_backed", "database_backed");
  1132. $Tin->tr("axbgdark");
  1133. $Tin->td( "Website uses a Database:", "axfg" );
  1134. $Tin->td( $chkbox->render("cp_database_backed") );
  1135.  
  1136. $Tin->tr("axbglite");
  1137. $Tin->td( "Hosts for persistent DB connection:", "axfg" );
  1138. $tbox->setvalue(str_replace("\"", "", $app->getparameter("permhosts", "permhosts")));
  1139. $Tin->td( $tbox->render("cp_permhosts") );
  1140. $Tin->tr("axbglite");
  1141. $Tin->td();
  1142. $Tin->td(
  1143. "A comma-delimited list of hostnames which will use persistent "
  1144. . "database connections. Usually these would be your production "
  1145. . "web-servers.",
  1146. "axfg"
  1147. );
  1148. $Tin->td_css("font-style:italic;font-size:80%");
  1149. $Tin->set_width_profile("50%,50%");
  1150. $Tapp->tr();
  1151. $Tapp->td( $Tin->render() );
  1152.  
  1153. // ......................................................................
  1154. // DATABASES
  1155. $Tapp->tr("axsubhdg");
  1156. $Tapp->td("<b>Databases</b>", "axsubhdg");
  1157.  
  1158. $Tin = new table("dbsettings");
  1159. $Tin->setpadding(2);
  1160.  
  1161. $database_listbox->setstyle("width:$ewidth;");
  1162. $database_listbox->size = 6;
  1163.  
  1164. // Get defined databases..
  1165. $dbs = $app->get_setting("database");
  1166. if ($dbs === false) $databases = array();
  1167. elseif (is_array($dbs)) $databases = $dbs;
  1168. else $databases[0] = $dbs;
  1169.  
  1170. $dbid = 0;
  1171. foreach ($databases as $database) {
  1172. // Populate listbox..
  1173. $dbname = $database->getparameter("name");
  1174. $database_listbox->additem($dbid, $dbname);
  1175.  
  1176. // Populate maintainer data. The maintainer add_record method
  1177. // requires an associative array keyed on listbox key id..
  1178. $rec = array(
  1179. "dbtype" => $database->getparameter("type"),
  1180. "dbname" => $dbname,
  1181. "dbuser" => $database->getparameter("user"),
  1182. "dbpassword" => $database->getparameter("password"),
  1183. "dbhost" => $database->getparameter("host"),
  1184. "dbport" => $database->getparameter("port")
  1185. );
  1186. $maintainer->add_record($dbid, $rec);
  1187. if (!isset($firstrec)) {
  1188. $firstrec = $rec;
  1189. }
  1190. $dbid += 1;
  1191. } // foreach
  1192. // Now set the defaults for each of the fields. These are
  1193. // necessary for when a new record is created..
  1194. $defaults = array(
  1195. "dbtype" => "postgres",
  1196. "dbname" => "",
  1197. "dbuser" => "",
  1198. "dbpassword" => "",
  1199. "dbhost" => "",
  1200. "dbport" => ""
  1201. );
  1202. $maintainer->add_defaults($defaults);
  1203. if (!isset($firstrec)) {
  1204. $firstrec = $defaults;
  1205. }
  1206.  
  1207. // The listbox field..
  1208. $database_listbox->setvalue($firstrec["dbname"]);
  1209. $Tin->tr("axbgdark");
  1210. $Tin->td( $database_listbox->render() );
  1211. $Tin->td_width("50%");
  1212.  
  1213. $Tin2 = new table();
  1214. $Tin2->td(
  1215. "NB: The ordering of this list is important. The first "
  1216. . "database will be the default connection.",
  1217. "axfg"
  1218. );
  1219. $Tin2->td_css("font-style:italic;font-size:80%");
  1220. $Tin2->td_alignment("", "top");
  1221. $Tin2->td(
  1222. $bup->render() . "<br>"
  1223. . $bdown->render() . "<br>"
  1224. . $bdel->render() . "<br>"
  1225. . $badd->render()
  1226. );
  1227. $Tin2->td_alignment("right", "top");
  1228. $Tin->td( $Tin2->render() );
  1229. $Tin->td_width("50%");
  1230. $Tin->td_alignment("", "top");
  1231. // ..................................................................
  1232. // Database type field..
  1233. $Fdbtype = new form_combofield("dbtype", "", $firstrec["dbtype"]);
  1234. $Fdbtype->setclass("axcombo");
  1235. $maintainer->register_field($Fdbtype);
  1236. $Fdbtype->additem("postgres", "Postgres");
  1237. $Fdbtype->additem("odbc", "ODBC");
  1238. $Fdbtype->additem("mssql", "MS SQL Server");
  1239. $Fdbtype->additem("mysql", "MySQL");
  1240. $Fdbtype->additem("oracle", "Oracle");
  1241. $Fdbtype->setstyle("width:$cbowidth;");
  1242. $Tin->tr("axbglite");
  1243. $Tin->td( "Database type:", "axfg" );
  1244. $Tin->td( $Fdbtype->render() );
  1245. // ..................................................................
  1246. // Database name field..
  1247. $Fdbname = new form_textfield("dbname", "", $firstrec["dbname"]);
  1248. $maintainer->register_field($Fdbname);
  1249. $Fdbname->setstyle("width:$ewidth;");
  1250. $Fdbname->setclass("axtxtbox");
  1251. $Tin->tr("axbgdark");
  1252. $Tin->td( "Database name:", "axfg" );
  1253. $Tin->td( $Fdbname->render() );
  1254. // ..................................................................
  1255. // Database user field..
  1256. $Fdbuser = new form_textfield("dbuser", "", $firstrec["dbuser"]);
  1257. $maintainer->register_field($Fdbuser);
  1258. $Fdbuser->setstyle("width:$ewidth;");
  1259. $Fdbuser->setclass("axtxtbox");
  1260. $Tin->tr("axbglite");
  1261. $Tin->td( "Username:", "axfg" );
  1262. $Tin->td( $Fdbuser->render() );
  1263. // ..................................................................
  1264. // Database password field..
  1265. $Fdbpassword = new form_textfield("dbpassword", "", $firstrec["dbpassword"]);
  1266. $maintainer->register_field($Fdbpassword);
  1267. $Fdbpassword->setstyle("width:$ewidth;");
  1268. $Fdbpassword->setclass("axtxtbox");
  1269. $Tin->tr("axbgdark");
  1270. $Tin->td( "User password:", "axfg" );
  1271. $Tin->td( $Fdbpassword->render() );
  1272. // ..................................................................
  1273. // Database host field..
  1274. $Fdbhost = new form_textfield("dbhost", "", $firstrec["dbhost"]);
  1275. $maintainer->register_field($Fdbhost);
  1276. $Fdbhost->setstyle("width:$ewidth;");
  1277. $Fdbhost->setclass("axtxtbox");
  1278. $Tin->tr("axbglite");
  1279. $Tin->td( "Hostname:", "axfg" );
  1280. $Tin->td( $Fdbhost->render() );
  1281. // ..................................................................
  1282. // Database port field..
  1283. $Fdbport = new form_textfield("dbport", "", $firstrec["dbport"]);
  1284. $maintainer->register_field($Fdbport);
  1285. $Fdbport->setstyle("width:$ewidth;");
  1286. $Fdbport->setclass("axtxtbox");
  1287. $Tin->tr("axbgdark");
  1288. $Tin->td( "Port number:", "axfg" );
  1289. $Tin->td( $Fdbport->render() );
  1290. $Tin->set_width_profile("50%,50%");
  1291. $Tapp->tr();
  1292. $Tapp->td( $Tin->render() );
  1293.  
  1294. // ......................................................................
  1295. // SESSION
  1296. $Tapp->tr("axsubhdg");
  1297. $Tapp->td("<b>Session</b>", "axsubhdg");
  1298.  
  1299. $Tin = new table("session");
  1300. $Tin->setpadding(2);
  1301.  
  1302. $Tin->tr("axbgdark");
  1303. $Tin->td( "Cookie name:", "axfg" );
  1304. $cookiename = $app->getparameter("cookiename", "cookiename");
  1305. if ($cookiename == "") {
  1306. $cookiename = $app->definitions["APP_PREFIX"] . "_session_id";
  1307. }
  1308. $tbox->setvalue($cookiename);
  1309. $Tin->td( $tbox->render("cp_cookiename") );
  1310.  
  1311. $Tin->tr("axbglite");
  1312. $Tin->td( "Cookie/session lifetime:", "axfg" );
  1313. $Flife = new form_combofield();
  1314. $Flife->setclass("axcombo");
  1315. $Flife->setstyle("width:$cwidth");
  1316. $Flife->additem(-1, "Until browser closed");
  1317. $Flife->additem(315360000, "Forever and a day");
  1318. $Flife->additem(31536000, "A year");
  1319. $Flife->additem(2592000, "A month");
  1320. $Flife->additem(604800, "A week");
  1321. $Flife->additem(86400, "24 hours");
  1322. $Flife->additem(43200, "12 hours");
  1323. $Flife->additem(28800, "8 hours");
  1324. $Flife->additem(14400, "4 hours");
  1325. $Flife->additem(3600, "An hour");
  1326. $Flife->additem(1200, "20 minutes");
  1327. $Flife->additem(0, "Immediate expiry");
  1328. $Flife->setvalue($app->getparameter("lifetime", "lifetime"));
  1329. $Tin->td( $Flife->render("cp_lifetime") );
  1330.  
  1331. $Tin->tr("axbgdark");
  1332. $Tin->td( "Page expiry (seconds):", "axfg" );
  1333.  
  1334. $Fexpiry = new form_combofield();
  1335. $Fexpiry->setclass("axcombo");
  1336. $Fexpiry->setstyle("width:$cwidth");
  1337. $Fexpiry->additem(-1, "Immediate (dynamic content)");
  1338. $Fexpiry->additem(60, "1 minute");
  1339. $Fexpiry->additem(120, "2 minutes");
  1340. $Fexpiry->additem(180, "3 minutes");
  1341. $Fexpiry->additem(240, "4 minutes");
  1342. $Fexpiry->additem(300, "5 minutes");
  1343. $Fexpiry->additem(600, "10 minutes");
  1344. $Fexpiry->additem(1800, "30 minutes");
  1345. $Fexpiry->additem(3600, "1 hour");
  1346. $Fexpiry->additem(14400, "4 hours");
  1347. $Fexpiry->additem(28800, "8 hours");
  1348. $Fexpiry->additem(86400, "24 hours");
  1349. $Fexpiry->additem(315360000, "Never (static content)");
  1350. $Fexpiry->setvalue($app->getparameter("expiry", "expiry"));
  1351. $Tin->td( $Fexpiry->render("cp_expiry") );
  1352.  
  1353. $chkbox->checked = $app->getparameter("guest_browser_lifetime", "guest_browser_lifetime");
  1354. $Tin->tr("axbglite");
  1355. $Tin->td( "Guest cookies browser lifetime:", "axfg" );
  1356. $Tin->td( $chkbox->render("cp_guest_browser_lifetime") );
  1357.  
  1358. $Tin->set_width_profile("50%,50%");
  1359. $Tapp->tr();
  1360. $Tapp->td( $Tin->render() );
  1361.  
  1362. // ......................................................................
  1363. // CONTENT
  1364. $Tapp->tr("axsubhdg");
  1365. $Tapp->td("<b>Content settings</b>", "axsubhdg");
  1366.  
  1367. $Tin = new table("content");
  1368. $Tin->setpadding(2);
  1369.  
  1370. $chkbox->checked = $app->getparameter("metadata_enabled", "metadata_enabled");
  1371. $Tin->tr("axbglite");
  1372. $Tin->td( "Enable metadata edit/generation:", "axfg" );
  1373. $Tin->td( $chkbox->render("cp_metadata_enabled") );
  1374.  
  1375. $chkbox->checked = $app->getparameter("buffered_output", "buffered_output");
  1376. $Tin->tr("axbgdark");
  1377. $Tin->td( "Buffered output (recommended):", "axfg" );
  1378. $Tin->td( $chkbox->render("cp_buffered_output") );
  1379.  
  1380. $Tin->tr("axbglite");
  1381. $Tin->td( "Compression type:", "axfg" );
  1382. $Fcomp = new form_combofield();
  1383. $Fcomp->setclass("axcombo");
  1384. $Fcomp->setstyle("width:$cwidth");
  1385. $Fcomp->additem(0, "No compression");
  1386. $Fcomp->additem(1, "Built-in compression (Php >= 4.0.4)");
  1387. $Fcomp->additem(2, "Axyl custom compression");
  1388. $Fcomp->setvalue($app->getparameter("compression_type", "compression_type"));
  1389. $Tin->td( $Fcomp->render("cp_compression_type") );
  1390.  
  1391. $Tin->tr("axbgdark");
  1392. $Tin->td( "Compression threshold:", "axfg" );
  1393. $Fcomp = new form_combofield();
  1394. $Fcomp->setclass("axcombo");
  1395. $Fcomp->setstyle("width:$cwidth");
  1396. $Fcomp->additem(0, "None (compress all content)");
  1397. $Fcomp->additem(1024, "Over 1Kb");
  1398. $Fcomp->additem(4096, "Over 4Kb");
  1399. $Fcomp->additem(8192, "Over 8Kb");
  1400. $Fcomp->additem(16384, "Over 16Kb");
  1401. $Fcomp->additem(32768, "Over 32Kb");
  1402. $Fcomp->additem(65536, "Over 64Kb");
  1403. $Fcomp->additem(262144, "Over 256Kb");
  1404. $Fcomp->setvalue($app->getparameter("compression_threshold", "compression_threshold"));
  1405. $Tin->td( $Fcomp->render("cp_compression_threshold") );
  1406.  
  1407. $Tin->set_width_profile("50%,50%");
  1408. $Tapp->tr();
  1409. $Tapp->td( $Tin->render() );
  1410.  
  1411. // ......................................................................
  1412. // GET/POST settings
  1413. $Tapp->tr("axsubhdg");
  1414. $Tapp->td("<b>GET/POST settings</b>", "axsubhdg");
  1415.  
  1416. $Tin = new table("getpost");
  1417. $Tin->setpadding(2);
  1418.  
  1419. $chkbox->checked = $app->getparameter("keep", "keep");
  1420. $Tin->tr("axbgdark");
  1421. $Tin->td( "Enable Axyl KEEP feature:", "axfg" );
  1422. $Tin->td( $chkbox->render("cp_keep") );
  1423.  
  1424. $chkbox->checked = $app->getparameter("globalise", "globalise");
  1425. $Tin->tr("axbglite");
  1426. $Tin->td( "Auto-globalise all GET/POST vars:", "axfg" );
  1427. $Tin->td( $chkbox->render("cp_globalise") );
  1428.  
  1429. $Tin->set_width_profile("50%,50%");
  1430. $Tapp->tr();
  1431. $Tapp->td( $Tin->render() );
  1432.  
  1433. // ......................................................................
  1434. // AUTHENTICATION
  1435. $Tapp->tr("axsubhdg");
  1436. $Tapp->td("<b>Authentication</b>", "axsubhdg");
  1437.  
  1438. $Tin = new table("authentication");
  1439. $Tin->setpadding(2);
  1440.  
  1441. $chkbox->checked = $app->getparameter("encrypted_passwords", "encrypted_passwords");
  1442. $Tin->tr("axbgdark");
  1443. $Tin->td( "Encrypted passwords:", "axfg" );
  1444. $Tin->td( $chkbox->render("cp_encrypted_passwords") );
  1445.  
  1446. $Tin->tr("axbglite");
  1447. $Tin->td( "Authentication type:", "axfg" );
  1448. $Fcomp = new form_combofield();
  1449. $Fcomp->setclass("axcombo");
  1450. $Fcomp->setstyle("width:$cwidth");
  1451. $Fcomp->additem(0, "No authentication");
  1452. $Fcomp->additem(1, "HTTP authentication");
  1453. $Fcomp->additem(2, "Axyl login form");
  1454. $Fcomp->setvalue($app->getparameter("authtype", "authtype"));
  1455. $Tin->td( $Fcomp->render("cp_authtype") );
  1456.  
  1457. $Tin->tr("axbgdark");
  1458. $Tin->td( "On failed authentication:", "axfg" );
  1459. $Fcomp = new form_combofield();
  1460. $Fcomp->setclass("axcombo");
  1461. $Fcomp->setstyle("width:$cwidth");
  1462. $Fcomp->additem(0, "Display basic fail message");
  1463. $Fcomp->additem(1, "Die silently");
  1464. $Fcomp->additem(2, "Re-direct to URL (below)");
  1465. $Fcomp->additem(3, "Login as guest instead");
  1466. $Fcomp->setvalue($app->getparameter("authfail", "authfailopt"));
  1467. $Tin->td( $Fcomp->render("cp_authfailopt") );
  1468.  
  1469. $Tin->tr("axbgdark");
  1470. $Tin->td( "Failed re-direct URL:", "axfg" );
  1471. $tbox->setvalue($app->getparameter("authfail", "authfailurl"));
  1472. $Tin->td( $tbox->render("cp_authfailurl") );
  1473.  
  1474. $Tin->tr("axbglite");
  1475. $Tin->td( "On login limit exceeded:", "axfg" );
  1476. $Flogexc = new form_combofield();
  1477. $Flogexc->setclass("axcombo");
  1478. $Flogexc->setstyle("width:$cwidth");
  1479. $Flogexc->additem(0, "Take no action");
  1480. $Flogexc->additem(1, "Allow, cull oldest sessions");
  1481. $Flogexc->additem(2, "Deny access, display message");
  1482. $Flogexc->additem(3, "Deny access silently");
  1483. $Flogexc->additem(4, "Redirect to a URL (below)");
  1484. $Flogexc->additem(5, "Login as guest instead");
  1485. $Flogexc->setvalue($app->getparameter("loginlimit", "logexceedopt"));
  1486. $Tin->td( $Flogexc->render("cp_logexceedopt") );
  1487.  
  1488. $Tin->tr("axbglite");
  1489. $Tin->td( "Login excess re-direct URL:", "axfg" );
  1490. $tbox->setvalue($app->getparameter("loginlimit", "logexceedurl"));
  1491. $Tin->td( $tbox->render("cp_logexceedurl") );
  1492.  
  1493. $Tin->set_width_profile("50%,50%");
  1494. $Tapp->tr();
  1495. $Tapp->td( $Tin->render() );
  1496.  
  1497. // ......................................................................
  1498. // MISC SETTINGS
  1499. $Tapp->tr("axsubhdg");
  1500. $Tapp->td("<b>Miscellaneous settings</b>", "axsubhdg");
  1501.  
  1502. $Tin = new table("misc");
  1503. $Tin->setpadding(2);
  1504.  
  1505. $Tin->tr("axbglite");
  1506. $Tin->td( "IP addresses to block:", "axfg" );
  1507. $tbox->setvalue(str_replace("\"", "", $app->getparameter("badips", "badips")));
  1508. $Tin->td( $tbox->render("cp_badips") );
  1509. $Tin->tr("axbglite");
  1510. $Tin->td();
  1511. $Tin->td(
  1512. "A comma-delimited list of IP addresses which are to be denied access.",
  1513. "axfg"
  1514. );
  1515. $Tin->td_css("font-style:italic;font-size:80%");
  1516. $Tin->set_width_profile("50%,50%");
  1517. $Tapp->tr();
  1518. $Tapp->td( $Tin->render() );
  1519.  
  1520. // ......................................................................
  1521. // DEBUGGING
  1522. $Tapp->tr("axhdg");
  1523. $Tapp->td("<b>DEBUGGING</b>", "axhdg");
  1524.  
  1525. $Tin = new table("debugging");
  1526. $Tin->setpadding(2);
  1527.  
  1528. $debugging = $app->getparameter("debug_on", "debug_on");
  1529. $chkbox->checked = $debugging;
  1530. $Tin->tr("axbgdark");
  1531. $Tin->td( "Enable debugging:", "axfg" );
  1532. $Tin->td( $chkbox->render("cp_debug_on") );
  1533.  
  1534. $Tin->tr("axbglite");
  1535. $Tin->td( "Classes of output to show:", "axfg");
  1536. $Tin->td_alignment("", "top");
  1537. $Fdebugcl = new form_combofield();
  1538. $Fdebugcl->multiselect = true;
  1539. $Fdebugcl->set_size(6);
  1540. $Fdebugcl->setstyle("width:$cwidth");
  1541. $Fdebugcl->additem(2, "User diagnostics (default)");
  1542. $Fdebugcl->additem(4, "SQL statements");
  1543. $Fdebugcl->additem(8, "All SQL data (verbose)");
  1544. $Fdebugcl->additem(16, "Dump of GET/POST vars etc.");
  1545. $Fdebugcl->additem(32, "Include traceback info");
  1546. $Fdebugcl->additem(64, "Show table outlines");
  1547. $Fdebugcl->additem(128, "Execution profiler");
  1548. $Fdebugcl->additem(1, "System diagnostics");
  1549. // Build value as array of set bits..
  1550. $debugcl = $app->getparameter("debug_classes", "debug_classes");
  1551. $debug_value = array();
  1552. for ($i=1; $i < 256; $i*=2) {
  1553. if ($debugcl & $i) {
  1554. $debug_value[] = $i;
  1555. }
  1556. }
  1557. $Fdebugcl->setvalue($debug_value);
  1558. $Tin->td( $Fdebugcl->render("cp_debug_classes") );
  1559.  
  1560. $Tin->tr("axbgdark");
  1561. $Tin->td( "Output modes:", "axfg");
  1562. $Tin->td_alignment("", "top");
  1563. $Fdebugop = new form_combofield();
  1564. $Fdebugop->multiselect = true;
  1565. $Fdebugop->set_size(6);
  1566. $Fdebugop->setstyle("width:$cwidth");
  1567. $Fdebugop->additem(1, "Standard (default)");
  1568. $Fdebugop->additem(2, "Unbuffered echo");
  1569. $Fdebugop->additem(4, "CLI output (non-web mode)");
  1570. $Fdebugop->additem(8, "To system logfile");
  1571. // Build value as array of set bits..
  1572. $debugop = $app->getparameter("debug_output", "debug_output");
  1573. $debugop_value = array();
  1574. for ($i=1; $i < 256; $i*=2) {
  1575. if ($debugop & $i) {
  1576. $debugop_value[] = $i;
  1577. }
  1578. }
  1579. $Fdebugop->setvalue($debugop_value);
  1580. $Tin->td( $Fdebugop->render("cp_debug_output") );
  1581.  
  1582. $bg = "axbgdark";
  1583. integerField("SQL Execution log threshold:", "SQL_EXEC_THRESHOLD", $app->globals, 60000, 80);
  1584. infoField(
  1585. "SQL queries exeeding the specified number of milliseconds will "
  1586. . "be logged in the system log. To disable, set to zero."
  1587. );
  1588.  
  1589. $Tin->set_width_profile("50%,50%");
  1590. $Tapp->tr();
  1591. $Tapp->td( $Tin->render() );
  1592.  
  1593. $Tapp->tr("axfoot");
  1594. $Tapp->td("&nbsp;", "axfoot");
  1595.  
  1596. } // if no errors
  1597. // ----------------------------------------------------------------------
  1598. // Finish and return the page..
  1599.  
  1600. $s .= "<form name=\"cpform\" method=\"post\">\n";
  1601. $s .= $Tapp->render();
  1602. $s .= $maintainer->render();
  1603. $s .= "</form>\n";
  1604.  
  1605. //echo $app->htmldump();
  1606.  
  1607. $s .= "</body>\n";
  1608. $s .= "</html>\n";
  1609. echo $s;
  1610. // ----------------------------------------------------------------------
  1611. ?>

Documentation generated by phpDocumentor 1.3.0RC3