Beispiel #1
0
<?php

define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
if ($_REQUEST['act'] == 'list') {
    // 	$smarty->assign('ur_here',      "班级管理员列表");
    $smarty->display('person_list.htm');
} elseif ($_REQUEST['act'] == 'ajax_list') {
    $list = person_list();
    make_json($list);
} elseif ($_REQUEST['act'] == 'ajax_save') {
    $id = !empty($_REQUEST['person_id']) ? intval($_REQUEST['person_id']) : 0;
    if ($id == 0) {
        //insert
        $sql = "insert into " . $ecs->table("person") . " (name,is_active,class_code,iden,id_card,sex,\r\n\t\t\tbthday,nation,tel,shorttel,email,\r\n\t\t\taddress,unit,has_left,created ) values \r\n\t\t\t('" . $_REQUEST["name"] . "',1,'" . $_SESSION["class_code"] . "','" . $_REQUEST["iden"] . "','" . $_REQUEST["id_card"] . "',\r\n\t\t\t'" . $_REQUEST["sex"] . "',\r\n\t\t\t'" . $_REQUEST["bthday"] . "','" . $_REQUEST["nation"] . "',\r\n\t\t\t'" . $_REQUEST["tel"] . "','" . $_REQUEST["shorttel"] . "','" . $_REQUEST["email"] . "',\r\n\t\t\t'" . $_REQUEST["address"] . "','" . $_REQUEST["unit"] . "','" . $_REQUEST["has_left"] . "',\r\n\t\t\tnow())";
        $db->query($sql);
        admin_log(addslashes($_REQUEST["name"]), 'add', 'person');
        make_json_result("添加“" . $_REQUEST["name"] . "”成功!");
    } else {
        $sql = "update " . $ecs->table("person") . " set name='" . $_REQUEST["name"] . "',\r\n\t\t\tiden='" . $_REQUEST["iden"] . "',\r\n\t\t\tid_card='" . $_REQUEST["id_card"] . "',\r\n\t\t\tsex='" . $_REQUEST["sex"] . "',\r\n\t\t\t\t\tbthday='" . $_REQUEST["bthday"] . "',\r\n\t\t\t\t\tnation='" . $_REQUEST["nation"] . "',\r\n\t\t\t\t\ttel='" . $_REQUEST["tel"] . "',\r\n\t\t\t\t\tshorttel='" . $_REQUEST["shorttel"] . "',\r\n\t\t\t\t\temail='" . $_REQUEST["email"] . "',\r\n\t\t\t\t\taddress='" . $_REQUEST["address"] . "',\r\n\t\t\t\t\tunit='" . $_REQUEST["unit"] . "',\r\n\t\t\t\t\thas_left='" . $_REQUEST["has_left"] . "' \r\n\t\t\t\t\twhere person_id=" . $id;
        $db->query($sql);
        admin_log(addslashes($_REQUEST["name"]), 'update', 'person');
        make_json_result("修改“" . $_REQUEST["name"] . "”成功!");
    }
} elseif ($_REQUEST['act'] == 'ajax_delete') {
    $id = !empty($_REQUEST['person_id']) ? intval($_REQUEST['person_id']) : 0;
    $sql = "delete from " . $ecs->table("person") . " where person_id=" . $id;
    $db->query($sql);
    admin_log($_REQUEST["person_id"], 'delete', 'person');
    make_json_result("删除成功!");
}
<?php

function person_list()
{
    include 'dbconnect.php';
    $mysqli_result = mysqli_query($connection, "SELECT * FROM Person ORDER by fname DESC ");
    $person_list = array();
    foreach ($mysqli_result as $row) {
        $person_list[] = $row;
    }
    return $person_list;
}
echo json_encode(person_list());
Beispiel #3
0
function save_input()
{
    global $_STATE;
    $_STATE->new_rate = array("ID" => $_POST["ID"], "rate" => $_POST["rate"], "eff" => $_POST["eff"], "exp" => $_POST["exp"]);
    person_list();
    if (!array_key_exists($_STATE->record_id, $_STATE->records)) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid person id");
    }
    //we're being spoofed
    $rates = $_STATE->records[$_STATE->record_id]["rates"];
    $ndx = 0;
    if ($_POST["ID"] == 0) {
        $rate_rec = array("ID" => 0);
        array_unshift($rates, $rate_rec);
        //add to beginning
    } else {
        $found = false;
        foreach ($rates as $rate_rec) {
            if ($rate_rec["ID"] == $_STATE->new_rate["ID"]) {
                $found = true;
                break;
            }
            ++$ndx;
        }
        if (!$found) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid rate id");
        }
    }
    $_STATE->rates = $rates;
    //rates for this person
    $_STATE->rate_ndx = $ndx;
}