当前位置: 首页>>代码示例>>PHP>>正文


PHP dba_replace函数代码示例

本文整理汇总了PHP中dba_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP dba_replace函数的具体用法?PHP dba_replace怎么用?PHP dba_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dba_replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send_to_mysql

function send_to_mysql($buffer)
{
    $dbpath = "/home/artica/postfix/milter-greylist/logger/" . date("YmdH") . ".miltergreylist.db";
    if (!berekley_db_create($dbpath)) {
        return;
    }
    $db_con = @dba_open($dbpath, "w", "db4");
    if (!$db_con) {
        ToSyslog("send_to_mysql:: {$dbpath} failed connect");
        @dba_close($db_con);
        continue;
    }
    $results = explode(",", $buffer);
    $md5 = md5($buffer . time());
    $instance = $results[0];
    $publicip = $results[1];
    $mailfrom = mysql_escape_string2($results[2]);
    $rcpt = mysql_escape_string2($results[3]);
    $failed = $results[6];
    $Country = $results[7];
    $HOUR = date('H');
    $date = date("Y-m-d H:i:s");
    $tablename = "mgreyh_" . date("YmdH");
    $mailfromZ = explode("@", $mailfrom);
    $rcptZ = explode("@", $rcpt);
    $prefix = "INSERT IGNORE INTO {$tablename} (`zmd5`,`ztime`,`zhour`,`mailfrom`,`instancename`,`mailto`,`domainfrom`,`domainto`,`senderhost`,`failed`) VALUES ";
    $suffix = "('{$md5}','{$date}','{$HOUR}','{$mailfrom}','{$instance}','{$rcpt}','{$mailfromZ[1]}','{$rcptZ[1]}','{$publicip}','{$failed}')";
    $md5 = md5($suffix);
    dba_replace($md5, $suffix, $db_con);
    @dba_close($db_con);
    return;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:32,代码来源:exec.milter-greylist.logger.php

示例2: store

 public function store($key, $value, $ttl = 0)
 {
     $store['value'] = $value;
     $store['dateline'] = time();
     $store['ttl'] = $ttl;
     return dba_replace($this->create_key($key), serialize($store), $this->rs);
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:7,代码来源:dba.php

示例3: 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"));
    }
}
开发者ID:bitweaver,项目名称:xmlrpc_lib,代码行数:34,代码来源:discuss.php

示例4: 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"));
    }
}
开发者ID:TsobuEnterprise,项目名称:phpxmlrpc,代码行数:35,代码来源:discuss.php

示例5: HIT

 function HIT($id)
 {
     $key = "{$id}.1";
     if ($r = unserialize(gzuncompress(dba_fetch($key, $this->handle)))) {
         $r["hits"] += 1;
         dba_replace($key, gzcompress(serialize($r), $this->gz), $this->handle);
     }
 }
开发者ID:gpuenteallott,项目名称:rox,代码行数:8,代码来源:dba.php

示例6: db4_replace

function db4_replace($key, $val)
{
    dbg_log("db4_replace({$key}, {$val})<br />");
    $ret = dba_replace(bin4($key), $val, $GLOBALS['db']);
    if ($ret === false) {
        die('failed to replace');
    }
    return $ret;
}
开发者ID:JasonWoof,项目名称:square,代码行数:9,代码来源:db.php

示例7: 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;
 }
开发者ID:syjzwjj,项目名称:quyeba,代码行数:11,代码来源:dba.php

示例8: set

 public function set($key, $value)
 {
     // Store
     if ($this->useCache) {
         $this->cache[$key] = $value;
     }
     // Convert
     $v = $this->encode($value);
     // Write
     if (dba_exists($key, $this->dbHandler)) {
         $r = dba_replace($key, $v, $this->dbHandler);
     } else {
         $r = dba_insert($key, $v, $this->dbHandler);
     }
     return $r;
 }
开发者ID:schpill,项目名称:thin,代码行数:16,代码来源:Dba.php

示例9: _swap

 private function _swap()
 {
     $count =& $this->_count;
     $disk =& $this->_disk;
     /* freeing memory and dump it to disk  {{{ */
     $limit = $this->_limit;
     if (memory_get_usage() / (1024 * 1024) <= $limit) {
         return;
         /* nothing to free-up, so return */
     }
     $limit -= $this->_threshold;
     /* dump X megabytes to disk */
     $wdata =& $this->_data;
     end($wdata);
     fwrite(STDERR, "Freeing " . ceil(memory_get_usage() / (1024 * 1024)) . "M " . time() . "\n");
     $i = $count;
     while (memory_get_usage() / (1024 * 1024) >= $limit) {
         if (--$i < 0) {
             break;
         }
         $xdata = current($wdata);
         if (!is_array($xdata)) {
             prev($wdata);
             continue;
         }
         $xkey = key($wdata);
         fwrite(STDERR, "\t\tAttempt to free {$xkey}\n");
         $serial = serialize($xdata);
         if (!dba_insert($xkey, $serial, $this->_db)) {
             dba_replace($xkey, $serial, $this->_db);
         }
         unset($wdata[$xkey]);
         unset($xdata);
         unset($serial);
         $wdata[$xkey] = true;
         prev($wdata);
         $disk++;
     }
     dba_sync($this->_db);
     fwrite(STDERR, "\tFreed " . ceil(memory_get_usage() / (1024 * 1024)) . "M " . time() . "\n");
     /* }}} */
 }
开发者ID:rosarion,项目名称:php-hadoop,代码行数:42,代码来源:mem-file.php

示例10: 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;
}
开发者ID:nicolnx,项目名称:norad,代码行数:38,代码来源:radius.php

示例11: addcomment

function addcomment($m)
{
    global $xmlrpcerruser;
    $err = "";
    // since validation has already been carried out for us,
    // we know we got exactly 3 string values
    $n = php_xmlrpc_decode($m);
    $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 xmlrpcresp(0, $xmlrpcerruser, $err);
    } else {
        // otherwise, we create the right response
        // with the state name
        return new xmlrpcresp(new xmlrpcval($count, "int"));
    }
}
开发者ID:partisan-collective,项目名称:partisan,代码行数:36,代码来源:discuss.php

示例12: dba_open

// | 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 <busterb@mail.utexas.edu>                         |
// +----------------------------------------------------------------------+
//
// $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);
开发者ID:laiello,项目名称:coopcrucial,代码行数:31,代码来源:test_compatibility.php

示例13: unlock_ufdbguard_artica

