common->phpgw_exit() is now called when there is a halt becuase of a database error and I started adding the auto_stripslashes feature

This commit is contained in:
jengo 2001-01-08 10:08:32 +00:00
parent c9ca56e4a6
commit 883b40c508
2 changed files with 65 additions and 43 deletions

View File

@ -18,6 +18,7 @@ class db {
var $Password = ""; var $Password = "";
/* public: configuration parameters */ /* public: configuration parameters */
var $auto_stripslashes = False;
var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result() var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages. 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) 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(); print $this->num_rows();
} }
function f($Name) { function f($Name, $strip_slashes = "")
return $this->Record[$Name]; {
if ($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes)) {
return stripslashes($this->Record[$Name]);
} else {
return $this->Record[$Name];
}
} }
function p($Name) { function p($Name) {
@ -350,25 +356,29 @@ class db {
} }
/* private: error handling */ /* private: error handling */
function halt($msg, $line = "", $file = "") { function halt($msg, $line = "", $file = "")
$this->unlock(); // Just in case there is a table currently locked {
global $phpgw;
$this->Error = @mysql_error($this->Link_ID); $this->unlock(); // Just in case there is a table currently locked
$this->Errno = @mysql_errno($this->Link_ID);
if ($this->Halt_On_Error == "no") $this->Error = @mysql_error($this->Link_ID);
return; $this->Errno = @mysql_errno($this->Link_ID);
if ($this->Halt_On_Error == "no")
$this->haltmsg($msg); return;
if ($file) { $this->haltmsg($msg);
printf("<br><b>File:</b> %s",$file);
} if ($file) {
if ($line) { printf("<br><b>File:</b> %s",$file);
printf("<br><b>Line:</b> %s",$line); }
} if ($line) {
printf("<br><b>Line:</b> %s",$line);
if ($this->Halt_On_Error != "report") }
die("<p><b>Session halted.</b>");
if ($this->Halt_On_Error != "report") {
echo "<p><b>Session halted.</b>";
$phpgw->common->phpgw_exit(True);
}
} }
function haltmsg($msg) function haltmsg($msg)

View File

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