登陆页去掉用户名 密码输入框,直接用一个连接或者按钮如下
cas.php代码如下:
session_start();header("Content-Type:text/html;charset=utf-8");
include_once("inc/init.php");
include_once("inc/class/common/common_config.php");
include_once("inc/class/common/common_db.php");
include_once("inc/class/table/table_admin.php");
// Load the settings from the central config file
//require_once 'config.php';
// Load the CAS lib
$cas_host="passport.******.edu.cn";
$cas_port=443;
$cas_context="";
require_once 'inc/CAS-1.3.0/CAS.php';
// Uncomment to enable debugging
phpCAS::setDebug();
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port,
$cas_context);
// For production use set the CA certificate that is the issuer
of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($cas_server_ca_cert_path);
// For quick testing you can disable SSL validation of the CAS
server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS
PROTOCOL!
phpCAS::setNoCasServerValidation();
// force CAS authentication
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS
server
// and the user's login name can be read with
phpCAS::getUser().
// logout if desired
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
unset($_SESSION['usertype']);unset($_SESSION['adminchecked']);
}
$login_name = phpCAS::getUser();
$sql = "select id,login_name from
".common_config::TABLE_PREFIX."admin where
login_name='".$login_name."' limit 1";
$rs = cls::getDB()->getRowsNew($sql);$num = count($rs);
if($num==0){
die("请在管理员后台设置用户名为:".$login_name."的管理员账户");
}
$userid =
cls::getTable('admin')->checkLogin($login_name,'',1);
cls::closeDB();
if($userid == 0){
echo "
//common_func::sendMsg("帐户或密码输入有误",1,"./","返回重新登录");
}else{
echo "
}
主要方法就是拿doc/examples/examp_simple.php修改即可。
要先下载cas客户端文件,使用的是cas1.3.0在网盘里有