Просмотр файла admin/module_viktorina.php

Размер файла: 24.06Kb
<?php
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
	$filename = basename(__FILE__);
	$module[$lang['q_quiz']][$lang['q_sett']] = $filename."?p=1";
	$module[$lang['q_quiz']][$lang['q_quest']] = $filename."?p=2";
	return;
}

$no_page_header = TRUE;
$phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

$module_root_path = "../";
define('QUESTIONS_TABLE', $table_prefix.'question');
define('QUESTIONS_CONFIG_TABLE', $table_prefix.'questions_config');
define('QUESTIONS_TEMP_TABLE', $table_prefix.'questions_temp');
define('QUESTIONS_ACTIVE_TABLE', $table_prefix.'questions_active');
define('USERS_TABLE', $table_prefix.'users');

$points_name = ($board_config['points_name']) ? $board_config['points_name'] : 'points';

$template->set_filenames(array(
        'body' => 'admin/admin_viktorina.tpl')
);

$user_lang = $userdata['user_lang'];
if( file_exists($phpbb_root_path . 'language/lang_' . $user_lang . '/lang_viktorina.php') )
{
        include_once($phpbb_root_path . 'language/lang_' . $user_lang . '/lang_viktorina.php');
}
else
{
        include_once($phpbb_root_path . 'language/lang_english/lang_viktorina.php');
}

include('./page_header_admin.'.$phpEx);

