include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('Video');
if (!isset($_POST['submitted']) || $_POST['submitted'] != 'true') {
    App::Throw404();
}
// Validate starting record
if (!empty($_POST['start']) && is_numeric($_POST['start'])) {
    $start = $_POST['start'];
} else {
    $start = 0;
}
// Validate block output format
$block = isset($_POST['block']) ? $_POST['block'] . '.tpl' : null;
// Retrieve video list
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' ORDER BY video_id DESC LIMIT {$start}, 20";
$videos = array();
$result = $db->Query($query);
while ($video = $db->FetchObj($result)) {
    $videos[] = $video->video_id;
}
// Output video list in requested format
if ($block) {
    View::InitView();
    ob_start();
    View::RepeatingBlock($block, $videos);
    $output = ob_get_contents();
    ob_end_clean();
} else {
    $output = json_encode($videos);
}
echo $output;
Example #2
0
     $block = null;
 }
 // Save comment if no errors were found
 if (empty($Errors)) {
     $data['video_id'] = $video->video_id;
     $data['status'] = 'approved';
     Plugin::Trigger('comment.ajax.before_post_comment');
     $comment_id = Comment::Create($data);
     $comment = new Comment($comment_id);
     $comment->Approve('activate');
     // Retrieve formatted new comment
     if (Settings::Get('auto_approve_comments') == 1) {
         if ($block) {
             View::InitView();
             ob_start();
             View::RepeatingBlock($block, array($comment->comment_id));
             $output = ob_get_contents();
             ob_end_clean();
         } else {
             $output = $comment;
         }
         $message = (string) Language::GetText('success_comment_posted');
         $other = array('auto_approve' => 1, 'output' => $output);
     } else {
         $message = (string) Language::GetText('success_comment_approve');
         $other = array('auto_approve' => 0, 'output' => '');
     }
     echo json_encode(array('result' => 1, 'msg' => $message, 'other' => $other));
     Plugin::Trigger('comment.ajax.post_comment');
     exit;
 } else {
Example #3
0
if (!$logged_in) {
    App::Throw404();
}
$user = new User($logged_in);
$data = array();
/***********************
Handle page if submitted
***********************/
if (isset($_POST['submitted'])) {
    // Save update if no errors were found
    if (!empty($_POST['post']) && !ctype_space($_POST['post'])) {
        $data['post'] = htmlspecialchars(trim($_POST['post']));
        $data['user_id'] = $user->user_id;
        Plugin::Trigger('post.ajax.before_post_update');
        $post_id = Post::Create($data);
        $post = new Post($post_id);
        // Retrieve new formatted status updated
        View::InitView();
        ob_start();
        View::RepeatingBlock('post.tpl', array($post->post_id));
        $status_update = ob_get_contents();
        ob_end_clean();
        Plugin::Trigger('post.ajax.post_update');
        echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_status_updated'), 'other' => $status_update));
        exit;
    } else {
        echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_status_update')));
        exit;
    }
}
// END verify if page was submitted