Beispiel #1
0
function mybb_sync_db($username, $password_md5)
{
    global $db, $main;
    // Synchronize 2 databases
    // Banned groups
    $banned_usergroups = array(5, 7);
    // Table prefix
    $table_prefix = "wnagr_mybb.mybb_";
    // Get MyBB User info
    $query = $db->query("SELECT username,usergroup,email FROM {$table_prefix}users WHERE username='******'");
    $data = mysql_fetch_assoc($query);
    // Find pre-existing user on WiND database
    $query = $db->query("SELECT id FROM `users` WHERE `username` = '{$data['username']}'");
    $localinfo = mysql_fetch_assoc($query);
    // If not exists, then update the query
    if (!$localinfo) {
        // Elseways, insert a new entry
        $code = generate_account_code();
        $query = $db->query("INSERT INTO `users`\n\t\t\t(`username`, `password`, `surname`, `name`, `phone`, `email`, `info`, `account_code`, `status`) VALUES\n\t\t\t('{$data['username']}', '{$password_md5}', '', '', '', '{$data['email']}', '', '{$code}', 'activated')\n\t\t");
        $main->userdata->logged = true;
    } else {
        $query = $db->query("UPDATE `users` SET\n\t\t\t`username` = '{$data['username']}',\n\t\t\t`password` = '{$password_md5}',\n\t\t\t`email` = '{$data['email']}',\n\t\t\t`status` = 'activated'\n\t\t\tWHERE `id` = {$localinfo['id']}\n\t\t");
    }
    // wavesoft: hotspot sync
    //include_once "/home/wnagr/public_html/radcp/scripts/lib.hotspotfunc.php";
    // wavesoft; Sync User/Password
    //sync_user_pwd($username, $password_md5); -wrong pass -> to metafero sto forum
}
Beispiel #2
0
 function output_onpost_form_change_password()
 {
     global $main, $db;
     if ($db->cnt('', 'users', "account_code IS NOT NULL AND account_code = '" . get('account_code') . "' AND id = '" . get('user') . "'") == 1) {
         if ($_POST['users__password'] == $_POST['users__password_c'] && $_POST['users__password'] != '') {
             $ret = $db->set('users', array("status" => "activated", "account_code" => generate_account_code(), "password" => md5($_POST['users__password'])), "id = '" . get('user') . "'");
             if ($ret) {
                 $main->message->set_fromlang('info', 'password_restored', self_ref());
             } else {
                 $main->message->set_fromlang('error', 'generic');
             }
         } else {
             $main->message->set_fromlang('error', 'password_not_match');
         }
     } else {
         $main->message->set_fromlang('error', 'generic');
     }
 }
Beispiel #3
0
 function output_onpost_form_user()
 {
     global $main, $db, $vars, $lang;
     if ($_POST['users__password'] != $_POST['users__password_c']) {
         $main->message->set_fromlang('error', 'password_not_match');
         return;
     }
     if ($_POST['users__password'] == '' && get('user') != 'add') {
         unset($_POST['users__password']);
     } else {
         if ($_POST['users__password'] == '') {
             $main->message->set_fromlang('error', 'password_not_valid');
             return;
         }
         $_POST['users__password'] = md5($_POST['users__password']);
     }
     if (get('user') != 'add') {
         $v_old = $db->get('email', 'users', "id = '" . get('user') . "'");
     }
     $ret = TRUE;
     $form_user = $this->form_user();
     array_splice($form_user->data, 2, 1);
     if ($_POST['users__password'] == '') {
         array_splice($form_user->data, 1, 1);
     }
     if (get('user') == 'add') {
         $a['status'] = 'pending';
         $a['account_code'] = generate_account_code();
     }
     $ret = $form_user->db_set($a, "users", "id", get('user'));
     if (get('user') == 'add') {
         $ins_id = $db->insert_id;
     } else {
         $ins_id = get('user');
         $a['account_code'] = generate_account_code();
     }
     if ($ret && $main->userdata->privileges['admin'] === TRUE) {
         $ret = $form_user->db_set_multi(array(), "rights", "user_id", get('user'));
         $ret = $ret && $form_user->db_set_multi(array('owner' => 'N'), "users_nodes", "user_id", $ins_id);
         $ret = $ret && $db->del('users_nodes', "user_id = '" . $ins_id . "' AND owner = 'Y'");
         foreach ((array) $_POST['node_id_owner'] as $value) {
             $ret = $ret && $db->del('users_nodes', "node_id = '" . $value . "' AND owner = 'Y'");
             $ret = $ret && $db->add('users_nodes', array("user_id" => $ins_id, "node_id" => $value, 'owner' => 'Y'));
         }
     }
     if ($ret && (get('user') == 'add' || $v_old[0]['email'] != $_POST['users__email'])) {
         if (get('user') == 'add') {
             $t = 'user_activation';
         } else {
             $t = 'user_change_email';
         }
         $subject = $lang['email'][$t]['subject'];
         $subject = str_replace('##username##', $_POST['users__username'], $subject);
         $body = $lang['email'][$t]['body'];
         $body = str_replace('##username##', $_POST['users__username'], $body);
         $body = str_replace('##act_link##', $vars['site']['url'] . "?page=users&user="******"&action=activate&account_code=" . $a['account_code'], $body);
         $ret = sendmail($_POST['users__email'], $subject, $body);
         if ($ret && (get('user') != 'add' && $v_old[0]['email'] != $_POST['users__email'])) {
             $ret = $db->set('users', array('status' => 'pending', 'account_code' => $a['account_code']), "id = '" . get('user') . "'");
         }
     }
     if ($ret) {
         $main->message->set_fromlang('info', (get('user') == 'add' ? 'signup' : 'edit') . '_success', makelink());
     } else {
         $main->message->set_fromlang('error', 'generic');
     }
 }