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


PHP SetCache函数代码示例

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


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

示例1: lib_changyan

function lib_changyan(&$ctag, &$refObj)
{
    global $dsql, $envs;
    //属性处理
    $attlist = "type|code,config|,class|_DEDECY,style|";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $reval = "";
    if (!$dsql->IsTable("#@__plus_changyan_setting")) {
        return '没安装畅言模块';
    }
    $client_id = changyan_get_setting('appid');
    if (empty($client_id)) {
        return '尚未注册畅言帐号,请到后台注册';
    }
    if ($type == 'code' or $type == 'code2') {
        $reval .= "<div class='{$class}' style='{$style}'>";
        $prefix = 'changyan';
        $key = 'code';
        $row = GetCache($prefix, $key);
        if (!is_array($row)) {
            $appid = changyan_get_setting('appid');
            $user = changyan_get_setting('user');
            $sign = changyan_gen_sign($user);
            $result = changyan_getcode(CHANGYAN_CLIENT_ID, $user, false, $sign, $appid);
            $row['reval'] = htmlspecialchars($result['code']);
            SetCache($prefix, $key, $row, 60 * 60 * 1);
        }
        if (!empty($config)) {
            $config_arr = array();
            $configs = explode(',', $config);
            if (count($configs) > 0) {
                foreach ($configs as $c) {
                    $item = explode(':', $c);
                    $config_arr[$item[0]] = $item[1];
                }
            }
            $config_str = json_encode($config_arr);
            $reval .= <<<EOT
<script>
    var_config={$config_str};
</script>
EOT;
        }
        $reval .= htmlspecialchars_decode($row['reval']);
        $reval = str_replace("id='SOHUCS'", "id='SOHUCS' sid='{$refObj->ArcID}'", $reval);
        if ($type == 'code2') {
            $reval = preg_replace("#window.SCS_NO_IFRAME[ ]?=[ ]?true;#i", "", $reval);
        }
        $reval = str_replace("<script>", "</div><script>", $reval);
    } elseif ($type == 'count') {
        if (!$GLOBALS['changyan_count_js']) {
            $reval .= "<script type=\"text/javascript\" src=\"http://assets.changyan.sohu.com/upload/plugins/plugins.count.js\"></script>";
        }
        $reval .= "<a href=\"#SOHUCS\" id=\"changyan_count_unit\"></a>";
        $GLOBALS['changyan_count_js'] = TRUE;
    }
    return $reval;
}
开发者ID:stonelf,项目名称:mcgmh,代码行数:59,代码来源:changyan.lib.php

示例2: DelCache

            $add_caicai_sub = $cfg_digg_update * $cfg_caicai_sub;
            $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET scores = scores + {$add_caicai_sub},goodpost=goodpost+{$cfg_digg_update} WHERE id='{$id}'");
            DelCache($prefix, $key);
        }
    } else {
        if ($action == 'bad') {
            $row['badpost'] = $row['badpost'] + 1;
            $row['scores'] = $row['scores'] - $cfg_caicai_sub;
            if ($row['badpost'] % $cfg_digg_update == 0) {
                $add_caicai_sub = $cfg_digg_update * $cfg_caicai_sub;
                $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET scores = scores - {$add_caicai_sub},badpost=badpost+{$cfg_digg_update} WHERE id='{$id}'");
                DelCache($prefix, $key);
            }
        }
    }
    SetCache($prefix, $key, $row, 0);
}
$digg = '';
if (!is_array($row)) {
    exit;
}
if ($row['goodpost'] + $row['badpost'] == 0) {
    $row['goodper'] = $row['badper'] = 0;
} else {
    $row['goodper'] = number_format($row['goodpost'] / ($row['goodpost'] + $row['badpost']), 3) * 100;
    $row['badper'] = 100 - $row['goodper'];
}
if (empty($formurl)) {
    $formurl = '';
}
if ($formurl == 'caicai') {
开发者ID:bthtml,项目名称:web-hwxf,代码行数:31,代码来源:digg_ajax.php

示例3: GetMemberName

 function GetMemberName($mid = 0)
 {
     global $dsql;
     $rs = GetCache('memberlogin', $mid);
     if (empty($rs)) {
         $rs = $dsql->GetOne("SELECT * FROM `#@__member` WHERE mid='{$mid}' ");
         SetCache('memberlogin', $mid, $rs, 1800);
     }
     return $rs['uname'];
 }
开发者ID:cwcw,项目名称:cms,代码行数:10,代码来源:config.php

示例4: SetCache

<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I am a way to test that cahce functions are working
I'll store and return a user provided variable
***********************************************/
// I'll use HASH as the variable to log by IP address;
if ($ERROR == 100) {
    if ($CONFIG['CacheType'] == "") {
        $ERROR = "The cache is not configured on this server";
    }
}
if ($ERROR == 100) {
    if (strlen($PARAMS["Hash"]) == 0) {
        $ERROR = "You need to provide a Hash";
    } else {
        $CacheKey = $IP . "_CacheTest";
        SetCache($CacheKey, $PARAMS["Hash"]);
        $result = GetCache($CacheKey);
        $OUTPUT['CacheKey'] = $CacheKey;
        $OUTPUT['CachedResult'] = $result;
    }
}
开发者ID:simonfoxe,项目名称:PHP-DAVE-API,代码行数:27,代码来源:CacheTest.php

示例5: __construct

 function __construct($kptime = -1, $cache = FALSE)
 {
     global $dsql;
     if ($kptime == -1) {
         $this->M_KeepTime = 3600 * 24 * 7;
     } else {
         $this->M_KeepTime = $kptime;
     }
     $formcache = FALSE;
     $this->M_ID = $this->GetNum(GetCookie("DedeUserID"));
     $this->M_LoginTime = GetCookie("DedeLoginTime");
     $this->fields = array();
     $this->isAdmin = FALSE;
     if (empty($this->M_ID)) {
         $this->ResetUser();
     } else {
         $this->M_ID = intval($this->M_ID);
         if ($cache) {
             $this->fields = GetCache($this->memberCache, $this->M_ID);
             if (empty($this->fields)) {
                 $this->fields = $dsql->GetOne("Select * From `#@__member` where mid='{$this->M_ID}' ");
             } else {
                 $formcache = TRUE;
             }
         } else {
             $this->fields = $dsql->GetOne("Select * From `#@__member` where mid='{$this->M_ID}' ");
         }
         if (is_array($this->fields)) {
             #api{{
             if (defined('UC_API') && @(include_once DEDEROOT . '/uc_client/client.php')) {
                 if ($data = uc_get_user($this->fields['userid'])) {
                     if (uc_check_avatar($data[0]) && !strstr($this->fields['face'], UC_API)) {
                         $this->fields['face'] = UC_API . '/avatar.php?uid=' . $data[0] . '&size=middle';
                         $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET `face`='" . $this->fields['face'] . "' WHERE `mid`='{$this->M_ID}'");
                     }
                 }
             }
             #/aip}}
             //间隔一小时更新一次用户登录时间
             if (time() - $this->M_LoginTime > 3600) {
                 $dsql->ExecuteNoneQuery("update `#@__member` set logintime='" . time() . "',loginip='" . GetIP() . "' where mid='" . $this->fields['mid'] . "';");
                 PutCookie("DedeLoginTime", time(), $this->M_KeepTime);
             }
             $this->M_LoginID = $this->fields['userid'];
             $this->M_MbType = $this->fields['mtype'];
             $this->M_Money = $this->fields['money'];
             $this->M_UserName = FormatUsername($this->fields['uname']);
             $this->M_Scores = $this->fields['scores'];
             $this->M_Face = $this->fields['face'];
             $this->M_Rank = $this->fields['rank'];
             $this->M_Spacesta = $this->fields['spacesta'];
             $sql = "Select titles From #@__scores where integral<={$this->fields['scores']} order by integral desc";
             $scrow = $dsql->GetOne($sql);
             $this->fields['honor'] = $scrow['titles'];
             $this->M_Honor = $this->fields['honor'];
             if ($this->fields['matt'] == 10) {
                 $this->isAdmin = TRUE;
             }
             $this->M_UpTime = $this->fields['uptime'];
             $this->M_ExpTime = $this->fields['exptime'];
             $this->M_JoinTime = MyDate('Y-m-d', $this->fields['jointime']);
             if ($this->M_Rank > 10 && $this->M_UpTime > 0) {
                 $this->M_HasDay = $this->Judgemember();
             }
             if (!$formcache) {
                 SetCache($this->memberCache, $this->M_ID, $this->fields, 1800);
             }
         } else {
             $this->ResetUser();
         }
     }
 }
开发者ID:hensonvip,项目名称:ymroad,代码行数:72,代码来源:memberlogin.class.php

示例6: ufdbgclient

function ufdbgclient($full, $pipes = null)
{
    //http://192.168.1.245/Inotify.php?_=1355916677559 192.168.1.158/- - GET myip=192.168.1.238 myport=3128
    $fullORG = $full;
    $KEY = md5($full);
    $full = trim($full);
    //if(IsInCache($KEY)){return $GLOBALS["CACHE"][$KEY]["URI"];}
    if ($GLOBALS["DEBUG"]) {
        WriteToSyslog("ufdbgclient:: PIPE(): Write \"{$fullORG}\"");
    }
    fwrite($pipes[0], $fullORG);
    $output = array();
    $get = fgets($pipes[1], 1024);
    if ($GLOBALS["DEBUG"]) {
        WriteToSyslog("ufdbgclient:: PIPE(): receive \"{$get}");
    }
    return $get;
    $cmd = "echo \"{$full}\"|{$GLOBALS["UFDBGCLIENT"]} 2>&1";
    if ($GLOBALS["DEBUG"]) {
        WriteToSyslog("ufdbgclient::`{$cmd}`");
    }
    exec($cmd, $results);
    if ($GLOBALS["DEBUG"]) {
        WriteToSyslog("ufdbgclient:: {$results[0]}");
    }
    SetCache($KEY, $results[0]);
    return $results[0];
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:28,代码来源:exec.pdns.pipe.php

示例7: time

        }
        print "ERR\n";
        continue;
    }
    $t = time();
    if ($GLOBALS["DEBUG_LEVEL"] > 0) {
        $GLOBALS["HELPER"]->WLOG("GetScore of {$szFilename}");
    }
    $iScore = intval($filter->GetScore($szFilename));
    @unlink($szFilename);
    $t2 = time();
    $seconds = $t2 - $t;
    if ($GLOBALS["DEBUG_LEVEL"] > 0) {
        $GLOBALS["HELPER"]->WLOG(basename($szUrl) . ": {$iScore}% in ({$seconds}s)");
    }
    SetCache($szUrl, $iScore);
    if ($iScore >= $iPicScanVal) {
        $array["POURC"] = $iScore;
        $tfile = "/var/log/squid/nudity/" . md5(serialize($array));
        if (!is_file($tfile)) {
            @file_put_contents($tfile, serialize($array));
        }
        if ($GLOBALS["DEBUG_LEVEL"] > 1) {
            $GLOBALS["HELPER"]->WLOG("BLOCK->" . $szMac . " " . $szUrl . " score:" . $iScore . " " . $iPicScanVal . " " . $iRes);
        }
        print "OK\n";
        continue;
    }
    print "ERR\n";
}
SaveCache();
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:picporn.php

