Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function prepare(Request $request)
 {
     parent::prepare($request);
     if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $this->getEtag()) {
         $this->setStatusCode(304);
         $this->maxlen = 0;
     } else {
         if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
             $lastModified = $this->getLastModified();
             $lastModified instanceof \DateTime && ($lastModified = $lastModified->getTimeStamp());
             if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified) {
                 $this->setStatusCode(304);
                 $this->maxlen = 0;
             }
         } else {
             switch (substr($_SERVER['SERVER_SOFTWARE'], 0, (int) strpos($_SERVER['SERVER_SOFTWARE'], '/'))) {
                 case 'nginx':
                     $this->headers->set('X-Accel-Redirect', env('APP_PATH') . '/' . relative_path($this->file->getPathname(), APPPATH));
                     $this->headers->set('X-Accel-Buffering', 'yes');
                     //$this->headers->set('X-Accel-Limit-Rate', '102400'); //速度限制 Byte/s
                     //$this->headers('Accept-Ranges', 'none');//单线程 限制多线程
                     $this->maxlen = 0;
                     break;
                 case 'Apache':
                     if (function_exists('apache_get_modules') && in_array('mod_xsendfile', apache_get_modules())) {
                         $this->headers->set('X-Sendfile', $this->file->getPathname());
                         $this->maxlen = 0;
                     }
                     break;
                 case 'squid':
                     $this->headers->set('X-Accelerator-Vary', $this->file->getPathname());
                     $this->maxlen = 0;
                     break;
                 case 'lighttpd':
                     $this->headers->set('X-LIGHTTPD-send-file', $this->file->getPathname());
                     $this->maxlen = 0;
                     break;
             }
         }
     }
     return $this;
 }
Ejemplo n.º 2
0
 protected function onPrepare($argv = null)
 {
     $this->thisApp = App::getApp();
     $root = $this->getNewAppDir();
     if (is_dir($root)) {
         throw new \Exception("Directory {$root} is existing!");
     }
     $kephpEntry = relative_path($root, $this->thisApp->kephp());
     list($path, $phar) = split_phar($kephpEntry);
     if ($phar !== false) {
         $kephpEntry = "'phar://' . __DIR__ . '{$path}/{$phar}{$this->entryFile}'";
     } else {
         $kephpEntry = "__DIR__ . '{$path}{$this->entryFile}'";
     }
     $this->context['kephpLibEntry'] = $kephpEntry;
     if (empty($this->appNamespace)) {
         $this->appNamespace = path2class($this->name);
     } else {
         if (!preg_match('#^[a-z0-9_]+$#i', $this->appNamespace)) {
             throw new \Exception("App namespace only can use char in a-z0-9_.");
         }
     }
     $this->context['appNamespace'] = trim($this->appNamespace, KE_PATH_NOISE);
 }
Ejemplo n.º 3
0
function get_caller($num = 1, $start = 2)
{
    $out = array();
    if (!is_callable('debug_backtrace')) {
        return $out;
    }
    $bt = debug_backtrace();
    for ($i = $start; $i < $num + $start; $i++) {
        if (!empty($bt[$i])) {
            $t = '';
            if (!empty($bt[$i]['file'])) {
                $t .= relative_path($bt[$i]['file']);
            }
            if (!empty($bt[$i]['line'])) {
                $t .= ':' . $bt[$i]['line'];
            }
            if ($t) {
                $t .= ' ';
            }
            if (!empty($bt[$i]['class'])) {
                $t .= $bt[$i]['class'];
            }
            if (!empty($bt[$i]['type'])) {
                $t .= $bt[$i]['type'];
            }
            if (!empty($bt[$i]['function'])) {
                $t .= $bt[$i]['function'];
                $t .= '()';
            }
            $out[] = $t;
        }
    }
    return $out;
}
Ejemplo n.º 4
0
 protected function set_path()
 {
     if (!$this->path) {
         $this->path = relative_path(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['file']);
     }
     return $this;
 }
Ejemplo n.º 5
0
 public function log($error, $type, $trace = 0)
 {
     $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $trace + 1);
     $this->_log[] = array($error, $type, relative_path($backtrace[$trace]['file']), $backtrace[$trace]['line']);
 }
Ejemplo n.º 6
0
 /**
  * This function handles upgrading the plugin to a new version.
  * It gets triggered when the plugin version is different than the one stored in the database.
  */
 function upgrade()
 {
     if (!isset($this->options['plugin_version']) || version_compare($this->options['plugin_version'], '2.1', '<')) {
         $this->options['backup_token'] = wp_generate_password(12, false);
         $this->options['backup_title'] = get_bloginfo('name');
         $this->options['include_list'] = array();
         $this->options['request_timeout'] = 60;
         $this->options['backup_attempts'] = 3;
         $this->options['enabled_transports'] = $this->http_transports;
         $this->options['ssl_verify'] = true;
         $this->options['email_notify'] = false;
         $this->options['user_info'] = array();
         $this->options['backup_list'] = array();
         if ($this->goauth->is_authorized()) {
             $this->set_user_info();
         }
         // Delete the old backup folder if it's the default
         if (WP_CONTENT_DIR . '/backup' == $this->local_folder) {
             delete_path($this->local_folder);
             $this->options['local_files'] = array();
             // and create a new one based on the random token.
             $this->local_folder = WP_CONTENT_DIR . '/backup-' . $this->options['backup_token'];
             $this->options['local_folder'] = relative_path(ABSPATH, $this->local_folder);
             if (wp_mkdir_p($this->local_folder)) {
                 if (!@is_file($this->local_folder . "/.htaccess")) {
                     file_put_contents($this->local_folder . "/.htaccess", "Order allow,deny\nDeny from all");
                 }
             }
         } else {
             file_put_contents($this->local_folder . "/.htaccess", "Order allow,deny\nDeny from all");
             delete_path($this->local_folder . '/backup.log');
         }
         // Use the new backup_list array to store backup data.
         if (isset($this->options['backup_list'])) {
             return;
         }
         $local_list = array_reverse($this->options['local_files']);
         $drive_list = array_reverse($this->options['drive_files']);
         $count = count($drive_list);
         if (count($local_list) > $count) {
             $count = count($local_list);
         }
         for ($i = 0; $i < $count; $i++) {
             $element = array();
             $element['status'] = 1;
             if (isset($local_list[$i])) {
                 $element['file_path'] = $local_list[$i];
             }
             if (isset($drive_list[$i])) {
                 $element['drive_id'] = $drive_list[$i];
             }
             if (0 == $i) {
                 $element['timestamp'] = $this->options['last_backup'];
             }
             $this->options['backup_list'] = array_merge(array((string) $i => $element), $this->options['backup_list']);
         }
         unset($this->options['local_files'], $this->options['drive_files'], $this->options['last_backup'], $this->options['resume_attempts']);
     }
     // Save the new plugin version
     $this->options['plugin_version'] = $this->version;
 }
Ejemplo n.º 7
0
function generate_page($file)
{
    global $base, $base_doc, $base_path, $docs_path, $options, $mode, $relative_base;
    $template = $options['template'];
    $filename = substr(strrchr($file, "/"), 1);
    if ($filename === 'index.md') {
        $homepage = TRUE;
    } else {
        $homepage = FALSE;
    }
    if (!$file) {
        $page['path'] = '';
        $page['markdown'] = '';
        $page['title'] = 'Oh No';
        $page['content'] = "<h3>Oh No. That page doesn't exist</h3>";
        $options['file_editor'] = false;
    } else {
        $page['path'] = str_replace($docs_path . '/', "", $file);
        $page['markdown'] = file_get_contents($file);
        $page['modified'] = filemtime($file);
        $page['content'] = MarkDownExtended($page['markdown']);
        $page['title'] = clean_url($file, 'Title');
    }
    $relative_base = $mode === 'Static' ? relative_path("", $file) : "http://" . $base_path . '/';
    ob_start();
    include $base . "/template/" . $template . ".tpl";
    $return = ob_get_contents();
    @ob_end_clean();
    return $return;
}
Ejemplo n.º 8
0
<?php

/**
 * Groups configuration for default Minify implementation
 * @package Minify
 */
/** 
 * You may wish to use the Minify URI Builder app to suggest
 * changes. http://yourdomain/min/builder/
 **/
function relative_path()
{
    $rel = str_replace($_SERVER['DOCUMENT_ROOT'], null, str_replace(basename(dirname(__FILE__)), null, dirname(__FILE__)));
    return preg_match('/^\\//', $rel) ? substr($rel, 1, strlen($rel)) : $rel;
}
$groupsConfig = array('js' => array('//js/jquery.min.js', '//js/jquery.raty.min.js', '//js/effect.js'), 'css' => array('//style.css'));
foreach ($groupsConfig as $key => $files) {
    foreach ($files as $i => $file) {
        $groupsConfig[$key][$i] = str_replace('//', '//' . relative_path(), $file);
    }
}
return $groupsConfig;
Ejemplo n.º 9
0
 public function query($request)
 {
     $start = microtime(TRUE);
     $resource = mysql_query($request);
     $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
     $this->_db->requests[] = array($request, microtime(TRUE) - $start, mysql_error(), !is_bool($resource) && !empty($resource) ? mysql_num_rows($resource) : 0, relative_path($backtrace[2]['file']), $backtrace[2]['line']);
     return $resource;
 }
Ejemplo n.º 10
0
?>
		<?php 
if (isset($_SESSION['notice'])) {
    ?>
			<div class="container notice"><?php 
    echo $_SESSION['notice'];
    unset($_SESSION['notice']);
    ?>
</div>
		<?php 
}
?>

		<?php 
require_once 'routes.php';
?>
		<?php 
$_SESSION['url'] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
?>
		<?php 
require_once 'assets/modals.php';
?>

		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
		<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="<?php 
echo relative_path();
?>
assets/js/function.js"></script>
	</body>
</html>