Esempio n. 1
0
 public function getImages($option = array())
 {
     $images = Image::where("album_id", $this->id)->get();
     if (!empty($option['width'])) {
         foreach ($images as $index => $image) {
             $width = getimagesize(public_path() . "/" . $image->path)[0];
             if ($width > $option['width']) {
                 $images->forget($index);
             }
         }
     }
     if (!empty($option['height'])) {
         foreach ($images as $index => $image) {
             $height = getimagesize(public_path() . "/" . $image->path)[1];
             if ($height > $option['width']) {
                 $images->forget($index);
             }
         }
     }
     if ($images->count() == 0) {
         return array();
     } else {
         return $images;
     }
 }
 public function store()
 {
     Notes::where('email', Auth::user()->email)->update(array('notes' => Input::get('notes')));
     TBD::where('email', Auth::user()->email)->update(array('tbd' => Input::get('tbd')));
     $input = Input::all();
     for ($i = 0; $i < count($input); $i++) {
         if (!Links::where('links', '=', Input::get("link{$i}"))->exists()) {
             if (Input::get("link{$i}") != "") {
                 Links::insert(array('email' => Auth::user()->email, 'links' => Input::get("link{$i}")));
             }
         }
     }
     if (Input::hasFile('photo')) {
         $count = Image::where('email', Auth::user()->email)->count();
         if ($count >= 4) {
             echo "USER CAN ONLY HAVE 4 PHOTOS MAX";
             return Redirect::back();
         }
         $extension = Input::file('photo')->getClientOriginalExtension();
         if ($extension == "gif" || $extension == "jpeg") {
             Image::insert(array('email' => Auth::user()->email, 'image' => file_get_contents(Input::file('photo'))));
         } else {
             echo "CAN ONLY DO GIF OR JPEG";
         }
     }
     $imageCount = Image::where('email', Auth::user()->email)->count();
     for ($i = 0; $i < $imageCount - 1; $i++) {
         if (Input::get("delete{$i}") != null) {
             $imageTable = Image::where('email', Auth::user()->email)->get();
             //echo $imageTable[$i+1]["id"];
             Image::where('id', $imageTable[$i]["id"])->delete();
         }
     }
     return Redirect::to('profile');
 }
Esempio n. 3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Checking all profile images...');
     $images = Image::all();
     foreach ($images as $image) {
         // Send HEAD request
         $c = curl_init();
         curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
         curl_setopt($c, CURLOPT_HEADER, 1);
         curl_setopt($c, CURLOPT_NOBODY, true);
         curl_setopt($c, CURLOPT_URL, $image->author_image_url);
         $res = curl_exec($c);
         $this->info('ERROR HTTP CODE : ' . curl_getinfo($c, CURLINFO_HTTP_CODE));
         // If 404 not found then delete from db
         if (curl_getinfo($c, CURLINFO_HTTP_CODE) == 404) {
             $this->info('Deleting: ' . $image->image_id);
             $url = 'https://api.instagram.com/v1/users/search?q=' . $image->username . '&access_token=1040772762.5b9e1e6.7a7387aa92a546de86fde4fc4aec0d5b';
             $ch = curl_init();
             curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 2));
             $result = curl_exec($ch);
             curl_close($ch);
             $results = json_decode($result, true);
             $profile_picture = $results['data'][0]['profile_picture'];
             $this->info('New Profile Picture : ' . $profile_picture);
             Image::where('image_id', $image->image_id)->update(array('author_image_url' => $profile_picture));
             $this->info('Update Complete' . $image->author_image_url);
         }
     }
 }
 public function getImageIdAttribute($value)
 {
     if ($value) {
         $image = Image::find($value);
     } else {
         $image = Image::where('album_id', $this->id)->first();
     }
     return $image ? $image->thumburl : '';
 }
 /**
  * Display detail of an image
  *
  * @param  int  $id
  * @return Response
  */
 public function imageDetail($id)
 {
     $image = Image::where('status', Constants::$COMMON_STATUSES['public'])->find($id);
     if (empty($image)) {
         App::abort('404');
     }
     $this->setViewData('model', $image);
     return $this->createView('public.image-detail');
 }
Esempio n. 6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Updateing all usernames...');
     // Get all the images
     $images = Image::all();
     // Loop over images to check each one exists
     foreach ($images as $image) {
         if ($image->username == "") {
             $this->info('Update' . $image->image_id);
             Image::where('image_id', $image->image_id)->update(['username' => substr($image->author_link_url, 21)]);
             $this->info('Update Compelete ' . $image->username);
         }
     }
 }
Esempio n. 7
0
 public function __construct($id = '', $width = '', $height = '')
 {
     // header('Content-Type: image/jpeg');
     $this->ci =& get_instance();
     $this->ci->config->load('cms/config');
     $this->ci->load->library('Imagick');
     $this->config = get_config();
     //
     $id = $id == '' ? null : $id;
     $this->width = $width == '' ? null : $width;
     $this->height = $height == '' ? null : $height;
     // getImage Table DB
     $this->image = \Image::where('id', $id)->first();
 }
 private function getLastTags($from, $threshold = 10)
 {
     $last_images = Image::where('created_at', '>=', $from)->get();
     $last_tags = array();
     foreach ($last_images as $image) {
         $image_tags = $image->tags;
         foreach ($image_tags as $tag) {
             if ($tag->confidence < $threshold) {
                 continue;
             }
             array_push($last_tags, $tag);
         }
     }
     return $this->getTags($last_tags);
 }
Esempio n. 9
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::check()) {
         //regenerate sessions after coming back so old session from before are replaced
         Session::regenerate();
         $note = Note::whereUser(Auth::user()->email)->first();
         $images = Image::where('user', Auth::user()->email)->get();
         $count = Image::where('user', Auth::user()->email)->get()->count();
         $data = array('notes' => $note, 'user' => Auth::user()->email, 'images' => $images, 'count' => $count);
         return View::make('sessions.home')->with($data);
     } else {
         return Redirect::route('sessions.create');
         //form
     }
 }
Esempio n. 10
0
 public function index()
 {
     $user_id = Input::get('user_id');
     $user = User::find($user_id);
     if ($user) {
         if (FEUsersHelper::isCurrentUser($user->id)) {
             $images_d = Image::where('user_id', '=', $user->id);
         } else {
             $album_id = Album::where('user_id', '=', $user->id)->where('privacy', PrivaciesHelper::getId("Công khai"))->select('id')->get();
             $images_d = Image::where('user_id', '=', $user->id)->whereIn('album_id', $album_id->fetch('id')->toArray());
         }
         return View::make('frontend/photos/images/index')->with('user', $user)->with('images', $images_d->paginate($this->image_per_page));
     } else {
         return Redirect::to('/');
     }
 }
Esempio n. 11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->deleteFiles(['thumbnail', 'gallery', 'origin', 'avatar_origin', 'avatar_large', 'avatar_middle', 'avatar_small']);
     $s3 = AWS::get('s3');
     $prefix = 'https://yolanothertest.s3-us-west-2.amazonaws.com/';
     $objects = $s3->getIterator('listObjects', ['Bucket' => 'yolanothertest']);
     foreach ($objects as $object) {
         $imageUrl = $prefix . $object['Key'];
         if ($thumbnail = Image::where('thumbnail', $prefix . $object['Key'])->whereNotNull('imageable_id')->first()) {
             if ($thumbnail) {
                 File::append(storage_path('thumbnail.csv'), "{$thumbnail->id}, {$object['Key']}, {$thumbnail->imageable_type}, {$thumbnail->imageable_id}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
                 $this->line("{$thumbnail->id} thumbnail {$object['Key']} {$thumbnail->imageable_type} {$thumbnail->imageable_id} {$object['Size']}");
             }
         } elseif ($large = Image::where('regular', $prefix . $object['Key'])->whereNotNull('imageable_id')->first()) {
             if ($large) {
                 File::append(storage_path('gallery.csv'), "{$large->id},  {$object['Key']}, {$large->imageable_type}, {$large->imageable_id}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
                 $this->line("{$large->id} gallery {$object['Key']} {$large->imageable_type} {$large->imageable_id} {$object['Size']}");
             }
         } elseif ($origin = Image::where('origin', $prefix . $object['Key'])->whereNotNull('imageable_id')->first()) {
             if ($origin) {
                 File::append(storage_path('origin.csv'), "{$origin->id}, {$object['Key']}, {$origin->imageable_type}, {$origin->imageable_id}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
             }
         } elseif ($avatarOrigin = User::where('img_origin', $prefix . $object['Key'])->first()) {
             if ($avatarOrigin) {
                 File::append(storage_path('avatar_origin.csv'), "{$avatarOrigin->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
             }
         } elseif ($avatarLarge = User::where('img_large', $prefix . $object['Key'])->first()) {
             if ($avatarLarge) {
                 File::append(storage_path('avatar_large.csv'), "{$avatarLarge->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
             }
         } elseif ($avatarMiddle = User::where('img_middle', $prefix . $object['Key'])->first()) {
             if ($avatarMiddle) {
                 File::append(storage_path('avatar_middle.csv'), "{$avatarMiddle->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
             }
         } elseif ($avatarSmall = User::where('img_small', $prefix . $object['Key'])->first()) {
             if ($avatarSmall) {
                 File::append(storage_path('avatar_small.csv'), "{$avatarSmall->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
             }
         }
     }
 }
Esempio n. 12
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $popular_media = $this->source->getPopularMedia();
     // $images = Image::all();
     // foreach($images as $image)
     // {
     // 	$request = \Httpful\Request::get($image->url)->send();
     // 	if($request->hasErrors())
     // 	{
     // 		$image->delete();
     // 	}
     // }
     foreach ($popular_media->data as $media) {
         $post_link = $media->link;
         $image_url = $media->images->standard_resolution->url;
         $created_at = intval($media->created_time);
         $image_count = Image::where('url', '=', $image_url)->count();
         if ($image_count > 0) {
             continue;
         }
         $tags = $this->getTags($image_url);
         $image = new Image();
         $image->url = $image_url;
         $image->source = 'instagram';
         $image->created_at = Carbon::now();
         $image->post_url = $post_link;
         $image->save();
         $tags_objects = array();
         foreach ($tags as $tag) {
             $tag_object = new Tag();
             $tag_object->name = $tag->tag;
             $tag_object->confidence = $tag->confidence;
             $tag_object->image()->associate($image);
             $tag_object->save();
             array_push($tags_objects, $tag_object);
         }
         $image->tags()->saveMany($tags_objects);
         echo '.';
     }
 }
Esempio n. 13
0
 public function update($id)
 {
     if (!empty(Input::get('like')) && Input::get('like') == 'true') {
         $image = Image::find($id);
         $image->count_like = $image->count_like + 1;
         $image->save();
         echo 'true';
     } else {
         $data = Input::all();
         $image = Image::where('id', $id)->first();
         if (AlbumsHelper::save($data, $image->album->id)) {
             $image->caption = $data['caption'];
             if ($image->save()) {
                 Session::flash('status', 'success');
                 Session::flash('messages', array(0 => 'Updated'));
             } else {
                 Session::flash('status', 'fail');
                 Session::flash('messages', array(0 => 'Failed'));
             }
             return Redirect::to('image/' . $image->id . '/edit');
         }
     }
 }
Esempio n. 14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($order)
 {
     $success = 'not sure !';
     // delete
     $image = Image::where('gallery_id', '=', Input::get('gallery_id'))->where('order', '=', $order)->first();
     if (empty($image)) {
         return Redirect::to('admin/gallery/' . Input::get('gallery_id'))->with('error', 'Cette image n\'existe pas !');
     }
     $gallery = Gallery::find(Input::get('gallery_id'));
     if ($image->id == $gallery->cover_id) {
         $success = 'Vous avez supprimé la Cover de la Galerie ! Elle a été remplacé par la première image.';
     }
     //Regulation order in image
     $image->delete();
     DB::table('images')->where('gallery_id', '=', Input::get('gallery_id'))->where('order', '>', $order)->decrement('order');
     if ($image->id == $gallery->cover_id) {
         $gallery->cover_id = Image::where('gallery_id', '=', Input::get('gallery_id'))->where('order', '=', 0)->first()->id;
         $gallery->save();
     }
     // redirect
     $success .= ' L\'image a été supprimé !';
     return Redirect::to('admin/gallery/' . Input::get('gallery_id'))->with('success', $success);
 }
Esempio n. 15
0
 /**
  * Delete an entire album
  *
  * @return boolean
  */
 public function deleteAlbum()
 {
     try {
         DB::beginTransaction();
         // Get all the images in this album
         // and physical deleting images
         $images = $this->images;
         if (!empty($images)) {
             foreach ($images as $image) {
                 Utilities::deleteImageFile($image->name, true, $image->extension);
             }
             // Delete all record of images in this album
             Image::where('album_id', $this->id)->delete();
         }
         // Delete this album
         $this->delete();
         DB::commit();
         return true;
     } catch (Exception $e) {
         DB::rollback();
         return false;
     }
 }
Esempio n. 16
0
 protected function updateImagesOrder($image_order_values)
 {
     foreach ($image_order_values as $key => $image_order) {
         //@TODO add catch here
         $image_id = intval($key);
         $order = $image_order[0];
         if ($order != NULL) {
             $new_data = array("order" => $order);
             Image::where("id", "=", $image_id)->update($new_data);
         }
     }
 }
 public function submitPage()
 {
     $timeDiff = round(abs(time() - $_SESSION["time"]) / 60, 2) . " minute";
     if ($timeDiff >= 20) {
         exit("LOGGED OUT OF INACTIVE. <a href='home'>Log In</a>");
     }
     $userID = $_POST["userID"];
     $result = Image::where('userID', $userID)->count();
     if (file_exists($_FILES['photo']['tmp_name']) || is_uploaded_file($_FILES['photo']['tmp_name'])) {
         $result++;
     }
     if ($result >= 4) {
         echo $result;
         exit("CAN ONLY HAVE 4 IMAGES GO BACK");
     }
     $id = Image::select('id')->where('userID', $userID)->get()->toArray();
     for ($i = 0; $i < $result; $i++) {
         if (isset($_POST["delete{$i}"])) {
             Image::where('id', $id[$i]["id"])->delete();
         }
     }
     Notes::where('userID', $_POST["userID"])->update(array('notes' => $_POST["notes"]));
     TBD::where('userID', $_POST["userID"])->update(array('tbd' => $_POST["tbd"]));
     $emailArray = array();
     for ($i = 0; $i < 10; $i++) {
         if (isset($_POST["website{$i}"]) && $_POST["website{$i}"] != "") {
             array_push($emailArray, $_POST["website{$i}"]);
         }
     }
     for ($i = 0; $i < count($emailArray); $i++) {
         $result = Website::select('website')->where('website', $emailArray[$i])->get();
         if ($result == "[]") {
             Website::insert(array('userID' => $userID, 'website' => $emailArray[$i]));
         }
     }
     if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) {
         if ($_FILES['photo']['type'] == "image/jpeg" || $_FILES['photo']['type'] == "image/jpg" || $_FILES['photo']['type'] == "image/gif") {
             Image::insert(array('userID' => $userID, 'image' => file_get_contents($_FILES['photo']['tmp_name'])));
         }
     }
     $profile = $this->returnProfile($_POST["userID"]);
     return View::make('profile')->with('userProfile', $profile);
 }
 /**
  * Add information from $this->files to the database
  *
  * @return boolean
  */
 protected function toDB()
 {
     if (!$this->files) {
         $this->addError('No files where found!');
         return false;
     }
     foreach ($this->files as $album => $images) {
         $album = $album ? $album : 'Undefined';
         $a = Album::where('title', $album)->first();
         $a = $a ? $a : new Album();
         $a->folder = $this->urlSafe($album);
         $a->title = $album;
         $a->save();
         if (!$a->id) {
             $this->addError('Error saving album to database!');
             return false;
         }
         foreach ($images as $image) {
             $i = Image::where('image', $image['newfilename'] . '.' . $image['ext'])->first();
             $i = $i ? $i : new Image();
             $i->image = $image['newfilename'] . '.' . $image['ext'];
             $i->title = $image['filename'];
             $i->text = $image['text'];
             $i->album()->associate($a);
             $i->save();
             if (!$i->id) {
                 $this->addError('Error saving image to database!');
                 return false;
             }
             if ($image['cover']) {
                 $a->image_id = $i->id;
                 $a->save();
             }
         }
     }
     return true;
 }
Esempio n. 19
0
 /**
  * Remove the specified resource from storage.
  * DELETE /beer/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $beer = Beer::find($id);
     foreach (Image::where('beer_id', $id) as $img) {
         $img->delete();
     }
     foreach ($beer->image as $image) {
         $image->delete();
     }
     foreach (Sticker::where('beer_id', $id) as $sticker) {
         $sticker->delete();
     }
     $beer->brewer()->sync([]);
     $beer->delete();
     return Redirect::to('/dashboard/beers');
 }
Esempio n. 20
0
 /**
  * Detaches image from title.
  * 
  * @param array $input
  * @return  void
  */
 public function detachImage(array $input)
 {
     $title = $this->title->find($input['title-id']);
     \Image::where('id', $input['image-id'])->delete();
     Event::fire('Titles.Modified', array($input['title-id']));
 }
Esempio n. 21
0
 public function subStringUsername()
 {
     $images = Image::all();
     foreach ($images as $image) {
         if ($image->username == "") {
             Image::where('image_id', $image->image_id)->update(['username' => substr($image->author_link_url, 21)]);
         }
     }
     return View::make('test');
 }