Example #1
2
 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
 public function actionVideo()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 25;
     $model = Video::model()->is_publish()->findAll($criteria);
     $this->setRss($model, 'video', 'Video', 'Rss Feed Video', $this->createUrl('video'));
 }
Example #3
0
 public function run()
 {
     //限制下载频率
     $cookie = Yii::app()->request->getCookies();
     $id = Yii::app()->request->getParam('id');
     $cookie_key = 'DL' . $id . 'TIMES';
     if (isset($cookie[$cookie_key]) && $cookie[$cookie_key]->value) {
         throw new CHttpException(404, Yii::t('common', 'Access frequency too fast'));
     }
     $video = Video::model()->findByPk($id);
     if ($video) {
         $file = Helper::convertChineseName(ROOT_PATH . '/' . $video->video_file);
         if ($video->video_file && file_exists($file)) {
             $filename = pathinfo($file, PATHINFO_BASENAME);
             //更新下载次数
             $video->updateCounters(array('down_count' => 1), 'id=:id', array('id' => $id));
             //存储下载cookie次数
             unset($cookie[$cookie_key]);
             $down = 1;
             $cookie = new CHttpCookie($cookie_key, $down);
             $cookie->expire = time() + 20;
             //20秒之后可以再次下载
             Yii::app()->request->cookies[$cookie_key] = $cookie;
             //开始下载
             Yii::app()->request->sendFile($filename, file_get_contents($file));
             exit;
         } else {
             throw new CHttpException(404, Yii::t('common', 'Source Is Not Found'));
         }
     } else {
         throw new CHttpException(404, Yii::t('common', 'Source Is Not Found'));
     }
 }
