Przedszkolak
Postów: 2
Data rejestracji: 18.04.2009 14:18
|
Witam, mam prosbe, mogłby mi ktos zedytowac pliki do ankiety aby ta mogla miec np. 20 opcji? Jestem początkujacym uzytkowinikiem i nie dalem rady tego zrobic mimo iz przeczytalem wasze porady na forum.
Plik polls.php:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: polls.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../maincore.php";
require_once THEMES."templates/admin_header.php";
include LOCALE.LOCALESET."admin/polls.php";
if (!checkrights("PO") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { redirect("../index.php"); }
if (isset($_GET['poll_id']) && !isnum($_GET['poll_id'])) { redirect(FUSION_SELF); }
if (isset($_GET['status']) && !isset($message)) {
if ($_GET['status'] == "sn") {
$message = $locale['410'];
} elseif ($_GET['status'] == "su") {
$message = $locale['411'];
} elseif ($_GET['status'] == "del") {
$message = $locale['412'];
}
if ($message) { echo "<div class='admin-message'>".$message."</div>\n"; }
}
if (isset($_POST['save'])) {
$poll_title = trim(stripinput($_POST['poll_title']));
$poll_option = array();
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = trim(stripinput($_POST['poll_option'][$key]));
}
if (isset($_GET['poll_id']) && isnum($_GET['poll_id'])) {
if ($poll_title && count($poll_option)) {
$ended = (isset($_POST['close']) ? time() : 0);
$result = dbquery("UPDATE ".DB_POLLS." SET poll_title='$poll_title', poll_opt_0='$poll_option[0]', poll_opt_1='$poll_option[1]', poll_opt_2='$poll_option[2]', poll_opt_3='$poll_option[3]', poll_opt_4='$poll_option[4]', poll_opt_5='$poll_option[5]', poll_opt_6='$poll_option[6]', poll_opt_7='$poll_option[7]', poll_opt_8='$poll_option[8]', poll_opt_9='$poll_option[9]', poll_ended='$ended' WHERE poll_id='".$_GET['poll_id']."'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
redirect(FUSION_SELF.$aidlink);
}
} else {
if ($poll_title && count($poll_option)) {
$result = dbquery("UPDATE ".DB_POLLS." SET poll_ended='".time()."' WHERE poll_ended='0'");
$result = dbquery("INSERT INTO ".DB_POLLS." (poll_title, poll_opt_0, poll_opt_1, poll_opt_2, poll_opt_3, poll_opt_4, poll_opt_5, poll_opt_6, poll_opt_7, poll_opt_8, poll_opt_9, poll_started, poll_ended) VALUES ('$poll_title', '$poll_option[0]', '$poll_option[1]', '$poll_option[2]', '$poll_option[3]', '$poll_option[4]', '$poll_option[5]', '$poll_option[6]', '$poll_option[7]', '$poll_option[8]', '$poll_option[9]', '".time()."', '0')");
redirect(FUSION_SELF.$aidlink."&status=sn");
} else {
redirect(FUSION_SELF.$aidlink);
}
}
} else if (isset($_POST['delete']) && (isset($_POST['poll_id']) && isnum($_POST['poll_id']))) {
$result = dbquery("SELECT * FROM ".DB_POLLS." WHERE poll_id='".$_POST['poll_id']."'");
if (dbrows($result) != 0) $result = dbquery("DELETE FROM ".DB_POLLS." WHERE poll_id='".$_POST['poll_id']."'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$poll = ""; $i = 0;
$poll_title = stripinput($_POST['poll_title']);
while ($i < count($_POST['poll_option'])) {
$poll_option[$i] = trim(stripinput($_POST['poll_option'][$i]));
if (!$poll_option[$i]) { $poll_option[$i] = $locale['439']; }
$poll .= "<label><input type='radio' name='option[]' /> ".$poll_option[$i]."</label><br /><br />\n";
$i++;
}
$opt_count = (isset($_POST['opt_count']) && $_POST['opt_count'] != 10 ? count($poll_option) : $_POST['opt_count']);
if ($poll_title) {
opentable($locale['403']);
echo "<table cellpadding='0' cellspacing='0' width='280' class='center'>\n<tr>\n";
echo "<td class='tbl'><strong>".$poll_title."</strong><br /><br />\n".$poll."</td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' class='tbl'><input type='button' name='blank' value='".$locale['430']."' class='button' style='width:70px' /></td>\n";
echo "</tr>\n</table>\n";
closetable();
}
}
$editlist = "";
$result = dbquery("SELECT * FROM ".DB_POLLS." ORDER BY poll_id DESC");
if (dbrows($result)) {
while ($data = dbarray($result)) {
$editlist .= "<option value='".$data['poll_id']."'>".$data['poll_title']."</option>\n";
}
opentable($locale['402']);
echo "<div style='text-align:center'>\n<form name='editform' method='post' action='".FUSION_SELF.$aidlink."'>\n";
echo "<select name='poll_id' class='textbox' style='width:200px;'>\n".$editlist."</select>\n";
echo "<input type='submit' name='edit' value='".$locale['421']."' class='button' />\n";
echo "<input type='submit' name='delete' value='".$locale['422']."' class='button' />\n";
echo "</form>\n</div>\n";
closetable();
}
if (isset($_POST['edit']) && (isset($_POST['poll_id']) && isnum($_POST['poll_id']))) {
$_GET['poll_id'] = $_POST['poll_id'];
$data = dbarray(dbquery("SELECT * FROM ".DB_POLLS." WHERE poll_id='".$_POST['poll_id']."'"));
$poll_title = $data['poll_title'];
$poll_option = array();
for ($i = 0; $i <= 9; $i++) {
if ($data["poll_opt_".$i]) { $poll_option[$i] = $data["poll_opt_".$i]; }
}
$opt_count = count($poll_option);
$poll_started = $data['poll_started'];
$_GET['poll_ended'] = $data['poll_ended'];
}
if (isset($_POST['addoption'])) {
$poll_title = stripinput($_POST['poll_title']);
if (isset($_POST['poll_option']) && is_array($_POST['poll_option'])) {
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = stripinput($_POST['poll_option'][$key]);
}
$opt_count = ($_POST['opt_count'] != 10 ? count($poll_option) + 1 : $_POST['opt_count']);
} else {
$poll_option[0] = "";
$opt_count = 1;
}
}
$i = 0; $opt = 1;
$poll_title = isset($poll_title) ? $poll_title : "";
$opt_count = isset($opt_count) ? $opt_count : 2;
if (isset($poll_id)) $poll_ended = isset($poll_ended) ? $poll_ended : 0;
opentable((isset($_GET['poll_id']) ? $locale['401'] : $locale['400']));
echo "<form name='pollform' method='post' action='".FUSION_SELF.$aidlink.(isset($_GET['poll_id']) ? "&poll_id=".$_GET['poll_id']."&poll_ended=".$_GET['poll_ended'] : "")."'>\n";
echo "<table cellpadding='0' cellspacing='0' width='280' class='center'>\n<tr>\n";
echo "<td width='80' class='tbl'>".$locale['431']."</td>\n";
echo "<td class='tbl'><input type='text' name='poll_title' value='".$poll_title."' class='textbox' style='width:200px' /></td>\n";
echo "</tr>\n";
while ($i != $opt_count) {
$poll_opt = isset($poll_option[$i]) ? $poll_option[$i] : "";
echo "<tr>\n<td width='80' class='tbl'>".$locale['432']."$opt</td>\n";
echo "<td class='tbl'><input type='text' name='poll_option[".$i."]' value='".$poll_opt."' class='textbox' style='width:200px' /></td>\n</tr>\n";
$i++; $opt++;
}
echo "</table>\n";
echo "<table cellpadding='0' cellspacing='0' width='280' class='center'>\n<tr>\n";
echo "<td align='center' class='tbl'><br />\n";
if (isset($_GET['poll_id']) && !$_GET['poll_ended']) {
echo "<input type='checkbox' name='close' value='yes' />".$locale['433']."<br /><br />\n";
}
if (!isset($_GET['poll_id']) || (isset($_GET['poll_id']) && !$_GET['poll_ended'])) {
echo "<input type='hidden' name='opt_count' value='".$opt_count."' />\n";
echo "<input type='submit' name='addoption' value='".$locale['436']."' class='button' />\n";
echo "<input type='submit' name='preview' value='".$locale['437']."' class='button' />\n";
echo "<input type='submit' name='save' value='".$locale['438']."' class='button' />\n";
} else {
echo $locale['434'].showdate("shortdate", $poll_started)."<br />\n";
echo $locale['435'].showdate("shortdate", $_GET['poll_ended'])."<br />\n";
}
echo "</td>\n</tr>\n</table>\n</form>\n";
closetable();
}
require_once THEMES."templates/footer.php";
?> Kliknij i zaczekaj na załadowanie kodu ...
Plik member_poll_panel.php:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: member_poll_panel.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }
openside($locale['global_130']);
if (isset($_POST['cast_vote']) && (isset($_POST['poll_id']) && isnum($_POST['poll_id']))) {
$result = dbquery("SELECT * FROM ".DB_POLL_VOTES." WHERE vote_user='".$userdata['user_id']."' AND poll_id='".$_POST['poll_id']."'");
if (!dbrows($result)) {
if (isset($_POST['voteoption']) && isnum($_POST['voteoption'])) {
$result = dbquery("INSERT INTO ".DB_POLL_VOTES." (vote_user, vote_opt, poll_id) VALUES ('".$userdata['user_id']."', '".$_POST['voteoption']."', '".$_POST['poll_id']."')");
}
redirect(FUSION_SELF.(FUSION_QUERY ? "?".FUSION_QUERY : ""));
}
}
$result = dbquery("SELECT * FROM ".DB_POLLS." ORDER BY poll_started DESC LIMIT 1");
if (dbrows($result)) {
$data = dbarray($result);
$poll_title = $data['poll_title'];
$poll_option = array();
for ($i = 0; $i <= 9; $i++) {
if ($data["poll_opt_".$i]) $poll_option[$i] = $data["poll_opt_".$i];
}
if (iMEMBER) $result2 = dbquery("SELECT * FROM ".DB_POLL_VOTES." WHERE vote_user='".$userdata['user_id']."' AND poll_id='".$data['poll_id']."'");
if ((!iMEMBER || !dbrows($result2)) && $data['poll_ended'] == 0) {
$poll = ""; $i = 0; $num_opts = count($poll_option);
while ($i < $num_opts) {
$poll .= "<label><input type='radio' name='voteoption' value='$i' /> $poll_option[$i]</label><br /><br />\n";
$i++;
}
echo "<form name='voteform' method='post' action='".FUSION_SELF.(FUSION_QUERY ? "?".FUSION_QUERY : "")."'>\n";
echo "<strong>".$poll_title."</strong><br /><br />\n".$poll;
echo "<div style='text-align:center'><input type='hidden' name='poll_id' value='".$data['poll_id']."' />\n";
if (iMEMBER) {
echo "<input type='submit' name='cast_vote' value='".$locale['global_131']."' class='button' />";
} else {
echo $locale['global_132'];
}
echo "</div>\n</form>\n";
} else {
$poll = ""; $i = 0; $num_opts = count($poll_option);
$poll_votes = dbcount("(vote_opt)", DB_POLL_VOTES, "poll_id='".$data['poll_id']."'");
while ($i < $num_opts) {
$num_votes = dbcount("(vote_opt)", DB_POLL_VOTES, "vote_opt='$i' AND poll_id='".$data['poll_id']."'");
$opt_votes = ($poll_votes ? number_format(100 / $poll_votes * $num_votes) : 0);
$poll .= "<div>".$poll_option[$i]."</div>\n";
$poll .= "<div><img src='".get_image("pollbar")."' alt='".$poll_option[$i]."' height='12' width='".$opt_votes."' class='poll' /></div>\n";
$poll .= "<div>".$opt_votes."% [".$num_votes." ".($num_votes == 1 ? $locale['global_133'] : $locale['global_134'])."]</div><br />\n";
$i++;
}
echo "<strong>".$poll_title."</strong><br /><br />\n".$poll;
echo "<div style='text-align:center'>".$locale['global_135'].$poll_votes."<br />\n";
echo $locale['global_136'].showdate("shortdate", $data['poll_started']);
if ($data['poll_ended'] > 0) {
echo "<br />\n".$locale['global_137'].showdate("shortdate", $data['poll_ended'])."\n";
}
$result = dbquery("SELECT * FROM ".DB_POLLS);
if (dbrows($result) > 1) {
echo "<br /><br /><a href='".INFUSIONS."member_poll_panel/polls_archive.php' class='side'>".$locale['global_138']."</a>\n";
}
echo "</div>\n";
}
} else {
echo "<div style='text-align:center'>".$locale['global_142']."</div>\n";
}
closeside();
?> Kliknij i zaczekaj na załadowanie kodu ...
PW od moderatora:
- Przeniesienie tematu - hoopak 18.04 - 15:09
|