コード例 #1
0
ファイル: apiOauth.class.php プロジェクト: kevicki/pig
	public function webOauth($info, $scope = '', $fansInfo = '')
	{
		$now = time();
		$redirect_uri = getSelfUrl();
		$codeUrl = $this->get_code_url($info, $redirect_uri, $scope, '', $fansInfo);
		if (empty($_GET['code']) && empty($_GET['state'])) {
			header('Location: ' . $codeUrl);
			exit();
		}
		else {
			$code = $_GET['code'];

			if (!empty($code)) {
				$res = $this->get_web_access_token($info, $code);

				if (empty($res['errcode'])) {
					$data = array('access_token' => $res['access_token'], 'openid' => $res['openid']);
					return $data;
				}
				else {
					exit('授权错误,请检查公众号权限和设置');
				}
			}
		}
	}
コード例 #2
0
	public function setCount($params) {
		if ($this->_isRequest && !IS_GET) {
			return true;
		}
		$params['module'] = strtolower(GROUP_NAME);
		$params['controller'] = strtolower(MODULE_NAME);
		$params['action'] = strtolower(ACTION_NAME);
		if ('wap' == $params['module']) {
			$params['token'] = empty($_GET['token']) ? session('wap_token') : $_GET['token'];
		} else {
			$params['token'] = empty($_GET['token']) ? session('token') : $_GET['token'];
		}
		$params['token'] = empty($params['token']) ? 'alltoken' : $params['token'];;
		$params['create_time'] = array('egt', $this->_getWeekTime());
		$data = $this->where($params)->find();
		if ( 'wap' == $params['module'] && 'alltoken' != $params['token']) {
			session('last_access_url_'.$params['token'], getSelfUrl());
		}
		if ($data && 'alltoken' !== $params['token']) {
			$this->where(array('id'=>$data['id']))->setInc('count');
		} else {
			if ('alltoken' !== $params['token']) {	// 不记录没有TOKEN的页面
				$params['create_time'] = array('lt', $this->_getTime() - ($this->_deleteBeforeDay*86400));
				$this->where($params)->delete();
				$this->add($params);
			}
		}		
		if ('alltoken' !== $params['token']) {
			$params['token'] = 'alltoken';
			$params['create_time'] = array('egt', strtotime(date('Y-m-d')));
			$data = $this->where($params)->find();
			if ($data) {
				$this->where(array('id'=>$data['id']))->setInc('count');
			} else {
				$params['create_time'] = array('lt', $this->_getTime() - ($this->_deleteBeforeDay*86400));
				$this->where($params)->delete();
				$this->add($params);
			}
		}
		$this->_isRequest = true;
	}
コード例 #3
0
ファイル: bug.mod.php プロジェクト: tech-nik89/lpm4
     }
 } else {
     $issue = $db->selectOneRow('bugtracker_issues', '*', "`issueid`=" . $issueid);
     if ($issue != null) {
         if ($isallowed) {
             if (isset($_POST['sbtAssignTo'])) {
                 $db->update('bugtracker_issues', "`assignedto`=" . (int) $_POST['txtAssignTo'], "`issueid`=" . $issueid);
                 if ($issue['state'] == 0) {
                     $db->update('bugtracker_issues', "`state`=1", "`issueid`=" . $issueid);
                 }
                 if ($config->get('bug', 'send-mail') == '1') {
                     $assignedToUser = $user->getUserById((int) $_POST['txtAssignTo']);
                     $eMail->setVar('summary', $issue['summary']);
                     $eMail->setVar('project', $db->selectOne('bugtracker_projects', 'name', "`projectid`=" . $issue['projectid']));
                     $eMail->setVar('issueid', $issue['issueid']);
                     $eMail->setVar('url', getSelfUrl() . makeURL('bug', array('issueid' => $issue['issueid'])));
                     $eMail->send($lang->get('mail_notify_assignment_subject'), $lang->get('mail_notify_assignment_text'), $assignedToUser['email']);
                 }
             }
             if (isset($_POST['sbtSetState'])) {
                 $db->update('bugtracker_issues', "`state`=" . (int) $_POST['txtState'], "`issueid`=" . $issueid);
             }
             if (isset($_POST['sbtRemove'])) {
                 $db->delete('bugtracker_issues', "`issueid`=" . $issueid);
                 redirect(makeURL($mod));
             }
         }
         if (isset($_POST['sbtAddComment'])) {
             $comments->add($mod, $login->currentUserID(), $_POST['txtNewComment'], $issueid);
         }
         $smarty->assign('notes', $comments->get($mod, $issueid));
コード例 #4
0
ファイル: WechatShare.class.php プロジェクト: kevicki/pig
	public function getShareData($params)
	{
		$params["moduleName"] = (empty($params["moduleName"]) ? MODULE_NAME : $params["moduleName"]);
		$params["moduleID"] = (empty($params["moduleID"]) ? 0 : $params["moduleID"]);
		$params["imgUrl"] = (empty($params["imgUrl"]) ? "" : $params["imgUrl"]);

		if (empty($params["sendFriendLink"])) {
			$params["sendFriendLink"] = stripslashes(getSelfUrl(array("wecha_id")));
		}
		else {
			$params["sendFriendLink"] = stripslashes(getSelfUrl(array("wecha_id"), $params["sendFriendLink"]));
		}

		$params["tTitle"] = (empty($params["tTitle"]) ? "" : shareFilter($params["tTitle"]));
		$params["tContent"] = (empty($params["tContent"]) ? $params["tTitle"] : shareFilter($params["tContent"]));
		$shareData = str_replace("\/", "/", json_encode($params));
		$html = "\t\t<script type=\"text/javascript\">\r\n\t\t\t\twindow.shareData = $shareData;\r\n\t\t</script>";
		return $html;
	}
コード例 #5
0
ファイル: index.php プロジェクト: tech-nik89/lpm4
$smarty->assign('image_path', 'templates/' . $template_path . '/images');
$smarty->assign('template_path', $template_path);
// set the breadcrumbs
$smarty->assign('breadcrumbs', $breadcrumbs->get(true, 'breadcrumb_element'));
// notifications
$smarty->assign('notify', $notify->getAll());
// assign the language array
$smarty->assign('lang', $lang->getAll());
// assign core values
$c['version'] = $version;
$c['title'] = $config->get('core', 'title');
$head_path = './templates/head.html';
$h = fopen($head_path, 'r');
$c['head'] = fread($h, filesize($head_path));
fclose($h);
$c['self_url'] = getSelfUrl();
$c['print_url'] = makeURL($_GET['mod'], array_merge($_GET, array('tpl' => 'print')));
$c['language'] = $current_language;
// add meta tags
$meta = $db->selectList('meta', '*', "(`language`='' OR `language`='" . $current_language . "') AND (`domainid`=0 OR `domainid`=" . $d_id . ")");
$t = '';
foreach ($meta as $m) {
    $t .= '<meta';
    if ($m['name'] != '') {
        $t .= ' name="' . $m['name'] . '"';
    }
    if ($m['http_equiv'] != '') {
        $t .= ' http-equiv="' . $m['http_equiv'] . '"';
    }
    if ($m['content'] != '') {
        $t .= ' content="' . $m['content'] . '"';
コード例 #6
0
ファイル: WapAction.class.php プロジェクト: kevicki/pig
	protected function _initialize()
	{
		parent::_initialize();
		$this->_appid = C('appid');
		$this->_secret = C('secret');
		$this->time = 0;
		$this->token = $this->_get('token');
		if (ALI_FUWU_GROUP && (date('Y') == 2015)) {
			$fuwuuserlist = M('fuwuuser')->where(array('token' => $this->token))->select();

			foreach ($fuwuuserlist as $fuwuvo) {
				$fuwuuserinfo = M('userinfo')->where(array('token' => $this->token, 'wecha_id' => $fuwuvo['wecha_id']))->find();

				if ($fuwuuserinfo == '') {
					if ($fuwuvo['gender'] == 'M') {
						$fuwuvo['gender'] = 1;
					}
					else if ($fuwuvo['gender'] == 'F') {
						$fuwuvo['gender'] = 2;
					}
					else {
						$fuwuvo['gender'] = 0;
					}

					$add_userinfo_hb = array('token' => $this->token, 'wecha_id' => $fuwuvo['wecha_id'], 'issub' => 1, 'portrait' => $fuwuvo['avatar'], 'truename' => $fuwuvo['real_name'], 'nickname' => $fuwuvo['real_name'], 'wechaname' => $fuwuvo['real_name'], 'sex' => $fuwuvo['gender']);
					$add_userinfo_hb = array_map('nulltoblank', $add_userinfo_hb);
					$id_userinfo = M('userinfo')->add($add_userinfo_hb);
				}
				else {
					if (($fuwuuserinfo['portrait'] == '') || ($fuwuuserinfo['wechaname'] == '')) {
						if ($fuwuvo['gender'] == 'M') {
							$fuwuvo['gender'] = 1;
						}
						else if ($fuwuvo['gender'] == 'F') {
							$fuwuvo['gender'] = 2;
						}
						else {
							$fuwuvo['gender'] = 0;
						}

						$save_userinfo_hb = array('token' => $this->token, 'wecha_id' => $fuwuvo['wecha_id'], 'issub' => 1, 'portrait' => $fuwuvo['avatar'], 'truename' => $fuwuvo['real_name'], 'nickname' => $fuwuvo['real_name'], 'wechaname' => $fuwuvo['real_name'], 'sex' => $fuwuvo['gender']);
						$save_userinfo_hb = array_map('nulltoblank', $save_userinfo_hb);
						$up_userinfo = M('userinfo')->where(array('token' => $this->token, 'wecha_id' => $fuwuvo['wecha_id']))->save($save_userinfo_hb);
					}
				}
			}
		}

		if (strlen($this->token)) {
			$_SESSION['wap_token'] = $this->token;
		}

		if (!$this->token) {
			$this->token = $_SESSION['wap_token'];
		}

		if (!empty($_SESSION['wap_token'])) {
			$this->token = $_SESSION['wap_token'];
		}

		if (!$this->token && !(strpos(MODULE_NAME, 'Drp') === false)) {
			$id = $this->_get('id');

			if ($id) {
				$did = M('Distributor_store')->where(array('id' => $id))->getField('did');
				$this->token = M('Distributor')->where(array('id' => $did))->getField('token');
			}
		}

		$this->assign('token', $this->token);

		if (!$this->token) {
			exit('no token');
		}

		if ($this->token && !preg_match('/^[0-9a-zA-Z]{3,42}$/', $this->token)) {
			exit('error token');
		}

		$this->wxuser = S('wxuser_' . $this->token);
		if (!$this->wxuser || 1) {
			$this->wxuser = D('Wxuser')->where(array('token' => $this->token))->find();
			S('wxuser_' . $this->token, $this->wxuser);
		}

		$this->owxuser = $this->wxuser;
		$this->assign('wxuser', $this->wxuser);
		$this->_checkVipTime($this->wxuser);
		$fake = 0;
		if (($this->wxuser['winxintype'] != 3) && $this->_appid && $this->_secret) {
			if ($this->wxuser['oauth'] == 1) {
				if (!$this->isAgent) {
					$this->wxuser['appid'] = trim($this->_appid);
					$this->wxuser['appsecret'] = trim($this->_secret);
				}
				else {
					$this->wxuser['appid'] = $this->thisAgent['appid'];
					$this->wxuser['appsecret'] = $this->thisAgent['appsecret'];
				}
			}

			$fake = 1;
		}

		$toAuth = 0;
		if ((C('server_topdomain') == 'pigcms.cn') && (C('site_url') != 'http://demo2.pigcms.cn')) {
			$toAuth = 1;
		}
		else {
			$toAuth = $this->wxuser['oauth'];
		}

		if ((C('server_topdomain') == 'pigcms.cn') && ($this->wxuser['winxintype'] != 3)) {
			$this->wxuser['appid'] = $this->_appid;
			$this->wxuser['appsecret'] = $this->_secret;
			$this->wxuser['oauth'] = 0;
			$this->wxuser['is_domain'] = 1;
			$fake = 1;
		}

		$wexintype = $this->wxuser['winxintype'];
		$session_openid_name = 'token_openid_' . $this->token;
		$session_fakeopenid_name = 'token_fakeopenid_' . $this->token;
		$session_reopenid_name = 'token_reopenid_' . $this->token;
		$session_oauthed_name = 'token_oauthed_' . $this->token;
		$getUserInfoModules = getUserInfoModule::index();
		$getUserinfo = 0;
		if (isset($_GET['rget']) || intval($_GET['ali'])) {
			$_SESSION['otherSource'] = 1;
			$toAuth = 0;
			$this->wxuser['oauthinfo'] = 0;
		}

		if (isset($_SESSION['otherSource'])) {
			$toAuth = 0;
		}

		if ($this->wxuser['oauthinfo'] && !$_SESSION[$session_oauthed_name]) {
			if ($_SESSION[$session_openid_name]) {
				$fansInfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $_SESSION[$session_openid_name]))->find();

				if ($toAuth) {
					if (!$fansInfo || !$fansInfo['wechaname'] || !$fansInfo['portrait']) {
						unset($_SESSION[$session_openid_name]);
						$getUserinfo = 1;
					}
				}
			}
			else {
				if (isset($_SESSION[$session_reopenid_name]) && $_SESSION[$session_reopenid_name]) {
					$fansInfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $_SESSION[$session_reopenid_name]))->find();
					if (!$fansInfo || !$fansInfo['wechaname'] || !$fansInfo['portrait']) {
						unset($_SESSION[$session_openid_name]);
						unset($_SESSION[$session_reopenid_name]);
						$getUserinfo = 1;
					}
				}
				else {
					$getUserinfo = 1;
				}
			}
		}

		$this->isFuwu = 0;
		$this->isWechat = 0;
		$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);

		if (strpos($userAgent, 'alipayclient')) {
			$this->isFuwu = 1;
		}
		else if (strpos($userAgent, 'micromessenger')) {
			$this->isWechat = 1;
		}

		if (!M('Weixin_account')->where(array('type' => 1))->find()) {
			M('Wxuser')->where('1')->save(array('type' => 0));
		}

		if ($_GET['wecha_id'] && ($_GET['wecha_id'] != $_SESSION[$session_openid_name]) && (3 != $wexintype)) {
			unset($_SESSION[$session_openid_name]);
			unset($_SESSION[$session_oauthed_name]);
		}

		if ($this->isFuwu) {
			if ($_GET['wecha_id'] != '') {
				$this->wecha_id = $_GET['wecha_id'];
			}
			else {
				$this->wecha_id = session('wecha_id');
			}

			session('wecha_id', $this->wecha_id);
			$thisfuwuuser = M('fuwuuser')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
			$isFuwuoauth = session('isFuwuoauth');
		}

		if ($this->isFuwu && ($isFuwuoauth != 'yes')) {
			$fw_wecha_id = FuwuOAuth::index($this->token);

			if ($fw_wecha_id != 'no') {
				$this->wecha_id = $fw_wecha_id;
				session('wecha_id', $this->wecha_id);
				session('isFuwuoauth', 'yes');
			}
			else if ($this->wecha_id == '') {
				$this->error('服务窗没有获取粉丝信息权限<br/>请在服务窗开发者中确认开通');
				exit();
			}

			$_SESSION[$session_openid_name] = $this->wecha_id;
			$_SESSION[$session_oauthed_name] = 1;
		}

		$users = M('Users')->where(array('id' => $this->wxuser['uid']))->find();
		if (('payReturn' == ACTION_NAME) && (0 < $users['is_syn'])) {
			$_SESSION[$session_openid_name] = $_GET['wecha_id'];
		}

		if (empty($_SESSION[$session_openid_name]) && (0 < $users['is_syn'])) {
			$_SESSION['auth_callback_' . $this->token] = array('url' => getSelfUrl(array('wecha_id')), 'token' => $this->token);
			$url = $users['source_domain'] . A('Home/Auth')->getCallbackUrl($users['is_syn'], 'auth') . 'token=' . $this->token . '&source=pigcms';
			header('Location:' . $url);
			exit();
		}

		if (!isset($_SESSION[$session_openid_name]) || !$_SESSION[$session_openid_name]) {
			if ($this->isFuwu) {
			}
			else {
				$apiOauth = new apiOauth();
				if ((!$_GET['wecha_id'] || (urldecode($_GET['wecha_id']) == '{wechat_id}')) && ($_GET['wecha_id'] != 'no') && $this->wxuser['appid'] && ((($this->wxuser['type'] == 0) && ($this->wxuser['appsecret'] != '')) || ($this->wxuser['type'] == 1)) && ($toAuth == 1)) {
					$token_info = $apiOauth->webOauth($this->wxuser, '', $fansInfo);
				}

				if (!empty($token_info)) {
					$this->wecha_id = $token_info['openid'];

					if (3 == $wexintype) {
						$fake = 0;
					}

					if ($fake) {
						if (isset($_SESSION[$session_fakeopenid_name])) {
							$datainfo['issub'] = 1;
							$this->wecha_id = $_SESSION[$session_fakeopenid_name];
							$userinfoModel = M('Userinfo');
							$userinfoData = $userinfoModel->where(array('token' => $this->token, 'wecha_id' => $_SESSION[$session_fakeopenid_name]))->find();

							if ($userinfoData) {
								$fakeUserinfoData = $userinfoModel->where(array('token' => $this->token, 'wecha_id' => $token_info['openid'], 'fakeopenid' => $token_info['openid']))->find();

								if ($fakeUserinfoData) {
									if ($userinfoModel->where(array('id' => $fakeUserinfoData['id']))->save($this->_mergeUserinfo($userinfoData, $fakeUserinfoData))) {
										$userinfoModel->where(array('id' => $userinfoData['id']))->delete();
									}
								}
								else {
									$userinfoModel->where(array('id' => $userinfoData['id']))->setField('fakeopenid', $token_info['openid']);
								}
							}
							else {
								$fakeUserinfoData = $userinfoModel->where(array('token' => $this->token, 'wecha_id' => $token_info['openid'], 'fakeopenid' => $token_info['openid']))->find();

								if ($fakeUserinfoData) {
									$userinfoModel->where(array('id' => $fakeUserinfoData['id']))->setField('wecha_id', $_SESSION[$session_fakeopenid_name]);
								}
							}

							$this->wecha_id = $_SESSION[$session_fakeopenid_name];
						}
						else {
							$fansInfo = M('Userinfo')->where(array('token' => $this->token, 'fakeopenid' => $token_info['openid']))->find();

							if ($fansInfo) {
								$this->wecha_id = $fansInfo['wecha_id'];
							}
						}
					}

					if ($this->wxuser['oauthinfo'] && (MODULE_NAME != 'Index')) {
						$jsonui = $apiOauth->get_fans_info($token_info['access_token'], $token_info['openid']);
						if (isset($jsonui['openid']) && $jsonui['openid']) {
							if ($fansInfo) {
								$exist = $fansInfo['id'];
								$issub = $fansInfo['issub'];
							}
							else {
								$existInfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
								$issub = $existInfo['issub'];
								$exist = $existInfo['id'];
							}

							$datainfo['wechaname'] = str_replace(array('\'', '\\'), array(''), $jsonui['nickname']);
							$datainfo['sex'] = $jsonui['sex'];
							$datainfo['portrait'] = $jsonui['headimgurl'];
							$datainfo['token'] = $this->token;
							$datainfo['wecha_id'] = $jsonui['openid'];
							$datainfo['city'] = $jsonui['city'];
							$datainfo['province'] = $jsonui['province'];
							$datainfo['truename'] = $datainfo['wechaname'];
							$datainfo['wecha_id'] = $this->wecha_id;

							if ($fake) {
								$datainfo['fakeopenid'] = $jsonui['openid'];
							}

							if (3 == $wexintype) {
								$datainfo['fakeopenid'] = '';
								$datainfo['issub'] = $this->_issubService($datainfo['wecha_id']);
							}

							if ($exist) {
								D('Userinfo')->where(array('id' => $exist))->save($datainfo);
							}
							else {
								D('Userinfo')->add($datainfo);
							}
						}
						else {
							$this->error('授权不对哦,请重置您的appsecret!<br>' . $this->wxuser['appid'] . '<br>' . $this->wxuser['appsecret'] . '<br>' . $jsonui['errcode'], '#');
							exit();
						}
					}

					if (empty($this->wxuser['oauthinfo']) && (MODULE_NAME != 'Index')) {
						if ($fansInfo) {
							$exist = $fansInfo['id'];
						}
						else {
							$existInfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
							$exist = $existInfo['id'];
						}

						$datainfo['token'] = $this->token;
						$datainfo['wecha_id'] = $this->wecha_id;

						if ($fake) {
							$datainfo['fakeopenid'] = $token_info['openid'];
						}

						if (3 == $wexintype) {
							$datainfo['fakeopenid'] = '';
							$datainfo['issub'] = $this->_issubService($datainfo['wecha_id']);
						}

						if ($exist) {
							D('Userinfo')->where(array('id' => $exist))->save($datainfo);
						}
						else {
							D('Userinfo')->add($datainfo);
						}
					}

					$_SESSION[$session_openid_name] = $this->wecha_id;
					$_SESSION[$session_oauthed_name] = 1;
				}
				else {
					$this->wecha_id = $this->_get('wecha_id');
					if ($fake && $toAuth && !isset($_GET['isappinstalled'])) {
						$_SESSION[$session_fakeopenid_name] = $this->wecha_id;
					}

					if (!$toAuth) {
						$_SESSION[$session_openid_name] = $this->wecha_id;
					}

					if (isset($_GET['wecha_id']) && strlen($_GET['wecha_id']) && $toAuth) {
						$get_parms = $_GET;
						unset($get_parms['wecha_id']);
						$get_parm_str = '';

						if ($get_parms) {
							$comma = '';

							foreach ($get_parms as $gpk => $gpv) {
								$get_parm_str .= $comma . $gpk . '=' . $gpv;
								$comma = '&';
							}
						}

						$get_parm_str .= '&g=' . GROUP_NAME . '&m=' . MODULE_NAME . '&a=' . ACTION_NAME;
						$_SESSION[$session_reopenid_name] = $this->wecha_id;
						header('Location:' . $this->siteUrl . '/index.php?' . $get_parm_str);
						exit();
					}
				}
			}
		}
		else {
			$this->wecha_id = $_SESSION[$session_openid_name];
		}

		if ($_GET['yundabao'] == 1) {
			cookie('yundabao', '1', 31536000);
		}

		$yundabao = cookie('yundabao');

		if ($yundabao != '1') {
			if ($this->wecha_id && !preg_match('/^[0-9a-zA-Z_\\-\\s]{3,82}$/', $this->wecha_id)) {
				exit('error openid:' . $this->wecha_id);
			}
		}

		if (!$this->wecha_id) {
			$this->wecha_id = $this->_get('wecha_id');
		}

		$this->assign('wecha_id', $this->wecha_id);
		//$fansInfo = S('fans_' . $this->token . '_' . $this->wecha_id);//导致会员卡连接充值数据不实时,

		if (!$fansInfo) {
			$fansInfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
		}

		$advanceInfo = M('Wechat_group_list')->where(array('token' => $this->token, 'openid' => $this->wecha_id))->find();

		if ($advanceInfo) {
			$fansInfo['nickname'] = $advanceInfo['nickname'];

			if (!$fansInfo['wechaname']) {
				$fansInfo['wechaname'] = $advanceInfo['nickname'];
			}

			$fansInfo['sex'] = $advanceInfo['sex'];
			$fansInfo['province'] = $advanceInfo['province'];
			$fansInfo['city'] = $advanceInfo['city'];
		}

		if ($this->isFuwu) {
			$ali_userinfo_list = M('Userinfo')->where(array(
	'token'    => $this->token,
	'wecha_id' => array('like', '%z_%')
	))->select();
			$ali_wecha_id_array = array();

			foreach ($ali_userinfo_list as $alivo) {
				if (in_array($alivo['wecha_id'], $ali_wecha_id_array)) {
					$del_ali_userinfo = M('Userinfo')->where(array('token' => $this->token, 'id' => $alivo['id'], 'wecha_id' => $alivo['wecha_id']))->delete();
				}
				else {
					$ali_wecha_id_array[] = $alivo['wecha_id'];
				}
			}

			$FuwuUserInfo = M('fuwuuser')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();

			if ($FuwuUserInfo['gender'] == 'M') {
				$FuwuUserInfo['gender'] = 1;
			}
			else if ($FuwuUserInfo['gender'] == 'F') {
				$FuwuUserInfo['gender'] = 2;
			}
			else {
				$FuwuUserInfo['gender'] = 0;
			}

			if ($FuwuUserInfo['real_name'] != '') {
				$is_userinfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();

				if ($is_userinfo == '') {
					$add_userinfo = array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'issub' => 1, 'portrait' => $FuwuUserInfo['avatar'], 'truename' => $FuwuUserInfo['real_name'], 'nickname' => $FuwuUserInfo['real_name'], 'wechaname' => $FuwuUserInfo['real_name'], 'sex' => $FuwuUserInfo['gender']);
					$add_userinfo = array_map('nulltoblank', $add_userinfo);
					$id_Userinfo = M('Userinfo')->add($add_userinfo);
				}
				else if ($fansInfo['issub'] == 0) {
					$up_Userinfo = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->save(array('issub' => 1));
				}

				if ($fansInfo['wechaname'] == '') {
					$fansInfo['wechaname'] = $FuwuUserInfo['real_name'];
				}

				if ($fansInfo['portrait'] == '') {
					$fansInfo['portrait'] = $FuwuUserInfo['avatar'];
				}

				if ($fansInfo['nickname'] == '') {
					$fansInfo['nickname'] = $FuwuUserInfo['real_name'];
				}

				if ($fansInfo['truename'] == '') {
					$fansInfo['truename'] = $FuwuUserInfo['real_name'];
				}

				if ($fansInfo['tel'] == '') {
					$fansInfo['tel'] = $FuwuUserInfo['mobile'];
				}
			}
		}

		S('fans_' . $this->token . '_' . $this->wecha_id, $fansInfo);
		$this->fans = $fansInfo;
		$this->assign('fans', $fansInfo);
		$homeInfo = S('homeinfo_' . $this->token);
		if (!$homeInfo || 1) {
			$homeInfo = M('home')->where(array('token' => $this->token))->find();
			S('homeinfo_' . $this->token, $homeInfo);
		}

		$this->homeInfo = $homeInfo;
		$this->assign('homeInfo', $this->homeInfo);
		$catemenu = S('bottomMenus_' . $this->token);
		if (!$catemenu || 1) {
			$catemenu_db = M('catemenu');
			$catemenu = $catemenu_db->where(array('token' => $this->token, 'status' => 1))->order('orderss desc')->select();
			S('bottomMenus_' . $this->token, $catemenu);
		}

		$menures = array();

		if ($catemenu) {
			$res = array();
			$rescount = 0;

			foreach ($catemenu as $val) {
				$val['url'] = $this->getLink($val['url']);
				$res[$val['id']] = $val;

				if ($val['fid'] == 0) {
					$val['vo'] = array();
					$menures[$val['id']] = $val;
					$menures[$val['id']]['k'] = $rescount;
					$rescount++;
				}
			}

			foreach ($catemenu as $val) {
				$val['url'] = $this->getLink($val['url']);

				if (0 < $val['fid']) {
					array_push($menures[$val['fid']]['vo'], $val);
				}
			}
		}

		$catemenu = $menures;
		$this->bottomeMenus = $catemenu;
		$this->assign('catemenu', $this->bottomeMenus);
		$radiogroup = $homeInfo['radiogroup'];

		if ($radiogroup == false) {
			$radiogroup = 0;
		}

		$cateMenuFileName = 'tpl/Wap/default/Index_menuStyle' . $radiogroup . '.html';
		$this->assign('cateMenuFileName', $cateMenuFileName);
		$this->assign('radiogroup', $radiogroup);
		$this->user = S('user_' . $this->wxuser['uid']);
		if (!$this->user || 1) {
			$this->user = D('Users')->find(intval($this->wxuser['uid']));
			S('user_' . $this->wxuser['uid'], $this->user);
		}

		$this->assign('user', $this->user);
		$this->group = S('group_' . $this->user['gid']);
		if (!$this->group || 1) {
			$this->group = M('User_group')->where(array('id' => intval($this->user['gid'])))->find();
			S('group_' . $this->user['gid'], $this->group);
		}

		$this->assign('group', $this->group);
		$this->company = S('company_' . $this->token);
		if (!$this->company || 1) {
			$company_db = M('company');
			$this->company = $company_db->where(array('token' => $this->token, 'isbranch' => 0))->find();
			S('company_' . $this->token, $this->company);
		}

		$this->assign('company', $this->company);
		$this->copyright = $this->group['iscopyright'];
		$this->assign('iscopyright', $this->copyright);
		$this->assign('siteCopyright', C('copyright'));
		$this->assign('copyright', $this->copyright);
		$share = new WechatShare($this->wxuser, $this->wecha_id);
		$this->shareScript = $share->getSgin();
		$this->assign('shareScript', $this->shareScript);
		$this->fakeopenid = D('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->getField('fakeopenid');
	}
コード例 #7
0
ファイル: WechatShare.class.php プロジェクト: hehekeke/pigcms
 public function getShareData($params = array())
 {
     $params['moduleName'] = empty($params['moduleName']) ? MODULE_NAME : $params['moduleName'];
     $params['moduleID'] = empty($params['moduleID']) ? 0 : $params['moduleID'];
     $params['imgUrl'] = empty($params['imgUrl']) ? '' : $params['imgUrl'];
     if (empty($params['sendFriendLink'])) {
         $params['sendFriendLink'] = stripslashes(getSelfUrl(array('wecha_id')));
     } else {
         $params['sendFriendLink'] = stripslashes(getSelfUrl(array('wecha_id'), $params['sendFriendLink']));
     }
     $params['tTitle'] = empty($params['tTitle']) ? '' : shareFilter($params['tTitle']);
     $params['tContent'] = empty($params['tContent']) ? $params['tTitle'] : shareFilter($params['tContent']);
     $shareData = str_replace('\\/', '/', json_encode($params));
     $html = '		<script type="text/javascript">' . "\r\n" . '				window.shareData = ' . $shareData . ';' . "\r\n" . '		</script>';
     return $html;
 }