public function pools($pool = null) { $poolselected = Input::get('Pool', $pool); $pool = Pool::find($poolselected); if ($pool == Null) { $name = ""; $volretension = ""; $recycle = ""; $autoprune = ""; $pooltype = ""; } else { $name = $pool->uname; $to = Date::now(); $text = " Days"; /* 86400 -> equal to seconds in i day*/ $volretension = $pool->volretention / 86400 . $text; if ($volretension >= 365) { $type = ' Year'; $volretension = intval($pool->volretention / 31536000) . $type; } $recycle = $pool->recycle; $autoprune = $pool->autoprune; $pooltype = $pool->pooltype; } /* Get Stored bytes pool */ $tjobs = Media::where('poolid', '=', $poolselected)->remember(10)->sum('volbytes'); return View::make('pools', array('name' => $name, 'volretension' => $volretension, 'recycle' => $recycle, 'pooltype' => $pooltype, 'autoprune' => $autoprune, 'poolSelectBox' => $this->poolSelectBox)); }
public function setPhoto() { if (Auth::check()) { $text = Input::get('file'); $destinationPath = 'images/users/'; $data = $text['$ngfDataUrl']; list($type, $data) = explode(';', $data); list(, $type) = explode('/', $type); list(, $data) = explode(',', $data); $fileName = md5(date("YmdHis") . rand(5, 50)) . '.' . $type; $data = base64_decode($data); $media = Media::where('id', Auth::user()->media_id)->first(); if (file_put_contents($destinationPath . $fileName, $data)) { if ($media->id != 1) { $tmp = $media->name; $media->name = URL::to('/') . "/" . $destinationPath . $fileName; $media->save(); $arr = explode("/", $tmp); unlink($destinationPath . $arr[count($arr) - 1]); } else { $media = new Media(); $media->name = URL::to('/') . "/" . $destinationPath . $fileName; $media->save(); $user = Auth::user(); $user->media_id = $media->id; $user->save(); } return $this->getProfile(); } else { return response()->json(['result' => 'error'], 200); } } else { return response()->json(['result' => 'error'], 200); } }
public function get($type, $yearAndMonth, $day, $filename) { $media = Media::where('key', '=', $filename)->first(); if (!is_null($media)) { $file = Storage::get('uploads/' . $type . '/' . $yearAndMonth . '/' . $day . '/' . $media->key); if ($file) { return Response($file, 200)->header('Content-Type', $media->mime); } } throw new NotFoundException(); }
public function editWish($id) { // return response()->json(['result' => 'success', 'data' => $text], 200); $wish = Wish::where('id', $id)->first(); if ($wish) { $wish->name = Input::get('name'); $wish->description = Input::get('description'); $wish->category_id = Input::get('category')['id']; $wish->link = Input::get('link'); $text = Input::get("photo"); if (isset($text['$ngfDataUrl'])) { $destinationPath = 'images/wishes/'; $data = $text['$ngfDataUrl']; list($type, $data) = explode(';', $data); list(, $type) = explode('/', $type); list(, $data) = explode(',', $data); $fileName = md5(date("YmdHis") . rand(5, 50)) . '.' . $type; $data = base64_decode($data); $media = Media::where('id', $wish->media_id)->first(); if (file_put_contents($destinationPath . $fileName, $data)) { if ($media->id != 3) { $tmp = $media->name; $media->name = URL::to('/') . "/" . $destinationPath . $fileName; $media->save(); $arr = explode("/", $tmp); unlink($destinationPath . $arr[count($arr) - 1]); } else { $media = new Media(); $media->name = URL::to('/') . "/" . $destinationPath . $fileName; $media->save(); $wish->media_id = $media->id; } } } $wish->save(); return response()->json(['result' => 'success'], 200); } else { return response()->json(['result' => 'error'], 200); } }
public function volumes($volumes = null) { $volumeSelected = Input::get('Volume', $volumes); $media = Media::where('mediaid', '=', $volumeSelected)->first(); if ($media == Null) { $slot = ""; $pool = ""; $firstwritten = ""; $lastwritten = ""; $labeldate = ""; $voljobs = ""; $volfiles = ""; $labeldate = ""; $volretention = ""; $volbytes = ""; $volstatus = ""; $volumeSelected = ""; } else { $slot = $media->slot; $pool = $media->pool; $firstwritten = $media->firstwritten; $lastwritten = $media->lastwritten; $labeldate = $media->labeldate; $voljobs = $media->voljobs; $volfiles = $media->volfiles; $labeldate = $media->labeldate; $to = Date::now(); $text = " Days"; /* 86400 -> equal to seconds in i day*/ $volretention = $media->volretention / 86400 . $text; if ($volretention >= 365) { $type = ' Year'; $volretention = intval($volretention / 31536000) . $type; } $volbytes = $this->byte_format($media->VolBytes); $volstatus = $media->volstatus; } return View::make('volumes', array('slot' => $slot, 'volume' => $volumeSelected, 'firstwritten' => $firstwritten, 'lastwritten' => $lastwritten, 'labeldate' => $labeldate, 'voljobs' => $voljobs, 'volfiles' => $volfiles, 'labeldate' => $labeldate, 'volretention' => $volretention, 'volbytes' => $volbytes, 'volstatus' => $volstatus, 'volumeSelectBox' => $this->volumeSelectBox)); }