public function _initialize() { // 登录验证 $passport = service('Passport'); if (!$passport->isLogged()) { redirect(U('wap/Public/login')); } global $ts; // 站点名称 $this->_title = $ts['site']['site_name'] . ' phiên bản WAP'; $this->assign('site_name', $this->_title); // 分页 $_GET['page'] = $_POST['page'] ? intval($_POST['page']) : intval($_GET['page']); $this->_page = $_GET['page'] > 0 ? $_GET['page'] : 1; $this->assign('page', $this->_page); $this->_item_count = 20; $this->assign('item_count', $this->_item_count); // 来源类型 $this->_type_wap = 1; $this->_from_type = array('0' => '网站', '1' => '手机网页版', '2' => 'Android客户端', '3' => 'iPhone客户端'); $this->assign('from_type', $this->_from_type); // 关注状态 $this->_follow_status = array('eachfollow' => '相互关注', 'havefollow' => '已关注', 'unfollow' => '未关注'); $this->assign('follow_status', $this->_follow_status); // 当前URL $this->_self_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if (isset($_POST['key'])) { $this->_self_url .= "&key={$_POST['key']}"; $this->_self_url .= isset($_POST['user']) ? '&user=1' : '&weibo=1'; } $this->assign('self_url', $this->_self_url); // 是否为owner $_GET['uid'] = intval($_GET['uid']); $this->assign('is_owner', $_GET['uid'] == 0 || $_GET['uid'] == $ts['user']['uid'] ? '1' : '0'); // 获取新通知 $counts = X('Notify')->getCount($this->mid); $this->assign('news', $counts); Session::pause(); return; }
function countNew() { Session::pause(); exit(json_encode(X('Notify')->getCount($this->mid))); }
private function _bindPublish($type, &$result) { Session::start(); $this->_loadTypeLogin($type); $obj = new $type(); $obj->checkUser(); if (!isset(self::$validPublish[$_SESSION['open_platform_type']])) { $result['status'] = 0; $result['url'] = U('home/Public/displayAddons', array("class" => __CLASS__, 'type' => "{$type}")); $result['info'] = "授权失败"; } // 检查是否成功获取用户信息 $userinfo = $obj->userInfo(); if (!isset($userinfo['id']) || !is_string($userinfo['uname'])) { $result['status'] = 0; $result['url'] = U('home/Public/displayAddons', array("class" => __CLASS__, 'type' => "{$type}")); $result['info'] = "获取用户信息失败"; return; } $syncdata['uid'] = $this->mid; $syncdata['type_uid'] = $userinfo['id']; $syncdata['type'] = $type; $syncdata['oauth_token'] = $_SESSION[$type]['access_token']['oauth_token']; $syncdata['oauth_token_secret'] = $_SESSION[$type]['access_token']['oauth_token_secret']; $syncdata['is_sync'] = '1'; S('user_login_' . $this->mid, null); if ($info = M('login')->where("type_uid={$userinfo['id']} AND type='" . $type . "'")->find()) { // 该新浪用户已在本站存在, 将其与当前用户关联(即原用户ID失效) M('login')->where("`login_id`={$info['login_id']}")->save($syncdata); } else { // 添加同步信息 M('login')->add($syncdata); } if (isset($_SESSION['weibo_bind_target_url'])) { $result['url'] = $_SESSION['weibo_bind_target_url']; unset($_SESSION['weibo_bind_target_url']); } else { $result['url'] = U('home/User/index'); } $result['status'] = 1; $result['info'] = "绑定成功"; Session::pause(); }
/** * uploadImage * 上传图片接受处理 * @access public * @return void */ public function uploadImage() { if ($_FILES['pic']) { $config = model('AddonData')->lget('weibo_type'); $size = $config['image']['size'] ? $config['image']['size'] : 999999999; if ($_FILES['pic']['size'] > $size * 1024) { $result['boolen'] = 0; $result['message'] = "请上传小于" . $config['image']['size'] . "KB大小的图片"; exit(json_encode($result)); } $imageInfo = getimagesize($_FILES['pic']['tmp_name']); $imageType = strtolower(substr(image_type_to_extension($imageInfo[2]), 1)); if ($imageType == "jpeg") { $imageType = 'jpg'; } $config['image']['ext'] = empty($config['image']['ext']) ? "jpg;png;jpeg;gif" : $config['image']['ext']; $ext = explode(';', $config['image']['ext']); if (!in_array($imageType, $ext)) { $result['boolen'] = 0; $result['message'] = L('photo_format_error'); exit(json_encode($result)); } //执行上传操作 $savePath = $this->_getSaveTempPath(); $filename = md5($_FILES['pic']['tmp_name'] . $this->mid) . '.' . $imageType; $copyRes = @copy($_FILES['pic']['tmp_name'], $savePath . '/' . $filename); $moveUploadRes = @move_uploaded_file($_FILES['pic']['tmp_name'], $savePath . '/' . $filename); if ($copyRes || $moveUploadRes) { $result['boolen'] = 1; $result['type_data'] = 'temp/' . $filename; $result['file_name'] = $filename; $result['picurl'] = __UPLOAD__ . '/temp/' . $filename; Session::start(); $_SESSION['weibo_img_attach'][] = $savePath . '/' . $filename; Session::pause(); } else { $result['boolen'] = 0; $result['message'] = L('upload_filed'); } } else { $result['boolen'] = 0; $result['message'] = L('upload_filed'); } $result['publish_type'] = $this->typeCode; exit(json_encode($result)); }
public function __construct() { Session::pause(); parent::__construct(); }
public function no_register_do($param) { // Session::start(); $type = $param['type']; $result =& $param['res']; $config = model('AddonData')->lget('login'); if (!in_array($type, $config['open'])) { $result['status'] = 0; $result['info'] = "该同步操作管理员已关闭"; Session::pause(); return; } switch ($_REQUEST['connectMod']) { case "bind": $this->_bindaccunt($type, $result); break; case "createNew": $this->_register($type, $result); break; default: $result['status'] = 0; $result['info'] = "非法参数"; } // Session::pause(); }