PHP-Bridge加密

时间:2015-08-05 00:02:09

标签: php wcf

我需要将刻录板桥转换为this new encryption system

class Wbb3 extends Plugin {
    private $username;
    private $password;
    private $email;
    private $db;

    public function register($username, $password, $email) {
        $this->username = $username;
        $this->password = $password;
        $this->email = $email;

        $this->db = $this->CI->load->database($this->CI->config->item('bridge'), TRUE);

        $this->process();
    }

    /**
     * Add the account
     */
    private function process() {
        $salt = $this->random_str();
        $password = $this->encryptPassword($salt);
        $now = time();
        $loginkey = $this->random_str(50);
        $ip = $this->CI->input->ip_address();

        $this->db->query("INSERT INTO `wcf1_user` (`username`, `email`, `password`, `accessToken`, `languageID`, `registrationDate`, `styleID`, `activationCode`, `registrationIpAddress`, `lastLostPasswordRequestTime`, `lostPasswordKey`, `newEmail`, `reactivationCode`, `oldUsername`, `lastUsernameChange`, `quitStarted`, `banned`, `banReason`, `rankID`, `userTitle`, `activityPoints`, `avatarID`, `gravatarFileExtension`, `disableAvatar`, `disableAvatarReason`, `lastActivityTime`, `profileHits`, `signature`, `signatureEnableSmilies`, `signatureEnableHtml`, `signatureEnableBBCodes`, `disableSignature`, `disableSignatureReason`, `userOnlineGroupID`) VALUES ('".$this->username."', '".$this->email."', '".$password."', '".$salt."', '2', '".time()."', '0', '0', '".$ip."', '0', '', '', '0', '', '0', '0', '0', null, '4', '', '0', '1', '', '0', null, '".time()."', '0', null, '1', '0', '1', '0', null, '3');");

        $this->db->select('userID');
        $this->db->where('username', $this->username);
        $res = $this->db->get('wcf1_user');
        $row = $res->row();

        $this->db->query("INSERT INTO `wcf1_user_to_group` (userID, groupID) VALUES ($row->userID, 3)");
    }

    private function encryptPassword($salt) {
        return $salt($salt($this->password, $salt), $salt);
    }

    private function random_str($max = 8) {
        $chars = explode(" ", range('a', 'z'));
        $rtn = '';
        for($i = 0; $i < $max; $i++) {
            $rtn .= str_replace('=', '', base64_encode(md5($chars[array_rand($chars)])));
        }
        return substr(str_shuffle($rtn), 0, $max);
    }
}

如何转换我的代码?

0 个答案:

没有答案