Просмотр файла functions.php

Размер файла: 6.39Kb
<?php
// MyForum - Сервис форумов 
// Copyright © A'lex и KO. All Rights Reserved
// По всем вопросам обращайтесь на email [email protected] или в асю 376920428



function displayWML($caption, $title, $body, $end)
{
header('Content-Type: text/vnd.wap.wml; charset=utf-8');  

$caption = ereg_replace("&#39;","'",$caption);
$title = ereg_replace("&#39;","'",$title);
$body = ereg_replace("&#39;","'",$body);
$end = ereg_replace("&#39;","'",$end);

$title = ereg_replace('&','&amp;',$title);
$body = ereg_replace('&','&amp;',$body);
$end = ereg_replace('&','&amp;',$end);
$body = ereg_replace('$','$$',$body);
$body = substr($body, 0, strrpos($body, '$'));
$body = substr($body, 0, strrpos($body, '$'));
$body = ereg_replace('<dol>','$',$body);
$body = ereg_replace('&amp;lt;','&lt;',$body);
$body = ereg_replace('&amp;gt;','&gt;',$body);
$body = ereg_replace('&amp;quot;','&quot;',$body);


echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"><wml><head><meta forua="true" http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate"/></head>';
echo "<card id=\"c1\" title=\"$caption\">";
$caption = ereg_replace('&','&amp;',$caption);

echo '<p align="left">' . $title . '</p>';
echo '<p align="center">------</p>';
echo '<p align="left">' . $body . '</p>';
echo '<p align="center">------</p>';
echo '<p align="left">' . $end . '</p>';
echo '</card></wml>';
}


function displayHTML($caption, $title, $body, $end)
{
header('Content-Type: text/html; charset=utf-8');
$caption = ereg_replace("&#39;","'",$caption);
$title = ereg_replace("&#39;","'",$title);
$body = ereg_replace("&#39;","'",$body);
$end = ereg_replace("&#39;","'",$end);

$title = ereg_replace('&','&amp;',$title);
$body = ereg_replace('&','&amp;',$body);
$end = ereg_replace('&','&amp;',$end);

$caption = ereg_replace("&amp;nbsp;","&nbsp;",$caption);
$title = ereg_replace("&amp;nbsp;","&nbsp;",$title);
$body = ereg_replace("&amp;nbsp;","&nbsp;",$body);
$end = ereg_replace("&amp;nbsp;","&nbsp;",$end);
$body = ereg_replace('&amp;lt;','&lt;',$body);
$body = ereg_replace('&amp;gt;','&gt;',$body);
$body = ereg_replace('&amp;quot;','&quot;',$body);


$res=<<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta forua="true" http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate"/><title>$caption</title></head>
<body bgcolor="#0598AD" link="#917E35" vlink="#917E35" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="500">
<tr><td bgcolor="#023339" align="center"><font color="#ffffff"><b>$caption</b></font></td></tr>
<tr><td bgcolor="#79EBFB">$title</td></tr>
<tr><td bgcolor="#C3F6FD">$body</td></tr>
<tr><td bgcolor="#79EBFB">$end</td></tr></table>
</body></html>
END;
echo $res;
}

function displaytext($caption, $title, $body, $end, $w)
{
	if ($w=='html') {
		displayHTML($caption, $title, $body, $end);
	}
	if ($w=='wml') {
		displayWML($caption, $title, $body, $end);
	}
	if ($w==FALSE) {
		$tp = $_SERVER['HTTP_ACCEPT'];
		$user = $_SERVER["HTTP_USER_AGENT"];
		if (strstr($user,'Mozilla') || strstr($user,'Opera')) {
			displayHTML($caption, $title, $body, $end);
		} else {
			displayWML($caption, $title, $body, $end);
		}
	}
}

