Location: PHPKode > projects > ZompLog > plugins/poll/admin.php
<?php
ob_start();

include_once("../../admin/functions.php");
include("../../admin/config.php");
include("../../admin/session.php");
include("../../admin/header.php");


$user = loadUser($_SESSION['login'],$link,$table_users);
?>

<div id="submenu"><a href="../../admin/plugins.php" class="sub">plugins</a></div>


<div id="side">
<div class="title">&nbsp;</div>
<div class="box"><?php
if(!empty($messages)){
	displayErrors($messages);
}

elseif($_GET[message] && empty($messages)){
  	displayMessage($_GET[message]);
}

else{
  	echo "Show all searchengines and keywords";
}  
  
?>
</div></div>


<div id="main">
<h1>Searchengines and keywords</h1><br />

<?php
include("admin.inc.php");
$admin = new wmadmin();
if(isset($HTTP_GET_VARS['a'])) {
$a = $HTTP_GET_VARS['a'];
} else {
$a = "";
}


/**** TOEVOEGEN ****/
if($a == "toevoegen") {
if(isset($HTTP_POST_VARS['submit'])) {
$vraag = $admin->formdata($HTTP_POST_VARS['vraag']);
for($x=1; $x<=10; $x++) {
$keuze[$x] = $admin->formdata($HTTP_POST_VARS["keuze".$x]);
}
$actief = $admin->formdata($HTTP_POST_VARS['actief']);
if(empty($vraag) || empty($keuze[1]) || empty($keuze[2])) {
$admin->error(1, "toevoegen");
} else {
$datum = time();
@mysql_query("INSERT INTO $prefix"."_poll (vraag, actief, datum, keuze1, keuze2, keuze3, keuze4, keuze5, keuze6, keuze7, keuze8, keuze9, keuze10) VALUES ('$vraag', '$actief', '$datum', '".$keuze[1]."', '".$keuze[2]."', '".$keuze[3]."', '".$keuze[4]."', '".$keuze[5]."', '".$keuze[6]."', '".$keuze[7]."', '".$keuze[8]."', '".$keuze[9]."', '".$keuze[10]."')");
$admin->bericht("Poll has been added.<br>\n<a href=\"admin.php\">Back</a>", 1);
}

} else {
$admin->openform("toevoegen");
$admin->formtext("Question", "vraag", "", 200);
for($x=1; $x<=10; $x++) {
$admin->formtext("Choice ".$x, "keuze".$x, "", 50);
}
$admin->formcheckbox("Active", "actief", 1);
$admin->sluitform("Toevoegen");
}




/**** BEWERK ****/
} elseif($a == "bewerk") {
$id = $admin->formdata($HTTP_GET_VARS['id']);
if(isset($HTTP_POST_VARS['submit'])) {
$vraag = $admin->formdata($HTTP_POST_VARS['vraag']);
for($x=1; $x<=10; $x++) {
$keuze[$x] = $admin->formdata($HTTP_POST_VARS["keuze".$x]);
}
$actief = $admin->formdata($HTTP_POST_VARS['actief']);
$reset = $admin->formdata($HTTP_POST_VARS['reset']);
if(empty($vraag) || empty($keuze[1]) || empty($keuze[2])) {
$admin->error(1, "bewerk&id".$id);
} else {
@mysql_query("UPDATE $prefix"."_poll SET vraag='$vraag', actief='$actief', keuze1='".$keuze[1]."', keuze2='".$keuze[2]."', keuze3='".$keuze[3]."', keuze4='".$keuze[4]."', keuze5='".$keuze[5]."', keuze6='".$keuze[6]."', keuze7='".$keuze[7]."', keuze8='".$keuze[8]."', keuze9='".$keuze[9]."', keuze10='".$keuze[10]."' WHERE id='$id'");
if($reset == "1") {
@mysql_query("UPDATE $prefix"."_poll SET antwoord1='0', antwoord2='0', antwoord3='0', antwoord4='0', antwoord5='0', antwoord6='0', antwoord7='0', antwoord8='0', antwoord9='0', antwoord10='0', gestemd='' WHERE id='$id'");
}
$admin->bericht("Poll has been edited.<br>\n<a href=\"admin.php\">Back</a>", 1);
}

} else {
$sql = @mysql_query("SELECT * FROM $prefix"."_poll WHERE id='$id'");
$list = @mysql_fetch_assoc($sql);
$admin->openform("bewerk&id=".$id);
$admin->formtext("Question", "vraag", $list['vraag'], 200);
for($x=1; $x<=10; $x++) {
$admin->formtext("Choice ".$x, "keuze".$x, $list["keuze".$x], 50);
}
$admin->formcheckbox("Active", "actief", $list['actief']);
$admin->formcheckbox("Reset Votes", "reset", 0);
$admin->sluitform("Edit");
}




/**** VERWIJDER ****/
} elseif($a == "verwijder") {
$id = $admin->formdata($HTTP_GET_VARS['id']);
@mysql_query("DELETE FROM $prefix"."_poll WHERE id='$id'");
$admin->bericht("Poll has been deleted.<br>\n<a href=\"admin.php\">Back</a>", 1);




/**** LIJST ****/
} else {
$admin->bericht("<a href=\"admin.php?a=toevoegen\">Add poll</a><br><br>", 1);
$admin->polllist();
}
?>

</div>

<?php
include("../../admin/footer.php");
?>
Return current item: ZompLog