예제 #1
0
 public function getLogout()
 {
     HelperClassified::save_return_url();
     try {
         Auth::logout();
     } catch (Exception $e) {
         throw $e;
         return false;
     }
     return Redirect::to(HelperClassified::redirect_return_url());
 }
예제 #2
0
 public static function save_tag($data = array())
 {
     $default = array('ad_id' => '0', 'tag_ids' => '', 'city_tag' => '', 'state_tag' => '');
     $merge = array_merge($default, $data);
     $merge = \DLNLab\Classified\Classes\HelperClassified::trim_value($merge);
     extract($merge);
     if (!$ad_id) {
         return false;
     }
     $arr_tag_ids = array();
     // Find city tag
     if ($city_tag) {
         $id = self::add_location_tag($city_tag, 'city');
         if ($id) {
             $arr_tag_ids[] = array('ad_id' => $ad_id, 'tag_id' => $id);
         }
     }
     // Find state tag
     if ($state_tag) {
         $id = self::add_location_tag($state_tag, 'state');
         if ($id) {
             $arr_tag_ids[] = array('ad_id' => $ad_id, 'tag_id' => $id);
         }
     }
     $tag_ids = explode(',', $tag_ids);
     if ($tag_ids) {
         $cache_ids = array();
         foreach ($tag_ids as $id) {
             if (!in_array($id, $cache_ids)) {
                 $cache_ids[] = $id;
                 $arr_tag_ids[] = array('ad_id' => $ad_id, 'tag_id' => $id);
             }
         }
     }
     if (count($arr_tag_ids)) {
         $records = DB::table('dlnlab_classified_ads_tags')->where('ad_id', '=', $ad_id)->delete();
         DB::table('dlnlab_classified_ads_tags')->insert($arr_tag_ids);
     }
     return true;
 }
예제 #3
0
 public function postBitlyLink()
 {
     if (!Auth::check()) {
         return Response::json(array('status' => 'error', 'message' => trans(CLF_LANG_MESSAGE . 'require_signin')), 500);
     }
     $message = 'Success';
     $code = 200;
     $data = post();
     $default = array('link' => '');
     $merge = array_merge($default, $data);
     $merge = \DLNLab\Classified\Classes\HelperClassified::trim_value($merge);
     extract($merge);
     if ($link) {
         $md5 = md5($link);
         $record = Bitly::where('md5', '=', $md5)->first();
         if (!$record) {
             $record = new Bitly();
             $record->md5 = $md5;
             $record->link = $link;
             $record->save();
         }
     }
     return Response::json($record);
 }
예제 #4
0
 public function getAdAroundState($ad_id)
 {
     $data = get();
     $default = array('page' => 0, 'state_id' => 0);
     $merge = array_merge($default, $data);
     $merge = \DLNLab\Classified\Classes\HelperClassified::trim_value($merge);
     extract($merge);
     $records = Ad::getAdAroundState($state_id, $ad_id, $page);
     return Response::json(array('status' => 'success', 'data' => $records));
 }
예제 #5
0
파일: Ad.php 프로젝트: httvncoder/151722441
 public static function gen_auto_ad_name($data)
 {
     $default = array('type_id' => '', 'category_id' => '', 'price' => '');
     $merge = array_merge($default, $data);
     $merge = \DLNLab\Classified\Classes\HelperClassified::trim_value($merge);
     extract($merge);
     $kind = '';
     $types = HelperCache::getAdType();
     foreach ($types as $id => $type) {
         if ($id == $type_id) {
             $kind = $type;
         }
     }
     $category = HelperCache::findAdCategoryById($category_id);
     $ad_name = ucfirst($kind);
     $ad_name .= ' ' . mb_strtolower($category->name);
     $ad_name .= ' giá ' . mb_strtolower($price) . ' đồng';
     return $ad_name;
 }
예제 #6
0
 public function postFeedFB()
 {
     if (!Auth::check()) {
         return Response::json(array('status' => 'error', 'message' => trans(CLF_LANG_MESSAGE . 'require_signin')), 500);
     }
     $data = post();
     $default = array('ad_id' => '', 'type' => '', 'link' => '', 'message' => '');
     $merge = array_merge($default, $data);
     $merge = \DLNLab\Classified\Classes\HelperClassified::trim_value($merge);
     extract($merge);
     // Get access token
     $user_id = Auth::getUser()->id;
     $record = UserAccessToken::valid_access_token($user_id, 'facebook');
     if (empty($record) || empty($record->access_token)) {
         return Response::json(array('status' => 'error'), 500);
     }
     $access_token = $record->access_token;
     $check = UserAccessToken::check_fb_access_token($access_token);
     if (!$check) {
         return Response::json(array('status' => 'error'), 500);
     }
     $fb_user_id = $check->user_id;
     $record = null;
     if ($fb_user_id) {
         $postdata = http_build_query(array('access_token' => $access_token, 'message' => $message, 'link' => $link, 'privacy' => array('value' => 'EVERYONE')));
         $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
         $context = stream_context_create($opts);
         $obj = json_decode(@file_get_contents(self::$graph . $fb_user_id . '/feed', false, $context));
         if (!empty($obj->id)) {
             $user_id = Auth::getUser()->id;
             $record = new AdShare();
             $record->ad_id = $ad_id;
             $record->user_id = $user_id;
             $record->link = $link;
             $record->md5 = md5($link);
             $record->share_id = $obj->id;
             $record->save();
         }
     }
     return Response::json($record);
 }