• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Gesior ACC] Tutor Test => Rewritten

Status
Not open for further replies.
Ok, it's working now. But I still have a problem. My account got blocked when I entered the control panel. Now I'll have to unblock it from the database every time. :p
 
Blocking account is in script, because player may get easier questions!
 
The problem is that I didn't even do the test. :/ Can't you make that configurable?

Btw, I added rep. ;)

Script works perfectly, if you have any ideas, you can add to your test.
 
Nono, I was just asking if you could make the account blocking configurable in the script.

I can do it, but now I don't have free time, I'm writing from iphone :|


#edit
#down
Yes :)
 
Last edited:

It would be this:

PHP:
<?php
/* Created by Averatec(pervera.pl) */

$link = "test";

if($logged)
{    
    $dark = $config['site']['darkborder'];
    $light = $config['site']['lightborder'];
    $group=2; //group id
    $number_of_tutors=20;
    $level=20;
    $number_of_questions = 0; // showed questions // change from 0 to your number!!!
    
    $num = $SQL->query('SELECT COUNT(`group_id`) AS num FROM `players` WHERE `group_id` = '.$group.'')->fetch();
    
	if (function_exists('isPremium($premdays, $lastday)'))    
    {
        return (int) $premdays - floor((time() - $lastday) / 86400);
    }
        
    if($account_logged->getCustomField("passed") == 1)
    {
        $blocked_long = 0;
        $account_logged->setCustomField('blocked_long', $blocked_long);
        $blocked_normal = 0;
        $account_logged->setCustomField('blocked_normal', $blocked_normal);
        $blocked_short = 0;
        $account_logged->setCustomField('blocked_short', $blocked_short);
    }
    
    if($account_logged->getCustomField("blocked_short") > 0 and $account_logged->getCustomField("blocked_short") < time())
    {
        $problem = 'The time to complete the test expired.';
        $expired=true;
    }
    else
    {
        $expired=false;
    }
    $blocked_short = 0;
    $account_logged->setCustomField('blocked_short', $blocked_short);
    
    if($num['num'] >= $number_of_tutors)
    {
        $errors[] = 'Too many tutors are now.';
    }
    if($account_logged->getCustomField("blocked_long") > time())
    {
        $errors[] = 'Your account is blocked, please try again later('.date("j.n.Y, H:i:s", $account_logged->getCustomField("blocked_long")).').';
    }
    if($account_logged->getCustomField("passed") == 1)
    {
        $errors[] = 'You have already passed the test.';
    }
    if(!isPremium($account_logged->getCustomField("premdays"), $account_logged->getCustomField("lastday")) > 7)
    {
        $errors[] = 'You do not have 7 days premium account.';
    }
    
    if(!empty($errors))
    {    
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Informations</B></TD></TR>';
        foreach($errors as $error)
        {
            if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
            $main_content .= '<tr bgcolor='.$bgcolor.'><td>'.$error.'</td></tr>';
        }
        $main_content .= '</table>';
        $deny=true;
    }

    if($number_of_questions > 0)
    {
        $questions_radio = $SQL->query('SELECT * from `z_test_questions` where `type` = "radio"')->fetchAll();
        $random_questions_radio = array_rand ($questions_radio, $number_of_questions);

        $questions_checkbox = $SQL->query('SELECT * from `z_test_questions` where `type` = "checkbox"')->fetchAll();
        $random_questions_checkbox = array_rand ($questions_checkbox, $number_of_questions);
    }
    else
    {
        $random_questions_radio = 0;
        $random_questions_checkbox = 0;
    }

    $unique[0] = 564321;
    $unique[1] = 574321;
    $unique[2] = 584321;
    if(!$expired)
    {
        if(!$deny)
        {
            if(isset($_POST['check']))
            {    
                $player = $ots->createObject('Player');
                $name = stripslashes(ucwords(strtolower(trim($_POST['f1']))));
                $player->find($name);
                if($player->isLoaded() and $player->getCustomField("online") == 0)
                {
                    if($player->getCustomField("online") == 0)
                    {    
                        for($i=0;$i < $number_of_questions; $i++) //radio checking
                        {    
                            $nie = $_POST[$unique[0]];
                    
                            if(isset($_POST[$unique[0]]))
                            {
                                if(!empty($_POST[$nie]))
                                {
                                    $check = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[0]]))).' and `answer_id` = '.addslashes(htmlspecialchars(trim($_POST[$nie]))).'')->fetch();
                    
                                    if($check['true_or_false'] == 1)
                                    $checked=true;
                                    else
                                    $checked=false;
                    
                                    if(!$checked)
                                    {
                                        //deny
                                        $blocked_long = time()+14*24*60*60;
                                        $account_logged->setCustomField('blocked_long', $blocked_long);
                                        header('Location: index.php?subtopic='.$link.'');
                                    }                    
                                }
                                else
                                {
                                    //deny
                                    $blocked_long = time()+14*24*60*60;
                                    $account_logged->setCustomField('blocked_long', $blocked_long);
                                    header('Location: index.php?subtopic='.$link.'');
                                }
                            
                                $unique[0]++;
                            }
                        }
                        for($i=0;$i < $number_of_questions; $i++)
                        {
                            if(isset($_POST[$unique[1]]))
                            {
                                $answers = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[1]]))).'');

                                foreach($answers as $answer)
                                {
                                    if(!empty($_POST[$unique[2]]))
                                    {
                                        $check = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[1]]))).' and `answer_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[2]]))).'')->fetchAll();

                                        if($answer['true_or_false'] == 1)
                                        {
                                            if($answer['true_or_false'] != $check[0]['true_or_false'])
                                            {
                                                //deny
                                                $blocked_long = time()+14*24*60*60;
                                                $account_logged->setCustomField('blocked_long', $blocked_long);
                                                header('Location: index.php?subtopic='.$link.'');
                                            }
                                        }
                                    }
                                    else
                                    {
                                        $check[0]['true_or_false'] = 0;
                                        if($answer['true_or_false'] == 1)
                                        {
                                            if($answer['true_or_false'] != $check[0]['true_or_false'])
                                            {
                                                //deny
                                                $blocked_long = time()+14*24*60*60;
                                                $account_logged->setCustomField('blocked_long', $blocked_long);
                                                header('Location: index.php?subtopic='.$link.'');
                                            }
                                        }
                                    }
                        
                                    $unique[2]++;
                                }
                    
                                $unique[1]++;
                            }
                        }
                    }
                    else
                    {
                        header('Location: index.php?subtopic='.$link.'');
                    }
                    //PASSED
                    $main_content .= '<center><font size=3><b>Congratulations!</b></font></center>';
                    $account_logged->setCustomField('passed', 1);
                    $player->setCustomField("group_id", $group);
                    $account_logged->setCustomField('blocked_normal', 0);                    
                    $showed=true;
                }
                else
                {
                    header('Location: index.php?subtopic='.$link.'');
                }
            }
        }
    }
    else
    {
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Informations</B></TD></TR>';
        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
        $main_content .= '<tr bgcolor='.$bgcolor.'><td>'.$problem.'</td></tr>';
        $main_content .= '</table>';
    }
    
    if($account_logged->getCustomField('blocked_normal') < time())
    {
        if(!$deny)
        {
            if(!$showed)
            {
                $main_content .= '<form method="post" action="">';
                $account_players = $account_logged->getPlayers();
                $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white height=20><B>Select Character</B></TD></TR>';
                foreach($account_players as $player)
                {
                    if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                    $players = $player->getName();
                    $player_lvl = $player->getLevel();
                    if($player_lvl >= $level)
                        $main_content .= "<TR BGCOLOR=\"$bgcolor\"><td width=8% height=20><center><input type=radio name=f1 value=\"$players\"></center></td><td height=20>$players</td></tr>";
                    else
                        $main_content .= "<TR BGCOLOR=\"$bgcolor\"><td width=8% height=20><center>Blocked</center></td><td height=20>$players</td></tr>";                        
                }
                $main_content .= '</table><br><br>';
                
                $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white height=20><B>Tutor Test</B></TD></TR>';
                
        
                $uniques[0] = 564321;
                for($i=0;$i < $number_of_questions; $i++)
                {
                    if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                    $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td COLSPAN=2 height=20><b>'.$questions_radio[$random_questions_radio[$i]]['question'].'</b></td></tr>';
        
                    $answers_radio = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.$questions_radio[$random_questions_radio[$i]]['id'].'');
                    $main_content .= '<input type=hidden name='.$uniques[0].' value='.$questions_radio[$random_questions_radio[$i]]['id'].' />';
            
                    foreach($answers_radio as $answer)
                    {    
                        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                        $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=5% height=20><center><input type=radio name='.$answer['question_id'].' value='.$answer['answer_id'].' /></center></td><td height=20>'.$answer['answer'].'</td></tr>';
                    }    
                    $uniques[0]++;
                }

                $uniques[1] = 574321;
                $uniques[2] = 584321;
                for($i=0;$i < $number_of_questions; $i++)
                {
                    if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                    $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td COLSPAN=2 height=20><b>'.$questions_checkbox[$random_questions_checkbox[$i]]['question'].'</b></td></tr>';
            
                    $answers_radio = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.$questions_checkbox[$random_questions_checkbox[$i]]['id'].'');
                    $main_content .= '<input type=hidden name='.$uniques[1].' value='.$questions_checkbox[$random_questions_checkbox[$i]]['id'].' />';
            
                    foreach($answers_radio as $answer)
                    {    
                        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                        $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=5% height=20><center><input type=checkbox name='.$uniques[2].' value='.$answer['answer_id'].' /></center></td><td height=20>'.$answer['answer'].'</td></tr>';
                        $uniques[2]++;
                    }    
                    $uniques[1]++;
                }
                $main_content .= '</table>';
                $main_content .= '<br><input type="submit" name="check" value="Submit" class="input2"/></form><br>';
                $main_content .= '<br>You must fill out the form within 15 minutes.<br>';
                $main_content .= 'Please choose a character that is <font color=red>offline</font>.<br>';
                
                $blocked_short = time()+9;
                $blocked_normal = time()+1*24*60*60;
                
                $account_logged->setCustomField('blocked_short', $blocked_short);
                $account_logged->setCustomField('blocked_normal', $blocked_normal);
            }
        }
    }
    else
    {
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Informations</B></TD></TR>';
        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
        $main_content .= '<tr bgcolor='.$bgcolor.'><td>Your account is blocked, please try again later('.date("j.n.Y, H:i:s", $account_logged->getCustomField("blocked_normal")).').</td></tr>';
        $main_content .= '</table>';
    }
    //Adding questions & answers
    if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] != "true")
    {
        $main_content .= '<br><a href="?subtopic='.$link.'&control=true"><b>Panel Control</b></a><br>';
        $main_content .= '<a href="?subtopic='.$link.'&control=true&adm=clean"><b>Remove Old Tutors</b></a><br><br>';
    }
    if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] == "true")
    {
        if(isset($_POST['next']))
        {
            $_SESSION['answers'] = $_POST['answers'];
            if($_POST['type'] == 1)
            {
                $type = "checkbox";
                $_SESSION['type'] = $type;
                $main_content .= '<form method="post" action=""><b><font size=3>Adding</font></b><br><br>
                <input type=text name=question value="" /> Question<br>In radio must be one true answer and only one answer!!!<br>';
            
                for( $x = 1; $x <= $_SESSION['answers']; $x++ )
                {
                    $a = $x+1000;
                    $main_content .= '<input type=text name='.$x.' value="" /> Answer no. '.$x.'';
                    $main_content .= '<input type=text name='.$a.' value="" /> false=0 || true=1<br>';
                }
                $main_content .= '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
            }
            elseif($_POST['type'] == 2)
            {
                $type = "radio";
                $_SESSION['type'] = $type;
                $main_content .= '<form method="post" action=""><b><font size=3>Adding</font></b><br><br>
                <input type=text name=question value="" /> Question<br>';
            
                for( $x = 1; $x <= $_SESSION['answers']; $x++ )
                {
                    $a = $x+1000;
                    $main_content .= '<input type=text name='.$x.' value="" /> Answer no. '.$x.' - ';
                    $main_content .= '<input type=text name='.$a.' value="" /> false=0 || true=1<br>';
                }
                $main_content .= '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
            }
            $next=true;
        }
        if(isset($_POST['finish']))
        {
            $id = $SQL->query('SELECT MAX(id) FROM `z_test_questions`')->fetch();
            $id_next = $id[0] + 1;
                
            for( $x = 1; $x <= $_SESSION['answers']; $x++ )
            {
                $a = $x+1000;
                $INSERT_answer = $SQL->query('INSERT INTO `z_test_answers` (`question_id`,`answer_id`,`answer`, `true_or_false`) VALUES ('.$SQL->quote($id_next).','.$SQL->quote($x).','.$SQL->quote($_POST[$x]).','.$SQL->quote($_POST[$a]).')');
            }
            $INSERT_question = $SQL->query('INSERT INTO `z_test_questions` (`id`,`question`,`type`) VALUES ('.$SQL->quote($id_next).','.$SQL->quote($_POST['question']).','.$SQL->quote($_SESSION['type']).')');
        }
        if(!$next)
        {
            $main_content .= '<form method="post" action=""><b><font size=3>Adding</font></b><br><br>
            <input type=radio name=type value="1"/> Checkbox<br>
            <input type=radio name=type value="2"/> Radio<br>
            <input type=text name=answers value"" /> Number of Answers<br>
            <input type="submit" name="next" value="Submit" class="input2"/></form><br><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")) < 7 or $player->getCustomField("level") < 20)
                {
                    $account->setCustomField("passed", 0);
                    $account->setCustomField('blocked_normal', time() + 604800);
                    $player->setCustomField("group_id", 1);
                    $main_content .= 'deleted - '.$players['name'].'<br>';
                }
                elseif(($time - $player->getCustomField("lastlogin")) > 7*24*60*60)
                {
                    $account->setCustomField("passed", 0);
                    $account->setCustomField('blocked_normal', time() + 604800);
                    $player->setCustomField("group_id", 1);
                    $main_content .= 'deleted - '.$players['name'].'<br>';
                }
            }
        }    
    }
}
else
{
    $main_content .= 'Please enter your account number and your password.<br/><a href="?subtopic=createaccount" >Create an account</a> if you do not have one yet.<br/><br/><form action="?subtopic='.$link.'" 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 Number:</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>';
}
?>
 
