| // | Plugin description : | // | Ce plugin permet l'enregistrement d'un utilisateur directement dans | // | PunBB (http://www.punbb.org) - This plugin allows to automatically | // | register a PWG user in a PunBB forum (http://www.punbb.org) | // +-----------------------------------------------------------------------+ // | This program is free software; you can redistribute it and/or modify | // | it under the terms of the GNU General Public License as published by | // | the Free Software Foundation | // | | // | This program is distributed in the hope that it will be useful, but | // | WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | // | General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. | // +-----------------------------------------------------------------------+ // ***************************************** // ** Add user to the PunBB #_users table ** // ***************************************** // Load Plugin settings from database load_conf_from_db('param like \'punbb\\_%\''); global $conf; // Password hashing method if (function_exists('sha1')) // Only in PHP 4.3.0+ { $password = sha1($_POST['password']); } else if (function_exists('mhash')) // Only if Mhash library is loaded { $password = bin2hex(mhash(MHASH_SHA1, $_POST['password'])); } else { $password = md5($_POST['password']); } $registred = time(); $registred_ip = $_SERVER['REMOTE_ADDR']; // Check wich email var is used if (defined('IN_ADMIN') and IN_ADMIN) /* This is for adding a user in admin panel */ { $mail = $_POST['email']; $query = " INSERT INTO ".$conf['punbb_prefix']."users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES('".$_POST['login']."', '".$conf['punbb_id_default_group']."', '".$password."', '".$mail."', '".$conf['punbb_email_setting']."', '".$conf['punbb_save_pass']."', '".$conf['punbb_timezone']."', '".$conf['punbb_language']."', '".$conf['punbb_style']."','".$registred."', '".$registred_ip."', '".$registred."');"; $result = pwg_query($query); } else /* This is when a user registered himself with the register form */ { $query = " INSERT INTO ".$conf['punbb_prefix']."users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES('".$_POST['login']."', '".$conf['punbb_id_default_group']."', '".$password."', '".$_POST['mail_address']."', '".$conf['punbb_email_setting']."', '".$conf['punbb_save_pass']."', '".$conf['punbb_timezone']."', '".$conf['punbb_language']."', '".$conf['punbb_style']."','".$registred."', '".$registred_ip."', '".$registred."');"; $result = pwg_query($query); } // Retrieve user ID in PunBB user table $id_user_punbb = mysql_insert_id(); // Retrieve user ID in PWG user table $user_id_pwg = get_userid($_POST['login']); // Insertion of the ID in the pwg/punbb correspondence table $query = " INSERT INTO ".PLUGIN_REGISTER_PUNBB_ID." (id_user_pwg, id_user_punbb) VALUES('".$user_id_pwg."', '".$id_user_punbb."');"; $result = pwg_query($query); ?>