averatec
Advanced OT User
Instructions:
Query mysql:
Create test.php, and put to file:
In index.php after:
Put this code:
Create file countTime.js, and put to file this code:
Report bugs.
The script works like rl tibia(randoming questions, etc.)
#edit
REWRITTEN SCRIPT!!!
Query mysql:
Code:
ALTER TABLE `accounts` ADD `passed` INT( 11 ) NOT NULL ;
ALTER TABLE `accounts` ADD `block` INT( 11 ) NOT NULL ;
ALTER TABLE `accounts` ADD `refresh` INT( 11 ) NOT NULL ;
Create test.php, and put to file:
PHP:
<?php
if($logged)
{
if(!function_exists('isPremium'))
{
function isPremium($premdays, $lastday)
{
return (int) $premdays - floor((time() - $lastday) / 86400);
}
}
/* question && answer(arrays) */
// answer true = 1, false =0
$question[1] = "Question?";
$answer[1][1] = array("Answer-true", 1);
$answer[1][2] = array("Answer-false", 0);
$question[2] = "Question2?";
$answer[2][1] = array("Answer-true", 1);
$answer[2][2] = array("Answer-false", 0);
$answer[2][3] = array("Answer-false", 0);
$question[3] = "Question3?";
$answer[3][1] = array("Answer-true", 1);
$answer[3][2] = array("Answer-false", 0);
$question[4] = "Question4?";
$answer[4][1] = array("Answer-true", 1);
$answer[4][2] = array("Answer-false", 0);
$refresh_to_block=2;
$block_time=7*24*60*60;
$number_of_tutors=20;
$premium=7;
$level=20;
$number_questions = 4;
$group = 2; // tutor group id
/* errors */
if($account_logged->getCustomField("passed") == 1)
{
$errors[] = "You have already passed.";
$account_logged->setCustomField('refresh', 0);
}
$num = $SQL->query('SELECT COUNT(`group_id`) AS num FROM `players` WHERE `group_id` = '.$group.'')->fetch();
if($num['num'] >= $number_of_tutors && $account_logged->getCustomField("passed") != 1)
{
$errors[] = 'Too many tutors are now.';
}
if(isPremium($account_logged->getCustomField("premdays"), $account_logged->getCustomField("lastday")) < $premium && $account_logged->getCustomField("passed") != 1)
{
$errors[] = 'You do not have '.$premium.' days premium account.';
}
$refresh_add=$account_logged->getCustomField('refresh')+1;
if($account_logged->getCustomField("refresh") < $refresh_to_block && $account_logged->getCustomField("refresh") < time() && $account_logged->getCustomField("passed") != 1)
{
$account_logged->setCustomField('refresh', $refresh_add);
}
if($account_logged->getCustomField("refresh") >= $refresh_to_block && $account_logged->getCustomField("refresh") < time() && $account_logged->getCustomField("block") == 1 && $account_logged->getCustomField("passed") != 1)
{
$account_logged->setCustomField('refresh', 0);
$account_logged->setCustomField('block', 0);
}
elseif($account_logged->getCustomField("refresh") >= $refresh_to_block && $account_logged->getCustomField("refresh") > time() && $account_logged->getCustomField("block") == 1 && $account_logged->getCustomField("passed") != 1)
{
$errors[] = "Too many refreshes.";
}
if($account_logged->getCustomField("refresh") >= $refresh_to_block && $account_logged->getCustomField("refresh") < time() && $account_logged->getCustomField("block") != 1 && $account_logged->getCustomField("passed") != 1)
{
$errors[] = "Too many refreshes.";
$time=time()+$block_time;
$account_logged->setCustomField('refresh', $time);
$account_logged->setCustomField('block', 1);
}
if((time() - $_SESSION['time']) > 300 && $_SESSION['time'] > 0)
{
$errors[100] = "Time expired.";
$time=time()+$block_time;
$account_logged->setCustomField('refresh', $time);
$account_logged->setCustomField('block', 2);
}
if($account_logged->getCustomField("refresh") >= $refresh_to_block && $account_logged->getCustomField("refresh") < time() && $account_logged->getCustomField("block") == 2 && $account_logged->getCustomField("passed") != 1)
{
$account_logged->setCustomField('refresh', 0);
$account_logged->setCustomField('block', 0);
}
elseif($account_logged->getCustomField("refresh") >= $refresh_to_block && $account_logged->getCustomField("refresh") > time() && $account_logged->getCustomField("block") == 2 && $account_logged->getCustomField("passed") != 1)
{
$errors[100] = "Time expired.";
}
if(empty($errors))
{
$_SESSION['time'] = time();
/* MUSN'T CHANGE IT */
$ex=0;
$ex2=0;
/* count questions && answers */
$count_questions = count($question);
for($i = 0; $i < $count_questions; $i++)
{
$n = $i + 1;
$count_answers[$n] = count($answer[$n]);
}
/* check form*/
if(isset($_POST['submit']))
{
if(isset($_POST['f1']))
{
for($i = 0; $i < $number_questions; $i++)
{
for($n = 0; $n < $count_answers[$_SESSION['question'.$i.'']]; $n++)
{
if($answer[$_SESSION['question'.$i.'']][$_SESSION['ra'.$i.''][$n]][1] == 1 && $_POST[$ex2] == "true")
{
}
elseif($answer[$_SESSION['question'.$i.'']][$_SESSION['ra'.$i.''][$n]][1] == 0 && $_POST[$ex2] != "true")
{
}
else
{
$next[]="fail";
}
$ex2++;
}
}
}
else
{
$main_content.= 'Select a character.<br>';
}
if(!empty($next))
{
$main_content .= '<h1><b>Failed!</b></h1><br>';
$time=time()+$block_time;
$account_logged->setCustomField('refresh', $time);
}
else
{
if(isset($_POST['submit']))
{
$player = $ots->createObject('Player');
$id = stripslashes(ucwords(strtolower(trim($_POST['f1']))));
$player->load($id);
if($player->isLoaded())
{
if($player->getCustomField("online") == 0)
{
$main_content .= '<h1><b>Congratulations!</b></h1><br>';
$account_logged->setCustomField('passed', 1);
$player->setCustomField("group_id", $group);
}
else
{
$main_content.= 'Character must be offline.<br>';
}
}
}
}
}
/* randomizing questions*/
$random_questions = array_rand ($question, $number_questions);
$main_content .= '<script type="text/javascript" src="countTime.js"></script><div id="time"></div><div id="test"><form method="post" action="">';
$account_players = $account_logged->getPlayers();
$main_content .= '<TABLE><TR><TD COLSPAN=3><B>Select Character</B></TD></TR>';
foreach($account_players as $player)
{
$players = $player->getName();
$id = $player->getId();
$player_lvl = $player->getLevel();
if($player_lvl >= $level)
$main_content .= '<TR><td><input type=radio name=f1 value="'.$id.'"></td><td><font color=green>'.$players.'</font></td><td><b>'.$config['site']['worlds'][$player->getWorld()].'</b></td></tr>';
else
$main_content .= '<TR><td><font color=black>Blocked</font></td><td><font color=red>'.$players.'</font></td><td><b>'.$config['site']['worlds'][$player->getWorld()].'</b></td></tr>';
}
$main_content .= '</table><br>';
$main_content .= '<table>';
for($i = 0; $i < $number_questions; $i++)
{
$rq = $random_questions[$i];
$main_content .= '<tr><td><b>'.$question[$rq].'</b></td></tr>';
$_SESSION['question'.$i.''] = "".$rq."";
$random_answers = array_rand ($answer[$rq], $count_answers[$rq]);
$_SESSION['ra'.$i.''] = $random_answers;
for($n = 0; $n < $count_answers[$rq]; $n++)
{
$main_content .= '<tr><td><INPUT TYPE="checkbox" NAME='.$ex.' value="true"/>'.$answer[$rq][$random_answers[$n]][0].'</td></tr>';
$ex++;
}
}
$main_content .= '<tr><td><input type="submit" name="submit" value="Submit"/></td></tr></table></form></div>';
}
else
{
$main_content .= '<b>You haven\'t access to this page, reasons:</b><br><ul>';
foreach($errors as $error)
{
$main_content .= '<li>'.$error.'</li>';
}
$main_content .= '</ul>';
}
if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
{
$main_content .= '<br><a href="index.php?subtopic=tutor&adm=clean">[CLEAN]</a><br>';
if($_REQUEST['adm'] == "clean")
{
$time = time();
$SQL = $SQL->query('SELECT * from `players` where `group_id` = '.$group.' and `online` = 0');
foreach($SQL as $players)
{
$player = $ots->createObject('Player');
$player->load($players['id']);
$account = $ots->createObject('Account');
$account->load($players['account_id']);
if(isPremium($account->getCustomField("premdays"), $account->getCustomField("lastday")) < $premium or $player->getCustomField("level") < $level)
{
$account->setCustomField("passed", 0);
$player->setCustomField("group_id", 1);
$time=time()+$block_time;
$account->setCustomField('refresh', $time);
$account->setCustomField('block', 1);
$main_content .= 'deleted - '.$players['name'].'<br>';
}
elseif(($time - $player->getCustomField("lastlogin")) > 7*24*60*60)
{
$account->setCustomField("passed", 0);
$player->setCustomField("group_id", 1);
$time=time()+$block_time;
$account->setCustomField('refresh', $time);
$account->setCustomField('block', 1);
$main_content .= 'deleted - '.$players['name'].'<br>';
}
unset($player);
unset($account);
}
}
}
}
else
{
$main_content .= 'Please enter your account name and your password.<br/><a href="?subtopic=createaccount" >Create an account</a> if you do not have one yet.<br/><br/><form action="?subtopic=test" method="post" ><div class="TableContainer" > <table class="Table1" cellpadding="0" cellspacing="0" > <div class="CaptionContainer" > <div class="CaptionInnerContainer" > <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span> <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span> <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span> <div class="Text" >Account Login</div> <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span> <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span> <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span> </div> </div> <tr> <td> <div class="InnerTableContainer" > <table style="width:100%;" ><tr><td class="LabelV" ><span >Account Name:</span></td><td style="width:100%;" ><input type="password" name="account_login" SIZE="10" maxlength="10" ></td></tr><tr><td class="LabelV" ><span >Password:</span></td><td><input type="password" name="password_login" size="30" maxlength="29" ></td></tr> </table> </div> </table></div></td></tr><br/><table width="100%" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=lostaccount" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Account lost?" alt="Account lost?" src="'.$layout_name.'/images/buttons/_sbutton_accountlost.gif" ></div></div></td></tr></form></table></td></tr></table>';
}
?>
In index.php after:
PHP:
case "team";
$subtopic = "team";
$topic = "Gamemasters List";
include("team.php");
break;
PHP:
case "test";
$subtopic = "test";
$topic = "Tutor Test";
include("test.php");
break;
Create file countTime.js, and put to file this code:
Code:
when = new Date();
r = when.getFullYear();
m = when.getMonth();
d = when.getDate();
g = when.getHours();
mm = when.getMinutes()+5;
s = when.getSeconds();
to = new Date(r,m,d,g,mm,s);
function liczCzas()
{
now = new Date();
ile = to.getTime() - now.getTime();
minut = Math.floor( ile / (1000 * 60));
sekund = Math.floor(ile / 1000 - minut*60);
document.getElementById("time").innerHTML = "Time left: "+minut+" minutes, "+sekund+" seconds";
if (ile < 0)
{
document.getElementById("time").innerHTML = '<h1>Time Expired</h1>';
document.getElementById("test").innerHTML = '';
clearInterval(animeInt);
var animeInt2;
clearInterval(animeInt2);
when = new Date();
r = when.getFullYear();
m = when.getMonth();
d = when.getDate();
g = when.getHours();
mm = when.getMinutes();
s = when.getSeconds()+10;
too = new Date(r,m,d,g,mm,s);
animeInt2 = setInterval("liczCzas2(too)", 1000);
}
}
function liczCzas2(too)
{
now = new Date();
ile = too.getTime() - now.getTime();
sekund = Math.floor(ile / 1000);
document.getElementById("test").innerHTML = "Time to automatic refresh: "+sekund+" seconds";
if (ile < 0)
{
window.location.reload();
}
}
var animeInt;
clearInterval(animeInt);
animeInt = setInterval("liczCzas()", 1000);
Report bugs.
The script works like rl tibia(randoming questions, etc.)
#edit
REWRITTEN SCRIPT!!!
Last edited: