| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:57:11 2008 ] | [ PHP-Update 2.7 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <? 2 extract($HTTP_POST_VARS); 3 extract($HTTP_GET_VARS); 4 extract($HTTP_COOKIE_VARS); 5 $adminsect = 1; 6 include "protection.php"; 7 if(file_exists("languages/$language.php")) include "languages/$language.php"; 8 else { 9 echo "<b>Critical error</b><br>Language file <i>$language</i> could not be found.<p>"; 10 exit; 11 } 12 if(!isset($txt_dispvotes)) $txt_dispvotes = "Display number of votes?"; 13 $pagetitle = "$sitetitle $split $title_poll"; 14 $thispagetitle = "$title_poll"; 15 if(file_exists("../code/templates/$template}_h.php") && file_exists("../code/templates/$template}_f.php")) { 16 $tempfilename = "../code/templates/$template}_h.php"; 17 $handle = fopen($tempfilename, "r"); 18 $temp = fread($handle, filesize ($tempfilename)); 19 fclose($handle); 20 include "../code/menucode.php"; 21 include "../code/parsetemplate.php"; 22 parsetemplate($temp, $menucode, $thispagetitle, $pagetitle); 23 if($rights[8] == "1") { 24 echo "<b>$title_poll"; 25 26 if($a == "a") { 27 echo " $split $txt_addnew</b><br><img src=\"../gfx/blank.gif\" width=1 height=6><br>"; 28 29 if(isset($newopt[1])) { 30 31 $query = mysql_query("SELECT * FROM $table_prefix}polls ORDER BY pollno DESC"); 32 $pollno = mysql_result($query, 0, "pollno") + 1; 33 34 $table_def = "'', '$pollno', "; 35 for($i = 1; $i <= 20; $i++) $table_def .= "'$newopt[$i]', "; 36 for($i = 1; $i <= 20; $i++) $table_def .= "'0', "; 37 $table_def .= "'$newquestion', '$log', '$dispv'"; 38 if(!mysql_query("INSERT INTO $table_prefix}polls VALUES($table_def)")) $err = 1; 39 40 if($err == 1) echo "<b>$txt_error</b><br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_noaccess<br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_home"; 41 else echo "$txt_pollsaved<br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_home"; 42 43 } 44 else { 45 echo "<table border=0 cellspacing=1 cellpadding=2><form method=post action=poll.php?a=a><input type=hidden name=log value=\"$log\"><input type=hidden name=dispv value=\"$dispv\"> 46 <tr><td align=right>$txt_question:</td><td><input type=text name=newquestion value=\"$question\"></td></tr> 47 <tr><td align=right valign=top>$txt_options:</td><td>"; 48 for($i = 1; $i <= $n; $i++) echo "<input type=text name=newopt[$i]><br>"; 49 echo "</td></tr> 50 <tr><td colspan=2 align=center><input type=submit value=\"$txt_save\"></td></tr> 51 </form></table>"; 52 } 53 54 } 55 elseif($a == "p") { 56 echo " $split $txt_viewprev</b><br><img src=\"../gfx/blank.gif\" width=1 height=6><br>"; 57 58 $query = mysql_query("SELECT * FROM $table_prefix}polls ORDER BY pollno DESC"); 59 60 for($j = 1; $j < mysql_num_rows($query); $j++) { 61 $question = mysql_result($query, $j, "pollq"); 62 echo "<i>$question</i><br> 63 <table border=0 cellspacing=3 cellpadding=0>"; 64 for($i = 1; $i <= 20; $i++) { 65 if(mysql_result($query, $j, "pollopt$i") != "") $answers++; 66 } 67 for($i = 1; $i <= $answers; $i++) { 68 $opt[$i] = mysql_result($query, $j, "pollopt$i"); 69 $ans[$i] = mysql_result($query, $j, "pollans$i"); 70 $tot = $tot + $ans[$i]; 71 } 72 for($i = 1; $i <= $answers; $i++) { 73 if($tot != "0") $per[$i] = ($ans[$i]/$tot) * 100; 74 else $per[$i] = 0; 75 $per[$i] = round($per[$i]); 76 $leftper[$i] = 100 - $per[$i]; 77 78 echo "<tr><td width=30%>$opt[$i]</td><td width=50%><table width=100% height=10><tr><td width=$per[$i]% height=100% class=header><img src=\"../gfx/blank.gif\"><br></td><td width=$leftper[$i]% height=100%><img src=\"../gfx/blank.gif\"><br></td></tr></table></td><td width=20%>$per[$i]% <i>($ans[$i])</i></td></tr>"; 79 } 80 echo "</table>"; 81 } 82 83 } 84 elseif($a == "e") { 85 echo " $split $txt_editpoll</b><br><img src=\"../gfx/blank.gif\" width=1 height=6><br>"; 86 if(isset($newquestion)) { 87 88 $query = mysql_query("SELECT * FROM $table_prefix}polls ORDER BY pollno DESC"); 89 $pollno = mysql_result($query, 0, "pollno"); 90 for($i = 1; $i <= 20; $i++) $pollans[$i] = mysql_result($query, 0, "pollans$i"); 91 92 $table_def = "'', '$pollno', "; 93 for($i = 1; $i <= 20; $i++) $table_def .= "'$newopt[$i]', "; 94 for($i = 1; $i <= 20; $i++) $table_def .= "'$pollans[$i]', "; 95 96 $table_def .= "'$newquestion', '$newlog', '$newdispv'"; 97 if(!mysql_query("REPLACE INTO $table_prefix}polls VALUES($table_def)")) $err = 1; 98 99 if($err == 1) echo "<b>$txt_error</b><br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_noaccess<br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_home"; 100 else echo "$txt_pollsaved<br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_home"; 101 102 } 103 else { 104 $query = mysql_query("SELECT * FROM $table_prefix}polls ORDER BY pollno DESC"); 105 $log = mysql_result($query, 0, "polllog"); 106 $dispv = mysql_result($query, 0, "dispv"); 107 $question = mysql_result($query, 0, "pollq"); 108 $question = str_replace("\"", """, $question); 109 $question = str_replace("<", "<", $question); 110 $question = str_replace(">", ">", $question); 111 112 echo "<table border=0 cellspacing=1 cellpadding=2><form method=post action=poll.php?a=e><input type=hidden name=origlog value=\"$log\"> 113 <tr><td align=right>$txt_question:</td><td><input type=text name=newquestion value=\"$question\"></td></tr> 114 <tr><td align=right valign=top>$txt_options:</td><td>"; 115 for($i = 1; $i <= 20; $i++) { 116 if(mysql_result($query, 0, "pollopt$i") != "") $answers++; 117 } 118 for($i = 1; $i <= $answers; $i++) { 119 $opt[$i] = mysql_result($query, 0, "pollopt$i"); 120 $opt[$i] = str_replace("\"", """, $opt[$i]); 121 $opt[$i] = str_replace("<", "<", $opt[$i]); 122 $opt[$i] = str_replace(">", ">", $opt[$i]); 123 echo "<input type=text name=newopt[$i] value=\"$opt[$i]\"><br>"; 124 } 125 126 for($i = (count($opt) + 1); $i <= (count($opt) + 5); $i++) { 127 echo "<input type=text name=newopt[$i]><br>"; 128 } 129 130 echo "</td></tr> 131 <tr><td align=right>$txt_logusers</td><td><input type=radio name=newlog value=\"y\""; 132 if($log == "y") echo " CHECKED"; 133 echo "> $txt_yes <input type=radio name=newlog value=\"n\""; 134 if($log == "n") echo " CHECKED"; 135 echo "> $txt_no </td></tr> 136 <tr><td align=right>$txt_dispvotes</td><td><input type=radio name=newdispv value=\"y\""; 137 if($dispv == "y") echo " CHECKED"; 138 echo "> $txt_yes <input type=radio name=newdispv value=\"n\""; 139 if($dispv == "n") echo " CHECKED"; 140 echo "> $txt_no </td></tr> 141 <tr><td colspan=2 align=center><input type=submit value=\"$txt_save\"></td></tr> 142 </form></table>"; 143 } 144 } 145 else { 146 147 echo "</b><br><img src=\"../gfx/blank.gif\" width=1 height=6><br> 148 <b>$txt_addnew</b><br> 149 <table border=0 cellspacing=1 cellpadding=2><form method=post action=poll.php?a=a><tr><td>$txt_nooptions:</td><td><select name=n>"; 150 for($i = 2; $i <= 20; $i++) echo "<option value=$i>$i</option>"; 151 echo "</select></td></tr><tr><td colspan=2>$txt_logusers <input type=radio name=log value=y CHECKED> $txt_yes <input type=radio name=log value=n> $txt_no</td></tr> 152 <tr><td colspan=2>$txt_dispvotes <input type=radio name=dispv value=y CHECKED> $txt_yes <input type=radio name=dispv value=n> $txt_no</td></tr><tr><td colspan=2><input type=submit value=\"$txt_addnew\"></td></tr></form></table><img src=\"../gfx/blank.gif\" width=1 height=6><br> 153 $txt_current:<br>"; 154 155 $query = mysql_query("SELECT * FROM $table_prefix}polls ORDER BY pollno DESC"); 156 if(mysql_num_rows($query) > 0) { 157 $question = mysql_result($query, 0, "pollq"); 158 echo "<i>$question</i><br> 159 <table border=0 cellspacing=3 cellpadding=0>"; 160 for($i = 1; $i <= 20; $i++) { 161 if(mysql_result($query, 0, "pollopt$i") != "") $answers++; 162 } 163 for($i = 1; $i <= $answers; $i++) { 164 $opt[$i] = mysql_result($query, 0, "pollopt$i"); 165 $ans[$i] = mysql_result($query, 0, "pollans$i"); 166 $tot = $tot + $ans[$i]; 167 } 168 for($i = 1; $i <= $answers; $i++) { 169 if($tot != "0") $per[$i] = ($ans[$i]/$tot) * 100; 170 else $per[$i] = 0; 171 $per[$i] = round($per[$i]); 172 $leftper[$i] = 100 - $per[$i]; 173 174 echo "<tr><td width=30%>$opt[$i]</td><td width=50%><table width=100% height=10><tr><td width=$per[$i]% height=100% class=header><img src=\"../gfx/blank.gif\"><br></td><td width=$leftper[$i]% height=100%><img src=\"../gfx/blank.gif\"><br></td></tr></table></td><td width=20%>$per[$i]% <i>($ans[$i])</i></td></tr>"; 175 } 176 echo "</table> 177 <a href=poll.php?a=e>$txt_editpoll</a>"; 178 if(mysql_num_rows($query) > 1) echo " $split <a href=poll.php?a=p>$txt_viewprev</a><br>"; 179 } 180 else { 181 echo "$txt_nopolls"; 182 } 183 184 } 185 } 186 else echo "<b>$txt_error</b><br>$txt_norights<br><img src=\"../gfx/blank.gif\" width=1 height=6><br>$txt_home<p>"; 187 $tempfilename = "../code/templates/$template}_f.php"; 188 $handle = fopen($tempfilename, "r"); 189 $temp = fread($handle, filesize ($tempfilename)); 190 fclose($handle); 191 parsetemplate($temp, $menucode, $thispagetitle, $pagetitle); 192 } 193 else echo "<b>$txt_error</b><br>$txt_tempnofound<p>"; 194 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |