|
PHP CAS客户端包可以从网上下载。
注意开启php_curl.dll库
<?php
define('CAS_ENABLE', true);
define('CAS_SERVER_HOSTNAME', "CAS服务器ip");
define('CAS_SERVER_PORT', 3000);
define('CAS_SERVER_APP_NAME', "/cas");
require_once("./cas/CAS.php");
phpCAS::setDebug("D:/MYOA/test.txt");
phpCAS::client(CAS_VERSION_2_0, CAS_SERVER_HOSTNAME, CAS_SERVER_PORT, CAS_SERVER_APP_NAME);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
$SSO_ID = phpCAS::getUser();
if($SSO_ID!="")
{
include_once("inc/utility.php");
include_once("inc/utility_all.php");
$query = "SELECT * from USER where USER_ID='$SSO_ID'";
$cursor= exequery($connection,$query);
if($ROW=mysql_fetch_array($cursor))
{
$UID=$ROW["UID"];
$USER_ID=$ROW["USER_ID"];
$BYNAME=$ROW["BYNAME"];
$USER_NAME=$ROW["USER_NAME"];
$BIND_IP=$ROW["BIND_IP"];
$USEING_KEY=$ROW["USEING_KEY"];
$SECURE_KEY_SN = $ROW["SECURE_KEY_SN"];
$ON_STATUS=$ROW["ON_STATUS"];
//-------- 验证是否允许该用户登录 --------
if($NOT_LOGIN)
{
Message("","用户".$USER_NAME."被设定为禁止登录!");
exit;
}
$LOGIN_USER_PRIV=$ROW["USER_PRIV"];
$USER_PRIV_OTHER=$ROW["USER_PRIV_OTHER"];
$LOGIN_AVATAR=$ROW["AVATAR"];
$LOGIN_DEPT_ID=$ROW["DEPT_ID"];
$LOGIN_DEPT_ID_OTHER=$ROW["DEPT_ID_OTHER"];
$LAST_PASS_TIME=$ROW["LAST_PASS_TIME"];
$LOGIN_THEME=$ROW["THEME"];
$LOGIN_NOT_VIEW_USER=$ROW["NOT_VIEW_USER"];
$LAST_VISIT_TIME = $ROW["LAST_VISIT_TIME"];
if($LOGIN_THEME=="")
$LOGIN_THEME="1";
if(!find_id($USER_PRIV_OTHER,$LOGIN_USER_PRIV))
$USER_PRIV_OTHER.=$LOGIN_USER_PRIV.",";
//--------- 获取角色模块权限 ----------
$LOGIN_FUNC_STR="";
$USER_PRIV_OTHER = td_trim($USER_PRIV_OTHER);
if($USER_PRIV_OTHER != "")
{
$query1 = "SELECT FUNC_ID_STR from USER_PRIV where USER_PRIV in ($USER_PRIV_OTHER)";
$cursor1= exequery($connection,$query1);
while($ROW=mysql_fetch_array($cursor1))
{
$FUNC_STR=$ROW["FUNC_ID_STR"];
$MY_ARRAY=explode(",",$FUNC_STR);
$ARRAY_COUNT=sizeof($MY_ARRAY);
if($MY_ARRAY[$ARRAY_COUNT-1]=="")$ARRAY_COUNT--;
for($I=0;$I<$ARRAY_COUNT;$I++)
{
if(!find_id($LOGIN_FUNC_STR,$MY_ARRAY[$I]))
$LOGIN_FUNC_STR.=$MY_ARRAY[$I].",";
}
}
}
//--------- 取界面主题信息 ---------
$query = "SELECT * from INTERFACE";
$cursor1= exequery($connection,$query);
if($ROW=mysql_fetch_array($cursor1))
{
$THEME_SELECT=$ROW["THEME_SELECT"];
$THEME=$ROW["THEME"];
if($THEME_SELECT=="0")
$LOGIN_THEME=$THEME;
}
//--------- 注册OA的Session数据 ----------
$LOGIN_UID=$UID;
$LOGIN_USER_ID=$USER_ID;
$LOGIN_BYNAME=$BYNAME;
$LOGIN_USER_NAME=$USER_NAME;
$LOGIN_ANOTHER="0";
$LOGIN_USER_PRIV_OTHER=$USER_PRIV_OTHER;
session_start();
session_register("LOGIN_UID");
session_register("LOGIN_USER_ID");
session_register("LOGIN_BYNAME");
session_register("LOGIN_USER_NAME");
session_register("LOGIN_USER_PRIV");
session_register("LOGIN_USER_PRIV_OTHER");
session_register("LOGIN_DEPT_ID");
session_register("LOGIN_DEPT_ID_OTHER");
session_register("LOGIN_AVATAR");
session_register("LOGIN_THEME");
session_register("LOGIN_FUNC_STR");
session_register("LOGIN_NOT_VIEW_USER");
session_register("LOGIN_ANOTHER");
session_register("USERTYPE");
//---------- 建立在线状态 -----------
update_my_online_status(1);
clear_online_status();
//---------- 检查短信提醒文件 -----------
if(!file_exists($ROOT_PATH."attachment/new_sms/".$LOGIN_UID.".sms"))
new_sms_remind($LOGIN_UID, 0);
if($SEC_ON_STATUS!="1" && $ON_STATUS!="1")
$update_str .= ",ON_STATUS='1'";
$query = "update USER set LAST_VISIT_TIME='".date("Y-m-d H:i:s")."'".$update_str." where USER_ID='$LOGIN_USER_ID'";
exequery($connection,$query);
//--------- 设置登录Cookie数据 ----------
if($SEC_USER_MEM==1)
setcookie("USER_NAME_COOKIE", $USERNAME,time() + 60*60*24*1000);
else
setcookie("USER_NAME_COOKIE", "",time() + 60*60*24*1000);
setcookie("LOGIN_TYPE", "1",time() + 60*60*24*1000);
setcookie("OA_USER_ID", $LOGIN_USER_ID); //随浏览器关闭而消失
setcookie("SID_".$UID, dechex(crc32(session_id())),time() + 60*60*24*1000, "/");
//-------- 检查密码是否过期 --------
if($SEC_PASS_FLAG=="1"&&(time()-strtotime($LAST_PASS_TIME) >=$SEC_PASS_TIME*24*3600))
{
header("location: /general/pass.php");
exit;
}
//-------- 检查是否首次登录修改密码 --------
if($SEC_INIT_PASS=="1"&&($LAST_PASS_TIME==""||$LAST_PASS_TIME=="0000-00-00 00:00:00"))
{
header("location: /general/pass.php");
exit;
}
//-------- 根据日程安排生成短信息 --------
affair_sms();
//-------- 检查是否有新短信 --------------
$query = "SELECT SMS_ID from SMS where TO_ID='$LOGIN_USER_ID' and REMIND_FLAG='1' and REMIND_TIME<='".time()."' limit 0,1";
$cursor1= exequery($connection,$query);//echo $query;exit;
$SMS_COUNT = mysql_num_rows($cursor1);
if($SMS_COUNT == 0)
new_sms_remind($LOGIN_UID, 0);
ob_end_clean();
header("location:general");
}
}
?>
|
|