SHARE
TWEET

Untitled

a guest May 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.    
  3.     require_once 'inc/DbConnector.php';
  4.     require_once 'mssql/DbConnector.php';
  5.     ini_set ("max_execution_time", '30000');
  6.     ini_set("memory_limit", '-1');
  7.    
  8.    
  9.     $db = new DbConnector();
  10.     $MSdb = new MSSQL();
  11.    
  12.     $members = array();
  13.    
  14.     $qry = $db-> query('SELECT
  15.                         CONCAT(UCASE(MID(ime,1,1)), MID(ime, 2)) as Firstname,
  16.                         CONCAT(UCASE(MID(priimek, 1,1)), MID(priimek, 2)) as Lastname,
  17.                         naslov as Address,
  18.                         postna_stevilka as PostCode,
  19.                         email,
  20.                         FROM_UNIXTIME(birthday) as DateOfBirth,
  21.                         FROM_UNIXTIME(datump) as Registered,
  22.                         FROM_UNIXTIME(zadnjaPrijava) as LastVisit,
  23.                         uporabniskoime as Username,
  24.                         geslo as Pass,
  25.                         REPLACE(gsm, "/", "") as gsm,
  26.                         event, promotor, enabled, geslo_plaintext,facebook
  27.                         FROM uporabniki');
  28.     while($member = mysql_fetch_array($qry))
  29.     {
  30.         array_push($members, $member); 
  31.     }
  32.     foreach($members as $member)
  33.     {  
  34.         $check = $MSdb->fetchArr("SELECT * FROM Member WHERE gsm = '$member[gsm]'");
  35.        
  36.         if(!$check || (!$check && $check != null))
  37.         {
  38.             $facebook = $member['facebook'] == 'da' && $member['facebook'] != '' ? 1 : 0;
  39.            
  40.             $MSdb -> query("INSERT INTO Member (Firstname, Lastname, Address, Email, DateOfBirth, Registered, Unregistered, LastVisit, Username, Password,Gsm, Confirmed, Facebook, Active)
  41.                         VALUES('$member[Firstname]', '$member[Lastname]', '$member[Address], $member[PostCode]', '$member[email]','$member[DateOfBirth]',
  42.                         '$member[Registered]', '', '$member[LastVisit]', '$member[Username]', '$member[Pass]', '$member[gsm]', 1, $facebook, $member[enabled])");  
  43.             $memberID = $MSdb-> getScalar("SELECT id FROM Member WHERE Gsm = '$member[gsm]'");
  44.            
  45.             if($member['promotor'] && $member['event'])
  46.             {
  47.                 $promotorID = $MSdb-> getScalar("SELECT id FROM Promotors WHERE Promotor = '$member[promotor]'");
  48.                 $eventID = $MSdb-> getScalar("SELECT id FROM Events WHERE Event = '$member[event]'");
  49.                
  50.                 $MSdb-> query("INSERT INTO Promotions(MemberId, EventId, PromotorId) VALUES ('$memberID', '$eventID', '$promotorID')");
  51.  
  52.             }
  53.         }
  54.         elseif($check && ($member['geslo_plaintext'] != null && $member['geslo_plaintext']))
  55.         {
  56.             $facebook = $member['facebook'] == 'da' && $member['facebook'] != '' ? 1 : 0;
  57.             $MSdb-> query("UPDATE Member SET Password = '$member[geslo_plaintext]', Active = '$member[enabled]', Facebook = $facebook");   
  58.         }
  59.        
  60.         unset($promotorID, $eventID, $memberID, $member);
  61.         if(count($members)%500 == 0)
  62.         {
  63.             $MSdb = null;
  64.             sleep(5);
  65.             $MSdb = new MSSQL();
  66.         }
  67.     }
  68.     /*$MSdb -> query("USE MygiggPortal");
  69.     $membersOld = $MSdb -> fetchArr("SELECT fullname, '' as address, '' as email, dob, GETDATE() as registered, null as unregistered, '' as lastvisit, LOWER(REPLACE(fullname, ' ', '')) as                                     username, password, gsm, isactivated as confirmed, '' as hash, '' as facebook
  70.                                 FROM Users");*/
  71. ?>
RAW Paste Data
Top