Im_YouViolateMe

cid_upload

Oct 14th, 2015
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.71 KB | None | 0 0
  1. <?php
  2. session_start();
  3. //echo $IP;
  4.  
  5. $cid = $_POST['cid'];
  6. $status = $_POST['status'];
  7. $username = $_POST['username'];
  8. $date = $_POST['date'];
  9. $votes = $_POST['votes'];
  10. $GhostsStatus = $_POST['GhostsStatus'];
  11. $GTAStatus = $_POST['GTAStatus'];
  12. $key = $_POST['leechers'];
  13. $CIDs = array();
  14. $IPs = array();
  15. $cidexists = false;
  16. $postingallowed = true;
  17.  
  18. if (notBanned())
  19. {
  20. if (canUpload())
  21. {
  22. if (strlen($cid) == 32 && $status != '' && $username != '' && $date != '' && $votes != '' && $GhostsStatus != '' && $GTAStatus != '' && $postingallowed == true)
  23. {
  24. $i = 0;
  25. $dir = 'CIDs/';
  26. if ($handle = opendir($dir)) {
  27.         while (($file = readdir($handle)) !== false){
  28.             if (!in_array($file, array('.', '..')) && !is_dir($dir.$file))
  29.                 $i++;
  30.         }
  31. }
  32.  
  33. for ($i2 = 0; $i2 < $i; $i2++)
  34. {
  35. $tempfile='CIDs/CID' . $i2 . '.txt';
  36. $tempvar=fopen($tempfile,'r');
  37. $temptext=fgets($tempvar);
  38. $string = str_replace(array("\n", "\r"), '', $temptext);
  39. array_push($CIDs, $string);
  40. fclose($tempvar);
  41. }
  42.  
  43. //$cid = str_replace(array("\n", "\r"), '', $cid);
  44.  
  45. foreach ($CIDs as $value)
  46. {
  47.     if ($value == $cid)
  48.     {
  49.     $cidexists = true;
  50.     }
  51. }
  52.  
  53. if (in_array($cid, $CIDs) == true)
  54. {
  55. echo "exists";
  56. }
  57. else
  58. {
  59. echo "CID doesnt exist";
  60. file_put_contents('CIDs/CID' . $i . '.txt', $cid . "\r\n" . $status . "\r\n" . $username . "\r\n" . $date . "\r\n" . $votes . "\r\n" . $GhostsStatus . "\r\n" . $GTAStatus);
  61. }
  62. }
  63. }
  64. }
  65. else
  66. {
  67. echo "You are not allowed to post anymore CIDs";
  68. }
  69.  
  70. function canUpload()
  71. {
  72. $conn = mysql_connect("mysql.1freehosting.com", "u386696279_table", "TGSROCKS123") or die(mysql_error()); mysql_select_db("u386696279_ips") or die(mysql_error());
  73.  
  74. $data = mysql_query("SELECT * FROM ips") or die(mysql_error());
  75.  
  76. $IP = $_SERVER['REMOTE_ADDR'];
  77. $username2 = $_POST['username'];
  78.  
  79. echo $username2;
  80.  
  81. $foundip = false;
  82.  
  83. $date_ = "";
  84. $attempts = "";
  85.  
  86. while($info = mysql_fetch_array( $data ))
  87. {
  88. $ipfromtb = $info['IP'];
  89. if ($ipfromtb == $IP)
  90. {
  91. //echo "ip found" . $ipfromtb;
  92. $attempts = $info['Attempts'];
  93. $date_ = $info['LastLogin'];
  94. $foundip = true;
  95. }
  96. else
  97. {
  98. echo "not found";
  99. }
  100. }
  101.  
  102. if ($foundip == true)
  103. {
  104. date_default_timezone_set('America/New_York');
  105. $today=date("d/m/y H:i:s");
  106. $result = mysql_query($SQL);
  107. if ($attempts < 4)
  108. {
  109. $val = $attempts + 1;
  110. $sql = "UPDATE ips SET LastUsername = '$username2', LastLogin = '$today', Attempts = '$val' WHERE IP ='$IP'";
  111. $result = mysql_query($sql, $conn);
  112. if($attempts == 3)
  113.   {
  114.      echo "start session";
  115.      $_SESSION['timeout'] = time();
  116.      return true;
  117.   }
  118. return true;
  119. }
  120. else
  121. {
  122. if ($_SESSION['timeout'] + 10 * 10 < time())
  123. {
  124. echo "reset to 0";
  125. $val = 0;
  126. $sql = "UPDATE ips SET LastUsername = '$username', LastLogin = '$today', Attempts = '$val' WHERE IP ='$IP'";
  127. $result = mysql_query($sql, $conn);
  128. session_destroy();
  129. return true;
  130. }
  131. else
  132. {
  133. echo "no attempts left";
  134. return false;
  135. }
  136. }
  137. }
  138. else
  139. {
  140. date_default_timezone_set('America/New_York');
  141. $today=date("d/m/y H:i:s");
  142. $SQL = "INSERT INTO ips (IP, Attempts, LastLogin, LastUsername) VALUES ('$IP', 0, '$today', '$username2')";
  143. $result = mysql_query($SQL);
  144. return true;
  145. }
  146. }
  147.  
  148. function notBanned()
  149. {
  150. $conn = mysql_connect("mysql.1freehosting.com", "u386696279_table", "TGSROCKS123") or die(mysql_error()); mysql_select_db("u386696279_ips") or die(mysql_error());
  151.  
  152. $data = mysql_query("SELECT * FROM banned_ips") or die(mysql_error());
  153.  
  154. $IP = $_SERVER['REMOTE_ADDR'];
  155.  
  156. $found = false;
  157.  
  158. while($info = mysql_fetch_array( $data ))
  159. {
  160. $ipfromtb = $info['IP'];
  161. if ($ipfromtb == $IP)
  162. {
  163. $found = true;
  164. }
  165. }
  166.  
  167. if ($found == true)
  168. {
  169. return false;
  170. }
  171. else
  172. {
  173. return true;
  174. }
  175.  
  176. } //end of function
  177.  
  178.  
  179. unset($CIDs);
  180. $cidexists = false;
  181. ?>
Advertisement
Add Comment
Please, Sign In to add comment