function getwmode($w)
{
	if ($w=='html') {
		$wmode = 'html';
	}
	if ($w=='wml') {
		$wmode = 'wml';
	}
	if ($w==FALSE) {
		$tp = $_SERVER['HTTP_ACCEPT'];
		$user = $_SERVER["HTTP_USER_AGENT"];
		if (strstr($user,'Mozilla') || strstr($user,'Opera')) {
			$wmode = 'html';
		} else {
			$wmode = 'wml';
		}
	}
	return $wmode;
}

function randstr($length = 8) { 
$a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
for($i=0; $i<$length; $i++) $ret .= substr($a, rand(0, strlen($a)-1), 1); 
return $ret; 
}

function datetoarr($datetime) { 
	$a=explode(" ", $datetime);
	$date=explode(".", $a[0]);
	$time=explode(":", $a[1]);
	$res=array('s' => $date[0], 'd' => $date[1], 'h' => $time[0], 'm' => $time[1]);
	return $res;
}

function lastdate($adate, $bdate) { 
	$a=datetoarr($adate);
	$b=datetoarr($bdate);
	$res=FALSE;
	if ($a['s']<$b['s']) {$res=TRUE;} else {
		if ($a['d']<$b['d']) {$res=TRUE;} else {
			if ($a['h']<$b['h']) {$res=TRUE;} else {
				if ($a['m']<$b['m']) {$res=TRUE;}
			}
		}
	}
	return $res;
}
function datedec($datetime, $min) { 
	$a=datetoarr($datetime);
	$a['m']-=$min;
	$n=0;
	while ($a['m']<0) {
		$a['m']=60+$a['m'];
		$n++;
	}
	$a['h']-=$n;
	$n=0;
	while ($a['m']<0) {
		$a['m']=24+$a['m'];
		$n++;
	}
	$a['d']-=$n;
	$d=$a['s'].'.'.$a['d'].' '.$a['h'].':'.$a['m'];
	return $d;
}

function dateinc($datetime, $min) { 
	$a=datetoarr($datetime);
	$a['m']+=$min;
	$n=0;
	while ($a['m']>60) {
		$a['m']=$a['m']-60;
		$n++;
	}
	$a['h']+=$n;
	$n=0;
	while ($a['m']>24) {
		$a['m']=$a['m']-24;
		$n++;
	}
	$a['d']+=$n;
	$d=$a['s'].'.'.$a['d'].' '.$a['h'].':'.$a['m'];
	return $d;
}


//---------------------------------------------------------------------------------------------------



$date = date('j.n G:i');
$rurl = $HTTP_SERVER_VARS['REQUEST_URI'];
if ($f==FALSE) {$f=1;}
$Banner="";

if ($sid!=FALSE) {
	$isid="&sid=$sid";
	$r = mysql_query("SELECT * FROM {$table}{$f}_users WHERE FSID='$sid'");
		if (mysql_numrows($r)!=0) {
			$userinfo = mysql_fetch_array($r);
			$usernick=$userinfo['Nick'];
			mysql_query("UPDATE {$table}{$f}_users SET GoDate='$date' WHERE FSID='$sid'");
		} else {
			$sid=FALSE;
			$isid="";
		}
	
} else {$isid="";}

if ($sid=='0000000000000000') {$sid=FALSE;$isid="";}

if ($w!=FALSE) {$isid="$isid&w=$w";}
if ($show=='all') {$isid="$isid&show=all";}

$userlever = $userinfo['Lever'];
if ($userlever>2) {
	$moder = TRUE;
	if ($show=='all') {$show=TRUE;}
} else {$moder=FALSE;}

$r = mysql_query("SELECT * FROM {$table}banners");
$BannersCoint=mysql_numrows($r);
if ($BannersCoint!=0) {
	
	$BannerID = rand(0, $BannersCoint);
	$r = mysql_query("SELECT * FROM {$table}banners WHERE ID=$BannerID");
	$a = mysql_fetch_array($r);
	$Banner .= $a['BannerCode'];
}

$r = mysql_query("SELECT * FROM {$table}forums WHERE ID=$f");
if ((mysql_numrows($r)==0) && ($f!=1)) {header("Location: index.php?f=1"); exit;}
$foruminfo=mysql_fetch_array($r);

?>