Permalink
Browse files

import to github

  • Loading branch information...
0 parents commit 8047900c89e8b96dcb94ec412797017dd6766ebf @jmazzi committed Apr 23, 2008
Showing with 26,930 additions and 0 deletions.
  1. +475 −0 ChangeLog
  2. +36 −0 INSTALL
  3. 0 README
  4. +2 −0 TODO
  5. +17 −0 backend/addzone.php
  6. +22 −0 backend/includes/globals.php
  7. +41 −0 backend/processqueue.php
  8. +8 −0 backend/rebuildzones.php
  9. +41 −0 backend/removeorphans.php
  10. +7 −0 backend/rewriteconf.php
  11. +22 −0 frontend/addrecord.php
  12. +19 −0 frontend/admin/addzone.php
  13. +49 −0 frontend/admin/index.php
  14. +21 −0 frontend/admin/login.php
  15. +6 −0 frontend/admin/logout.php
  16. +35 −0 frontend/admin/modzone.php
  17. +36 −0 frontend/admin/search.php
  18. +25 −0 frontend/changeip.php
  19. +2 −0 frontend/compiled_templates/.htaccess
  20. +311 −0 frontend/includes/adodb/adodb-csvlib.inc.php
  21. +771 −0 frontend/includes/adodb/adodb-datadict.inc.php
  22. +257 −0 frontend/includes/adodb/adodb-error.inc.php
  23. +79 −0 frontend/includes/adodb/adodb-errorhandler.inc.php
  24. +88 −0 frontend/includes/adodb/adodb-errorpear.inc.php
  25. +80 −0 frontend/includes/adodb/adodb-exceptions.inc.php
  26. +84 −0 frontend/includes/adodb/adodb-iterator.inc.php
  27. +899 −0 frontend/includes/adodb/adodb-lib.inc.php
  28. +289 −0 frontend/includes/adodb/adodb-pager.inc.php
  29. +374 −0 frontend/includes/adodb/adodb-pear.inc.php
  30. +931 −0 frontend/includes/adodb/adodb-perf.inc.php
  31. +16 −0 frontend/includes/adodb/adodb-php4.inc.php
  32. +984 −0 frontend/includes/adodb/adodb-time.inc.php
  33. BIN frontend/includes/adodb/adodb-time.zip
  34. +2,194 −0 frontend/includes/adodb/adodb-xmlschema.inc.php
  35. +3,824 −0 frontend/includes/adodb/adodb.inc.php
  36. +157 −0 frontend/includes/adodb/contrib/toxmlrpc.inc.php
  37. BIN frontend/includes/adodb/cute_icons_for_site/adodb.gif
  38. BIN frontend/includes/adodb/cute_icons_for_site/adodb2.gif
  39. +95 −0 frontend/includes/adodb/datadict/datadict-access.inc.php
  40. +143 −0 frontend/includes/adodb/datadict/datadict-db2.inc.php
  41. +151 −0 frontend/includes/adodb/datadict/datadict-firebird.inc.php
  42. +125 −0 frontend/includes/adodb/datadict/datadict-generic.inc.php
  43. +67 −0 frontend/includes/adodb/datadict/datadict-ibase.inc.php
  44. +80 −0 frontend/includes/adodb/datadict/datadict-informix.inc.php
  45. +251 −0 frontend/includes/adodb/datadict/datadict-mssql.inc.php
  46. +181 −0 frontend/includes/adodb/datadict/datadict-mysql.inc.php
  47. +280 −0 frontend/includes/adodb/datadict/datadict-oci8.inc.php
  48. +359 −0 frontend/includes/adodb/datadict/datadict-postgres.inc.php
  49. +121 −0 frontend/includes/adodb/datadict/datadict-sapdb.inc.php
  50. +228 −0 frontend/includes/adodb/datadict/datadict-sybase.inc.php
  51. +3,262 −0 frontend/includes/adodb/docs/docs-adodb.htm
  52. +278 −0 frontend/includes/adodb/docs/docs-datadict.htm
  53. +534 −0 frontend/includes/adodb/docs/docs-oracle.htm
  54. +962 −0 frontend/includes/adodb/docs/docs-perf.htm
  55. +233 −0 frontend/includes/adodb/docs/docs-session.htm
  56. +700 −0 frontend/includes/adodb/docs/old-changelog.htm
  57. +68 −0 frontend/includes/adodb/docs/readme.htm
  58. +362 −0 frontend/includes/adodb/docs/tips_portable_sql.htm
  59. +290 −0 frontend/includes/adodb/docs/tute.htm
  60. +86 −0 frontend/includes/adodb/drivers/adodb-access.inc.php
  61. +629 −0 frontend/includes/adodb/drivers/adodb-ado.inc.php
  62. +636 −0 frontend/includes/adodb/drivers/adodb-ado5.inc.php
  63. +54 −0 frontend/includes/adodb/drivers/adodb-ado_access.inc.php
  64. +98 −0 frontend/includes/adodb/drivers/adodb-ado_mssql.inc.php
  65. +91 −0 frontend/includes/adodb/drivers/adodb-borland_ibase.inc.php
  66. +203 −0 frontend/includes/adodb/drivers/adodb-csv.inc.php
  67. +361 −0 frontend/includes/adodb/drivers/adodb-db2.inc.php
  68. +266 −0 frontend/includes/adodb/drivers/adodb-fbsql.inc.php
  69. +75 −0 frontend/includes/adodb/drivers/adodb-firebird.inc.php
  70. +855 −0 frontend/includes/adodb/drivers/adodb-ibase.inc.php
  71. +35 −0 frontend/includes/adodb/drivers/adodb-informix.inc.php
  72. +473 −0 frontend/includes/adodb/drivers/adodb-informix72.inc.php
  73. +311 −0 frontend/includes/adodb/drivers/adodb-ldap.inc.php
  74. +1,017 −0 frontend/includes/adodb/drivers/adodb-mssql.inc.php
  75. +62 −0 frontend/includes/adodb/drivers/adodb-mssqlpo.inc.php
  76. +706 −0 frontend/includes/adodb/drivers/adodb-mysql.inc.php
