function download($reqst = '') { //checando a existencia do arquivo solicitado $reqst = _file_exists($reqst); if ($reqst == false) { return false; } //gerando header apropriado include ROOT . '.php/config/mimetypes.php'; $ext = end(explode('.', $reqst)); if (!isset($_mimes[$ext])) { $mime = 'text/plain'; } else { $mime = is_array($_mimes[$ext]) ? $_mimes[$ext][0] : $_mimes[$ext]; } //get file $dt = file_get_contents($reqst); //download ob_end_clean(); ob_start('ob_gzhandler'); header('Vary: Accept-Language, Accept-Encoding'); header('Content-Type: ' . $mime); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($reqst)) . ' GMT'); header('Cache-Control: must_revalidate, public, max-age=31536000'); header('Content-Length: ' . strlen($dt)); header('x-Server: Qzumba.com'); header('ETAG: ' . md5($reqst)); exit($dt); }
/** * Carrega os arquivos * @param string $Class * @return boolean */ function __autoload($Class) { if ($source = _file_exists("{$Class}.class.php")) { include_once $source; return true; } trigger_error('A class `' . $Class . '` não existe.'); return false; }
public function setPath($path) { // Update if ($path == '*') { $path = $this->_path; } $path = _realpath($path); if (_file_exists($path) and _is_dir($path)) { if (_is_readable($path)) { $this->_path = $path; $this->_tree = _scandir($this->_path); $this->_size = count($this->_tree); return $this->_path; } else { throw new Exception("Can't read dir: {$path}"); } } else { throw new Exception("Not a dir: {$path}"); } }
public function __construct($path) { if (_file_exists($path)) { /*$name = basename($path); if ($name == '.' or $name == '..') { // Les deux fichiers zarbis throw new Exception("Le fichier est zarb: '$name'"); // Sinon on fait normalement } else*/ $this->_path = _realpath($path); } else { throw new Exception("Le fichier n'existe pas: {$path}"); } $this->_write = $this->isWritable(); $this->_read = $this->isReadable(); if ($this->isFolder()) { $this->_type = 'folder'; } elseif ($this->isFile()) { $this->_type = 'file'; } else { $this->_type = 'unknown'; } }
ls($modscripts, function ($subpath, $subfile) use(&$scripts, $modfile) { $scripts .= "<script src='./modules/{$modfile}/scripts/{$subfile}'></script>"; }, 'is_file'); // Chargement des styles ls($modstyles, function ($subpath, $subfile) use(&$styles, $modfile) { $styles .= "<link rel='stylesheet' type='text/css' href='./modules/{$modfile}/styles/{$subfile}'/>"; }, 'is_file'); }, 'is_dir'); // On retourne tout return array('styles' => $styles . "\n", 'scripts' => $scripts . "\n"); } $init = false; if ($module = get('m')) { $init = _file_exists($modinit = "./modules/_{$module}/init.php") ? 'm' : null; } elseif ($module = get('n')) { $init = _file_exists($modinit = "./modules/_{$module}/jnjt.php") ? 'n' : null; } if ($init) { // Petit système REST include_once $modinit; // Si une action est définie if (!($action = post('action'))) { $action = 'default'; } // Si on demande un module en json if ($init == 'm') { header('Content-Type: application/json'); try { echo json_encode($MODULE[$action]()); } catch (Exception $e) { echo json_encode(array('error' => true, 'data' => $e->getMessage()));
// Defaults error_reporting(E_ALL ^ E_STRICT); setlocale(LC_ALL, 'pt_BR'); mb_internal_encoding('UTF-8'); date_default_timezone_set('America/Sao_Paulo'); // Constants $base = dirname(dirname(__DIR__)); define('APP_MODE', 'pro'); // options: dev & pro define('WEB_PATH', str_replace('\\', '/', strpos($base, 'phar://') !== false ? dirname(str_replace('phar://', '', $base)) . '/' : $base . '/')); define('RPHAR', strpos(WEB_PATH, 'phar://') !== false ? WEB_PATH : false); define('APP_PATH', WEB_PATH . '.app/'); define('CONFIG_PATH', APP_PATH . 'config/'); define('LOG_PATH', APP_PATH . 'log/'); define('HTML_PATH', APP_PATH . 'html/'); //Helpers include APP_PATH . 'lib/functions.php'; // Error/Exception set set_error_handler("errorHandler"); set_exception_handler('exceptionHandler'); // Internal autoload set_include_path(APP_PATH . PATH_SEPARATOR . get_include_path()); spl_autoload_register(function ($class) { $class = APP_PATH . str_replace('\\', '/', trim(strtolower($class), '\\')) . '.php'; return ($file = _file_exists($class)) !== false ? require_once $file : false; }); // Composer autoload include APP_PATH . 'vendor/autoload.php'; // Mount the "App" static dock class_alias('Lib\\App', 'App'); class_alias('Lib\\App', 'dock');
/** * Verifica a existência da controller * @param string $Controller * @param string $Modulo * @return string|false */ function controller_exists($Controller) { return _file_exists(preg_replace('/Controller$/', null, $Controller) . 'Controller.class.php', false); }