Advertisement
aligatro

Plug answer code

Dec 24th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.02 KB | None | 0 0
  1. <?php
  2. /*Выводим инфо после голоса юзера*/
  3. ob_start();
  4. $pool1_abspath = dirname(__FILE__);
  5. $pool1_abspath_1 = str_replace('wp-content/plugins/pool-one-wp-plugin', '', $pool1_abspath);
  6. $pool1_abspath_1 = str_replace('wp-content\plugins\pool-one-wp-plugin', '', $pool1_abspath_1);
  7. require_once($pool1_abspath_1 .'wp-config.php');
  8.  
  9. $ans = @$_GET["ans"];
  10. $res = "";
  11. global $wpdb, $wp_version;
  12. $pool1_que_css = "<div class='pool-question'>##QUESTION##</div>";
  13. $pool1_ans_css = "<div class='pool-answer'>##ANSWER## <span class='pool-result'>(##RES##)</span></div>";
  14.  
  15. $cSql = "select poolq_id, poolq_question from ". POOLONETABLEQ ." where poolq_id in (select poolq_id from ". POOLONETABLEA . " where poola_id =" . $ans . ") limit 0,1;";
  16. $res = $res . '<span id="pool1_msg"></span>';
  17. $pool_question = $wpdb->get_results($cSql);
  18. if ( !empty($pool_question) )
  19. {
  20.     $sql = "update ". POOLONETABLEA . " set poola_vote = poola_vote+1 where poola_id = " . $ans;
  21.     $wpdb->get_results($sql);
  22.    
  23.     foreach ( $pool_question as $question )
  24.     {
  25.         $poolq_id = $question->poolq_id;
  26.         $poolq_question = $question->poolq_question;
  27.         // setcookie
  28.         setcookie("POLLONE-".$poolq_id, 1, time() + 30000000, COOKIEPATH);
  29.         // setcookie
  30.         $poolq_question = str_replace( "##QUESTION##" , $poolq_question, $pool1_que_css);
  31.         $res = $res . $poolq_question;
  32.         $sSql = "select poola_id, poola_answer, poola_vote from ". POOLONETABLEA ." where 1=1 and poolq_id = ". $poolq_id;
  33.         $pool_answer = $wpdb->get_results($sSql);
  34.         if ( ! empty($pool_answer) )
  35.         {
  36.             foreach ( $pool_answer as $answer )
  37.             {
  38.                 $poola_id = $answer->poola_id;
  39.                 $poola_answer = stripslashes($answer->poola_answer);
  40.                 $poola_vote = $answer->poola_vote;
  41.                 $poola_answer = str_replace( "##ANSWER##" , $poola_answer, $pool1_ans_css);
  42.                 $poola_answer = str_replace( "##RES##" , $poola_vote, $poola_answer);
  43.                 $res = $res . $poola_answer;
  44.             }
  45.         }
  46.     }
  47.     $res = $res . "<div style='padding-top:20px;'></div>";
  48.     echo $res;
  49. }
  50. else
  51. {
  52.     echo "exs";
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement