Commit: 4de9826286ae8378c26f788fec1f646702295f7a Author: Hannes Magnusson <[email protected]> Sun, 29 Dec 2013 20:34:05 -0800 Parents: c4520deb9164dc71e016766c5a0931696c8cd824 Branches: master
Link: http://git.php.net/?p=web/people.git;a=commitdiff;h=4de9826286ae8378c26f788fec1f646702295f7a Log: Remove apc as dependency and enable karma listing again Changed paths: M include/karma.php M user.php Diff: diff --git a/include/karma.php b/include/karma.php index bc39bc7..ac28b46 100644 --- a/include/karma.php +++ b/include/karma.php @@ -1,40 +1,36 @@ <?php +define("KARMA_FILE", sys_get_temp_dir() . "/karma.txt"); function findKarma($username) { refreshStaleKarma(); - $karma = apc_fetch("karma_".$username); + $karma = json_decode(file_get_contents(KARMA_FILE), true); if ($karma === FALSE) { return false; } - $karma = array( - "avail" => explode(PATH_SEPARATOR, $karma["avail"]), - "unavail" => explode(PATH_SEPARATOR, $karma["unavail"]), + $mykarma = $karma[$username]; + $retval = array( + "avail" => explode(PATH_SEPARATOR, $mykarma["avail"]), + "unavail" => explode(PATH_SEPARATOR, $mykarma["unavail"]), ); - return $karma; + return $retval; } function refreshStaleKarma() { - $karma_updated = (int) apc_fetch("global_avail_update"); + $karma_updated = filemtime(KARMA_FILE); $timezone = timezone_open("UTC"); $is_expired = (date_create("@$karma_updated", $timezone) < date_create("1 day ago", $timezone)); if ($is_expired) { $karma = fetchKarma(); - if ($karma) { - apc_store("global_avail_update", $_SERVER["REQUEST_TIME"]); - foreach ($karma as $user => $avails) { - apc_store("karma_".$user, $avails); - } - } + file_put_contents(KARMA_FILE, json_encode($karma)); } } function fetchKarma() { -# $ctx = stream_context_create(array("http" => array("ignore_errors" => true))); -# $retval = @file_get_contents("https://svn.php.net/repository/SVNROOT/global_avail", false, $ctx); - $retval = @file_get_contents("/home/svn/SVNROOT/global_avail"); + $ctx = stream_context_create(array("http" => array("ignore_errors" => true))); + $retval = @file_get_contents("https://svn.php.net/repository/SVNROOT/global_avail", false, $ctx); if (!$retval) { if (isset($http_response_header) && $http_response_header) { list($protocol, $errcode, $errmsg) = explode(" ", $http_response_header[0], 3); diff --git a/user.php b/user.php index 7e10c2d..acd48b1 100644 --- a/user.php +++ b/user.php @@ -11,8 +11,7 @@ site_header("Developers Profile Pages; $USERNAME"); $NFO = findPHPUser($USERNAME); $PEAR = findPEARUser($USERNAME); $GITHUB = findGitHubUser($NFO["name"]); -/* This stuff uses apc.. which is no longer available */ -$KARMA = array();//findKarma($USERNAME); +$KARMA = findKarma($USERNAME); $PROFILE = findPHPUserProfile($USERNAME); $email = $NFO["enable"] ? $NFO["username"].'@php.net' : ""; $location = isset($PEAR["long"], $PEAR["lat"]) ? $PEAR["lat"] . ", " . $PEAR["long"] : null; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
