Example #1
0
<?php

header('Content-type: text/html; charset=utf8');
date_default_timezone_set('Asia/Shanghai');
require_once './includes/functions.php';
require_once './includes/schoolBITclass.php';
require_once './includes/schoolBITAccountclass.php';
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'login') {
    if (empty($_POST['username']) || empty($_POST['password'])) {
        $pagemsg = '请输入学号和密码。';
        $pagemsg_type = 'error';
    } else {
        $school = new schoolBIT((int) $_POST['username'], $_POST['password']);
        if (!$school->login()) {
            if (strpos($school->last_error, 'I') === 0) {
                if ($school->last_error == 'Inetwork_error') {
                    $pagemsg = '无法连接教务系统。';
                } else {
                    if ($school->last_error == 'Iservice_error') {
                        $pagemsg = '教务系统错误,请重试。';
                    } else {
                        if ($school->last_error == 'Itimeout_error') {
                            $pagemsg = '请求超时,请重试。';
                        } else {
                            if ($school->last_error == 'Iparse_error') {
                                $pagemsg = '错误信息解析错误。';
                            } else {
                                $pagemsg = $school->last_error;
                            }
                        }
                    }