Browse Source

log input received from superfeedr

main
Aaron Parecki 9 years ago
parent
commit
195b827e0d
6 changed files with 289 additions and 41 deletions
  1. +2
    -1
      composer.json
  2. +261
    -39
      composer.lock
  3. +4
    -0
      controllers/API.php
  4. +20
    -0
      lib/helpers.php
  5. +1
    -1
      scripts/telegraph.php
  6. +1
    -0
      tests/bootstrap.php

+ 2
- 1
composer.json View File

@ -12,7 +12,8 @@
"p3k/caterpillar": "0.1.*", "p3k/caterpillar": "0.1.*",
"predis/predis": "1.*", "predis/predis": "1.*",
"michelf/php-markdown": "1.6.*", "michelf/php-markdown": "1.6.*",
"camspiers/json-pretty": "1.0.*"
"camspiers/json-pretty": "1.0.*",
"monolog/monolog": "1.*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "*" "phpunit/phpunit": "*"

+ 261
- 39
composer.lock View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "a8d37c97d0b911b03141113fb4cd1322",
"content-hash": "5b9ec8fe80d7a02cfbb56463f40efb9c",
"hash": "80253bee3fec80ece5c62e69419ed6da",
"content-hash": "033f44c5ec88a9c53103e9a38e3f78c3",
"packages": [ "packages": [
{ {
"name": "barnabywalters/mf-cleaner", "name": "barnabywalters/mf-cleaner",
@ -298,6 +298,48 @@
], ],
"time": "2015-12-23 18:11:19" "time": "2015-12-23 18:11:19"
}, },
{
"name": "ircmaxell/password-compat",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/ircmaxell/password_compat.git",
"reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c",
"reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "4.*"
},
"type": "library",
"autoload": {
"files": [
"lib/password.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthony Ferrara",
"email": "ircmaxell@php.net",
"homepage": "http://blog.ircmaxell.com"
}
],
"description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
"homepage": "https://github.com/ircmaxell/password_compat",
"keywords": [
"hashing",
"password"
],
"time": "2014-11-20 16:49:30"
},
{ {
"name": "j4mie/idiorm", "name": "j4mie/idiorm",
"version": "v1.5.1", "version": "v1.5.1",
@ -628,6 +670,83 @@
], ],
"time": "2015-12-24 01:37:31" "time": "2015-12-24 01:37:31"
}, },
{
"name": "monolog/monolog",
"version": "1.17.2",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bee7f0dc9c3e0b69a6039697533dca1e845c8c24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bee7f0dc9c3e0b69a6039697533dca1e845c8c24",
"reference": "bee7f0dc9c3e0b69a6039697533dca1e845c8c24",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"raven/raven": "^0.13",
"ruflin/elastica": ">=0.90 <3.0",
"swiftmailer/swiftmailer": "~5.3",
"videlalvaro/php-amqplib": "~2.4"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"raven/raven": "Allow sending log messages to a Sentry server",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.16.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"time": "2015-10-14 12:51:02"
},
{ {
"name": "nikic/fast-route", "name": "nikic/fast-route",
"version": "v0.7.0", "version": "v0.7.0",
@ -808,23 +927,62 @@
], ],
"time": "2015-07-30 18:34:15" "time": "2015-07-30 18:34:15"
}, },
{
"name": "psr/log",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"Psr\\Log\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2012-12-21 11:40:51"
},
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v2.8.0",
"version": "v2.8.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "5ed0ec39ef684bec84d1fd9f2a55104e403b7e49"
"reference": "9194b33c71da8ef4d05d22964376f2f9c95a1bfd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5ed0ec39ef684bec84d1fd9f2a55104e403b7e49",
"reference": "5ed0ec39ef684bec84d1fd9f2a55104e403b7e49",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/9194b33c71da8ef4d05d22964376f2f9c95a1bfd",
"reference": "9194b33c71da8ef4d05d22964376f2f9c95a1bfd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.9", "php": ">=5.3.9",
"symfony/polyfill-php54": "~1.0"
"symfony/polyfill-php54": "~1.0",
"symfony/polyfill-php55": "~1.0"
}, },
"require-dev": { "require-dev": {
"symfony/expression-language": "~2.4|~3.0.0" "symfony/expression-language": "~2.4|~3.0.0"
@ -859,20 +1017,20 @@
], ],
"description": "Symfony HttpFoundation Component", "description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-27 11:03:19"
"time": "2016-01-13 10:28:07"
}, },
{ {
"name": "symfony/polyfill-php54", "name": "symfony/polyfill-php54",
"version": "v1.0.0",
"version": "v1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php54.git", "url": "https://github.com/symfony/polyfill-php54.git",
"reference": "2c9f6d98eb30dc04fe0b06f9cc92a55acea5bdcc"
"reference": "74663d5a2ff3c530c1bc0571500e0feec9094054"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/2c9f6d98eb30dc04fe0b06f9cc92a55acea5bdcc",
"reference": "2c9f6d98eb30dc04fe0b06f9cc92a55acea5bdcc",
"url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/74663d5a2ff3c530c1bc0571500e0feec9094054",
"reference": "74663d5a2ff3c530c1bc0571500e0feec9094054",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -881,7 +1039,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -917,7 +1075,63 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2015-11-04 20:28:58"
"time": "2016-01-20 09:13:37"
},
{
"name": "symfony/polyfill-php55",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php55.git",
"reference": "b4f3f07d91702f8f926339fc4fcf81671d8c27e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/b4f3f07d91702f8f926339fc4fcf81671d8c27e6",
"reference": "b4f3f07d91702f8f926339fc4fcf81671d8c27e6",
"shasum": ""
},
"require": {
"ircmaxell/password-compat": "~1.0",
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php55\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2016-01-20 09:13:37"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -1128,16 +1342,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "3.0.2",
"version": "3.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d"
"reference": "92f5c61b5c64159faec5298325ffab0c7e59dcc8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7bb5cddf4ffe113eeb737b05241adb947b43f9d",
"reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/92f5c61b5c64159faec5298325ffab0c7e59dcc8",
"reference": "92f5c61b5c64159faec5298325ffab0c7e59dcc8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1146,7 +1360,7 @@
"phpunit/php-text-template": "~1.2", "phpunit/php-text-template": "~1.2",
"phpunit/php-token-stream": "~1.3", "phpunit/php-token-stream": "~1.3",
"sebastian/environment": "^1.3.2", "sebastian/environment": "^1.3.2",
"sebastian/version": "~1.0"
"sebastian/version": "~1.0|~2.0"
}, },
"require-dev": { "require-dev": {
"ext-xdebug": ">=2.1.4", "ext-xdebug": ">=2.1.4",
@ -1160,7 +1374,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "3.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -1186,7 +1400,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-11-12 21:08:20"
"time": "2016-02-04 13:05:19"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -1368,16 +1582,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "5.1.3",
"version": "5.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "c047ff05d2279404af9a7e89e2a7151c32c88022"
"reference": "40d32454fdad8a08ded0a2aafbc6d0e8f06a6b04"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c047ff05d2279404af9a7e89e2a7151c32c88022",
"reference": "c047ff05d2279404af9a7e89e2a7151c32c88022",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/40d32454fdad8a08ded0a2aafbc6d0e8f06a6b04",
"reference": "40d32454fdad8a08ded0a2aafbc6d0e8f06a6b04",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1389,7 +1603,7 @@
"myclabs/deep-copy": "~1.3", "myclabs/deep-copy": "~1.3",
"php": ">=5.6", "php": ">=5.6",
"phpspec/prophecy": "^1.3.1", "phpspec/prophecy": "^1.3.1",
"phpunit/php-code-coverage": "~3.0",
"phpunit/php-code-coverage": "~3.1",
"phpunit/php-file-iterator": "~1.4", "phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2", "phpunit/php-text-template": "~1.2",
"phpunit/php-timer": ">=1.0.6", "phpunit/php-timer": ">=1.0.6",
@ -1400,7 +1614,7 @@
"sebastian/exporter": "~1.2", "sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0", "sebastian/global-state": "~1.0",
"sebastian/resource-operations": "~1.0", "sebastian/resource-operations": "~1.0",
"sebastian/version": "~1.0",
"sebastian/version": "~1.0|~2.0",
"symfony/yaml": "~2.1|~3.0" "symfony/yaml": "~2.1|~3.0"
}, },
"suggest": { "suggest": {
@ -1412,7 +1626,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "5.1.x-dev"
"dev-master": "5.2.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -1438,7 +1652,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-12-10 07:54:54"
"time": "2016-02-05 17:50:46"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
@ -1876,19 +2090,27 @@
}, },
{ {
"name": "sebastian/version", "name": "sebastian/version",
"version": "1.0.6",
"version": "2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/version.git", "url": "https://github.com/sebastianbergmann/version.git",
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
"reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5",
"reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5",
"shasum": "" "shasum": ""
}, },
"require": {
"php": ">=5.6"
},
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": { "autoload": {
"classmap": [ "classmap": [
"src/" "src/"
@ -1907,20 +2129,20 @@
], ],
"description": "Library that helps with managing the version number of Git-hosted PHP projects", "description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version", "homepage": "https://github.com/sebastianbergmann/version",
"time": "2015-06-21 13:59:46"
"time": "2016-02-04 12:56:52"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.0.0",
"version": "v3.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002"
"reference": "3cf0709d7fe936e97bee9e954382e449003f1d9a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002",
"reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002",
"url": "https://api.github.com/repos/symfony/yaml/zipball/3cf0709d7fe936e97bee9e954382e449003f1d9a",
"reference": "3cf0709d7fe936e97bee9e954382e449003f1d9a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1956,7 +2178,7 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-11-30 12:36:17"
"time": "2016-02-02 13:44:19"
} }
], ],
"aliases": [], "aliases": [],

+ 4
- 0
controllers/API.php View File

@ -2,6 +2,8 @@
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Monolog\Logger;
class API { class API {
public $http; public $http;
@ -160,6 +162,8 @@ class API {
} }
public function superfeedr_tracker(Request $request, Response $response, $args) { public function superfeedr_tracker(Request $request, Response $response, $args) {
logger()->addInfo("Got payload from superfeedr", $request->request->all());
# Require the code parameter # Require the code parameter
if(!$token=$args['token']) { if(!$token=$args['token']) {
return $this->respond($response, 401, [ return $this->respond($response, 401, [

+ 20
- 0
lib/helpers.php View File

@ -1,4 +1,7 @@
<?php <?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
if(array_key_exists('ENV', $_ENV)) { if(array_key_exists('ENV', $_ENV)) {
@ -13,6 +16,23 @@ function initdb() {
ORM::configure('password', Config::$db['password']); ORM::configure('password', Config::$db['password']);
} }
function logger() {
static $log;
if(!isset($log)) {
$log = new Logger('name');
$log->pushHandler(new StreamHandler(dirname(__FILE__).'/../logs/telegraph.log', Logger::DEBUG));
}
return $log;
}
function log_info($msg) {
logger()->addInfo($msg);
}
function log_warning($msg) {
logger()->addWarning($msg);
}
function view($template, $data=[]) { function view($template, $data=[]) {
global $templates; global $templates;
return $templates->render($template, $data); return $templates->render($template, $data);

+ 1
- 1
scripts/telegraph.php View File

@ -2,4 +2,4 @@
chdir('..'); chdir('..');
include('vendor/autoload.php'); include('vendor/autoload.php');
q()->run_workers(4);
q()->run_workers(array_key_exists(1, $argv) ? $argv[1] : 4);

+ 1
- 0
tests/bootstrap.php View File

@ -1,2 +1,3 @@
<?php <?php
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
initdb();

Loading…
Cancel
Save