예제 #1
0
 public function signup($username, $fullname, $password, $email, $sex, $year, $month, $day, $language = '')
 {
     $result = array("error" => true);
     $helper = new helper($this->db);
     if (!helper::isCorrectLogin($username)) {
         $result = array("error" => true, "error_code" => ERROR_UNKNOWN, "error_type" => 0, "error_description" => "Incorrect login");
         return $result;
     }
     if ($helper->isLoginExists($username)) {
         $result = array("error" => true, "error_code" => ERROR_LOGIN_TAKEN, "error_type" => 0, "error_description" => "Login already taken");
         return $result;
     }
     if (empty($fullname)) {
         $result = array("error" => true, "error_code" => ERROR_UNKNOWN, "error_type" => 3, "error_description" => "Empty user full name");
         return $result;
     }
     if (!helper::isCorrectPassword($password)) {
         $result = array("error" => true, "error_code" => ERROR_UNKNOWN, "error_type" => 1, "error_description" => "Incorrect password");
         return $result;
     }
     if (!helper::isCorrectEmail($email)) {
         $result = array("error" => true, "error_code" => ERROR_UNKNOWN, "error_type" => 2, "error_description" => "Wrong email");
         return $result;
     }
     if ($helper->isEmailExists($email)) {
         $result = array("error" => true, "error_code" => ERROR_EMAIL_TAKEN, "error_type" => 2, "error_description" => "User with this email is already registered");
         return $result;
     }
     if ($sex < 0 || $sex > 1) {
         $sex = 0;
     }
     $salt = helper::generateSalt(3);
     $passw_hash = md5(md5($password) . $salt);
     $currentTime = time();
     $ip_addr = helper::ip_addr();
     $accountState = ACCOUNT_STATE_ENABLED;
     $default_user_balance = DEFAULT_BALANCE;
     $stmt = $this->db->prepare("INSERT INTO users (state, login, fullname, passw, email, salt, balance, bYear, bMonth, bDay, sex, regtime, ip_addr) value (:state, :username, :fullname, :password, :email, :salt, :balance, :bYear, :bMonth, :bDay, :sex, :createAt, :ip_addr)");
     $stmt->bindParam(":state", $accountState, PDO::PARAM_INT);
     $stmt->bindParam(":username", $username, PDO::PARAM_STR);
     $stmt->bindParam(":fullname", $fullname, PDO::PARAM_STR);
     $stmt->bindParam(":password", $passw_hash, PDO::PARAM_STR);
     $stmt->bindParam(":email", $email, PDO::PARAM_STR);
     $stmt->bindParam(":salt", $salt, PDO::PARAM_STR);
     $stmt->bindParam(":balance", $default_user_balance, PDO::PARAM_INT);
     $stmt->bindParam(":bYear", $year, PDO::PARAM_INT);
     $stmt->bindParam(":bMonth", $month, PDO::PARAM_INT);
     $stmt->bindParam(":bDay", $day, PDO::PARAM_INT);
     $stmt->bindParam(":sex", $sex, PDO::PARAM_INT);
     $stmt->bindParam(":createAt", $currentTime, PDO::PARAM_INT);
     $stmt->bindParam(":ip_addr", $ip_addr, PDO::PARAM_INT);
     if ($stmt->execute()) {
         $this->setId($this->db->lastInsertId());
         $settings = new settings($this->db);
         $this->setAdmob($settings->getIntValue("admob"));
         unset($settings);
         $this->setLanguage("en");
         $result = array("error" => false, 'accountId' => $this->id, 'username' => $username, 'password' => $password, 'error_code' => ERROR_SUCCESS, 'error_description' => 'SignUp Success!');
         return $result;
     }
     return $result;
 }
예제 #2
0
/*!
 * ifsoft.co.uk engine v1.0
 *
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
if (!admin::isSession()) {
    header("Location: /admin/login.php");
}
$stats = new stats($dbo);
$settings = new settings($dbo);
$admin = new admin($dbo);
$default = $settings->getIntValue("admob");
if (isset($_GET['act'])) {
    $accessToken = isset($_GET['access_token']) ? $_GET['access_token'] : 0;
    $act = isset($_GET['act']) ? $_GET['act'] : '';
    if ($accessToken === admin::getAccessToken() && !APP_DEMO) {
        switch ($act) {
            case "global_off":
                $settings->setValue("admob", 0);
                header("Location: /admin/admob.php");
                break;
            case "global_on":
                $settings->setValue("admob", 1);
                header("Location: /admin/admob.php");
                break;
            case "on":
                $admin->setAdmobValueForAccounts(1);