Example #1
0
 public static function gifts()
 {
     $gifts = Gift::orderBy('created_at', 'desc')->get();
     foreach ($gifts as $gift) {
         $url = GiftPoster::where('gift_id', '=', $gift->id)->first()->url;
         $gift->img = StaticController::imageWH($url);
     }
     return $gifts;
 }
Example #2
0
 public function home()
 {
     $scroll_imgs = ScrollImg::all();
     //话题
     $topics = Topic::where('topic_url', '!=', '')->orderBy('created_at', 'desc')->get();
     $topics = StaticController::page(12, 1, $topics);
     //每日推荐
     $daily = Poster::where('daily_id', '=', 1)->get();
     //每日推
     $daily = StaticController::page(16, 1, $daily);
     // $user = Sentry::findUserById(4);
     // Sentry::login($user,false);
     // Sentry::logout();
     if (Sentry::check()) {
         foreach ($daily as $recommend) {
             $gift = Gift::find($recommend->info_url);
             $recommend->title = $gift->title;
             $recommend->price = $gift->price;
             $recommend->taobao_url = $gift->taobao_url;
             $gift_focus = GiftFocus::where('gift_id', '=', $recommend->info_url)->where('user_id', '=', Sentry::getUser()->id)->first();
             /* 2015-09-16 hyy fix */
             if (isset($gift_focus)) {
                 $recommend->focus = 1;
             } else {
                 $recommend->focus = 0;
             }
         }
     } else {
         foreach ($daily as $recommend) {
             $gift = Gift::find($recommend->info_url);
             $recommend->title = $gift->title;
             $recommend->price = $gift->price;
             $recommend->taobao_url = $gift->taobao_url;
             $recommend->focus = 0;
         }
     }
     //精选话题
     $articles = DB::table('articles')->orderBy('focus_num', 'desc')->get();
     $articles = StaticController::page(12, 1, $articles);
     if ($articles) {
         foreach ($articles as $article) {
             $article_url = ArticlePart::where('article_id', '=', $article->id)->where('type', '=', 'url')->first();
             // dd($article_url->content);
             if (isset($article)) {
                 $article->url = $article_url->content;
             } else {
                 $article->url = null;
             }
         }
     }
     return View::make('pc.home')->with(array('topics' => $topics, 'gifts' => $daily, 'articles' => $articles, 'scroll_imgs' => $scroll_imgs));
 }
Example #3
0
 public function accessToken()
 {
     if (Sentry::check()) {
         return Redirect::to('/home')->with(array('user' => Sentry::getUser()));
     }
     // Session::put('code', Input::get('code'));
     $code = Input::get('code');
     $data = $this->getAccessTokenByCode($code);
     $data = StaticController::stringToArray($data);
     $access_token = $data['access_token'];
     $refresh_token = $data['refresh_token'];
     $data_of_openid = $this->getOpenidByAccessToken($access_token);
     $openid = $this->getOpenidFromString($data_of_openid);
     $user = User::where('qq_id', '=', $openid)->first();
     if (!isset($user)) {
         // try{
         $user = $this->getUserInfoByOpenid($access_token, $openid);
         $client_user = Sentry::createUser(array('username' => $user['nickname'], 'avatar' => $user['figureurl'], 'gender' => $user['gender'], 'email' => $openid, 'password' => $openid, 'qq_id' => $openid, 'activated' => '1'));
         // }
         // catch(Cartalyst\Sentry\Users\PasswordRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserExistsException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // try{
         $user = Sentry::findUserById($client_user->id);
         Sentry::login($user, false);
         // }
         // catch(Cartalyst\Sentry\Users\LoginRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotFoundException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotActivatedException $e)
         // {
         //     return View::make('errors.missing')
         // }
         return Redirect::to('/home')->with(array('user' => $user));
     }
     $user = Sentry::findUserById($user->id);
     Sentry::login($user, false);
     return Redirect::to('/home')->with(array('user' => $user));
 }
Example #4
0
 public function brefOffical()
 {
     if (!Sentry::check()) {
         return Response::json(array('errCode' => 10, 'message' => '请登录'));
     }
     $user = Sentry::getUser();
     // $user = User::find(5);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $officals = OfficalUser::where('user_id', '=', $user->id)->where('is_delete', '=', 0)->get();
     //总页数
     $total = ceil(count($officals) / $per_page);
     //排序
     $officals = StaticController::arraySortByCreatedAt($officals->toArray());
     //分页
     $officals = StaticController::page($per_page, $page, $officals);
     //总页数
     return Response::json(array('errCode' => 0, 'message' => '返回官方简讯', 'officals' => $officals, 'total' => $total));
 }
