Пример #1
0
    $postDB = new postDB();
    $rResult = $postDB->execSQL($sQuery);
    $sQuery = "\n        SELECT count(postIndex.postid) AS count FROM postIndex,postInfo WHERE postIndex.historyid = postInfo.historyid AND postIndex.deleted = 0";
    $result = $postDB->execSQL($sQuery);
    $iTotal = $result[0]["count"];
    $sQuery = "\n        SELECT count(postIndex.postid) AS count FROM postIndex,postInfo WHERE postIndex.historyid = postInfo.historyid AND postIndex.deleted = 0\n        {$sWhere}";
    $result = $postDB->execSQL($sQuery);
    $iFilteredTotal = $result[0]["count"];
    $postDB->close();
    return $rResult;
}
function fatal_error($sErrorMessage = '')
{
    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
    die($sErrorMessage);
}
function get_data_array($result)
{
    $array = array();
    foreach ($result as $entry) {
        $dataid = $entry["postid"];
        $histid = $entry["historyid"];
        $op = "<a href='' name='new'>添加</a> <a href='' name='delete'>删除</a> <a href='' name='edit'>编辑</a> <input type='hidden' data-id='{$dataid}' data-histid='{$histid}'/>";
        array_push($array, array($entry["title"], $entry["author"], $entry["createTime"], $op));
    }
    return $array;
}
$result = get_query_result($_GET);
$dataArray = get_data_array($result);
$output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => $dataArray);
echo json_encode($output);
Пример #2
0
function register_new_member(Member $member)
{
    if (!is_member($member->email)) {
        $connection = connect();
        $member->password = md5($member->password);
        $sql = "INSERT INTO team_members (member_id, first_name, last_name, email, password, dob, official_dob, reset_code) VALUES (NULL, '" . $member->first_name . "', '" . $member->last_name . "', '" . $member->email . "' , '" . $member->password . "', '3000-01-01', '" . $member->official_dob . "','" . get_uuid() . "')";
        $result = $connection->query($sql);
        disconnect($connection);
        if ($result == true) {
            $member_id_result = query_sql("SELECT `member_id` FROM `team_members` WHERE `email` = '" . $member->email . "'");
            $member_id = get_query_result($member_id_result, 'member_id');
            $result = array("registered" => true, "status_code" => 200, "member_id" => $member_id);
        } else {
            $result = array("registered" => false, "status_code" => 401, "error" => "Registration failed due to internal error");
        }
    } else {
        $result = array("registered" => false, "status_code" => 409, "error" => "Member already Registered");
    }
    return $result;
}