示例#1
0
 public function run($token)
 {
     $env = Environment::where('token', $token)->first();
     if (is_null($env)) {
         return json_encode(['error' => true, 'output' => 'invalid token']);
     }
     if (\Storage::exists($token . '.php')) {
         $tokenFile = \Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix() . "/" . $token . ".php";
         $output = null;
         $error = false;
         foreach ($this->steps as $step) {
             $command = "dep --ansi --file={$tokenFile} {$step} " . $env->server->host;
             $output .= $command . "\n";
             $process = new Process($command);
             $process->run();
             if (!$process->isSuccessful()) {
                 $output .= $process->getErrorOutput();
                 $error = true;
                 break;
             } else {
                 $output .= $process->getOutput();
             }
         }
         $history = EnvironmentHistory::create(['environment_id' => $env->id, 'status' => $error ? 'fail' : 'success', 'history' => $output]);
         return json_encode(['error' => $error, 'output' => $output]);
     }
 }
示例#2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  StoreMediaRequest  $request
  * @return Response
  */
 public function store(StoreMediaRequest $request)
 {
     if ($request->ajax()) {
         $response = ['error' => 1, 'path' => ''];
         if ($request->hasFile('file')) {
             $file = $request->file('file');
             $folder = '/public/uploads/' . $request->folder;
             if (!\Storage::exists($folder)) {
                 \Storage::makeDirectory($folder);
             }
             $path = $folder . '/' . date('Y-m-d');
             $hashed = sha1(Str::slug($file->getClientOriginalName() . time())) . '.' . $file->getClientOriginalExtension();
             if (!\Storage::exists($path)) {
                 \Storage::makeDirectory($path);
             }
             if ($file->move(storage_path('app') . $path, $hashed)) {
                 $path = str_replace('/public', '', $path);
                 $medium = $this->medium->create(['path' => $path . '/' . $hashed]);
                 if ($medium) {
                     $response['error'] = 0;
                     $response['path'] = $path . '/' . $hashed;
                     return response($response, 200);
                 }
                 // TODO: ln -s storage/app/public/uploads /path/to/public_html/public
             }
         }
     }
     return response('error', 400);
 }
示例#3
0
 /**
  * Checks if the Database Directory exists,
  * if not, directory will be created.
  */
 private function checkDirectoryExists()
 {
     $directory = storage_path($this->directoryPath);
     if (!$this->storage->exists($directory)) {
         $this->storage->makeDirectory($directory);
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     // If DB file exists delete it
     if (Storage::exists(database_path('SPGProfileDB.sqlite'))) {
         Storage::delete(database_path('SPGProfileDB.sqlite'));
     }
     Schema::connection($this->TargetDB)->drop('pass_profiles');
 }
示例#5
0
 private static function getImg(Meeting $meeting)
 {
     $name = 'meetings/' . $meeting->id;
     if (!\Storage::exists($name)) {
         return false;
     }
     return \Storage::get($name);
 }
 public function delete($projectId, $id)
 {
     try {
         $projectFile = $this->repository->find($id);
         if ($this->storage->exists($projectFile->getFileName())) {
             $this->storage->delete($projectFile->getFileName());
         }
         $this->repository->delete($id);
         return ['success' => true, "message" => 'Registro excluído com sucesso.'];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Registro não encontrado.', "messageDev" => $e->getMessage()];
     } catch (QueryException $e) {
         return ['error' => true, 'message' => 'Este registro não pode ser excluído, pois existe um ou mais projetos vinculados a ele.', "messageDev" => $e->getMessage()];
     } catch (\Exception $e) {
         return ["error" => true, "message" => 'Falha ao excluir registro.', "messageDev" => $e->getMessage()];
     }
 }
 public function verfoto(Request $request)
 {
     $public_path = public_path();
     //$url = $public_path.'/storage/'.$request->archivo;
     $url = \Storage::disk('local') . $request->archivo;
     //verificamos si el archivo existe y lo retornamos
     if (Storage::exists($archivo)) {
         return response()->download($url);
     }
     //si no se encuentra lanzamos un error 404.
     abort(404);
 }
示例#8
0
 public function setContent($content = null)
 {
     if ($content == null || !is_array($content)) {
         $content = $this->getContent();
     }
     $this->content = $content;
     \Storage::put($this->file_directory . '/' . $this->file_name . '-' . $this->id . '.json', json_encode($this->content));
     if (\Storage::exists($this->file_directory . '/' . $this->file_name . '.json')) {
         \Storage::delete($this->file_directory . '/' . $this->file_name . '.json');
     }
     \Storage::copy($this->file_directory . '/' . $this->file_name . '-' . $this->id . '.json', $this->file_directory . '/' . $this->file_name . '.json');
     return $this->content;
 }
示例#9
0
 public function get($id)
 {
     // $entry = File::where('filename', '=', $filename)->firstOrFail();
     // $file = \Storage::disk('local')->get($entry->filename);
     // // return (new \Response($file, 200))
     //             // ->header('Content-Type', $entry->mime);
     // return response($file,200)
     //           ->header('Content-Type', $entry->mime);
     // ===============================================================================================
     // $entry = File::where('filename', '=', $filename)->firstOrFail();
     // 	if (\Storage::exists($entry->filename)) {
     // 	$file = \Storage::disk('local')->get($entry->filename);
     // 	// return (new \Response($file, 200))
     //              // ->header('Content-Type', $entry->mime);
     // 	return response($file,200)
     //            ->header('Content-Type', $entry->mime);
     // 	}
     // 	else{
     // 		return 'File Rusak atau tidak ditemukan, Silahkan Update Ulang ';
     // 	}
     $entry = File::find(base64_decode($id));
     // dd($entry);
     if ($entry) {
         $dirfile = empty($entry->nama_baru) ? $entry->filename : $entry->dir . '/' . $entry->nama_baru;
         // echo $dirfile;
         // ARSIPPROSESSP2D-UYUYphpFDCC.tmp.pdf
         // dinas-p/ARSIPPROSESSP2D-UYUYphpF441.tmp.pdf
         // dd($dirfile);
         // dd($dirfile);
         // "SEKWAN-II/164-sp2d-nhl-setwn-09-arsipprosessp2d-164-sp2d-nhl-setwn-09-phpCAC5.tmp.pdf";
         // "164-sp2d-nhl-setwn-09-arsipprosessp2d-164-sp2d-nhl-setwn-09-1-php757E.tmp"
         if (\Storage::exists($dirfile)) {
             $file = \Storage::get($dirfile);
             // return (new \Response($file, 200))
             // ->header('Content-Type', $entry->mime);
             return response($file, 200)->header('Content-Type', $entry->mime);
         } elseif (!empty($entry->filename) && \Storage::exists($entry->filename)) {
             $file = \Storage::get($entry->filename);
             // return (new \Response($file, 200))
             // ->header('Content-Type', $entry->mime);
             return response($file, 200)->header('Content-Type', $entry->mime);
         } else {
             return 'File tidak ditemukan, Silahkan Update Ulang ';
         }
     } else {
         return 'Data File Rusak atau tidak ditemukan, Silahkan Update Ulang ';
     }
 }
示例#10
0
 public function get($filename, $size = null)
 {
     // Cut original file name
     $file = explode('.', $filename);
     $file_path = '';
     if (empty($filename)) {
         return '';
     }
     if (empty($size) && \Storage::exists($this->basepath . $file[0] . '_L.' . $file[1])) {
         $file_path = $this->basepath . $file[0] . '_L.' . $file[1];
     } else {
         if (\Storage::exists($this->basepath . $file[0] . '_' . $size . '.' . $file[1])) {
             $file_path = $this->basepath . $file[0] . '_' . $size . '.' . $file[1];
         } else {
             $file_path = $this->basepath . $filename;
         }
     }
     return url($file_path);
 }
示例#11
0
 public function get($filename, $size = null)
 {
     if (empty($filename)) {
         return '';
     }
     // Cut original file name
     $file = explode('.', $filename);
     $file_path = '';
     if (empty($filename)) {
         return '';
     }
     if (empty($size) && \Storage::exists($this->basepath . $file[0] . '_L.' . $file[1])) {
         $file_path = $this->basepath . $file[0] . '_L.' . $file[1];
     } elseif (\Storage::exists($this->basepath . $file[0] . '_' . $size . '.' . $file[1])) {
         $file_path = $this->basepath . $file[0] . '_' . $size . '.' . $file[1];
     } else {
         $file_path = $this->basepath . $filename;
     }
     if (\Config::get('filesystems.default') == 's3') {
         return \Storage::getDriver()->getAdapter()->getClient()->getObjectUrl(\Storage::getDriver()->getAdapter()->getBucket(), $this->basepath . $filename);
     } else {
         return url($file_path);
     }
 }
示例#12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $data_dokumen = Dokumens::find($id);
     $data_dokumen_pesan = $data_dokumen;
     // dd($data_dokumen_pesan->nama_skpd);
     if ($data_dokumen) {
         $data_dokumen->delete();
         $file = $data_dokumen->file;
         // dd($file);
         // $file->get()['filename'];
         if ($file) {
             $lokasi_baru = $file->dir . '/' . $file->nama_baru;
             $lokasi_lama = $file->filename;
             if ($file->nama_baru && $file->dir && \Storage::exists($lokasi_baru)) {
                 # code...
                 // echo $lokasi_baru;
                 \Storage::move($lokasi_baru, 'RecycleBin/' . $file->nama_baru);
             }
             if (\Storage::exists($lokasi_lama)) {
                 // echo $lokasi_lama;
                 \Storage::move($lokasi_lama, 'RecycleBin/' . $file->filename);
                 # code...
             }
             // $file->delete();
         }
     }
     $data_dokumenx = Dokumens::find($id);
     if (!$data_dokumenx) {
         return 'Sukses data SPPD  ' . $data_dokumen_pesan->no_sppd;
     } else {
         return 'gagal data SPPD  ' . $data_dokumen_pesan->no_sppd;
     }
     // return __function__;
     //
 }
            <th>TAMAÑO</th>
            <th>CREADO</th>
            <th>ACCION</th>
        </tr>
        </thead>
        <tbody>
        @foreach($medios as $medio)

            <tr>
                <td>{{ $medio->id }}</td>
                <td>
                  <a href="/medios/{{ $medio->nombre}}" target="newwindow"
                    data-toggle="tooltip" data-placement="right"
                    title="PRESIONE CLICK PARA VER O DESCARGAR SEGUN SEA EL TIPO DE ARCHIVO">
                    <?php 