Example #5
0
 public function selectByLabel()
 {
     $inputs = array('char_id' => Input::get('_char'), 'scene_id' => Input::get('scene'), 'object_id' => Input::get('object'), 'price_id' => Input::get('price'));
     // dd($inputs['object_id']);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $inputs = array_filter($inputs);
     // dd(count($inputs));
     $query = null;
     // dd($inputs['price_id']);
     foreach ($inputs as $key => $value) {
         if ($query != null) {
             $query = $query->where($key, $value);
         } else {
             $query = Gift::where($key, $value);
         }
     }
     if ($query == null) {
         // dd(count($gifts));
         //标签没有的情况
         // $gifts = StaticController::gifts();
         $gifts = Gift::orderBy('created_at', 'desc')->get();
         $total = ceil(count($gifts) / $per_page);
         $gifts = StaticController::page($per_page, $page, $gifts);
         $gifts = $this->addGiftImg($gifts);
         return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部', 'gifts' => $gifts, 'total' => $total));
     }
     $gifts = $query->get();
     if (count($gifts) == 0) {
         // $gifts = StaticController::gifts();
         $gifts = Gift::orderBy('created_at', 'desc')->get();
         $total = ceil(count($gifts) / $per_page);
         $gifts = StaticController::page($per_page, $page, $gifts);
         $gifts = $this->addGiftImg($gifts);
         return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部', 'gifts' => $gifts, 'total' => $total));
     }
     $total = ceil(count($gifts) / $per_page);
     $gifts = StaticController::page($per_page, $page, $gifts);
     $gifts = $this->addGiftImg($gifts);
     return Response::json(array('errCode' => 0, 'message' => '返回搜索数据', 'gifts' => $gifts, 'total' => $total));
 }
Example #6
0
 public function giftAjax()
 {
     // if(!Sentry::check())
     // 	return Response::json(array('errCode'=>1, 'message'=>'请登录'));
     // $user = Sentry::getUser();
     $user = User::find(1);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $gift_focus = DB::table('gift_focus')->where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->get();
     //总页数
     $total = ceil(count($gift_focus) / $per_page);
     // dd($total);
     //喜欢的礼品
     $focus = StaticController::page($per_page, $page, $gift_focus);
     // dd(count($focus));
     $gifts = array();
     if ($focus) {
         foreach ($focus as $gift) {
             array_push($gifts, Gift::find($gift->gift_id));
         }
         foreach ($gifts as $candy) {
             $url = GiftPoster::where('gift_id', '=', $candy->id)->first()->url;
             $candy->img = StaticController::imageWH($url);
         }
     }
     return Response::json(array('errCode' => 0, 'message' => '返回用户喜欢的礼品', 'gifts' => $gifts, 'total' => $total));
 }
Example #7
0
 public function involve()
 {
     //参与话题内容
     $join_id = Input::get('join_id');
     $article_join = ArticleJoin::find($join_id);
     if (!isset($article_join)) {
         return Response::json(array('errCode' => 1, 'message' => '没有该参与话题内容!'));
     }
     $article_join_parts = ArticleJoinPart::where('join_id', '=', $join_id)->orderBy('id', 'asc')->get();
     foreach ($article_join_parts as $part) {
         if ($part->type == 'url') {
             $part->img = StaticController::imageWH($part->content);
         }
     }
     //评论内容
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $join_coms = ArticleJoinCom::where('join_id', '=', $join_id)->with(['replies' => function ($query) {
         $query->select('com_id', 'content', 'sender_id')->orderBy('id', 'asc');
     }, 'sender' => function ($query) {
         $query->select('id', 'username', 'avatar');
     }, 'replies.sender' => function ($query) {
         $query->select('id', 'username');
     }])->get();
     foreach ($join_coms as $join_com) {
         $user = $join_com->sender;
         $join_com->username = $user->username;
         $join_com->avatar = $user->avatar;
         $join_com->replys = $join_com->replies;
         if (count($join_com->replys) != 0) {
             foreach ($join_com->replys as $reply) {
                 // dd($reply);
                 $reply->reply_name = $reply->sender->username;
                 unset($reply->sender);
             }
         }
         unset($join_com->replies);
         unset($join_com->sender);
     }
     // //总页数
     $total = ceil(count($join_coms) / $per_page);
     // //文章
     $join_coms = StaticController::page($per_page, $page, $join_coms);
     // $join_coms = DB::table('article_join_coms')->where('join_id', '=', $join_id)->get();
     // //总页数
     // $total = ceil(count($join_coms)/$per_page);
     // //文章
     // $join_coms = StaticController::page($per_page,$page,$join_coms);
     // if( $join_coms )
     // {
     // 	foreach($join_coms as $join_com)
     // 	{
     // 		$join_com->username = User::find($join_com->sender_id)->username;
     // 		$join_com->avatar = User::find($join_com->sender_id)->avatar;
     // 		$join_com->replys = ArticleJoinReply::where('com_id', '=', $join_com->id)->orderBy('id','asc')->get();
     // 		if(count($join_com->replys)!=0)
     // 		{
     // 			foreach($join_com->replys as $reply)
     // 			{
     // 				$reply->reply_name = User::find($reply->sender_id)->username;
     // 			}
     // 		}
     // 	}
     // }
     //是否喜欢
     $type = $this->isJoinLike($join_id);
     if ($page == 1) {
         return Response::json(array('errCode' => 0, 'message' => '返回参与话题详情', 'article_join' => $article_join, 'article_join_parts' => $article_join_parts, 'join_coms' => $join_coms, 'total' => $total, 'type' => $type));
     } else {
         return Response::json(array('errCode' => 0, 'message' => '返回参与话题详情', 'join_coms' => $join_coms, 'total' => $total, 'type' => $type));
     }
 }
Example #8
0
 function __construct($merge = false)
 {
     parent::__construct($merge);
 }
Example #9
0
<div class="nextUpdate">
    <?php 
if ($this->beginCache('servBackend', array('varyByExpression' => Yii::app()->request->cookies['language']->value, 'duration' => $this->getFConfig('serverCache') - 120, 'varyByRoute' => false))) {
    ?>
        <ul>
            <li><?php 
    echo $this->getFConfig('serverName');
    ?>
</li>
            <li><?php 
    echo MEMBSTAT::getOnline() + $this->getFConfig('serverFOnline');
    ?>
</li>
        </ul>
        <div class="pWrapper"><div class="progress<?php 
    echo StaticController::getSOnline();
    ?>
" style="width: 100%;"></div></div>
    <?php 
    $this->endCache();
}
?>
</div>
Example #10
0
 public function topic()
 {
     $topic_id = Input::get('topic_id');
     $topic = Topic::find($topic_id);
     if (!isset($topic)) {
         if (Request::wantsJson()) {
             return Response::json(array('errCode' => 1, 'message' => 该专题不存在));
         } else {
             return Response::view('errors.missing');
         }
     }
     $gifts = Gift::where('topic_id', '=', $topic->id)->get();
     if (isset($gifts)) {
         $number = 1;
         foreach ($gifts as $gift) {
             $url = GiftPoster::where('gift_id', '=', $gift->id)->first()->url;
             $gift->img = StaticController::imageWH($url);
             $gift->number = $number++;
         }
     }
     $gifts = $this->isGiftLike($gifts);
     $type = $this->isTopicLike($topic_id);
     if (Request::wantsJson()) {
         return Response::json(array('errCode' => 0, 'message' => '返回专题页数据', 'topic' => $topic, 'gifts' => $gifts, 'type' => $type));
     }
     return View::make('index/goodsList')->with(array('topic' => $topic, 'gifts' => $gifts, 'type' => $type));
 }
Example #11
0
}
/**
 * Load the configuration file
 */
require_once BASE_DIR . 'configs/config.php';
/**
 * Load global functions related to localization
 */
require_once BASE_DIR . "/lib/locale_functions.php";
/**
 * Used to set-up static error pages
 */
require_once BASE_DIR . "/controllers/static_controller.php";
mb_internal_encoding("UTF-8");
mb_regex_encoding("UTF-8");
$locale_tag = guessLocale();
$locale = NULL;
setLocaleObject($locale_tag);
if (!isset($_REQUEST['p']) || !in_array($_REQUEST['p'], array("404", "409"))) {
    $_REQUEST['p'] = "404";
}
switch ($_REQUEST['p']) {
    case "404":
        header("HTTP/1.0 404 Not Found");
        break;
    case "409":
        header("HTTP/1.0 409 Conflict");
        break;
}
$controller = new StaticController();
$controller->processRequest();
Example #12
0
 if (preg_match('/^(' . join('|', array_keys(Core::$config['cities'])) . ')\\/(|\\?.*)$/Uu', $url, $matches)) {
     require_once 'SearchController.php';
     $controller = new SearchController();
     $controller->setCity($matches[1]);
     echo $controller->actions();
     die;
 }
 if (preg_match('/^faq\\/(|\\?.*)$/Uu', $url, $matches)) {
     require_once 'QaController.php';
     $controller = new QaController();
     echo $controller->actions();
     die;
 }
 if (preg_match('/^about\\/(|\\?.*)$/Uu', $url, $matches)) {
     require_once 'StaticController.php';
     $controller = new StaticController('about');
     echo $controller->actions();
     die;
 }
 if (preg_match('/^feedback\\/(|\\?.*)$/Uu', $url, $matches)) {
     require_once 'FeedbackController.php';
     $controller = new FeedbackController();
     echo $controller->actions();
     die;
 }
 if (preg_match('/^(|\\?.*)$/Uu', $url, $matches)) {
     require_once 'IndexController.php';
     $controller = new IndexController();
     echo $controller->actions();
     die;
 }