From 4515cca57d6a5248114b03954fe7984ba477fcce Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 15 Mar 2013 01:06:16 +1000 Subject: Add grid server web scripts. --- web/offline_mysql.php | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 web/offline_mysql.php (limited to 'web/offline_mysql.php') diff --git a/web/offline_mysql.php b/web/offline_mysql.php new file mode 100644 index 0000000..fe0eb3e --- /dev/null +++ b/web/offline_mysql.php @@ -0,0 +1,112 @@ +Database error: $msg
\n"); + echo("MySQL error: $this->Errno ($this->Error)
\n"); + die("Session halted."); + } + + function connect() + { + if($this->Link_ID == 0) + { + $this->Link_ID = mysql_connect($this->Host, $this->User, $this->Password); + if (!$this->Link_ID) + { + $this->halt("Link_ID == false, connect failed"); + } + $SelectResult = mysql_select_db($this->Database, $this->Link_ID); + if(!$SelectResult) + { + $this->Errno = mysql_errno($this->Link_ID); + $this->Error = mysql_error($this->Link_ID); + $this->halt("cannot select database ".$this->Database.""); + } + } + } + + function escape($String) + { + return mysql_escape_string($String); + } + + function query($Query_String) + { + $this->connect(); + $this->Query_ID = mysql_query($Query_String,$this->Link_ID); + $this->Row = 0; + $this->Errno = mysql_errno(); + $this->Error = mysql_error(); + if (!$this->Query_ID) + { + $this->halt("Invalid SQL: ".$Query_String); + } + return $this->Query_ID; + } + + function next_record() + { + $this->Record = @mysql_fetch_array($this->Query_ID); + $this->Row += 1; + $this->Errno = mysql_errno(); + $this->Error = mysql_error(); + $stat = is_array($this->Record); + if (!$stat) + { + @mysql_free_result($this->Query_ID); + $this->Query_ID = 0; + } + return $this->Record; + } + + function num_rows() + { + return mysql_num_rows($this->Query_ID); + } + + function affected_rows() + { + return mysql_affected_rows($this->Link_ID); + } + + function optimize($tbl_name) + { + $this->connect(); + $this->Query_ID = @mysql_query("OPTIMIZE TABLE $tbl_name",$this->Link_ID); + } + + function clean_results() + { + if($this->Query_ID != 0) mysql_freeresult($this->Query_ID); + } + + function close() + { + if($this->Link_ID != 0) mysql_close($this->Link_ID); + } +} +?> -- cgit v1.1