コード例 #1
0
 function buildPathCache($paths, $last, $cwd, $zcache)
 {
     $parentPaths = array();
     $populated = array();
     $old_db_line = false;
     if (file_exists($cwd . '.patchwork.paths.txt')) {
         $old_db = @fopen($cwd . '.patchwork.paths.txt', 'rb');
         $old_db && ($old_db_line = fgets($old_db));
     } else {
         $old_db = false;
     }
     $tmp = $cwd . '.~' . uniqid(mt_rand(), true);
     $db = fopen($tmp, 'wb');
     $paths = array_flip($paths);
     unset($paths[$cwd]);
     uksort($paths, array($this, 'dirCmp'));
     foreach ($paths as $h => $level) {
         $this->populatePathCache($populated, $old_db, $old_db_line, $db, $parentPaths, $paths, substr($h, 0, -1), $level, $last);
     }
     $db && fclose($db);
     $old_db && fclose($old_db);
     $h = $cwd . '.patchwork.paths.txt';
     '\\' === DIRECTORY_SEPARATOR && file_exists($h) && @unlink($h);
     rename($tmp, $h) || unlink($tmp);
     if (function_exists('dba_handlers')) {
         $h = array('cdb', 'db2', 'db3', 'db4', 'qdbm', 'gdbm', 'ndbm', 'dbm', 'flatfile', 'inifile');
         $h = array_intersect($h, dba_handlers());
         $h || ($h = dba_handlers());
         if ($h) {
             foreach ($h as $db) {
                 if ($h = @dba_open($tmp, 'nd', $db, 0600)) {
                     break;
                 }
             }
         }
     } else {
         $h = false;
     }
     if ($h) {
         foreach ($parentPaths as $paths => &$level) {
             sort($level);
             dba_insert($paths, implode(',', $level), $h);
         }
         dba_close($h);
         $h = $cwd . '.patchwork.paths.db';
         '\\' === DIRECTORY_SEPARATOR && file_exists($h) && @unlink($h);
         rename($tmp, $h) || unlink($tmp);
     } else {
         $db = false;
         foreach ($parentPaths as $paths => &$level) {
             sort($level);
             $paths = md5($paths) . '.' . substr(md5($cwd), -6) . '.path.txt';
             $h = $zcache . $paths[0] . DIRECTORY_SEPARATOR . $paths[1] . DIRECTORY_SEPARATOR;
             file_exists($h) || mkdir($h, 0700, true);
             file_put_contents($h . $paths, implode(',', $level));
         }
     }
     return $db;
 }
コード例 #2
0
ファイル: Cdb.php プロジェクト: Tjorriemorrie/app
 /**
  * Returns true if the native extension is available
  *
  * @return bool
  */
 public static function haveExtension()
 {
     if (!function_exists('dba_handlers')) {
         return false;
     }
     $handlers = dba_handlers();
     if (!in_array('cdb', $handlers) || !in_array('cdb_make', $handlers)) {
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: Dba.php プロジェクト: gjerokrsteski/pimf-framework
 /**
  * @param string  $file    the cache-file.
  *
  * @param string  $handler the dba handler.
  *
  * You have to install one of this handlers before use.
  *
  * cdb      = Tiny Constant Database - for reading.
  * cdb_make = Tiny Constant Database - for writing.
  * db4      = Oracle Berkeley DB 4   - for reading and writing.
  * qdbm     = Quick Database Manager - for reading and writing.
  * gdbm     = GNU Database Manager   - for reading and writing.
  * flatfile = default dba extension  - for reading and writing.
  *
  * Use flatfile-handler only when you cannot install one,
  * of the libraries required by the other handlers,
  * and when you cannot use bundled cdb handler.
  *
  * @param string  $mode    For read/write access, database creation if it doesn't currently exist.
  *
  * @param boolean $persistently
  *
  * @throws \RuntimeException If no DBA extension or handler installed.
  */
 public function __construct($file, $handler = 'flatfile', $mode = 'c', $persistently = true)
 {
     if (false === extension_loaded('dba')) {
         throw new \RuntimeException('The DBA extension is required for this wrapper, but the extension is not loaded');
     }
     if (false === in_array($handler, dba_handlers(false))) {
         throw new \RuntimeException('The ' . $handler . ' handler is required for the DBA extension, but the handler is not installed');
     }
     $this->dba = true === $persistently ? dba_popen($file, $mode, $handler) : dba_open($file, $mode, $handler);
     $this->file = $file;
     $this->handler = $handler;
 }
コード例 #4
0
 public function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename)
 {
     // Check for dba extension
     if (!extension_loaded('dba')) {
         throw new Exception('PHP is not compiled with dba support, required to use DBM style cache.');
     }
     // Check for specific dba driver
     if (!function_exists('dba_handlers') || !in_array($cache_type, dba_handlers())) {
         throw new Exception('PHP is not compiled --with ' . $cache_type . ' support, required to use DBM style cache.');
     }
     // Create lock file if needed
     if (!file_exists($lock_filename)) {
         if (!touch($lock_filename)) {
             throw new Exception('failed to create lock file: ' . $lock_filename);
         }
     }
     // Open lock file for writing
     if (!is_writeable($lock_filename)) {
         throw new Exception('lock file: ' . $lock_filename . ' is not writable');
     }
     $this->lock = fopen($lock_filename, 'w');
     // Acquire exclusive write lock to lock file
     flock($this->lock, LOCK_EX);
     flock($this->lock, LOCK_EX);
     // Create dbm-file if needed
     if (!file_exists($dbm_filename)) {
         if (!touch($dbm_filename)) {
             throw new Exception('failed to create dbm file: ' . $dbm_filename);
         }
     }
     // Try to open dbm file for writing
     $this->dba = dba_open($dbm_filename, 'w', $cache_type);
     if (!$this->dba) {
         // Failed - create new dbm file
         $this->dba = dba_open($dbm_filename, 'n', $cache_type);
         if (!$this->dba) {
             throw new Exception('failed to create dbm file: ' . $dbm_filename);
         }
         // Insert getID3 version number
         dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
     }
     // Init misc values
     $this->cache_type = $cache_type;
     $this->dbm_filename = $dbm_filename;
     // Register destructor
     register_shutdown_function(array($this, '__destruct'));
     // Check version number and clear cache if changed
     if (dba_fetch(getID3::VERSION, $this->dba) != getID3::VERSION) {
         $this->clear_cache();
     }
     parent::__construct();
 }
コード例 #5
0
ファイル: Cache.php プロジェクト: gjerokrsteski/php-dba-cache
 /**
  * @param string  $file    the cache-file.
  *
  * @param string  $handler the dba handler.
  *
  * You have to install one of this handlers before use.
  *
  * cdb      = Tiny Constant Database - for reading.
  * cdb_make = Tiny Constant Database - for writing.
  * db4      = Oracle Berkeley DB 4   - for reading and writing.
  * qdbm     = Quick Database Manager - for reading and writing.
  * gdbm     = GNU Database Manager   - for reading and writing.
  * inifile  = Ini File               - for reading and writing.
  * flatfile = default dba extension  - for reading and writing.
  *
  * Use "flatfile" only when you cannot install one, of the libraries
  * required by the other handlers, and when you cannot use bundled cdb handler.
  *
  * @param string  $mode    For read/write access, database creation if it doesn't currently exist.
  *
  * r  = for read access
  * w  = for read/write access to an already existing database
  * c  = for read/write access and database creation if it doesn't currently exist
  * n  = for create, truncate and read/write access
  *
  * When you are absolutely sure that you do not require database locking you can use "-" as suffix.
  *
  * @param boolean $persistently
  *
  * @throws \RuntimeException If no DBA extension or handler installed.
  */
 public function __construct($file, $handler = 'flatfile', $mode = 'c', $persistently = true)
 {
     if (!extension_loaded('dba')) {
         throw new \RuntimeException('missing ext/dba');
     }
     if (!function_exists('dba_handlers') || !in_array($handler, dba_handlers(false))) {
         throw new \RuntimeException("dba-handler '{$handler}' not supported");
     }
     $this->dba = true === $persistently ? @dba_popen($file, $mode, $handler) : @dba_open($file, $mode, $handler);
     if ($this->dba === false) {
         $err = error_get_last();
         throw new \RuntimeException($err['message']);
     }
     $this->storage = $file;
     $this->handler = $handler;
 }
コード例 #6
0
ファイル: DbaDatabase.php プロジェクト: pombredanne/tuleap
 function DbaDatabase($filename, $mode = false, $handler = 'gdbm')
 {
     $this->_file = $filename;
     $this->_handler = $handler;
     $this->_timeout = DBA_DATABASE_DEFAULT_TIMEOUT;
     $this->_dbh = false;
     if (function_exists("dba_handlers")) {
         // since 4.3.0
         if (!in_array($handler, dba_handlers())) {
             $this->_error(sprintf(_("The DBA handler %s is unsupported!") . "\n" . _("Supported handlers are: %s"), $handler, join(",", dba_handlers())));
         }
     }
     if ($mode) {
         $this->open($mode);
     }
 }
コード例 #7
0
ファイル: dba.php プロジェクト: nemein/openpsa
 /**
  * This handler completes the configuration.
  */
 public function _on_initialize()
 {
     // We need to serialize data
     $this->_auto_serialize = true;
     if (array_key_exists('handler', $this->_config)) {
         $this->_handler = $this->_config['handler'];
     } else {
         $handlers = dba_handlers();
         if (in_array('db4', $handlers)) {
             $this->_handler = 'db4';
         } else {
             if (in_array('db3', $handlers)) {
                 $this->_handler = 'db3';
             } else {
                 if (in_array('db2', $handlers)) {
                     $this->_handler = 'db2';
                 } else {
                     if (in_array('gdbm', $handlers)) {
                         $this->_handler = 'gdbm';
                     } else {
                         if (in_array('flatfile', $handlers)) {
                             $this->_handler = 'flatfile';
                         } else {
                             debug_print_r("Failed autodetection of a usable DBA handler. Found handlers were: {$handlers}");
                             throw new midcom_error('Failed autodetection of a usable DBA handler');
                         }
                     }
                 }
             }
         }
     }
     $this->_filename = "{$this->_cache_dir}{$this->_name}.{$this->_handler}";
     // Check for file existence by opening it once for write access.
     if (!file_exists($this->_filename)) {
         $handle = dba_open($this->_filename, 'c', $this->_handler);
         if ($handle === false) {
             throw new midcom_error("Failed to open the database {$this->_filename} for creation.");
         }
         dba_close($handle);
     }
     debug_add("DBA Cache backend '{$this->_name}' initialized to file: {$this->_filename}");
 }
コード例 #8
0
ファイル: AbstractDbaTest.php プロジェクト: navassouza/zf2
 public function setUp()
 {
     if (!extension_loaded('dba')) {
         try {
             new Cache\Storage\Adapter\Dba();
             $this->fail("Expected exception Zend\\Cache\\Exception\\ExtensionNotLoadedException");
         } catch (Cache\Exception\ExtensionNotLoadedException $e) {
             $this->markTestSkipped("Missing ext/dba");
         }
     }
     if (!in_array($this->handler, dba_handlers())) {
         try {
             new Cache\Storage\Adapter\DbaOptions(array('handler' => $this->handler));
             $this->fail("Expected exception Zend\\Cache\\Exception\\ExtensionNotLoadedException");
         } catch (Cache\Exception\ExtensionNotLoadedException $e) {
             $this->markTestSkipped("Missing ext/dba handler '{$this->handler}'");
         }
     }
     $this->temporaryDbaFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('zfcache_dba_');
     $this->_options = new Cache\Storage\Adapter\DbaOptions(array('pathname' => $this->temporaryDbaFile, 'handler' => $this->handler));
     $this->_storage = new Cache\Storage\Adapter\Dba();
     $this->_storage->setOptions($this->_options);
     parent::setUp();
 }
コード例 #9
0
ファイル: Yoficator.php プロジェクト: rin-nas/php-yoficator
 /**
  * Создает из PHP-словаря словарь в формате CDB (файл с расширением .cdb в той же директории).
  * Yoficator.dic.php (UTF-8) => Yoficator.dic.cdb (UTF-8)
  *
  * @link    http://ru2.php.net/dba
  * @return  bool   TRUE, если словарь создан, FALSE в противном случае (CDB не поддерживается или файл уже существует).
  */
 private function _php2cdb()
 {
     if (!function_exists('dba_open') || !array_key_exists('cdb_make', dba_handlers(true))) {
         return false;
     }
     $filename = $this->_filename('cdb');
     if (file_exists($filename)) {
         return false;
     }
     if (!is_array($this->dic)) {
         include $this->_filename('php');
     }
     $db = dba_open($filename, 'n', 'cdb_make');
     if ($db === false) {
         return false;
     }
     #нет права доступа на запись в папку
     foreach ($this->dic as $k => $v) {
         dba_insert($k, $v, $db);
     }
     dba_optimize($db);
     dba_close($db);
 }
コード例 #10
0
ファイル: index.php プロジェクト: gjerokrsteski/php-dba-cache
        echo '<div class="alert alert-success">' . $msg . '</div>';
    } elseif (isset($check) && $check === false) {
        echo '<div class="alert alert-error"><strong>NO!</strong> ' . $msg . '</div>';
    }
}
// retrieve an cache and a cache-sweeper.
try {
    list($cache, $sweep) = factory($config);
} catch (Exception $exception) {
    die($exception->getMessage());
}
// load the configuration at the global namespace.
extract($config);
// make a list of all the available handlers.
$available_handlers = $handler_in_use = '';
foreach (dba_handlers(true) as $handler_name => $handler_version) {
    $handler_version = str_replace('$', '', $handler_version);
    if ($handler == $handler_name) {
        $handler_in_use = "{$handler_name}: {$handler_version} <br />";
        continue;
    }
    $available_handlers .= "{$handler_name}: {$handler_version} <br />";
}
// compute the user authentication.
$authenticated = false;
if (isset($_POST['login']) || isset($_SERVER['PHP_AUTH_USER'])) {
    if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] != $authentication['username'] || $_SERVER['PHP_AUTH_PW'] != $authentication['password']) {
        header("WWW-Authenticate: Basic realm=\"PHP DBA Cache Login\"");
        header("HTTP/1.0 401 Unauthorized");
        exit;
    }
コード例 #11
0
ファイル: Dba.php プロジェクト: schpill/thin
 public function debug()
 {
     $html = [];
     $html[] = "Available DBA handlers:\n<ul>\n";
     foreach (dba_handlers(true) as $handler_name => $handler_version) {
         // clean the versions
         $handler_version = str_replace('$', '', $handler_version);
         $html[] = "<li>{$handler_name}: {$handler_version}</li>\n";
     }
     $html[] = "</ul>\n";
     $html[] = "All opened databases:\n<ul>\n";
     foreach (dba_list() as $res_id => $db_name) {
         // clean the versions
         $html[] = "<li>{$res_id} : {$db_name}</li>\n";
     }
     $html[] = "</ul>\n";
     return $html;
 }
コード例 #12
0
ファイル: monisetup.php プロジェクト: reviforks/moniwiki
 function _getHostConfig()
 {
     print '<div class="check">';
     if (function_exists("dba_open")) {
         print '<h3>' . _t("Check a dba configuration") . '</h3>';
         $dbtypes = dba_handlers(true);
         $dbtests = array('db4', 'db3', 'db2', 'gdbm', 'flatfile');
         foreach ($dbtests as $mydb) {
             if (isset($dbtypes[$mydb])) {
                 $config['dba_type'] = $mydb;
                 break;
             }
         }
         if (!empty($config['dba_type'])) {
             print '<ul><li>' . sprintf(_t("%s is selected."), "<b>{$config['dba_type']}</b>") . '</li></ul>';
         } else {
             print '<p>' . sprintf(_t("No \$dba_type selected.")) . '</p>';
         }
     }
     // set random seed for security
     $config['seed'] = randstr(64);
     preg_match("/Apache\\/2\\./", $_SERVER['SERVER_SOFTWARE'], $match);
     if (preg_match('/^\\d+\\.\\d+\\.\\d+\\.\\d+$/', $_SERVER['SERVER_ADDR'])) {
         $host = $_SERVER['SERVER_ADDR'];
     } else {
         $host = $_SERVER['SERVER_NAME'];
     }
     if (empty($match)) {
         $config['query_prefix'] = '?';
         while (ini_get('allow_url_fopen')) {
             print '<h3>' . _t("Check a AcceptPathInfo setting for Apache 2.x.xx") . '</h3>';
             print '<ul>';
             $fp = @fopen('http://' . $host . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['SCRIPT_NAME'] . '/pathinfo?action=pathinfo', 'r');
             $out = '';
             if ($fp) {
                 while (!feof($fp)) {
                     $out .= fgets($fp, 2048);
                 }
             } else {
                 print "<li><b><a href='http://moniwiki.kldp.net/wiki.php/AcceptPathInfo'>AcceptPathInfo</a> <font color='red'>" . _t("Off") . "</font></b><li>\n";
                 print '</ul>';
                 break;
             }
             fclose($fp);
             if ($out[0] == '*') {
                 print "<li><b><a href='http://moniwiki.kldp.net/wiki.php/AcceptPathInfo'>AcceptPathInfo</a> <font color='red'>" . _t("Off") . "</font></b></li>\n";
             } else {
                 print "<li><b>AcceptPathInfo <font color='blue'>" . _t("On") . "</font></b></li>\n";
                 $config['query_prefix'] = '/';
             }
             print '</ul>';
             break;
         }
     }
     $url_prefix = preg_replace("/\\/([^\\/]+)\\.php\$/", "", $_SERVER['SCRIPT_NAME']);
     $config['url_prefix'] = $url_prefix;
     $user = getenv('LOGNAME');
     $user = $user ? $user : '******';
     $config['rcs_user'] = $user;
     if (getenv("OS") == "Windows_NT") {
         $config['timezone'] = "'-09-09'";
         // http://kldp.net/forum/message.php?msg_id=7675
         // http://bugs.php.net/bug.php?id=22418
         //$config['version_class']="'RcsLite'";
         $config['path'] = './bin;';
         if (is_dir('../bin')) {
             $config['path'] .= '../bin;';
         }
         // packaging for win32
         $config['path'] .= 'c:/program files/vim/vimXX';
         $config['vartmp_dir'] = "c:/tmp/";
     } else {
         $config['rcs_user'] = '******';
         // XXX
     }
     if (!file_exists('wikilib.php')) {
         $checkfile = array('plugin', 'locale');
         $dir = '';
         foreach ($checkfile as $f) {
             if (is_link($f)) {
                 $dir = dirname(readlink($f));
             }
         }
         $config['include_path'] = ".:{$dir}";
     }
     print '</div>';
     return $config;
 }