function unlock_ufdbguard_artica()
{
    $dbfile = "/var/log/squid/ufdbgclient.unlock.db";
    $unix = new unix();
    $q = new mysql_squid_builder();
    $RESET = false;
    $Count = $q->COUNT_ROWS("ufdbunlock");
    $q->QUERY_SQL("DELETE FROM ufdbunlock WHERE finaltime <" . time());
    $Count2 = $q->COUNT_ROWS("ufdbunlock");
    if ($Count2 != $Count) {
        $RESET = TRUE;
    }
    if ($GLOBALS["RELOAD"]) {
        $RESET = TRUE;
    }
    $sql = "SELECT * FROM ufdbunlock WHERE finaltime > " . time();
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
    }
    @unlink($dbfile);
    echo "berekley_db:: Creating {$dbfile} database\n";
    $db_desttmp = @dba_open($dbfile, "c", "db4");
    @dba_close($db_desttmp);
    if (!is_file($dbfile)) {
        squid_admin_mysql(2, "berekley_db::FATAL ERROR", $dbfile, __FILE__, __LINE__);
        return;
    }
    $db_con = @dba_open($dbfile, "c", "db4");
    echo mysql_num_rows($results) . " Rows... {$sql}\n";
    while ($ligne = mysql_fetch_assoc($results)) {
        $md5 = $ligne["md5"];
        $finaltime = $ligne["finaltime"];
        $uid = $ligne["uid"];
        $ipaddr = $ligne["ipaddr"];
        $www = $ligne["www"];
        if ($GLOBALS["VERBOSE"]) {
            echo "***** {$md5} {$www} {$ipaddr}******\n";
        }
        unlock_events("{$md5} {$www} {$ipaddr} > {$finaltime}");
        $array["finaltime"] = $finaltime;
        $array["uid"] = $uid;
        $array["ipaddr"] = $ipaddr;
        $array["www"] = $www;
        @dba_replace($md5, serialize($array), $db_con);
    }
    @dba_close($db_con);
    if ($RESET) {
        $php = $unix->LOCATE_PHP5_BIN();
        shell_exec("{$php} /usr/share/artica-postfix/exec.ufdbclient.reload.php");
        unlock_events("{$php} /usr/share/artica-postfix/exec.ufdbclient.reload.php");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:53,代码来源:exec.ufdb.queue.release.php

示例14: GoogleSafeBrowsingInCache

function GoogleSafeBrowsingInCache($servername)
{
    $dbfile = "/var/log/squid/GoogleSafeBrowsing.db";
    $GoogleSafeBrowsingCacheTime = $GLOBALS["GoogleSafeBrowsingCacheTime"];
    if (isset($GLOBALS["GoogleSafeBrowsingCache_time"])) {
        $Since = tool_time_min($GLOBALS["GoogleSafeBrowsingCache_time"]);
        if ($GLOBALS["GOOGLE_SAFE"]) {
            events("GoogleSafeBrowsingInCache: {$dbfile} ({$Since}Mn/{$GoogleSafeBrowsingCacheTime}Mn");
        }
        if ($Since > $GoogleSafeBrowsingCacheTime) {
            $GLOBALS["GoogleSafeBrowsingMEMCache"] = array();
            @unlink($dbfile);
        }
    }
    $MD5 = md5($servername);
    if (isset($GLOBALS["GoogleSafeBrowsingMEMCache"][$MD5])) {
        if (count($GLOBALS["GoogleSafeBrowsingMEMCache"]) > 64000) {
            $GLOBALS["GoogleSafeBrowsingMEMCache"] = array();
        }
        return $GLOBALS["GoogleSafeBrowsingMEMCache"][$MD5];
    }
    tool_create_berekley($dbfile);
    if (!is_file($dbfile)) {
        return null;
    }
    $db_con = @dba_open($dbfile, "r", "db4");
    if (!$db_con) {
        events("GoogleSafeBrowsingInCache:: FATAL!!!::{$dbfile}, unable to open");
        return null;
    }
    if (!@dba_exists("CREATED", $db_con)) {
        $GLOBALS["GoogleSafeBrowsingCache_time"] = time();
        @dba_replace("CREATED", time(), $db_con);
    }
    if (!isset($GLOBALS["GoogleSafeBrowsingCache_time"])) {
        if (@dba_exists("CREATED", $db_con)) {
            $GLOBALS["GoogleSafeBrowsingCache_time"] = dba_fetch("CREATED", $db_con);
        }
    }
    if (!@dba_exists($MD5, $db_con)) {
        @dba_close($db_con);
        return null;
    }
    $result = dba_fetch($MD5, $db_con);
    $GLOBALS["GoogleSafeBrowsingMEMCache"][$MD5] = $result;
    @dba_close($db_con);
    return $result;
}
开发者ID:articatech,项目名称:artica,代码行数:48,代码来源:ufdbgclient.php

示例15: buildRules_mirror

function buildRules_mirror()
{
    $dbfile = "/usr/share/squid3/HyperCacheRules_mirror.db";
    @unlink($dbfile);
    if (!is_file($dbfile)) {
        try {
            events("Creating {$dbfile} database", 0, 2, __LINE__);
            $db_desttmp = @dba_open($dbfile, "c", "db4");
        } catch (Exception $e) {
            $error = $e->getMessage();
            events("analyze::FATAL ERROR {$error} on {$dbfile}");
        }
        @dba_close($db_desttmp);
    }
    if (!is_file($dbfile)) {
        return;
    }
    $db_con = @dba_open($dbfile, "c", "db4");
    if (!$db_con) {
        events("FATAL!!!::{$dbfile}, unable to open", 0, 0, __LINE__);
        return false;
    }
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL("SELECT * FROM artica_caches_mirror WHERE enabled=1");
    while ($ligne = mysql_fetch_assoc($results)) {
        $sitename = $ligne["sitename"];
        $ID = $ligne["ID"];
        echo "Building mirror rule {$ID} {$sitename}\n";
        @dba_replace($sitename, "NONE", $db_con);
    }
    @dba_close($db_con);
    @chown($dbfile, "squid");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:33,代码来源:exec.squidcache.php


注:本文中的dba_replace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。