Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**************************************************
- * vZID ARTCC User Database Sync Tool *
- * Written by Michael Hodge *
- * This script runs via a cron job every 3 hours *
- * ***********************************************/
- define('IN_PHPBB', true);
- $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- include($phpbb_root_path . 'common.' . $phpEx);
- include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
- $con_joomla = mysql_connect(INFO) or die("Unable to connect to the database" .
- mysql_error());
- mysql_select_db("learntof_zidartcc") or die("Unable to select the database");
- $sql = "SELECT `username`, `name`, `email` FROM jos_users";
- $query = mysql_query($sql, $con_joomla);
- while ($row = mysql_fetch_assoc($query))
- {
- $cid = $row['username'];
- $phpbb_username = $row['name'] . " - " . $cid;
- $email = $row['email'];
- mysql_select_db("learntof_zidforum") or die("Unable to select the database");
- $sql_2 = "SELECT * FROM `phpbb_users` WHERE `username` LIKE '%" . $cid . "'";
- $query_2 = mysql_query($sql_2, $con_joomla) or die("There was an error with the query: $sql" . mysql_error());
- $num_rows = mysql_num_rows($query_2);
- $user_row = array(
- 'username' => $phpbb_username,
- 'user_password' => phpbb_hash($cid),
- 'user_email' => $email,
- 'group_id' => 2,
- 'user_timezone' => 0,
- 'user_dst' => 0,
- 'user_lang' => "en",
- 'user_type' => 0,
- 'user_actkey' => "",
- 'user_ip' => "",
- 'user_regdate' => time(),
- 'user_inactive_reason' => 0,
- 'user_inactive_time' => 0,
- );
- if ($num_rows == 0)
- {
- print_r($user_row);
- user_add($user_row) or die("Unable to complete the user_add function");
- /*******************
- * SENDS E-mail *
- * ****************/
- $to = $email;
- $from = "datm@vzidartcc.org";
- $subject = "Forum Registration - A Message from the vZID ARTCC";
- $headers = 'From:website@vzidartcc.org' . "\r\n" .
- 'Reply-To: ' . $from . "\r\n" .
- 'Content-type: text/html; charset=iso-8859-1' .
- 'X-Mailer: PHP/' . phpversion();
- $message = "This is an automated message to inform you that you have been registered for the vZID ARTCC Forums located at
- forums.vzidartcc.org. Below is your Username and Password for the forums: <br><br>
- <b>Username: " . $phpbb_username . "<br>
- Password: " . $cid . "</b><br>
- 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>";
- mail($to, $subject, $message, $headers);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement