Exemple #1
0
function b1n_doLogin($sql, &$ret_msgs, &$logging)
{
    $ret_msgs = array();
    session_unset();
    if (!b1n_getVar("page0", $page0) || !b1n_getVar("action0", $action0) || !b1n_getVar("login", $login) || !b1n_getVar("passwd", $passwd) || $page0 != "login" || $action0 != "login") {
        return false;
    }
    $query = "\n        SELECT\n            usr_id,\n            usr_name,\n            usr_start_page,\n            usr_email\n        FROM\n            view_active_usr\n        WHERE\n            usr_login = '******'\n            AND usr_passwd = '" . b1n_inBd(b1n_crypt($passwd)) . "'";
    $rs = $sql->singleQuery($query);
    if (!is_array($rs)) {
        b1n_retMsg($ret_msgs, b1n_FIZZLES, "Login incorrect");
        return false;
    }
    $user = array("usr_id" => $rs["usr_id"], "usr_name" => ucfirst(strtok($rs["usr_name"], " ")), "usr_email" => $rs["usr_email"]);
    if (!empty($rs['usr_start_page'])) {
        $aux = explode(': ', $rs['usr_start_page']);
        if (sizeof($aux)) {
            $user += array("usr_toc" => $aux[0]);
            if (isset($aux[1])) {
            }
            $user += array("usr_content" => $aux[1]);
        }
    }
    $user["permission"] = b1n_getPermissions($sql, $user["usr_id"]);
    $user["bookmark"] = b1n_getBookmarks($sql, $user["usr_id"]);
    $_SESSION["user"] = $user;
    $logging = 1;
    return true;
}
Exemple #2
0
function b1n_playerChangePasswd($data)
{
    global $sql, $lang;
    if (b1n_cmp($data['newpasswd'], $data['newpasswd2'])) {
        b1n_retMsg($lang['player_password_mismatch']);
        return false;
    }
    $query = '
    UPDATE player
    SET
      pla_passwd  = ' . b1n_inBd(b1n_crypt($data['newpasswd'])) . '
    WHERE
      pla_login   = '******'pla_login']) . ' AND
      pla_passwd  = ' . b1n_inBd(b1n_crypt($data['curpasswd']));
    if ($sql->sqlQuery($query)) {
        b1n_retMsg($lang['player_password_success'], array(), b1n_SUCCESS);
    } else {
        b1n_retMsg($lang['player_password_wrong']);
    }
}
Exemple #3
0
function b1n_permNewPlayer($login, $passwd, $email, $seccode, $master)
{
    global $sql, $lang;
    $seccode = b1n_crypt($seccode);
    if (!b1n_cmp($seccode, $_SESSION['seccode'])) {
        $msg = b1n_decrypt($seccode);
        $msg .= ' != ';
        $msg .= b1n_decrypt($_SESSION['seccode']);
        b1n_retMsg($lang['login_err_wrong_code'], array('{code}' => $msg));
        return false;
    }
    if (b1n_permCheckNewPlayer($login, $passwd, $email, $master)) {
        $query = '
      SELECT
        func_newPlayer(
          ' . b1n_inBd($login) . ',
          ' . b1n_inBd(b1n_crypt($passwd)) . ',
          ' . b1n_inBd($email) . ',
          ' . b1n_inBd($master) . ') AS ret';
        $rs = $sql->sqlSingleQuery($query);
        $rs['ret'] = b1n_checkTrue($rs['ret']);
        if ($rs['ret']) {
            b1n_retMsg($lang['unexpected']);
        }
        return $rs['ret'];
    }
    return false;
}
Exemple #4
0
    }
    // Font
    if ($txt_use_random_font) {
        $font = $txt_font_dir . b1n_arrayRand($txt_fonts);
        if (!file_exists($font)) {
            $font = $txt_font_dir . $txt_fonts[0];
        }
    } else {
        $font = $txt_font_dir . $txt_fonts[0];
    }
    // Color
    if ($txt_use_random_color) {
        $r = rand($txt_rgb_min, $txt_rgb_max);
        $g = rand($txt_rgb_min, $txt_rgb_max);
        $b = rand($txt_rgb_min, $txt_rgb_max);
        $color = imageColorAllocate($img, $r, $g, $b);
    } else {
        $color = $black;
    }
    imageTTFText($img, $txt_font_size, $angle, $position, $txt_vertical_pos, $color, $font, $c);
    $position += $txt_letter_spacing_inc;
}
// Saving string in session
$_SESSION['seccode'] = b1n_crypt(strToLower($string));
// Showing image
header('Content-type: image/jpeg');
imageJpeg($img);
imageDestroy($img);
?>
 
