本文整理汇总了PHP中dba_close函数的典型用法代码示例。如果您正苦于以下问题:PHP dba_close函数的具体用法?PHP dba_close怎么用?PHP dba_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dba_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
/**
* Closes an open dba resource
*
* @return void
*/
public function __destruct()
{
if ($this->dba) {
dba_close($this->dba);
$this->dba = null;
}
}
示例2: close
public function close()
{
if (isset($this->handle)) {
dba_close($this->handle);
}
unset($this->handle);
}
示例3: run
function run()
{
global $wgExtensionMessagesFiles, $wgMessageCache, $IP;
$nameHash = md5(implode("\n", array_keys($wgExtensionMessagesFiles)));
$dir = "{$IP}/cache/ext-msgs";
wfMkdirParents($dir);
$db = dba_open("{$dir}/{$nameHash}.cdb", 'n', 'cdb');
if (!$db) {
echo "Cannot open DB file\n";
exit(1);
}
# Load extension messages
foreach ($wgExtensionMessagesFiles as $file) {
$messages = $magicWords = array();
require $file;
foreach ($messages as $lang => $unused) {
$wgMessageCache->processMessagesArray($messages, $lang);
}
}
# Write them to the file
foreach ($wgMessageCache->mExtensionMessages as $lang => $messages) {
foreach ($messages as $key => $text) {
dba_insert("{$lang}:{$key}", $text, $db);
}
}
dba_close($db);
}
示例4: __get
public function __get($name)
{
$db = dba_open($this->filePath, 'wl', 'db4');
$value = dba_exists($name, $db) ? dba_fetch($name, $db) : null;
dba_close($db);
return $value;
}
示例5: addcomment
function addcomment($m)
{
global $xmlrpcerruser;
$err = "";
// get the first param
$msgID = php_xmlrpc_decode($m->getParam(0));
$name = php_xmlrpc_decode($m->getParam(1));
$comment = php_xmlrpc_decode($m->getParam(2));
$dbh = dba_open("/tmp/comments.db", "c", "db2");
if ($dbh) {
$countID = "{$msgID}_count";
if (dba_exists($countID, $dbh)) {
$count = dba_fetch($countID, $dbh);
} else {
$count = 0;
}
// add the new comment in
dba_insert($msgID . "_comment_{$count}", $comment, $dbh);
dba_insert($msgID . "_name_{$count}", $name, $dbh);
$count++;
dba_replace($countID, $count, $dbh);
dba_close($dbh);
} else {
$err = "Unable to open comments database.";
}
// if we generated an error, create an error return response
if ($err) {
return new xmlrpcresp(0, $xmlrpcerruser, $err);
} else {
// otherwise, we create the right response
// with the state name
return new xmlrpcresp(new xmlrpcval($count, "int"));
}
}
示例6: addComment
function addComment($req)
{
$err = "";
// since validation has already been carried out for us,
// we know we got exactly 3 string values
$encoder = new PhpXmlRpc\Encoder();
$n = $encoder->decode($req);
$msgID = $n[0];
$name = $n[1];
$comment = $n[2];
$dbh = dba_open("/tmp/comments.db", "c", "db2");
if ($dbh) {
$countID = "{$msgID}_count";
if (dba_exists($countID, $dbh)) {
$count = dba_fetch($countID, $dbh);
} else {
$count = 0;
}
// add the new comment in
dba_insert($msgID . "_comment_{$count}", $comment, $dbh);
dba_insert($msgID . "_name_{$count}", $name, $dbh);
$count++;
dba_replace($countID, $count, $dbh);
dba_close($dbh);
} else {
$err = "Unable to open comments database.";
}
// if we generated an error, create an error return response
if ($err) {
return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
} else {
// otherwise, we create the right response
return new PhpXmlRpc\Response(new PhpXmlRpc\Value($count, "int"));
}
}
示例7: close
function close()
{
if (isset($this->handle)) {
dba_close($this->handle);
$this->handle = null;
}
}
示例8: __destruct
/**
* Closes the database connection.
*
* @access public
* @return void
*/
function __destruct()
{
if ($this->_db !== NULL) {
dba_close($this->_db);
$this->connected = FALSE;
}
}
示例9: buildPathCache
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;
}
示例10: CloseDataBase
function CloseDataBase($dbi)
{
reset($dbi);
while (list($dbmfile, $dbihandle) = each($dbi)) {
dba_close($dbihandle);
}
return;
}
示例11: db4_close
function db4_close()
{
if (isset($GLOBALS['db'])) {
$res = $GLOBALS['db'];
unset($GLOBALS['db']);
return dba_close($res);
}
}
示例12: Close
function Close()
{
if (!$this->handler) {
return;
}
dba_close($this->handler);
$this->handler = false;
}
示例13: recovery
public function recovery($record)
{
$key = $record['key'];
$store['value'] = $record['value'];
$store['dateline'] = $record['dateline'];
$store['ttl'] = $record['ttl'];
$rs = dba_open(DATA_DIR . '/kvstore/dba.db', 'cl', $this->handle);
$ret = dba_replace($this->create_key($key), serialize($store), $rs);
dba_close($rs);
return $ret;
}
示例14: berekley_db_create
function berekley_db_create($db_path)
{
if (is_file($db_path)) {
return true;
}
$db_desttmp = @dba_open($db_path, "c", "db4");
@dba_close($db_desttmp);
if (is_file($db_path)) {
return true;
}
ToSyslog("berekley_db_create:: Failed Creating {$db_path} database");
}
示例15: radius_authenticate
function radius_authenticate($user, $password)
{
global $HTTP_COOKIE_VARS;
global $REMOTE_ADDR;
if (($db = dba_open("/tmp/radiuscache", "c", "ndbm")) == FALSE) {
echo "Couldn't open /tmp/radiuscache<br>\n";
}
$cookie = $HTTP_COOKIE_VARS["radius_test"];
if ($cookie != "") {
$lastid = dba_fetch($cookie . "_id", $db);
$laston = dba_fetch($cookie . "_laston", $db);
$lasthost = dba_fetch($cookie . "_fromip", $db);
$lastuserid = dba_fetch($cookie . "_userid", $db);
}
//
// Sanity checking
//
if ($cookie == "" || $lastid == "" || $laston == 0 || $laston < time() - 15 * 60 || $lasthost != $REMOTE_ADDR || $lastuserid != $user) {
// 2 -> Access-Accept
// 3 -> Access-Reject
if (($retval = RADIUS_AUTHENTICATION($user, $password)) == 2) {
if ($cookie == "") {
$cookie = md5(uniqid(rand()));
}
setcookie("radius_test", $cookie);
dba_replace($cookie . "_id", $cookie, $db);
dba_replace($cookie . "_userid", $user, $db);
dba_replace($cookie . "_fromip", $REMOTE_ADDR, $db);
dba_replace($cookie . "_laston", time(), $db);
}
} else {
setcookie("radius_test", $cookie);
dba_replace($cookie . "_laston", time(), $db);
$retval = 2;
}
dba_close($db);
return $retval == 2;
}