Merge pull request #1010 from Alkarex/cleanLogs

Clean logs
pull/1026/head
Marien Fressinaud 9 years ago
commit b8b0ba6f24
  1. 4
      app/Controllers/feedController.php
  2. 5
      app/Models/LogDAO.php
  3. 38
      p/api/greader.php

@ -307,9 +307,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$pubSubHubbubEnabled = $pubsubhubbubEnabledGeneral && $feed->pubSubHubbubEnabled(); $pubSubHubbubEnabled = $pubsubhubbubEnabledGeneral && $feed->pubSubHubbubEnabled();
if ((!$simplePiePush) && (!$id) && $pubSubHubbubEnabled && ($feed->lastUpdate() > $pshbMinAge)) { if ((!$simplePiePush) && (!$id) && $pubSubHubbubEnabled && ($feed->lastUpdate() > $pshbMinAge)) {
$text = 'Skip pull of feed using PubSubHubbub: ' . $url; //$text = 'Skip pull of feed using PubSubHubbub: ' . $url;
//Minz_Log::debug($text); //Minz_Log::debug($text);
file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND); //file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND);
continue; //When PubSubHubbub is used, do not pull refresh so often continue; //When PubSubHubbub is used, do not pull refresh so often
} }

@ -21,5 +21,10 @@ class FreshRSS_LogDAO {
public static function truncate() { public static function truncate() {
file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), ''); file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), '');
if (FreshRSS_Auth::hasAccess('admin')) {
file_put_contents(join_path(DATA_PATH, 'users', '_', 'log.txt'), '');
file_put_contents(join_path(DATA_PATH, 'users', '_', 'log_api.txt'), '');
file_put_contents(join_path(DATA_PATH, 'users', '_', 'log_pshb.txt'), '');
}
} }
} }

