public function videoPass(Swf2VidEvent $event)
 {
     /** @var Video $video */
     if ($data = $event->getEventData()) {
         if ($video = @Video::find($data['video']['video_id'])) {
             if ($user = $event->getUser()) {
                 if (Video::count(['conditions' => ['project_id = ? and vid_status = "pass" and updated_at > DATE_SUB(NOW(), INTERVAL 10 MINUTE)', $video->project_id]])) {
                     //redo
                     return;
                 }
                 $minLevel = Swf2Vid::getInstance()->getUserVideoLevel();
                 $levels = $user->user_level;
                 /** @var UserLevel $level */
                 foreach ($levels as $level) {
                     if ($level->credits > 0) {
                         if (AccessLevels::getInstance()->checkAccess($level->level, $minLevel)) {
                             $level->credits = $level->credits - 1;
                             $level->save_direct();
                             return;
                         }
                     }
                 }
             }
             $video->vid_status = 'fail';
             $video->save_direct();
         }
         App::getInstance()->dispatch(Swf2VidEvent::VIDEO_NO_CREDITS, $event);
     }
 }
示例#2
0
 public static function generate()
 {
     // Там еще в сайтмепе есть приоритетность. Для главной ставим самую высокую, для всех категорий чуть ниже и последняя приоритетность для постов
     //Создает XML-строку и XML-документ при помощи DOM
     $dom = new DomDocument('1.0');
     //добавление корня - <books>
     $urlset = $dom->appendChild($dom->createElement('urlset'));
     $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     // Главная страница
     $url = $urlset->appendChild($dom->createElement('url'));
     $loc = $url->appendChild($dom->createElement('loc'));
     $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME']));
     $priority = $url->appendChild($dom->createElement('priority'));
     $priority->appendChild($dom->createTextNode('1.0'));
     // Категории фото
     $categoryPhoto = CategoryPhoto::find()->all();
     foreach ($categoryPhoto as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/photo/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Категории видео
     $categoryVideo = Category::find()->all();
     foreach ($categoryVideo as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/video/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Страницы фото
     $photoCatalog = PhotoCatalog::find()->where('publish = 1')->all();
     foreach ($photoCatalog as $photo) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/photo/" . $photo->category->url . "/" . $photo->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     // Страницы видео
     $videos = Video::find()->where('publish = 1')->all();
     foreach ($videos as $video) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/video/" . $video->category->url . "/" . $video->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     //генерация xml
     $dom->formatOutput = true;
     // установка атрибута formatOutput
     // domDocument в значение true
     // save XML as string or file
     //$test1 = $dom->saveXML(); // передача строки в test1
     $dom->save('../web/sitemap.xml');
     // сохранение файла
 }
示例#3
0
 public function init()
 {
     parent::init();
     if ($this->latestVideos === null) {
         $User = OvcUser::getCurrentUser();
         $courseIds = OvcCourse::getUserCourseIds($User->id);
         $this->latestVideos = \app\models\Video::find()->where(['course_id' => $courseIds])->orderBy('id DESC')->limit(16)->all();
     }
 }
示例#4
0
 public function preview($vidId)
 {
     $video = Video::find($vidId);
     if ($video) {
         $category = VideoCategories::find($video->category_id);
         return view('videos.preview')->with('video', $video)->with('category', $category);
     }
     return redirect("/videos");
 }
示例#5
0
 public function run()
 {
     if ($this->type == 'video') {
         $model = Video::find()->orderBy('hits DESC')->limit(5)->all();
     }
     if ($this->type == 'photo') {
         $model = PhotoCatalog::find()->orderBy('hits DESC')->limit(5)->all();
     }
     return $this->render('teaser', ['model' => $model, 'type' => $this->type]);
 }
示例#6
0
 /**
  * Lists all Video models.
  * @return mixed
  */
 public function actionIndex()
 {
     $query = Video::find();
     if (!Yii::$app->user->can('admin')) {
         $query->andFilterWhere(['block_edit' => 0]);
     }
     $query->orderBy('id DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#7
0
 public function run()
 {
     $model = null;
     if ($this->type == 'video') {
         $model = Video::find()->where('id <> :id && publish = 1', [':id' => $this->currentId])->orderBy('RAND()')->limit(3)->all();
     } else {
         $model = PhotoCatalog::find()->where('id <> :id && publish = 1', [':id' => $this->currentId])->orderBy('RAND()')->limit(4)->all();
     }
     return $this->render($this->type == 'video' ? 'randomize_video' : 'randomize_photo', ['model' => $model]);
 }
示例#8
0
 public function actionView($category = null, $url = null)
 {
     $video = Video::find()->where("url = :url && publish = 0", [":url" => $url])->one();
     if ($video == null) {
         throw new HttpException(404);
     }
     // счетчик показов
     $video->updateCounters(['hits' => 1]);
     return $this->render('/video/view', ['video' => $video]);
 }
示例#9
0
 public function beforeDelete()
 {
     //echo "test"; die();
     //Video::deleteAll('category_id = :category_id', [':category_id'=>$this->id]);
     $videos = Video::find()->where('category_id = :category_id', [':category_id' => $this->id])->all();
     foreach ($videos as $v) {
         $v->delete();
     }
     return parent::beforeDelete();
     // TODO: Change the autogenerated stub
 }
示例#10
0
 public function actionIndex()
 {
     $query = Video::find()->where("publish = 1");
     // делаем копию выборки
     $countQuery = clone $query;
     // подключаем класс Pagination, выводим по 10 пунктов на страницу
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 24]);
     // приводим параметры в ссылке к ЧПУ
     $pages->pageSizeParam = false;
     $videos = $query->offset($pages->offset)->orderBy('id DESC')->limit($pages->limit)->all();
     return $this->render('index', ['videos' => $videos, 'pages' => $pages]);
 }
示例#11
0
 public function getTarget()
 {
     $target_type = $this->target_type;
     switch ($target_type) {
         case 'user':
             return User::find($this->target_id);
         case 'comment':
             return Comment::find($this->target_id);
         case 'video':
             return Video::find($this->target_id);
         default:
             return null;
     }
 }
示例#12
0
 public function destroy($id)
 {
     $v = Video::find($id);
     if ($v) {
         $res = $v->delete();
         if ($res) {
             return ['error' => false, 'message' => 'Video successfully deleted!'];
         } else {
             return ['error' => true, 'message' => 'Failed to delete!'];
         }
     } else {
         return ['error' => true, 'message' => 'Video not available!'];
     }
 }
示例#13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Video::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created' => $this->created]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'video', $this->video])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
示例#14
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Video::find();
     $query->joinWith(['editor']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['editor'] = ['asc' => ['bnm_users.name' => SORT_ASC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'user' => $this->user, 'date' => $this->date, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'bnm_media.name', $this->name])->andFilterWhere(['like', 'desp', $this->desp])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'bnm_users.name', $this->editor])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]);
     return $dataProvider;
 }
