<?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(
"Partai ID:<br />\n".
"<input type='text' name='id".$sid."' maxlength='20' format='*N' /><br />\n".
"Nomor:<br />\n".
"<input type='text' name='int".$sid."' maxlength='5' format='*N' /><br />\n".
"Tindakan:<br />\n".
"<select name='where".$sid."'>\n".
"<option value='hosts-hits'>Host - Hits</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".
"<anchor>Menambahkan<go href='".PATH."/admin/".VERSION."/?login=".$login."&amp;pwd=".$password."&amp;mod=transitions&amp;sid=".$sid."' method='post'>\n".
"<postfield name='id' value='$(id".$sid.")' />\n".
"<postfield name='int' value='$(int".$sid.")' />\n".
"<postfield name='where' value='$(where".$sid.")' />\n".
"<postfield name='action' value='SportSoft' />\n".
"</go></anchor><br />\n");
}
else
{
   do
   {   $id = (int) $_POST['id'];
   $int = (int) $_POST['int'];
   $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."] untuk 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");

?>