コード例 #13
0
ファイル: configurator.php プロジェクト: pombredanne/tuleap
$properties["SQL Database Name"] = new _variable('_dsn_sqldbname', "phpwiki", "\nSQL Database Name:");
$dsn_sqltype = $properties["SQL Type"]->value();
$dsn_sqluser = $properties["SQL User"]->value();
$dsn_sqlpass = $properties["SQL Password"]->value();
$dsn_sqlhostorsock = $properties["SQL Database Host"]->value();
$dsn_sqldbname = $properties["SQL Database Name"]->value();
$dsn_sqlstring = $dsn_sqltype . "://{$dsn_sqluser}:{$dsn_sqlpass}@{$dsn_sqlhostorsock}/{$dsn_sqldbname}";
$properties["SQL dsn"] = new unchangeable_define("DATABASE_DSN", $dsn_sqlstring, "\nCalculated from the settings above:");
$properties["Filename / Table name Prefix"] = new _define_commented("DATABASE_PREFIX", DATABASE_PREFIX, "\nUsed by all DB types:\n\nPrefix for filenames or table names, e.g. \"phpwiki_\"\n\nCurrently <b>you MUST EDIT THE SQL file too!</b> (in the schemas/\ndirectory because we aren't doing on the fly sql generation\nduring the installation.");
$properties["DATABASE_PERSISTENT"] = new boolean_define_commented_optional('DATABASE_PERSISTENT', array('false' => "Disabled", 'true' => "Enabled"));
$properties["DB Session table"] = new _define_optional("DATABASE_SESSION_TABLE", DATABASE_SESSION_TABLE, "\nTablename to store session information. Only supported by SQL backends.\n\nA word of warning - any prefix defined above will be prepended to whatever is given here.\n");
//TODO: $TEMP
$temp = !empty($_ENV['TEMP']) ? $_ENV['TEMP'] : "/tmp";
$properties["dba directory"] = new _define("DATABASE_DIRECTORY", $temp);
// TODO: list the available methods
$properties["dba handler"] = new _define_selection('DATABASE_DBA_HANDLER', array('gdbm' => "gdbm - GNU database manager (not recommended anymore)", 'dbm' => "DBM - Redhat default. On sf.net there's dbm and not gdbm anymore", 'db2' => "DB2 - BerkeleyDB (Sleepycat) DB2", 'db3' => "DB3 - BerkeleyDB (Sleepycat) DB3. Default on Windows but not on every Linux", 'db4' => "DB4 - BerkeleyDB (Sleepycat) DB4."), "\nUse 'gdbm', 'dbm', 'db2', 'db3' or 'db4' depending on your DBA handler methods supported: <br >  " . (function_exists("dba_handlers") ? join(", ", dba_handlers()) : "") . "\n\nBetter not use other hacks such as inifile, flatfile or cdb");
$properties["dba timeout"] = new numeric_define("DATABASE_TIMEOUT", DATABASE_TIMEOUT, "\nRecommended values are 10-20 seconds. The more load the server has, the higher the timeout.");
$properties["DBADMIN_USER"] = new _define_optional('DBADMIN_USER', DBADMIN_USER . "\nIf action=upgrade detects mysql problems, but has no ALTER permissions, \ngive here a database username which has the necessary ALTER or CREATE permissions.\nOf course you can fix your database manually. See lib/upgrade.php for known issues.");
$properties["DBADMIN_PASSWD"] = new _define_password_optional('DBADMIN_PASSWD', DBADMIN_PASSWD);
///////////////////
$properties["Page Revisions"] = new unchangeable_variable('_parttworevisions', "", "\n\nSection 2a: Archive Cleanup\nThe next section controls how many old revisions of each page are kept in the database.\n\nThere are two basic classes of revisions: major and minor. Which\nclass a revision belongs in is determined by whether the author\nchecked the \"this is a minor revision\" checkbox when they saved the\npage.\n \nThere is, additionally, a third class of revisions: author\nrevisions. The most recent non-mergable revision from each distinct\nauthor is and author revision.\n\nThe expiry parameters for each of those three classes of revisions\ncan be adjusted seperately. For each class there are five\nparameters (usually, only two or three of the five are actually\nset) which control how long those revisions are kept in the\ndatabase.\n<dl>\n   <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the\n            number of archived revisions of that class. This is\n            meant to be used as a safety cap when a non-zero\n            min_age is specified. It should be set relatively high,\n            and it's purpose is to prevent malicious or accidental\n            database overflow due to someone causing an\n            unreasonable number of edits in a short period of time.</dd>\n\n  <dt>min_age:</dt>  <dd>Revisions younger than this (based upon the supplanted\n            date) will be kept unless max_keep is exceeded. The age\n            should be specified in days. It should be a\n            non-negative, real number,</dd>\n\n  <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>\n\n  <dt>keep:</dt>     <dd>No more than this many revisions will be kept.</dd>\n\n  <dt>max_age:</dt>  <dd>No revision older than this age will be kept.</dd>\n</dl>\nSupplanted date: Revisions are timestamped at the instant that they\ncease being the current revision. Revision age is computed using\nthis timestamp, not the edit time of the page.\n\nMerging: When a minor revision is deleted, if the preceding\nrevision is by the same author, the minor revision is merged with\nthe preceding revision before it is deleted. Essentially: this\nreplaces the content (and supplanted timestamp) of the previous\nrevision with the content after the merged minor edit, the rest of\nthe page metadata for the preceding version (summary, mtime, ...)\nis not changed.\n");
// For now the expiration parameters are statically inserted as
// an unchangeable property. You'll have to edit the resulting
// config file if you really want to change these from the default.
$properties["Major Edits: keep minimum days"] = new numeric_define("MAJOR_MIN_KEEP", MAJOR_MIN_KEEP, "\nDefault: Keep for unlimited time. \nSet to 0 to enable archive cleanup");
$properties["Minor Edits: keep minumum days"] = new numeric_define("MINOR_MIN_KEEP", MINOR_MIN_KEEP, "\nDefault: Keep for unlimited time. \nSet to 0 to enable archive cleanup");
$properties["Major Edits: how many"] = new numeric_define("MAJOR_KEEP", MAJOR_KEEP, "\nKeep up to 8 major edits");
$properties["Major Edits: how many days"] = new numeric_define("MAJOR_MAX_AGE", MAJOR_MAX_AGE, "\nkeep them no longer than a month");
$properties["Minor Edits: how many"] = new numeric_define("MINOR_KEEP", MINOR_KEEP, "\nKeep up to 4 minor edits");
$properties["Minor Edits: how many days"] = new numeric_define("MINOR_MAX_AGE", "7", "\nkeep them no longer than a week");
$properties["per Author: how many"] = new numeric_define("AUTHOR_KEEP", "8", "\nKeep the latest contributions of the last 8 authors,");
コード例 #14
0
ファイル: dba.php プロジェクト: gpuenteallott/rox
 function CONNECT($dba_file)
 {
     $avail = array_reverse(dba_handlers());
     $try = substr($dba_file, strrpos($dba_file, ".") + 1);
     $try = array_merge(array($try, "gdbm", "db7", "db3", "db2", "flatfile", "db6", "db4", "db5", "ndbm", "dbm"), $avail);
     $handle = false;
     foreach ($try as $dba_handler) {
         if (in_array($dba_handler, $avail)) {
             foreach (array("w", "c", "n") as $mode) {
                 if ($handle = dba_open($dba_file, $mode, $dba_handler)) {
                     #echo "USING($dba_handler), ";
                     if ($mode != "w") {
                         dba_close($handle);
                         $handle = dba_open($dba_file, "w", $dba_handler);
                     }
                     break 2;
                 }
             }
         }
     }
     return $handle;
 }