示例#15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $paramss
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $userCourseIds = \app\components\OvcCourse::getUserCourseIds();
     $commentCount = "(SELECT COUNT(*) AS nos FROM comment AS c WHERE c.video_id = video.id)";
     $query = Video::find()->select("video.*, course.name, {$commentCount} as commentCount")->innerJoin('course', '`video`.`course_id` = `course`.`id`')->where(['video.course_id' => $userCourseIds]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
     /**
      * additional columns to be sorted
      */
     $dataProvider->sort->attributes['courseName'] = ['asc' => ['course.name' => SORT_ASC], 'desc' => ['course.name' => SORT_DESC]];
     $dataProvider->sort->attributes['commentCount'] = ['asc' => ['commentCount' => SORT_ASC], 'desc' => ['commentCount' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['video.id' => $this->id, 'video.course_id' => $this->course_id, 'video.user_id' => $this->user_id, 'video.created_at' => $this->created_at, 'video.modified_at' => $this->modified_at, $commentCount => $this->commentCount]);
     $query->andFilterWhere(['like', 'video.title', $this->title])->andFilterWhere(['like', 'video.description', $this->description])->andFilterWhere(['like', 'video.path', $this->path])->andFilterWhere(['like', 'course.name', $this->courseName]);
     return $dataProvider;
 }
示例#16
0
 public function actionIndex($type, $url)
 {
     if ($type != 'photo' && $type != 'video') {
         throw new HttpException(404);
     }
     if ($type == 'video') {
         $category = Category::find()->where('url = :url', [':url' => $url])->one();
     }
     if ($type == 'photo') {
         $category = CategoryPhoto::find()->where('url = :url', [':url' => $url])->one();
     }
     if ($category == null) {
         throw new HttpException(404);
     }
     if ($type == 'video') {
         $videos = Video::find()->where('category_id = :category_id && publish = :publish', [':category_id' => $category->id, ':publish' => 1])->orderBy('id DESC')->all();
         return $this->render('video', ['videos' => $videos, 'category' => $category]);
     }
     if ($type == 'photo') {
         $photo = PhotoCatalog::find()->where('category_id = :category_id && publish = :publish', [':category_id' => $category->id, ':publish' => 1])->orderBy('id DESC')->all();
         return $this->render('photo', ['photos' => $photo, 'category' => $category]);
     }
 }
示例#17
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Video::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
     $_column = [Video::tableName() . '.id', Video::tableName() . '.video_url', Video::tableName() . '.title_' . Yii::$app->language, Video::tableName() . '.description_' . Yii::$app->language, Video::tableName() . '.create_date', Video::tableName() . '.created_by', Video::tableName() . '.status'];
     $query->joinWith(['createdBy']);
     $query->select($_column)->distinct();
     if ($this->filter) {
         $query->joinWith(['videoTags']);
     }
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'create_date' => $this->create_date]);
     $query->andFilterWhere(['like', 'search', $this->search])->andFilterWhere(['like', 'video_code', $this->video_code])->andFilterWhere(['like', 'video_url', $this->video_url])->andFilterWhere(['like', 'title_ar', $this->title_ar])->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'description_ar', $this->description_ar])->andFilterWhere(['like', 'description_en', $this->description_en])->andFilterWhere(['like', 'status', $this->status]);
     if ($this->filter) {
         $query->andFilterWhere(['IN', VideoTag::tableName() . '.tag_id', $this->video_tag]);
     }
     $query->orderBy('create_date DESC');
     return $dataProvider;
 }
