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

header("Content-type: application/json; charset = UTF-8");
require_once "init.php";
$videos = new Video();
if (!Input::exists()) {
    $videos_list = $videos->display_weeks_by(1, 4, 'ASC');
    $videos_list_results = $videos->data();
    if (count($videos_list_results)) {
        echo json_encode($videos_list_results);
    }
} else {
    if (isset($_POST['week_start']) && isset($_POST['week_end']) && isset($_POST['week_order'])) {
        $wk_st = escape((int) $_POST['week_start']);
        $wk_end = escape((int) $_POST['week_end']);
        $ordering = escape((string) $_POST['week_order']);
        $videos_list = $videos->display_weeks_by($wk_st, $wk_end, $ordering);
        $videos_list_results = $videos->data();
        if (count($videos_list_results)) {
            echo json_encode($videos_list_results);
        }
    }
}
Пример #2
0
    if (!$user->isLoggedIn()) {
        Redirect::to('../index.php');
    } else {
        foreach ($_GET as $key => $value) {
            if ($value == "") {
                Redirect::to('../index.php');
            }
        }
        if (Input::exists('get')) {
            $video_entry = new Video();
            $video_entry_index = $video_entry->safe_string(Input::get('id'));
            //You can also use the video->exists method!!!
            if (!$video_entry->find($video_entry_index)) {
                echo "Data not found!";
            } else {
                $video_entry_data = $video_entry->data();
                $video_entry_date_published = $video_entry_data->date_published;
                $video_entry_date_exp = explode("-", $video_entry_date_published);
                $video_entry_date_m = $video_entry_date_exp[1];
                $video_entry_date_d = $video_entry_date_exp[2];
                $video_entry_date_y = $video_entry_date_exp[0];
            }
        } else {
            Redirect::to('../index.php');
        }
    }
}
?>

<!--include reg_user_header.php-->
<?php 
Пример #3
0
    Redirect::to('../index.php');
} else {
    if (!$user->isLoggedIn() || !$user->hasPermission('admin')) {
        Redirect::to('../index.php');
    } else {
        foreach ($_GET as $key => $value) {
            if ($value == "") {
                Redirect::to('../index.php');
            }
        }
        if (Input::exists('get')) {
            $video_entry = new Video();
            $video_entry_id = $video_entry->safe_string(Input::get('id'));
            $video_entry->find($video_entry_id);
            if (!$video_entry->exists()) {
                Redirect::to('../index.php');
            } else {
                $video_entry_title = $video_entry->data()->video_title;
                try {
                    $video_entry->delete(['id', '=', Input::get('id')]);
                    Session::flash('delete', 'Video for entry "' . $video_entry_title . '" has been deleted from the database.');
                    Redirect::to('../index.php');
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
        } else {
            Redirect::to('../index.php');
        }
    }
}