Codice PHP:
<?if(!defined('OEC'))
die('Hacking attempt...');
// my first attempt to apply OOP (object-oriented programming) in a script :) ...
class loadinfo {
function above()
{
global $page_title, $themedir, $info, $context, $scripturl, $timeZone;
echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>',$page_title,'</title>
<link rel="stylesheet" href="',$themedir,'/default.css" type="text/css" />
<body>';
if(isset($_SESSION['user']) && isset($_SESSION['password']))
{
$info -> get_invite();
foreach($context['invites'] as $invite)
{
echo '<p class="titlebg" align="center" style="font-size:x-small">',$invite['msg'],'
accept? [url="',$scripturl,'?action=inv&do=accept&id=',$invite['id'],'&r=',$invite['r_id'],'&sid=',session_id(),'"]Yes[/url] |
[url="',$scripturl,'?action=inv&do=decline&id=',$invite['id'],'&r=',$invite['r_id'],'&sid=',session_id(),'"]No[/url]';
}
$info -> booted();
foreach($context['booted'] as $boot)
{
$newTime = $boot['exp_time'] + ($timeZone * 60 * 60);
if(time() < ($boot['exp_time']))
{
die('<p class="catbg">Booted!</p>
<p class="windowbg">Sorry '.$context['member']['name'].' you have been booted from this room
REASON: '.$boot['reason'].'</p>
Boot expires: '.(date('D, M j , H:i:s',$newTime)).'</p>');
}
}
}
}
function wap_above()
{
global $page_title, $info, $context, $timeZone;
echo '<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card title="',$page_title,'">';
if(isset($_SESSION['user']) && isset($_SESSION['password']))
{
$info -> get_invite();
foreach($context['invites'] as $invite)
{
echo '
[size="1"]',$invite['msg'],'[/size]</p>';
}
$info -> booted();
foreach($context['booted'] as $boot)
{
if(time() < ($boot['exp_time']))
{
$newTime = $boot['exp_time'] + ($timeZone * 60 * 60);
die('
[b][size="1"]Booted![/size][/b]</p>
Sorry '.$context['member']['name'].' you have been booted from this room
REASON: '.$boot['reason'].'</p>
Boot expires: '. (date('D, M j , H:i:s',$newTime)).'</p></card></wml>');
}
}
}
}
function member_data()
{
global $db_prefix, $context;
$result = mysql_query("SELECT m.memberName, m.memberID, m.membergroupID, m.banned, m.email, m.gender, m.dateRegistered, m.Posts,
m.Browser, m.IP, m.color, g.ID_GROUP, g.groupName
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS g ON (ID_GROUP = membergroupID)
WHERE memberName = '{$_SESSION['user']}'
LIMIT 1") or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
$context['member']['id'] = $row['memberID'];
$context['member']['name'] = $row['memberName'];
$context['member']['group'] = $row['groupName'];
$context['member']['groupID'] = $row['ID_GROUP'];
$context['member']['email'] = $row['email'];
$context['member']['gender'] = $row['gender'];
$context['member']['registered'] = $row['dateRegistered'];
$context['member']['posts'] = $row['Posts'];
$context['member']['browser'] = $row['Browser'];
$context['member']['ip'] = $row['IP'];
$context['member']['color'] = $row['color'];
$context['member']['banned'] = $row['banned'];
}
mysql_free_result($result);
}
function update_member_data($member)
{
global $scripturl, $context, $error, $page_title, $db_prefix, $info;
if(isset($_POST['password']) && $_POST['password1'])
{
if(strlen($_POST['password']) <=4)
$error = 'password too short!';
if($_POST['password'] != $_POST['password1'])
$profile_error .= 'password did not match!';
$password_hash = md5($_POST['password']);
}
else
{
$password_hash = $member['password'];
}
if(isset($_POST['about']))
$about = ($_POST['about']);
if(strlen($about) > 300)
$profile_error = '
Your [b]About[/b] Description, exceeds 300 characters...
</p>';
if(isset($_POST['gender']))
$gender = $_POST['gender'];
if(isset($_POST['location']))
$location = $_POST['location'];
if(isset($_POST['photo']))
$pic = $_POST['photo'];
if(isset($_POST['color']))
$color = $_POST['color'];
if(isset($profile_error))
{
echo $profile_error. '
[url="'.$scripturl.'?u='.$user['id'].'&action=profile&do=settings"]« Back[/url]</p>';
}
else
{
mysql_query("UPDATE
{$db_prefix}members
SET email = '{$_POST['email']}', password = '$password_hash', gender = '$gender', location = '$location', about = '{$_POST['about']}', pic = '{$_POST['photo']}', color = '$color', membergroupID = '$_POST[group]'
WHERE memberName = '{$member['name']}'
OR memberID = '{$member['id']}'") or die(mysql_error());
if(WAP)
{
echo '<card title="Processing...">
<onevent type="ontimer">
<go href="'. $scripturl. '?action=profile&wap&sid=',session_id(),'" method="get"></go>
</onevent><timer value="20"/>
Processing your request, please wait...</p>
<p align="center">[url="',$scripturl,'?action=profile&u=',$_GET['u'],'&wap&sid=',session_id(),'"]View Profile[/url]</p>
</card>';
}
else{
echo '<p class="titlebg">Profile Updated</p>
<p align="center">[url="',$scripturl,'?action=profile&u=',$_GET['u'],'&sid=',session_id(),'"]>>View Profile<<[/url]</p>';
}
}
}
function cleanRequest()
{
if(!get_magic_quotes_gpc())
{
$_GET = array_map('trim', $_GET);
$_POST = array_map('trim', $_POST);
$_COOKIE = array_map('trim', $_COOKIE);
$_GET = array_map('addslashes', $_GET);
$_POST = array_map('addslashes', $_POST);
$_COOKIE = array_map('addslashes', $_COOKIE);
}
}
function write_logs()
{
global $db_prefix, $context, $room;
// Checks if the user has been logged already
$query = mysql_query("SELECT count(*)
FROM {$db_prefix}online
WHERE member_Name = '{$context['member']['name']}'
AND ID_Room = '$room'
OR ID_Room = '0'") or die(mysql_error());
$in = mysql_fetch_array($query);
// put them in the online list
if($in['count(*)'] == 0)
{
if(!$room == 0)
{
mysql_query("INSERT
INTO {$db_prefix}online
(time, member_Name, ID_Room)
VALUES('".time()."','{$context['member']['name']}','$room')");
}
else {
mysql_query("INSERT
INTO {$db_prefix}online
(time, member_Name, ID_Room)
VALUES('".time()."','{$context['member']['name']}','0')");
}
}
// or update their online status
else
{
mysql_query("UPDATE
{$db_prefix}online
SET time = '".time()."', ID_Room = '$room'
WHERE member_Name = '{$context['member']['name']}'");
mysql_query("UPDATE
{$db_prefix}online
SET time = '".time()."', ID_Room = '0'
WHERE member_Name = {$context['member']['name']}'");
}
mysql_query("UPDATE
{$db_prefix}members
SET Browser = '".$_SERVER['HTTP_USER_AGENT']."', IP = '".$_SERVER['REMOTE_ADDR']."', lastLogin = '".time()."'
WHERE memberName = '{$context['member']['name']}'");
}
function cleanup()
{
global $db_prefix;
mysql_query("
DELETE
FROM {$db_prefix}messages
WHERE time<'".(time()-300)."'
LIMIT 1");
mysql_query("DELETE
FROM {$db_prefix}online
WHERE time<'".(time()-4)."'");
}
function banned()
{
// Dont cache this error
header('Expires: Tue, 17 Dec 1986 03:00:00 GMT');
header('Last-Modified: '. gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, no-store, must-revalidate');
if(isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !==false)
{
echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Banned</title>
</head>
<body>
<h2>Banned!!</h2>
Sorry ',$_SESSION['user'],' you have been banned from using this chat system, please contact the site administrator.
</body>
</html>';
}
else
{
header('Content-Type: text/vnd.wap.wml');
echo '<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml">
<wml>
<card title="Banned">
[b]Banned!![/b]
</p>
Sorry ',$_SESSION['user'],' you have been banned from using this chat system, please contact the site administrator.</p>
</card>
</wml>';
}
}
function db_error()
{
global $site_title;
// Dont cache this error
header('Expires: Tue, 17 Dec 1986 03:00:00 GMT');
header('Last-Modified: '. gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, no-store, must-revalidate');
if(isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !==false)
{