示例#18
0
 /**
  * Lists all Video models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Video::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#19
0
 public function actionIndex()
 {
     return $this->render('index', ['video' => Video::find()->one(), 'concerts' => Concert::find()->where(['>=', 'date', date('Y-m-d')])->orderBy('date desc')->all(), 'showArchives' => Concert::find()->where(['<=', 'date', date('Y-m-d')])->count() > 0]);
 }
 /**
  * Delete and Image of a Product
  * AJAX
  *
  * @param  Request $request
  * @return JSON
  */
 public function deleteMedium(Request $request)
 {
     if ($request->ajax()) {
         if ($request->mediaType == 'image') {
             $image = Image::find($request->mediaId);
             // Check if file exists in the storage
             if (Storage::disk('public')->exists('/images/product/' . $image->name)) {
                 $fullFilePath = '/images/product/' . $image->name;
                 Storage::disk('public')->delete($fullFilePath);
             }
             $image->delete();
         } else {
             if ($request->mediaType = 'video') {
                 $video = Video::find($request->mediaId);
                 // Check if file exists in the storage
                 if (Storage::disk('public')->exists('/videos/product/' . $video->name)) {
                     $fullFilePath = '/videos/product/' . $video->name;
                     Storage::disk('public')->delete($fullFilePath);
                 }
                 $video->delete();
             }
         }
         return response()->json('File deleted', 200);
     }
 }
示例#21
0
文件: index.php 项目: Romario25/porka
//            ],
//
//        ]);
?>
    </div>
