Файл: add_question.php
Строк: 136
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/constants.' . $phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
$user_lang = ($userdata['user_id'] != ANONYMOUS) ? $userdata['user_lang'] : $board_config['default_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
{
$user_lang = 'english';
include_once($phpbb_root_path . 'language/lang_english/lang_viktorina.php');
}
global $db , $lang , $phpEx , $phpbb_root_path;
define('QUESTIONS_TABLE', $table_prefix.'question');
define('QUESTIONS_TEMP_TABLE', $table_prefix.'questions_temp');
define('QUESTIONS_ACTIVE_TABLE', $table_prefix.'questions_active');
define('QUESTIONS_CONFIG_TABLE', $table_prefix.'questions_config');
$page_title = $lang['qz_page_title1'];
$user_id = $userdata['user_id'];
$points_name = ($board_config['points_name']) ? $board_config['points_name'] : 'points';
if (!$userdata['session_logged_in'] && $user_id == ANONYMOUS)
{
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
header($header_location . append_sid("login.$phpEx?redirect=viktorina.$phpEx", true));
exit;
}
$template->set_filenames(array( 'body' => 'viktorina_new_body.tpl'));
if ( isset($HTTP_POST_VARS['ok']) )
{
$quest = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['quest'])));
$otv1 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv1'])));
$otv2 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv2'])));
$otv3 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv3'])));
$otv4 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv4'])));
$real = $HTTP_POST_VARS['radio_otvet'];
$isto = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['isto'])));
if (!$quest OR !$otv1 OR !$otv2 OR !$otv3 OR !$otv4 OR !$real) redirect(append_sid("add_question.$phpEx", true));
$sql = "INSERT INTO " . QUESTIONS_TEMP_TABLE . "
(question, otvet_1, otvet_2, otvet_3, otvet_4, otvet_verno, isto, author)
VALUES ('$quest', '$otv1', '$otv2', '$otv3', '$otv4', $real, '$isto', $user_id)";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, $lang['qz_obloms']."201", '', __LINE__, __FILE__, $sql);
}
$message = $lang['qz_message_send'];
message_die(GENERAL_MESSAGE, $message);
}
if ( !isset($HTTP_POST_VARS['ok']) )
{
$sql= "SELECT config_value
FROM " . QUESTIONS_CONFIG_TABLE . "
WHERE config_name = 'max_numb_temp'";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, $lang['qz_obloms']."202", "", __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$count_voprs_max = $row['config_value'];
$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']."203", "", __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$cost_input = $row['config_value'];
$sql = "SELECT COUNT(*) as count_voprs FROM " . QUESTIONS_TEMP_TABLE . " WHERE author = $user_id";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, $lang['qz_obloms']."204", "", __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$count_voprs = $row['count_voprs'];
if ( $count_voprs+1 > $count_voprs_max)
{
$dis = ' disabled';
$info = $lang['qz_mnogo_vop'];
}
elseif ( !$count_voprs )
{
$dis = '';
$info = '';
}
else
{
$dis = '';
$info = $lang['qz_info_add'] . $count_voprs . '</b></font>';
}
}
$template->set_filenames(array( 'body' => 'viktorina_new_body.tpl'));
$template->assign_vars(array(
'L_FORM' => $lang['qz_formname'],
'L_INFO_PRIZE' => $lang['qz_info_prize'],
'L_INPUT_VARS' => $lang['qz_input_vars'],
'L_VAR' => $lang['qz_variant'],
'L_ISTO' => $lang['qz_add_isto'],
'L_ISTO1' => $lang['qz_add_isto1st'],
'L_SEND' => $lang['qz_send'],
'L_CLEAR' => $lang['qz_clear'],
'L_COPYR' => $lang['qz_co'],
'DIS' => $dis,
'INFO' => $info,
'PRIZE' => $cost_input,
'QUEST' => $lang['qz_quest'],
'POINTS' => $points_name
));
$template->assign_block_vars('', array());
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
?>