/** * Set our error handler */ function error_handler($errorno, $string, $file, $line) { if ($errorno != 2048 && $errorno != 8) { // E_STRICT & E_NOTICE && $errorno != 8 return compile_error($string, $file, $line); } }
function createCache($allinfo, $filename) { $contents = "<?php \nerror_reporting(E_ALL); \n\nif(!defined('IN_K4')) { \n\texit; \n}"; $contents .= "\n\n\$cache += " . var_export($allinfo, TRUE) . ";"; $contents .= "\n?>"; /* Create our file */ if (file_exists($filename)) { unlink($filename); } $handle = @fopen($filename, "w"); @chmod($filename, 0777); @fwrite($handle, $contents); @chmod($filename, 0777); @fclose($handle); @touch($filename); /* Error checking on our newly created file */ if (!file_exists($filename) || !is_readable($filename) || !is_writeable($filename)) { compile_error('An error occured while trying to create the forum cache file.', __FILE__, __LINE__); } else { $lines = file($filename); if (count($lines) <= 1 || empty($lines)) { compile_error('An error occured while trying to create the forum cache file. It appears to be empty.', __FILE__, __LINE__); } return TRUE; /** * Need the touch here because for some reason the file changes the mod time in * some php versions */ @touch($filename); } }
function GetValue($query) { $result = sqlite_query($query, $this->link); /* Increment the number of queries */ $this->num_queries++; if (is_resource($result)) { if (sqlite_has_more($result)) { $value = sqlite_fetch_single($result); if (DEBUG_SQL) { set_debug_item($query, $value); } return $value; } } else { return compile_error("Invalid query: " . sqlite_error_string(sqlite_last_error($this->link)), __FILE__, __LINE__); } return FALSE; }
function executeQuery($stmt, $mode = DBA_ASSOC) { $result = mysqli_query($this->link, $stmt); if (!$result) { if (mysqli_errno($this->link) == 0) { return compile_error("Invalid query: Called executeQuery on an update", __FILE__, __LINE__); } return compile_error("Invalid query: " . mysqli_error($this->link), __FILE__, __LINE__); } /* Increment the number of queries */ $this->num_queries++; $result =& new MysqliResultIterator($result, $mode); if (DEBUG_SQL) { set_debug_item($stmt, $result); } return $result; }
function GetValue($query) { $result = mysql_query($query, $this->link); /* Increment the number of queries */ $this->num_queries++; if (is_resource($result)) { if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result, MYSQL_NUM); mysql_free_result($result); if (DEBUG_SQL) { set_debug_item($query, $row[0]); } return $row[0]; } } else { return compile_error("Invalid query: " . mysql_error($this->link), __FILE__, __LINE__); } return FALSE; }
<h3>Database Tables Added...</h3> <script type="text/javascript">redirect_page(3, 'install.php?act=install2');</script> <meta http-equiv="refresh" content="3; url=install.php?act=install2" /> <?php } elseif (isset($request['act']) && $request['act'] == 'install2') { /** * Add the data to the database */ $_CONFIG['dba']['driver'] = strtolower($session['install_vars']['dba']); $_CONFIG['dba']['user'] = $session['install_vars']['dba_username']; $_CONFIG['dba']['pass'] = $session['install_vars']['dba_password']; $_CONFIG['dba']['database'] = $session['install_vars']['dba_name']; $_CONFIG['dba']['server'] = $session['install_vars']['dba_server']; $_CONFIG['dba']['directory'] = FORUM_BASE_DIR . '/includes/sqlite'; if (!file_exists(INSTALL_BASE_DIR . '/k4.data.schema')) { compile_error('The SQL data file for k4 Bulletin Board does not exist.', '--', '--'); } $str = file_get_contents(INSTALL_BASE_DIR . '/k4.data.schema'); $str = @sprintf($str, $session['install_vars']['username'], $session['install_vars']['email'], md5($session['install_vars']['password']), $session['install_vars']['bbtitle'], $session['install_vars']['bbdescription'], $session['install_vars']['email'], $session['install_vars']['email']); $str = preg_replace("~(\r\n|\r|\n)~", "\n", $str); $queries = explode("\n", $str); error::reset(); $dba =& Database::open($_CONFIG['dba']); if (error::grab()) { return critical_error(); } /* Loop through the database tables and add them to the database */ foreach ($queries as $query) { if ($query != '') { $dba->executeUpdate($query); }