/**
  * Check whether path is in root path
  *
  * @static
  * @access  public
  * @return  bool
  * @param   string  $path
  * @param   string  $root
  */
 function pathInRoot($path, $root)
 {
     static $realPaths = array();
     if (!isset($realPaths[$root])) {
         $realPaths[$root] = File_Util::realPath($root);
     }
     return false !== strstr(File_Util::realPath($path), $realPaths[$root]);
 }
示例#2
0
 /**
  * Constructor
  *
  * @param   mixed   $db         SQLiteDatabase のインスタンス or データベースのパス
  * @param   array   $options    キャッシュ設定オプション (optional)
  * @throws  Cache_SQLiteException
  * @access  public
  */
 public function __construct($db = ':memory:', $options = array())
 {
     // エラー管理オブジェクトを用意
     $this->_stack = PEAR_ErrorStack::singleton('Cache_SQLite');
     // オプションを設定
     $constOptions = array('debug', 'strict', 'autoCreateTable', 'autoVacuum');
     foreach ($this->_defaults as $key => $value) {
         $propName = '_' . $key;
         $this->{$propName} = $value;
         if (isset($options[$key])) {
             if ($key == 'table') {
                 $this->{$propName} = (string) $options[$key];
             } elseif (in_array($key, $constOptions)) {
                 $this->{$propName} = (bool) $options[$key];
             } else {
                 $this->setOption($key, $options[$key]);
             }
         }
     }
     $this->_tableQuoted = self::_quoteIdentifier($this->_table);
     $this->_validFromat = self::SERIALIZE_PHP | self::ENCODE_BASE64 | self::ENCODE_ZLIB_BINARY;
     // データベースをオープン
     $errmsg = '';
     if ($db instanceof SQLiteDatabase) {
         $this->_db = $db;
     } else {
         if ($db == ':memory:' || File_Util::isAbsolute($db)) {
             $path = $db;
         } else {
             $path = File_Util::realPath($db);
         }
         $this->_db = new SQLiteDatabase($path, CACHE_SQLITE_FILE_MODE, $errmsg);
     }
     if ($errmsg == '') {
         $this->_inTransaction = false;
         if ($this->_autoCreateTable) {
             $this->_checkTable();
         }
     } else {
         $params = array('message' => $errmsg);
         $msg = 'sqlite_open() failed: %message%';
         $this->_stack->push(self::ERR_CRITICAL, 'error', $params, $msg);
         throw new Cache_SQLiteException('Cache_SQLite sqlite_open() failed: {$errmsg}', self::ERR_CRITICAL);
     }
 }
示例#3
0
/**
 * 実在しない(かもしれない)ファイルの絶対パスを取得する
 *
 * @param   string $path
 * @return  string
 */
function p2_realpath($path)
{
    if (file_exists($path)) {
        return realpath($path);
    }
    return File_Util::realPath($path);
}
示例#4
0
function getPermissionError($file, $desc, $is_directory, $exists)
{
    $error = '';
    if ($is_directory) {
        $title = 'Directory';
    } else {
        $title = 'File';
    }
    $error = "{$title} <b>'" . File_Util::realPath($file) . ($is_directory ? '/' : '') . "'</b> ";
    if (!$exists) {
        $error .= "does not exist. Please create the {$title} and reload this page.";
    } else {
        $error .= "is not writeable. Please change this {$title} to be writeable by the web server.";
    }
    return $error;
}
示例#5
0
文件: conf.inc.php 项目: poppen/p2
/**
 * @return  void
 */
function _prepareFileSession()
{
    global $_conf;
    // セッションデータ保存ディレクトリを設定
    if ($_conf['session_save'] == 'p2' and session_module_name() == 'files') {
        // $_conf['data_dir'] を絶対パスに変換する
        define('P2_DATA_DIR_REAL_PATH', File_Util::realPath($_conf['data_dir']));
        $_conf['session_dir'] = P2_DATA_DIR_REAL_PATH . DIRECTORY_SEPARATOR . 'session';
    }
    if (!is_dir($_conf['session_dir'])) {
        require_once P2_LIB_DIR . '/FileCtl.php';
        FileCtl::mkdirFor($_conf['session_dir'] . '/dummy_filename');
    }
    if (!is_writable($_conf['session_dir'])) {
        die(sprintf('p2 error: セッションデータ保存ディレクトリ (%s) に書き込み権限がありません。', hs($_conf['session_dir'])));
    }
    session_save_path($_conf['session_dir']);
    // session.save_path のパスの深さが2より大きいとガーベッジコレクションが行われないので
    // 自前でガーベッジコレクションする
    P2Util::session_gc();
}
示例#6
0
/**
 * 実在しない(かもしれない)ファイルの絶対パスを取得する
 *
 * @param   string $path
 * @return  string
 */
function p2_realpath($path)
{
    if (file_exists($path)) {
        return realpath($path);
    }
    if (!class_exists('File_Util', false)) {
        require 'File/Util.php';
    }
    return File_Util::realPath($path);
}