Example #4
0
 public function run()
 {
     //SEO
     $this->controller->_seoTitle = $this->controller->_setting['seo_title'];
     $this->controller->_seoKeywords = $this->controller->_setting['seo_keywords'];
     $this->controller->_seoDescription = $this->controller->_setting['seo_description'];
     //头部banner
     $index_top_banner = Ad::model()->getAdOne(4);
     //中部banner
     $index_mid_banner = Ad::model()->getAdOne(3);
     //底部banner
     $index_bottom_banner = Ad::model()->getAdOne(5);
     //最新资讯
     $news_new = Post::model()->getList(array('limit' => 20));
     //热门资讯
     $news_hot = Post::model()->getList(array('order' => 't.view_count DESC, t.id DESC', 'limit' => 20));
     //最新图集
     $image_new = Image::model()->getList(array('limit' => 10));
     //热门图集
     $image_hot = Image::model()->getList(array('limit' => 10, 'order' => 'view_count DESC, t.id DESC'));
     //最新软件
     $soft_new = Soft::model()->getList(array('limit' => 20));
     //热门软件
     $soft_hot = Soft::model()->getList(array('limit' => 10, 'order' => 'down_count DESC, t.id DESC'));
     //最新视频
     $video_new = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY id DESC Limit 20", array(':status' => 'Y'));
     //热门视频
     $video_hot = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY view_count DESC, video_score DESC, id DESC Limit 20", array(':status' => 'Y'));
     //友情链接
     $link_logos = Link::model()->findAll("logo !='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->controller->render('index', array('index_top_banner' => $index_top_banner, 'index_mid_banner' => $index_mid_banner, 'index_bottom_banner' => $index_bottom_banner, 'link_logos' => $link_logos, 'link_texts' => $link_texts, 'news_new' => $news_new, 'news_hot' => $news_hot, 'image_new' => $image_new, 'image_hot' => $image_hot, 'soft_new' => $soft_new, 'soft_hot' => $soft_hot, 'video_new' => $video_new, 'video_hot' => $video_hot));
 }
Example #5
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             foreach ((array) $ids as $id) {
                 $videoModel = Video::model()->findByPk($id);
                 if ($videoModel) {
                     Uploader::deleteFile(ROOT_PATH . $videoModel->cover_image);
                 }
             }
             Video::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Video::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隐藏
             Video::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
 private function loadPost($id, $slug)
 {
     $model = Video::model()->is_publish()->findByAttributes(array('ID' => (int) $id, 'post_link' => $slug));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Video the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Video::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function run()
 {
     $criteria = new CdbCriteria();
     $criteria->limit = $this->data('limit');
     $criteria->offset = $this->data('offset');
     $criteria->order = "ID DESC";
     $model = Video::model()->is_publish()->findAll($criteria);
     $this->layout($model);
 }
Example #9
0
 public function actionPlay($id)
 {
     $this->layout = '//layouts/header_default';
     $video = Video::model()->findByPk($id);
     if (count($video)) {
         $this->render('play', array('url' => $video->path));
     } else {
         echo "Video not found!";
     }
 }
Example #10
0
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = Video::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
Example #11
0
 public function run()
 {
     $catalog_id = trim(Yii::app()->request->getParam('catalog_id'));
     $order = trim(Yii::app()->request->getParam('order'));
     if (!$order) {
         $order = 'id';
     }
     switch ($order) {
         case 'id':
             $order_by = 't.id DESC';
             break;
         case 'view_count':
             $order_by = 'view_count DESC';
             break;
         default:
             $order = 'id';
             $order_by = 't.id DESC';
             break;
     }
     //SEO
     $navs = array();
     $search_cats = '所有';
     if ($catalog_id) {
         $condition = ' AND catalog_id = ' . $catalog_id;
         $catalog = Catalog::model()->findByPk($catalog_id);
         if ($catalog) {
             $this->controller->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->controller->_setting['site_name'];
             $this->controller->_seoKeywords = $catalog->seo_keywords;
             $this->controller->_seoDescription = $catalog->seo_description;
             $navs[] = array('url' => $this->controller->createUrl('video/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
             //已搜索的分类
             $cat_parents = Catalog::getParantsCatalog($catalog_id);
             $search_cats = $cat_parents ? implode('>', $cat_parents) . '>' . $catalog->catalog_name : $catalog->catalog_name;
         }
     } else {
         $condition = '';
         $catalog = array();
         $seo = ModelType::getSEO('post');
         $this->controller->_seoTitle = $seo['seo_title'] . ' - ' . $this->controller->_setting['site_name'];
         $this->controller->_seoKeywords = $seo['seo_keywords'];
         $this->controller->_seoDescription = $seo['seo_description'];
         $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $this->controller->_seoTitle);
     }
     //获取所有符合条件的视频
     $pages = array();
     $datalist = Video::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
     //该栏目下最新的视频
     $last_videos = Video::model()->getList(array('condition' => $condition, 'limit' => 10));
     $this->controller->render('index', array('navs' => $navs, 'catalog' => $catalog, 'videos' => $datalist, 'pagebar' => $pages, 'last_videos' => $last_videos, 'order' => $order, 'search_cats' => $search_cats));
 }
Example #12
0
 public function run($id)
 {
     if (app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $this->controller->getModel(null)->findByPk($id)->delete();
         if ($this->controller->getId() == 'user') {
             Video::model()->deleteAll("user_id = :p", array(":p" => $id));
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->controller->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
         } else {
             app()->end();
         }
     }
 }
Example #13
0
 public function actionView()
 {
     if (isset($_GET['id'])) {
         $video = Video::model()->findByPk($_GET['id']);
         //var_dump($video->user_id);die;
         $video->view += 1;
         $video->update(array('view'));
         //$video->user = XfUser::model()->find("user_id=".$video->user_id);
         $comment = $this->newComment($video);
         $cs = Yii::app()->getClientScript();
         $js = $this->generateJs();
         $cs->registerScript('sharebox', $js, CClientScript::POS_READY);
         /*$xf = new XfAuthentication();
           $user = $xf->getUser();
           var_dump($user);*/
         $this->render('view', array('video' => $video, 'comment' => $comment));
     } else {
         $this->redirect($this->createUrl('index'));
     }
 }
Example #14
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $post = Video::model()->findByPk(intval($id));
     if (false == $post || $post->status == 'N') {
         throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
     }
     //更新浏览次数
     $post->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $id));
     //seo信息
     $this->controller->_seoTitle = empty($post->seo_title) ? $post->title . ' - ' . $this->controller->_setting['site_name'] : $post->seo_title;
     $this->controller->_seoKeywords = empty($post->seo_keywords) ? $post->tags : $post->seo_keywords;
     $this->controller->_seoDescription = empty($post->seo_description) ? $this->controller->_seoDescription : $post->seo_description;
     //最近的视频
     $last_videos = Video::model()->findAll(array('condition' => 'catalog_id = ' . $post->catalog_id, 'order' => 'id DESC', 'limit' => 10));
     //nav
     $navs = array();
     $navs[] = array('url' => $this->controller->createUrl('video/view', array('id' => $id)), 'name' => $post->title);
     $tplVar = array('video' => $post, 'navs' => $navs, 'last_videos' => $last_videos);
     $this->controller->render('view', $tplVar);
 }
Example #15
0
 public function run()
 {
     $g = Yii::app()->request->getParam('g');
     //1获取 0评分
     $id = Yii::app()->request->getParam('id');
     $s = Yii::app()->request->getParam('s');
     //等级0-5
     $res = Video::model()->findByPk($id);
     //t 总人数 s 从低分人数到高分人数分布
     if ($g == 1) {
         if ($res->voted) {
             exit($res->voted);
         } else {
             exit('{"t":0,"s":[0,0,0,0,0]}');
         }
     } else {
         if ($res->voted) {
             $arr_res = CJSON::decode($res->voted);
         } else {
             $arr_res = array('t' => 0, 's' => array(0, 0, 0, 0, 0));
         }
         $arr_res['t'] = $arr_res['t'] + 1;
         $arr_res['s'][$s - 1] = $arr_res['s'][$s - 1] + 1;
         //计算得分
         $avg_1 = $arr_res['t'] > 0 ? round(($arr_res['s'][0] + 2 * $arr_res['s'][1] + 3 * $arr_res['s'][2] + 4 * $arr_res['s'][3] + 5 * $arr_res['s'][4]) / $arr_res['t'] * 2, 1) : '0.0';
         $avg_2 = substr($avg_1, 0, 3);
         //取前三位
         $avg = trim($avg_2, '.');
         //去除多余的前后.
         $data = CJSON::encode($arr_res);
         $res->voted = $data;
         $res->video_score = $avg;
         $res->save();
         exit('1');
     }
 }
Example #16
0
 public function run()
 {
     $this->controller->layout = false;
     $view_url = Yii::app()->request->getParam('view_url');
     $content_id = Yii::app()->request->getParam('content_id');
     $topic_type = Yii::app()->request->getParam('topic_type');
     $cur_url = Yii::app()->request->hostinfo . Yii::app()->request->getUrl();
     $post = false;
     //评论类型
     switch ($topic_type) {
         case 'post':
             $post = Post::model()->findByPk($content_id);
             break;
         case 'image':
             $post = Image::model()->findByPk($content_id);
             break;
         case 'soft':
             $post = Soft::model()->findByPk($content_id);
             break;
         case 'video':
             $post = Video::model()->findByPk($content_id);
             break;
     }
     if (!$post) {
         throw new CHttpException(404, Yii::t('admin', 'Loading Error'));
     }
     //评论内容
     $model = new Comment('create');
     $criteria = new CDbCriteria();
     $criteria->with = array('user');
     $criteria->addColumnCondition(array('content_id' => $content_id));
     $criteria->addColumnCondition(array('t.status' => Comment::STATUS_SHOW));
     $criteria->addColumnCondition(array('type' => $this->controller->_type_ids[$topic_type]));
     $criteria->addCondition('u.uid > 0');
     $criteria->order = 't.id DESC';
     $criteria->select = 't.id, user_id, content_id, content, t.create_time ';
     //分页
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $comments = $model->findAll($criteria);
     //回复
     if ($comments) {
         foreach ($comments as $c) {
             $replies[$c->id] = Reply::model()->with('user')->findAll(array('condition' => 'cid = ' . $c->id . ' AND t.status = "' . Reply::STATUS_SHOW . '" AND u.uid > 0', 'order' => 'id'));
         }
     } else {
         $comments = array();
         $replies = array();
     }
     if (Yii::app()->request->isPostRequest) {
         $uid = Yii::app()->user->id;
         if (!$uid) {
             $this->message('script', Yii::t('common', 'You Need Login'));
         }
         $model->attributes = $_POST['Comment'];
         $model->content_id = $content_id;
         $model->type = $this->controller->_type_ids[$topic_type];
         $model->user_id = $uid;
         $model->status = 'N';
         $model->client_ip = Yii::app()->request->userHostAddress;
         $model->create_time = time();
         $ret_url = $_POST['ret_url'];
         if ($model->save()) {
             $this->controller->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url);
         }
     }
     $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies);
     $this->controller->render('create', $data);
 }
Example #17
0
     </div>
     <div>
         <?php $category = Category::model()->findByPk(9); ?>
         <h1>
         <?= CHtml::link(Yii::app()->language == 'ru' ? $category->title_ru : $category->title_uk, array('/site/category', 'alias'=>$category->alias)); ?></h1>
         <?php $news = News::model()->find(array('condition'=>'category_id = :category_id', 'order'=>'date DESC', 'params'=>array(':category_id'=>$category->id))); ?>
         <span>
             <?= CHtml::link(Yii::app()->language == 'ru' ? $news->title_ru : $news->title_uk, array('/site/news', 'id'=>$news->id)); ?>
         </span>
         <?= CHtml::link(Yii::t('main', 'Всі новини з категорії'), array('/site/category', 'alias'=>$category->alias)); ?>
     </div>
 </div>
 <div>
     <div>
         <h1><?= CHtml::link(Yii::t('main', 'Відеозаписи'), array('/site/videos')); ?></h1>
         <?php $news = Video::model()->find(array('order'=>'date DESC', 'condition'=>'category_id != :category_id', 'params'=>array(':category_id'=>11))); ?>
         <span>
             <?= CHtml::link(Yii::app()->language == 'ru' ? $news->title_ru : $news->title_uk, array('/site/videos', 'id'=>$news->id)); ?>
         </span>
         <?= CHtml::link(Yii::t('main', 'Всі новини з категорії'), array('/site/videos')); ?>
     </div>
     <div>
         <h1><?= CHtml::link(Yii::t('main', 'Фоторепортажі'), array('/site/photos')); ?></h1>
         <?php $news = PhotoCategory::model()->find(array('order'=>'date DESC')); ?>
         <span>
             <?= CHtml::link(Yii::app()->language == 'ru' ? $news->title_ru : $news->title_uk, array('/site/photos', 'id'=>$news->id)); ?>
         </span>
         <?= CHtml::link(Yii::t('main', 'Всі новини з категорії'), array('/site/photos')); ?>
     </div>
     <form action="#" class="forSubscribe">
     <div class="input-group">
Example #18
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'delete':
             //删除视频
             foreach ((array) $ids as $id) {
                 $postModel = Video::model()->findByPk($id);
                 if ($postModel) {
                     Uploader::deleteFile($postModel->cover_image);
                     $postModel->delete();
                 }
             }
             break;
         case 'show':
             //视频显示
             foreach ((array) $ids as $id) {
                 $postModel = Video::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'Y';
                     $postModel->save();
                 }
             }
             break;
         case 'hidden':
             //视频隐藏
             foreach ((array) $ids as $id) {
                 $postModel = Video::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'N';
                     $postModel->save();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
Example #19
0
 public function actionSubmitpaypal()
 {
     $paypal = new GetExpressCheckoutDetails();
     $details = $paypal->getResponse();
     //$totalPrice = urldecode($details['AMT']);
     $what = urldecode($details['CUSTOM']);
     $desc = urldecode($details["DESC"]);
     $cst = $details["CUSTOM"];
     $cst = explode("_", $cst);
     $type = $cst[2];
     $cst = $cst[1];
     $discount = $cst[3];
     if ($type == "basic") {
         $totalPrice = "19.95";
     } else {
         if ($type == "basicplus") {
             $totalPrice = "24.95";
         } else {
             if ($type == "pro") {
                 $totalPrice = "29.95";
             }
         }
     }
     $prorate = round($totalPrice * (((double) date('t') - (double) date('j')) / (double) date('t')), 2);
     $initAmt = $prorate + 0;
     // switch ($_SESSION["discount"]) {
     //     case 'MFVideoMgr-100':
     //         $prorate = $initAmt = 0;
     //         break;
     //     case 'MFVM-50A':
     //         $prorate = round((float)$prorate * 0.50, 2);
     //         $initAmt = round((float)$initAmt * 0.50, 2);
     //         break;
     //     case 'MFVM25':
     //         $prorate = round((float)$prorate * 0.25, 2);
     //         $initAmt = round((float)$initAmt * 0.25, 2);
     //         break;
     // }
     if (isset($_SESSION["discount"])) {
         Yii::import('admin.models.*');
         $coupon = Coupon::model()->findByAttributes(array('name' => $_SESSION["discount"]));
         if ($coupon) {
             if ($coupon->discount >= 100) {
                 //$initAmt = $initAmt - (2*$initAmt);
                 $prorate = 0.01;
                 $initAmt = 0.01;
             } else {
                 $prorate = $prorate - round((double) $prorate * ($coupon->discount / 100), 2);
                 $initAmt = $initAmt - round((double) $initAmt * ($coupon->discount / 100), 2);
             }
         }
     }
     $payment = new DoExpressCheckoutPayment($initAmt);
     $payment_response1 = $payment->getResponse();
     $recur = new CreateRecurringPaymentsProfile(ucfirst($type) . " Subscription for VidMgr, {$totalPrice} /mo", $totalPrice);
     // \n $0 One Time Setup Fee
     $recur->setNVP("SUBSCRIBERNAME", user()->Name);
     $recur->setNVP("PROFILEREFERENCE", "userid_" . uid() . "_" . $cst);
     $recur->setNVP("PROFILESTARTDATE", date("Y-m-d\\TH:i:s\\Z", mktime(0, 0, 0, date("m") + 1, 1, date("y"))));
     $recur->setNVP("MAXFAILEDPAYMENTS", "1");
     $recur->setNVP("BILLINGPERIOD", "Month");
     $recur->setNVP("BILLINGFREQUENCY", "1");
     $recur->setNVP("CURRENCYCODE", "USD");
     $recur->setNVP('L_PAYMENTREQUEST_0_NAME0', "Video Subscription - Basic 40MB");
     $recur->setNVP('L_PAYMENTREQUEST_0_ITEMCATEGORY0', 'Digital');
     $recur->setNVP('L_PAYMENTREQUEST_0_AMT0', $totalPrice);
     $recur->setNVP('L_PAYMENTREQUEST_0_QTY0', "1");
     $recur->setNVP("INITAMT", $initAmt);
     $payment_response = $recur->getResponse();
     Ytrace($payment_response);
     Ytrace($details);
     if ($payment_response["ACK"] == "Success" && $payment_response1["ACK"] == "Success") {
         Video::model()->updateByPk($cst, array("active" => "1", "lastPayment" => sqlDate(), "payModel" => $type));
         User::model()->updateByPk(uid(), array("payModel" => $type, "coupon" => ""));
         $this->process($cst, $type);
     } else {
         $this->renderText("There was some problem in processing your request. Please try again. If you repeatedly face this error please use the contact page, we would love to help you.");
     }
 }
Example #20
0
 /**
  * 提交评论
  *
  * @return [type] [description]
  */
 public function actionCreate()
 {
     $this->layout = false;
     $view_url = $this->_request->getParam('view_url');
     $topic_id = $this->_request->getParam('topic_id');
     $topic_type = $this->_request->getParam('topic_type');
     $cur_url = $this->_request->hostinfo . $this->_request->getUrl();
     $post = false;
     //评论类型
     switch ($topic_type) {
         case 'post':
             $post = Post::model()->findByPk($topic_id);
             break;
         case 'image':
             $post = Image::model()->findByPk($topic_id);
             break;
         case 'soft':
             $post = Soft::model()->findByPk($topic_id);
             break;
         case 'video':
             $post = Video::model()->findByPk($topic_id);
             break;
     }
     if (!$post) {
         throw new CHttpException(404, Yii::t('admin', 'Submit Error'));
         break;
     }
     //评论内容
     $model = new Comment('create');
     $criteria = new CDbCriteria();
     $condition = "topic_id={$topic_id} AND status='Y' AND type={$this->_type_ids[$topic_type]}";
     $criteria->condition = $condition;
     $criteria->order = 'id DESC';
     $criteria->select = "id, user_id, topic_id, content, create_time ";
     //分页
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $comments = $model->findAll($criteria);
     //回复
     if ($comments) {
         foreach ((array) $comments as $c) {
             $replies[$c->id] = Reply::model()->findAll('cid=:cid AND status=:status ORDER BY id', array(':cid' => $c->id, ':status' => 'Y'));
         }
     }
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/comment.css");
     Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     if ($this->_request->isPostRequest) {
         $uid = Yii::app()->user->id;
         if (!$uid) {
             $this->message('script', Yii::t('common', 'You Need Login'));
         }
         $model->attributes = $_POST['Comment'];
         $model->topic_id = $topic_id;
         $model->type = $this->_type_ids[$topic_type];
         $model->user_id = $uid;
         $model->status = 'N';
         $model->client_ip = $this->_request->userHostAddress;
         $model->create_time = time();
         $ret_url = $_POST['ret_url'];
         if ($model->save()) {
             $this->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url);
             //$this->redirect($ret_url);
         }
     }
     $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies);
     $this->render('create', $data);
 }
 public function actionShowform($id)
 {
     $data = explode('_', $id);
     $pack = Prices::model()->findByAttributes(array('genre_id' => $data[0], 'package' => $data[1], 'user_id' => Yii::app()->user->id));
     if (Yii::app()->user->role == 2) {
         //videooperator
         $title = Video::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'id' => $data[0]));
     } else {
         $title = Portfolio::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'id' => $data[0]));
     }
     if (is_object($pack)) {
         $html = '<form action="/my/prices/update/id/' . $pack->id . '" method="post">';
         $html .= '<script>
             $(document).ready(function() {
                 $("#price__price").keydown(function (e) {
                     // Allow: backspace, delete, tab, escape, enter and .
                     if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110]) !== -1 ||
                          // Allow: Ctrl+A
                         (e.keyCode == 65 && e.ctrlKey === true) || 
                          // Allow: home, end, left, right, down, up
                         (e.keyCode >= 35 && e.keyCode <= 40)) {
                              return;
                     }
                     // Ensure that it is a number and stop the keypress
                     if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
                         e.preventDefault();
                     }
                 });
             });
             </script>';
         $html .= '<div class="tooltip_cost_title">' . $title->title . '</div>
                 <label for="albom__name" class="tool_label" style="margin-top: 25px;">Цена</label>
                     <input type="text" name="Prices[price]" value="' . $pack->price . '" id="price__price" class="default__input search__hidden__input--city" maxlength="7" title="Это поле обязательно для заполнение" placeholder="500 грн" required="">
                 <label for="albom__name" class="tool_label">Описание</label>
                     <textarea name="Prices[about]" id="about__user" cols="25" rows="10" class="default__textarea" placeholder="Описание услуги:">' . $pack->about . '</textarea>
                     
                     <div class="col-12 text_center" style="margin-top: 25px;">
                         <div class="btn__group clfx">
                             <div class="col-179">                  
                                 <button type="button" class="t-cls cabinet__profile__btn" id="close_tip" onclick="closeTip(\'' . $id . '\')">ОТМЕНА</button>                  
                             </div>                  
                             <div class="col-179">                    
                                 <input type="hidden" name="Prices[user_id]" value="' . Yii::app()->user->id . '" />
                                 <input type="hidden" name="Prices[package]" value="' . $data[1] . '" />
                                 <input type="hidden" name="Prices[genre_id]" value="' . $data[0] . '" />
                                 <button type="submit" class="t-cls cabinet__profile__btn cabinet__profile__btn-submit">СОХРАНИТЬ</button>
                             </div>                
                         </div>            
               </div>
               </form>';
     } else {
         $html = '<form action="/my/prices/create/" method="post">';
         $html .= '<div class="tooltip_cost_title">' . $title->title . '</div>
                 <label for="albom__name" class="tool_label" style="margin-top: 25px;">Цена</label>
                     <input type="text" name="Prices[price]" id="albom__name" class="default__input search__hidden__input--city" title="Это поле обязательно для заполнение" placeholder="500 грн" required="">
                 <label for="albom__name" class="tool_label">Описание</label>
                     <textarea name="Prices[about]" id="about__user" cols="25" rows="10" class="default__textarea" placeholder="Описание услуги:"></textarea>
                     
                     <div class="col-12 text_center" style="margin-top: 25px;">
                         <div class="btn__group clfx">
                             <div class="col-179">                  
                                 <button type="button" class="t-cls cabinet__profile__btn" id="close_tip" onclick="closeTip(\'' . $id . '\')">ОТМЕНА</button>                  
                             </div>                  
                             <div class="col-179">                    
                                 <input type="hidden" name="Prices[user_id]" value="' . Yii::app()->user->id . '" />
                                 <input type="hidden" name="Prices[package]" value="' . $data[1] . '" />
                                 <input type="hidden" name="Prices[genre_id]" value="' . $data[0] . '" />
                                 <button type="submit" class="t-cls cabinet__profile__btn cabinet__profile__btn-submit">СОХРАНИТЬ</button>
                             </div>                
                         </div>            
               </div>
               </form>';
     }
     echo $html;
 }
