311 lines
4.1 KiB
PHP
311 lines
4.1 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();}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 nonce_tock($nlife=220000) {
|
|
|
|
$life_of_a_nounce = $nlife;
|
|
|
|
return ceil(time() / ( $life_of_a_nounce ));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function randomcode($len=8)
|
|
|
|
{
|
|
|
|
$code = NULL;
|
|
|
|
for( $i=0; $i<$len; $i++ )
|
|
|
|
{
|
|
|
|
$char = chr(rand(48,122));
|
|
|
|
while( !preg_match("~[a-zA-Z0-9]~", $char) )
|
|
|
|
{
|
|
|
|
if( $char == $lchar ) continue;
|
|
|
|
$char = chr(rand(48,90));
|
|
|
|
}
|
|
|
|
$pass .= $char;
|
|
|
|
$lchar = $char;
|
|
|
|
}
|
|
|
|
return $pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//curl using http://mailboxlayer.com phil's email and a mammal
|
|
|
|
function getUrlContent($url){
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
|
|
$data = curl_exec($ch);
|
|
|
|
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($ch);
|
|
|
|
return ($httpcode>=200 && $httpcode<300) ? $data : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function yearsDifference($endDate, $beginDate)
|
|
|
|
{
|
|
|
|
$date_parts1=explode("-", $beginDate);
|
|
|
|
$date_parts2=explode("-", $endDate);
|
|
|
|
return $date_parts2[0] - $date_parts1[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$dbhost = "localhost";
|
|
|
|
$dbuser = "db.bateworldcom";
|
|
|
|
$dbname = "bateworldcom";
|
|
|
|
$dbpass = "sDIE8U8!5n*4%Ue_x.Pq";
|
|
|
|
|
|
|
|
|
|
|
|
if(!isset($_SESSION["reguid"])){$reguserid=uuid();$_SESSION["reguid"]=$reguserid;}
|
|
|
|
function dbconnect($dbhost,$dbuser,$dbname,$dbpass)
|
|
|
|
{}
|
|
|
|
?>
|