if (Storage::exists($medio->nombre)) {
    $nombre = $medio->nombre;
    $tamanio = Storage::size($medio->nombre);
    $creado = $medio->created_at;
    $tipo = $medio->tipo;
    if ($tipo == 'jpg' || $tipo == 'png' || $tipo == 'jpeg' || $tipo == 'gif') {
        ?>
<img class="img_click" src="/medios/{{ $medio->nombre}}"><?php 
    } else {
        if ($tipo == 'pdf') {
            ?>
<img class="img_click" src="/img/pdf.png"><?php 
        } else {
            if ($tipo == 'doc' || $tipo == 'dot' || $tipo == 'docx') {
                ?>
<img class="img_click" src="/img/m_word.png"><?php 
示例#14
0
 public function getLoginOk($wxuin)
 {
     $file = "user/{$wxuin}.txt";
     if (\Storage::exists($file)) {
         $user = \Storage::get($file);
         $user = json_decode($user);
     } else {
         return '不存在此wxuin';
     }
     //进行post登陆尝试
     $url = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?lang=zh_CN&pass_ticket=" . urlencode($user->pass_ticket) . "&r=-" . rr();
     $post = '{"BaseRequest":{"Uin":"' . $user->cookies->wxuin . '","Sid":"' . $user->cookies->wxsid . '","Skey":"' . $user->skey . '","DeviceID":"' . $user->deviceid . '"}}';
     $ret = CURL::send($url, ['Cookie' => urldecode(http_build_query($user->cookies, '', '; '))], ['follow_redirects' => false], ['ret' => 'all', 'post' => $post]);
     $cookies = toCookies($ret->cookies);
     $cookies = (object) ((array) $cookies + (array) $user->cookies);
     //判断是否正常
     $data_arr = json_decode($ret->body, true);
     if (count($data_arr)) {
         if (!isset($data_arr['BaseResponse']['Ret'])) {
             $data_arr = array();
         } else {
             if ($data_arr['BaseResponse']['Ret'] != 0) {
                 return $data_arr['BaseResponse']['Ret'] . $data_arr['BaseResponse']['ErrMsg'] . ',请从新<a href="/login/">扫描</a>';
             }
         }
     } else {
         return '没有获取到内容,请从新<a href="/login/">扫描</a>';
     }
     //开始获取基本信息了
     $data['Uin'] = $data_arr['User']['Uin'];
     $data['UserName'] = $data_arr['User']['UserName'];
     $data['NickName'] = $data_arr['User']['NickName'];
     $data['SyncKey'] = json_encode($data_arr['SyncKey']);
     $data['wxuin'] = $cookies->wxuin;
     $data['skey'] = urldecode($user->skey);
     $data['pass_ticket'] = urldecode($user->pass_ticket);
     $data['deviceid'] = $user->deviceid;
     $data['cookies'] = json_encode($cookies);
     //设置状态为可用
     $data['status'] = 1;
     Login::inSave($data);
     //删除临时文件
     \Storage::delete($file);
     //写入好友信息
     $this->ContactList($data_arr);
     //加入群信息获取队列
     $job = (new JobChatroom($data['wxuin']))->onQueue('chatroom');
     $this->dispatch($job);
     //加入监控队列
     $job = (new JobCheck($data['wxuin']))->onQueue('check');
     $this->dispatch($job);
 }
 public function removeFile($filename, Flash $flash)
 {
     $file = "{$filename}.pdf";
     if (\Storage::exists($file)) {
         \Storage::delete($file);
         $flash->success('File has been deleted.');
     }
     return redirect()->back();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     return;
     $links_arr = (include '/var/www/kotik/storage/app/citynature_urls.php');
     foreach ($links_arr as $link) {
         $file_name = 'citynature_pages/' . md5($link) . '.html';
         $exists = \Storage::exists($file_name);
         if (!$exists) {
             continue;
         }
         $file_content = \Storage::get($file_name);
         preg_match('@<h1>(.+)</h1>@si', $file_content, $product_name);
         preg_match('@<span class="ean">([^<]+)</span>@si', $file_content, $article);
         preg_match('@<p>Категория\\: <a href="[/a-z0-9_-]{1,}">([^<]+)</a></p>@si', $file_content, $category);
         preg_match('@<p class="manufacturer_name">Бренд:[\\s]{0,}<a class = "bolder_cart_product" href = "[/a-z0-9_-]{1,}">([^<]+)</a>[\\s]{0,}, <a href="[/a-z0-9_-]{1,}">([^<]+)</a>[\\s]{0,}</p>@si', $file_content, $brand_country);
         preg_match('@<p>Линейка товаров: <a href="[/#a-z0-9_-]{1,}">([^<]+)</a></p>@si', $file_content, $products_line);
         preg_match('@<span>([0-9\\s]+) (мл|мг)+</span>@si', $file_content, $value);
         preg_match('@<div class="qty_in_stock">В наличии:[\\s]{0,}<span >([0-9]+)</span>&nbsp;[\\s]{0,}Мин. партия: от <span>([0-9]+)</span> шт.[\\s]{0,}</div>@si', $file_content, $part);
         preg_match('@<div class="jshop_prod_description"style = "margin-top:60px;">(.+?)</div>@si', $file_content, $description);
         preg_match_all('@<a class="lightbox" id="main_image_full_[\\d]+" href="([^"]+)"@si', $file_content, $images);
         $product_name = !empty($product_name) ? trim($product_name[1]) : '';
         $article = !empty($article) ? trim($article[1]) : '';
         $category = !empty($category) ? trim($category[1]) : '';
         $brand = !empty($brand_country) ? trim($brand_country[1]) : '';
         $country = !empty($brand_country) ? trim($brand_country[2]) : '';
         $products_line = !empty($products_line) ? trim($products_line[1]) : '';
         $images = !empty($images) ? $images[1] : [];
         $weight = !empty($value) ? $value[1] : '';
         $weight = str_replace(' ', '', $weight);
         $measure_unit = !empty($value) ? trim($value[2]) : '';
         $description = !empty($description) ? $description[1] : '';
         $description = str_replace("</p>", "\n", $description);
         $description = strip_tags($description);
         $description = preg_replace('/Описание:/', '', $description);
         $description = trim($description);
         $in_stock = !empty($part) ? trim($part[1]) : 0;
         $min_party = !empty($part) ? trim($part[2]) : 0;
         $product_model = \App\Models\Product::create(['article' => $article, 'name' => $product_name, 'description' => $description, 'source_url' => $link, 'brand' => $brand, 'country_name' => $country, 'weight' => $weight, 'measure_unit' => $measure_unit, 'in_stock' => $in_stock, 'min_party' => $min_party, 'category_name' => $category, 'product_line' => $products_line]);
         if (!empty($images)) {
             foreach ($images as $image) {
                 $media_model = new \App\Models\Media();
                 $media_model->product_id = $product_model->id;
                 $media_model->source_url = $image;
                 $media_model->save();
             }
         }
     }
     return;
     $catalog = \App\Helpers\CitynatureHelper::getCatalogArrayFromCsvFile(base_path('storage/app/price1.csv'));
     $this->info('Catalog count = ' . count($catalog));
     foreach ($catalog as $item) {
         if (\App\Models\Product::where('code', '=', $item->index)->first()) {
             continue;
         }
         $product = new \App\Models\Product();
         $product->name = $item->title;
         $product->catalog_id = 1;
         $product->code = $item->index;
         $product->article = $item->article;
         $product->save();
         $product->setAttributeById(1, $item->volume);
         // weight
         $product->setAttributeById(4, $item->article);
         // article
         $product->setPriceByColumnId(18, $item->price_1);
         $product->setPriceByColumnId(19, $item->price_2);
         $product->setPriceByColumnId(20, $item->price_3);
         $product->setPriceByColumnId(21, $item->price_4);
         echo '.';
     }
     echo "\n";
 }
示例#17
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route:
get('/', function () {
    // check request type
    if (Request::ajax()) {
        $file = 'Json/data.json';
        // path to Json file
        $data = '';
        // Json data
        // check that the file is exist
        if (Storage::exists($file)) {
            // read data from the file
            $data = Storage::get($file);
        }
        // return Json data
        return $data;
    }
    // return a page
    return view('index');
});
示例#18
0
文件: routes.php 项目: alanarza/ubook
Route::resource('ubooks_publico', 'UbooksController@publico');
// Rutas protegidas
$router->group(['middleware' => ['auth']], function () {
    Route::resource('inicio', 'IndexController@inicio');
    Route::resource('perfil', 'PerfilController');
    Route::resource('ubooks', 'UbooksController');
    Route::resource('book_vista', 'UbooksController@vista');
    Route::resource('favoritos', 'FavoritosController');
    Route::resource('cuenta', 'PerfilController@cuenta');
    Route::post('gestion_cuenta', 'GestionCuentaController@save');
    Route::get('/busqueda', 'BusquedaController@busquedaUsuario');
});
// Rutas protegidas if authenticated
$router->group(['middleware' => ['guest']], function () {
    Route::resource('/', 'IndexController');
    Route::get('/buscar', 'BusquedaController@busquedaAnonima');
});
// Rutas de almacenamiento
// Ruta para obtener archivos
Route::get('storage/{archivo}', function ($archivo) {
    $public_path = public_path();
    $url = $public_path . '/storage/' . $archivo;
    //verificamos si el archivo existe y lo retornamos
    if (Storage::exists($archivo)) {
        return response()->download($url);
    }
    //si no se encuentra lanzamos un error 404.
    abort(404);
});
// Ruta para subir archivos
//Route::post('storage/create', 'StorageController@save');
示例#19
0
文件: mail.php 项目: rhymix/rhymix
 /**
  * Embed a file.
  *
  * @param string $local_filename
  * @param string $cid (optional)
  * @return string|false
  */
 public function embed($local_filename, $cid = null)
 {
     if (!Storage::exists($local_filename)) {
         return false;
     }
     $embedded = \Swift_EmbeddedFile::fromPath($local_filename);
     if ($cid !== null) {
         $embedded->setId(preg_replace('/^cid:/i', '', $cid));
     }
     $result = $this->message->embed($embedded);
     if ($result) {
         $this->attachments[] = (object) array('type' => 'embed', 'local_filename' => $local_filename, 'display_filename' => null, 'cid' => $result);
         return $result;
     } else {
         return false;
     }
 }
示例#20
0
Storage::add("DB", $DB);
if (!isset($_SESSION['WEB_SERFER'])) {
    $_SESSION['WEB_SERFER'] = array("IP" => $_SERVER["REMOTE_ADDR"], "BROWSER" => $_SERVER["HTTP_USER_AGENT"], "WEB_ID" => md5(GetRandom(8) . $_SERVER["REMOTE_ADDR"]));
}
$_SESSION['WEB_SERFER']["LAST_ACTIVITY"] = time();
$USER = App::USER();
$bIsAdmin = $USER->IsAdmin();
Storage::add("USER", $USER);
// [Рудименты]
if (Storage::exists("APP_TEMPLATE")) {
    App::get()->templateName = Storage::get("APP_TEMPLATE");
}
if (!Storage::exists("SITE_NAME")) {
    Storage::add("SITE_NAME", "");
}
if (!Storage::exists("SITE_DESCRIPTION")) {
    Storage::add("SITE_DESCRIPTION", "");
}
App::get()->setTitle(Storage::get()->SITE_NAME);
App::get()->setDescr(Storage::get()->SITE_DESCRIPTION);
// [/Рудименты]
// Задаем тип отображения для сессии
if (@isset($_REQUEST["sacid_display_mode"]) && $bIsAdmin) {
    switch (strtoupper($_REQUEST["sacid_display_mode"])) {
        case 'EDIT':
            $_SESSION['SACID_DISPLAY_MODE'] = 'EDIT';
            break;
        case 'NORMAL':
        default:
            $_SESSION['SACID_DISPLAY_MODE'] = 'NORMAL';
            break;
示例#21
0
 public function descargar($id)
 {
     $archivo = Archivo::find($id);
     $ruta_descarga = env('ARCHIVO_GENERAL', 'archivo') . '/' . $archivo->carpeta_id . '/' . $archivo->name;
     if (\Storage::exists($archivo->carpeta_id . '/' . $archivo->name)) {
         $headers = ['Content-Type' => $archivo->mime];
         return response()->download($ruta_descarga, $archivo->name, $headers);
     } else {
         return redirect()->back()->with(['message' => 'No se puede descargar el archivo. Favor de comunicarse con el administrador del sisetma.', 'alert-class' => 'alert-danger']);
     }
 }
 public function downloadPlan($id)
 {
     $meeting = Meeting::find($id);
     $public_path = public_path();
     $url = $public_path . '/storage/' . $meeting->plan;
     if (\Storage::exists($meeting->plan)) {
         return response()->download($url);
     }
     return redirect('historial')->with('file_error', 'No se ha encontrado el archivo especificado');
 }
 public function eliminar(Request $request)
 {
     if (\Storage::exists($request->nombreTrabajo)) {
         \Storage::delete($request->nombreTrabajo);
         $trabajoId = $request->trabajoId;
         $trabajo = Trabajo::find($trabajoId);
         $trabajo->delete();
         return view('templates.estudiante.gestionarTrabajos', ['mensaje' => 'Archivo Eliminado']);
     } else {
         return view('templates.estudiante.gestionarTrabajos', ['mensaje' => 'Archivo no Eliminado']);
     }
 }
示例#24
0
 /**
  * 
  */
 public function anyDeleteTable(Request $req, $db)
 {
     // ECHO $req->get('filename');
     // dd(explode('.', $req->get('filename'))[0]);
     $model = $this->mod($db);
     // $model->where('filename','=',$req->get('filename'))->delete();
     $export = Eksport::where('files_id', $req->get('file_id'));
     // dd($export->delete());
     if (count($export)) {
         $nama_file = $export->get()[0]->nama_file . '.xlsx';
         $dir_export = 'exports/';
         // echo $dir_export.$nama_file;
         // dd(\Storage::disk('local')->exists($dir_export.$nama_file) );
         if (\Storage::exists($dir_export . $nama_file) and \Storage::delete($dir_export . $nama_file)) {
             if ($export->delete()) {
                 $response['code'] = 200;
                 $response['msg'] = "Menghapus export : " . $nama_file . " Sukses";
             }
         } else {
             $response['code'] = 400;
             $response['msg'] = " Gagal!  File export : " . $nama_file . " Tidak Ada";
         }
     } else {
         $response['code'] = 400;
         $response['msg'] = "Terjadi Kesalahan";
     }
     echo json_encode($response);
 }
示例#25
0
 public function tidyUp()
 {
     $redisKey = config('rediskeys.digitalocean_token') . $this->provision->uuid;
     $sshKeys = new \App\Fodor\Ssh\Keys($this->provision->uuid);
     $adapter = new GuzzleHttpAdapter(Redis::get($redisKey));
     $digitalocean = new DigitalOceanV2($adapter);
     // ## REMOVE SSH KEYS FROM DIGITALOCEAN AND OUR LOCAL FILESYSTEM ##
     $keysFromDo = $digitalocean->key()->getAll();
     if (!empty($keysFromDo)) {
         foreach ($keysFromDo as $key) {
             if ($key->name == 'fodor-' . $this->provision->uuid) {
                 $digitalocean->key()->delete($key->id);
                 // Remove our fodor SSH key from the users DigitalOcean account
                 $this->log->addInfo("Removed SSH key: {$key->name}: {$key->id} from DigitalOcean");
             }
         }
     }
     if (\Storage::exists($sshKeys->getPublicKeyPath())) {
         try {
             $this->log->addInfo("Removed local SSH Keys");
             $sshKeys->remove();
             // uuid is the name of the file
         } catch (Exception $e) {
             // TODO: Handle.  We should probably be alerted as we don't want these lying around
         }
     }
     Redis::del($redisKey);
     $this->provision->dateready = (new \DateTime('now', new \DateTimeZone('UTC')))->format('c');
     $this->provision->exitcode = $this->exitCode;
     $this->provision->status = $this->exitCode === 0 ? 'ready' : 'errored';
     //TODO: Other distros or shells?
     $this->provision->save();
     //TODO: If it errored, an alert should be sent out for investigation
     $this->log->addInfo("Set provision row's status to {$this->provision->status}, we're done here");
 }
 protected function _getFromCache($url)
 {
     $cache_path = 'FullContactCache/';
     $cache_file_name = $cache_path . '/' . md5(urldecode($url)) . '.json';
     if (\Storage::exists($cache_file_name)) {
         $json_content = \Storage::get($cache_file_name);
         return $json_content;
     }
     return false;
 }