add urlsafe_base64

This commit is contained in:
October 2014-09-03 16:30:54 +08:00
parent 2b5584b223
commit 0d266437be
2 changed files with 7 additions and 17 deletions

View File

@ -1,28 +1,19 @@
<?php
function urlsafe_base64_encode($url){
return strtr( base64_encode( $url ) , '+/', '-_' );
}
function urlsafe_base64_decode($url){
return base64_decode(strtr( $url , '-_','+/' ));
}
function checkLogin(){
if( !isLogin() ){
$back = $_SERVER['REQUEST_URI']?:'/';
if( v('ajax') && isset( $_SERVER['HTTP_REFERER'])&&$_SERVER['HTTP_REFERER'] ){
$back = $_SERVER['HTTP_REFERER'];
}
$state = NULL;
if( IFCookie::isNeedFix() ){
$sid = session_id();
$state = $sid;
$back .= '&'.IFCookie::SESSIONSTR.'='.$sid;
}
$_SESSION['backUrl'] = $back;
$aurl = Weibo::getAuthorizeURL( c('callback') , 'code' , $state );
$aurl = Weibo::getAuthorizeURL( c('callback') , 'code' );
header("Location: ".$aurl);
exit;
}
}
function isLogin(){
if( isset( $_GET['viewer'] ) ){
if( $_GET['viewer'] == '' || $_GET['viewer'] != $_SESSION['id'] ){
$_SESSION = array();
}
}
if( $_SESSION['id'] ){
return true;
}else{

View File

@ -16,6 +16,5 @@ if(is_file(ROOT.'themes/default/'. $__showPage .'.tpl.html'))
echo "<div>can't find $__showPage html file</div>";
?>
<script type="text/javascript" charset="utf-8" src="http://js.t.sinajs.cn/t4/enterprise/js/public/appframe/client.js"></script>
</body>
</html>