Guest User

Untitled

a guest
Jun 27th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. /* MySQL Config */
  5. $username = "demo";
  6. $password = "demo";
  7. $database = "demo";
  8. $host = "demo";
  9.  
  10. /* Debug Config */
  11. ini_set('max_execution_time', 1800);
  12.  
  13.  
  14.  
  15. function updateStatus($status) {
  16. session_start();
  17. $_SESSION['status'] = $status;
  18. session_write_close();
  19. }
  20.  
  21. if($_GET['a'] == "import_users") {
  22. if(file_exists($_FILES['user_file']['tmp_name'])) {
  23. $filename = $_FILES['user_file']['name'];
  24. move_uploaded_file($_FILES['user_file']['tmp_name'], "./if/" . $filename);
  25. updateStatus($filename . " Uploaded");
  26. sleep(2);
  27. }
  28. else { updateStatus("Error: No File Uploaded"); }
  29.  
  30. mysql_connect($host, $username, $password) or die("<h1>Failed to establish database connection</h1>");
  31. $crows = mysql_num_rows(mysql_query("SELECT * FROM faith.users"));
  32.  
  33. updateStatus("Processing File...");
  34. $handle = file_get_contents("./if/$filename");
  35. $handle = explode("\n", $handle);
  36. $rows = count($handle);
  37.  
  38. $x = 0;
  39. // for($x = 0; $x < $rows; $x++) {
  40. while($x < $rows) {
  41. $handle[$x] = explode(",", $handle[$x]);
  42. $full_name = str_replace("\"", '', $handle[$x][1] . " " . $handle[$x][2]);
  43. $consigner_id = $handle[$x][0];
  44. $consigner_pass = hash('md5', $handle[$x][3]);
  45. $consigner_sc = str_replace("\"", '', $handle[$x][4]);
  46.  
  47. if(mysql_num_rows(mysql_query("SELECT * FROM faith.users WHERE cid = '$consigner_id'"))) {
  48. mysql_query("UPDATE faith.users SET name = '$full_name', pass = '$consigner_pass', security_key = '$consigner_sc' WHERE cid = '$consigner_id'");
  49. }
  50. else {
  51. mysql_query("INSERT INTO faith.users(`id`,`cid`,`name`,`pass`,`email`,`security_key`,`ip`,`dt`) VALUES (null, '$consigner_id', '$full_name', '$consigner_pass', null, '$consigner_sc', null, null)");
  52. }
  53.  
  54. $percent_complete = round($x/$rows * 100, 1);
  55. updateStatus("Updating Tables..." . $percent_complete . "% Complete");
  56. $x++;
  57. }
  58. }
  59.  
  60.  
  61. ?>
Add Comment
Please, Sign In to add comment