Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* MySQL Config */
- $username = "demo";
- $password = "demo";
- $database = "demo";
- $host = "demo";
- /* Debug Config */
- ini_set('max_execution_time', 1800);
- function updateStatus($status) {
- session_start();
- $_SESSION['status'] = $status;
- session_write_close();
- }
- if($_GET['a'] == "import_users") {
- if(file_exists($_FILES['user_file']['tmp_name'])) {
- $filename = $_FILES['user_file']['name'];
- move_uploaded_file($_FILES['user_file']['tmp_name'], "./if/" . $filename);
- updateStatus($filename . " Uploaded");
- sleep(2);
- }
- else { updateStatus("Error: No File Uploaded"); }
- mysql_connect($host, $username, $password) or die("<h1>Failed to establish database connection</h1>");
- $crows = mysql_num_rows(mysql_query("SELECT * FROM faith.users"));
- updateStatus("Processing File...");
- $handle = file_get_contents("./if/$filename");
- $handle = explode("\n", $handle);
- $rows = count($handle);
- $x = 0;
- // for($x = 0; $x < $rows; $x++) {
- while($x < $rows) {
- $handle[$x] = explode(",", $handle[$x]);
- $full_name = str_replace("\"", '', $handle[$x][1] . " " . $handle[$x][2]);
- $consigner_id = $handle[$x][0];
- $consigner_pass = hash('md5', $handle[$x][3]);
- $consigner_sc = str_replace("\"", '', $handle[$x][4]);
- if(mysql_num_rows(mysql_query("SELECT * FROM faith.users WHERE cid = '$consigner_id'"))) {
- mysql_query("UPDATE faith.users SET name = '$full_name', pass = '$consigner_pass', security_key = '$consigner_sc' WHERE cid = '$consigner_id'");
- }
- else {
- 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)");
- }
- $percent_complete = round($x/$rows * 100, 1);
- updateStatus("Updating Tables..." . $percent_complete . "% Complete");
- $x++;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment