query("INSERT INTO $wpdb->pollsq VALUES (0, '$pollquestion', '$now', 0)"); if(!$addq) { $text .= "Error In Adding Poll '" . stripslashes($pollquestion) . "'"; } // Add Poll Answer $pollanswers = $_POST['pollanswer']; $poll_last_id = intval($wpdb->insert_id); foreach($pollanswers as $pollanswer) { if(get_magic_quotes_gpc()) $pollanswer = addslashes(trim($pollanswer)); else $pollanswer = trim($pollanswer); $adda = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0,$poll_last_id,'$pollanswer',0)"); if(!$adda) { $text .= "Error In Adding Poll's Answer '" . stripslashes($pollanswer) . "'"; } } if(empty($text)) { $text = "Poll '" . stripslashes($pollquestion) . "' Added Successfully"; } break; case 'Edit Poll': // Edit Poll Question $id = intval($_POST['id']); $total_votes = intval($_POST['total_votes']); if(get_magic_quotes_gpc()) $pollquestion = addslashes(trim($_POST['pollquestion'])); else $pollquestion = trim($_POST['pollquestion']); $editpollq = $wpdb->query("UPDATE $wpdb->pollsq SET question = '$pollquestion', total_votes = $total_votes WHERE id=$id;"); if(!$editpollq) { $text = "Error In Editing Poll '" . stripslashes($pollquestion) . "'"; } // Get Poll Answers ID $answers = array(); $getpollqid = $wpdb->get_results("SELECT aid FROM $wpdb->pollsa WHERE qid=$id ORDER BY answers"); if($getpollqid) { foreach($getpollqid as $answer) { $answers[] = intval($answer->aid); } foreach($answers as $answer) { if(get_magic_quotes_gpc()) $answer_text = addslashes(trim($_POST[$answer])); else $answer_text = trim($_POST[$answer]); $editpolla = $wpdb->query("UPDATE $wpdb->pollsa SET answers = '$answer_text' WHERE qid=$id AND aid=$answer"); if(!$editpolla) { $text .= "
Error In Editing Poll's Answer '" . stripslashes($answer_text) . "'"; } } } else { $text .= "
Invalid Poll '" . stripslashes($pollquestion) . "'"; } if(empty($text)) { $text = "Poll '" . stripslashes($pollquestion) . "' Edited Successfully"; } else { $text .= '

Please do not be alarmed if you see the errors. The errors occur because most likely you did not modify the values.'; } break; case 'Delete Poll': $id = intval($_POST['id']); $pollquestion = trim($_POST['poll_question']); $delete_q = $wpdb->query("DELETE FROM $wpdb->pollsq WHERE id=$id"); $delete_ans = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE qid=$id"); if(!$delete_q) { $text = "Error In Deleting Poll '" . stripslashes($pollquestion) . "' Question"; } if(!$delete_ans) { $text .= "
Error In Deleting Poll Answers For '" . stripslashes($pollquestion) . "'"; } if(empty($text)) { $text = "Poll '" . stripslashes($pollquestion) . "' Deleted Successfully"; } break; case 'Add Answer': $id = intval($_POST['id']); if(get_magic_quotes_gpc()) $answer = addslashes(trim($_POST['answer'])); else $answer = trim($_POST['answer']); $addq = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0,$id,'$answer',0)"); if(!$addq) { $text = "Error In Adding Poll Answer '" . stripslashes($answer) . "'"; } else { $text = "Poll Answer '" . stripslashes($answer) . "' Added Successfully"; } break; } } ### Determines Which Mode It Is switch($mode) { // Add A Poll case 'add': $title = 'Add Poll'; $standalone = 0; require("./admin-header.php"); if ($user_level < 5) { die('

Insufficient Level

'); } ?>

Add Poll

'; echo ""; echo ''; echo ''; } ?>
Question: Answers $i:
  
Question:
No. Of Answers:
  
Insufficient Level

'); } $poll_question = $wpdb->get_row("SELECT question, total_votes FROM $wpdb->pollsq WHERE id = $id"); $poll_answers = $wpdb->get_results("SELECT aid, answers, votes FROM $wpdb->pollsa WHERE qid = $id ORDER BY answers"); ?>

Edit Poll

\n'; echo "\n\n"; $totalvotes += $poll_answer->votes; $i++; } ?>
Question
Answers No. Of Votes
Answer $i:   "; echo "aid\" value=\"$poll_answer->answers\">   \n"; echo "aid\" onclick=\"return confirm('You Are About To Delete This Poll Answer \'$poll_answer->answers\'\\n \'Cancel\' to stop, \'OK\' to delete.')\">Delete\n"; echo '$poll_answer->votes
Total Votes : total_votes?>   
  

Add Answer

Add Answer
Insufficient Level

'); } $poll_question = $wpdb->get_row("SELECT question, total_votes FROM $wpdb->pollsq WHERE id = $id"); $poll_answers = $wpdb->get_results("SELECT aid, answers, votes FROM $wpdb->pollsa WHERE qid = $id ORDER BY answers"); $poll_question_text = stripslashes($poll_question->question); ?>

Delete Poll

\n'; echo "\n\n"; $i++; } ?>
Question
Answers No. Of Votes
Answer $i:   "; echo "$poll_answer->answers\n"; echo '$poll_answer->votes
Total Votes : total_votes?>

You Are About To Delete This Poll ''

  
Insufficient Level

'); } $poll_answer = $wpdb->get_row("SELECT votes, answers FROM $wpdb->pollsa WHERE aid=$aid AND qid=$id"); $votes = intval($poll_answer->votes); $answer = stripslashes(trim($poll_answer->answers)); $delete_ans = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE aid=$aid AND qid=$id"); $update_q = $wpdb->query("UPDATE $wpdb->pollsq SET total_votes = (total_votes-$votes) WHERE id=$id"); ?>

Delete Poll's Answer

Poll Answer '$answer' Deleted Successfully"; } else { $text = "Error In Deleting Poll Answer '$answer'"; } if($update_q) { $text .= "
Poll Question's Total Votes Updated Successfully"; } else { $text .= "
Error In Updating Poll's Total Votes"; } echo $text; ?>

Click here To Go Back To The Poll Edit Page.

Insufficient Level

'); } $polls = $wpdb->get_results("SELECT * FROM $wpdb->pollsq ORDER BY id DESC"); $total_ans = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pollsa"); $total_votes = 0; ?>

Last Action

'.$text.'
'; } ?>

Manage Polls

"; echo ""; echo ''; echo ""; echo ''; echo ""; echo ""; echo ''; $i++; $total_votes+= $poll->total_votes; } } else { echo ''; } ?>
ID Question Total Votes Date Added Action
$poll->id'; if($i == 0) { echo 'Displayed: '; } echo $poll->question.'$poll->total_votes'.date("d.m.Y", $poll->timestamp).'id\" class=\"edit\">Editid\" class=\"delete\">Delete
No Polls Found

Polls Stats

Total Polls:
Total Polls' Answers:
Total Votes Casted: