Пример #1
0
 /**
  *
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function ecshop($cfg)
 {
     parent::integrate(array());
     $this->user_table = 'users';
     $this->field_id = 'user_id';
     $this->field_name = 'user_name';
     $this->field_pass = '******';
     $this->field_email = 'email';
     $this->field_gender = 'sex';
     $this->field_bday = 'birthday';
     $this->field_reg_date = 'reg_time';
     $this->need_sync = false;
     $this->is_ecshop = 1;
 }
Пример #2
0
 /**
  * 构造函数
  *
  * @param unknown $cfg 
  */
 public function __construct($cfg)
 {
     parent::__construct(array());
     $this->user_table = 'users';
     $this->field_id = 'user_id';
     $this->ec_salt = 'ec_salt';
     $this->field_name = 'user_name';
     $this->field_pass = '******';
     $this->field_email = 'email';
     $this->field_mobile = 'mobile_phone';
     $this->field_gender = 'sex';
     $this->field_bday = 'birthday';
     $this->field_reg_date = 'reg_time';
     $this->field_passwd_question = 'passwd_question';
     $this->need_sync = false;
     $this->is_ecshop = 1;
 }
Пример #3
0
    /**
     * 构造函数
     *
     * @access  public
     * @param
     *
     * @return void
     */
    function ucenter($cfg)
    {
        parent::integrate(array());
        $this->user_table = 'users';
        $this->field_id = 'user_id';
        $this->field_name = 'user_name';
        $this->field_pass = '******';
        $this->field_email = 'email';
        $this->field_gender = 'sex';
        $this->field_bday = 'birthday';
        $this->field_reg_date = 'reg_time';
        $this->need_sync = false;
        $this->is_ecshop = 1;

        /* 初始化UC需要常量 */
        if (!defined('UC_CONNECT') && isset($cfg['uc_id']) && isset($cfg['db_host']) && isset($cfg['db_user']) && isset($cfg['db_name']))
        {
            if(strpos($cfg['db_pre'], '`' . $cfg['db_name'] . '`') === 0)
            {
                $db_pre = $cfg['db_pre'];
            }
            else
            {
                $db_pre = '`' . $cfg['db_name'] . '`.' . $cfg['db_pre'];
            }

            define('UC_CONNECT', isset($cfg['uc_connect'])?$cfg['uc_connect']:'');
            define('UC_DBHOST', isset($cfg['db_host'])?$cfg['db_host']:'');
            define('UC_DBUSER', isset($cfg['db_user'])?$cfg['db_user']:'');
            define('UC_DBPW', isset($cfg['db_pass'])?$cfg['db_pass']:'');
            define('UC_DBNAME', isset($cfg['db_name'])?$cfg['db_name']:'');
            define('UC_DBCHARSET', isset($cfg['db_charset'])?$cfg['db_charset']:'');
            define('UC_DBTABLEPRE', $db_pre);
            define('UC_DBCONNECT', '0');
            define('UC_KEY', isset($cfg['uc_key'])?$cfg['uc_key']:'');
            define('UC_API', isset($cfg['uc_url'])?$cfg['uc_url']:'');
            define('UC_CHARSET', isset($cfg['uc_charset'])?$cfg['uc_charset']:'');
            define('UC_IP', isset($cfg['uc_ip'])?$cfg['uc_ip']:'');
            define('UC_APPID', isset($cfg['uc_id'])?$cfg['uc_id']:'');
            define('UC_PPP', '20');
        }
    }
Пример #4
0
 /**
  *  设置论坛cookie
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function set_cookie($username = "")
 {
     parent::set_cookie($username);
     if (empty($username)) {
         $time = time() - 3600;
         setcookie($this->cookie_prefix . '_data', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . '_sid', '', $time, $this->cookie_path, $this->cookie_domain);
     } else {
         if ($this->charset != 'UTF8') {
             $username = ecs_iconv('UTF8', $this->charset, $username);
         }
         $sql = "SELECT " . $this->field_id . " AS user_id, " . $this->field_name . " AS user_name, " . $this->field_email . " AS email " . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . " = '{$username}'";
         $row = $this->db->getRow($sql);
         $auto_login_key = md5($this->dss_rand() . $this->dss_rand());
         /* 向整合对象的数据表里写入cookie值 */
         $this->db->query("INSERT INTO " . $this->table('sessions_keys') . " (key_id, user_id, last_login) " . "VALUES ('" . $auto_login_key . "', '{$row['user_id']}', '" . time() . "')");
         $client_ip = !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : (!empty($HTTP_ENV_VARS['REMOTE_ADDR']) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv('REMOTE_ADDR'));
         $sql = "INSERT INTO " . $this->table('sessions') . " (session_id, session_user_id, session_start, session_time, session_ip, session_logged_in, session_admin) VALUES('{$auto_login_key}', '" . $row[$this->field_id] . "','" . time() . "','" . time() . "','" . $this->encode_ip($client_ip) . "',1, 0)";
         $this->db->query($sql);
         $sessiondata = array('autologinid' => $auto_login_key, 'userid' => $row['user_id']);
         setcookie($this->cookie_prefix . '_data', serialize($sessiondata), time() + 31536000, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . '_sid', $auto_login_key, time() + 31536000, $this->cookie_path, $this->cookie_domain);
     }
 }
Пример #5
0
 /**
  * 添加新用户的函数
  *
  * @access      public
  * @param       string      username    用户名
  * @param       string      password    登录密码
  * @param       string      email       邮件地址
  * @param       string      bday        生日
  * @param       string      gender      性别
  * @return      int         返回最新的ID
  */
 function add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date = 0, $md5password = '')
 {
     $result = parent::add_user($username, $password, $email, $gender, $bday, $reg_date, $md5password);
     if (!$result) {
         return false;
     }
     /* 更新memberdata表 */
     $sql = 'INSERT INTO ' . $this->table('memberdata') . ' (' . $this->field_id . ") " . " SELECT " . $this->field_id . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
     $this->db->query($sql);
     return true;
 }
Пример #6
0
 /**
  * 添加新用户的函数
  *
  * @access      public
  * @param       string      username    用户名
  * @param       string      password    登录密码
  * @param       string      email       邮件地址
  * @param       string      bday        生日
  * @param       string      gender      性别
  * @return      int         返回最新的ID
  */
 function add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date = 0, $md5password = '')
 {
     $result = parent::add_user($username, $password, $email, $gender, $bday, $reg_date, $md5password);
     if (!$result) {
         return false;
     }
     $user_title = $this->db->GetOne("SELECT title FROM " . $this->table('usertitle') . " ORDER BY minposts LIMIT 1");
     if ($this->charset != 'UTF8') {
         $username = ecs_iconv('UTF8', $this->charset, $username);
     }
     /* 编译密码 */
     $salt = addslashes($this->fetch_user_salt());
     /* 更新数据 */
     $sql = "UPDATE " . $this->table($this->user_table) . " SET " . $this->field_pass . " = '" . $this->compile_password(array('type' => PWD_SUF_SALT, 'password' => $password, 'salt' => $salt)) . "', " . " salt = '{$salt}', " . " ipaddress = '" . real_ip() . "', " . " usergroupid = 2, " . " usertitle = '{$user_title}' " . " WHERE " . $this->field_name . "='{$username}'";
     $this->db->query($sql);
     $sql = 'INSERT INTO ' . $this->table('userfield') . ' (' . $this->field_id . ") " . " SELECT " . $this->field_id . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
     $this->db->query($sql);
     $sql = 'INSERT INTO ' . $this->table('usertextfield') . ' (' . $this->field_id . ") " . " SELECT " . $this->field_id . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
     $this->db->query($sql);
     return true;
 }
Пример #7
0
 /**
  * 添加新用户的函数
  *
  * @access      public
  * @param       string      username    用户名
  * @param       string      password    登录密码
  * @param       string      email       邮件地址
  * @param       string      bday        生日
  * @param       string      gender      性别
  * @return      int         返回最新的ID
  */
 function add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date = 0, $md5password = '')
 {
     $result = parent::add_user($username, $password, $email, $gender, $bday, $reg_date, $md5password);
     if (!$result) {
         return false;
     }
     /* 获得默认的用户组 */
     $sql = 'SELECT groupid FROM ' . $this->table('usergroups') . ' WHERE creditshigher <= 0 AND creditslower > 0';
     $grp = $this->db->getOne($sql);
     if ($this->charset != 'UTF8') {
         $username = ecs_iconv('UTF8', $this->charset, $username);
     }
     /* 更新组id */
     $sql = "UPDATE " . $this->table($this->user_table) . " SET groupid= '{$grp}', " . " regip = '" . real_ip() . "'," . " regdate = '" . time() . "'" . " WHERE " . $this->field_name . "='{$username}'";
     $this->db->query($sql);
     /* 更新memberfields表 */
     $sql = 'INSERT INTO ' . $this->table('memberfields') . ' (' . $this->field_id . ") " . " SELECT " . $this->field_id . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
     $this->db->query($sql);
     return true;
 }
