[7809] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | Plugin Name : Register_PunBB | |
---|
| 4 | // | Plugin Version : 1.3a | |
---|
| 5 | // | File Version : 0.3 | |
---|
| 6 | // | Plugin Version author : Eric <lucifer@infernoweb.net> | |
---|
| 7 | // | Plugin description : | |
---|
| 8 | // | Ce plugin permet l'enregistrement d'un utilisateur directement dans | |
---|
| 9 | // | PunBB (http://www.punbb.org) - This plugin allows to automatically | |
---|
| 10 | // | register a PWG user in a PunBB forum (http://www.punbb.org) | |
---|
| 11 | // +-----------------------------------------------------------------------+ |
---|
| 12 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 13 | // | it under the terms of the GNU General Public License as published by | |
---|
| 14 | // | the Free Software Foundation | |
---|
| 15 | // | | |
---|
| 16 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 17 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 18 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 19 | // | General Public License for more details. | |
---|
| 20 | // | | |
---|
| 21 | // | You should have received a copy of the GNU General Public License | |
---|
| 22 | // | along with this program; if not, write to the Free Software | |
---|
| 23 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 24 | // | USA. | |
---|
| 25 | // +-----------------------------------------------------------------------+ |
---|
| 26 | |
---|
| 27 | // ***************************************** |
---|
| 28 | // ** Add user to the PunBB #_users table ** |
---|
| 29 | // ***************************************** |
---|
| 30 | |
---|
| 31 | // Load Plugin settings from database |
---|
| 32 | load_conf_from_db('param like \'punbb\\_%\''); |
---|
| 33 | |
---|
| 34 | global $conf; |
---|
| 35 | |
---|
| 36 | // Password hashing method |
---|
| 37 | if (function_exists('sha1')) // Only in PHP 4.3.0+ |
---|
| 38 | { |
---|
| 39 | $password = sha1($_POST['password']); |
---|
| 40 | } |
---|
| 41 | else if (function_exists('mhash')) // Only if Mhash library is loaded |
---|
| 42 | { |
---|
| 43 | $password = bin2hex(mhash(MHASH_SHA1, $_POST['password'])); |
---|
| 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | $password = md5($_POST['password']); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | $registred = time(); |
---|
| 52 | $registred_ip = $_SERVER['REMOTE_ADDR']; |
---|
| 53 | // Check wich email var is used |
---|
| 54 | if (defined('IN_ADMIN') and IN_ADMIN) /* This is for adding a user in admin panel */ |
---|
| 55 | { |
---|
| 56 | $mail = $_POST['email']; |
---|
| 57 | $query = " |
---|
| 58 | INSERT INTO ".$conf['punbb_prefix']."users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) |
---|
| 59 | VALUES('".$_POST['login']."', '".$conf['punbb_id_default_group']."', |
---|
| 60 | '".$password."', '".$mail."', '".$conf['punbb_email_setting']."', |
---|
| 61 | '".$conf['punbb_save_pass']."', '".$conf['punbb_timezone']."', '".$conf['punbb_language']."', |
---|
| 62 | '".$conf['punbb_style']."','".$registred."', '".$registred_ip."', '".$registred."');"; |
---|
| 63 | $result = pwg_query($query); |
---|
| 64 | } |
---|
| 65 | else /* This is when a user registered himself with the register form */ |
---|
| 66 | { |
---|
| 67 | $query = " |
---|
| 68 | INSERT INTO ".$conf['punbb_prefix']."users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) |
---|
| 69 | VALUES('".$_POST['login']."', '".$conf['punbb_id_default_group']."', |
---|
| 70 | '".$password."', '".$_POST['mail_address']."', '".$conf['punbb_email_setting']."', |
---|
| 71 | '".$conf['punbb_save_pass']."', '".$conf['punbb_timezone']."', '".$conf['punbb_language']."', |
---|
| 72 | '".$conf['punbb_style']."','".$registred."', '".$registred_ip."', '".$registred."');"; |
---|
| 73 | $result = pwg_query($query); |
---|
| 74 | } |
---|
| 75 | // Retrieve user ID in PunBB user table |
---|
| 76 | $id_user_punbb = mysql_insert_id(); |
---|
| 77 | |
---|
| 78 | // Retrieve user ID in PWG user table |
---|
| 79 | $user_id_pwg = get_userid($_POST['login']); |
---|
| 80 | |
---|
| 81 | // Insertion of the ID in the pwg/punbb correspondence table |
---|
| 82 | $query = " |
---|
| 83 | INSERT INTO ".PLUGIN_REGISTER_PUNBB_ID." (id_user_pwg, id_user_punbb) |
---|
| 84 | VALUES('".$user_id_pwg."', '".$id_user_punbb."');"; |
---|
| 85 | $result = pwg_query($query); |
---|
| 86 | ?> |
---|