From: Christian Weiske Date: Sun, 2 Apr 2023 18:10:20 +0000 (+0200) Subject: Use composer for dependency installation X-Git-Url: https://git.cweiske.de/stapibas.git/commitdiff_plain/921c63670ed480417eea6049e0703dd7faa8ed61?ds=sidebyside Use composer for dependency installation --- diff --git a/.gitignore b/.gitignore index 457fc5d..16c635b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ www/test.htm lib/* /dist/ /bin/phar-stapibas.php -/README.html \ No newline at end of file +/README.html +/vendor/ diff --git a/README.rst b/README.rst index 97322e8..fea31c2 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ In Apache you can do this with the following configuration:: Header set X-Pingback "http://stapibas.example.org/xmlrpc.php" Header append Link '; rel="webmention"' - + Now, whitelist your domain in the database: Add an ``lt_url`` of ``https://example.org/%`` in the ``linkbacktargets`` table. @@ -93,21 +93,10 @@ extract new URLs from the feed and send pingbacks to them. $ php bin/stapibas - + ============ Dependencies ============ -- PHP 5.3+ +- PHP 8.0+ - PDO -- `Console_CommandLine`__ -- `Net_URL2`__ -- `HTTP_Request2`__ -- `PEAR2 Services_Linkback`__ -- `SimplePie`__ - -__ http://pear.php.net/package/Console_CommandLine -__ http://pear.php.net/package/Net_URL2 -__ http://pear.php.net/package/HTTP_Request2 -__ https://github.com/pear2/Services_Linkback -__ http://simplepie.org/ - +- PHP libraries that get installed with ``composer install --no-dev`` diff --git a/bin/stapibas b/bin/stapibas index 97028ec..e284137 100755 --- a/bin/stapibas +++ b/bin/stapibas @@ -2,7 +2,7 @@ run(); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e204120 --- /dev/null +++ b/composer.json @@ -0,0 +1,16 @@ +{ + "name": "cweiske/stapibas", + "description": "The standalone Linkback server, written in PHP.", + "autoload": { + "psr-4": { + "stapibas\\": "src/stapibas/" + } + }, + "require": { + "pear/console_commandline": "^1.2.6", + "pear/net_url2": "^2.2", + "pear/http_request2": "^2.5", + "pear2/services_linkback": "^0.4.0", + "simplepie/simplepie": "^1.8" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5c573e1 --- /dev/null +++ b/composer.lock @@ -0,0 +1,439 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "a228cc8658bd875469df78992799f272", + "packages": [ + { + "name": "pear/console_commandline", + "version": "v1.2.6", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_CommandLine.git", + "reference": "611c5bff2e47ec5a184748cb5fedc2869098ff28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_CommandLine/zipball/611c5bff2e47ec5a184748cb5fedc2869098ff28", + "reference": "611c5bff2e47ec5a184748cb5fedc2869098ff28", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xml": "*", + "pear/pear_exception": "^1.0.0", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "psr-0": { + "Console": "./" + }, + "exclude-from-classmap": [ + "tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Quadling", + "email": "rquadling@gmail.com" + }, + { + "name": "David Jean Louis", + "email": "izimobil@gmail.com" + } + ], + "description": "A full featured command line options and arguments parser.", + "homepage": "https://github.com/pear/Console_CommandLine", + "keywords": [ + "console" + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_CommandLine", + "source": "https://github.com/pear/Console_CommandLine" + }, + "time": "2023-04-02T18:49:53+00:00" + }, + { + "name": "pear/http2", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/pear/HTTP2.git", + "reference": "72e15b4faa86f6109c6fc3aa82c5515b6453b3b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/HTTP2/zipball/72e15b4faa86f6109c6fc3aa82c5515b6453b3b5", + "reference": "72e15b4faa86f6109c6fc3aa82c5515b6453b3b5", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-0": { + "HTTP2": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Michael Wallner", + "email": "mike@php.net", + "role": "Lead" + }, + { + "name": "Philippe Jausions", + "email": "jausions@php.net", + "role": "Lead" + } + ], + "description": "Miscellaneous HTTP utilities", + "homepage": "http://pear.php.net/package/HTTP2", + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP2", + "source": "https://github.com/pear/HTTP2" + }, + "time": "2023-03-22T20:22:11+00:00" + }, + { + "name": "pear/http_request2", + "version": "v2.5.1", + "source": { + "type": "git", + "url": "https://github.com/pear/HTTP_Request2.git", + "reference": "db4ce7844f838d3adca0513a77420c0fec22ed2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/db4ce7844f838d3adca0513a77420c0fec22ed2d", + "reference": "db4ce7844f838d3adca0513a77420c0fec22ed2d", + "shasum": "" + }, + "require": { + "pear/net_url2": "^2.2.0", + "pear/pear_exception": "^1.0.0", + "php": ">=5.6.0" + }, + "require-dev": { + "yoast/phpunit-polyfills": "^1.0.0" + }, + "suggest": { + "ext-curl": "Allows using cURL as a request backend.", + "ext-fileinfo": "Adds support for looking up mime-types using finfo.", + "ext-openssl": "Allows handling SSL requests when not using cURL.", + "ext-zlib": "Allows handling gzip compressed responses." + }, + "type": "library", + "autoload": { + "psr-0": { + "HTTP_Request2": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Alexey Borzov", + "email": "avb@php.net" + } + ], + "description": "Provides an easy way to perform HTTP requests.", + "homepage": "https://pear.php.net/package/HTTP_Request2", + "keywords": [ + "PEAR", + "curl", + "http", + "request" + ], + "support": { + "docs": "https://pear.php.net/manual/en/package.http.http-request2.php", + "issues": "https://github.com/pear/HTTP_Request2/issues", + "source": "https://github.com/pear/HTTP_Request2" + }, + "time": "2022-01-06T18:20:25+00:00" + }, + { + "name": "pear/net_url2", + "version": "v2.2.2", + "source": { + "type": "git", + "url": "https://github.com/pear/Net_URL2.git", + "reference": "07fd055820dbf466ee3990abe96d0e40a8791f9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Net_URL2/zipball/07fd055820dbf466ee3990abe96d0e40a8791f9d", + "reference": "07fd055820dbf466ee3990abe96d0e40a8791f9d", + "shasum": "" + }, + "require": { + "php": ">=5.1.4" + }, + "require-dev": { + "phpunit/phpunit": ">=3.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "Net/URL2.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "./" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "David Coallier", + "email": "davidc@php.net" + }, + { + "name": "Tom Klingenberg", + "email": "tkli@php.net" + }, + { + "name": "Christian Schmidt", + "email": "chmidt@php.net" + } + ], + "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", + "homepage": "https://github.com/pear/Net_URL2", + "keywords": [ + "PEAR", + "net", + "networking", + "rfc3986", + "uri", + "url" + ], + "support": { + "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", + "source": "https://github.com/pear/Net_URL2" + }, + "time": "2017-08-25T06:16:11+00:00" + }, + { + "name": "pear/pear_exception", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/pear/PEAR_Exception.git", + "reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/b14fbe2ddb0b9f94f5b24cf08783d599f776fff0", + "reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "<9" + }, + "type": "class", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "PEAR/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "." + ], + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Helgi Thormar", + "email": "dufuz@php.net" + }, + { + "name": "Greg Beaver", + "email": "cellog@php.net" + } + ], + "description": "The PEAR Exception base class.", + "homepage": "https://github.com/pear/PEAR_Exception", + "keywords": [ + "exception" + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception", + "source": "https://github.com/pear/PEAR_Exception" + }, + "time": "2021-03-21T15:43:46+00:00" + }, + { + "name": "pear2/services_linkback", + "version": "v0.4.0", + "source": { + "type": "git", + "url": "https://github.com/pear2/Services_Linkback.git", + "reference": "61790889871cae0bc6e54adb2637b9e0ec93275f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear2/Services_Linkback/zipball/61790889871cae0bc6e54adb2637b9e0ec93275f", + "reference": "61790889871cae0bc6e54adb2637b9e0ec93275f", + "shasum": "" + }, + "require": { + "ext-xmlrpc": "*", + "pear/http2": "^2.0", + "pear/http_request2": "^2.5", + "pear/net_url2": "^2.2" + }, + "require-dev": { + "pear/stream_var": "^2.0", + "phpunit/phpunit": "^9", + "squizlabs/php_codesniffer": "~2.6" + }, + "type": "library", + "autoload": { + "psr-0": { + "PEAR2\\Services\\Linkback\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0+" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@php.net", + "homepage": "http://cweiske.de/" + } + ], + "description": "Pingback+webmention client and server implementation ", + "homepage": "http://pear2.php.net/PEAR2_Services_Linkback", + "support": { + "email": "pear-general@lists.php.net", + "issues": "https://github.com/pear2/Services_Linkback/issues/", + "source": "https://github.com/pear2/Services_Linkback/tree/v0.4.0" + }, + "time": "2023-03-22T21:18:04+00:00" + }, + { + "name": "simplepie/simplepie", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/simplepie/simplepie.git", + "reference": "65b095d87bc00898d8fa7737bdbcda93a3fbcc55" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/simplepie/simplepie/zipball/65b095d87bc00898d8fa7737bdbcda93a3fbcc55", + "reference": "65b095d87bc00898d8fa7737bdbcda93a3fbcc55", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "php": ">=7.2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19 || ^3.8", + "psr/simple-cache": "^1 || ^2 || ^3", + "yoast/phpunit-polyfills": "^1.0.1" + }, + "suggest": { + "ext-curl": "", + "ext-iconv": "", + "ext-intl": "", + "ext-mbstring": "", + "mf2/mf2": "Microformat module that allows for parsing HTML for microformats" + }, + "type": "library", + "autoload": { + "psr-0": { + "SimplePie": "library" + }, + "psr-4": { + "SimplePie\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Ryan Parman", + "homepage": "http://ryanparman.com/", + "role": "Creator, alumnus developer" + }, + { + "name": "Sam Sneddon", + "homepage": "https://gsnedders.com/", + "role": "Alumnus developer" + }, + { + "name": "Ryan McCue", + "email": "me@ryanmccue.info", + "homepage": "http://ryanmccue.info/", + "role": "Developer" + } + ], + "description": "A simple Atom/RSS parsing library for PHP", + "homepage": "http://simplepie.org/", + "keywords": [ + "atom", + "feeds", + "rss" + ], + "support": { + "issues": "https://github.com/simplepie/simplepie/issues", + "source": "https://github.com/simplepie/simplepie/tree/1.8.0" + }, + "time": "2023-01-20T08:37:35+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/src/stapibas/PDO.php b/src/stapibas/PDO.php index 7b85906..65a6b73 100644 --- a/src/stapibas/PDO.php +++ b/src/stapibas/PDO.php @@ -6,8 +6,9 @@ namespace stapibas; */ class PDO extends \PDO { - public function query() - { + public function query( + string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs + ): \PDOStatement|false { $args = func_get_args(); $res = call_user_func_array(array('parent', 'query'), $args); if ($res !== false) { @@ -17,7 +18,7 @@ class PDO extends \PDO $this->handleError(); } - public function exec($statement) + public function exec(string $statement): int|false { $res = parent::exec($statement); if ($res !== false) { @@ -36,4 +37,4 @@ class PDO extends \PDO } } -?> \ No newline at end of file +?> diff --git a/src/stapibas/autoloader.php b/src/stapibas/autoloader.php deleted file mode 100644 index 6ff3f1b..0000000 --- a/src/stapibas/autoloader.php +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/www/www-header.php b/www/www-header.php index f42ebc7..1e53013 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -4,7 +4,7 @@ header('HTTP/1.0 500 Internal Server error'); header('Content-type: text/plain'); require_once __DIR__ . '/../data/config.php'; -require_once 'stapibas/autoloader.php'; +require_once __DIR__ . '/../vendor/autoload.php'; $db = new PDO($dbdsn, $dbuser, $dbpass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/www/xmlrpc.php b/www/xmlrpc.php index 5a56488..5eb3927 100644 --- a/www/xmlrpc.php +++ b/www/xmlrpc.php @@ -3,7 +3,7 @@ namespace stapibas; /** * Simply stores all pingbacks in the database. */ -require_once 'www-header.php'; +require_once '../vendor/autoload.php'; $s = new \PEAR2\Services\Linkback\Server();