".$locale['401']."";
} elseif ($status == "sn") {
$title = $locale['400'];
$message = "".$locale['402']."";
} elseif ($status == "del") {
$title = $locale['403'];
$message = "".$locale['404']."";
}
opentable($title);
echo "
".$message."
\n";
closetable();
tablebreak();
}
if (isset($_POST['save'])) {
$poll_title = stripinput($poll_title);
foreach($_POST['poll_option'] as $key => $value) {
$poll_option[$key] = stripinput($_POST['poll_option'][$key]);
}
if (isset($poll_id)) {
if (!isNum($poll_id)) fallback("polls.php");
$ended = (isset($_POST['close']) ? time() : 0);
$result = dbquery("UPDATE ".$db_prefix."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='$poll_id'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
$result = dbquery("UPDATE ".$db_prefix."polls SET poll_ended='".time()."' WHERE poll_ended='0'");
$result = dbquery("INSERT INTO ".$db_prefix."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 if (isset($_POST['delete'])) {
$result = dbquery("SELECT * FROM ".$db_prefix."polls WHERE poll_id='$poll_id'");
if (dbrows($result) != 0) $result = dbquery("DELETE FROM ".$db_prefix."polls WHERE poll_id='$poll_id'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$poll = ""; $i = 0;
$poll_title = stripinput($poll_title);
while ($i < count($_POST['poll_option'])) {
$poll_option[$i] = stripinput($_POST['poll_option'][$i]);
$poll .= " $poll_option[$i]
\n";
$i++;
}
$opt_count = (isset($_POST['opt_count']) && $_POST['opt_count'] != 10 ? count($poll_option) : $_POST['opt_count']);
opentable($locale['410']);
echo "\n";
closetable();
tablebreak();
}
$editlist = "";
$result = dbquery("SELECT * FROM ".$db_prefix."polls ORDER BY poll_id DESC");
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
$editlist .= "\n";
}
opentable($locale['420']);
echo "\n";
closetable();
tablebreak();
}
if (isset($_POST['edit'])) {
if (!isNum($poll_id)) { header("Location:polls.php"); exit; }
$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."polls WHERE poll_id='$poll_id'"));
$poll_title = $data['poll_title'];
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'];
$poll_ended = $data['poll_ended'];
}
if (isset($_POST['addoption'])) {
$poll_title = stripinput($_POST['poll_title']);
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']);
}
$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($poll_id) ? $locale['431'] : $locale['430']));
echo "\n";
closetable();
}
echo "\n";
require_once BASEDIR."footer.php";
?>