Пример #1
0
 public function testCanUnsetAVariable()
 {
     $this->namespace->testUnset = 5;
     $this->assertEquals(5, $this->storage->get('testUnset'));
     $this->storage->remove('testUnset');
     $this->assertFalse(isset($this->namespace->testUnset));
     $this->assertFalse($this->storage->has('testUnset'));
 }
Пример #2
0
 /**
  * 应用程序初始化
  */
 public static function start()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoLoad');
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimeFile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimeFile)) {
         Storage::load($runtimeFile);
     } else {
         $content = '';
         // 读取应用模式
         $mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载应用模式配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(load_config($file)) : C($key, load_config($file));
         }
     }
 }
 /**
  * load gitlab user data from file.
  *
  * @return type user list(json encoding)
  */
 public function loadGitLabUser()
 {
     if (\Storage::has($this->userList)) {
         $users = \Storage::read($this->userList);
         return json_decode($users, true);
     }
     // if file not exist, create empty list.
     return [];
 }
Пример #4
0
 /**
  *html静态文件缓存
  * @access protected
  * @param string $filename 生成的静态文件名称
  * @param string $filepath 生成的静态文件路径
  * @param string $expire 静态文件缓存时间
  * @return void
 */
 protected function html_before($filename = '',$filepath = '',$expire = 15){
     $suffix = C('HTML_FILE_SUFFIX')?C('HTML_FILE_SUFFIX'):'shtml';
     if($filename === '' && $filepath === ''){
         $filename = APP_PATH.'/static/'.__ACTION__.'.'.$suffix;
     }else{
         $filename = $filename?$filename.'.'.$suffix:md5(__ACTION__).'.'.$suffix;
         $filepath = $filepath?APP_PATH.'/'.$filepath:APP_PATH.'/static';
         $filename = $filepath.'/'.$filename;
     }
     if(Storage::has($filename)){
         if(time() - Storage::get($filename,'mtime') < $expire){
             exit(Storage::read($filename));
         }
     }
     $this->filename = $filename;
 }
Пример #5
0
 public function getCityByCountry($countryCode)
 {
     $file = 'city_list_' . $countryCode;
     if (!\Storage::has('location/' . $file)) {
         $data = json_encode(\DB::table($this->cityTable)->where('countryCode', $countryCode)->orderBy('name', 'asc')->get());
         \Storage::put('location/' . $file, $data);
         return $data;
     } else {
         try {
             $city = \Storage::get('location/' . $file);
             return $city;
         } catch (\Exception $e) {
             return $e->getMessage();
         }
     }
 }
Пример #6
0
 /**
  * Uplaod Image on Storage
  *
  * @param File $file
  * @param      $key
  *
  * @return string
  */
 function upload_photo_on_storage(File $file, $key)
 {
     if (!$file->isValid() || !$key) {
         return null;
     }
     $imageDirectory = 'images/profile';
     if (!Storage::has($imageDirectory)) {
         Storage::makeDirectory($imageDirectory, 0777);
     }
     $imageExtension = $file->getClientOriginalExtension();
     $imageHashName = $key;
     $imageFilePath = "app/{$imageDirectory}/{$imageHashName}";
     $imageFileAbsolutePath = storage_path($imageFilePath);
     // resize image
     $image = Image::make($file->getRealPath())->resize(300, 300, function ($constraint) {
         // prevent possible upsizing
         $constraint->aspectRatio();
         $constraint->upsize();
     })->save($imageFileAbsolutePath);
     return $image ? $imageFilePath : null;
 }
Пример #7
0
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function start()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoload');
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimefile)) {
         Storage::load($runtimefile);
     } else {
         if (Storage::has($runtimefile)) {
             Storage::unlink($runtimefile);
         }
         $content = '';
         // 读取应用模式
         $mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载应用模式配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(include $file) : C($key, include $file);
         }
         // 读取当前应用模式对应的配置文件
         if ('common' != APP_MODE && is_file(CONF_PATH . 'config_' . APP_MODE . '.php')) {
             C(include CONF_PATH . 'config_' . APP_MODE . '.php');
         }
         // 加载模式别名定义
         if (isset($mode['alias'])) {
             self::addMap(is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias']));
         }
         // 加载应用别名定义文件
         if (is_file(CONF_PATH . 'alias.php')) {
             self::addMap(include CONF_PATH . 'alias.php');
         }
         // 加载模式行为定义
         if (isset($mode['tags'])) {
             Hook::import(is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags']));
         }
         // 加载应用行为定义
         if (is_file(CONF_PATH . 'tags.php')) {
             // 允许应用增加开发模式配置定义
             Hook::import(include CONF_PATH . 'tags.php');
         }
         // 加载框架底层语言包
         L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
         if (!APP_DEBUG) {
             $content .= "\nnamespace { Think\\Think::addMap(" . var_export(self::$_map, true) . ");";
             $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(Hook::get(), true) . ');}';
             Storage::put($runtimefile, strip_whitespace('<?php ' . $content));
         } else {
             // 调试模式加载系统默认的配置文件
             C(include THINK_PATH . 'Conf/debug.php');
             // 读取应用调试配置文件
             if (is_file(CONF_PATH . 'debug.php')) {
                 C(include CONF_PATH . 'debug.php');
             }
         }
     }
     // 读取当前应用状态对应的配置文件
     if (APP_STATUS && is_file(CONF_PATH . APP_STATUS . '.php')) {
         C(include CONF_PATH . APP_STATUS . '.php');
     }
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 检查应用目录结构 如果不存在则自动创建
     if (C('CHECK_APP_DIR') && !is_dir(LOG_PATH)) {
         // 创建应用目录结构
         require THINK_PATH . 'Common/build.php';
     }
     // 记录加载文件时间
     G('loadTime');
     // 运行应用
     App::run();
 }
Пример #8
0
         $tpl->fetch($_content, $this->tVar, $prefix);
     }
 }
 // 获取并清空缓存
 $content = ob_get_clean();
 // 内容过滤标签
 // 系统默认的特殊变量替换
 $replace = array('__ROOT__' => __ROOT__, '__APP__' => __APP__, '__MODULE__' => __MODULE__, '__ACTION__' => __ACTION__, '__SELF__' => __SELF__, '__CONTROLLER__' => __CONTROLLER__, '__URL__' => __CONTROLLER__, '__PUBLIC__' => __ROOT__ . '/Public');
 // 允许用户自定义模板的字符串替换