if( $_GET['p'] == 1 OR !$_GET['p'] )
{

	if (isset ($HTTP_POST_VARS['save_conf_admin']))
	{
                $conf_on_off = (isset ($HTTP_POST_VARS['a_on_off'])) ? $HTTP_POST_VARS['a_on_off'] : 0;
                $conf_cost_right = (isset ($HTTP_POST_VARS['a_cost_right'])) ? $HTTP_POST_VARS['a_cost_right'] : 1;
                $conf_cost_input = (isset ($HTTP_POST_VARS['a_cost_input'])) ? $HTTP_POST_VARS['a_cost_input'] : 2;
                $conf_max_numb_temp = (isset ($HTTP_POST_VARS['a_max_input'])) ? $HTTP_POST_VARS['a_max_input'] : 10;
                $conf_numb2rate = (isset ($HTTP_POST_VARS['a_min_rat'])) ? $HTTP_POST_VARS['a_min_rat'] : 3;
                $conf_min_time = (isset ($HTTP_POST_VARS['a_min_time'])) ? $HTTP_POST_VARS['a_min_time'] : 1;
                $conf_otv_time = (isset ($HTTP_POST_VARS['a_otv_time'])) ? $HTTP_POST_VARS['a_otv_time'] : 20;
                $conf_popup = (isset ($HTTP_POST_VARS['a_pop2'])) ? $HTTP_POST_VARS['a_pop2'] : 0;
                $conf_snd_on = (isset ($HTTP_POST_VARS['a_on_snd'])) ? $HTTP_POST_VARS['a_on_snd'] : 1;

	        if ( !preg_match("/^[0-9]*$/", $conf_cost_right) OR !preg_match("/^[0-9]*$/", $conf_cost_input) OR !preg_match("/^[0-9]*$/", $conf_max_numb_temp) )
	        {
		        $message = $lang['qz_bad_format'] . sprintf($lang['qz_bad_return'], "<a href=\"" . append_sid("module_viktorina.$phpEx") . "\">", "</a>");
		        message_die(GENERAL_MESSAGE, $message);	
	        }
	        elseif ( !preg_match("/^[0-9]*$/", $conf_numb2rate) OR !preg_match("/^[0-9]*$/", $conf_min_time) OR !preg_match("/^[0-9]*$/", $conf_otv_time) )
	        {
		        $message = $lang['qz_bad_format'] . sprintf($lang['qz_bad_return'], "<a href=\"" . append_sid("module_viktorina.$phpEx") . "\">", "</a>");
		        message_die(GENERAL_MESSAGE, $message);	
	        }

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_on_off'
		        WHERE config_name = 'on_off'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_cost_right'
		        WHERE config_name = 'cost_right'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_cost_input'
		        WHERE config_name = 'cost_input'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_max_numb_temp'
		        WHERE config_name = 'max_numb_temp'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_numb2rate'
		        WHERE config_name = 'numb2rate'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_min_time'
		        WHERE config_name = 'min_time'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_otv_time'
		        WHERE config_name = 'otv_time'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_popup'
		        WHERE config_name = 'popup'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . QUESTIONS_CONFIG_TABLE . "
		        SET config_value = '$conf_snd_on'
		        WHERE config_name = 'snd_on'";
		if( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql);
		}
		$message = $lang['qz_save1'] . sprintf($lang['qz_settings'], "<a href=\"" . append_sid("module_viktorina.$phpEx") . "\">", "</a>") . $lang['qz_or_goto'] . sprintf($lang['qz_forum'], "<a href=\"" . append_sid("../index.$phpEx") . "\">", "</a>");
		message_die(GENERAL_MESSAGE, $message);	
	}
	if (!isset ($HTTP_POST_VARS['save_conf_admin']))
	{
	        $sql="SELECT * FROM " . QUESTIONS_CONFIG_TABLE;
	
	        if ( !($result = $db->sql_query($sql)) )
	        {
		        message_die(GENERAL_ERROR, $lang['qz_obloms'] ."101", '', __LINE__, __FILE__, $sql);
	        }
		while( $row = $db->sql_fetchrow($result) )
		{
			$quiz_conf[$row['config_name']] = $row['config_value'];
		}

		$conf_on_off = $quiz_conf['on_off'];
		$conf_cost_right = $quiz_conf['cost_right'];
		$conf_cost_input = $quiz_conf['cost_input'];
		$conf_max_numb_temp = $quiz_conf['max_numb_temp'];
		$conf_numb2rate = $quiz_conf['numb2rate'];
		$conf_min_time = $quiz_conf['min_time'];
		$conf_otv_time = $quiz_conf['otv_time'];
		$conf_snd_on = $quiz_conf['snd_on'];
		$conf_popup = $quiz_conf['popup'];

		$template->assign_block_vars('page1', array(
		       'ACTION1' => append_sid($module_root_path . 'admin/module_viktorina.' . $phpEx),
		       'L_SETT' => $lang['qz_ss'],
		       'L_MODE' => $lang['qz_mode'],
		       'L_QZ_ON' => $lang['qz_qz_on'],
		       'L_QZ_OFF' => $lang['qz_qz_off'],
		       'L_COST_RIGHT' => $lang['qz_cost_right'],
		       'L_COST_INPUT' => $lang['qz_cost_input'],
		       'L_MAX_TEMP' => $lang['qz_max_temp'],
		       'L_RATE' => $lang['qz_min2rate'],
		       'L_MIN_TIME' => $lang['qz_min_time'],
		       'L_M' => $lang['qz_minutes'],
		       'L_TA' => $lang['qz_time_answer'],
		       'L_S' => $lang['qz_seconds'],
		       'L_CONFIRM' => $lang['qz_adm_confirm'],
		       'L_BONUS2' => $lang['qz_bonus_in2'],
		       'L_OFF' => $lang['qz_off'],
		       'L_NUMB_BONUS' => $lang['qz_numb_bonus'],
		       'L_BONUS_CHECKED' => $lang['qz_bonus_checked'],
		       'L_AUTOMODER' => $lang['qz_automoder'],
		       'L_YES' => $lang['qz_yes'],
		       'L_NO' => $lang['qz_no'],
		       'L_SOUND' => $lang['qz_sound'],
		       'L_ONO' => $lang['qz_ono'],
		       'L_OFFO' => $lang['qz_offo'],
		       'L_SAVE' => $lang['qz_save'],
		       'L_COPYR' => $lang['qz_co'],

		       'A_ON_OFF' => $conf_on_off,
		       'A_COST_RIGHT' => $conf_cost_right,
		       'A_COST_INPUT' => $conf_cost_input,
		       'A_MAX_NUMB' => $conf_max_numb_temp,
		       'A_MIN_RAT' => $conf_numb2rate,
		       'CHECKED_ON_OFF1' => ($conf_on_off) ? 'checked="checked"' : '',
		       'CHECKED_ON_OFF0' => ($conf_on_off) ? '' : 'checked="checked"',
		       'SND_ON_OFF1' => ($conf_snd_on) ? 'checked="checked"' : '',
		       'SND_ON_OFF0' => ($conf_snd_on) ? '' : 'checked="checked"',
		       'POP2_ON' => ($conf_popup==2) ? 'checked="checked"' : '',
		       'POP2_OFF' => ($conf_popup==2) ? '' : 'checked="checked"',
		       'POINTS' => $points_name,
		       'A_OTV_TIME' => $conf_otv_time,
		       'A_MIN_TIME' => $conf_min_time)
		);
	}
}