コード例 #15
0
 public function testQdbm()
 {
     $drivers = dba_handlers(FALSE);
     $this->assertContains(FlatFileDB::HANDLER, $drivers);
 }
コード例 #16
0
ファイル: DbaOptions.php プロジェクト: tillk/vufind
 public function setHandler($handler)
 {
     $handler = (string) $handler;
     if (!function_exists('dba_handlers') || !in_array($handler, dba_handlers())) {
         throw new Exception\ExtensionNotLoadedException("DBA-Handler '{$handler}' not supported");
     }
     $this->triggerOptionEvent('handler', $handler);
     $this->handler = $handler;
     return $this;
 }
コード例 #17
0
ファイル: dict.class.php プロジェクト: lamphp/scws
 function _load($fpath)
 {
     $ext = strrchr($fpath, '.');
     $type = $ext ? strtolower(substr($ext, 1)) : 'gdbm';
     if (!in_array($type, dba_handlers())) {
         trigger_error("您的 dba 扩展不支持 `{$type}` 这一数据类型", E_USER_ERROR);
     }
     $this->_dbh = dba_popen($fpath, 'r', $type);
     if (!$this->_dbh) {
         trigger_error("无法打开类型为 `{$type}` 的 dba 数据文件 `{$fpath}`", E_USER_ERROR);
     }
 }
