191 lines
4.6 KiB
PHP
191 lines
4.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
include_once($_SERVER["DOCUMENT_ROOT"] . '/include/dbinclude.php');
|
||
|
|
session_name("PHPSESSID");
|
||
|
|
session_id($_COOKIE['754d3b148df7a597947f5556cbe06628']);
|
||
|
|
session_start();
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
if(isset($nosession))
|
||
|
|
{
|
||
|
|
if(!session_id())
|
||
|
|
{
|
||
|
|
session_start();
|
||
|
|
if(isset($_GET["regenid"]) || isset($regenid))
|
||
|
|
{
|
||
|
|
$old=session_id();
|
||
|
|
$old_session = $_SESSION;
|
||
|
|
session_regenerate_id(TRUE);
|
||
|
|
$_SESSION=$old_session;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if(!session_id()){session_start();}
|
||
|
|
}
|
||
|
|
//connect to db with appropriate rights
|
||
|
|
$sessid=session_id();*/
|
||
|
|
function dbconnect()
|
||
|
|
{}
|
||
|
|
|
||
|
|
function dbconnect2()
|
||
|
|
{}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function dbconnect4()
|
||
|
|
{}
|
||
|
|
|
||
|
|
|
||
|
|
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
|
||
|
|
{
|
||
|
|
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
|
||
|
|
|
||
|
|
switch ($theType) {
|
||
|
|
case "text":
|
||
|
|
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
|
||
|
|
break;
|
||
|
|
case "textnn":
|
||
|
|
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "''";
|
||
|
|
break;
|
||
|
|
case "long":
|
||
|
|
case "int":
|
||
|
|
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
|
||
|
|
break;
|
||
|
|
case "double":
|
||
|
|
$theValue = ($theValue != "") ? "'".doubleval($theValue)."'" : "NULL";
|
||
|
|
break;
|
||
|
|
case "date":
|
||
|
|
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
|
||
|
|
break;
|
||
|
|
case "defined":
|
||
|
|
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
return $theValue;
|
||
|
|
}
|
||
|
|
|
||
|
|
function quote_smart($value)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
if (get_magic_quotes_gpc()) {
|
||
|
|
$value = stripslashes($value);
|
||
|
|
}
|
||
|
|
if (!is_numeric($value)) {
|
||
|
|
$value = "'" . $database->database_real_escape_string($value) . "'";
|
||
|
|
}
|
||
|
|
return $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
function checkEmail($email) {
|
||
|
|
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)){
|
||
|
|
list($username,$domain)=split('@',$email);
|
||
|
|
if(!checkdnsrr($domain,'MX')) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
$wordgames="tspwitc";
|
||
|
|
function uuid() {
|
||
|
|
// The field names refer to RFC 4122 section 4.1.2
|
||
|
|
return sprintf('%04x%04x-%04x-%03x4-%04x-%04x%04x%04x',
|
||
|
|
mt_rand(0, 65535), mt_rand(0, 65535),
|
||
|
|
mt_rand(0, 65535),
|
||
|
|
mt_rand(0, 4095),
|
||
|
|
bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '01', 6, 2)),
|
||
|
|
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
date_default_timezone_set('America/Phoenix');
|
||
|
|
|
||
|
|
|
||
|
|
function exitIfNotModifiedSince($last_modified)
|
||
|
|
{
|
||
|
|
if(array_key_exists("HTTP_IF_MODIFIED_SINCE",$_SERVER))
|
||
|
|
{
|
||
|
|
$if_modified_since=strtotime(preg_replace('/;.*$/','',$_SERVER["HTTP_IF_MODIFIED_SINCE"]));
|
||
|
|
if($if_modified_since >= $last_modified)
|
||
|
|
{
|
||
|
|
header("HTTP/1.0 304 Not Modified");
|
||
|
|
exit();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function setLastModified($last_modified=NULL)
|
||
|
|
{
|
||
|
|
$page_modified=getlastmod();
|
||
|
|
|
||
|
|
if(empty($last_modified) || ($last_modified < $page_modified))
|
||
|
|
{
|
||
|
|
$last_modified=$page_modified;
|
||
|
|
}
|
||
|
|
$header_modified=filemtime(__FILE__);
|
||
|
|
if($header_modified > $last_modified)
|
||
|
|
{
|
||
|
|
$last_modified=$header_modified;
|
||
|
|
}
|
||
|
|
header('Last-Modified: ' . date("r",$last_modified));
|
||
|
|
return $last_modified;
|
||
|
|
}
|
||
|
|
function curPageURL() {
|
||
|
|
$pageURL = 'http';
|
||
|
|
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
|
||
|
|
$pageURL .= "://";
|
||
|
|
if ($_SERVER["SERVER_PORT"] != "80") {
|
||
|
|
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||
|
|
} else {
|
||
|
|
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
||
|
|
}
|
||
|
|
return $pageURL;
|
||
|
|
}
|
||
|
|
function getRealIpAddr()
|
||
|
|
{
|
||
|
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
|
||
|
|
{
|
||
|
|
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
||
|
|
}
|
||
|
|
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
|
||
|
|
{
|
||
|
|
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$ip=$_SERVER['REMOTE_ADDR'];
|
||
|
|
}
|
||
|
|
return $ip;
|
||
|
|
}
|
||
|
|
|
||
|
|
function QueryIntoArray($query){
|
||
|
|
global $database;
|
||
|
|
settype($retval,"array");
|
||
|
|
$result= $database->database_query($query);
|
||
|
|
if(!$result){
|
||
|
|
print "Query Failed";
|
||
|
|
}
|
||
|
|
for($i=0;$i<mysql_numrows($result);$i++){
|
||
|
|
for($j=0;$j<$database->database_num_fields($result);$j++){
|
||
|
|
$retval[$i][$database->database_field_name($result,$j)] = $database->database_result
|
||
|
|
($result,$i,$database->database_field_name($result,$j));
|
||
|
|
}//end inner loop
|
||
|
|
}//end outer loop
|
||
|
|
return $retval;
|
||
|
|
}
|
||
|
|
|
||
|
|
function do_reg($text, $regex)
|
||
|
|
{
|
||
|
|
if (preg_match($regex, $text)) {
|
||
|
|
return TRUE;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return FALSE;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
?>
|