Просмотр файла games/add_question.php

Размер файла: 4.81Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. define('IN_PHPBB', true);
  7. $phpbb_root_path = './';
  8. include($phpbb_root_path . 'extension.inc');
  9. include($phpbb_root_path . 'common.' . $phpEx);
  10. include($phpbb_root_path . 'includes/constants.' . $phpEx);
  11.  
  12. $userdata = session_pagestart($user_ip, PAGE_INDEX);
  13. init_userprefs($userdata);
  14.  
  15. $user_lang = ($userdata['user_id'] != ANONYMOUS) ? $userdata['user_lang'] : $board_config['default_lang'];
  16. if( file_exists($phpbb_root_path . 'language/lang_' . $user_lang . '/lang_quizzz.php') )
  17. {
  18. include_once($phpbb_root_path . 'language/lang_' . $user_lang . '/lang_quizzz.php');
  19. }
  20. else
  21. {
  22. $user_lang = 'english';
  23. include_once($phpbb_root_path . 'language/lang_english/lang_quizzz.php');
  24. }
  25.  
  26. global $db , $lang , $phpEx , $phpbb_root_path;
  27.  
  28. define('QUESTIONS_TABLE', $table_prefix.'question');
  29. define('QUESTIONS_TEMP_TABLE', $table_prefix.'questions_temp');
  30. define('QUESTIONS_ACTIVE_TABLE', $table_prefix.'questions_active');
  31. define('QUESTIONS_CONFIG_TABLE', $table_prefix.'questions_config');
  32.  
  33. $page_title = $lang['qz_page_title1'];
  34.  
  35. $user_id = $userdata['user_id'];
  36. $points_name = ($board_config['points_name']) ? $board_config['points_name'] : 'points';
  37.  
  38. if (!$userdata['session_logged_in'] && $user_id == ANONYMOUS)
  39. {
  40. $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
  41. header($header_location . append_sid("login.$phpEx?redirect=quizzz.$phpEx", true));
  42. exit;
  43. }
  44.  
  45. $template->set_filenames(array( 'body' => 'quiz_new_body.tpl'));
  46. if ( isset($HTTP_POST_VARS['ok']) )
  47. {
  48.  
  49. $quest = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['quest'])));
  50. $otv1 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv1'])));
  51. $otv2 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv2'])));
  52. $otv3 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv3'])));
  53. $otv4 = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['otv4'])));
  54. $real = $HTTP_POST_VARS['radio_otvet'];
  55. $isto = htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['isto'])));
  56. if (!$quest OR !$otv1 OR !$otv2 OR !$otv3 OR !$otv4 OR !$real) redirect(append_sid("add_question.$phpEx", true));
  57. $sql = "INSERT INTO " . QUESTIONS_TEMP_TABLE . "
  58. (question, otvet_1, otvet_2, otvet_3, otvet_4, otvet_verno, isto, author)
  59. VALUES ('$quest', '$otv1', '$otv2', '$otv3', '$otv4', $real, '$isto', $user_id)";
  60. if (!$db->sql_query($sql))
  61. {
  62. message_die(GENERAL_ERROR, $lang['qz_obloms']."201", '', __LINE__, __FILE__, $sql);
  63. }
  64.  
  65. $message = $lang['qz_message_send'];
  66. message_die(GENERAL_MESSAGE, $message);
  67. }
  68.  
  69. if ( !isset($HTTP_POST_VARS['ok']) )
  70. {
  71. $sql= "SELECT config_value
  72. FROM " . QUESTIONS_CONFIG_TABLE . "
  73. WHERE config_name = 'max_numb_temp'";
  74. if(!$result = $db->sql_query($sql))
  75. {
  76. message_die(GENERAL_ERROR, $lang['qz_obloms']."202", "", __LINE__, __FILE__, $sql);
  77. }
  78. $row = $db->sql_fetchrow($result);
  79. $count_voprs_max = $row['config_value'];
  80.  
  81. $sql= "SELECT config_value
  82. FROM " . QUESTIONS_CONFIG_TABLE . "
  83. WHERE config_name = 'cost_input'";
  84. if(!$result = $db->sql_query($sql))
  85. {
  86. message_die(GENERAL_ERROR, $lang['qz_obloms']."203", "", __LINE__, __FILE__, $sql);
  87. }
  88. $row = $db->sql_fetchrow($result);
  89. $cost_input = $row['config_value'];
  90.  
  91. $sql = "SELECT COUNT(*) as count_voprs FROM " . QUESTIONS_TEMP_TABLE . " WHERE author = $user_id";
  92. if(!$result = $db->sql_query($sql))
  93. {
  94. message_die(GENERAL_ERROR, $lang['qz_obloms']."204", "", __LINE__, __FILE__, $sql);
  95. }
  96. $row = $db->sql_fetchrow($result);
  97. $count_voprs = $row['count_voprs'];
  98.  
  99. if ( $count_voprs+1 > $count_voprs_max)
  100. {
  101. $dis = ' disabled';
  102. $info = $lang['qz_mnogo_vop'];
  103. }
  104. elseif ( !$count_voprs )
  105. {
  106. $dis = '';
  107. $info = '';
  108. }
  109. else
  110. {
  111. $dis = '';
  112. $info = $lang['qz_info_add'] . $count_voprs . '</b></font>';
  113. }
  114. }
  115. $template->set_filenames(array( 'body' => 'quiz_new_body.tpl'));
  116.  
  117. $template->assign_vars(array(
  118. 'L_FORM' => $lang['qz_formname'],
  119. 'L_INFO_PRIZE' => $lang['qz_info_prize'],
  120. 'L_INPUT_VARS' => $lang['qz_input_vars'],
  121. 'L_VAR' => $lang['qz_variant'],
  122. 'L_ISTO' => $lang['qz_add_isto'],
  123. 'L_ISTO1' => $lang['qz_add_isto1st'],
  124. 'L_SEND' => $lang['qz_send'],
  125. 'L_CLEAR' => $lang['qz_clear'],
  126. 'L_COPYR' => $lang['qz_co'],
  127.  
  128. 'DIS' => $dis,
  129. 'INFO' => $info,
  130. 'PRIZE' => $cost_input,
  131. 'QUEST' => $lang['qz_quest'],
  132. 'POINTS' => $points_name
  133. ));
  134.  
  135. $template->assign_block_vars('', array());
  136.  
  137.  
  138. include($phpbb_root_path . 'includes/page_header.' . $phpEx);
  139.  
  140. $template->pparse('body');
  141.  
  142. include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
  143.  
  144. ?>