Files
Testing/wall/include/base.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

305 lines
7.5 KiB
PHP

<?php
/*
if($_SERVER["REMOTE_ADDR"]=="98.211.64.187"){
ini_set('session.save_handler', 'memcached');
ini_set('session.use_trans_sid', '0');
echo session_module_name();
}*/
include_once($_SERVER["DOCUMENT_ROOT"] . '/include/dbinclude.php');
session_name("PHPSESSID");
session_id($_COOKIE['754d3b148df7a597947f5556cbe06628']);
//session_cache_limiter('none');
session_start();
/*if($_SERVER["REMOTE_ADDR"]=="98.211.64.187"){
var_dump($_SESSION);
phpinfo();exit;}
*/
/*
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 dbconnect3()
{}
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/Denver');
date_default_timezone_set('UTC');
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;
}
}
function is_date($val)
{
return (strtotime($val) !== false);
}
function get_timespan_string($older, $newer) {
$Y1 = $older->format('Y');
$Y2 = $newer->format('Y');
$Y = $Y2 - $Y1;
$m1 = $older->format('m');
$m2 = $newer->format('m');
$m = $m2 - $m1;
$d1 = $older->format('d');
$d2 = $newer->format('d');
$d = $d2 - $d1;
$H1 = $older->format('H');
$H2 = $newer->format('H');
$H = $H2 - $H1;
$i1 = $older->format('i');
$i2 = $newer->format('i');
$i = $i2 - $i1;
$s1 = $older->format('s');
$s2 = $newer->format('s');
$s = $s2 - $s1;
if($s < 0) {
$i = $i -1;
$s = $s + 60;
}
if($i < 0) {
$H = $H - 1;
$i = $i + 60;
}
if($H < 0) {
$d = $d - 1;
$H = $H + 24;
}
if($d < 0) {
$m = $m - 1;
$d = $d + get_days_for_previous_month($m2, $Y2);
}
if($m < 0) {
$Y = $Y - 1;
$m = $m + 12;
}
$timespan_string = create_timespan_string($Y, $m, $d, $H, $i, $s);
return $timespan_string;
}
function get_days_for_previous_month($current_month, $current_year) {
$previous_month = $current_month - 1;
if($current_month == 1) {
$current_year = $current_year - 1; //going from January to previous December
$previous_month = 12;
}
if($previous_month == 11 || $previous_month == 9 || $previous_month == 6 || $previous_month == 4) {
return 30;
}
else if($previous_month == 2) {
if(($current_year % 4) == 0) { //remainder 0 for leap years
return 29;
}
else {
return 28;
}
}
else {
return 31;
}
}
function create_timespan_string($Y, $m, $d, $H, $i, $s)
{
$timespan_string = '';
$found_first_diff = false;
if($Y >= 1) {
$found_first_diff = true;
$timespan_string .= pluralize($Y, 'Y').' ';
}
if($m >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($m, 'M').' ';
}
if($d >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($d, 'D').' ';
}
if($H >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($H, 'H').' ';
}
if($i >= 1 || $found_first_diff) {
$found_first_diff = true;
// $timespan_string .= pluralize($i, 'minute').' ';
}
if($found_first_diff) {
//$timespan_string .= 'and ';
}
//$timespan_string .= pluralize($s, 'second');
return $timespan_string;
}
function pluralize( $count, $text )
{
return $count . ( ( $count == 1 ) ? ( "$text" ) : ( "${text}" ) );
}
$ssn="/^\d{3}-\d{2}-\d{4}$/";
//&#39 = '
$specialChars = array('&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', "'"=>'&#39;', '"'=>'&quot;'); //for chat
?>