Ejemplo n.º 1
0
 public static function getArgumentOptionByName($name)
 {
     $dbutil = new SQLUtil();
     $where = "name = " . "\"" . $name . "\"";
     $res = $dbutil->selectAllFromTableWhere(self::TABLE, $where);
     $retArr = $dbutil::interpretQueryResponse($res);
     return $retArr;
 }
Ejemplo n.º 2
0
 public static function getAllCommandOptions()
 {
     $dbutil = new SQLUtil();
     $sql = "SELECT C.name AS command_name, C.id AS command_id, O.name AS command_option_name, O.id AS command_option_id, O.short_name AS command_option_short_name FROM command C, command_option O WHERE O.command_id = C.id";
     $res = $dbutil->executeSql($sql);
     $retArr = $dbutil::interpretQueryResponse($res);
     return $retArr;
 }
Ejemplo n.º 3
0
 public static function login($username, $password)
 {
     $user_table = new UserTable();
     $result = $user_table->select($username, $password);
     if ($result != false) {
         // 设置Session
         SessionUtil::set(array('is_login' => true, 'user_id' => $result['user_id'], 'user_login' => $result['user_login'], 'user_name' => $result['user_name'], 'user_phone' => $result['user_phone'], 'user_email' => $result['user_email'], 'user_type' => $result['user_type'], 'user_authority' => SQLUtil::get_authority($result['user_type'], $result['user_authority'])));
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 4
0
function insert()
{
    echo "<form action='form.html' method='post'>";
    $id = $_POST["Id"];
    $firstName = $_POST["FirstName"];
    $lastName = $_POST["LastName"];
    $title = $_POST["Title"];
    $hireDate = $_POST["HireDate"];
    $sql = "INSERT INTO employee_info\n\t\t\tVALUES (:id, :firstName, :lastName, :title, :hireDate)";
    $array = array(':id' => $id, ':firstName' => $firstName, ':lastName' => $lastName, ':title' => $title, ':hireDate' => $hireDate);
    if (!empty(SQLUtil::run($sql, $array, true))) {
        echo "\n - Insert Successful";
    } else {
        echo "\n - Insert Failed";
    }
    echo "<tr>\n\t\t <td width='100'> </td>\n\t\t <td>\n\t   \t\t<input name='back' type='submit' id='back' value='Back'>\n\t\t </td>\n\t\t </tr>\n\t     </form>";
}
Ejemplo n.º 5
0
function update()
{
    echo "<form action='form.html' method='post'>";
    $id = $_POST["Id"];
    $firstName = $_POST["FirstName"];
    $lastName = $_POST["LastName"];
    $title = $_POST["Title"];
    $hireDate = $_POST["HireDate"];
    $sql = "UPDATE employee_info\n\t\t\tSET FirstName = :firstName, LastName = :lastName, Title = :title, HireDate = :hireDate\n\t\t\tWHERE Id = :id";
    $array = array(':firstName' => $firstName, ':lastName' => $lastName, ':title' => $title, ':hireDate' => $hireDate, ':id' => $id);
    if (!empty(SQLUtil::run($sql, $array, true))) {
        echo "\n - Update Successful";
    } else {
        echo "\n - Update Failed";
    }
    echo "<tr>\n\t\t <td width='100'> </td>\n\t\t <td>\n\t   \t\t<input name='back' type='submit' id='back' value='Back'>\n\t\t </td>\n\t\t </tr>\n\t     </form>";
}
Ejemplo n.º 6
0
 public function signupHandler()
 {
     $username = Util::fetch_post('username');
     $password = Util::fetch_post('password');
     $realname = Util::fetch_post('realname');
     if ($username == null || $password == null || $realname == null) {
         $this->error(2);
     }
     $userTable = new UserTable();
     if ($userTable->is_exist($username)) {
         $this->errorMsg('该用户已存在');
     }
     // 插入数据
     $userTable->insert($username, $password, $realname);
     $result = $userTable->select($username, $password);
     $userExtraTable = new UserExtraTable();
     $userExtraTable->insert($result['user_id']);
     SQLUtil::login($username, $password);
     Util::go(URL . 'manager/');
 }
Ejemplo n.º 7
0
<?php

include '/system.php';
include '/template/mysql.php';
$connection = SQLUtil::connect($hostname, $database, $username, $password);
$success = System::createAccount($connection, $_POST['username'], $_POST['password'], $_POST['email']);
include '/redirect.php';
Ejemplo n.º 8
0
 public static function getCommandStructure()
 {
     $dbutil = new SQLUtil();
     $sql = "SELECT C.name AS command_name, C.id AS command_id, A.name AS argument_name, A.id AS argument_id FROM command C LEFT JOIN argument A ON C.id = A.command_id";
     $res = $dbutil->executeSql($sql);
     $retArr = $dbutil::interpretQueryResponse($res);
     return $retArr;
 }
Ejemplo n.º 9
0
 public function viewInfo($user_id = null)
 {
     if ($user_id != null && $user_id != SessionUtil::get('user_id')) {
         // 如果是要修改其它用户的信息,需检查是否有权限10
         if (!Util::has_authority(10)) {
             $this->error(3);
         }
     } else {
         $user_id = SessionUtil::get('user_id');
     }
     $user_info = $this->model->select($user_id);
     $user_type_table = new UserTypeTable();
     $user_type_name = SQLUtil::get_type_name($user_info['user_type']);
     $user_department = SQLUtil::get_department($user_info['user_department']);
     $view_data = array('stunum' => $user_info['user_login'], 'name' => $user_info['user_name'], 'sex' => Util::get_sex($user_info['user_sex']), 'phone' => $user_info['user_phone'], 'email' => $user_info['user_email'], 'qq' => $user_info['user_qq'], 'department' => $user_department, 'dormitory' => $user_info['user_dormitory'], 'major' => $user_info['user_major'], 'birthplace' => $user_info['user_birthplace'], 'birthday' => $user_info['user_birthday'], 'usertype' => $user_type_name, 'created' => $user_info['user_created']);
     $this->my_render('info', $view_data);
 }