Exemple #1
0
 public function getVideo()
 {
     return Video::exists($this->video_id) ? Video::find($this->video_id) : false;
 }
Exemple #2
0
 public static function generateId($length)
 {
     $idExists = true;
     while ($idExists) {
         $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         $id = '';
         for ($i = 0; $i < $length; $i++) {
             $id .= $chars[rand(0, strlen($chars) - 1)];
         }
         $idExists = Video::exists(array('id' => $id));
     }
     return $id;
 }
 /**
  * 
  * Return a Json Response. The most important index for js are data.sd.status and data.hd.status : 
  * values can be : 
  * 'ok' => everything is okay, 
  * 'doing' => a file is being converted, 
  * 'no' => There is no file availlable in this resolution
  */
 public function status($id, $request)
 {
     if (Video::exists($id)) {
         $video = Video::find($id);
         $data = [];
         $sizes = ['sd' => '640x360p', 'hd' => '1280x720p'];
         //Arrays of sizes and formats
         $formats = ['mp4', 'webm'];
         foreach ($sizes as $k => $size) {
             //For each size
             foreach ($formats as $format) {
                 //And each format
                 $file_name = $video->url . '_' . $size . '.' . $format;
                 //File name = <url of the video>_<size>.<format>
                 if (Utils::stringStartsWith($file_name, 'http')) {
                     //If stocked on an external server : absoulute path.
                     $data[$k][$format] = Utils::getHTTPStatusCodeFromURL($file_name);
                 } else {
                     $data[$k][$format] = Utils::getHTTPStatusCodeFromURL('http://' . $_SERVER['HTTP_HOST'] . '/' . $file_name);
                     //Ressource is directly on the same server with relative path
                 }
             }
         }
         foreach ($data as $k => $v) {
             if ($v['mp4'] < 400 && $v['webm'] < 400) {
                 $data[$k]['status'] = 'ok';
             } elseif ($v['mp4'] < 400 xor $v['webm'] < 400) {
                 $data[$k]['status'] = 'doing';
             } else {
                 $data[$k]['status'] = 'no';
             }
         }
         return new JsonResponse($data);
         //Return as JSON
     } else {
         return new JsonResponse([null]);
     }
 }
if (!$user->exists()) {
    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');
        }
    }
 public function video($id, $request)
 {
     $video = Video::exists($id) ? Video::find($id) : false;
     if (!$request->acceptsJson()) {
         return new RedirectResponse(WEBROOT . 'watch/' . $id);
     }
     if (is_object($video)) {
         $comments = $video->getComments();
         $commentsData = array();
         foreach ($comments as $comment) {
             $commentsData[] = array('id' => $comment->id, 'author' => UserChannel::find($comment->poster_id)->name, 'video_id' => $comment->video_id, 'comment' => $comment->comment, 'relativeTime' => Utils::relative_time($comment->timestamp), 'timestamp' => $comment->timestamp, 'likes' => $comment->likes, 'dislikes' => $comment->dislikes);
         }
         return new JsonResponse($commentsData);
     }
     return new Response(500);
 }
Exemple #6
0
                        ?>
">
										<div class="thumbnail bg-loader" data-background-load-in-view data-background="http://lorempicsum.com/up/350/200/6"></div>
										<p><?php 
                        echo $phrase;
                        ?>
</p>
									</a>
									<i><?php 
                        echo Utils::relative_time($action->timestamp);
                        ?>
</i>
								</div>
							<?php 
                    } else {
                        if ($action->type == 'comment' && Video::exists($action->target)) {
                            $comment = Comment::getByChannelAction($action);
                            $video = Utils::secureActiveRecordModel(Video::find($action->target));
                            ?>
								<div class="card<?php 
                            echo $supp_class;
                            ?>
 comment">
									<a href="<?php 
                            echo WEBROOT . 'watch/' . $action->target;
                            ?>
">
										<p><b><?php 
                            echo Utils::secure($channel_action->name);
                            ?>
</b> a commenté votre vidéo "<b><?php