0) { while($dat = mysql_fetch_array($res)) array_push($out,$dat); } } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); } } return $out; } function DBGetNumRow($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); $out = 0; if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { $out = mysql_num_rows($res); } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); } } return $out; } function DBGetCountRow($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); $out = 0; if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { $out = mysql_result($res,0,0); } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); } } return $out; } // Query , Return true on success or false on failure function DBQuery($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { return true; } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); return false; } } else return false; } function PPP_GetBaseURI() { global $HTTP_SERVER_VARS; if (isset($HTTP_SERVER_VARS['REQUEST_URI'])) { $path = $HTTP_SERVER_VARS['REQUEST_URI']; } else { $path = getenv('REQUEST_URI'); } if ((empty($path)) || (substr($path, -1, 1) == '/')) { $path = getenv('PATH_INFO'); if (empty($path)) { if (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) { $path = $HTTP_SERVER_VARS['SCRIPT_NAME']; } else { $path = getenv('SCRIPT_NAME'); } } } $path = preg_replace('/[#\?].*/', '', $path); $path = dirname($path); if (preg_match('!^[/\\\]*$!', $path)) { $path = ''; } return $path; } function PPP_DBGetConn() { global $dbconn; return $dbconn; } function PPP_GetBaseURL() { global $HTTP_SERVER_VARS; if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) { $server = getenv('HTTP_HOST'); } else { $server = $HTTP_SERVER_VARS['HTTP_HOST']; } if (isset($HTTP_SERVER_VARS['HTTPS']) && $HTTP_SERVER_VARS['HTTPS'] != 'off') { $proto = 'https://'; } else { $proto = 'http://'; } $path = PPP_GetBaseURI(); return "$proto$server$path/"; } function PPP_Redirect($redirecturl) { if (function_exists('session_write_close')) { session_write_close(); } if (preg_match('!^http!', $redirecturl)) { Header("Location: $redirecturl"); return; } else { $redirecturl = preg_replace('!^/*!', '', $redirecturl); $baseurl = PPP_GetBaseURL(); Header("Location: $baseurl$redirecturl"); } } function PPP_JSRedirect($redirecturl,$alert="") { if($alert != "") { $al = "alert('".$alert."');"; } echo " "; exit; } function PPP_VarPrepForStore() { $resarray = array(); foreach (func_get_args() as $ourvar) { if (!get_magic_quotes_runtime()) { $ourvar = addslashes($ourvar); } array_push($resarray, $ourvar); } if (func_num_args() == 1) { return $resarray[0]; } else { return $resarray; } } ?>