public function getCacheBasic() { $data = get(); $default = array('clear_cache' => 0); extract(array_merge($default, $data)); $cache_id = 'dln_category'; if (!empty($clear_cache)) { Cache::forget($cache_id); } if (!Cache::has($cache_id)) { $category = FbCategory::where('status', '=', true)->select(DB::raw('id, name, description'))->orderBy('name', 'ASC')->get()->toArray(); Cache::put($cache_id, json_encode($category), DLN_CACHE_CATEGORY); } else { $category = json_decode(Cache::get($cache_id)); } $cache_id = 'dln_pages'; if (!empty($clear_cache)) { Cache::forget($cache_id); } if (!Cache::has($cache_id)) { $page = FbPage::where('status', '=', true)->select(DB::raw('id, name, fb_id, category_id, like_count, talking_about'))->orderBy('like_count', 'DESC')->get()->toArray(); Cache::put($cache_id, json_encode($page), DLN_CACHE_PAGE); } else { $page = json_decode(Cache::get($cache_id)); } $result = new \stdClass(); $result->category = $category; $result->page = $page; return Response::json(array('status' => 'success', 'data' => $result), 200); }
public function getSearchPage() { $data = get(); $default = array('q' => ''); extract(array_merge($default, $data)); if (empty($q)) { return Response::json(array('status' => 'error', 'data' => 'Error'), 500); } $result = FbPage::search_fb_pages($q); return Response::json(array('status' => 'success', 'data' => $result), 200); }
public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $reportId) { if (!($record = FbPageModel::find($reportId))) { continue; } $record->delete(); } Flash::success('Successfully deleted those reports.'); } return $this->listRefresh(); }
public function getSpamCommentPage() { $record = FbPage::whereRaw('status = ? AND crawl_fb = ?', array(true, false))->first(); if (!$record) { FbPage::where('crawl_fb', '=', true)->update(['crawl_fb' => false]); $record = FbPage::whereRaw('status = ? AND crawl_fb = ?', array(true, false))->first(); } if (!empty($record->fb_id)) { // Get post of current page //$records = FbFeed::whereRaw('status = ? AND page_id = ? AND per_day = CURDATE() AND comment_count > ? AND type = ? AND spam IS NULL', [true, $record->id, LIMIT_COMMENT_COUNT, 'link', null]) $feeds = FbFeed::whereRaw('status = ? AND page_id = ? AND DATE(created_at) = CURDATE() AND comment_count > ? AND type = ? AND spam IS NULL', [true, $record->id, LIMIT_COMMENT_COUNT, 'link'])->select(DB::raw('id, fb_id, fb_link, name, message, picture, page_id, category_id, like_count, comment_count, share_count, type, source, object_id, created_at, DATE(created_at) AS per_day'))->orderBy('per_day', 'DESC')->orderBy('comment_count', 'DESC')->take(10)->get(); if (count($feeds) >= 4) { // Get hot news //$feeds = FbFeed::getHotFeeds($record->id, 2); /*if (count($feeds)) { foreach ( $records as $record ) { if ($record->fb_id != ) { HelperNews::postCommentToFB($record->fb_id, $record->link, $record->name); } } }*/ $last = count($feeds) - 1; if ($last >= 1) { foreach ($feeds as $i => $feed) { if ($last - $i != $i) { $feed->spam = HelperNews::postCommentToFB($feed->fb_id, $feeds[$last - $i]->fb_link, $feeds[$last - $i]->name); $feed->save(); $record->crawl_fb = true; $record->save(); } } } } } return Response::json(array('status' => 'success', 'data' => $feeds), 200); }
public function run() { $timestamp = \Carbon\Carbon::now()->toDateTimeString(); FbCategory::insert([['name' => 'Hài vui', 'slug' => 'hai-vui', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['name' => 'Girl xinh', 'slug' => 'girl-xinh', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['name' => 'Tin tức', 'slug' => 'tin-tuc', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['name' => 'Bóng đá', 'slug' => 'bong-da', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp]]); FbPage::insert([['fb_id' => '755038977864672', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '487998621317746', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '232665283585847', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '506318469450579', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '383923618322771', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '178077709031664', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp]]); }
public function getPageOptions() { return FbPage::getNameList(); }