Exemple #1
0
 public static function getBannerURL($cid, $banner_directory = "")
 {
     $user = User::findOrFail($cid);
     //Remove trailing slash, if present, and readd.
     if (empty($banner_directory)) {
         $banner_directory = rtrim(Setting::fetch('banner_directory'), '/') . '/';
     }
     //Add the current file update time to the end of the image link so that the browser will not cache the image if it is newer then what is previously loaded.
     $bannerurl = URL::to('/') . $banner_directory . $user->banner . '?last_picture_update=' . filemtime(public_path() . $banner_directory . $user->banner);
     return $bannerurl;
 }
Exemple #2
0
 public function post_uploadbanner()
 {
     //Verify we have a file
     if (Input::hasFile('inputBanner')) {
         //Get our file
         $banner = Input::file('inputBanner');
         //Create an array of acceptable mimetypes
         $mimetypes = array('image/jpeg', 'image/png');
         if (in_array($banner->getMimeType(), $mimetypes)) {
             switch ($banner->getMimeType()) {
                 case 'image/jpeg':
                     $extension = ".jpg";
                     break;
                 case 'image/png':
                     $extension = ".png";
                     break;
             }
             //Get our image height min and max
             $maxheight = Setting::fetch('banner_maxheight');
             $maxwidth = Setting::fetch('banner_maxwidth');
             list($width, $height) = getimagesize($banner);
             //Is the width or height larger than the max?
             if ($width > $maxwidth || $height > $maxheight) {
                 App::abort(400, 'Image is larger than the max width: ' . $maxwidth . 'px or max height: ' . $maxheight . 'px');
             }
             //Mime check passed continue to move the image from tmp directory to /banners
             $destinationPath = public_path() . Setting::fetch('banner_directory');
             $fileName = Auth::user()->get()->cid . $extension;
             $banner->move($destinationPath, $fileName);
             //Finally update the db with the new banner name.
             $va = User::where('cid', '=', Auth::user()->get()->cid)->first();
             $va->banner = $fileName;
             $va->save();
             //Redirect the user back to the banner page
             return Redirect::to(route('va') . '#banner');
         } else {
             //Time to abort.
             App::abort(400, 'Invalid file type.');
         }
     }
 }
Exemple #3
0
 public function post_searchvas()
 {
     $query = Input::get('query');
     $vas = User::where('status', '=', 1)->where(function ($q) use($query) {
         $q->where('vaname', 'like', '%' . $query . '%')->orWhere('description', 'like', '%' . $query . '%')->orWhere('url', 'like', '%' . $query . '%')->orWhere('url', 'like', '%' . $query . '%');
     })->orderBy('vaname', 'ASC')->get();
     if (count($vas) == 0 || empty($query) || $query == " ") {
         echo '<h4>No Virtual Airlines Found.</h4>';
     } else {
         $maxwidth = Setting::fetch('banner_maxwidth');
         $banner_directory = rtrim(Setting::fetch('banner_directory'), '/') . '/';
         $output = '';
         foreach ($vas as $va) {
             $va->description = html_entity_decode($va->description);
             $va->vaname = html_entity_decode($va->vaname);
             $va->url = html_entity_decode($va->url);
             $banner = '';
             if ($va->banner) {
                 $banner = User::getBannerUrl($va->cid, $banner_directory);
                 $output .= '<div class="bannerbg"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><img style="max-width:' . $maxwidth . ';" class="img-polaroid" src="' . $banner . '" alt="Banner" /></a></div><div class="well"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><h4>' . $va->vaname . '</h4></a><blockquote style="margin-top: 4px;">' . $va->description . '</blockquote></div>';
             } else {
                 $output .= '<div class="well"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><h4>' . $va->vaname . '</h4></a><blockquote style="margin-top: 4px;">' . $va->description . '</blockquote></div>';
             }
         }
         echo $output;
     }
 }
 public function post_vapubliccategoriessave()
 {
     $cid = Input::get('cid');
     $user = User::findOrFail($cid);
     $categories = Input::get('categories');
     if (empty($categories)) {
         $categories = '';
     }
     //F**k it. Let's just start the validator
     $validator = Validator::make(array('categories' => $categories), array('categories' => 'max: ' . Setting::fetch('max_categories')), array('categories.max' => 'You have selected more than :max categories.'));
     if ($validator->fails()) {
         // The given data did not pass validation
         $messages = $validator->messages();
         $errorStr = '';
         foreach ($messages->all('<li>:message</li>') as $message) {
             $errorStr .= $message;
         }
         return Redirect::to('console/va/' . $cid . '#categories')->with('message', $errorStr);
     }
     //We need to check and see if any hidden categories are currently included in the categories string and add them to our new string if so
     $currentCategories = explode(',', $user->categories);
     array_pop($currentCategories);
     //Get a list of hidden categories
     $appendlist = '';
     foreach ($currentCategories as $currentCategory) {
         if (Category::isHiddenCategory($currentCategory)) {
             $appendlist .= $currentCategory . ',';
         }
     }
     $categories = implode(',', $categories);
     $categories .= ',' . $appendlist;
     $user->categories = $categories;
     $user->save();
     return Redirect::to('console/va/' . $cid . '#categories')->with('message', 'Public Categories Saved Successfully.');
 }