コード例 #18
0
ファイル: class.cache.php プロジェクト: umonkey/molinos-cms
 public static function initialize()
 {
     if (function_exists('dba_handlers') and in_array('flatfile', dba_handlers())) {
         return new DBA_FlatFile_provider('flatfile');
     }
 }
コード例 #19
0
ファイル: DBA.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Returns an array of the currently supported drivers
  *
  * @return array
  */
 function getDriverList()
 {
     if (function_exists('dba_handlers')) {
         return array_merge(dba_handlers(), array('file'));
     } else {
         return array('file');
     }
 }
コード例 #20
0
ファイル: Dba.php プロジェクト: blar/dba
 /**
  * @return array
  */
 public static function getDrivers() : array
 {
     return dba_handlers();
 }
コード例 #21
0
ファイル: get.php プロジェクト: Artea/freebeer
function do_option($option)
{
    switch ($option) {
        case 0:
            global $options;
            foreach ($options as $key => $value) {
                if ($key == 0) {
                    continue;
                }
                do_option($key);
                echo "<hr />\n";
            }
            break;
        case 1:
            echo "get_declared_classes()=";
            $a = get_declared_classes();
            ksort($a);
            print_r($a);
            foreach ($a as $class) {
                echo "get_class_methods('{$class}')=";
                $b = get_class_methods($class);
                sort($b);
                print_r($b);
            }
            break;
        case 2:
            $a = get_loaded_extensions();
            echo "get_loaded_extensions()=";
            sort($a);
            print_r($a);
            break;
        case 3:
            $a = get_loaded_extensions();
            sort($a);
            foreach ($a as $ext) {
                echo "get_extension_funcs('{$ext}')=";
                $b = get_extension_funcs($ext);
                sort($b);
                print_r($b);
            }
            break;
        case 4:
            echo "get_user_constants()=";
            $a = get_defined_constants();
            $user_constants = array();
            foreach ($a as $key => $value) {
                if (isset($PHP_CONSTANTS[$key])) {
                    continue;
                }
                $user_constants[$key] = $value;
            }
            ksort($user_constants);
            print_r($user_constants);
            break;
        case 5:
            echo "get_defined_constants()=";
            $a = get_defined_constants();
            ksort($a);
            print_r($a);
            break;
        case 6:
            echo "ini_get_all()=";
            if (function_exists('ini_get_all')) {
                $a = ini_get_all();
                ksort($a);
                print_r($a);
            } else {
                echo "not available in PHP version ", phpversion(), "\n";
            }
            break;
        case 7:
            echo "ini_get_all() (different)=";
            if (function_exists('ini_get_all')) {
                $a = ini_get_all();
                $diff = array();
                foreach ($a as $key => $value) {
                    if ($value['global_value'] != $value['local_value']) {
                        $diff[$key] = $value;
                    }
                }
                ksort($diff);
                print_r($diff);
            } else {
                echo "not available in PHP version ", phpversion(), "\n";
            }
            break;
        case 8:
            if (function_exists('dba_handlers')) {
                echo "dba_handlers()=";
                $a = dba_handlers();
                ksort($a);
                print_r($a);
            }
            break;
        case 9:
            echo "getrandmax()=", getrandmax(), "\n";
            echo "mt_getrandmax()=", mt_getrandmax(), "\n";
            break;
        case 10:
            if (function_exists('stream_get_wrappers')) {
                echo "stream_get_wrappers()=";
                $a = stream_get_wrappers();
                ksort($a);
                print_r($a);
            }
            break;
        case 11:
            echo "\$_ENV=";
            $a = $_ENV;
            ksort($a);
            print_r($a);
            break;
        case 12:
            echo "\$_SERVER=";
            $a = $_SERVER;
            ksort($a);
            print_r($a);
            break;
        default:
            break;
    }
}
コード例 #22
0
ファイル: dba.php プロジェクト: umonkey/molinos-cms
<?php

