Advertisement
Guest User

Untitled

a guest
May 10th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.90 KB | None | 0 0
  1. <?php
  2.  
  3. /**************************************************
  4.  *  vZID ARTCC User Database Sync Tool            *
  5.  *  Written by Michael Hodge                      *
  6.  *  This script runs via a cron job every 3 hours *
  7.  *  ***********************************************/
  8.  
  9.      
  10. define('IN_PHPBB', true);
  11. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  12. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  13. include($phpbb_root_path . 'common.' . $phpEx);
  14. include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
  15.  
  16. $con_joomla = mysql_connect(INFO) or die("Unable to connect to the database" .
  17.         mysql_error());
  18.  
  19. mysql_select_db("learntof_zidartcc") or die("Unable to select the database");        
  20.  
  21. $sql = "SELECT `username`, `name`, `email` FROM jos_users";
  22.  
  23. $query = mysql_query($sql, $con_joomla);
  24.  
  25.  
  26.  
  27. while ($row = mysql_fetch_assoc($query))
  28. {
  29.    
  30.   $cid = $row['username'];
  31.   $phpbb_username = $row['name'] . " - " . $cid;
  32.   $email = $row['email'];
  33.    
  34.  
  35.   mysql_select_db("learntof_zidforum") or die("Unable to select the database");
  36.   $sql_2 = "SELECT * FROM `phpbb_users` WHERE `username` LIKE '%" . $cid . "'";
  37.   $query_2 = mysql_query($sql_2, $con_joomla) or die("There was an error with the query: $sql" . mysql_error());
  38.   $num_rows = mysql_num_rows($query_2);
  39.    $user_row = array(
  40.    'username'         => $phpbb_username,
  41.    'user_password'         => phpbb_hash($cid),
  42.    'user_email'         => $email,
  43.    'group_id'         => 2,
  44.    'user_timezone'         => 0,
  45.    'user_dst'         => 0,
  46.    'user_lang'         => "en",
  47.    'user_type'         => 0,
  48.    'user_actkey'         => "",
  49.    'user_ip'         => "",
  50.    'user_regdate'         => time(),
  51.    'user_inactive_reason'      => 0,
  52.    'user_inactive_time'      => 0,
  53.     );
  54.  
  55.  
  56.  
  57.   if ($num_rows == 0)
  58.   {
  59.     print_r($user_row);
  60.     user_add($user_row) or die("Unable to complete the user_add function");
  61.    
  62.    
  63.     /*******************
  64.      * SENDS E-mail    *
  65.      * ****************/
  66.      
  67.      $to = $email;
  68.      $from = "datm@vzidartcc.org";
  69.      $subject =  "Forum Registration - A Message from the vZID ARTCC";
  70.      $headers = 'From:website@vzidartcc.org' . "\r\n" .
  71.  
  72.     'Reply-To: ' . $from . "\r\n" .
  73.  
  74.     'Content-type: text/html; charset=iso-8859-1' .
  75.  
  76.     'X-Mailer: PHP/' . phpversion();
  77.    
  78.     $message = "This is an automated message to inform you that you have been registered for the vZID ARTCC Forums located at
  79.    forums.vzidartcc.org. Below is your Username and Password for the forums: <br><br>
  80.    
  81.    <b>Username: " . $phpbb_username . "<br>
  82.       Password: " . $cid . "</b><br>
  83.      
  84.       If you have any questions, please reply to this e-mail and our Deputy Air Traffic Manager will get back with you shortly. <br><br>";
  85.        
  86.     mail($to, $subject, $message, $headers);  
  87.  
  88.  
  89.              
  90.   }
  91.  
  92.  
  93. }
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement