public static function isLogin() { if (isset($_REQUEST['login'])) { return $_REQUEST['login']; } if (!isset($_COOKIE['wrm_aid']) || !isset($_COOKIE['wrm_atype'])) { return false; } else { $cookieId = UidEncryptUtil::decryptUid($_COOKIE['wrm_aid']); $cookieType = $_COOKIE['wrm_atype']; $session = Yaf_Session::getInstance(); $oauthId = $session->offsetGet('wrm_oauth_id'); $oauthType = $session->offsetGet('wrm_oauth_type'); $oauthExpire = intval($session->offsetGet('wrm_oauth_expire')); $oauthToken = $session->offsetGet("wrm_oauth_token"); self::getClient($cookieType); if ($cookieId != $oauthId || $cookieType != $oauthType) { if (!empty($oauthId)) { self::delSession(); } return false; UserApi::getAccessToken($cookieId, $cookieType); $oauthToken = $session->offsetGet("wrm_oauth_token"); } if (empty($oauthToken)) { self::delSession(); self::delCookie(); return false; } if ($oauthExpire > time()) { self::$client = null; self::getClient($cookieType); return true; } else { if (!empty($oauthId) && !empty($oauthType)) { $client = self::getClient($oauthType); $client->getAccessToken(); if ($client->expireTime > time()) { return true; } } self::delSession(); self::delCookie(); return false; } } }
protected function getLegalParam($tag, $legalType, $legalList = array(), $default = null) { //检查是否是post请求 if (strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0) { $param = $this->getRequest()->getPost($tag, $default); } else { $param = $this->getRequest()->get($tag, $default); } if ($param !== null) { switch ($legalType) { case 'eid': if ($param) { if ($param === $default) { return $default; } else { return UidEncryptUtil::decryptUid($param); } } else { return null; } break; case 'id': if (preg_match('/^\\d{1,20}$/', strval($param))) { return strval($param); } break; case 'time': return intval($param); break; case 'int': if (!is_numeric($param)) { break; } if ($param >= -2147483648.0 && $param <= 2147483647) { $val = intval($param); } else { $val = $param * 1; } if (count($legalList) == 2) { if ($val >= $legalList[0] && $val <= $legalList[1]) { return $val; } } else { return $val; } break; case 'float': if (!is_numeric($param)) { break; } $var = floatval($param); return $var; break; case 'str': $val = strval($param); if (count($legalList) == 2) { if ($val >= $legalList[0] && $val <= $legalList[1]) { return $val; } } else { return $val; } break; case 'trim_spec_str': $val = trim(strval($param)); if (!preg_match("/['.,:;*?~`!@#\$%^&+=)(<>{}]|\\]|\\[|\\/|\\\\|\"|\\|/", $val)) { if (count($legalList) == 2) { if (strlen($val) >= $legalList[0] && strlen($val) <= $legalList[1]) { return $val; } } else { return $val; } } break; case 'enum': if (in_array($param, $legalList)) { return $param; } break; case 'array': if (count($legalList) > 0) { return explode($legalList[0], strval($param)); } else { if (empty($param)) { return array(); } return explode(',', strval($param)); } break; case 'json': return json_decode(strval($param), true); break; case 'raw': return $param; break; default: break; } } if ($default != null) { return $default; } return false; }