define('COUNT', 1000);
$data = file_get_contents(__FILE__);
foreach (dba_handlers() as $handler) {
    if ('inifile' == $handler) {
        continue;
    }
    $filename = 'cache.' . $handler;
    printf("testing %s\n", $handler);
    if (file_exists($filename)) {
        unlink($filename);
    }
    if (!($db = @dba_open($filename, 'cd', $handler))) {
        printf(" - open failed\n");
        continue;
    }
    $time = microtime(true);
    for ($idx = 0; $idx < COUNT; $idx++) {
        dba_replace('key' . $idx, $data, $db);
    }
    $time1 = microtime(true) - $time;
    printf(" + %u writes = %f sec (%f w/sec)\n", COUNT, $time1, $time1 / COUNT);
    $time = microtime(true);
    for ($idx = 0; $idx < COUNT; $idx++) {
        if ($data !== dba_fetch('key' . $idx, $db)) {
            printf(" - error\n");
            continue 2;
        }
    }
    $time2 = microtime(true) - $time;
コード例 #23
0
 function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename)
 {
     // Check for dba extension
     if (!extension_loaded('dba')) {
         die('PHP is not compiled with dba support, required to use DBM style cache.');
     }
     // Check for specific dba driver
     if (function_exists('dba_handlers')) {
         // PHP 4.3.0+
         if (!in_array('db3', dba_handlers())) {
             die('PHP is not compiled --with ' . $cache_type . ' support, required to use DBM style cache.');
         }
     } else {
         // PHP <= 4.2.3
         ob_start();
         // nasty, buy the only way to check...
         phpinfo();
         $contents = ob_get_contents();
         ob_end_clean();
         if (!strstr($contents, $cache_type)) {
             die('PHP is not compiled --with ' . $cache_type . ' support, required to use DBM style cache.');
         }
     }
     // Create lock file if needed
     if (!file_exists($lock_filename)) {
         if (!touch($lock_filename)) {
             die('failed to create lock file: ' . $lock_filename);
         }
     }
     // Open lock file for writing
     if (!is_writeable($lock_filename)) {
         die('lock file: ' . $lock_filename . ' is not writable');
     }
     $this->lock = fopen($lock_filename, 'w');
     // Acquire exclusive write lock to lock file
     flock($this->lock, LOCK_EX);
     // Create dbm-file if needed
     if (!file_exists($dbm_filename)) {
         if (!touch($dbm_filename)) {
             die('failed to create dbm file: ' . $dbm_filename);
         }
     }
     // Try to open dbm file for writing
     $this->dba = @dba_open($dbm_filename, 'w', $cache_type);
     if (!$this->dba) {
         // Failed - create new dbm file
         $this->dba = dba_open($dbm_filename, 'n', $cache_type);
         if (!$this->dba) {
             die('failed to create dbm file: ' . $dbm_filename);
         }
         // Insert getID3 version number
         dba_insert(GETID3_VERSION, GETID3_VERSION, $this->dba);
     }
     // Init misc values
     $this->cache_type = $cache_type;
     $this->dbm_filename = $dbm_filename;
     // Register destructor
     register_shutdown_function(array($this, '__destruct'));
     // Check version number and clear cache if changed
     if (dba_fetch(GETID3_VERSION, $this->dba) != GETID3_VERSION) {
         $this->clear_cache();
     }
     parent::getID3();
 }