Пример #9
0
    if ($codigo == '') {
        abort(404);
    }
    $idx = Input::get('idx');
    if ($idx == '') {
        abort(404);
    }
    $carpeta = Input::get('carpeta');
    if ($carpeta == '') {
        abort(404);
    }
    try {
        $vars = Crypt::decrypt($codigo);
    } catch (DecryptException $e) {
        abort(404);
    }
    $variables = explode(";", $vars);
    $orden = Orden::whereDate('valido_hasta', '>=', date('Y-m-d'))->where("imprenta_id", "=", $variables[0])->where("numero_de_orden", '=', $variables[1])->firstOrFail();
    $archivos = $orden->lista_archivos;
    $mimetype = array('gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'cdr' => 'image/x-coreldraw', 'psd' => 'image/x-photoshop', 'pdf' => 'application/pdf', '.ai' => 'application/illustrator', 'zip' => 'application/zip');
    $content = NULL;
    $mime = NULL;
    if (Storage::has($archivos[$carpeta][$idx])) {
        $content = Storage::get($archivos[$carpeta][$idx]);
        $mime = $mimetype[substr($archivos[$carpeta][$idx], -3)];
    }
    if ($content == NULL) {
        abort(404);
    }
    return response($content)->header('Content-Type', $mime)->header('Content-Disposition', 'attachment;filename=' . basename($archivos[$carpeta][$idx]));
});
Пример #10
0
    if (Request::hasFile('cv')) {
        $arch = Request::file('cv');
        Storage::put('curriculums/' . $cv->id . '.' . $arch->getClientOriginalExtension(), File::get($arch));
    }
    return view('bolsa', ["mensaje" => true]);
});
Route::group(['middleware' => 'auth'], function () {
    Route::resource('bolsa-de-trabajo/consulta', 'BolsaDeTrabajoController', ['only' => ['index', 'show']]);
    Route::get('curriculum/{id}/descargar', function ($id) {
        $cv = App\Curriculum::findOrFail($id);
        $mimetype = array('pdf' => 'application/pdf', 'doc' => 'Content-Type: application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
        $content = NULL;
        $mime = NULL;
        $nombre = NULL;
        foreach ($mimetype as $ext => $type) {
            if (Storage::has('curriculums/' . $cv->id . "." . $ext)) {
                $content = Storage::get('curriculums/' . $cv->id . "." . $ext);
                $nombre = $cv->apellido . "-" . $cv->nombre . "." . $ext;
                $mime = $type;
                break;
            }
        }
        if ($content == NULL) {
            abort(404);
        }
        return response($content)->header('Content-Type', $mime)->header('filename', $nombre);
    });
});
Route::post('contacto', function () {
    $data = Input::all();
    $mail = Mail::send('contacto', ["data" => $data], function ($message) use($data) {
Пример #11
0
 protected function checkCache($cacheFile, $templateFile, $layoutFile)
 {
     if (!Storage::has($cacheFile)) {
         return false;
     } elseif (filemtime($templateFile) > filemtime($cacheFile)) {
         // 模板文件如果有更新则缓存需要更新
         return false;
     }
     //elseif(){}//缓存时间判断
     // 开启布局模板
     if ($layoutFile) {
         if (filemtime($layoutFile) > filemtime($cacheFile)) {
             return false;
         }
     }
     // 缓存有效
     return true;
 }
Пример #12
0
 public static function delete_file($type, $folder, $file)
 {
     if ($folder && $file && $file != '' && $file != NULL) {
         if ($type == 'image') {
             if ($image_folder = \Solunes\Master\App\ImageFolder::where('name', $folder)->first()) {
                 $image_sizes = $image_folder->image_sizes->toArray();
                 array_push($image_sizes, ['code' => 'mini']);
                 foreach ($image_sizes as $size) {
                     if (\Storage::has($folder . '/' . $size["code"] . '/' . $file)) {
                         \Storage::delete($folder . '/' . $size["code"] . '/' . $file);
                     }
                 }
             }
         } else {
             if (\Storage::has($folder . '/' . $file)) {
                 \Storage::delete($folder . '/' . $file);
             }
         }
         return true;
     } else {
         return false;
     }
 }
Пример #13
0
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function start()
 {
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoload');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimefile, 'runtime')) {
         Storage::load($runtimefile, null, 'runtime');
     } else {
         if (Storage::has($runtimefile, 'runtime')) {
             Storage::unlink($runtimefile, 'runtime');
         }
         $content = '';
         // 读取应用模式
         $mode = (include is_file(COMMON_PATH . 'Conf/core.php') ? COMMON_PATH . 'Conf/core.php' : THINK_PATH . 'Conf/Mode/' . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(include $file) : C($key, include $file);
         }
         // 加载别名定义
         foreach ($mode['alias'] as $alias) {
             self::addMap(is_array($alias) ? $alias : (file_exists($alias) ? include $alias : array()));
         }
         // 加载模式系统行为定义
         if (isset($mode['extends'])) {
             Hook::import(is_array($mode['extends']) ? $mode['extends'] : (include $mode['extends']));
         }
         // 加载应用行为定义
         if (isset($mode['tags'])) {
             if (is_array($mode['tags'])) {
                 $tags = $mode['tags'];
             } else {
                 $tags = file_exists($mode['tags']) ? include $mode['tags'] : array();
             }
             Hook::import($tags);
         }
         // 加载框架底层语言包
         L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
         if (!APP_DEBUG) {
             $content .= "\nnamespace { Think\\Think::addMap(" . var_export(self::$_map, true) . ");";
             $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(Hook::get(), true) . ');}';
             Storage::put($runtimefile, strip_whitespace('<?php ' . $content), 'runtime');
         } else {
             // 调试模式加载系统默认的配置文件
             C(include THINK_PATH . 'Conf/debug.php');
             // 读取调试模式的应用状态
             $status = C('APP_STATUS');
             // 加载对应的项目配置文件
             if (is_file(COMMON_PATH . 'Conf/' . $status . '.php')) {
                 // 允许项目增加开发模式配置定义
                 C(include COMMON_PATH . 'Conf/' . $status . '.php');
             }
         }
     }
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 检查项目目录结构 如果不存在则自动创建
     if (C('CHECK_APP_DIR') && !is_dir(LOG_PATH)) {
         // 创建项目目录结构
         require THINK_PATH . 'Common/build.php';
     }
     // 记录加载文件时间
     G('loadTime');
     if (!defined('IsInterface')) {
         // 运行应用
         App::run();
     } else {
         App::init();
     }
 }