| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,64 @@ |
| 1 |
+<?php |
|
| 2 |
+if(!defined("_CHARSET")) exit( );
|
|
| 3 |
+ |
|
| 4 |
+global $language, $tinyMCE, $allowed_tags; |
|
| 5 |
+$blockquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_blocks WHERE block_name = 'poll'");
|
|
| 6 |
+while($block = dbassoc($blockquery)) {
|
|
| 7 |
+ if ($block['block_variables']) |
|
| 8 |
+ {
|
|
| 9 |
+ $blocks[$block['block_name']] = unserialize($block['block_variables']); |
|
| 10 |
+ } |
|
| 11 |
+ $blocks[$block['block_name']]['title'] = $block['block_title']; |
|
| 12 |
+ $blocks[$block['block_name']]['file'] = $block['block_file']; |
|
| 13 |
+ $blocks[$block['block_name']]['status'] = $block['block_status']; |
|
| 14 |
+} |
|
| 15 |
+include("blocks/".$blocks['poll']['file']);
|
|
| 16 |
+ if(isset($_GET['delete']) && isNumber($_GET['delete'])) {
|
|
| 17 |
+ $delete = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_poll WHERE poll_id = '$_GET[delete]' LIMIT 1");
|
|
| 18 |
+ if($delete) $output .= write_message(_ACTIONSUCCESSFUL); |
|
| 19 |
+ } |
|
| 20 |
+ if(isset($_POST['close_current'])) {
|
|
| 21 |
+ $final = ""; |
|
| 22 |
+ foreach($pollopts as $num => $opt) {
|
|
| 23 |
+ if(strlen($final) > 0) $final .= "#"; |
|
| 24 |
+ $n = $num + 1; |
|
| 25 |
+ $final .= (isset($results[$n]) ? $results[$n] : "0"); |
|
| 26 |
+ } |
|
| 27 |
+ $closepoll =dbquery("UPDATE ".TABLEPREFIX."fanfiction_poll SET poll_results = '$final', poll_end = '" . time() . "' WHERE poll_id = '".$currentpoll['poll_id']."'");
|
|
| 28 |
+ if($closepoll) $emptyvotes = dbquery("TRUNCATE TABLE `".TABLEPREFIX."fanfiction_poll_votes`");
|
|
| 29 |
+ $output .= write_message(_ACTIONSUCCESSFUL); |
|
| 30 |
+ } |
|
| 31 |
+ if(isset($_POST['submit'])) {
|
|
| 32 |
+ $poll_question = escapestring(descript(stripslashes($_POST['poll_question']))); |
|
| 33 |
+ $opts = explode("\r\n", ltrim(strip_tags(preg_replace( '!<p>!iU', "\r\n", stripslashes(trim($_POST['poll_opts']))), preg_replace("!<p>!iu", "", $allowed_tags))));
|
|
| 34 |
+ $new_opts = array( ); |
|
| 35 |
+ foreach($opts as $opt) {
|
|
| 36 |
+ if(strlen(trim(preg_replace("! !", " ", $opt))) > 0) $new_opts[] = $opt;
|
|
| 37 |
+ } |
|
| 38 |
+ $new_opts = escapestring(implode("|#|", $new_opts));
|
|
| 39 |
+ $newpoll = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_poll(`poll_question`, `poll_opts`, `poll_start`) VALUES('$poll_question', '$new_opts', '" . time() . "')");
|
|
| 40 |
+ include("blocks/".$blocks['poll']['file']);
|
|
| 41 |
+ $output .= "<div style='text-align: center;'><b>"._CURRENT.":</b><br /><div class=\"tblborder\" style=\"width: 200px; margin: 0 auto; text-align: left;\">$content</div><br /></div>"; |
|
| 42 |
+ } |
|
| 43 |
+ if($currentpoll && !isset($_POST['close_current'])) {
|
|
| 44 |
+ include("blocks/".$blocks['poll']['file']);
|
|
| 45 |
+ $output .= "<div style='text-align: center;'><b>"._CURRENT.":</b><br /><div class=\"tblborder\" style=\"width: 200px; margin: 0 auto; text-align: left;\">$content</div><br /></div>"; |
|
| 46 |
+ $output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=blocks&admin=poll\" style='text-align: center;'><INPUT type=\"submit\" class=\"button\" name=\"close_current\" value=\""._CLOSEPOLL."\"></form>"; |
|
| 47 |
+ } |
|
| 48 |
+ else {
|
|
| 49 |
+ $output .= "<div style='width: 400px; margin: 1em auto; text-align: center;'><form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=blocks&admin=poll\"> |
|
| 50 |
+ <label for=\"poll_question\">"._POLLQUESTION."</label><textarea name='poll_question' cols='40' id='poll_question' rows='5'></textarea><br />"; |
|
| 51 |
+ if($tinyMCE) |
|
| 52 |
+ $output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('poll_question');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
|
|
| 53 |
+ $output .= "<label for=\"poll_opts\">"._POLLOPTS."</label><textarea name='poll_opts' id='poll_opts' class='mceNoEditor' cols='40' rows='5'></textarea><br />"; |
|
| 54 |
+ $output .= "<INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></form></div>"; |
|
| 55 |
+ } |
|
| 56 |
+ $oldpolls = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_poll WHERE poll_end != 0 ORDER BY poll_id DESC");
|
|
| 57 |
+ if(dbnumrows($oldpolls)) {
|
|
| 58 |
+ $output .= "<table class='tblborder' style='width: 400px; margin: 1em auto; text-align: center;'><tr><th>"._POLLQUESTION."</th><th>"._OPTIONS."</th></tr>"; |
|
| 59 |
+ while($poll = dbassoc($oldpolls)) {
|
|
| 60 |
+ $output .= "<tr><td class='tblborder'>".stripslashes($poll['poll_question'])."</td><td class='tblborder'><a href='admin.php?action=blocks&admin=poll&delete=".$poll['poll_id']."'>"._DELETE."</a></td></tr>"; |
|
| 61 |
+ } |
|
| 62 |
+ $output .= "</table><br />"; |
|
| 63 |
+ } |
|
| 64 |
+?> |
|
| 0 | 65 |
\ No newline at end of file |