Sorry, we could not display the entire diff because it was too big.
475 ChangeLog
@@ -0,0 +1,475 @@
+2005-06-20 16:34:51 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Version 1.0.1
+
+ * A frontend/tags/1.0.1
+ * A backend/tags/1.0.1
+
+2005-06-20 16:32:27 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Version 1.0.1
+
+ * M includes/globals.php
+
+2005-06-20 16:29:26 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * BUG FIXES:
+ Security fix for possible session failure
+
+ M includes/classes/session.inc.php
+
+ * CHANGES:
+ www A record added by default
+
+ M includes/classes/dns.inc.php
+
+ * NEW FEATURES:
+ Searching Added
+
+ A admin/search.php
+ A templates/admin/search_form.htm
+ A templates/admin/nav_search.htm
+ M templates/admin/nav.htm
+ A templates/admin/search_results.htm
+ M templates/admin/index.htm
+ M templates/addrecord.htm
+
+2005-03-05 11:30:18 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M releases/dnscontrol-1.0.0-beta1.tar.gz
+
+2005-03-05 11:28:02 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M INSTALL
+
+2005-03-05 11:01:58 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * woops
+ * A releases/dnscontrol-1.0.0-beta1.tar.gz
+ * D releases/dnscontrol-1.0.0-beta1.tar
+
+2005-03-05 11:01:39 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * AM releases/dnscontrol-1.0.0-beta1.tar
+
+2005-03-05 11:00:44 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M INSTALL
+
+2005-03-05 10:59:34 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M frontend/tags/1.0.0-beta1/sql/dns.sql
+
+2005-03-05 10:59:12 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * generic sql
+ * M frontend/trunk/sql/dns.sql
+
+2005-03-05 10:56:01 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * A TODO
+ * M INSTALL
+
+2005-03-05 10:53:20 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Generic Conf
+ * M frontend/trunk/includes/config.inc.php.dist
+ * M frontend/tags/1.0.0-beta1/includes/config.inc.php.dist
+ * M ChangeLog
+
+2005-03-05 10:49:10 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M INSTALL
+
+2005-03-05 10:19:34 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * A INSTALL
+
+2005-03-05 10:16:21 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * A frontend/tags/1.0.0-beta1
+ * A frontend/tags/1.0.0-beta1/includes/globals.php
+ * A backend/tags/1.0.0-beta1
+
+2005-03-05 10:15:37 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * tar.gz
+ * A releases
+
+2005-03-05 10:15:14 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * changed version
+ * M frontend/trunk/includes/globals.php
+
+2005-03-05 10:13:54 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * D backend/tags/1.0.0-RC1
+
+2005-03-05 10:13:48 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * D frontend/tags/1.0.0-RC1
+
+2005-03-04 15:14:50 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * fixed bug with rndc reload
+ * M includes/classes/dns.inc.php
+
+2005-03-04 11:54:24 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Out put status when processing a rebuild (rebuildZones()
+ * M includes/classes/dns.inc.php
+
+2005-03-04 11:53:16 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * find and remove orphan domains
+ * A removeorphans.php
+
+2005-03-04 00:01:10 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * bug fixes
+
+2005-03-03 16:35:14 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * 1.0.0-RC1
+
+2005-03-03 16:34:41 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * version tags
+ * M templates/footer.htm
+
+2005-03-03 16:33:18 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * D frontend/tags/1.0.0-RC1
+
+2005-03-03 16:32:52 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * RC1
+
+2005-03-03 16:31:32 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * 1.0.0-RC1
+ * A frontend/tags/1.0.0-RC1
+ * A backend/tags/1.0.0-RC1
+
+2005-03-03 16:26:41 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M ChangeLog
+
+2005-03-03 16:25:43 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * added changing of main IP
+ * A changeip.php
+ * M includes/classes/dns.inc.php
+ * A templates/editip.htm
+ * M templates/index.htm
+
+2005-03-03 16:02:02 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * updated db
+ * added change passwords on zones
+ * M sql/dns.sql
+ * M includes/classes/dns.inc.php
+ * M admin/modzone.php
+ * M admin/index.php
+ * A templates/admin/editzone.htm
+ * M templates/admin/index.htm
+
+2005-03-03 15:45:29 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * ask for password durring creatin
+ * M admin/index.php
+ * M templates/admin/addzone.htm
+ * M templates/admin/index.htm
+
+2005-03-03 15:28:23 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * queue lock
+ * M processqueue.php
+
+2005-03-03 15:27:58 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * queue locks
+ * M includes/functions.inc.php
+ * M includes/classes/dns.inc.php
+ * M admin/index.php
+ * M templates/admin/nav.htm
+ * M templates/admin/index.htm
+
+2005-03-03 14:30:42 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * adding and removing domains
+ * A admin/modzone.php
+ * M admin/index.php
+ * M templates/admin/addzone.htm
+ * M templates/admin/index.htm
+
+2005-03-03 14:17:23 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * adding admin functions
+
+ * M logout.php
+ * M includes/globals.php
+ * M includes/classes/session.inc.php
+ * M includes/classes/dns.inc.php
+ * A admin
+ * A admin/logout.php
+ * A admin/addzone.php
+ * A admin/index.php
+ * A admin/login.php
+ * M addrecord.php
+ * A templates/admin
+ * A templates/admin/login.htm
+ * A templates/admin/addzone.htm
+ * A templates/admin/nav.htm
+ * A templates/admin/index.htm
+
+2005-03-03 09:58:20 Justin Mazzi <jmazzi@gmail.com>
+
+
+2005-02-28 16:53:59 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * global app_name var
+ * M includes/globals.php
+ * M templates/login.htm
+
+2005-02-28 16:47:53 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * failed message with color
+ * M addrecord.php
+
+2005-02-28 16:39:57 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * new window for raw zone
+ * M templates/nav.htm
+
+2005-02-28 16:37:51 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * colors for good and bad messages
+ * M modrecord.php
+ * M index.php
+ * M templates/index.htm
+
+2005-02-28 16:34:38 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * redirect to index on success
+ * M addrecord.php
+
+2005-02-28 16:34:15 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * nav
+ * D templates/header.htm
+ * A templates/nav.htm
+
+2005-02-28 16:33:53 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * adding nav
+ * M templates/addrecord_post.htm
+ * M templates/footer.htm
+ * M templates/editzone.htm
+ * M templates/index.htm
+ * M templates/addrecord.htm
+
+2005-02-28 16:22:37 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * fixed record edit issues
+ * M modrecord.php
+ * M includes/classes/dns.inc.php
+ * M templates/editzone.htm
+
+2005-02-28 15:56:43 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M ChangeLog
+
+2005-02-28 15:56:24 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * D frontend/trunk/ChangeLog
+ * A ChangeLog
+
+2005-02-28 15:53:24 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * M frontend/trunk/ChangeLog
+
+2005-02-28 15:51:55 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * default records added
+ * removed register link
+ * M includes/classes/dns.inc.php
+ * M templates/login.htm
+
+2005-02-28 11:23:17 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * D test.php
+
+2005-02-28 11:23:03 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * A test.php
+
+2005-02-28 11:06:05 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Id tags
+ * MM includes/functions.inc.php
+ * MM includes/globals.php
+ * MM includes/cmd.php
+
+2005-02-28 11:04:31 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Id tags
+ * M trunk/logout.php
+ * M trunk/modrecord.php
+ * M trunk/viewzone.php
+ * M trunk/addrecord.php
+ * M trunk/index.php
+ * M trunk/login.php
+
+2005-02-28 11:03:00 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * Id tags
+ * _M trunk/logout.php
+ * _M trunk/modrecord.php
+ * _M trunk/viewzone.php
+ * _M trunk/addrecord.php
+ * _M trunk/index.php
+ * _M trunk/login.php
+
+2005-02-28 11:02:35 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * adding Id Tags
+ * M trunk/logout.php
+ * M trunk/modrecord.php
+ * M trunk/viewzone.php
+ * M trunk/addrecord.php
+ * M trunk/index.php
+ * M trunk/login.php
+
+2005-02-27 22:22:29 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * editing zones works now
+ * M modrecord.php
+ * M includes/classes/dns.inc.php
+ * M index.php
+ * A templates/editzone.htm
+ * M templates/index.htm
+
+2005-02-27 22:21:56 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * run del last
+ * M processqueue.php
+
+2005-02-27 21:28:19 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * adodb420->adodb421
+
+2005-02-27 21:22:45 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * del records added
+ * start of mod
+ * A modrecord.php
+ * _M includes
+ * M includes/classes/dns.inc.php
+ * _M compiled_templates
+
+2005-02-27 21:02:45 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * removed debug test link
+ * M templates/index.htm
+
+2005-02-27 21:02:24 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * confirm delete
+ * M includes/classes/dns.inc.php
+ * M templates/index.htm
+
+2005-02-27 09:43:37 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * alternate colors
+ * M templates/index.htm
+
+2005-02-27 09:26:08 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * offline mode for dns scipts
+ * M processqueue.php
+
+2005-02-27 09:25:49 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * offline mode for dns scripts
+ * M includes/config.inc.php.dist
+
+2005-02-27 09:22:17 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * A viewzone.php
+
+2005-02-26 16:32:17 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * new options
+ * M includes/config.inc.php.dist
+
+2005-02-26 16:27:48 Justin Mazzi <jmazzi@gmail.com>
+
+
+ * public import
+
36 INSTALL
@@ -0,0 +1,36 @@
+The frontend directory has the web interface in it.
+The backend directory has the command scripts. You want these in a directory not accessable from the web.
+
+Web setup:
+1) Create a mysql database
+2) Create a mysql user
+3) import the dump: mysql dns < frontend/sql/dump.sql
+4) Create Admin, Run this sql query
+ INSERT INTO `admins` ( `userid` , `username` , `password` ) VALUES ( '', 'ADMIN_USERNAME', MD5( 'YOUR_PASSWORD' ));
+
+5) edit frontend/includes/config.inc.php
+6) chmod 777 frontend/compiled_templates
+Admin Login URL /admin/
+
+
+Backend Setup:
+1) Place scrips in a directory outside the web interface.
+2) edit backend/includes/globals.php
+3) change this line to the correct path
+4) require("/var/www/html/includes/config.inc.php");
+5) chmod 755 *.php
+6) ensure path to php is correct in all command scripts
+7) Setup processqueue.php to run on a cron as often as 1 minute.
+ */5 * * * * /path/to/processqueue.php
+
+Script definitions:
+addzone.php - Command line Add Zone script
+processqueue.php - This is the script that processes all changes made to zones
+rebuildzones.php - Rebuilds all zone files, maintenance script
+rewriteconf.php - Rebuilds named.conf
+removeorphans.php - Removes orphans domains from your named dir. If it doesnt exist in the DB, it will remove the zone file
+
+
+Notes:
+
+Process queue link in web interface does not work yet.
0 README
No changes.
2 TODO
@@ -0,0 +1,2 @@
+reorganize and cleanup DNS class
+validate record name input
17 backend/addzone.php
@@ -0,0 +1,17 @@
+#!/usr/bin/php -q
+<?php
+require(dirname(__FILE__).'/includes/globals.php');
+
+if($argc == 4) {
+ if(!$dns->addZone($argv[1], $argv[2], $argv[3])) {
+ print $dns->error . "\n";
+ }
+ else {
+ print "Added $argv[1]:$argv[2] password:$argv[3]\n";
+ }
+}
+else {
+ print "Usage: $argv[0] <zone> <ip> <password>\n";
+}
+
+?>
22 backend/includes/globals.php
@@ -0,0 +1,22 @@
+<?php
+/* $Id: globals.php 61 2005-02-26 19:43:12Z justin $ */
+require("/var/www/html/includes/config.inc.php");
+
+
+$tpl_path = $base_path . "/includes/templates";
+require($base_path . "/includes/functions.inc.php");
+require($base_path . "/includes/adodb/adodb.inc.php");
+require($base_path . "/includes/adodb/adodb-errorhandler.inc.php");
+require($base_path . "/includes/adodb/session/adodb-session.php");
+
+$db = NewADOConnection('mysql');
+$db->Connect($db_host, $db_user, $db_pass, $db_name);
+
+require($base_path . "/includes/classes/dns.inc.php");
+
+$dns = new DNS($db, $zone_path, $conf_file, $tpl_path);
+$dns->dns1 = $dns1;
+$dns->dns2 = $dns2;
+$dns->dnshostmaster = $dnshostmaster;
+
+?>
41 backend/processqueue.php
@@ -0,0 +1,41 @@
+#!/usr/bin/php -q
+<?php
+require(dirname(__FILE__).'/includes/globals.php');
+
+if($offline_mode) {
+ print "Offline Mode\n";
+ exit(0);
+}
+
+if(!$dns->createLock("DNS")) {
+ print $dns->error;
+ exit;
+}
+
+//Mod
+if(!$dns->processModqueue()) {
+ print $dns->error;
+}
+else {
+ print "Mods completed\n";
+}
+
+//Mod
+if(!$dns->processAddqueue()) {
+ print $dns->error;
+}
+else {
+ print "Adds completed\n";
+}
+
+//del
+if(!$dns->processDelqueue()) {
+ print $dns->error;
+}
+else {
+ print "Delete completed\n";
+}
+$dns->delLock("DNS");
+
+?>
+
8 backend/rebuildzones.php
@@ -0,0 +1,8 @@
+#!/usr/bin/php -q
+<?php
+
+require(dirname(__FILE__).'/includes/globals.php');
+
+$dns->rebuildZones();
+
+?>
41 backend/removeorphans.php
@@ -0,0 +1,41 @@
+#!/usr/bin/php -q
+<?php
+require(dirname(__FILE__).'/includes/globals.php');
+
+if($offline_mode) {
+ print "Offline Mode\n";
+ exit(0);
+}
+if(!$dns->createLock("ORPHAN")) {
+ print $dns->error;
+ exit;
+}
+function alter_record(&$domain, $key) {
+ global $orphans, $dns, $db, $zone_path;
+ if(empty($zone_path)) {
+ print "Zone path not set!\n";
+ $dns->delLock("ORPHAN");
+ exit(-1);
+ }
+ $domain = preg_replace("/.*\//", "", $domain);
+ $domain = trim($domain);
+ if($dns->isDomain($domain)) {
+ $d = $db->quote($domain);
+ $q = $db->getOne("SELECT count(domainid) FROM domains WHERE domain = $d");
+ if($q == "0") {
+ $orphans[] = $domain;
+ print "Removing: $domain .... ";
+ $letter = substr($domain, 0, 1);
+ unlink("$zone_path/$letter/$domain");
+ print "Done!\n";
+ }
+ }
+}
+
+$zones = exec("find $zone_path -type f", $domains);
+array_walk($domains, 'alter_record');
+
+$dns->delLock("ORPHAN");
+
+?>
+
7 backend/rewriteconf.php
@@ -0,0 +1,7 @@
+#!/usr/bin/php -q
+<?php
+require(dirname(__FILE__).'/includes/globals.php');
+
+$dns->writeConf();
+
+?>
22 frontend/addrecord.php
@@ -0,0 +1,22 @@
+<?php
+/* $Id: addrecord.php 32 2005-03-03 19:17:23Z justin $ */
+include("includes/globals.php");
+$session->isAuth();
+if($_SERVER['REQUEST_METHOD'] == "POST") {
+ $tpl->assign('domain', $_SESSION['valid_user']);
+ if(!$dns->addRecord($_POST['type'], $_SESSION['valid_user'], $_POST['name'], $_POST['address'])) {
+ $message = $dns->error;
+ header("Location: index.php?failed=1&msg=". urlencode($message));
+ }
+ else {
+ $message = "Record Added";
+ header("Location: index.php?msg=". urlencode($message));
+ }
+}
+else {
+ $domain = $_SESSION['valid_user'];
+ $tpl->assign('ip', $dns->zoneIp($domain));
+ $tpl->display("addrecord.htm");
+}
+
+?>
19 frontend/admin/addzone.php
@@ -0,0 +1,19 @@
+<?php
+/* $Id: addrecord.php 29 2005-02-28 21:47:53Z justin $ */
+include("../includes/globals.php");
+$session->isAdmin();
+if($_POST['act'] == 'add') {
+ if(!$dns->addZone($_POST['domain'], $_POST['ip'], $_POST['password'])) {
+ $message = $dns->error;
+ header("Location: index.php?failed=1&msg=". urlencode($message));
+ }
+ else {
+ $message = "Zone Added";
+ header("Location: index.php?msg=". urlencode($message));
+ }
+}
+else {
+ $tpl->display("admin/addzone.htm");
+}
+
+?>
49 frontend/admin/index.php
@@ -0,0 +1,49 @@
+<?php
+/* $Id: index.php 27 2005-02-28 21:37:51Z justin $ */
+include("../includes/globals.php");
+$session->isAdmin();
+
+if($_GET['act'] == 'runqueue') {
+ exit;
+ if(!$dns->createLock("DNS")) {
+ $message = $dns->error;
+ header("Location: index.php?failed=1&msg=" . urlencode($message));
+ }
+ else {
+ $dns->processModqueue();
+ $dns->processAddqueue();
+ $dns->processDelqueue();
+ $message = "Queue has been run\n";
+ $dns->delLock("DNS");
+ header("Location: index.php?msg=" . urlencode($message));
+ }
+}
+
+if(empty($_GET['start'])) {
+ $start = "0";
+}
+else {
+ if(is_numeric($_GET['start'])) {
+ $start = $_GET['start'];
+ }
+ else {
+ $start = "0";
+ }
+}
+if($_GET['failed'] == "1") {
+ $color = 'red';
+}
+else {
+ $color = 'green';
+}
+$perpage = 25;
+$count = $db->getOne("SELECT count(domainid) FROM domains WHERE domainid != '1' ORDER BY domain");
+$paging = generate_pagination($_SERVER['PHP_SELF']."?", $count, $perpage, $start);
+$domains = $db->getAll("SELECT domainid, domain, password FROM domains WHERE domainid != '1' ORDER BY domain LIMIT $start, $perpage");
+$tpl->assign('color', $color);
+$tpl->assign('paging', $paging);
+$tpl->assign('totaldomains', $count);
+$tpl->assign('msg', $_GET['msg']);
+$tpl->assign('domains', $domains);
+$tpl->display('admin/index.htm');
+?>
21 frontend/admin/login.php
@@ -0,0 +1,21 @@
+<?php
+/* $Id: login.php 15 2005-02-28 16:04:31Z justin $ */
+include("../includes/globals.php");
+if($session->isAdmin()) {
+ header("Location: index.php");
+ exit;
+}
+if(!empty($_POST['username']) && !empty($_POST['password'])) {
+ $session->authAdmin($_POST['username'], $_POST['password']);
+}
+else{
+ if($_GET['failed']) {
+ print "<center><font color=\"red\"><b>The information you entered is incorrect</b></font>";
+ }
+ if($_GET['msg']) {
+ print "<center><b><font color=\"red\">$msg</b></font>";
+ }
+ $tpl->display("admin/login.htm");
+}
+
+?>
6 frontend/admin/logout.php
@@ -0,0 +1,6 @@
+<?php
+/* $Id: logout.php 15 2005-02-28 16:04:31Z justin $ */
+include("../includes/globals.php");
+$session->isAdmin();
+$session->destroy();
+?>
35 frontend/admin/modzone.php
@@ -0,0 +1,35 @@
+<?php
+/* $Id: modrecord.php 27 2005-02-28 21:37:51Z justin $ */
+include("../includes/globals.php");
+$session->isAdmin();
+if(!empty($_REQUEST['domainid'])) {
+ switch($_REQUEST['act']) {
+ case 'del':
+ $domainid = $db->quote($_REQUEST['domainid']);
+ $domain = $db->getOne("SELECT domain FROM domains WHERE domainid = $domainid");
+ $dns->removeZone($domain);
+ $message = "$domain has been removed\n";
+ header("Location: index.php?msg=" . urlencode($message));
+ break;
+ case 'edit':
+ $info = $dns->zoneInfo($_GET['domainid']);
+ $tpl->assign('password', $info['password']);
+ $tpl->assign('domain', $info['domain']);
+ $tpl->display('admin/editzone.htm');
+ break;
+ case 'update':
+ $dns->updateZonePass($_POST['domainid'], $_POST['password']);
+ $message = "Password updated\n";
+ header("Location: index.php?msg=" . urlencode($message));
+ break;
+ default:
+ header("Location: index.php?failed=1&msg=Invalid+Action");
+ break;
+ }
+}
+else {
+ header("Location: index.php");
+}
+//$tpl->display("index.htm");
+
+?>
36 frontend/admin/search.php
@@ -0,0 +1,36 @@
+<?php
+/* $Id: index.php 27 2005-02-28 21:37:51Z justin $ */
+include("../includes/globals.php");
+$session->isAdmin();
+if(empty($_REQUEST['act']) || !isset($_REQUEST['q'])) {
+ $tpl->display('admin/search_form.htm');
+}
+else {
+ $search_term = "";
+ if($_REQUEST['contains'] == "1") {
+ $search_term = $db->quote('%'.$_REQUEST['q']. '%');
+ }
+ else {
+ $search_term = $db->quote($_REQUEST['q']. '%');
+ }
+
+ if(empty($_GET['start'])) {
+ $start = "0";
+ }
+ else {
+ if(is_numeric($_GET['start'])) {
+ $start = $_GET['start'];
+ }
+ else {
+ $start = "0";
+ }
+ }
+ $perpage = 25;
+ $count = $db->getOne("SELECT count(domainid) FROM domains WHERE domain like $search_term");
+ $paging = generate_pagination($_SERVER['PHP_SELF']."?act=result&q=".$_REQUEST['q']."&contains=".$_REQUEST['contains'], $count, $perpage, $start);
+ $results = $db->getAll("SELECT domainid, domain, password FROM domains WHERE domain like $search_term LIMIT $start, $perpage");
+ $tpl->assign("domains", $results);
+ $tpl->assign("paging", $paging);
+ $tpl->display('admin/search_results.htm');
+}
+?>
25 frontend/changeip.php
@@ -0,0 +1,25 @@
+<?php
+/* $Id: modrecord.php 27 2005-02-28 21:37:51Z justin $ */
+include("includes/globals.php");
+$session->isAuth();
+$domain = $_SESSION['valid_user'];
+if($_REQUEST['act'] == 'edit') {
+ $info = $dns->zoneInfo($_SESSION['domainid']);
+ $tpl->assign('ip', $info['address']);
+ $tpl->display('editip.htm');
+}
+elseif($_REQUEST['act'] == 'update') {
+ if(!$dns->updateIP($_SESSION['domainid'], $_REQUEST['address'])) {
+ $message = $dns->error;
+ header("Location: index.php?failed=1msg=" . urlencode($message));
+ }
+ else {
+ $message = "IP updated\n";
+ header("Location: index.php?msg=" . urlencode($message));
+ }
+}
+else {
+ header("Location: index.php");
+}
+
+?>
2 frontend/compiled_templates/.htaccess
@@ -0,0 +1,2 @@
+Options -Indexes
+deny from all
311 frontend/includes/adodb/adodb-csvlib.inc.php
@@ -0,0 +1,311 @@
+<?php
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+global $ADODB_INCLUDED_CSV;
+$ADODB_INCLUDED_CSV = 1;
+
+/*
+
+ V4.61 24 Feb 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for CSV serialization. This is used by the csv/proxy driver and is the
+ CacheExecute() serialization format.
+
+ ==== NOTE ====
+ Format documented at http://php.weblogs.com/ADODB_CSV
+ ==============
+*/
+
+ /**
+ * convert a recordset into special format
+ *
+ * @param rs the recordset
+ *
+ * @return the CSV formated data
+ */
+ function _rs2serialize(&$rs,$conn=false,$sql='')
+ {
+ $max = ($rs) ? $rs->FieldCount() : 0;
+
+ if ($sql) $sql = urlencode($sql);
+ // metadata setup
+
+ if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete
+ if (is_object($conn)) {
+ $sql .= ','.$conn->Affected_Rows();
+ $sql .= ','.$conn->Insert_ID();
+ } else
+ $sql .= ',,';
+
+ $text = "====-1,0,$sql\n";
+ return $text;
+ }
+ $tt = ($rs->timeCreated) ? $rs->timeCreated : time();
+
+ ## changed format from ====0 to ====1
+ $line = "====1,$tt,$sql\n";
+
+ if ($rs->databaseType == 'array') {
+ $rows =& $rs->_array;
+ } else {
+ $rows = array();
+ while (!$rs->EOF) {
+ $rows[] = $rs->fields;
+ $rs->MoveNext();
+ }
+ }
+
+ for($i=0; $i < $max; $i++) {
+ $o =& $rs->FetchField($i);
+ $flds[] = $o;
+ }
+
+ $savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
+ $class = $rs->connection->arrayClass;
+ $rs2 =& new $class();
+ $rs2->sql = $rs->sql;
+ $rs2->oldProvider = $rs->dataProvider;
+ $rs2->InitArrayFields($rows,$flds);
+ $rs2->fetchMode = $savefetch;
+ return $line.serialize($rs2);
+ }
+
+
+/**
+* Open CSV file and convert it into Data.
+*
+* @param url file/ftp/http url
+* @param err returns the error message
+* @param timeout dispose if recordset has been alive for $timeout secs
+*
+* @return recordset, or false if error occured. If no
+* error occurred in sql INSERT/UPDATE/DELETE,
+* empty recordset is returned
+*/
+ function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
+ {
+ $err = false;
+ $fp = @fopen($url,'rb');
+ if (!$fp) {
+ $err = $url.' file/URL not found';
+ return false;
+ }
+ flock($fp, LOCK_SH);
+ $arr = array();
+ $ttl = 0;
+
+ if ($meta = fgetcsv($fp, 32000, ",")) {
+ // check if error message
+ if (strncmp($meta[0],'****',4) === 0) {
+ $err = trim(substr($meta[0],4,1024));
+ fclose($fp);
+ return false;
+ }
+ // check for meta data
+ // $meta[0] is -1 means return an empty recordset
+ // $meta[1] contains a time
+
+ if (strncmp($meta[0], '====',4) === 0) {
+
+ if ($meta[0] == "====-1") {
+ if (sizeof($meta) < 5) {
+ $err = "Corrupt first line for format -1";
+ fclose($fp);
+ return false;
+ }
+ fclose($fp);
+
+ if ($timeout > 0) {
+ $err = " Illegal Timeout $timeout ";
+ return false;
+ }
+
+ $rs =& new $rsclass($val=true);
+ $rs->fields = array();
+ $rs->timeCreated = $meta[1];
+ $rs->EOF = true;
+ $rs->_numOfFields = 0;
+ $rs->sql = urldecode($meta[2]);
+ $rs->affectedrows = (integer)$meta[3];
+ $rs->insertid = $meta[4];
+ return $rs;
+ }
+ # Under high volume loads, we want only 1 thread/process to _write_file
+ # so that we don't have 50 processes queueing to write the same data.
+ # We use probabilistic timeout, ahead of time.
+ #
+ # -4 sec before timeout, give processes 1/32 chance of timing out
+ # -2 sec before timeout, give processes 1/16 chance of timing out
+ # -1 sec after timeout give processes 1/4 chance of timing out
+ # +0 sec after timeout, give processes 100% chance of timing out
+ if (sizeof($meta) > 1) {
+ if($timeout >0){
+ $tdiff = (integer)( $meta[1]+$timeout - time());
+ if ($tdiff <= 2) {
+ switch($tdiff) {
+ case 4:
+ case 3:
+ if ((rand() & 31) == 0) {
+ fclose($fp);
+ $err = "Timeout 3";
+ return false;
+ }
+ break;
+ case 2:
+ if ((rand() & 15) == 0) {
+ fclose($fp);
+ $err = "Timeout 2";
+ return false;
+ }
+ break;
+ case 1:
+ if ((rand() & 3) == 0) {
+ fclose($fp);
+ $err = "Timeout 1";
+ return false;
+ }
+ break;
+ default:
+ fclose($fp);
+ $err = "Timeout 0";
+ return false;
+ } // switch
+
+ } // if check flush cache
+ }// (timeout>0)
+ $ttl = $meta[1];
+ }
+ //================================================
+ // new cache format - use serialize extensively...
+ if ($meta[0] === '====1') {
+ // slurp in the data
+ $MAXSIZE = 128000;
+
+ $text = fread($fp,$MAXSIZE);
+ if (strlen($text)) {
+ while ($txt = fread($fp,$MAXSIZE)) {
+ $text .= $txt;
+ }
+ }
+ fclose($fp);
+ $rs = unserialize($text);
+ if (is_object($rs)) $rs->timeCreated = $ttl;
+ else {
+ $err = "Unable to unserialize recordset";
+ //echo htmlspecialchars($text),' !--END--!<p>';
+ }
+ return $rs;
+ }
+
+ $meta = false;
+ $meta = fgetcsv($fp, 32000, ",");
+ if (!$meta) {
+ fclose($fp);
+ $err = "Unexpected EOF 1";
+ return false;
+ }
+ }
+
+ // Get Column definitions
+ $flds = array();
+ foreach($meta as $o) {
+ $o2 = explode(':',$o);
+ if (sizeof($o2)!=3) {
+ $arr[] = $meta;
+ $flds = false;
+ break;
+ }
+ $fld =& new ADOFieldObject();
+ $fld->name = urldecode($o2[0]);
+ $fld->type = $o2[1];
+ $fld->max_length = $o2[2];
+ $flds[] = $fld;
+ }
+ } else {
+ fclose($fp);
+ $err = "Recordset had unexpected EOF 2";
+ return false;
+ }
+
+ // slurp in the data
+ $MAXSIZE = 128000;
+
+ $text = '';
+ while ($txt = fread($fp,$MAXSIZE)) {
+ $text .= $txt;
+ }
+
+ fclose($fp);
+ @$arr = unserialize($text);
+ //var_dump($arr);
+ if (!is_array($arr)) {
+ $err = "Recordset had unexpected EOF (in serialized recordset)";
+ if (get_magic_quotes_runtime()) $err .= ". Magic Quotes Runtime should be disabled!";
+ return false;
+ }
+ $rs =& new $rsclass();
+ $rs->timeCreated = $ttl;
+ $rs->InitArrayFields($arr,$flds);
+ return $rs;
+ }
+
+
+ /**
+ * Save a file $filename and its $contents (normally for caching) with file locking
+ */
+ function adodb_write_file($filename, $contents,$debug=false)
+ {
+ # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
+ # So to simulate locking, we assume that rename is an atomic operation.
+ # First we delete $filename, then we create a $tempfile write to it and
+ # rename to the desired $filename. If the rename works, then we successfully
+ # modified the file exclusively.
+ # What a stupid need - having to simulate locking.
+ # Risks:
+ # 1. $tempfile name is not unique -- very very low
+ # 2. unlink($filename) fails -- ok, rename will fail
+ # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
+ # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
+ if (strncmp(PHP_OS,'WIN',3) === 0) {
+ // skip the decimal place
+ $mtime = substr(str_replace(' ','_',microtime()),2);
+ // getmypid() actually returns 0 on Win98 - never mind!
+ $tmpname = $filename.uniqid($mtime).getmypid();
+ if (!($fd = fopen($tmpname,'a'))) return false;
+ $ok = ftruncate($fd,0);
+ if (!fwrite($fd,$contents)) $ok = false;
+ fclose($fd);
+ chmod($tmpname,0644);
+ // the tricky moment
+ @unlink($filename);
+ if (!@rename($tmpname,$filename)) {
+ unlink($tmpname);
+ $ok = false;
+ }
+ if (!$ok) {
+ if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
+ }
+ return $ok;
+ }
+ if (!($fd = fopen($filename, 'a'))) return false;
+ if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
+ $ok = fwrite( $fd, $contents );
+ fclose($fd);
+ chmod($filename,0644);
+ }else {
+ fclose($fd);
+ if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
+ $ok = false;
+ }
+
+ return $ok;
+ }
+?>
771 frontend/includes/adodb/adodb-datadict.inc.php
@@ -0,0 +1,771 @@
+<?php
+
+/**
+ V4.61 24 Feb 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+ DOCUMENTATION:
+
+ See adodb/tests/test-datadict.php for docs and examples.
+*/
+
+/*
+ Test script for parser
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+function Lens_ParseTest()
+{
+$str = "`zcol ACOL` NUMBER(32,2) DEFAULT 'The \"cow\" (and Jim''s dog) jumps over the moon' PRIMARY, INTI INT AUTO DEFAULT 0, zcol2\"afs ds";
+print "<p>$str</p>";
+$a= Lens_ParseArgs($str);
+print "<pre>";
+print_r($a);
+print "</pre>";
+}
+
+
+if (!function_exists('ctype_alnum')) {
+ function ctype_alnum($text) {
+ return preg_match('/^[a-z0-9]*$/i', $text);
+ }
+}
+
+//Lens_ParseTest();
+
+/**
+ Parse arguments, treat "text" (text) and 'text' as quotation marks.
+ To escape, use "" or '' or ))
+
+ Will read in "abc def" sans quotes, as: abc def
+ Same with 'abc def'.
+ However if `abc def`, then will read in as `abc def`
+
+ @param endstmtchar Character that indicates end of statement
+ @param tokenchars Include the following characters in tokens apart from A-Z and 0-9
+ @returns 2 dimensional array containing parsed tokens.
+*/
+function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-')
+{
+ $pos = 0;
+ $intoken = false;
+ $stmtno = 0;
+ $endquote = false;
+ $tokens = array();
+ $tokens[$stmtno] = array();
+ $max = strlen($args);
+ $quoted = false;
+
+ while ($pos < $max) {
+ $ch = substr($args,$pos,1);
+ switch($ch) {
+ case ' ':
+ case "\t":
+ case "\n":
+ case "\r":
+ if (!$quoted) {
+ if ($intoken) {
+ $intoken = false;
+ $tokens[$stmtno][] = implode('',$tokarr);
+ }
+ break;
+ }
+
+ $tokarr[] = $ch;
+ break;
+
+ case '`':
+ if ($intoken) $tokarr[] = $ch;
+ case '(':
+ case ')':
+ case '"':
+ case "'":
+
+ if ($intoken) {
+ if (empty($endquote)) {
+ $tokens[$stmtno][] = implode('',$tokarr);
+ if ($ch == '(') $endquote = ')';
+ else $endquote = $ch;
+ $quoted = true;
+ $intoken = true;
+ $tokarr = array();
+ } else if ($endquote == $ch) {
+ $ch2 = substr($args,$pos+1,1);
+ if ($ch2 == $endquote) {
+ $pos += 1;
+ $tokarr[] = $ch2;
+ } else {
+ $quoted = false;
+ $intoken = false;
+ $tokens[$stmtno][] = implode('',$tokarr);
+ $endquote = '';
+ }
+ } else
+ $tokarr[] = $ch;
+
+ }else {
+
+ if ($ch == '(') $endquote = ')';
+ else $endquote = $ch;
+ $quoted = true;
+ $intoken = true;
+ $tokarr = array();
+ if ($ch == '`') $tokarr[] = '`';
+ }
+ break;
+
+ default:
+
+ if (!$intoken) {
+ if ($ch == $endstmtchar) {
+ $stmtno += 1;
+ $tokens[$stmtno] = array();
+ break;
+ }
+
+ $intoken = true;
+ $quoted = false;
+ $endquote = false;
+ $tokarr = array();
+
+ }
+
+ if ($quoted) $tokarr[] = $ch;
+ else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch;
+ else {
+ if ($ch == $endstmtchar) {
+ $tokens[$stmtno][] = implode('',$tokarr);
+ $stmtno += 1;
+ $tokens[$stmtno] = array();
+ $intoken = false;
+ $tokarr = array();
+ break;
+ }
+ $tokens[$stmtno][] = implode('',$tokarr);
+ $tokens[$stmtno][] = $ch;
+ $intoken = false;
+ }
+ }
+ $pos += 1;
+ }
+ if ($intoken) $tokens[$stmtno][] = implode('',$tokarr);
+
+ return $tokens;
+}
+
+
+class ADODB_DataDict {
+ var $connection;
+ var $debug = false;
+ var $dropTable = 'DROP TABLE %s';
+ var $renameTable = 'RENAME TABLE %s TO %s';
+ var $dropIndex = 'DROP INDEX %s';
+ var $addCol = ' ADD';
+ var $alterCol = ' ALTER COLUMN';
+ var $dropCol = ' DROP COLUMN';
+ var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default)
+ var $nameRegex = '\w';
+ var $schema = false;
+ var $serverInfo = array();
+ var $autoIncrement = false;
+ var $dataProvider;
+ var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql
+ var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
+ /// in other words, we use a text area for editting.
+
+ function GetCommentSQL($table,$col)
+ {
+ return false;
+ }
+
+ function SetCommentSQL($table,$col,$cmt)
+ {
+ return false;
+ }
+
+ function &MetaTables()
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaTables();
+ }
+
+ function &MetaColumns($tab, $upper=true, $schema=false)
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema);
+ }
+
+ function &MetaPrimaryKeys($tab,$owner=false,$intkey=false)
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey);
+ }
+
+ function &MetaIndexes($table, $primary = false, $owner = false)
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ return ADORecordSet::MetaType($t,$len,$fieldobj);
+ }
+
+ function NameQuote($name = NULL)
+ {
+ if (!is_string($name)) {
+ return FALSE;
+ }
+
+ $name = trim($name);
+
+ if ( !is_object($this->connection) ) {
+ return $name;
+ }
+
+ $quote = $this->connection->nameQuote;
+
+ // if name is of the form `name`, quote it
+ if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
+ return $quote . $matches[1] . $quote;
+ }
+
+ // if name contains special characters, quote it
+ if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) {
+ return $quote . $name . $quote;
+ }
+
+ return $name;
+ }
+
+ function TableName($name)
+ {
+ if ( $this->schema ) {
+ return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name);
+ }
+ return $this->NameQuote($name);
+ }
+
+ // Executes the sql array returned by GetTableSQL and GetIndexSQL
+ function ExecuteSQLArray($sql, $continueOnError = true)
+ {
+ $rez = 2;
+ $conn = &$this->connection;
+ $saved = $conn->debug;
+ foreach($sql as $line) {
+
+ if ($this->debug) $conn->debug = true;
+ $ok = $conn->Execute($line);
+ $conn->debug = $saved;
+ if (!$ok) {
+ if ($this->debug) ADOConnection::outp($conn->ErrorMsg());
+ if (!$continueOnError) return 0;
+ $rez = 1;
+ }
+ }
+ return $rez;
+ }
+
+ /*
+ Returns the actual type given a character code.
+
+ C: varchar
+ X: CLOB (character large object) or largest varchar size if CLOB is not supported
+ C2: Multibyte varchar
+ X2: Multibyte CLOB
+
+ B: BLOB (binary large object)
+
+ D: Date
+ T: Date-time
+ L: Integer field suitable for storing booleans (0 or 1)
+ I: Integer
+ F: Floating point number
+ N: Numeric or decimal number
+ */
+
+ function ActualType($meta)
+ {
+ return $meta;
+ }
+
+ function CreateDatabase($dbname,$options=false)
+ {
+ $options = $this->_Options($options);
+ $sql = array();
+
+ $s = 'CREATE DATABASE ' . $this->NameQuote($dbname);
+ if (isset($options[$this->upperName]))
+ $s .= ' '.$options[$this->upperName];
+
+ $sql[] = $s;
+ return $sql;
+ }
+
+ /*
+ Generates the SQL to create index. Returns an array of sql strings.
+ */
+ function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false)
+ {
+ if (!is_array($flds)) {
+ $flds = explode(',',$flds);
+ }
+
+ foreach($flds as $key => $fld) {
+ $flds[$key] = $this->NameQuote($fld);
+ }
+
+ return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions));
+ }
+
+ function DropIndexSQL ($idxname, $tabname = NULL)
+ {
+ return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname)));
+ }
+
+ function SetSchema($schema)
+ {
+ $this->schema = $schema;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
+ foreach($lines as $v) {
+ $sql[] = $alter . $v;
+ }
+ return $sql;
+ }
+
+ /**
+ * Change the definition of one column
+ *
+ * As some DBM's can't do that on there own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default ''
+ * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+ foreach($lines as $v) {
+ $sql[] = $alter . $v;
+ }
+ return $sql;
+ }
+
+ /**
+ * Rename one column
+ *
+ * Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql)
+ * @param string $tabname table-name
+ * @param string $oldcolumn column-name to be renamed
+ * @param string $newcolumn new column-name
+ * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default=''
+ * @return array with SQL strings
+ */
+ function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if ($flds) {
+ list($lines,$pkey) = $this->_GenFields($flds);
+ list(,$first) = each($lines);
+ list(,$column_def) = split("[\t ]+",$first,2);
+ }
+ return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
+ }
+
+ /**
+ * Drop one column
+ *
+ * Some DBM's can't do that on there own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default ''
+ * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ $sql = array();
+ $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' ';
+ foreach($flds as $v) {
+ $sql[] = $alter . $this->NameQuote($v);
+ }
+ return $sql;
+ }
+
+ function DropTableSQL($tabname)
+ {
+ return array (sprintf($this->dropTable, $this->TableName($tabname)));
+ }
+
+ function RenameTableSQL($tabname,$newname)
+ {
+ return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
+ }
+
+ /*
+ Generate the SQL to create table. Returns an array of sql strings.
+ */
+ function CreateTableSQL($tabname, $flds, $tableoptions=false)
+ {
+ if (!$tableoptions) $tableoptions = array();
+
+ list($lines,$pkey) = $this->_GenFields($flds, true);
+
+ $taboptions = $this->_Options($tableoptions);
+ $tabname = $this->TableName ($tabname);
+ $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions);
+
+ $tsql = $this->_Triggers($tabname,$taboptions);
+ foreach($tsql as $s) $sql[] = $s;
+
+ return $sql;
+ }
+
+ function _GenFields($flds,$widespacing=false)
+ {
+ if (is_string($flds)) {
+ $padding = ' ';
+ $txt = $flds.$padding;
+ $flds = array();
+ $flds0 = Lens_ParseArgs($txt,',');
+ $hasparam = false;
+ foreach($flds0 as $f0) {
+ $f1 = array();
+ foreach($f0 as $token) {
+ switch (strtoupper($token)) {
+ case 'CONSTRAINT':
+ case 'DEFAULT':
+ $hasparam = $token;
+ break;
+ default:
+ if ($hasparam) $f1[$hasparam] = $token;
+ else $f1[] = $token;
+ $hasparam = false;
+ break;
+ }
+ }
+ $flds[] = $f1;
+
+ }
+ }
+ $this->autoIncrement = false;
+ $lines = array();
+ $pkey = array();
+ foreach($flds as $fld) {
+ $fld = _array_change_key_case($fld);
+
+ $fname = false;
+ $fdefault = false;
+ $fautoinc = false;
+ $ftype = false;
+ $fsize = false;
+ $fprec = false;
+ $fprimary = false;
+ $fnoquote = false;
+ $fdefts = false;
+ $fdefdate = false;
+ $fconstraint = false;
+ $fnotnull = false;
+ $funsigned = false;
+
+ //-----------------
+ // Parse attributes
+ foreach($fld as $attr => $v) {
+ if ($attr == 2 && is_numeric($v)) $attr = 'SIZE';
+ else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v);
+
+ switch($attr) {
+ case '0':
+ case 'NAME': $fname = $v; break;
+ case '1':
+ case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break;
+
+ case 'SIZE':
+ $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,',');
+ if ($dotat === false) $fsize = $v;
+ else {
+ $fsize = substr($v,0,$dotat);
+ $fprec = substr($v,$dotat+1);
+ }
+ break;
+ case 'UNSIGNED': $funsigned = true; break;
+ case 'AUTOINCREMENT':
+ case 'AUTO': $fautoinc = true; $fnotnull = true; break;
+ case 'KEY':
+ case 'PRIMARY': $fprimary = $v; $fnotnull = true; break;
+ case 'DEF':
+ case 'DEFAULT': $fdefault = $v; break;
+ case 'NOTNULL': $fnotnull = $v; break;
+ case 'NOQUOTE': $fnoquote = $v; break;
+ case 'DEFDATE': $fdefdate = $v; break;
+ case 'DEFTIMESTAMP': $fdefts = $v; break;
+ case 'CONSTRAINT': $fconstraint = $v; break;
+ } //switch
+ } // foreach $fld
+
+ //--------------------
+ // VALIDATE FIELD INFO
+ if (!strlen($fname)) {
+ if ($this->debug) ADOConnection::outp("Undefined NAME");
+ return false;
+ }
+
+ $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname));
+ $fname = $this->NameQuote($fname);
+
+ if (!strlen($ftype)) {
+ if ($this->debug) ADOConnection::outp("Undefined TYPE for field '$fname'");
+ return false;
+ } else {
+ $ftype = strtoupper($ftype);
+ }
+
+ $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec);
+
+ if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls
+
+ if ($fprimary) $pkey[] = $fname;
+
+ // some databases do not allow blobs to have defaults
+ if ($ty == 'X') $fdefault = false;
+
+ //--------------------
+ // CONSTRUCT FIELD SQL
+ if ($fdefts) {
+ if (substr($this->connection->databaseType,0,5) == 'mysql') {
+ $ftype = 'TIMESTAMP';
+ } else {
+ $fdefault = $this->connection->sysTimeStamp;
+ }
+ } else if ($fdefdate) {
+ if (substr($this->connection->databaseType,0,5) == 'mysql') {
+ $ftype = 'TIMESTAMP';
+ } else {
+ $fdefault = $this->connection->sysDate;
+ }
+ } else if (strlen($fdefault) && !$fnoquote)
+ if ($ty == 'C' or $ty == 'X' or
+ ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault)))
+ if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ')
+ $fdefault = trim($fdefault);
+ else if (strtolower($fdefault) != 'null')
+ $fdefault = $this->connection->qstr($fdefault);
+ $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned);
+
+ if ($widespacing) $fname = str_pad($fname,24);
+ $lines[$fid] = $fname.' '.$ftype.$suffix;
+
+ if ($fautoinc) $this->autoIncrement = true;
+ } // foreach $flds
+
+ return array($lines,$pkey);
+ }
+ /*
+ GENERATE THE SIZE PART OF THE DATATYPE
+ $ftype is the actual type
+ $ty is the type defined originally in the DDL
+ */
+ function _GetSize($ftype, $ty, $fsize, $fprec)
+ {
+ if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {
+ $ftype .= "(".$fsize;
+ if (strlen($fprec)) $ftype .= ",".$fprec;
+ $ftype .= ')';
+ }
+ return $ftype;
+ }
+
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+
+ $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s .= '(' . $flds . ')';
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ function _DropAutoIncrement($tabname)
+ {
+ return false;
+ }
+
+ function _TableSQL($tabname,$lines,$pkey,$tableoptions)
+ {
+ $sql = array();
+
+ if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) {
+ $sql[] = sprintf($this->dropTable,$tabname);
+ if ($this->autoIncrement) {
+ $sInc = $this->_DropAutoIncrement($tabname);
+ if ($sInc) $sql[] = $sInc;
+ }
+ if ( isset ($tableoptions['DROP']) ) {
+ return $sql;
+ }
+ }
+ $s = "CREATE TABLE $tabname (\n";
+ $s .= implode(",\n", $lines);
+ if (sizeof($pkey)>0) {
+ $s .= ",\n PRIMARY KEY (";
+ $s .= implode(", ",$pkey).")";
+ }
+ if (isset($tableoptions['CONSTRAINTS']))
+ $s .= "\n".$tableoptions['CONSTRAINTS'];
+
+ if (isset($tableoptions[$this->upperName.'_CONSTRAINTS']))
+ $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS'];
+
+ $s .= "\n)";
+ if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName];
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ /*
+ GENERATE TRIGGERS IF NEEDED
+ used when table has auto-incrementing field that is emulated using triggers
+ */
+ function _Triggers($tabname,$taboptions)
+ {
+ return array();
+ }
+
+ /*
+ Sanitize options, so that array elements with no keys are promoted to keys
+ */
+ function _Options($opts)
+ {
+ if (!is_array($opts)) return array();
+ $newopts = array();
+ foreach($opts as $k => $v) {
+ if (is_numeric($k)) $newopts[strtoupper($v)] = $v;
+ else $newopts[strtoupper($k)] = $v;
+ }
+ return $newopts;
+ }
+
+ /*
+ "Florian Buzin [ easywe ]" <florian.buzin#easywe.de>
+
+ This function changes/adds new fields to your table. You don't
+ have to know if the col is new or not. It will check on its own.
+ */
+ function ChangeTableSQL($tablename, $flds, $tableoptions = false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false);
+
+ // check table exists
+ $cols = &$this->MetaColumns($tablename);
+
+ if (isset($savem)) $this->connection->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ( empty($cols)) {
+ return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+ }
+
+ if (is_array($flds)) {
+ // Cycle through the update fields, comparing
+ // existing fields to fields to update.
+ // if the Metatype and size is exactly the
+ // same, ignore - by Mark Newham
+ $holdflds = array();
+ foreach($flds as $k=>$v) {
+ if ( isset($cols[$k]) && is_object($cols[$k]) ) {
+ $c = $cols[$k];
+ $ml = $c->max_length;
+ $mt = &$this->MetaType($c->type,$ml);
+ if ($ml == -1) $ml = '';
+ if ($mt == 'X') $ml = $v['SIZE'];
+ if (($mt != $v['TYPE']) || $ml != $v['SIZE']) {
+ $holdflds[$k] = $v;
+ }
+ } else {
+ $holdflds[$k] = $v;
+ }
+ }
+ $flds = $holdflds;
+ }
+
+
+ // already exists, alter table instead
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+ $sql = array();
+
+ foreach ( $lines as $id => $v ) {
+ if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+
+ $flds = Lens_ParseArgs($v,',');
+
+ // We are trying to change the size of the field, if not allowed, simply ignore the request.
+ if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue;
+
+ $sql[] = $alter . $this->alterCol . ' ' . $v;
+ } else {
+ $sql[] = $alter . $this->addCol . ' ' . $v;
+ }
+ }
+
+ return $sql;
+ }
+} // class
+?>
257 frontend/includes/adodb/adodb-error.inc.php
@@ -0,0 +1,257 @@
+<?php
+/**
+ * @version V4.61 24 Feb 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * The following code is adapted from the PEAR DB error handling code.
+ * Portions (c)1997-2002 The PHP Group.
+ */
+
+
+if (!defined("DB_ERROR")) define("DB_ERROR",-1);
+
+if (!defined("DB_ERROR_SYNTAX")) {
+ define("DB_ERROR_SYNTAX", -2);
+ define("DB_ERROR_CONSTRAINT", -3);
+ define("DB_ERROR_NOT_FOUND", -4);
+ define("DB_ERROR_ALREADY_EXISTS", -5);
+ define("DB_ERROR_UNSUPPORTED", -6);
+ define("DB_ERROR_MISMATCH", -7);
+ define("DB_ERROR_INVALID", -8);
+ define("DB_ERROR_NOT_CAPABLE", -9);
+ define("DB_ERROR_TRUNCATED", -10);
+ define("DB_ERROR_INVALID_NUMBER", -11);
+ define("DB_ERROR_INVALID_DATE", -12);
+ define("DB_ERROR_DIVZERO", -13);
+ define("DB_ERROR_NODBSELECTED", -14);
+ define("DB_ERROR_CANNOT_CREATE", -15);
+ define("DB_ERROR_CANNOT_DELETE", -16);
+ define("DB_ERROR_CANNOT_DROP", -17);
+ define("DB_ERROR_NOSUCHTABLE", -18);
+ define("DB_ERROR_NOSUCHFIELD", -19);
+ define("DB_ERROR_NEED_MORE_DATA", -20);
+ define("DB_ERROR_NOT_LOCKED", -21);
+ define("DB_ERROR_VALUE_COUNT_ON_ROW", -22);
+ define("DB_ERROR_INVALID_DSN", -23);
+ define("DB_ERROR_CONNECT_FAILED", -24);
+ define("DB_ERROR_EXTENSION_NOT_FOUND",-25);
+ define("DB_ERROR_NOSUCHDB", -25);
+ define("DB_ERROR_ACCESS_VIOLATION", -26);
+}
+
+function adodb_errormsg($value)
+{
+global $ADODB_LANG,$ADODB_LANG_ARRAY;
+
+ if (empty($ADODB_LANG)) $ADODB_LANG = 'en';
+ if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ;
+ else {
+ include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php");
+ }
+ return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR];
+}
+
+function adodb_error($provider,$dbType,$errno)
+{
+ //var_dump($errno);
+ if (is_numeric($errno) && $errno == 0) return 0;
+ switch($provider) {
+ case 'mysql': $map = adodb_error_mysql(); break;
+
+ case 'oracle':
+ case 'oci8': $map = adodb_error_oci8(); break;
+
+ case 'ibase': $map = adodb_error_ibase(); break;
+
+ case 'odbc': $map = adodb_error_odbc(); break;
+
+ case 'mssql':
+ case 'sybase': $map = adodb_error_mssql(); break;
+
+ case 'informix': $map = adodb_error_ifx(); break;
+
+ case 'postgres': return adodb_error_pg($errno); break;
+
+ case 'sqlite': return $map = adodb_error_sqlite(); break;
+ default:
+ return DB_ERROR;
+ }
+ //print_r($map);
+ //var_dump($errno);
+ if (isset($map[$errno])) return $map[$errno];
+ return DB_ERROR;
+}
+
+//**************************************************************************************
+
+function adodb_error_pg($errormsg)
+{
+ if (is_numeric($errormsg)) return (integer) $errormsg;
+ static $error_regexps = array(
+ '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE,
+ '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS,
+ '/divide by zero$/' => DB_ERROR_DIVZERO,
+ '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER,
+ '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD,
+ '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX,
+ '/referential integrity violation/' => DB_ERROR_CONSTRAINT,
+ '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/'
+ => DB_ERROR_ALREADY_EXISTS
+ );
+ reset($error_regexps);
+ while (list($regexp,$code) = each($error_regexps)) {
+ if (preg_match($regexp, $errormsg)) {
+ return $code;
+ }
+ }
+ // Fall back to DB_ERROR if there was no mapping.
+ return DB_ERROR;
+}
+
+function adodb_error_odbc()
+{
+static $MAP = array(
+ '01004' => DB_ERROR_TRUNCATED,
+ '07001' => DB_ERROR_MISMATCH,
+ '21S01' => DB_ERROR_MISMATCH,
+ '21S02' => DB_ERROR_MISMATCH,
+ '22003' => DB_ERROR_INVALID_NUMBER,
+ '22008' => DB_ERROR_INVALID_DATE,
+ '22012' => DB_ERROR_DIVZERO,
+ '23000' => DB_ERROR_CONSTRAINT,
+ '24000' => DB_ERROR_INVALID,
+ '34000' => DB_ERROR_INVALID,
+ '37000' => DB_ERROR_SYNTAX,