Browse code

Initial uplad w/ php7 fixes

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