Пример #1
0
<?php

$app->get("/", function () {
    $post = selectPost(null);
    return view("home", ["noFooter" => true, "post" => $post, "title" => "Mosey On", "titleLink" => true]);
});
$app->get("/archive", function () {
    $archive = selectArchive();
    return view("archive", ["archive" => $archive, "noFooter" => true, "title" => "Archive - Mosey On"]);
});
$app->get("/post/{id}", function ($id) {
    $post = selectPost($id);
    return view("post", ["post" => $post, "title" => $post->title . " - Mosey On", "titleLink" => false]);
});
$app->get("/api/flickr/{id}", function ($id) {
    $flickrRest = "https://api.flickr.com/services/rest";
    $parameters = ["api_key" => "c69d07db843fe141222d16d7b1b79736", "format" => "json", "method" => "flickr.photosets.getPhotos", "nojsoncallback" => "1", "photoset_id" => $id];
    $url = $flickrRest . "?" . http_build_query($parameters);
    $json = file_get_contents($url);
    $data = json_decode($json);
    return response()->json($data->photoset->photo);
});
function selectArchive()
{
    $query = DB::table("post");
    $query->select("created", "post_id", "title");
    $query->orderBy("created", "asc");
    $rows = $query->get();
    $archive = [];
    foreach ($rows as $row) {
        $time = strtotime($row->created);
Пример #2
0
// programmer:	Jafarkhani
// create Date:	88.12
//---------------------------
require_once '../header.inc.php';
require_once 'post.class.php';
require_once inc_response;
require_once inc_dataReader;
require_once inc_component;
require_once inc_manage_unit;
require_once inc_QueryHelper;
$task = isset($_POST["task"]) ? $_POST["task"] : (isset($_GET["task"]) ? $_GET["task"] : "");
switch ($task) {
    case "fullSelect":
        fullSelect();
    case "selectPost":
        selectPost();
    case "SavePost":
        SavePost();
    case "DeletePost":
        DeletePost();
    case "MovePost":
        MovePost();
}
function selectPost()
{
    $where = "1=1";
    $whereParam = array();
    //-----------------------
    if (!empty($_POST["post_id"])) {
        $where .= "post_id=:pid";
        $whereParam[":pid"] = $_POST["post_id"];