if( $_GET['p']== 2 )
{
        if (!isset ($_GET['nnn']) )
        {
                $sql = "SELECT COUNT(id) AS numb_all FROM " . QUESTIONS_TABLE ;	
	        if(!$result = $db->sql_query($sql))
	        {
		        message_die(GENERAL_ERROR, $lang['qz_obloms'] ."102", "", __LINE__, __FILE__, $sql);
	        }
	        $row = $db->sql_fetchrow($result);
	        $numb_all = $row['numb_all'];
                
                $sql = "SELECT COUNT(id) AS numb_mod0 FROM " . QUESTIONS_TABLE . " WHERE moder=0";	
	        if(!$result = $db->sql_query($sql))
	        {
		        message_die(GENERAL_ERROR, $lang['qz_obloms'] ."103", "", __LINE__, __FILE__, $sql);
	        }
	        $row = $db->sql_fetchrow($result);
	        $numb_mod0 = $row['numb_mod0'];
	        $numb_mod1 = $numb_all-$numb_mod0;

                $sql = "SELECT COUNT(id) AS numb_temp FROM " . QUESTIONS_TEMP_TABLE;	
	        if(!$result = $db->sql_query($sql))
	        {
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."104", "", __LINE__, __FILE__, $sql);
	        }
	        $row = $db->sql_fetchrow($result);
	        $numb_temp = $row['numb_temp'];
        }
        if (isset ($_GET['nnn']) )
        {
                $numb_array = explode("-", $_GET['nnn']);
                $numb_temp = $numb_array[0];
                $numb_mod1 = $numb_array[1];
                $numb_mod0 = $numb_array[2];
        }
	if (isset ($HTTP_POST_VARS['cancel2']) AND isset ($HTTP_POST_VARS['cancel22']))
	{
		$cancel_id = $HTTP_POST_VARS['hidden_id'];
		$sql = "UPDATE " . QUESTIONS_TABLE . "
			SET moder = 0
			WHERE id = $cancel_id";
		if (!$db->sql_query($sql))
		{
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."105", "", __LINE__, __FILE__, $sql);
		}
                $numb_mod1 = $numb_mod1 -1;
                $numb_mod0 = $numb_mod0 +1;
	}

	if (isset ($HTTP_POST_VARS['add3']) AND isset ($HTTP_POST_VARS['add33']))
	{
		$cancel_id = $HTTP_POST_VARS['hidden_id'];
		$sql = "UPDATE " . QUESTIONS_TABLE . "
			SET moder = 1
			WHERE id = $cancel_id";
		if (!$db->sql_query($sql))
		{
		        message_die(GENERAL_ERROR, $lang['qz_obloms'] ."106", "", __LINE__, __FILE__, $sql);
		}
                $numb_mod0 = $numb_mod0 -1;
                $numb_mod1 = $numb_mod1 +1;
	}

	if (isset ($HTTP_POST_VARS['del2']) AND isset ($HTTP_POST_VARS['del22']))
	{
		$del_id = $HTTP_POST_VARS['hidden_id'];
		$sql = "DELETE FROM " . QUESTIONS_TABLE . "
			WHERE id = $del_id";
		if (!$db->sql_query($sql))
		{
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."107", "", __LINE__, __FILE__, $sql);
		}
                $numb_mod1 = $numb_mod1 -1;
	}

	if (isset ($HTTP_POST_VARS['del3']) AND isset ($HTTP_POST_VARS['del33']))
	{
		$del_id = $HTTP_POST_VARS['hidden_id'];
		$sql = "DELETE FROM " . QUESTIONS_TABLE . "
			WHERE id = $del_id";
		if (!$db->sql_query($sql))
		{
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."108", "", __LINE__, __FILE__, $sql);
		}
                $numb_mod0 = $numb_mod0 -1;
	}

	if (isset ($HTTP_POST_VARS['del1']) AND isset ($HTTP_POST_VARS['del11']))
	{
		$del_id = $HTTP_POST_VARS['hidden_id'];
		$sql = "DELETE FROM " . QUESTIONS_TEMP_TABLE . "
			WHERE id = $del_id";
		if (!$db->sql_query($sql))
		{
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."109", "", __LINE__, __FILE__, $sql);
		}
                $numb_temp = $numb_temp -1;
	}

	if (isset ($HTTP_POST_VARS['add1']) AND isset ($HTTP_POST_VARS['add11']))
	{
		$add_id = $HTTP_POST_VARS['hidden_id'];

		$sql = "SELECT * FROM " . QUESTIONS_TEMP_TABLE . " WHERE id = $add_id";
		if ( !($result = $db->sql_query($sql)) )
		{
				message_die(GENERAL_ERROR, $lang['qz_obloms'] ."110", '', __LINE__, __FILE__, $sql);
		}
		$row1 = $db->sql_fetchrow($result);
		$id = $row1['id'];
		$question = $row1['question'];
		$otvet_1 = $row1['otvet_1'];
		$otvet_2 = $row1['otvet_2'];
		$otvet_3 = $row1['otvet_3'];
		$otvet_4 = $row1['otvet_4'];
		$otvet_verno = $row1['otvet_verno'];
		$author_id = $row1['author'];

	        $sql = "SELECT username
	                FROM " . USERS_TABLE . "
	                WHERE user_id = $author_id
	                LIMIT 1";
	         if ( !($result = $db->sql_query($sql)) )
	         {
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."111", '', __LINE__, __FILE__, $sql);
	         }
	         $row2 = $db->sql_fetchrow($result);
	         $author = $row2['username'];

	         $sql = "SELECT config_value
	                 FROM " . QUESTIONS_CONFIG_TABLE . "
		         WHERE config_name = 'cost_input'";
	         if ( !($result = $db->sql_query($sql)) )
	         {
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."000", '', __LINE__, __FILE__, $sql);
	         }
	         $row3 = $db->sql_fetchrow($result);
	         $conf_cost_input = $row3['config_value'];

                 $sql = "UPDATE " . USERS_TABLE . "
	                 SET user_points = user_points+$conf_cost_input
	                 WHERE user_id = $author_id";
                 if ( !($result = $db->sql_query($sql)) )
	         {
		         message_die(GENERAL_ERROR, $lang['qz_obloms'] ."000", '', __LINE__, __FILE__, $sql);
	         }

	         $sql = "INSERT INTO " . QUESTIONS_TABLE . " (question, otvet_1, otvet_2, otvet_3, otvet_4, otvet_verno, moder, author)
		         VALUES ('$question', '$otvet_1', '$otvet_2', '$otvet_3', '$otvet_4', $otvet_verno, '1', '$author')";		
		 if (!$db->sql_query($sql))
		 {
			 message_die(GENERAL_ERROR, $lang['qz_obloms'] ."112", '', __LINE__, __FILE__, $sql);
		 }
                 $sql = "UPDATE " . QUESTIONS_ACTIVE_TABLE . "
	                 SET prin_vop = prin_vop+1
	                 WHERE user_id = $author_id LIMIT 1";
                 if ( !($result = $db->sql_query($sql)) )
                 {
	                 message_die(GENERAL_ERROR, $lang['qz_obloms'] ."113", '', __LINE__, __FILE__, $sql);
                 }

	         $sql = "DELETE FROM " . QUESTIONS_TEMP_TABLE . "
		         WHERE id = $id";
		 if (!$db->sql_query($sql))
		 {
			 message_die(GENERAL_ERROR, $lang['qz_obloms'] ."114", '', __LINE__, __FILE__, $sql);
		 }
                 $numb_temp = $numb_temp -1;
                 $numb_mod1 = $numb_mod1 +1;
         }
         $nnn = $numb_temp . "-" . $numb_mod1 . "-" . $numb_mod0;
         $page_numb_vop = 10; // number of questions on page

         $str01 = '<tr><td class="row1">';
         $str03 = $lang['qz_adm_view'] . $page_numb_vop . $lang['qz_start_view']. '<br/></span> <input type="text" name="vybor_start" class="post" size="4" maxlength="5" value=""><input type="submit" name="submit_start" value="ОК" class="liteoption">';
         $str04 = '</td></tr>';
	 if ( $_GET['type']==1 )
         {
                 $numb_vop2 = $numb_temp;
                 $za = ($numb_vop2) ? $lang['qz_manage_input'] : "";
                 $str02 = ($numb_vop2) ? $lang['qz_numb_inthis'] . $numb_vop2 . '<br>' : '';
                 $pusto = $lang['qz_pusto1'];
         }
	 if ( $_GET['type']==2 )
         {
                 $numb_vop2 = $numb_mod1;
                 $za = ($numb_vop2) ? $lang['qz_manage_raz'] : "";
                 $str02 = ($numb_vop2) ? $lang['qz_numb_inthis'] . $numb_vop2 . '<br>' : '';
                 $pusto = $lang['qz_pusto2'];
         }
	 if ( $_GET['type']==3 )
         {
                 $numb_vop2 = $numb_mod0;
                 $za = ($numb_vop2) ? $lang['qz_manage_zap'] : "";
                 $str02 = ($numb_vop2) ? $lang['qz_numb_inthis'] . $numb_vop2 . '<br>' : '';
                 $pusto = $lang['qz_pusto3'];
         }

         if( isset($HTTP_POST_VARS['vybor_start']))
         {
	         $start = abs($HTTP_POST_VARS['vybor_start'] - 1);
                 $page_action = $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=' . $_GET['type'] . '&nnn=' . $nnn;
         }
         else
         {
                 $start = 0;
                 $page_action = $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=' . $_GET['type'] . '&nnn=' . $nnn;
         }

         if( isset($_GET['start']) )
         {
	          $start = $_GET['start'] -1;
         }
	 if ($start+1 > $numb_mod1) $start=0;

         $start_next = $start + $page_numb_vop +1;

         $f = '<a href="' . append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=' . $_GET['type'] . '&nnn=' . $nnn . '&start=' . $start_next) . $lang['qz_next_page'];
	 $template->assign_block_vars('page2', array(
		'L_BASE' => $lang['qz_base'],
		'L_INPUT_Q' => $lang['qz_input_q'],
		'L_MODER1_Q' => $lang['qz_moder1_q'],
		'L_MODER0_Q' => $lang['qz_moder0_q'],
		'L_ST' => $lang['qz_stuk'],
		'L_VIEW' => $lang['qz_adm_view'],
		'L_COPYR' => $lang['qz_co'],

		'PAGING' => ($numb_vop2) ? $str01 . $str02 . $str03 . $f . $str04 : $pusto,
		'PAGE_ACTION' => append_sid($page_action),
		'LINK1' => append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=1&nnn=' . $nnn ),
		'LINK2' => append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=2&nnn=' . $nnn ),
		'LINK3' => append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=3&nnn=' . $nnn ),
		'NUMB_TEMP' => $numb_temp,
		'NUMB_MOD0' => $numb_mod0,
		'NUMB_MOD1' => $numb_mod1,
		'NUMB_VOP2' => $numb_vop2,
		'ZA' => $za)
	 );
	 if ( $_GET['type']==1 )
	 {
                 $sql = "SELECT * FROM " . QUESTIONS_TEMP_TABLE . " LIMIT $start, $page_numb_vop";
	         if( !($result = $db->sql_query($sql)) )
	         {
		          message_die(GENERAL_ERROR, $lang['qz_obloms'] ."115", "", __LINE__, __FILE__, $sql);
	         }
	         $row = $db->sql_fetchrowset($result);

                 for ($i=0; $i<count($row); $i++)
                 {
	                 $id_temp[$i] = $row[$i]['id'];
	                 $name_vop[$i] = $row[$i]['question'];
	                 $var_1[$i] = $row[$i]['otvet_1'];
	                 $var_2[$i] = $row[$i]['otvet_2'];
	                 $var_3[$i] = $row[$i]['otvet_3'];
	                 $var_4[$i] = $row[$i]['otvet_4'];
	                 $var_real[$i] = $row[$i]['otvet_verno'];
	                 $author1[$i] = $row[$i]['author'];
	                 $isto[$i] = $row[$i]['isto'];

	                 $sql = "SELECT username
	                         FROM " . USERS_TABLE . "
	                         WHERE user_id = $author1[$i]
	                         LIMIT 1";
		         if ( !($result = $db->sql_query($sql)) )
		         {
			          message_die(GENERAL_ERROR, $lang['qz_obloms'] ."116", '', __LINE__, __FILE__, $sql);
		         }
	                 $row2 = $db->sql_fetchrow($result);
	                 $author[$i] = $row2['username'];

	                 $template->assign_block_vars('page2.type1', array(
		                'ACTION' => append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=1&nnn=' . $nnn ),
		                'L_FROM' => $lang['qz_from_user'],
		                'L_ADD' => $lang['qz_act_add'],
		                'L_EDIT' => $lang['qz_act_edit'],
		                'L_DEL' => $lang['qz_act_del'],

		                'ID_VOP' => $id_temp[$i],
		                'NAME_VOP' => $name_vop[$i],
		                'VAR_1' => ($var_real[$i] == 1) ? ("<font color=blue>" . $var_1[$i] . "</font>") : $var_1[$i],
		                'VAR_2' => ($var_real[$i] == 2) ? ("<font color=blue>" . $var_2[$i] . "</font>") : $var_2[$i],
		                'VAR_3' => ($var_real[$i] == 3) ? ("<font color=blue>" . $var_3[$i] . "</font>") : $var_3[$i],
		                'VAR_4' => ($var_real[$i] == 4) ? ("<font color=blue>" . $var_4[$i] . "</font>") : $var_4[$i],
		                'ISTO' => $lang['qz_isto'] . $isto[$i],
		                'AUTHOR' => "<a href=" . $phpbb_root_path . "profile.php?mode=viewprofile&u=" . $author1[$i] . ">" . $author[$i] . "</a>")
		         );
                 }

	 }
	 if ( $_GET['type']==2 )
	 {
                 $sql = "SELECT * FROM " . QUESTIONS_TABLE . " WHERE moder=1 ORDER BY id ASC LIMIT $start, $page_numb_vop";
	         if( !($result = $db->sql_query($sql)) )
	         {
		          message_die(GENERAL_ERROR, $lang['qz_obloms'] ."117", "", __LINE__, __FILE__, $sql);
	         }
	         $row = $db->sql_fetchrowset($result);

                 for ($i=0; $i<count($row); $i++)
                 {
	                 $id_vop[$i] = $row[$i]['id'];
	                 $name_vop[$i] = $row[$i]['question'];
	                 $var_1[$i] = $row[$i]['otvet_1'];
	                 $var_2[$i] = $row[$i]['otvet_2'];
	                 $var_3[$i] = $row[$i]['otvet_3'];
	                 $var_4[$i] = $row[$i]['otvet_4'];
	                 $var_real[$i] = $row[$i]['otvet_verno'];
	                 $author[$i] = $row[$i]['author'];

	                 $template->assign_block_vars('page2.type2', array(
		                 'ACTION' => append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=2&nnn=' . $nnn ),
		                 'L_QUEST' => $lang['qz_quest'],
		                 'L_CANCEL' => $lang['qz_act_cancel'],
		                 'L_EDIT' => $lang['qz_act_edit'],
		                 'L_DEL' => $lang['qz_act_del'],
		                 'L_AUTOR' => $lang['qz_autor'],

		                 'ID_VOP' => $id_vop[$i],
		                 'NAME_VOP' => $name_vop[$i],
		                 'VAR_1' => ($var_real[$i] == 1) ? ("<font color=blue>" . $var_1[$i] . "</font>") : $var_1[$i],
		                 'VAR_2' => ($var_real[$i] == 2) ? ("<font color=blue>" . $var_2[$i] . "</font>") : $var_2[$i],
		                 'VAR_3' => ($var_real[$i] == 3) ? ("<font color=blue>" . $var_3[$i] . "</font>") : $var_3[$i],
		                 'VAR_4' => ($var_real[$i] == 4) ? ("<font color=blue>" . $var_4[$i] . "</font>") : $var_4[$i],
		                 'AUTHOR' => $author[$i])
	                 );
                 }
	 }
	 if ( $_GET['type']==3 )
	 {
                 $sql = "SELECT * FROM " . QUESTIONS_TABLE . " 
                         WHERE moder = 0 ORDER BY id ASC 
                         LIMIT $start, $page_numb_vop";
	         if( !($result = $db->sql_query($sql)) )
	         {
		          message_die(GENERAL_ERROR, $lang['qz_obloms'] ."118", "", __LINE__, __FILE__, $sql);
	         }
	         $row = $db->sql_fetchrowset($result);

                 for ($i=0; $i<count($row); $i++)
                 {
	                  $id_vop[$i] = $row[$i]['id'];
	                  $name_vop[$i] = $row[$i]['question'];
	                  $var_1[$i] = $row[$i]['otvet_1'];
	                  $var_2[$i] = $row[$i]['otvet_2'];
	                  $var_3[$i] = $row[$i]['otvet_3'];
	                  $var_4[$i] = $row[$i]['otvet_4'];
	                  $var_real[$i] = $row[$i]['otvet_verno'];
	                  $author[$i] = $row[$i]['author'];
	                  $template->assign_block_vars('page2.type3', array(
		                'ACTION' => append_sid( $module_root_path . 'admin/module_viktorina.' . $phpEx . '?p=2&type=3&nnn=' . $nnn ),
		                'L_QUEST' => $lang['qz_quest'],
		                'L_MOD1' => $lang['qz_act_moder1'],
		                'L_EDIT' => $lang['qz_act_edit'],
		                'L_DEL' => $lang['qz_act_del'],
		                'L_AUTOR' => $lang['qz_autor'],

		                'ID_VOP' => $id_vop[$i],
		                'NAME_VOP' => $name_vop[$i],
		                'VAR_1' => ($var_real[$i] == 1) ? ("<font color=blue>" . $var_1[$i] . "</font>") : $var_1[$i],
		                'VAR_2' => ($var_real[$i] == 2) ? ("<font color=blue>" . $var_2[$i] . "</font>") : $var_2[$i],
		                'VAR_3' => ($var_real[$i] == 3) ? ("<font color=blue>" . $var_3[$i] . "</font>") : $var_3[$i],
		                'VAR_4' => ($var_real[$i] == 4) ? ("<font color=blue>" . $var_4[$i] . "</font>") : $var_4[$i],
		                'AUTHOR' => $author[$i])
	                 );
                 }
	 }
}

$template->pparse('body');

?>