It would be this:

PHP:
<?php
/* Created by Averatec(pervera.pl) */

$link = "test";

if($logged)
{    
    $dark = $config['site']['darkborder'];
    $light = $config['site']['lightborder'];
    $group=2; //group id
    $number_of_tutors=20;
    $level=20;
    $number_of_questions = 0; // showed questions // change from 0 to your number!!!
    
    $num = $SQL->query('SELECT COUNT(`group_id`) AS num FROM `players` WHERE `group_id` = '.$group.'')->fetch();
    
	if (function_exists('isPremium($premdays, $lastday)'))    
    {
        return (int) $premdays - floor((time() - $lastday) / 86400);
    }
        
    if($account_logged->getCustomField("passed") == 1)
    {
        $blocked_long = 0;
        $account_logged->setCustomField('blocked_long', $blocked_long);
        $blocked_normal = 0;
        $account_logged->setCustomField('blocked_normal', $blocked_normal);
        $blocked_short = 0;
        $account_logged->setCustomField('blocked_short', $blocked_short);
    }
    
    if($account_logged->getCustomField("blocked_short") > 0 and $account_logged->getCustomField("blocked_short") < time())
    {
        $problem = 'The time to complete the test expired.';
        $expired=true;
    }
    else
    {
        $expired=false;
    }
    $blocked_short = 0;
    $account_logged->setCustomField('blocked_short', $blocked_short);
    
    if($num['num'] >= $number_of_tutors)
    {
        $errors[] = 'Too many tutors are now.';
    }
    if($account_logged->getCustomField("blocked_long") > time())
    {
        $errors[] = 'Your account is blocked, please try again later('.date("j.n.Y, H:i:s", $account_logged->getCustomField("blocked_long")).').';
    }
    if($account_logged->getCustomField("passed") == 1)
    {
        $errors[] = 'You have already passed the test.';
    }
    if(!isPremium($account_logged->getCustomField("premdays"), $account_logged->getCustomField("lastday")) > 7)
    {
        $errors[] = 'You do not have 7 days premium account.';
    }
    
    if(!empty($errors))
    {    
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Informations</B></TD></TR>';
        foreach($errors as $error)
        {
            if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
            $main_content .= '<tr bgcolor='.$bgcolor.'><td>'.$error.'</td></tr>';
        }
        $main_content .= '</table>';
        $deny=true;
    }

    if($number_of_questions > 0)
    {
        $questions_radio = $SQL->query('SELECT * from `z_test_questions` where `type` = "radio"')->fetchAll();
        $random_questions_radio = array_rand ($questions_radio, $number_of_questions);

        $questions_checkbox = $SQL->query('SELECT * from `z_test_questions` where `type` = "checkbox"')->fetchAll();
        $random_questions_checkbox = array_rand ($questions_checkbox, $number_of_questions);
    }
    else
    {
        $random_questions_radio = 0;
        $random_questions_checkbox = 0;
    }

    $unique[0] = 564321;
    $unique[1] = 574321;
    $unique[2] = 584321;
    if(!$expired)
    {
        if(!$deny)
        {
            if(isset($_POST['check']))
            {    
                $player = $ots->createObject('Player');
                $name = stripslashes(ucwords(strtolower(trim($_POST['f1']))));
                $player->find($name);
                if($player->isLoaded() and $player->getCustomField("online") == 0)
                {
                    if($player->getCustomField("online") == 0)
                    {    
                        for($i=0;$i < $number_of_questions; $i++) //radio checking
                        {    
                            $nie = $_POST[$unique[0]];
                    
                            if(isset($_POST[$unique[0]]))
                            {
                                if(!empty($_POST[$nie]))
                                {
                                    $check = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[0]]))).' and `answer_id` = '.addslashes(htmlspecialchars(trim($_POST[$nie]))).'')->fetch();
                    
                                    if($check['true_or_false'] == 1)
                                    $checked=true;
                                    else
                                    $checked=false;
                    
                                    if(!$checked)
                                    {
                                        //deny
                                        $blocked_long = time()+14*24*60*60;
                                        $account_logged->setCustomField('blocked_long', $blocked_long);
                                        header('Location: index.php?subtopic='.$link.'');
                                    }                    
                                }
                                else
                                {
                                    //deny
                                    $blocked_long = time()+14*24*60*60;
                                    $account_logged->setCustomField('blocked_long', $blocked_long);
                                    header('Location: index.php?subtopic='.$link.'');
                                }
                            
                                $unique[0]++;
                            }
                        }
                        for($i=0;$i < $number_of_questions; $i++)
                        {
                            if(isset($_POST[$unique[1]]))
                            {
                                $answers = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[1]]))).'');

                                foreach($answers as $answer)
                                {
                                    if(!empty($_POST[$unique[2]]))
                                    {
                                        $check = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[1]]))).' and `answer_id` = '.addslashes(htmlspecialchars(trim($_POST[$unique[2]]))).'')->fetchAll();

                                        if($answer['true_or_false'] == 1)
                                        {
                                            if($answer['true_or_false'] != $check[0]['true_or_false'])
                                            {
                                                //deny
                                                $blocked_long = time()+14*24*60*60;
                                                $account_logged->setCustomField('blocked_long', $blocked_long);
                                                header('Location: index.php?subtopic='.$link.'');
                                            }
                                        }
                                    }
                                    else
                                    {
                                        $check[0]['true_or_false'] = 0;
                                        if($answer['true_or_false'] == 1)
                                        {
                                            if($answer['true_or_false'] != $check[0]['true_or_false'])
                                            {
                                                //deny
                                                $blocked_long = time()+14*24*60*60;
                                                $account_logged->setCustomField('blocked_long', $blocked_long);
                                                header('Location: index.php?subtopic='.$link.'');
                                            }
                                        }
                                    }
                        
                                    $unique[2]++;
                                }
                    
                                $unique[1]++;
                            }
                        }
                    }
                    else
                    {
                        header('Location: index.php?subtopic='.$link.'');
                    }
                    //PASSED
                    $main_content .= '<center><font size=3><b>Congratulations!</b></font></center>';
                    $account_logged->setCustomField('passed', 1);
                    $player->setCustomField("group_id", $group);
                    $account_logged->setCustomField('blocked_normal', 0);                    
                    $showed=true;
                }
                else
                {
                    header('Location: index.php?subtopic='.$link.'');
                }
            }
        }
    }
    else
    {
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Informations</B></TD></TR>';
        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
        $main_content .= '<tr bgcolor='.$bgcolor.'><td>'.$problem.'</td></tr>';
        $main_content .= '</table>';
    }
    
    if($account_logged->getCustomField('blocked_normal') < time())
    {
        if(!$deny)
        {
            if(!$showed)
            {
                $main_content .= '<form method="post" action="">';
                $account_players = $account_logged->getPlayers();
                $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white height=20><B>Select Character</B></TD></TR>';
                foreach($account_players as $player)
                {
                    if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                    $players = $player->getName();
                    $player_lvl = $player->getLevel();
                    if($player_lvl >= $level)
                        $main_content .= "<TR BGCOLOR=\"$bgcolor\"><td width=8% height=20><center><input type=radio name=f1 value=\"$players\"></center></td><td height=20>$players</td></tr>";
                    else
                        $main_content .= "<TR BGCOLOR=\"$bgcolor\"><td width=8% height=20><center>Blocked</center></td><td height=20>$players</td></tr>";                        
                }
                $main_content .= '</table><br><br>';
                
                $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white height=20><B>Tutor Test</B></TD></TR>';
                
        
                $uniques[0] = 564321;
                for($i=0;$i < $number_of_questions; $i++)
                {
                    if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                    $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td COLSPAN=2 height=20><b>'.$questions_radio[$random_questions_radio[$i]]['question'].'</b></td></tr>';
        
                    $answers_radio = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.$questions_radio[$random_questions_radio[$i]]['id'].'');
                    $main_content .= '<input type=hidden name='.$uniques[0].' value='.$questions_radio[$random_questions_radio[$i]]['id'].' />';
            
                    foreach($answers_radio as $answer)
                    {    
                        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                        $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=5% height=20><center><input type=radio name='.$answer['question_id'].' value='.$answer['answer_id'].' /></center></td><td height=20>'.$answer['answer'].'</td></tr>';
                    }    
                    $uniques[0]++;
                }

                $uniques[1] = 574321;
                $uniques[2] = 584321;
                for($i=0;$i < $number_of_questions; $i++)
                {
                    if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                    $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td COLSPAN=2 height=20><b>'.$questions_checkbox[$random_questions_checkbox[$i]]['question'].'</b></td></tr>';
            
                    $answers_radio = $SQL->query('SELECT * from `z_test_answers` where `question_id` = '.$questions_checkbox[$random_questions_checkbox[$i]]['id'].'');
                    $main_content .= '<input type=hidden name='.$uniques[1].' value='.$questions_checkbox[$random_questions_checkbox[$i]]['id'].' />';
            
                    foreach($answers_radio as $answer)
                    {    
                        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
                        $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><td width=5% height=20><center><input type=checkbox name='.$uniques[2].' value='.$answer['answer_id'].' /></center></td><td height=20>'.$answer['answer'].'</td></tr>';
                        $uniques[2]++;
                    }    
                    $uniques[1]++;
                }
                $main_content .= '</table>';
                $main_content .= '<br><input type="submit" name="check" value="Submit" class="input2"/></form><br>';
                $main_content .= '<br>You must fill out the form within 15 minutes.<br>';
                $main_content .= 'Please choose a character that is <font color=red>offline</font>.<br>';
                
                $blocked_short = time()+9;
                $blocked_normal = time()+1*24*60*60;
                
                $account_logged->setCustomField('blocked_short', $blocked_short);
                $account_logged->setCustomField('blocked_normal', $blocked_normal);
            }
        }
    }
    else
    {
        $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Informations</B></TD></TR>';
        if(is_int($number_of_rows / 2)) { $bgcolor = $light; } else { $bgcolor = $dark; } $number_of_rows++;
        $main_content .= '<tr bgcolor='.$bgcolor.'><td>Your account is blocked, please try again later('.date("j.n.Y, H:i:s", $account_logged->getCustomField("blocked_normal")).').</td></tr>';
        $main_content .= '</table>';
    }
    //Adding questions & answers
    if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] != "true")
    {
        $main_content .= '<br><a href="?subtopic='.$link.'&control=true"><b>Panel Control</b></a><br>';
        $main_content .= '<a href="?subtopic='.$link.'&control=true&adm=clean"><b>Remove Old Tutors</b></a><br><br>';
    }
    if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] and $_REQUEST['control'] == "true")
    {
        if(isset($_POST['next']))
        {
            $_SESSION['answers'] = $_POST['answers'];
            if($_POST['type'] == 1)
            {
                $type = "checkbox";
                $_SESSION['type'] = $type;
                $main_content .= '<form method="post" action=""><b><font size=3>Adding</font></b><br><br>
                <input type=text name=question value="" /> Question<br>In radio must be one true answer and only one answer!!!<br>';
            
                for( $x = 1; $x <= $_SESSION['answers']; $x++ )
                {
                    $a = $x+1000;
                    $main_content .= '<input type=text name='.$x.' value="" /> Answer no. '.$x.'';
                    $main_content .= '<input type=text name='.$a.' value="" /> false=0 || true=1<br>';
                }
                $main_content .= '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
            }
            elseif($_POST['type'] == 2)
            {
                $type = "radio";
                $_SESSION['type'] = $type;
                $main_content .= '<form method="post" action=""><b><font size=3>Adding</font></b><br><br>
                <input type=text name=question value="" /> Question<br>';
            
                for( $x = 1; $x <= $_SESSION['answers']; $x++ )
                {
                    $a = $x+1000;
                    $main_content .= '<input type=text name='.$x.' value="" /> Answer no. '.$x.' - ';
                    $main_content .= '<input type=text name='.$a.' value="" /> false=0 || true=1<br>';
                }
                $main_content .= '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
            }
            $next=true;
        }
        if(isset($_POST['finish']))
        {
            $id = $SQL->query('SELECT MAX(id) FROM `z_test_questions`')->fetch();
            $id_next = $id[0] + 1;
                
            for( $x = 1; $x <= $_SESSION['answers']; $x++ )
            {
                $a = $x+1000;
                $INSERT_answer = $SQL->query('INSERT INTO `z_test_answers` (`question_id`,`answer_id`,`answer`, `true_or_false`) VALUES ('.$SQL->quote($id_next).','.$SQL->quote($x).','.$SQL->quote($_POST[$x]).','.$SQL->quote($_POST[$a]).')');
            }
            $INSERT_question = $SQL->query('INSERT INTO `z_test_questions` (`id`,`question`,`type`) VALUES ('.$SQL->quote($id_next).','.$SQL->quote($_POST['question']).','.$SQL->quote($_SESSION['type']).')');
        }
        if(!$next)
        {
            $main_content .= '<form method="post" action=""><b><font size=3>Adding</font></b><br><br>
            <input type=radio name=type value="1"/> Checkbox<br>
            <input type=radio name=type value="2"/> Radio<br>
            <input type=text name=answers value"" /> Number of Answers<br>
            <input type="submit" name="next" value="Submit" class="input2"/></form><br><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")) < 7 or $player->getCustomField("level") < 20)
                {
                    $account->setCustomField("passed", 0);
                    $account->setCustomField('blocked_normal', time() + 604800);
                    $player->setCustomField("group_id", 1);
                    $main_content .= 'deleted - '.$players['name'].'<br>';
                }
                elseif(($time - $player->getCustomField("lastlogin")) > 7*24*60*60)
                {
                    $account->setCustomField("passed", 0);
                    $account->setCustomField('blocked_normal', time() + 604800);
                    $player->setCustomField("group_id", 1);
                    $main_content .= 'deleted - '.$players['name'].'<br>';
                }
            }
        }    
    }
}
else
{
    $main_content .= 'Please enter your account number and your password.<br/><a href="?subtopic=createaccount" >Create an account</a> if you do not have one yet.<br/><br/><form action="?subtopic='.$link.'" 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 Number:</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>';
}
?>