@ -77,7 +77,7 @@ class MyPDO extends Minz_ModelPdo {
} }
function logMe($text) { function logMe($text) {
file_put_contents(join_path(USERS_PATH, '_', 'log_api.txt'), $text, FILE_APPEND); file_put_contents(join_path(USERS_PATH, '_', 'log_api.txt'), date('c') . "\t" . $text . "\n", FILE_APPEND);
} }
function debugInfo() { function debugInfo() {
@ -96,7 +96,7 @@ function debugInfo() {
} }
function badRequest() { function badRequest() {
logMe("badRequest()\n"); logMe("badRequest()");
logMe(debugInfo()); logMe(debugInfo());
header('HTTP/1.1 400 Bad Request'); header('HTTP/1.1 400 Bad Request');
header('Content-Type: text/plain; charset=UTF-8'); header('Content-Type: text/plain; charset=UTF-8');
@ -104,7 +104,7 @@ function badRequest() {
} }
function unauthorized() { function unauthorized() {
logMe("unauthorized()\n"); logMe("unauthorized()");
logMe(debugInfo()); logMe(debugInfo());
header('HTTP/1.1 401 Unauthorized'); header('HTTP/1.1 401 Unauthorized');
header('Content-Type: text/plain; charset=UTF-8'); header('Content-Type: text/plain; charset=UTF-8');
@ -113,7 +113,7 @@ function unauthorized() {
} }
function notImplemented() { function notImplemented() {
logMe("notImplemented()\n"); logMe("notImplemented()");
logMe(debugInfo()); logMe(debugInfo());
header('HTTP/1.1 501 Not Implemented'); header('HTTP/1.1 501 Not Implemented');
header('Content-Type: text/plain; charset=UTF-8'); header('Content-Type: text/plain; charset=UTF-8');
@ -121,14 +121,14 @@ function notImplemented() {
} }
function serviceUnavailable() { function serviceUnavailable() {
logMe("serviceUnavailable()\n"); logMe("serviceUnavailable()");
header('HTTP/1.1 503 Service Unavailable'); header('HTTP/1.1 503 Service Unavailable');
header('Content-Type: text/plain; charset=UTF-8'); header('Content-Type: text/plain; charset=UTF-8');
die('Service Unavailable!'); die('Service Unavailable!');
} }
function checkCompatibility() { function checkCompatibility() {
logMe("checkCompatibility()\n"); logMe("checkCompatibility()");
header('Content-Type: text/plain; charset=UTF-8'); header('Content-Type: text/plain; charset=UTF-8');
if (PHP_INT_SIZE < 8 && !function_exists('gmp_init')) { if (PHP_INT_SIZE < 8 && !function_exists('gmp_init')) {
die('FAIL 64-bit or GMP extension!'); die('FAIL 64-bit or GMP extension!');
@ -159,7 +159,7 @@ function authorizationToUser() {
if ($headerAuthX[1] === sha1($system_conf->salt . $user . $conf->apiPasswordHash)) { if ($headerAuthX[1] === sha1($system_conf->salt . $user . $conf->apiPasswordHash)) {
return $user; return $user;
} else { } else {
logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1] . "\n"); logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]);
Minz_Log::warning('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]); Minz_Log::warning('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]);
unauthorized(); unauthorized();
} }
@ -172,7 +172,7 @@ function authorizationToUser() {
} }
function clientLogin($email, $pass) { //http://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.html function clientLogin($email, $pass) { //http://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.html
logMe('clientLogin(' . $email . ")\n"); //logMe('clientLogin(' . $email . ")");
if (ctype_alnum($email)) { if (ctype_alnum($email)) {
if (!function_exists('password_verify')) { if (!function_exists('password_verify')) {
include_once(LIB_PATH . '/password_compat.php'); include_once(LIB_PATH . '/password_compat.php');
@ -205,7 +205,7 @@ function token($conf) {
//http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/ //http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/
//https://github.com/ericmann/gReader-Library/blob/master/greader.class.php //https://github.com/ericmann/gReader-Library/blob/master/greader.class.php
$user = Minz_Session::param('currentUser', '_'); $user = Minz_Session::param('currentUser', '_');
logMe('token('. $user . ")\n"); //TODO: Implement real token that expires //logMe('token('. $user . ")"); //TODO: Implement real token that expires
$system_conf = Minz_Configuration::get('system'); $system_conf = Minz_Configuration::get('system');
$token = str_pad(sha1($system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z'); //Must have 57 characters $token = str_pad(sha1($system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z'); //Must have 57 characters
echo $token, "\n"; echo $token, "\n";
@ -215,7 +215,7 @@ function token($conf) {
function checkToken($conf, $token) { function checkToken($conf, $token) {
//http://code.google.com/p/google-reader-api/wiki/ActionToken //http://code.google.com/p/google-reader-api/wiki/ActionToken
$user = Minz_Session::param('currentUser', '_'); $user = Minz_Session::param('currentUser', '_');
logMe('checkToken(' . $token . ")\n"); //logMe('checkToken(' . $token . ")");
$system_conf = Minz_Configuration::get('system'); $system_conf = Minz_Configuration::get('system');
if ($token === str_pad(sha1($system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z')) { if ($token === str_pad(sha1($system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z')) {
return true; return true;
@ -224,7 +224,7 @@ function checkToken($conf, $token) {
} }
function tagList() { function tagList() {
logMe("tagList()\n"); //logMe("tagList()");
header('Content-Type: application/json; charset=UTF-8'); header('Content-Type: application/json; charset=UTF-8');
$pdo = new MyPDO(); $pdo = new MyPDO();
@ -249,7 +249,7 @@ function tagList() {
} }
function subscriptionList() { function subscriptionList() {
logMe("subscriptionList()\n"); //logMe("subscriptionList()");
header('Content-Type: application/json; charset=UTF-8'); header('Content-Type: application/json; charset=UTF-8');
$pdo = new MyPDO(); $pdo = new MyPDO();
@ -283,7 +283,7 @@ function subscriptionList() {
} }
function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#unread-count function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#unread-count
logMe("unreadCount()\n"); //logMe("unreadCount()");
header('Content-Type: application/json; charset=UTF-8'); header('Content-Type: application/json; charset=UTF-8');
$totalUnreads = 0; $totalUnreads = 0;
@ -330,7 +330,7 @@ function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-googl
function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation) { function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation) {
//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI //http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
logMe("streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation)\n"); //logMe("streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation)");
header('Content-Type: application/json; charset=UTF-8'); header('Content-Type: application/json; charset=UTF-8');
$feedDAO = FreshRSS_Factory::createFeedDao(); $feedDAO = FreshRSS_Factory::createFeedDao();
@ -436,7 +436,7 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
//http://code.google.com/p/google-reader-api/wiki/ApiStreamItemsIds //http://code.google.com/p/google-reader-api/wiki/ApiStreamItemsIds
//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI //http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
logMe("streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)\n"); //logMe("streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)");
$type = 'A'; $type = 'A';
$id = ''; $id = '';
@ -484,7 +484,7 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
} }
function editTag($e_ids, $a, $r) { function editTag($e_ids, $a, $r) {
logMe("editTag()\n"); //logMe("editTag()");
foreach ($e_ids as $i => $e_id) { foreach ($e_ids as $i => $e_id) {
$e_ids[$i] = hex2dec(basename($e_id)); //Strip prefix 'tag:google.com,2005:reader/item/' $e_ids[$i] = hex2dec(basename($e_id)); //Strip prefix 'tag:google.com,2005:reader/item/'
@ -520,7 +520,7 @@ function editTag($e_ids, $a, $r) {
} }
function markAllAsRead($streamId, $olderThanId) { function markAllAsRead($streamId, $olderThanId) {
logMe("markAllAsRead($streamId, $olderThanId)\n"); //logMe("markAllAsRead($streamId, $olderThanId)");
$entryDAO = FreshRSS_Factory::createEntryDao(); $entryDAO = FreshRSS_Factory::createEntryDao();
if (strpos($streamId, 'feed/') === 0) { if (strpos($streamId, 'feed/') === 0) {
$f_id = basename($streamId); $f_id = basename($streamId);
@ -538,7 +538,7 @@ function markAllAsRead($streamId, $olderThanId) {
exit(); exit();
} }
logMe('----------------------------------------------------------------'."\n"); //logMe('----------------------------------------------------------------');
//logMe(debugInfo()); //logMe(debugInfo());
$pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_INFO']); $pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_INFO']);
@ -560,7 +560,7 @@ if ($user !== '') {
$conf = get_user_configuration($user); $conf = get_user_configuration($user);
} }
logMe('User => ' . $user . "\n"); //logMe('User => ' . $user);
Minz_Session::_param('currentUser', $user); Minz_Session::_param('currentUser', $user);

Loading…
Cancel
Save