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


PHP redisLink函数代码示例

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


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

示例1: adminProUsers

function adminProUsers()
{
    $r = redisLink();
    $prousers = $r->smembers("global:prousers");
    echo "<table>";
    foreach ($prousers as $uid) {
        uid2html($r, $uid);
    }
    echo "</table>";
}
开发者ID:shaugier,项目名称:lloogg,代码行数:10,代码来源:adm.php

示例2: logTodayTrend

function logTodayTrend()
{
    $uid = reqUserId();
    $r = redisLink();
    $t = time() - time() % (3600 * 24);
    $pageviews = $visitors = 0;
    $n = $r->get("day:pv:{$uid}:{$t}");
    if ($n) {
        $pageviews = $n;
    }
    $n = $r->get("day:uv:{$uid}:{$t}");
    if ($n) {
        $visitors = $n;
    }
    return array("pageviews" => $pageviews, "visitors" => $visitors);
}
开发者ID:shaugier,项目名称:lloogg,代码行数:16,代码来源:trends.php

示例3: reqUserId

function reqUserId()
{
    global $_COOKIE;
    $r = redisLink();
    if (!isset($_COOKIE['requser'])) {
        return userId();
    }
    $username = $_COOKIE['requser'];
    if (($id = getIdFromUsername($username)) == -1) {
        return userId();
    }
    if ($r->sismember("uid:{$id}:allowing", userId())) {
        return $id;
    } else {
        return userId();
    }
}
开发者ID:shaugier,项目名称:lloogg,代码行数:17,代码来源:pro.php

示例4: g

<?php

require "lib.php";
$username = g('usernameReg');
$password = g("passReg");
$email = g("email");
if (g("passReg", "") != g("repassReg", "")) {
    panic("Some var is emtpy or pass != repass after javascript test");
}
if (strlen($password) < 5) {
    panic("Pass is shorter than 5 chars after javascript test");
}
$r = redisLink();
if ($r->get("username:{$username}:id")) {
    panic("Username already in use");
}
# Everything is ok, Register the user!
$userid = $r->incr("global:nextUserId");
$r->set("username:{$username}:id", $userid);
$r->set("uid:{$userid}:username", $username);
$r->set("uid:{$userid}:hashpass", bcrypt_hash($password));
$r->set("uid:{$userid}:email", $email);
$r->set("uid:{$userid}:regtime", time());
$r->set("uid:{$userid}:excludemyvisits", '0');
$authsecret = getrand();
$r->set("uid:{$userid}:auth", $authsecret);
$r->set("auth:{$authsecret}", $userid);
# Manage a Set with all the users, may be userful in the future
$r->sadd("global:users", $userid);
# User registered! Login this guy
$now = time() + 3600 * 24 * 365;
开发者ID:shaugier,项目名称:lloogg,代码行数:31,代码来源:register.php

示例5: getAllUsers

function getAllUsers()
{
    $r = redisLink();
    $allusers = $r->sort("global:users", array('GET' => 'uid:*:username'));
    return $allusers;
}
开发者ID:raphaelcm,项目名称:Retwis-w-Predis,代码行数:6,代码来源:retwis.php

示例6: recv

function recv()
{
    global $_SERVER;
    $ip = $_SERVER['REMOTE_ADDR'];
    # get data
    $type = g('type', 'pageview');
    $uid = readSecureId(g('u', ''), "userid");
    if ($uid == -1) {
        return;
    }
    $location = trim(g('l', ''));
    if (strlen($location) == 0) {
        return;
    }
    $referer = trim(g('r', ''));
    $width = gi('w', 0);
    $height = gi('h', 0);
    $historylen = gi('hl', 0);
    $agent = g('a', '');
    $cookies = strtolower(trim(g('c', 'na')));
    if ($cookies != 'na' && $cookies != 'y' && $cookies != 'n') {
        $cookies = 'na';
    }
    # split domain info
    $url = parseurl($location);
    if ($url === false) {
        return;
    }
    $time = time();
    $ispro = isPro($uid);
    $eventid = LOG_EVENT_PAGEVIEW;
    if ($type == 'adclick') {
        $eventid = LOG_EVENT_ADCLICK;
    }
    if (!$ispro && $eventid != LOG_EVENT_PAGEVIEW) {
        return;
    }
    # Log the visit. We assign a new event ID to every logged event.
    # Note that PHP running on 32 bit systems will overflow the ID soon
    # or later.
    $r = redisLink();
    $logid = $r->incr("global:nextLogId");
    $aux = array("time" => $time, "user_id" => $uid, "event_id" => $eventid, "location" => $location, "proto" => $url['proto'], "domain" => $url['domain'], "path" => $url['path'], "query" => $url['query'], "ref" => $referer, "swidth" => $width, "sheight" => $height, "cookies" => $cookies, "ip" => $ip, "agent" => $agent, "historylen" => $historylen, "id" => $logid);
    # Insert new
    $r->push("last:{$uid}", serialize($aux), false);
    # History length is different for PRO / non PRO user.
    $r->ltrim("last:{$uid}", 0, $ispro ? 1000 : 50);
    if ($eventid != LOG_EVENT_PAGEVIEW) {
        return;
    }
    # Update stats
    $nv = gi('nv', 0);
    $rv = gi('rv', 0);
    $t = time();
    $t = $t - $t % (3600 * 24);
    # Update unique visits
    if ($nv) {
        $r->incr("day:uv:{$uid}:{$t}");
        if ($rv) {
            $r->incr("day:rv:{$uid}:{$t}");
        }
    }
    $r->incr("day:pv:{$uid}:{$t}");
}
开发者ID:shaugier,项目名称:lloogg,代码行数:64,代码来源:recv.php