</div>
</div>
<div class="g w1140 main">
<!-- slider -->

<!-- main -->

    <div class="c-c">
        <div class="c">
            <?php 
$countVideo = \app\models\Video::find()->count('*');
?>
            <p class="fs24 fw300 text-center opensans"><a class="pink" href="/video" title="Эксклюзивные порно фото и видео в HD качестве!">Смотреть <span class="fw700"><?php 
echo $countVideo;
?>
+</span> видео в <span class="fw700">HD качестве</span></a></p>
        </div>

        <?php 
echo \app\components\widgets\CategoryWidget::widget(['type' => 'video']);
?>
        <!-- intro text -->

        <div class="c text-center">
            <h1 class="fs22 fw400 opensans"><?php 
echo $dataPage->title_video;
示例#22
0
 /**
  * Remove the specified Video from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $video = Video::find($id);
     if (empty($video)) {
         Flash::error('Video not found');
         return redirect(route('videos.index'));
     }
     $video->delete();
     Flash::success('Video deleted successfully.');
     return redirect(route('videos.index'));
 }
示例#23
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Response
  */
 public function destroy(Request $request, $id)
 {
     $user = auth()->check() ? auth()->user() : null;
     if (is_null($user)) {
         return new JsonResponse(['error' => 'not_logged_in']);
     }
     if (!$request->has('reason') || trim($request->get('reason')) == '') {
         return new JsonResponse(['error' => 'invalid_request']);
     }
     $reason = trim($request->get('reason'));
     if ($user->can('delete_video')) {
         $warnings = [];
         $vid = Video::find($id);
         if (!$vid) {
             return new JsonResponse(['error' => 'video_not_found']);
         }
         foreach ($vid->comments as $comment) {
             $comment->delete();
             // delete associated comments
         }
         $vid->faved()->detach();
         if (!\File::move(public_path() . '/b/' . $vid->file, storage_path() . '/deleted/' . $vid->file)) {
             $warnings[] = 'Could not move file';
         }
         $vid->delete();
         $receiver = $vid->user;
         if ($user->id != $receiver->id) {
             Message::send(1, $receiver->id, 'A moderator deleted your video', view('messages.moderation.videodelete', ['video' => $vid, 'reason' => $reason, 'videoinfo' => ['artist' => $vid->interpret, 'songtitle' => $vid->songtitle, 'video_source' => $vid->imgsource, 'category' => $vid->category->name]]));
         }
         $log = new ModeratorLog();
         $log->user()->associate($user);
         $log->type = 'delete';
         $log->target_type = 'video';
         $log->target_id = $id;
         $log->reason = $reason;
         $log->save();
         return new JsonResponse(['error' => 'null', 'warnings' => $warnings]);
     }
     return new JsonResponse(['error' => 'insufficient_permissions']);
 }
示例#24
0
 public function actionIndex()
 {
     $videos = Video::find()->where('publish = :publish', [":publish" => 1])->orderBy('id DESC')->limit(9)->all();
     $photos = PhotoCatalog::find()->where('publish = :publish', [":publish" => 1])->orderBy('id DESC')->limit(12)->all();
     return $this->render('index', ['videos' => $videos, 'photos' => $photos]);
 }
