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; }
/** * Delete cache * @param string $id * @return boolean */ public function delete($key) { if (!dba_exists($key, $this->_handler('r'))) { return true; } return dba_delete($key, $this->_handler('w')); }
function getComments($req) { $err = ""; $ra = array(); $encoder = new PhpXmlRpc\Encoder(); $msgID = $encoder->decode($req->getParam(0)); $dbh = dba_open("/tmp/comments.db", "r", "db2"); if ($dbh) { $countID = "{$msgID}_count"; if (dba_exists($countID, $dbh)) { $count = dba_fetch($countID, $dbh); for ($i = 0; $i < $count; $i++) { $name = dba_fetch("{$msgID}_name_{$i}", $dbh); $comment = dba_fetch("{$msgID}_comment_{$i}", $dbh); // push a new struct onto the return array $ra[] = array("name" => $name, "comment" => $comment); } } } // 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($encoder->encode($ra)); } }
public function exists($key) { if (!$this->db_file_exists()) { return FALSE; } return dba_exists($key, $this->get_db_handle('r')); }
function getcomments($m) { global $xmlrpcerruser; $err = ""; $ra = array(); // get the first param if (XMLRPC_EPI_ENABLED == '1') { $msgID = xmlrpc_decode($m->getParam(0)); } else { $msgID = php_xmlrpc_decode($m->getParam(0)); } $dbh = dba_open("/tmp/comments.db", "r", "db2"); if ($dbh) { $countID = "{$msgID}_count"; if (dba_exists($countID, $dbh)) { $count = dba_fetch($countID, $dbh); for ($i = 0; $i < $count; $i++) { $name = dba_fetch("{$msgID}_name_{$i}", $dbh); $comment = dba_fetch("{$msgID}_comment_{$i}", $dbh); // push a new struct onto the return array $ra[] = array("name" => $name, "comment" => $comment); } } } // 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(php_xmlrpc_encode($ra)); } }
function lookup_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/ if (dba_exists("nonce_$nonce", $this->dbh)) { return TRUE; } else { dba_insert("nonce_$nonce", "1", $this->dbh); return FALSE; } }/*}}}*/
function lookupNonce($consumer, $token, $nonce, $timestamp) { if (dba_exists("nonce_{$nonce}", $this->dbh)) { return true; } else { dba_insert("nonce_{$nonce}", "1", $this->dbh); return false; } }
//�ppna databasen $db = dba_open("my_db.db", "c", "db4"); $entry = 0; // R�knar hur m�nga entries som finns i databasen while (dba_exists($entry, $db)) { $entry++; } // G�r ett l�mplig datum och tidsvisning till en str�ng $time = date("Y-n-d G:i:s"); // Fyller databasen med v�sentliga v�rden dba_insert($entry, $_SERVER['HTTP_USER_AGENT'], $db); dba_insert(++$entry, $_SERVER['REMOTE_ADDR'], $db); dba_insert(++$entry, $time, $db); //H�mtar fr�n databasen s�l�nge som det finns n�got i en viss entry $counter = 3; while (dba_exists($entry, $db)) { //�r det tiden som h�mtades? if ($counter == 3) { echo "Time: " . dba_fetch($entry, $db) . "\n"; } else { if ($counter == 2) { echo "Remote address: " . dba_fetch($entry, $db) . "\n"; } else { echo "User Agent: " . dba_fetch($entry, $db) . "\n\n"; } } // Minska r�knaren nu med ett --$counter; // �r r�knaren lika med noll?, i s�nna fall b�rja om fr�n b�rjan med r�knandet if (!$counter) { $counter = 3;
$handler = 'cdb'; $db_file = dirname(__FILE__) . '/test.cdb'; if (($db_file = dba_open($db_file, "r", $handler)) !== FALSE) { // read key sequence $a = dba_firstkey($db_file); $count = 0; $keys = $a; while ($a) { $a = dba_nextkey($db_file); $keys .= $a; $count++; } // display number of entries and key existence echo $count; for ($i = 1; $i < 8; $i++) { echo dba_exists($i, $db_file) ? "Y" : "N"; } echo "\n="; echo dba_fetch(1, $db_file); echo dba_fetch(2, $db_file); echo dba_fetch(3, $db_file); echo dba_fetch(4, $db_file); echo "\n#"; echo dba_fetch(1, $db_file); echo dba_fetch(1, $db_file); echo dba_fetch(2, $db_file); echo dba_fetch(2, $db_file); echo "\n?" . $keys; // with skip = 0 dba_fetch must fetch the first result echo "\n#"; $skip = array();
function ifAlreadyDownloaded($uri) { $fam = new familysite(); $parse_url = parse_url($uri); $hostname = $parse_url["host"]; $familysite = $fam->GetFamilySites($hostname); $dbfile = "{$GLOBALS["HyperCacheStoragePath"]}/cache.db"; if (!is_file($dbfile)) { events("ifAlreadyDownloaded:: {$dbfile} no such file..."); return false; } $db_con = @dba_open($dbfile, "c", "db4"); if (!$db_con) { events("analyze:: FATAL!!!::{$dbfile}, unable to open"); return false; } if (@dba_exists($uri, $db_con)) { $array = unserialize(dba_fetch($uri, $db_con)); $filepath = $array["filepath"]; if (is_file("{$GLOBALS["HyperCacheStoragePath"]}/{$filepath}")) { $filesize = $array["filesize"]; if ($filesize == @filesize("{$GLOBALS["HyperCacheStoragePath"]}/{$filepath}")) { events("ifAlreadyDownloaded:: {$GLOBALS["HyperCacheStoragePath"]}/{$filepath} already exists"); @dba_close($db_con); return true; } } } else { events("ifAlreadyDownloaded:: {$uri} doesn't exists..."); } @dba_close($db_con); return false; }
/** * Internal method to remove an item. * * @param string $normalizedKey * @return bool * @throws Exception\ExceptionInterface */ protected function internalRemoveItem(&$normalizedKey) { $options = $this->getOptions(); $namespace = $options->getNamespace(); $prefix = $namespace === '' ? '' : $namespace . $options->getNamespaceSeparator(); $internalKey = $prefix . $normalizedKey; $this->_open(); // Workaround for PHP-Bug #62490 if (!dba_exists($internalKey, $this->handle)) { return false; } return dba_delete($internalKey, $this->handle); }
/** * @return bool */ public function bExists($sKey) { return dba_exists($sKey, $this->_hFile); }
function delete($key) { if (dba_exists($key, $this->_id)) { return dba_delete($key, $this->_id); } return 1; }
function Phistank($ARRAY) { $URI = $ARRAY["URI"]; if (!is_file("/etc/squid3/phistank.db")) { if ($GLOBALS["VERBOSE"]) { events("/etc/squid3/phistank.db no such file"); } return false; } $CONNECT = false; $KEY = null; if (isset($ARRAY["MAC"])) { $MAC = $ARRAY["MAC"]; } $H = parse_url($URI); $domain = $H["host"]; $md51 = md5($domain); $md52 = md5($URI); $md53 = md5($URI . "/"); $userid = $ARRAY["userid"]; $PROTO = $ARRAY["PROTO"]; $IP = $ARRAY["IP"]; if (isset($GLOBALS["PHISHTANK_QUEUE"])) { if (count($GLOBALS["PHISHTANK_QUEUE"]) > 10000) { $GLOBALS["PHISHTANK_QUEUE"] = array(); } } if (preg_match("#([0-9\\.]+)\\/(.*)#", $IP, $re)) { $hostname = $re[2]; $IP = $re[1]; } $SquidGuardIPWeb = $GLOBALS["SquidGuardIPWeb"]; $CONNECT = false; $KEY = null; if (isset($ARRAY["MAC"])) { $MAC = $ARRAY["MAC"]; } $urlenc = urlencode($URI); $returned = "{$GLOBALS["SquidGuardIPWeb"]}?rule-id=0SquidGuardIPWeb=" . base64_encode($GLOBALS["SquidGuardIPWeb"]) . "&clientaddr={$IP}&clientname={$IP}&clientuser={$userid}" . "&clientgroup=default&targetgroup=phishtank&url={$urlenc}"; $md5Key = md5("{$userid}{$IP}{$URI}"); if (isset($GLOBALS["PHISHTANK_QUEUE"][$md5Key])) { ufdbgevents("default", "phishtank"); Output_results($GLOBALS["PHISHTANK_QUEUE"][$md5Key], __FUNCTION__, __LINE__); return true; } $db_con = @dba_open("/etc/squid3/phistank.db", "r", "db4"); if (!$db_con) { if ($GLOBALS["VERBOSE"]) { events("Phistank: FATAL!!!::/etc/squid3/phistank.db, unable to open"); } return false; } if (@dba_exists($md51, $db_con)) { @dba_close($db_con); ufdbgevents("phishtank", "phishtank"); $GLOBALS["PHISHTANK_QUEUE"][$md5Key] = $returned; Output_results($returned, __FUNCTION__, __LINE__); return true; } if (@dba_exists($md52, $db_con)) { @dba_close($db_con); ufdbgevents("default", "phishtank"); $GLOBALS["PHISHTANK_QUEUE"][$md5Key] = $returned; Output_results($returned, __FUNCTION__, __LINE__); return true; } if (@dba_exists($md53, $db_con)) { @dba_close($db_con); ufdbgevents("phishtank", "phishtank"); $GLOBALS["PHISHTANK_QUEUE"][$md5Key] = $returned; Output_results($returned, __FUNCTION__, __LINE__); return true; } return false; }
/** * Checks if a key/value pair exists in the database. * * @access public * @param string $key * @return boolean * */ function exists($key) { return @dba_exists($key, $this->connection); }
function HyperCacheMD5File_get($md5) { $dbfile = "/usr/share/squid3/HyperCacheMD5.db"; if (!is_file($dbfile)) { if ($GLOBALS["VERBOSE"]) { echo "<li>" . __LINE__ . " {$dbfile} no such file</li>"; } return; } $db_con = dba_open($dbfile, "r", "db4"); if (!$db_con) { return; } if (!@dba_exists($md5, $db_con)) { if ($GLOBALS["VERBOSE"]) { echo "<li>" . __LINE__ . " {$md5} no such entry</li>"; } @dba_close($db_con); return null; } $fetch_content = @dba_fetch($md5, $db_con); $array = @unserialize($fetch_content); $FILEPATH = $array["FILEPATH"]; $FILENAME = $array["FILENAME"]; if ($GLOBALS["VERBOSE"]) { echo "<li>" . __LINE__ . " {$md5} PATH = {$FILEPATH} / {$FILENAME}</li>"; } @dba_close($db_con); return $array; }
function get_reverse_string($key) { if (!($id = dba_open(FILE_REVERSE_DB_PATH, "wd", FILEDB_HANDLER))) { return ERROR; } if (dba_exists($key, $id)) { $str = dba_fetch($key, $id); } else { $str = ERROR; } dba_close($id); return $str; }
// | License as published by the Free Software Foundation; either | // | version 2.1 of the License, or (at your option) any later version. | // | | // | This library is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | // | Lesser General Public License for more details. | // | | // | You should have received a copy of the GNU Lesser General Public | // | License along with this library; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA| // +----------------------------------------------------------------------+ // | Author: Brent Cook <*****@*****.**> | // +----------------------------------------------------------------------+ // // $Id: test_compatibility.php,v 1.2 2003/01/04 11:54:51 mj Exp $ // // test functionality of the dba compatibility layer require_once 'DBA/Compatibility.php'; $id = dba_open("file_test", "n", "db3"); if (!$id) { echo "dba_open failed\n"; exit; } dba_insert("key", "This is an example!", $id); dba_replace("key", "This is another example!", $id); if (dba_exists("key", $id)) { echo dba_fetch("key", $id); dba_delete("key", $id); } dba_close($id);
/** * Checks for existance of a key * * @param string key * @return bool TRUE if the specified key exists */ public function lookup($key) { return dba_exists($key, $this->_fd); }
function LASTVER($id) { $n = 1; while (dba_exists("{$id}.{$n}", $this->handle)) { $n++; } return --$n; }
public function isValid($key) { return dba_exists($key, $this->dbHandler); }
function lookup_nonce($consumer, $token, $nonce, $timestamp) { /*{{{*/ if (dba_exists("nonce_{$nonce}", $this->dbh)) { return TRUE; } else { dba_insert("nonce_{$nonce}", time(), $this->dbh); $this->cleanup_nonce(); return FALSE; } }
function lookup_nonce($consumer, $token, $nonce, $timestamp) { return dba_exists("nonce_$nonce", $this->dbh); }
function lookup_nonce($consumer, $token, $nonce, $timestamp) { /*{{{*/ return dba_exists("nonce_{$nonce}", $this->dbh); }
<?php $user = $_SERVER['argv'][1]; $password = $_SERVER['argv'][2]; $data_file = '/tmp/users.db'; $dbh = dba_open($data_file, 'c', 'db4') or die("Can't open db {$data_file}"); if (dba_exists($user, $dbh)) { print "User {$user} exists. Changing password."; } else { print "Adding user {$user}."; } dba_replace($user, $password, $dbh) or die("Can't write to database {$data_file}"); dba_close($dbh);
function GetHitCount($dbi, $pagename) { if (dba_exists($pagename, $dbi['hitcount'])) { // increase the hit count $count = dba_fetch($pagename, $dbi['hitcount']); return $count; } else { return 0; } }
/** * @param $key string * @param $time int * @return bool */ public function delete($key, $time = 0) { wfProfileIn(__METHOD__); wfDebug(__METHOD__ . "({$key})\n"); $handle = $this->getWriter(); if (!$handle) { wfProfileOut(__METHOD__); return false; } $ret = !dba_exists($key, $handle) || dba_delete($key, $handle); dba_close($handle); wfProfileOut(__METHOD__); return $ret; }
<?php $handler = "inifile"; include "test.inc"; $dba = dba_open($db_filename, "n", $handler) or die; for ($i = 0; $i < 3; ++$i) { echo "insert {$i}:"; var_dump(dba_insert("a", $i, $dba)); } echo "exists:"; var_dump(dba_exists("a", $dba)); echo "delete:"; var_dump(dba_delete("a", $dba)); echo "exists:"; var_dump(dba_exists("a", $dba)); echo "delete:"; var_dump(dba_delete("a", $dba)); ?> ===DONE===
<?php require_once dirname(__FILE__) . '/test.inc'; echo "database handler: {$handler}\n"; if (($db_file = dba_open($db_filename, "n", $handler)) !== FALSE) { dba_insert("key1", "Content String 1", $db_file); dba_insert("key2", "Content String 2", $db_file); $a = dba_firstkey($db_file); $i = 0; while ($a) { $a = dba_nextkey($db_file); $i++; } echo $i; for ($i = 1; $i < 3; $i++) { echo dba_exists("key{$i}", $db_file) ? "Y" : "N"; } echo "\n"; var_dump(dba_optimize()); var_dump(dba_optimize("")); var_dump(dba_optimize($db_file)); dba_close($db_file); } else { echo "Error creating database\n"; } ?> ===DONE===
function UserAuthDB($mac, $ipaddr, $uid, $hostname, $UserAgent) { $keymd5 = md5("{$mac}{$ipaddr}{$uid}{$hostname}{$UserAgent}"); if ($mac != null) { $keymd5 = md5("{$mac}{$uid}{$UserAgent}"); } if (isset($GLOBALS["UserAuthDB"][$keymd5])) { return; } $array["MAC"] = $mac; $array["IPADDR"] = $ipaddr; $array["uid"] = $uid; $array["hostname"] = $hostname; $array["UserAgent"] = $UserAgent; $db_con = @dba_open($GLOBALS["UserAuthDB_path"], "c", "db4"); if (!$db_con) { events("UserAuthDB:: FATAL!!!::{$GLOBALS["UserAuthDB_path"]}, unable to open"); return false; } if (!@dba_exists($keymd5, $db_con)) { @dba_replace($keymd5, serialize($array), $db_con); $GLOBALS["UserAuthDB"][$keymd5] = true; } else { $GLOBALS["UserAuthDB"][$keymd5] = true; } @dba_close($db_con); }