コード例 #24
0
<?php

/**
 * Created by IntelliJ IDEA.
 * User: t_ishikawa
 * Date: 15/09/27
 * Time: 13:05
 */
echo "Available DBA handlers:\n";
$handlers = dba_handlers();
for ($i = 0; $i < count($handlers); $i++) {
    echo $handlers[$i] . "\n";
}
コード例 #25
0
<?php

$handler = "flatfile";
require_once dirname(__FILE__) . '/test.inc';
echo "database handler: {$handler}\n";
function check($h)
{
    if (!$h) {
        return;
    }
    foreach ($h as $key) {
        if ($key === "flatfile") {
            echo "Success: flatfile enabled\n";
        }
    }
}
echo "Test 1\n";
check(dba_handlers());
echo "Test 2\n";
check(dba_handlers(null));
echo "Test 3\n";
check(dba_handlers(1, 2));
echo "Test 4\n";
check(dba_handlers(0));
echo "Test 5 - full info\n";
$h = dba_handlers(1);
foreach ($h as $key => $val) {
    if ($key === "flatfile") {
        echo "Success: flatfile enabled\n";
    }
}
コード例 #26
0
ファイル: setup_berkeleydb.php プロジェクト: msooon/hubzilla
}
if ($failed === TRUE or !isset($_POST['handler'])) {
    echo <<<END
<form action="{$_SERVER['PHP_SELF']}" method="post">

<h2>DBA Handler</h2>

<p>
The following table shows all available DBA handlers. Please choose the "Berkeley DB" one.
</p>

<table>
<tr><td></td><td><b>Handler</b></td><td><b>Description</b></td></tr>

END;
    foreach (dba_handlers(TRUE) as $name => $version) {
        $checked = "";
        if (!isset($_POST['handler'])) {
            if (strpos($version, "Berkeley") !== FALSE) {
                $checked = " checked=\"checked\"";
            }
        } else {
            if ($_POST['handler'] == $name) {
                $checked = " checked=\"checked\"";
            }
        }
        echo "<tr><td><input type=\"radio\" name=\"handler\" value=\"{$name}\"{$checked} /></td><td>{$name}</td><td>{$version}</td></tr>\n";
    }
    echo <<<END
</table>