示例#25
0
 public function actionMedia($type, $cat = 0, $order = 'date', $asc = 'desc', $name = "", $desp = "", $author = "")
 {
     $query;
     $typeid;
     if ($type == 'album') {
         $query = Album::find();
         $typeid = 0;
     } else {
         if ($type == 'video') {
             $query = Video::find();
             $typeid = 1;
         } else {
             $query = Message::find();
             $typeid = 2;
         }
     }
     $pagination = new Pagination(['defaultPageSize' => 30, 'totalCount' => $query->count()]);
     $query->distinct();
     $catArr = [];
     if ($cat) {
         $query->joinWith("category");
         $catArr = explode(',', $cat);
         $query->andWhere(['or', ['bnm_category_relationships.category' => $catArr]]);
     }
     $query->joinWith("editor");
     $query->andFilterWhere(['like', 'bnm_media.name', $name]);
     $query->andFilterWhere(['like', 'bnm_media.desp', $desp]);
     $query->orderBy($order . ' ' . $asc)->offset($pagination->offset)->limit($pagination->limit);
     //->asArray()
     //
     $catQuery = Category::find()->joinWith("categoryRelationship")->andWhere(['bnm_category_relationships.type' => $typeid])->distinct();
     return $this->render('media', ['media' => $query->all(), 'categories' => $catQuery->all(), 'pagination' => $pagination, 'catArr' => $catArr, 'catUrl' => $cat, 'oldCat' => ['cat' => $cat], 'oldOrder' => ['order' => $order, 'asc' => $asc], 'oldSearch' => ['name' => $name, 'desp' => $desp, 'author' => $author], 'type' => $type, 'typeid' => $typeid, 'asc' => $asc, 'order' => $order, 'name' => $name, 'desp' => $desp, 'author' => $author]);
 }
示例#26
0
 /**
  * Return unconverted videos
  *
  * @param int $limit
  * @param string $orderBy
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function getUnconvertedVideo($limit = 5, $orderBy = 'created_at ASC')
 {
     return Video::find()->where(['status' => Video::STATUS_ENCODE_WAIT])->orderBy($orderBy)->limit($limit)->all();
 }
示例#27
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function publish($slug)
 {
     $video = Video::find($slug);
     $video->update(['is_published' => $video->is_published ? 0 : 1]);
     return Redirect::route('videos.admin');
 }
示例#28
0
 public function postAddFavorite($video_id)
 {
     if (Auth::guest()) {
         return ['status' => 'red', 'message' => 'You have to be logged to add this video in your favorites'];
     } else {
         $favorited = DB::table('favorited')->where('user_id', Auth::user()->id)->where('video_id', $video_id)->first();
         if (is_null($favorited)) {
             DB::table('favorited')->insert(['user_id' => Auth::user()->id, 'video_id' => $video_id]);
             Video::find($video_id)->increment('nb_favorited');
             return ['status' => 'green', 'message' => 'This video is in you favorites now'];
         } else {
             return ['status' => 'red', 'message' => 'This video is already in your favorites'];
         }
     }
 }
示例#29
0
 public function actionIndex()
 {
     $videos = Video::find()->where("create_at > (now() - interval 7 day) && publish = 1")->orderBy('id DESC')->all();
     $photos = PhotoCatalog::find()->where("create_at > (now() - interval 7 day) && publish = 1")->orderBy('id DESC')->all();
     return $this->render('index', ['videos' => $videos, 'photos' => $photos]);
 }
示例#30
0
 public function postFastDelete($elements, Request $request)
 {
     switch ($elements) {
         case 'videos':
             $elements = $request->input('elements');
             $elements = explode(' ', $elements);
             PHPRedis::delete($elements);
             foreach ($elements as $element) {
                 // delete video from database
                 $elemId = Video::find($element);
                 if (!is_null($elemId)) {
                     $elemId->delete();
                 }
                 // delete folder
                 $destination = public_path("users_content/videos/{$element}");
                 if (File::exists($destination)) {
                     File::deleteDirectory($destination);
                 }
                 // delete comments from database
                 Comment::where('video_id', $element)->delete();
             }
             return redirect()->back()->with('message_success', 'Elements have been deleted');
             break;
         case 'users':
             $elements = $request->input('elements');
             $elements = explode(' ', $elements);
             foreach ($elements as $element) {
                 $elem = User::find($element);
                 if (!is_null($elem)) {
                     $elem->delete();
                 }
             }
             return redirect()->back()->with('message_success', 'Elements have been deleted');
             break;
         default:
             $elements = $request->input('elements');
             $elements = explode(' ', $elements);
             foreach ($elements as $element) {
                 $elem = Comment::find($element);
                 if (!is_null($elem)) {
                     $elem->delete();
                 }
             }
             return redirect()->back()->with('message_success', 'Elements have been deleted');
             break;
     }
 }