示例8: ufdbgclient

function ufdbgclient($full, $handleUfdbGuard, $pipes = null)
{
    $KEY = md5($full);
    $SourceFull = UserDBTranslate($full);
    $full = trim($full);
    if (IsInCache($KEY)) {
        return $GLOBALS["CACHE"][$KEY]["URI"];
    }
    if ($handleUfdbGuard) {
        if ($GLOBALS["DEBUG"]) {
            WLOG("ufdbgclient:: PIPE(): Write \"{$SourceFull}\"");
        }
        fwrite($pipes[0], $SourceFull);
        $output = array();
        $get = fgets($pipes[1], 1024);
        if ($GLOBALS["DEBUG"]) {
            WLOG("ufdbgclient:: PIPE(): receive \"{$get}");
        }
        if (strlen($get) > 0) {
            SetCache($KEY, $get);
            return $get;
        }
    }
    $cmd = "echo \"{$full}\"|{$GLOBALS["UFDBGCLIENT"]} 2>&1";
    if ($GLOBALS["DEBUG"]) {
        WLOG("ufdbgclient::`{$cmd}`");
    }
    exec($cmd, $results);
    if ($GLOBALS["DEBUG"]) {
        WLOG("ufdbgclient:: {$results[0]}");
    }
    SetCache($KEY, $results[0]);
    return $results[0];
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:34,代码来源:streamcache.php

示例9: lib_flink

function lib_flink(&$ctag, &$refObj)
{
    global $dsql, $cfg_soft_lang;
    $attlist = "type|textall,row|24,titlelen|24,linktype|1,typeid|0";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $totalrow = $row;
    $revalue = '';
    if (isset($GLOBALS['envs']['flinkid'])) {
        $typeid = $GLOBALS['envs']['flinkid'];
    }
    $wsql = " where ischeck >= '{$linktype}' ";
    if ($typeid == 0) {
        $wsql .= '';
    } else {
        if ($typeid == 999) {
            $prefix = 'flink';
            $key = '999';
            $row = GetCache($prefix, $key);
            if (!is_array($row)) {
                require DEDEDATA . '/admin/config_update.php';
                if (!class_exists('DedeHttpDown', false)) {
                    require_once DEDEINC . '/dedehttpdown.class.php';
                }
                $del = new DedeHttpDown();
                $del->OpenUrl($linkHost);
                $linkUrl = $del->GetHtml() . "flink.php?lang={$cfg_soft_lang}&site={$_SERVER['SERVER_NAME']}";
                $del->OpenUrl($linkUrl);
                $linkInfo = $del->GetHtml();
                if (!empty($linkInfo)) {
                    $dedelink = explode("\t", $linkInfo);
                    for ($i = 0; $i < count($dedelink); $i++) {
                        if ($i % 5 == 0 && $i != count($dedelink)) {
                            $revalue .= "<li><a href='http://" . @$dedelink[$i + 1] . "' target='_blank' title='" . @$dedelink[$i + 4] . "'>" . @$dedelink[$i] . "</a></li>";
                        }
                    }
                } else {
                    $revalue = <<<EOT
<li><a href='http://ad.dedecms.com' target='_blank' title='DedeCMS广告'>DedeCMS广告</a></li><li><a href='http://service.dedecms.com' target='_blank' title='织梦客户服务中心'>
织梦客户服务中心</a></li><li><a href='http://ask.dedecms.com' target='_blank' title='织梦问答'>
织梦问答</a></li><li><a href='http://tools.dedecms.com' target='_blank' title='站长工具'>
站长工具</a></li><li><a href='http://site.desdev.cn' target='_blank' title='DedeCMS建站中心'>
DedeCMS建站中心</a></li><li><a href='http://help.dedecms.com' target='_blank' title='织梦CMS帮助中心'>
织梦CMS帮助中心</a></li><li><a href='http://' target='_blank' title=''>
</a></li>
EOT;
                }
                $row['reval'] = $revalue;
                SetCache($prefix, $key, $row, 60 * 60 * 1);
            }
            return $row['reval'];
        } else {
            $wsql .= "And typeid = '{$typeid}'";
        }
    }
    if ($type == 'image') {
        $wsql .= " And logo<>'' ";
    } else {
        if ($type == 'text') {
            $wsql .= " And logo='' ";
        }
    }
    $equery = "SELECT * FROM #@__flink {$wsql} order by sortrank asc limit 0,{$totalrow}";
    if (trim($ctag->GetInnerText()) == '') {
        $innertext = "<li>[field:link /]</li>";
    } else {
        $innertext = $ctag->GetInnerText();
    }
    $dsql->SetQuery($equery);
    $dsql->Execute();
    while ($dbrow = $dsql->GetObject()) {
        if ($type == 'text' || $type == 'textall') {
            $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
        } else {
            if ($type == 'image') {
                $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='248' height='180' border='0'></a> ";
            } else {
                if ($dbrow->logo == '') {
                    $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
                } else {
                    $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='248' height='180' border='0'></a> ";
                }
            }
        }
        $rbtext = preg_replace("/\\[field:url([\\/\\s]{0,})\\]/isU", $row['url'], $innertext);
        $rbtext = preg_replace("/\\[field:webname([\\/\\s]{0,})\\]/isU", $row['webname'], $rbtext);
        $rbtext = preg_replace("/\\[field:logo([\\/\\s]{0,})\\]/isU", $row['logo'], $rbtext);
        $rbtext = preg_replace("/\\[field:link([\\/\\s]{0,})\\]/isU", $link, $rbtext);
        $revalue .= $rbtext;
    }
    return $revalue;
}
开发者ID:healen,项目名称:dsCMS,代码行数:92,代码来源:flink.lib.php

示例10: in

        $tinyQuerys[] = " mid='{$mid}' ";
    }
    if (!empty($cid)) {
        $tinyQuerys[] = " typeid in(" . GetSonIds($cid) . ") ";
    }
    if (count($tinyQuerys) > 0) {
        $tinyQuery = "WHERE " . join(' AND ', $tinyQuerys);
    }
    $tinyQuery = "WHERE mid={$adminid}";
    // 缓存处理
    $sql = "SELECT COUNT(*) AS dd FROM `#@__archives` {$tinyQuery} ";
    $cachekey = md5($sql);
    $arr = GetCache('listcache', $cachekey);
    if (empty($arr)) {
        $arr = $dsql->GetOne($sql);
        SetCache('listcache', $cachekey, $arr);
    }
    $totalresult = $arr['dd'];
}
if ($cid == 0) {
    if ($channelid == 0) {
        $positionname = '所有栏目&gt;';
    } else {
        $row = $tl->dsql->GetOne("SELECT id,typename,maintable FROM `#@__channeltype` WHERE id='{$channelid}'");
        $positionname = $row['typename'] . " &gt; ";
        $maintable = $row['maintable'];
        $channelid = $row['id'];
    }
} else {
    $positionname = str_replace($cfg_list_symbol, " &gt; ", $tl->GetPositionName()) . " &gt; ";
}
开发者ID:puppylsy,项目名称:cms,代码行数:31,代码来源:content_list3.php


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