Example #22
0
 public function actionViewVideo()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/flowplayer-3.2.11.min.js');
     $id = Yii::app()->request->getQuery('id');
     $video = Video::model()->findByPk($id);
     $this->render('video_view', array('video' => $video));
 }
Example #23
0
 public function getVedios($prod_id)
 {
     return Video::model()->findAll(array('condition' => 'program_id=:program_id and enable=:enable', 'order' => 'name,source_id DESC', 'params' => array(':program_id' => $prod_id, ':enable' => Constants::OBJECT_APPROVAL)));
 }
Example #24
0
 private function checkLocation($id)
 {
     $model = Video::model()->findByPk($id);
     $ip = $_SERVER['REMOTE_ADDR'];
     $loc = new IP2Location(Yii::getPathOfAlias('webroot') . '/IP2LOCATION-LITE-DB11.BIN');
     $record = $loc->lookup($ip, IP2Location::ALL);
     // echo 'Latitude: ' . $record->latitude . '<br />';
     //echo 'Longitude: ' . $record->longitude . '<br />';
     // print_r($record);
     //die();
     //$request_url = 'http://freegeoip.net/json/' . $ip;
     // $curl_connection = curl_init($request_url);
     // curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
     // //curl_setopt($curl_connection, CURLOPT_USERAGENT,
     // //    'Googlebot/2.1 (+http://www.google.com/bot.html)'
     // //);
     // curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
     // curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
     // $response = curl_exec($curl_connection);
     // curl_close($curl_connection);
     // $coords = json_decode($response);
     //$ip_addr = $_SERVER['REMOTE_ADDR'];
     // $geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip_addr) );
     // if ( is_numeric($geoplugin['geoplugin_latitude']) && is_numeric($geoplugin['geoplugin_longitude']) ) {
     // $lat = $geoplugin['geoplugin_latitude'];
     // $long = $geoplugin['geoplugin_longitude'];
     // }
     // echo $ip_addr.';'.$lat.';'.$long;
     $return_value = false;
     if (!empty($model->geolocations)) {
         if ($model->pal_all_location == 0) {
             foreach ($model->geolocations as $geo) {
                 $distance_between = $this->vincentyGreatCircleDistance($record->latitude, $record->longitude, $geo->latitude, $geo->longitude);
                 if ($distance_between <= $geo->distance) {
                     $return_value = true;
                 }
             }
         } else {
             foreach ($model->geolocations as $geo) {
                 $distance_between = $this->vincentyGreatCircleDistance($record->latitude, $record->longitude, $geo->latitude, $geo->longitude);
                 if ($distance_between > $geo->distance) {
                     $return_value = true;
                 }
             }
         }
     } else {
         $return_value = true;
     }
     return $return_value;
 }
 public function actionIndex()
 {
     $urls = array();
     // Actions
     $urls[] = $this->createUrl('actions/index');
     $actions = Actions::model()->findAll('t.picture != "" AND t.date_end <= ' . date('Y-m-d'));
     if (count($actions) > 0) {
         foreach ($actions as $action) {
             $urls[] = $this->createUrl('actions/view', array('id' => $action->id));
         }
     }
     // Tenders
     $urls[] = $this->createUrl('tenders/index');
     $tenders = Tenders::model()->findAll('t.date_end <= ' . date('Y-m-d'));
     if (count($tenders) > 0) {
         foreach ($tenders as $tender) {
             $urls[] = $this->createUrl('tenders/view', array('id' => $tender->id));
         }
     }
     // Freefoto
     $urls[] = $this->createUrl('freefoto/index');
     // Static Pages
     $urls[] = $this->createUrl('page/hmagent');
     $urls[] = $this->createUrl('page/advertisment');
     $urls[] = $this->createUrl('page/help_us');
     $urls[] = $this->createUrl('page/about');
     $urls[] = $this->createUrl('page/accounts');
     // News
     $urls[] = $this->createUrl('page/news');
     $news = News::model()->findAll('t.title != "" AND t.intro_text != ""');
     if (count($news) > 0) {
         foreach ($news as $item) {
             $urls[] = $this->createUrl('page/news', array('id' => $item->id));
         }
     }
     // Categories
     $cats = Occupation::model()->localized('ru')->findAll(array('condition' => 't.name!="" AND t.active=1', 'order' => 't.cat_id ASC'));
     if (count($cats) > 0) {
         foreach ($cats as $cat) {
             $urls[] = $this->createUrl('/cat/view', array('id' => 'c' . $cat->id . '_' . Settings::toLatin($cat->name)));
         }
     }
     // Users
     $users = Users::model()->findAll('t.name!="" AND t.activate=1');
     if (count($users) > 0) {
         foreach ($users as $user) {
             if ($user->filesCount >= 4 || $user->videosCount >= 4 || $user->floCount >= 4) {
                 $urls[] = '/id' . $user->id;
                 // Photo albums
                 if ($user->occupation_id == 1) {
                     $alb = Portfolio::model()->findAllByAttributes(array('uid' => $user->id, 'visible' => 1));
                     if (count($alb) > 0) {
                         foreach ($alb as $item) {
                             if ($item->filesCount > 0) {
                                 $urls[] = $this->createUrl('user/album', array('id' => $item->id));
                             }
                         }
                     }
                 }
                 // Video albums
                 if ($user->occupation_id == 2) {
                     $vid = Video::model()->findAllByAttributes(array('uid' => $user->id, 'visible' => 1));
                     if (count($vid) > 0) {
                         foreach ($vid as $item) {
                             if ($item->filesCount > 0) {
                                 $urls[] = $this->createUrl('user/videoalbum', array('id' => $item->id));
                             }
                         }
                     }
                 }
             }
         }
     }
     // Photo albums
     $users_alb = Users::model()->findAll('t.name!="" AND t.activate=1 AND t.occupation_id=1');
     if (count($users_alb) > 0) {
         foreach ($users_alb as $user_alb) {
             if ($user_alb->filesCount >= 4 || $user->videosCount >= 4 || $user->floCount >= 4) {
                 $urls[] = '/id' . $user->id;
             }
         }
     }
     /*// Страницы
             $pages = Page::model()->findAll(array(
                 'condition' => 't.public = 1';
             ));
             foreach ($posts as $page){
                 $urls[] = $this->createUrl('page/view', array('alias'=>$page->alias));
             }
      
             // Новости
             $news = News::model()->findAll(array(
                 'condition' => 't.public = 1';
             ));
             foreach ($news as $new){
                 $urls[] = $this->createUrl('news/view', array('id'=>$new->id));
             }
      
             // Работы портфолио
             $works = Work::model()->findAll(array(
                 'condition' => 't.public = 1';
             ));
             foreach ($works as $work){
                 $urls[] = $this->createUrl('work/view', array('id'=>$work->id));
             }
      
             // Товары
             $products = Product::model()->findAll(array(
                 'condition' => 't.public = 1 AND t.count > 0';
             ));
             foreach ($products as $product){
                 $urls[] = $this->createUrl('product/view', array('category'=>$product->category->alias, 'id'=>$product->id));
             }
      
             // ...*/
     $host = Yii::app()->request->hostInfo;
     echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     echo '<url>
             <loc>' . $host . '</loc>
             <changefreq>daily</changefreq>
             <priority>0.5</priority>
         </url>';
     if (count($urls) > 0) {
         foreach ($urls as $url) {
             echo '<url>
                 <loc>' . $host . $url . '</loc>
                 <changefreq>daily</changefreq>
                 <priority>0.5</priority>
             </url>';
         }
     }
     echo '</urlset>';
     Yii::app()->end();
 }
 public function actionVideo()
 {
     /*$model=Portfolio::model()->findAllByAttributes(array('uid'=>Yii::app()->user->id));
       
       $dataProvider=new CActiveDataProvider('Files',array(
           'criteria'=>array(
               'order'=>'id desc',
               'condition'=>'uid='.Yii::app()->user->id.' AND source="portfolio" AND type="video"',
           )
       ));
       $this->render('video',array(
           'dataProvider'=>$dataProvider,
           'user'=>Users::model()->findByPk(Yii::app()->user->id),
       ));*/
     $model = Video::model()->findAllByAttributes(array('uid' => Yii::app()->user->id));
     $this->render('index_video', array('model' => $model, 'user' => $usr));
 }
