diff --git a/phpgwapi/inc/phpgw_db_mysql.inc.php b/phpgwapi/inc/phpgw_db_mysql.inc.php index 66e2138eb2..278b6874a2 100644 --- a/phpgwapi/inc/phpgw_db_mysql.inc.php +++ b/phpgwapi/inc/phpgw_db_mysql.inc.php @@ -18,6 +18,7 @@ class db { var $Password = ""; /* public: configuration parameters */ + var $auto_stripslashes = False; var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result() var $Debug = 0; ## Set to 1 for debugging messages. var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) @@ -230,8 +231,13 @@ class db { print $this->num_rows(); } - function f($Name) { - return $this->Record[$Name]; + function f($Name, $strip_slashes = "") + { + if ($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes)) { + return stripslashes($this->Record[$Name]); + } else { + return $this->Record[$Name]; + } } function p($Name) { @@ -350,25 +356,29 @@ class db { } /* private: error handling */ - function halt($msg, $line = "", $file = "") { - $this->unlock(); // Just in case there is a table currently locked - - $this->Error = @mysql_error($this->Link_ID); - $this->Errno = @mysql_errno($this->Link_ID); - if ($this->Halt_On_Error == "no") - return; - - $this->haltmsg($msg); - - if ($file) { - printf("
File: %s",$file); - } - if ($line) { - printf("
Line: %s",$line); - } - - if ($this->Halt_On_Error != "report") - die("

Session halted."); + function halt($msg, $line = "", $file = "") + { + global $phpgw; + $this->unlock(); // Just in case there is a table currently locked + + $this->Error = @mysql_error($this->Link_ID); + $this->Errno = @mysql_errno($this->Link_ID); + if ($this->Halt_On_Error == "no") + return; + + $this->haltmsg($msg); + + if ($file) { + printf("
File: %s",$file); + } + if ($line) { + printf("
Line: %s",$line); + } + + if ($this->Halt_On_Error != "report") { + echo "

Session halted."; + $phpgw->common->phpgw_exit(True); + } } function haltmsg($msg) diff --git a/phpgwapi/inc/phpgw_db_pgsql.inc.php b/phpgwapi/inc/phpgw_db_pgsql.inc.php index d8875cfbb3..2c93a70cb0 100644 --- a/phpgwapi/inc/phpgw_db_pgsql.inc.php +++ b/phpgwapi/inc/phpgw_db_pgsql.inc.php @@ -14,6 +14,9 @@ class db { var $Database = ""; var $User = ""; var $Password = ""; + + var $auto_stripslashes = False; + var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) var $Link_ID = 0; @@ -214,34 +217,43 @@ class db { print $this->num_rows(); } - function f($Name) { - return $this->Record[$Name]; + function f($Name,$strip_slashes = "") + { + if ($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes)) { + return stripslashes($this->Record[$Name]); + } else { + return $this->Record[$Name]; + } } function p($Name) { print $this->Record[$Name]; } - function halt($msg, $line = "", $file = "") { - if($this->Halt_On_Error == "no") { - return; - } - $this->unlock(); // Just in case there is a table currently locked - - printf("Database error: %s
\n", $msg); - printf("PostgreSQL Error: %s (%s)
\n", - $this->Errno, - $this->Error); - if ($file) { - printf("
File: %s",$file); - } - if ($line) { - printf("
Line: %s",$line); - } - - if($this->Halt_On_Error == "yes") { - die("

Session halted."); - } + function halt($msg, $line = "", $file = "") + { + global $phpgw; + + if($this->Halt_On_Error == "no") { + return; + } + $this->unlock(); // Just in case there is a table currently locked + + printf("Database error: %s
\n", $msg); + printf("PostgreSQL Error: %s (%s)
\n", + $this->Errno, + $this->Error); + if ($file) { + printf("
File: %s",$file); + } + if ($line) { + printf("
Line: %s",$line); + } + + if ($this->Halt_On_Error == "yes") { + echo "

Session halted."; + $phpgw->common->phpgw_exit(True); + } } function table_names() {