Exemple #5
0
function b1n_regChange($sql, &$ret_msgs, $reg_data, $reg_config, $table, $msg, $module_function = "")
{
    $rs = $sql->query("BEGIN TRANSACTION");
    if ($rs) {
        $query = "SELECT * FROM \"" . $table . "\" WHERE " . $reg_config["ID"]["db"] . " = '" . b1n_inBd($reg_data['id']) . "'";
        $update = "";
        $old_values = $sql->singleQuery($query);
        foreach ($reg_config as $t => $r) {
            $value = $reg_data[$r['reg_data']];
            $aux = "";
            // Fields
            if ($r['db'] == 'none') {
                continue;
            }
            // Values
            switch ($r['type']) {
                case "select":
                    switch ($r['extra']['seltype']) {
                        case "date":
                        case "date_check_exp":
                        case "date_check_dob":
                            $aux = b1n_formatDate($value);
                            $old_values[$r['db']] = b1n_formatDate(b1n_formatDateFromDb($old_values[$r['db']]));
                            break;
                        case "date_hour":
                            $aux = b1n_formatDateHour($value);
                            $old_values[$r['db']] = b1n_formatDateHour(b1n_formatDateHourFromDb($old_values[$r['db']]));
                            break;
                        case "hour":
                            $aux = b1n_formatHour($value);
                            $old_values[$r['db']] = b1n_formatHour(b1n_formatHourFromDb($old_values[$r['db']]));
                            break;
                        default:
                            $aux = $value;
                            break;
                    }
                    break;
                case "password":
                    if (empty($value)) {
                        // For some reason, switch counts as a loop, so we need to use 'continue(2)' instead of just 'continue'
                        continue 2;
                    }
                    $aux = b1n_crypt($value);
                    break;
                default:
                    $aux = $value;
                    break;
            }
            // Only update if the values changed ($aux != $old...)
            if ($aux != $old_values[$r['db']]) {
                if (b1n_checkFilled($aux)) {
                    $aux = $r['db'] . " = '" . b1n_inBd($aux) . "'";
                } else {
                    $aux = $r['db'] . " = NULL";
                }
                // Setting update array
                $update[] = $aux;
            }
        }
        if (is_array($update)) {
            $update = implode(", ", $update);
            $query = "UPDATE \"" . $table . "\" SET " . $update . " WHERE " . $reg_config['ID']['db'] . " = '" . b1n_inBd($reg_data['id']) . "'";
            $rs = $sql->query($query);
        } else {
            $rs = true;
        }
        if ($rs) {
            $aux = true;
            if (!empty($module_function)) {
                $reg_data['old_values'] = $old_values;
                $aux = $module_function($sql, $ret_msgs, $reg_data, $reg_config);
            }
            if ($aux) {
                b1n_retMsg($ret_msgs, b1n_SUCCESS, $msg . ' changed successfully!');
                return $sql->query('COMMIT TRANSACTION');
            }
        }
    } else {
        b1n_retMsg($ret_msgs, b1n_FIZZLES, 'Could not begin transaction.');
    }
    $sql->query('ROLLBACK TRANSACTION');
    return false;
}