function _initialize()
 {
     parent::_initialize();
     $site_options = get_site_options();
     $this->assign($site_options);
     $ucenter_syn = C("UCENTER_ENABLED");
     if ($ucenter_syn) {
         if (!isset($_SESSION["user"])) {
             if (!empty($_COOKIE['thinkcmf_auth']) && $_COOKIE['thinkcmf_auth'] != "logout") {
                 $thinkcmf_auth = sp_authcode($_COOKIE['thinkcmf_auth'], "DECODE");
                 $thinkcmf_auth = explode("\t", $thinkcmf_auth);
                 $auth_username = $thinkcmf_auth[1];
                 $users_model = M('Users');
                 $where['user_login'] = $auth_username;
                 $user = $users_model->where($where)->find();
                 if (!empty($user)) {
                     $is_login = true;
                     $_SESSION["user"] = $user;
                 }
             }
         } else {
         }
     }
     if (sp_is_user_login()) {
         $this->assign("user", sp_get_current_user());
     }
 }
    protected function _send_to_resetpass($user)
    {
        $options = get_site_options();
        //邮件标题
        $title = $options['site_name'] . "密码重置";
        $uid = $user['id'];
        $username = $user['user_login'];
        $activekey = md5($uid . time() . uniqid());
        $users_model = M("Users");
        $result = $users_model->where(array("id" => $uid))->save(array("user_activation_key" => $activekey));
        if (!$result) {
            $this->error('密码重置激活码生成失败!');
        }
        //生成激活链接
        $url = U('user/login/password_reset', array("hash" => $activekey), "", true);
        //邮件内容
        $template = <<<hello
\t\t#username#,你好!<br>
\t\t请点击或复制下面链接进行密码重置:<br>
\t\t<a href="http://#link#">http://#link#</a>
hello;
        $content = str_replace(array('http://#link#', '#username#'), array($url, $username), $template);
        $send_result = sp_send_email($user['user_email'], $title, $content);
        if ($send_result['error']) {
            $this->error('密码重置邮件发送失败!');
        }
    }
Esempio n. 3
0
 function _initialize()
 {
     parent::_initialize();
     $site_options = get_site_options();
     $this->assign($site_options);
     $ucenter_syn = C("UCENTER_ENABLED");
     if ($ucenter_syn) {
         if (!isset($_SESSION["MEMBER_id"])) {
             if (!empty($_COOKIE['thinkcmf_auth']) && $_COOKIE['thinkcmf_auth'] != "logout") {
                 $thinkcmf_auth = sp_authcode($_COOKIE['thinkcmf_auth'], "DECODE");
                 $thinkcmf_auth = explode("\t", $thinkcmf_auth);
                 $auth_username = $thinkcmf_auth[1];
                 $members_obj = M('Members');
                 $where['user_login_name'] = $auth_username;
                 $member = $members_obj->where($where)->find();
                 if (!empty($member)) {
                     $is_login = true;
                     $_SESSION["MEMBER_type"] = 'local';
                     $_SESSION["MEMBER_id"] = $member['ID'];
                     $_SESSION['MEMBER_name'] = $auth_username;
                     $_SESSION['MEMBER_status'] = $member['user_status'];
                 }
             }
         } else {
         }
     }
 }
 /**
  * swfupload 上传 
  */
 public function swfupload()
 {
     if (IS_POST) {
         //上传处理类
         $config = array('rootPath' => './' . C("UPLOADPATH"), 'savePath' => '', 'maxSize' => 11048576, 'saveName' => array('uniqid', ''), 'exts' => array('jpg', 'gif', 'png', 'jpeg', "txt", 'zip'), 'autoSub' => true);
         $upload = new \Think\Upload($config);
         //
         $info = $upload->upload();
         //开始上传
         if ($info) {
             //上传成功
             //写入附件数据库信息
             $first = array_shift($info);
             if (!empty($first['url'])) {
                 $url = $first['savepath'] . $first['url'];
             } else {
                 $url = C("TMPL_PARSE_STRING.__UPLOAD__") . $first['savepath'] . $first['savename'];
             }
             $textareaid = I('post.textareaid');
             if ('goods_photos' === $textareaid) {
                 // 商品缩略图
                 $bigimg = $first['savepath'] . $first['savename'];
                 $image = new \Think\Image();
                 $srcimg = $upload->rootPath . $bigimg;
                 $image->open($srcimg);
                 $site_options = get_site_options();
                 $image->thumb($site_options['goods_thumb_width'], $site_options['goods_thumb_height']);
                 $dirname = './' . C("UPLOADPATH_S") . $first['savepath'];
                 if (!is_dir($dirname)) {
                     mkdir($dirname);
                 }
                 $image->save($dirname . $first['savename']);
             }
             echo "1," . $url . "," . '1,' . $first['name'];
             exit;
         } else {
             //上传失败,返回错误
             exit("0," . $upload->getError());
         }
     } else {
         if (isset($_GET['file_upload_limit'])) {
             $file_upload_limit = I('get.file_upload_limit');
         } else {
             $file_upload_limit = 1;
         }
         $textareaid = I('get.textareaid');
         $this->assign('file_upload_limit', $file_upload_limit);
         $this->assign('textareaid', $textareaid);
         $this->display(':swfupload');
     }
 }
 function _initialize()
 {
     parent::_initialize();
     $site_options = get_site_options();
     $this->assign($site_options);
     $ucenter_syn = C("UCENTER_ENABLED");
     if ($ucenter_syn) {
         if (!isset($_SESSION["user"])) {
             if (!empty($_COOKIE['thinkcmf_auth']) && $_COOKIE['thinkcmf_auth'] != "logout") {
                 $thinkcmf_auth = sp_authcode($_COOKIE['thinkcmf_auth'], "DECODE");
                 $thinkcmf_auth = explode("\t", $thinkcmf_auth);
                 $auth_username = $thinkcmf_auth[1];
                 $users_model = M('Member');
                 $where['user_login'] = $auth_username;
                 $user = $users_model->where($where)->find();
                 if (!empty($user)) {
                     $is_login = true;
                     $_SESSION["user"] = $user;
                 }
             }
         } else {
         }
     }
     if (sp_is_user_login()) {
         $this->assign("user", sp_get_current_user());
     } else {
         if (isset($_COOKIE['user_login'])) {
             $users_model = M('Member');
             $where['user_login'] = $_COOKIE['user_login'];
             $user = $users_model->where($where)->find();
             //echo $_COOKIE['user_auth'];echo '<br>';echo md5($result['user_pass'].'iloveyouhmvpoint');die;
             if (md5($user['user_pass'] . 'iloveyouhmvpoint') == $_COOKIE['user_auth']) {
                 $_SESSION['user'] = $user;
             }
         }
     }
     // 热搜
     $top_hot_search = M('Ad')->where('ad_content="top_hot_search"')->limit(7)->select();
     $this->assign('top_hot_search', $top_hot_search);
     $cart = A('Order/Cart')->cart();
     $this->assign('cartNum', count($cart['cart']));
 }
Esempio n. 6
0
function sp_get_site_options()
{
    get_site_options();
}