Example #27
0
<main class="cabinet__portfolio">
        <table class="cost-table">
          <tr>
            <th>Название услуги</th>
            <th>Пакет 1 (грн.)</th>
            <th>Пакет 2 (грн.)</th>
            <th>Пакет 3 (грн.)</th>
            <th>Пакет 4 (грн.)</th>
            <th>Пакет 5 (грн.)</th>
          </tr>
          <?php 
//$genres=unserialize($user->genre_id);
//print_r($genres); exit();
if ($user->occupation_id == 2) {
    //videooperator
    $genres = Video::model()->findAllByAttributes(array('uid' => $user->id));
} else {
    $genres = Portfolio::model()->findAllByAttributes(array('uid' => $user->id));
}
foreach ($genres as $val) {
    if ($user->occupation_id == 2) {
        $cnt_files = Files::model()->countByAttributes(array('uid' => $user->id, 'type' => 'video', 'portfolio_id' => $val->id));
    } else {
        $cnt_files = Files::model()->countByAttributes(array('uid' => $user->id, 'type' => 'photo', 'portfolio_id' => $val->id));
    }
    if ($cnt_files > 0) {
        echo '<tr>
                        <td>' . $val->title . '</td>';
        //$pack1=Prices::model()->findByAttributes(array('price'),'genre_id=:gen and package=1',array(':gen'=>$val));
        $pack1 = Prices::model()->findByAttributes(array('genre_id' => $val->id, 'package' => 1));
        if (is_object($pack1)) {
Example #28
0
 public function actionCheckemail()
 {
     /*echo CController::createAbsoluteUrl('user/verify', array(
               'key' => "LL",
               'email' => "LL"
           ));
       //sendMail('*****@*****.**', "tesWWt", "just a test");*/
     $model = Video::model()->findByPk(4);
     disp($model->details);
 }
Example #29
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $video = Video::model()->with('url', 'proveedorVideo', 'albumVideo')->findByPk($id);
     if (isset($_POST['Video'])) {
         $nombre = $video->nombre;
         $video->attributes = $_POST['Video'];
         if ($video->save()) {
             Yii::app()->user->setFlash('success', 'Video ' . $video->nombre . ' guardado con éxito');
             $this->redirect(array('view', 'id' => $video->id));
         }
     }
     //if(isset($_POST['NovedadesForm']))
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $this->render('modificar', array('model' => $video));
 }
 /**
  *
  * 视频下载
  * 
  */
 public function actionDownload($id)
 {
     $video = Video::model()->findByPk($id);
     if ($video) {
         $file = Upload::model()->findByPk($video->fileid);
         if ($file && file_exists($file->file_name)) {
             //更新下载次数
             $video->updateCounters(array('down_count' => 1), 'id=:id', array('id' => $id));
             //开始下载
             Yii::app()->request->sendFile($soft->title . '.' . $file->file_ext, file_get_contents($file->file_name));
             exit;
         } else {
             $this->message('error', Yii::t('common', 'Source Is Not Found'), $this->createUrl('video/view', array('id' => $id)));
         }
     } else {
         $this->message('error', Yii::t('common', 'Source Is Not Found'), $this->createUrl('video/view', array('id' => $id)));
     }
 }