WoW ? Are you master of code?
Maybe this:
PHP:
	if(!function_exists('isPremium'))
	{
		function isPremium($premdays, $lastday)
		{
			return (int) $premdays - floor((time() - $lastday) / 86400);
		}
	}

[size=+1]Thanks Victor :D[/size]
 
Last edited:
When I passed the test(I know I answered the questions correctly) It says The time to complete the test expired. and my account is blocked.
It says this even if I got like 10 min left
 
Hello
I have this fail:
PHP:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' in /var/www/test.php:237 Stack trace: #0 /var/www/test.php(237): PDO->query('SELECT * from `...') #1 /var/www/index.php(184): include('/var/www/test.p...') #2 {main} thrown in /var/www/test.php on line 237

What i should do it with?
 
It's your fault, maybe you don't have some table in mysql or questions :)
 
Do I need to have 10 questions with type 'Radio' if I have 10 questions with type 'Checkbox' ? :/
maybe tommorow I'll post my version of tutor test, random questions, random answers, like on real tibia - few checkboxes for each question.
PHP:
<?PHP
$normal_player_group_id = 1;
$tutor_player_group_id = 2;
$questions_number = 5;
$answers_number_min = 3;
$answers_number_max = 5;
$test_time = 30; // default 30 - player has 30 minutes to answer for all questions
$level_required = 50;
$premium_days_required = 5; // 0 = premium not required
$block_test_if_time_expired = 12; // default 12 hours
$block_test_if_wrong_answers = 48; // default 48 hours - 2 days
### QUESTIONS ###
$question[0]['question'] = "Select illegal names:";
$question[0][] = array("Gesior",false);
$question[0][] = array("Pvp Master",false);
$question[0][] = array("Fuuck Gaymasters",true);
$question[0][] = array("Arab Hater",true);
$question[0][] = array("Hitler",true);
$question[0][] = array("Sellacc",true);
$question[0][] = array("Harry Potter",true);
$question[0][] = array("Jesus Christ Sorcerer",true);
$question[0][] = array("Rayla",false);
$question[0][] = array("Packer",false);
$question[1]['question'] = "Which of the following statements about gamemasters are true?";
$question[1][] = array("Gamemasters can appoint tutors.",false);
$question[1][] = array("Gamemasters are players who have passed the gamemaster exam.",false);
$question[1][] = array("Gamemasters can check a character's criminal record.",false);
$question[1][] = array("Gamemasters process rule violation reports in the game.",true);
$question[1][] = array("Gamemasters help in quests.",false);
$question[1][] = array("Gamemasters give items.",false);
$question[2]['question'] = "When can you rename your character?";
$question[2][] = array("If your character has been killed",false);
$question[2][] = array("If your character has reached level 8",false);
$question[2][] = array("If the character name violates the Tibia Rules and the gamemaster has blocked it",true);
$question[2][] = array("If you have a Premium Account",false);
$question[2][] = array("If your character kill 5 players in one hour",false);
?>
It's default config for my tutor test. You can add new questions (with id 3,4,5,6... $question[3]), answers.
PHP:
array("If your character has been killed",false);
false - player CAN'T select answer
true - player MUST select answer
If player select one wrong answer or don't select answer with 'true' he must wait '$block_test_if_wrong_answers = 48;' (48 hours) :thumbup:
 
First screen from my tutor exam script.
tutorexamo.jpg
 
Status
Not open for further replies.

Similar threads

Back
Top