Пример #8
0
 /**
  *  设置论坛cookie
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function set_cookie($username = "")
 {
     parent::set_cookie($username);
     if (empty($username)) {
         $time = time() - 3600;
         setcookie($this->cookie_prefix . 'userid', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'username', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'password', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'userhidden', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'onlinecachetime', '', $time, $this->cookie_path, $this->cookie_domain);
     } else {
         if ($this->charset != 'UTF8') {
             $username = ecs_iconv('UTF8', $this->charset, $username);
         }
         $sql = "SELECT " . $this->field_id . " AS user_id, truepassword, userhidden " . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
         $row = $this->db->getRow($sql);
         setcookie($this->cookie_prefix . 'userid', $row['user_id'], time() + 3600 * 24 * 30, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'username', $username, time() + 3600 * 24 * 30, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'password', $row['truepassword'], time() + 3600 * 24 * 30, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'userhidden', $row['userhidden'], time() + 3600 * 24 * 30, $this->cookie_path, $this->cookie_domain);
     }
 }
Пример #9
0
 /**
  *  设置论坛cookie
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function set_cookie($username = "")
 {
     parent::set_cookie($username);
     if (empty($username)) {
         $time = time() - 3600 * 24;
         setcookie($this->cookie_prefix . 'sessionid', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'userid', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'password', '', $time, $this->cookie_path, $this->cookie_domain);
     } else {
         if ($this->charset != 'UTF8') {
             $username = ecs_iconv('UTF8', $this->charset, $username);
         }
         $sql = "SELECT " . $this->field_id . " AS user_id, salt, " . $this->field_pass . " As password " . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
         $row = $this->db->getRow($sql);
         $time = time() + 3600 * 24 * 30;
         setcookie($this->cookie_prefix . 'sessionid', '', time() - 3600 * 24, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'userid', $row['user_id'], time() + 3600 * 24 * 30, $this->cookie_path, $this->cookie_domain);
         setcookie($this->cookie_prefix . 'password', $row['password'], time() + 3600 * 24 * 30, $this->cookie_path, $this->cookie_domain);
     }
 }
Пример #10
0
 /**
  *  设置论坛cookie
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function set_cookie($username = "")
 {
     parent::set_cookie($username);
     if (empty($username)) {
         $time = time() - 3600;
         setcookie('session_id', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie('member_id', '', $time, $this->cookie_path, $this->cookie_domain);
         setcookie('pass_hash', '', $time, $this->cookie_path, $this->cookie_domain);
     } else {
         $time = time() + 3600 * 24 * 30;
         if ($this->charset != 'UTF8') {
             $username = ecs_iconv('UTF8', $this->charset, $username);
         }
         $sql = "SELECT " . $this->field_id . " AS user_id, member_login_key " . " FROM " . $this->table($this->user_table) . " WHERE " . $this->field_name . "='{$username}'";
         $row = $this->db->getRow($sql);
         if ($row) {
             setcookie('member_id', $row['user_id'], $time, $this->cookie_path, $this->cookie_domain);
             setcookie('pass_hash', $row['member_login_key'], $time, $this->cookie_path, $this->cookie_domain);
         }
     }
 }
Пример #11
0
 /**
  *
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function add_user($username, $password, $email, $gender = -1, $bday = 0, $reg_date = 0, $md5password = '')
 {
     $result = parent::add_user($username, $password, $email, $gender, $bday, $reg_date, $md5password);
     if (!$result) {
         return false;
     }
     $user_id = $this->check_user($username);
     if ($user_id > 0) {
         $sql = "REPLACE INTO " . $this->table('memberdata') . " (" . $this->field_id . ") VALUES ('{$user_id}')";
         $this->db->query($sql);
     }
     return true;
 }