示例7: showLastUsers

function showLastUsers() {
    $r = redisLink();
    $users = $r->sort("global:users","GET uid:*:username DESC LIMIT 0 10");
    echo("<div>");
    foreach($users as $u) {
        echo("<a class=\"username\" href=\"profile.php?u=".urlencode($u)."\">".utf8entities($u)."</a> ");
    }
    echo("</div><br>");
}
开发者ID:hritupon,项目名称:IMOP_WEB,代码行数:9,代码来源:retwis.php

示例8: showLastUsers

function showLastUsers() {
    $r = redisLink();
    $users = $r->zrevrange("users_by_time",0,9);
    echo("<div>");
    foreach($users as $u) {
        echo("<a class=\"username\" href=\"profile.php?u=".urlencode($u)."\">".utf8entities($u)."</a> ");
    }
    echo("</div><br>");
}
开发者ID:AlphaStaxLLC,项目名称:app-service-web-php-retwis,代码行数:9,代码来源:retwis.php

示例9: getIdFromUsername

function getIdFromUsername($username)
{
    $username = str_replace(" ", "_", $username);
    $r = redisLink();
    $id = $r->get("username:{$username}:id");
    if (!$id) {
        return -1;
    } else {
        return $id;
    }
}
开发者ID:shaugier,项目名称:lloogg,代码行数:11,代码来源:user.php

示例10: removetrafficRule

 function removetrafficRule($hkey)
 {
     $r = redisLink();
     $result = $r->HDEL('setting:traffic_custom_rules', $hkey);
     return $result;
 }
开发者ID:hellocc2,项目名称:crmht,代码行数:6,代码来源:Analyzer.php

示例11: getArticleTitle

 public static function getArticleTitle($aid)
 {
     return redisLink()->get("aid:{$aid}:ArticleTitle");
 }
开发者ID:soychicka,项目名称:tg,代码行数:4,代码来源:model_user_article.php

示例12: poll

function poll()
{
    $numres = 1;
    $r = redisLink();
    $uid = reqUserId();
    $minid = gi("minid", 0);
    $proto = gi("proto", 1);
    $loadhistory = 0;
    if ($minid == 0) {
        # First client request. Just return the latest entry
        $latest = unserialize($r->lindex("last:{$uid}", 0));
        $minid = $latest['id'];
    } else {
        if ($minid < 0) {
            # minid < 0 means: load history, with abs(minid) elements
            $numres = abs($minid);
            if ($numres > 1000) {
                $numres = 1000;
            }
            $loadhistory = 1;
        }
    }
    $rows = $r->lrange("last:{$uid}", 0, $numres - 1);
    # Handle free accounts timeouts.
    # NOTE: this is actually disabled, left here for historical reasons
    # and because the javascript still handles it.
    $ispro = isPro($uid);
    if (0 && !$ispro) {
        $startpoll = $r->get("startpoll:{$uid}");
        if (!$startpoll) {
            $r->set("startpoll:{$uid}", time());
        } else {
            $delta = time() - $r->get("startpoll:{$uid}");
            if ($delta > FREE_MAXTIME + FREE_WAIT) {
                $r->delete("startpoll:{$uid}");
            } else {
                if ($delta > FREE_MAXTIME) {
                    echo "TRYLATER:" . floor(1 + (FREE_MAXTIME + FREE_WAIT - $delta) / 60);
                    exit;
                }
            }
        }
    }
    # Empty list?
    if (count($rows) == 0) {
        echo "NODATA";
        exit;
    }
    # Check if even the most recent element (the first one)
    # is still too old. If so, no new data to return.
    $latest = unserialize($rows[0]);
    if ($latest['id'] < $minid) {
        echo "NODATA";
        exit;
    }
    # Try to get all the data required. Up to 50 elements for request
    while (!$loadhistory) {
        $oldest = unserialize($rows[count($rows) - 1]);
        if ($oldest['id'] > $minid && $numres < 50) {
            # We need more data
            $numres = ($numres + 1) * 2;
            if ($numres > 50) {
                $numres = 50;
            }
            $rows = $r->lrange("last:{$uid}", 0, $numres - 1);
        } else {
            break;
        }
    }
    # Ok now reverse the array to sort ascending and return data to ajax.
    $rows = array_reverse($rows);
    $gi = geoip_open("geoipdata/GeoIP.dat", GEOIP_STANDARD);
    foreach ($rows as $srow) {
        $row = unserialize($srow);
        if ($row['id'] < $minid) {
            continue;
        }
        $keys = array("time", "location", "domain", "ref", "swidth", "sheight", "cookies", "ip", "agent", "historylen");
        $aux = array();
        foreach ($keys as $k) {
            $aux[$k] = $row[$k];
        }
        $aux['country'] = geoip_country_name_by_addr($gi, $aux['ip']);
        $aux['type'] = 'pageview';
        # At some point LLOOGG supported the ability to display user clicks
        # adsense ADs. Now the javascript we inject no longer support this
        # but the support inside LLOOGG itself remains.
        if ($row['event_id'] == LOG_EVENT_ADCLICK) {
            $aux['type'] = 'adclick';
        }
        $t[] = $aux;
        if ($row['id'] > $maxid) {
            $maxid = $row['id'];
        }
    }
    geoip_close($gi);
    $t[] = $maxid + 1;
    if ($proto >= 2) {
        $t[] = logTodayVisitors();
        $t[] = logTodayPageviews();
//.........这里部分代码省略.........
开发者ID:shaugier,项目名称:lloogg,代码行数:101,代码来源:poll.php


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