<?php
###############################################
#  by MaZaFaKa                                #
#  ICQ: 449-559                               #
#  E-mail: Dimonnet@inbox.ru                  #
#  Menghabiskan waktu: Sekitar 2 minggu         #
#  Translate by: jogerplay #
#  Situs: http://jogerwap.net #
###############################################



if(!isset($_POST['action']))
{
echo(
"<div class='form'>\n".
"<form action='".PATH."/admin/".VERSION."/?login=".$login."&amp;pwd=".$password."&amp;mod=transitions&amp;sid=".$sid."' method='post'>\n".
"ID partai:<br />\n".
"<input type='text' name='id' maxlength='20' /><br />\n".
"Nomor:<br />\n".
"<input type='text' name='count' maxlength='5' /><br />\n".
"Tindakan:<br />\n".
"<select name='where'>\n".
"<option value='hosts-hits'>Host dan Hit</option>\n".
"<option value='hosts'>Host</option>\n".
"<option value='hits'>Hits</option>\n".
"<option value='in'>in</option>\n".
"<option value='out'>out</option>\n".
"</select><br />\n".
"<input type='hidden' name='action' value='1' />\n".
"<input type='submit' value='Menambahkan' />\n".
"</form></div><br />\n");
}
else
{
   do
   {   $id = (int) $_POST['id'];
   $int = (int) $_POST['count'];
   $where = (string) $_POST['where'];

   $where = mysql_escape_string($where);

   $error = "";

   if(empty($id)) $error .= "Anda belum mengisi kolom 'ID Partai'<br />\n";
   if(empty($int)) $error .= "Anda tidak mengisi kolom 'Jumlah'<br />\n";
   elseif($int < 1) $error .= "Nilai tidak valid di 'Jumlah'<br />\n";
   if(empty($where)) $error .= "Anda belum mengisi 'tindakan'<br />\n";
   elseif($where != "hosts" && $where != "hits" && $where != "in" && $where != "out" && $where != "hosts-hits") $error .= "Nilai tidak valid di 'Aksi'<br />\n";

      if(!empty($error))
      {
      echo($error);
      break;
      }

   $sql = mysql_query("SELECT * FROM `".USERS."` WHERE `id` = ".$id.";");

      if(mysql_affected_rows() < 1)
      {      echo("User dengan ID ".$id." tidak ditemukan dalam database !<br />\n");
      break;      }

   if($where == "hosts-hits") $sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `hosts` = (`hosts` + ".$int."), `month_hosts` = (`month_hosts` + ".$int."), `all_hosts` = (`all_hosts` + ".$int."), `hits` = (`hits` + ".$int."), `month_hits` = (`month_hits` + ".$int."), `all_hits` = (`all_hits` + ".$int.") WHERE `id` = ".$id.";");
   elseif($where == "hosts") $sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `hosts` = (`hosts` + ".$int."), `month_hosts` = (`month_hosts` + ".$int."), `all_hosts` = (`all_hosts` + ".$int.") WHERE `id` = ".$id.";");
   elseif($where == "hits") $sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `hits` = (`hits` + ".$int."), `month_hits` = (`month_hits` + ".$int."), `all_hits` = (`all_hits` + ".$int.") WHERE `id` = ".$id.";");
   elseif($where == "in") $sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `in` = (`in` + ".$int."), `all_in` = (`all_in` + ".$int.") WHERE `id` = ".$id.";");
   else $sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `out` = (`out` + ".$int."), `all_out` = (`all_out` + ".$int.") WHERE `id` = ".$id.";");

      if($sql)
      {      echo("Berhasil ditambahkan ".$int." [".$where."] di ID ".$id."!<br />\n");      }
      else
      {      echo("Kesalahan menambahkan!<br />\n");
      }
   }
   while(true === false);
}

echo(
"---<br />\n".
"<a href='".PATH."/admin/".VERSION."/?login=".$login."&amp;pwd=".$password."'>Papan pengawas</a><br />\n".
"<a href='".PATH."/?sid=".$sid."'>".NAME."</a><br />\n");

?>