Advertisement
s00rk

GunZ [Code] Hacer Sorteos en un link [PanelSorteo.php]

Jun 27th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.06 KB | None | 0 0
  1. <?php
  2. @session_start();
  3. $AID = $_SESSION['AID'];
  4.  
  5.  
  6. $link = mssql_connect("VictorPC", "sa", "987654321");
  7. mssql_select_db("GunzDB", $link);
  8.  
  9.  
  10. if(empty($AID) || !is_numeric($AID))
  11. {
  12.     if(isset($_POST['loguearse']))
  13.     {
  14.         $query = mssql_query("SELECT a.AID FROM Account a INNER JOIN [Login] b ON a.AID = b.AID WHERE b.UserID = '".antisql($_POST['userid'])."' AND b.Password = '".antisql($_POST['pass'])."'");
  15.         if(mssql_num_rows($query))
  16.         {
  17.             $r = mssql_fetch_object($query);
  18.             $_SESSION['AID'] = $r->AID;        
  19.             echo "<script>var url = window.location.href; window.location = url;</script>";
  20.             die();
  21.         }else{
  22.             echo "<script>alert('Usuario y/o Contraseña Incorrectas!');</script>";
  23.         }      
  24.     }
  25.         ?>
  26.         <form method="post">
  27.         <fieldset>
  28.         <legend>Loguearse</legend>
  29.         <label>User: </label><input type="text" name="userid" /><br />
  30.         <label>Password: </label><input type="password" name="pass" /><br />
  31.         <input type="submit" name="loguearse" value="Loguear" />
  32.         </fieldset>
  33.         </form>
  34.         <?
  35.    
  36.     die();
  37. }
  38.  
  39. function antisql($value)
  40. {
  41.         $check = $value;
  42.  
  43.         $value = preg_replace(sql_regcase("/(from|shutdown|select|update|clan|character|indexcontent|set|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$value);
  44.         $value = trim($value);
  45.         $value = strip_tags($value);
  46.         $value = addslashes($value);
  47.         $value = str_replace("'", "''", $value);
  48.  
  49.         if( $check != $value )
  50.         {
  51.             date_default_timezone_set('America/Los_Angeles');
  52.             if(!is_dir("logs"))
  53.             {
  54.                 mkdir("logs");
  55.             }
  56.             $logf = fopen("logs/sqllog.txt", "a+");
  57.             fprintf($logf, "Date: %s - IP: %s - Código: %s, - Correto: %s\r\n", date("d-m-Y h:i:s A"), $_SERVER['REMOTE_ADDR'], $check, $value );
  58.             fclose($logf);
  59.         }
  60.  
  61.         return( $value );
  62. }
  63.  
  64. function Msg($texto)
  65. {
  66.     echo '<script type="text/javascript">
  67.         alert("'.$texto.'");
  68.         window.location = "/";
  69.         </script>';
  70.     die();
  71. }
  72.  
  73. function getpath($url) {
  74. $part1 = explode("/", $url);
  75. $count = count($part1);
  76. $count_array = $count - 1;
  77. if ($count >= 4) {
  78. if ($part1[$count_array] != '') {
  79. $path = str_replace($part1[$count_array], '', $url); }
  80. else { $path = $url; }
  81. } else {
  82. if(substr($url,-1) != '/') $url .= '/'; $path = $url; }
  83. return $path;
  84. }
  85.  
  86. function isAdmin($AID)
  87. {
  88.     $query = mssql_query("SELECT UGradeID FROM Account WHERE AID = ".$AID);
  89.     $r = mssql_fetch_object($query);
  90.     switch($r->UGradeID)
  91.     {
  92.     //Estos son los que pueden crear un sorteo!
  93.         case 255: //Admin
  94.         case 254: //Mod
  95.         case 252: //Dev
  96.             return true;
  97.         default:
  98.             return false;
  99.     }
  100. }
  101.  
  102. if(!isAdmin($AID)){
  103.     Msg("Usted no pertenece al Staff no puede acceder aqui!");
  104. }
  105.  
  106. if(isset($_POST['sorteo']))
  107. {
  108.     $tabla = $_POST['tabla'];
  109.     $columna = $_POST['columna'];
  110.     $maxusers = $_POST['MaxUsers'];
  111.     $coins = $_POST['coins'];
  112.     if(is_numeric($maxusers) && is_numeric($coins))
  113.     {
  114.         if(mssql_query("INSERT INTO Sorteo (TABLA, COLUMNA, MaxUsers, Coins) VALUES ('".antisql($tabla)."', '".antisql($columna)."', ".$maxusers.", ".$coins.")"))
  115.         {
  116.             $r = mssql_fetch_object(mssql_query("SELECT ID FROM Sorteo Order By ID DESC"));
  117.             $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
  118.             $url = getpath($url)."sorteos/sorteo.php?id=".$r->ID;
  119.             echo "Sorteo Creado Satisfactoriamente!<br />";
  120.             echo "Link para los Usuarios: ".$url;          
  121.         }else{
  122.             echo "Error al Crear el Sorteo";
  123.         }
  124.        
  125.     }
  126. }else{
  127. ?>
  128.  
  129. <form method="post">
  130. <fieldset>
  131. <legend>Crear Nuevo Sorteo!</legend>
  132.     <label>Maximo Usuarios: </label>
  133.     <input type="number" name="MaxUsers" value="50" /><br />
  134.     <label>TABLA: </label>
  135.     <select name="tabla">
  136.         <option value="Account" selected="selected">Account</option>
  137.         <option value="Login">Login</option>
  138.     </select><br />
  139.     <label>COLUMNA: </label>
  140.     <input type="text" name="columna" value="Coins" /><br />
  141.     <label>Cantidad de Coins a Dar: </label>
  142.     <input type="number" name="coins" value="100" /><br /><br />
  143.     <input type="submit" name="sorteo" value="Crear Sorteo" />
  144. </fieldset>
  145. </form>
  146.  
  147. <?
  148. }
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement