├── .gitignore ├── www ├── favicon.ico ├── img │ ├── logo.png │ └── anonymous.svg ├── robots.txt ├── css │ ├── latest.css │ ├── index.css │ ├── auth-choose.css │ └── user.css ├── index.php ├── .htaccess ├── latest.php ├── latest-atom.php ├── user.php ├── comment.php ├── www-header.php ├── token.php ├── auth.php └── micropub.php ├── composer.json ├── data ├── config.php.dist ├── templates │ ├── auth-index.htm │ ├── user.htm │ ├── post-like.htm │ ├── post-reply.htm │ ├── latest-atom.htm │ ├── latest.htm │ ├── index.htm │ └── auth-choose.htm └── schema.sql ├── scripts └── dump-schema.sh ├── src └── anoweco │ ├── autoload.php │ ├── Linkback.php │ ├── Urls.php │ └── Storage.php ├── README.rst ├── composer.lock └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /data/config.php 2 | /README.html 3 | /vendor/ 4 | -------------------------------------------------------------------------------- /www/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cweiske/anoweco/master/www/favicon.ico -------------------------------------------------------------------------------- /www/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cweiske/anoweco/master/www/img/logo.png -------------------------------------------------------------------------------- /www/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: /auth.php 3 | Disallow: /micropub.php 4 | Disallow: /token.php 5 | -------------------------------------------------------------------------------- /www/css/latest.css: -------------------------------------------------------------------------------- 1 | table { 2 | border: 1px solid grey; 3 | border-collapse: collapse; 4 | } 5 | td, th { 6 | border: 1px solid grey; 7 | padding: 0.5ex 1ex; 8 | } 9 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "pear/net_url2": "^2.2", 4 | "twig/twig": "^3.0", 5 | "pear/services_libravatar": "^0.2.4", 6 | "pear2/services_linkback": "^0.4.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /data/config.php.dist: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /www/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | max-width: 60ex; 3 | margin-left: auto; 4 | margin-right: auto; 5 | background-color: #EEE; 6 | } 7 | 8 | pre { 9 | background-color: #DDD; 10 | padding: 2ex; 11 | border-radius: 1ex; 12 | } -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | $title, 10 | 'baseurl' => Urls::full('/'), 11 | ) 12 | ); 13 | ?> -------------------------------------------------------------------------------- /scripts/dump-schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # update data/schema.sql 3 | cd "`dirname "$0"`" 4 | mysqldump\ 5 | --skip-add-locks\ 6 | --skip-disable-keys\ 7 | --skip-add-drop-table\ 8 | --no-data\ 9 | -uanoweco -panoweco\ 10 | anoweco\ 11 | | grep -v '^/\\*'\ 12 | | grep -v '^--'\ 13 | | sed 's/AUTO_INCREMENT=[0-9]* //'\ 14 | > ../data/schema.sql 15 | -------------------------------------------------------------------------------- /www/.htaccess: -------------------------------------------------------------------------------- 1 | # PHP does not see the "Authorization" header by default 2 | # so we have to manually pass it to PHP 3 | SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 4 | 5 | RewriteEngine On 6 | RewriteBase / 7 | RewriteCond %{REQUEST_FILENAME} !-f 8 | RewriteCond %{REQUEST_FILENAME} !-d 9 | RewriteRule ^comment/([0-9]+).htm$ comment.php?id=$1 10 | RewriteRule ^user/([0-9]+).htm$ user.php?id=$1 11 | -------------------------------------------------------------------------------- /www/latest.php: -------------------------------------------------------------------------------- 1 | listLatest(); 7 | 8 | foreach ($comments as $comment) { 9 | $comment->url = Urls::comment($comment->comment_id); 10 | $comment->domain = parse_url($comment->comment_of_url, PHP_URL_HOST); 11 | } 12 | 13 | $vars = [ 14 | 'comments' => $comments, 15 | ]; 16 | render('latest', $vars); 17 | ?> 18 | -------------------------------------------------------------------------------- /data/templates/auth-index.htm: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |9 | This is an anonymous authentication and authorization 10 | endpoint for the IndieAuth protocol. 11 |
12 |13 | When asked about your website on an IndieAuth login screen, 14 | simply type: 15 |
16 |{{baseurl}}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/www/latest-atom.php:
--------------------------------------------------------------------------------
1 | listLatest();
7 |
8 | foreach ($comments as $comment) {
9 | $comment->url = Urls::comment($comment->comment_id);
10 | $comment->domain = parse_url($comment->comment_of_url, PHP_URL_HOST);
11 | }
12 |
13 | $vars = [
14 | 'baseUrl' => getBaseUrl(),
15 | 'comments' => $comments,
16 | 'lastComment' => $comments[0],
17 | ];
18 | header('Content-Type: application/atom+xml');
19 | render('latest-atom', $vars);
20 | ?>
21 |
--------------------------------------------------------------------------------
/www/img/anonymous.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/data/templates/user.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 | {% apply spaceless %}
12 |
13 |
14 | {{author.name}}
15 | {% endapply %}
16 | likes
17 | {{attribute(json, 'like-of').0}}.
19 |
11 | {% apply spaceless %}
12 |
13 |
14 | {{author.name}}
15 | {% endapply %}
16 | wrote
17 | the following reply to
18 | :
20 |
23 | Reply to this comment 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /data/templates/latest-atom.htm: -------------------------------------------------------------------------------- 1 | 2 || Date | 16 |Type | 17 |User | 18 |For domain | 19 |
|---|---|---|---|
| {{comment.comment_published}} | 25 |{{comment.comment_type}} | 26 |{{comment.user.user_name}} | 27 |{{comment.domain}} | 28 |
15 | Anonymous web comments for the indieweb. 16 |
17 | 18 | 19 |21 | Write a reply to a blog post: 22 |
23 | 33 | 34 | 35 |37 | This is an anonymous authentication and authorization 38 | endpoint for the IndieAuth protocol. 39 |
40 |41 | When asked about your website on an IndieAuth login screen, 42 | simply type: 43 |
44 |{{baseurl}}
45 |
46 |
47 | 49 | anoweco is open source. 50 | You may view the 51 | latest posts. 52 |
53 | 54 | 55 | -------------------------------------------------------------------------------- /src/anoweco/Linkback.php: -------------------------------------------------------------------------------- 1 | lbc = new \PEAR2\Services\Linkback\Client(); 11 | $req = $this->lbc->getRequest(); 12 | /* 13 | $req->setConfig( 14 | array( 15 | 'ssl_verify_peer' => false, 16 | 'ssl_verify_host' => false 17 | ) 18 | ); 19 | */ 20 | $headers = $req->getHeaders(); 21 | $req->setHeader('user-agent', 'anoweco'); 22 | $this->lbc->setRequestTemplate($req); 23 | } 24 | 25 | public function ping($postId) 26 | { 27 | $this->initLbc(); 28 | $storage = new Storage(); 29 | $rowPost = $storage->getJsonComment($postId)->Xrow; 30 | 31 | $from = Urls::full(Urls::comment($postId)); 32 | $to = $rowPost->comment_of_url; 33 | 34 | try { 35 | $res = $this->lbc->send($from, $to); 36 | if (!$res->isError()) { 37 | //all ok 38 | $error = false; 39 | } else { 40 | //some error 41 | error_log($res->getMessage()); 42 | $error = true; 43 | } 44 | } catch (\Exception $e) { 45 | error_log($e->getMessage()); 46 | $error = true; 47 | } 48 | 49 | if ($error) { 50 | $pingState = intval($rowPost->comment_pingstate) + 1; 51 | } else { 52 | $pingState = 'ok'; 53 | } 54 | $storage->setPostPingState($postId, $pingState); 55 | } 56 | } 57 | ?> 58 | -------------------------------------------------------------------------------- /data/templates/auth-choose.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |10 | You may log in to {{client_id}} with any identity you like. 11 |
12 | 13 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/anoweco/Urls.php: -------------------------------------------------------------------------------- 1 | user_imageurl != '') { 19 | return $rowUser->user_imageurl; 20 | } 21 | return static::full('/img/anonymous.svg'); 22 | } 23 | 24 | public static function full($str) 25 | { 26 | if (!isset($_SERVER['REQUEST_SCHEME'])) { 27 | $_SERVER['REQUEST_SCHEME'] = 'http'; 28 | } 29 | return $_SERVER['REQUEST_SCHEME'] . '://' 30 | . $_SERVER['HTTP_HOST'] 31 | . $str; 32 | } 33 | 34 | public static function userId($url) 35 | { 36 | $userbaseurl = Urls::full('/user/'); 37 | if (substr($url, 0, strlen($userbaseurl)) != $userbaseurl) { 38 | return null; 39 | } 40 | //actual user URL - loads his data 41 | $userId = substr($url, strrpos($url, '/') + 1, -4); 42 | if (intval($userId) != $userId) { 43 | return null; 44 | } 45 | return intval($userId); 46 | } 47 | 48 | public static function reply($url) 49 | { 50 | return 'https://quill.p3k.io/' 51 | . '?' . http_build_query( 52 | [ 53 | 'dontask' => 1, 54 | 'me' => Urls::full('/'), 55 | 'reply' => $url, 56 | ] 57 | ); 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /www/comment.php: -------------------------------------------------------------------------------- 1 | getJsonComment($id); 22 | if ($comment === null) { 23 | header('HTTP/1.0 404 Not Found'); 24 | header('Content-Type: text/plain'); 25 | echo "Comment not found\n"; 26 | exit(1); 27 | } 28 | 29 | $rowComment = $comment->Xrow; 30 | $rowUser = $comment->user; 31 | 32 | $vars = array( 33 | 'json' => $comment->properties, 34 | 'crow' => $rowComment, 35 | 'comment' => $comment, 36 | 'author' => array( 37 | 'name' => $rowUser->user_name, 38 | 'url' => Urls::full(Urls::user($rowUser->user_id)), 39 | 'imageurl' => Urls::userImg($rowUser), 40 | ), 41 | 'postUrl' => Urls::full(Urls::comment($rowComment->comment_id)), 42 | 'replyUrl' => Urls::reply( 43 | Urls::full(Urls::comment($rowComment->comment_id)) 44 | ), 45 | ); 46 | 47 | if ($rowComment->comment_type == 'like') { 48 | $template = 'post-like'; 49 | } else { 50 | //reply 51 | $template = 'post-reply'; 52 | if (isset($comment->properties->content['html'])) { 53 | $htmlContent = $comment->properties->content['html']; 54 | } else { 55 | $htmlContent = nl2br($comment->properties->content[0]); 56 | } 57 | $vars['htmlContent'] = $htmlContent; 58 | } 59 | 60 | if (isset($linkbackEndpoint) && $linkbackEndpoint) { 61 | header('X-Pingback: ' . $linkbackEndpoint); 62 | header('Link: <' . $linkbackEndpoint . '>; rel="webmention"'); 63 | } 64 | 65 | render($template, $vars); 66 | ?> 67 | -------------------------------------------------------------------------------- /www/www-header.php: -------------------------------------------------------------------------------- 1 | '/path/to/compilation_cache', 12 | 'debug' => true 13 | ) 14 | ); 15 | //$twig->addExtension(new Twig_Extension_Debug()); 16 | 17 | function verifyParameter($givenParams, $paramName) 18 | { 19 | if (!isset($givenParams[$paramName])) { 20 | error('"' . $paramName . '" parameter missing'); 21 | } 22 | return $givenParams[$paramName]; 23 | } 24 | 25 | function verifyUrlParameter($givenParams, $paramName) 26 | { 27 | verifyParameter($givenParams, $paramName); 28 | $url = parse_url($givenParams[$paramName]); 29 | if (!isset($url['scheme'])) { 30 | error('Invalid URL in "' . $paramName . '" parameter: scheme missing'); 31 | } 32 | if (!isset($url['host'])) { 33 | error('Invalid URL in "' . $paramName . '" parameter: host missing'); 34 | } 35 | 36 | return $givenParams[$paramName]; 37 | } 38 | 39 | function getOptionalParameter($givenParams, $paramName, $default) 40 | { 41 | if (!isset($givenParams[$paramName])) { 42 | return $default; 43 | } 44 | return $givenParams[$paramName]; 45 | } 46 | 47 | /** 48 | * Send out an error 49 | * 50 | * @param string $status HTTP status code line 51 | * @param string $code One of the allowed status types: 52 | * - forbidden 53 | * - insufficient_scope 54 | * - invalid_request 55 | * - not_found 56 | * @param string $description 57 | */ 58 | function error($description, $status = 'HTTP/1.0 400 Bad Request') 59 | { 60 | header($status); 61 | header('Content-Type: text/plain'); 62 | echo $description . "\n"; 63 | exit(1); 64 | } 65 | 66 | function render($tplname, $vars = array(), $return = false) 67 | { 68 | $template = $GLOBALS['twig']->load($tplname . '.htm'); 69 | 70 | if ($return) { 71 | return $template->render($vars); 72 | } else { 73 | echo $template->render($vars); 74 | } 75 | } 76 | 77 | /** 78 | * No trailing slash 79 | */ 80 | function getBaseUrl() 81 | { 82 | return $_SERVER['REQUEST_SCHEME'] 83 | . '://' . $_SERVER['HTTP_HOST']; 84 | } 85 | ?> 86 | -------------------------------------------------------------------------------- /www/token.php: -------------------------------------------------------------------------------- 1 | $me, 86 | 'client_id' => $client_id, 87 | 'scope' => $scope, 88 | ) 89 | ); 90 | 91 | } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { 92 | //generate token 93 | //we ignore the "me" parameter; it's for proxies only 94 | // see https://github.com/cweiske/anoweco/issues/3 95 | $redirect_uri = verifyUrlParameter($_POST, 'redirect_uri'); 96 | $client_id = verifyUrlParameter($_POST, 'client_id'); 97 | $code = verifyParameter($_POST, 'code');//auth token 98 | $state = getOptionalParameter($_POST, 'state', null); 99 | 100 | //verify auth code 101 | parse_str(base64_decode($code), $codeParts); 102 | $emoji = verifyParameter($codeParts, 'emoji'); 103 | $signature = verifyParameter($codeParts, 'signature'); 104 | $me = verifyUrlParameter($codeParts, 'me'); 105 | if ($emoji != '\360\237\222\251') { 106 | error('Auth token: Dog poo missing'); 107 | } 108 | if ($signature != 'FIXME') { 109 | error('Auth token: Invalid signature'); 110 | } 111 | 112 | //FIXME: check if state are set 113 | //FIXME: check auth endpoint if parameters are valid 114 | // and to get the scope 115 | $scope = 'post'; 116 | 117 | //FIXME: use real encryption 118 | $access_token = base64_encode( 119 | http_build_query( 120 | array( 121 | 'emoji' => '\360\237\222\251', 122 | 'me' => $me, 123 | 'client_id' => $client_id, 124 | 'scope' => $scope, 125 | 'signature' => 'FIXME', 126 | ) 127 | ) 128 | ); 129 | header('HTTP/1.0 200 OK'); 130 | header('Content-type: application/json'); 131 | echo json_encode( 132 | array( 133 | 'access_token' => $access_token, 134 | 'token_type' => 'Bearer', 135 | 'me' => $me, 136 | 'scope' => $scope 137 | ) 138 | ); 139 | } 140 | ?> 141 | -------------------------------------------------------------------------------- /www/auth.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | header('HTTP/1.0 500 Internal Server Error'); 9 | require 'www-header.php'; 10 | 11 | function getOrCreateUser($mode, $name, $imageurl, $email) 12 | { 13 | if ($mode == 'anonymous') { 14 | $name = 'Anonymous'; 15 | $email = ''; 16 | $imageurl = ''; 17 | } else { 18 | if ($name == '') { 19 | $name = 'Anonymous'; 20 | } 21 | } 22 | if ($imageurl == '') { 23 | $imageurl = getImageUrl($email); 24 | } 25 | 26 | $storage = new Storage(); 27 | $id = $storage->findUser($name, $imageurl); 28 | if ($id !== null) { 29 | return $id; 30 | } 31 | $id = $storage->createUser($name, $imageurl); 32 | return $id; 33 | } 34 | 35 | function getImageUrl($email) 36 | { 37 | //FIXME: libravatar 38 | return Urls::userImg((object)['user_imageurl' => '']); 39 | } 40 | 41 | header('IndieAuth: authorization_endpoint'); 42 | if ($_SERVER['REQUEST_METHOD'] == 'GET') { 43 | if (count($_GET) == 0) { 44 | //no parameters - show the index page 45 | header('HTTP/1.0 200 OK'); 46 | header('Content-Type: text/html'); 47 | render('auth-index', ['baseurl' => Urls::full('/')]); 48 | exit(); 49 | } 50 | 51 | $me = verifyUrlParameter($_GET, 'me'); 52 | $redirect_uri = verifyUrlParameter($_GET, 'redirect_uri'); 53 | $client_id = verifyUrlParameter($_GET, 'client_id'); 54 | $state = getOptionalParameter($_GET, 'state', null); 55 | $response_type = getOptionalParameter($_GET, 'response_type', 'id'); 56 | $scope = getOptionalParameter($_GET, 'scope', null); 57 | 58 | $id = array( 59 | 'mode' => 'anonymous', 60 | 'name' => '', 61 | 'imageurl' => '', 62 | ); 63 | $userId = Urls::userId($me); 64 | if ($userId !== null) { 65 | $storage = new Storage(); 66 | $rowUser = $storage->getUser($userId); 67 | if ($rowUser !== null) { 68 | $id['mode'] = 'data'; 69 | $id['name'] = $rowUser->user_name; 70 | $id['imageurl'] = $rowUser->user_imageurl; 71 | if ($id['imageurl'] == Urls::userImg()) { 72 | $id['imageurl'] = ''; 73 | } 74 | } 75 | } 76 | 77 | //let the user choose his identity 78 | header('HTTP/1.0 200 OK'); 79 | render( 80 | 'auth-choose', 81 | array( 82 | 'auth' => array( 83 | 'redirect_uri' => $redirect_uri, 84 | 'client_id' => $client_id, 85 | 'state' => $state, 86 | 'response_type' => $response_type, 87 | 'scope' => $scope, 88 | ), 89 | 'id' => $id, 90 | 'formaction' => '/auth.php?action=login', 91 | ) 92 | ); 93 | exit(); 94 | } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { 95 | if (isset($_GET['action']) && $_GET['action'] == 'login') { 96 | //log the user in 97 | $auth = $_POST['auth']; 98 | $redirect_uri = verifyUrlParameter($auth, 'redirect_uri'); 99 | $client_id = verifyUrlParameter($auth, 'client_id'); 100 | $state = getOptionalParameter($auth, 'state', null); 101 | $response_type = getOptionalParameter($auth, 'response_type', 'id'); 102 | $scope = getOptionalParameter($auth, 'scope', null); 103 | 104 | $id = $_POST['id']; 105 | verifyParameter($id, 'mode'); 106 | 107 | $userId = getOrCreateUser( 108 | $id['mode'], trim($id['name']), trim($id['imageurl']), 109 | trim($id['email']) 110 | ); 111 | $me = Urls::full(Urls::user($userId)); 112 | 113 | $code = base64_encode( 114 | http_build_query( 115 | [ 116 | 'emoji' => '\360\237\222\251', 117 | 'me' => $me, 118 | 'scope' => $scope, 119 | 'signature' => 'FIXME', 120 | ] 121 | ) 122 | ); 123 | 124 | //redirect back to client 125 | $url = new \Net_URL2($redirect_uri); 126 | $url->setQueryVariable('code', $code); 127 | $url->setQueryVariable('me', $me); 128 | $url->setQueryVariable('state', $state); 129 | header('Location: ' . $url->getURL()); 130 | exit(); 131 | } else { 132 | //auth code verification 133 | $code = base64_decode(verifyParameter($_POST, 'code')); 134 | $redirect_uri = verifyUrlParameter($_POST, 'redirect_uri'); 135 | $client_id = verifyUrlParameter($_POST, 'client_id'); 136 | $state = getOptionalParameter($_POST, 'state', null); 137 | 138 | parse_str($code, $codeParts); 139 | $emoji = verifyParameter($codeParts, 'emoji'); 140 | $signature = verifyParameter($codeParts, 'signature'); 141 | $me = verifyUrlParameter($codeParts, 'me'); 142 | if ($emoji != '\360\237\222\251') { 143 | error('Dog poo missing'); 144 | } 145 | if ($signature != 'FIXME') { 146 | error('Invalid signature'); 147 | } 148 | header('HTTP/1.0 200 OK'); 149 | header('Content-type: application/json'); 150 | echo json_encode(['me' => $me]); 151 | exit(); 152 | } 153 | } else if ($_SERVER['REQUEST_METHOD'] == 'HEAD') { 154 | //indieauth.com makes a HEAD request at first 155 | header('HTTP/1.0 200 OK'); 156 | exit(); 157 | } else { 158 | error('Unsupported HTTP request method'); 159 | } 160 | ?> 161 | -------------------------------------------------------------------------------- /src/anoweco/Storage.php: -------------------------------------------------------------------------------- 1 | db = new \PDO($dbdsn, $dbuser, $dbpass); 10 | $this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); 11 | } 12 | 13 | /** 14 | * Store a new comment into the database 15 | * 16 | * @param object $json Micropub create JSON 17 | * @param integer $userId ID of the user whom this comment belongs 18 | * 19 | * @return integer Comment ID 20 | * @throws \Exception 21 | */ 22 | public function addComment($json, $userId) 23 | { 24 | $stmt = $this->db->prepare( 25 | 'INSERT INTO comments SET' 26 | . ' comment_user_id = :userId' 27 | . ', comment_published = NOW()' 28 | . ', comment_of_url = :ofUrl' 29 | . ', comment_type = :type' 30 | . ', comment_json = :json' 31 | . ', comment_pingstate = "0"' 32 | ); 33 | 34 | $ofUrl = ''; 35 | $type = null; 36 | if (isset($json->properties->{'in-reply-to'})) { 37 | $ofUrl = reset($json->properties->{'in-reply-to'}); 38 | $type = 'reply'; 39 | } else if (isset($json->properties->{'like-of'})) { 40 | $ofUrl = reset($json->properties->{'like-of'}); 41 | $type = 'like'; 42 | } else { 43 | throw new \Exception( 44 | 'Invalid post type, only reply and like allowed', 45 | 400 46 | ); 47 | } 48 | 49 | $stmt->execute( 50 | array( 51 | ':userId' => $userId, 52 | ':ofUrl' => $ofUrl, 53 | ':type' => $type, 54 | ':json' => json_encode($json), 55 | ) 56 | ); 57 | return $this->db->lastInsertId(); 58 | } 59 | 60 | /** 61 | * @return null|object NULL if not found, JSON comment object otherwise 62 | * - "Xrow" property contains the database row object 63 | * - "user" property contains the user db row object 64 | */ 65 | public function getJsonComment($id) 66 | { 67 | $stmt = $this->db->prepare( 68 | 'SELECT * FROM comments WHERE comment_id = ?' 69 | ); 70 | $stmt->execute([$id]); 71 | $row = $stmt->fetchObject(); 72 | 73 | if ($row === false) { 74 | return null; 75 | } 76 | 77 | $json = json_decode($row->comment_json); 78 | $json->Xrow = $row; 79 | //FIXME: load user 80 | 81 | $stmt = $this->db->prepare('SELECT * FROM users WHERE user_id = ?'); 82 | $stmt->execute([$row->comment_user_id]); 83 | $rowUser = $stmt->fetchObject(); 84 | if ($rowUser === false) { 85 | $rowUser = (object) array( 86 | 'user_id' => 0, 87 | 'user_name' => 'Anonymous', 88 | 'user_imageurl' => '', 89 | ); 90 | } 91 | 92 | $json->user = $rowUser; 93 | return $json; 94 | } 95 | 96 | /** 97 | * @return null|object NULL if not found, JSON comment object otherwise 98 | * - "Xrow" property contains the database row object 99 | * - "user" property contains the user db row object 100 | */ 101 | public function listLatest() 102 | { 103 | $stmt = $this->db->prepare( 104 | 'SELECT comment_id, comment_user_id, comment_published' 105 | . ', comment_of_url, comment_type' 106 | . ' FROM comments' 107 | . ' ORDER BY comment_published DESC' 108 | . ' LIMIT 20' 109 | ); 110 | $stmt->execute(); 111 | $rows = $stmt->fetchAll(\PDO::FETCH_OBJ); 112 | if (!count($rows)) { 113 | return []; 114 | } 115 | $userIds = array_values( 116 | array_unique(array_column($rows, 'comment_user_id')) 117 | ); 118 | 119 | 120 | $placeholders = implode(',', array_fill(0, count($userIds), '?')); 121 | $stmt = $this->db->prepare( 122 | 'SELECT * FROM users WHERE user_id IN (' . $placeholders . ')' 123 | ); 124 | $stmt->execute($userIds); 125 | 126 | $users = $stmt->fetchAll(\PDO::FETCH_OBJ); 127 | $users = array_combine( 128 | array_column($users, 'user_id'), 129 | $users 130 | ); 131 | 132 | foreach ($rows as $row) { 133 | $row->user = $users[$row->comment_user_id]; 134 | } 135 | 136 | return $rows; 137 | } 138 | 139 | /** 140 | * @return null|object NULL if not found, user database row otherwise 141 | */ 142 | public function getUser($id) 143 | { 144 | $stmt = $this->db->prepare( 145 | 'SELECT * FROM users WHERE user_id = ?' 146 | ); 147 | $stmt->execute([$id]); 148 | $row = $stmt->fetchObject(); 149 | 150 | if ($row === false) { 151 | return null; 152 | } 153 | return $row; 154 | } 155 | 156 | public function findUser($name, $imageurl) 157 | { 158 | $stmt = $this->db->prepare( 159 | 'SELECT user_id FROM users' 160 | . ' WHERE user_name = ? AND user_imageurl = ?' 161 | ); 162 | $stmt->execute([$name, $imageurl]); 163 | $row = $stmt->fetchObject(); 164 | 165 | if ($row === false) { 166 | return null; 167 | } 168 | return $row->user_id; 169 | } 170 | 171 | public function createUser($name, $imageurl) 172 | { 173 | $stmt = $this->db->prepare( 174 | 'INSERT INTO users SET' 175 | . ' user_name = :name' 176 | . ', user_imageurl = :imageurl' 177 | ); 178 | $stmt->execute( 179 | array( 180 | ':name' => $name, 181 | ':imageurl' => $imageurl, 182 | ) 183 | ); 184 | return $this->db->lastInsertId(); 185 | } 186 | 187 | public function setPostPingState($postId, $pingstate) 188 | { 189 | $stmt = $this->db->prepare( 190 | 'UPDATE comments SET comment_pingstate = ? WHERE comment_id = ?' 191 | ); 192 | $stmt->execute(array($pingstate, $postId)); 193 | } 194 | } 195 | ?> 196 | -------------------------------------------------------------------------------- /www/micropub.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | header('HTTP/1.0 500 Internal Server Error'); 9 | require 'www-header.php'; 10 | 11 | /** 12 | * Send out a micropub error 13 | * 14 | * @param string $status HTTP status code line 15 | * @param string $code One of the allowed status types: 16 | * - forbidden 17 | * - insufficient_scope 18 | * - invalid_request 19 | * - not_found 20 | * @param string $description 21 | */ 22 | function mpError($status, $code, $description) 23 | { 24 | header($status); 25 | header('Content-Type: application/json'); 26 | echo json_encode( 27 | ['error' => $code, 'error_description' => $description] 28 | ) . "\n"; 29 | exit(1); 30 | } 31 | 32 | function validateToken($token) 33 | { 34 | $ctx = stream_context_create( 35 | array( 36 | 'http' => array( 37 | 'header' => array( 38 | 'Authorization: Bearer ' . $token, 39 | 'Accept: application/json', 40 | ), 41 | 'ignore_errors' => true, 42 | ), 43 | ) 44 | ); 45 | //FIXME: make hard-coded token server URL configurable 46 | $res = @file_get_contents(Urls::full('/token.php'), false, $ctx); 47 | list($dummy, $code, $msg) = explode(' ', $http_response_header[0]); 48 | if ($code != 200) { 49 | mpError( 50 | 'HTTP/1.0 403 Forbidden', 51 | 'forbidden', 52 | 'Error verifying bearer token: ' . trim($res) 53 | ); 54 | } 55 | 56 | $data = json_decode($res, true); 57 | //FIXME: they spit out non-micropub json error responess 58 | verifyParameter($data, 'me'); 59 | verifyParameter($data, 'client_id'); 60 | verifyParameter($data, 'scope'); 61 | 62 | return [$data['me'], $data['client_id'], $data['scope']]; 63 | } 64 | 65 | function handleCreate($json, $token) 66 | { 67 | list($me, $client_id, $scope) = validateToken($token); 68 | $userId = Urls::userId($me); 69 | if ($userId === null) { 70 | mpError( 71 | 'HTTP/1.0 403 Forbidden', 72 | 'forbidden', 73 | 'Invalid user URL' 74 | ); 75 | } 76 | $storage = new Storage(); 77 | $rowUser = $storage->getUser($userId); 78 | if ($rowUser === null) { 79 | mpError( 80 | 'HTTP/1.0 403 Forbidden', 81 | 'forbidden', 82 | 'User not found: ' . $userId 83 | ); 84 | } 85 | 86 | $storage = new Storage(); 87 | $lb = new Linkback(); 88 | try { 89 | $id = $storage->addComment($json, $userId); 90 | $lb->ping($id); 91 | 92 | header('HTTP/1.0 201 Created'); 93 | header('Location: ' . Urls::full(Urls::comment($id))); 94 | exit(); 95 | } catch (\Exception $e) { 96 | if ($e->getCode() == 400) { 97 | mpError( 98 | 'HTTP/1.0 400 Bad Request', 99 | 'invalid_request', 100 | $e->getMessage() 101 | ); 102 | } 103 | 104 | mpError( 105 | 'HTTP/1.0 500 Internal Server Error', 106 | 'this_violates_the_spec', 107 | $e->getMessage() 108 | ); 109 | exit(); 110 | } 111 | } 112 | 113 | function getTokenFromHeader() 114 | { 115 | if (isset($_SERVER['HTTP_AUTHORIZATION']) 116 | && $_SERVER['HTTP_AUTHORIZATION'] != '' 117 | ) { 118 | $auth = $_SERVER['HTTP_AUTHORIZATION']; 119 | } else if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) 120 | && $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] != '' 121 | ) { 122 | //php-cgi has it there 123 | $auth = $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; 124 | } else { 125 | mpError( 126 | 'HTTP/1.0 403 Forbidden', 'forbidden', 127 | 'Authorization HTTP header missing' 128 | ); 129 | } 130 | if (strpos($auth, ' ') === false) { 131 | mpError( 132 | 'HTTP/1.0 403 Forbidden', 'forbidden', 133 | 'Authorization header must start with "Bearer "' 134 | ); 135 | } 136 | list($bearer, $token) = explode(' ', $auth, 2); 137 | if ($bearer !== 'Bearer') { 138 | mpError( 139 | 'HTTP/1.0 403 Forbidden', 'forbidden', 140 | 'Authorization header must start with "Bearer "' 141 | ); 142 | } 143 | return trim($token); 144 | } 145 | 146 | 147 | if ($_SERVER['REQUEST_METHOD'] == 'GET') { 148 | if (!isset($_GET['q'])) { 149 | mpError( 150 | 'HTTP/1.1 400 Bad Request', 151 | 'invalid_request', 152 | 'Parameter "q" missing.' 153 | ); 154 | } else if ($_GET['q'] === 'config') { 155 | header('HTTP/1.0 200 OK'); 156 | header('Content-Type: application/json'); 157 | echo '{}'; 158 | exit(); 159 | } else if ($_GET['q'] === 'syndicate-to') { 160 | header('HTTP/1.0 200 OK'); 161 | header('Content-Type: application/json'); 162 | echo '{}'; 163 | exit(); 164 | } else { 165 | //FIXME: maybe implement $q=source 166 | header('HTTP/1.1 501 Not Implemented'); 167 | header('Content-Type: text/plain'); 168 | echo 'Unsupported "q" value: ' . $_GET['q'] . "\n"; 169 | exit(); 170 | } 171 | } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { 172 | if (!isset($_SERVER['CONTENT_TYPE'])) { 173 | mpError( 174 | 'HTTP/1.1 400 Bad Request', 175 | 'invalid_request', 176 | 'Content-Type header missing.' 177 | ); 178 | } 179 | list($ctype) = explode(';', $_SERVER['CONTENT_TYPE'], 2); 180 | $ctype = trim($ctype); 181 | if ($ctype == 'application/x-www-form-urlencoded' 182 | || $ctype == 'multipart/form-data' 183 | ) { 184 | if (!isset($_POST['action'])) { 185 | $_POST['action'] = 'create'; 186 | } 187 | if ($_POST['action'] != 'create') { 188 | header('HTTP/1.1 501 Not Implemented'); 189 | header('Content-Type: text/plain'); 190 | echo "Creation of posts supported only\n"; 191 | exit(); 192 | } 193 | 194 | $data = $_POST; 195 | $base = (object) [ 196 | 'type' => ['h-entry'], 197 | ]; 198 | if (isset($data['h'])) { 199 | $base->type = ['h-' . $data['h']]; 200 | unset($data['h']); 201 | } 202 | if (isset($data['access_token'])) { 203 | $token = $data['access_token']; 204 | unset($data['access_token']); 205 | } else { 206 | $token = getTokenFromHeader(); 207 | } 208 | //reserved properties 209 | foreach (['q', 'url', 'action'] as $key) { 210 | if (isset($data[$key])) { 211 | $base->$key = $data[$key]; 212 | unset($data[$key]); 213 | } 214 | } 215 | //"mp-" reserved for future use 216 | foreach ($data as $key => $value) { 217 | if (substr($key, 0, 3) == 'mp-') { 218 | $base->$key = $value; 219 | unset($data[$key]); 220 | } else if (!is_array($value)) { 221 | //convert to array 222 | $data[$key] = [$value]; 223 | } 224 | } 225 | $json = $base; 226 | $json->properties = (object) $data; 227 | handleCreate($json, $token); 228 | } else if ($ctype == 'application/json') { 229 | $input = file_get_contents('php://input'); 230 | $json = json_decode($input); 231 | if ($json === null) { 232 | mpError( 233 | 'HTTP/1.1 400 Bad Request', 234 | 'invalid_request', 235 | 'Invalid JSON' 236 | ); 237 | } 238 | $token = getTokenFromHeader(); 239 | handleCreate($json, $token); 240 | } else { 241 | mpError( 242 | 'HTTP/1.1 400 Bad Request', 243 | 'invalid_request', 244 | 'Unsupported POST content type' 245 | ); 246 | } 247 | } else { 248 | mpError( 249 | 'HTTP/1.0 400 Bad Request', 250 | 'invalid_request', 251 | 'Unsupported HTTP request method' 252 | ); 253 | } 254 | ?> -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "875fa1befaae8ac8d43aa38d81775c35", 8 | "packages": [ 9 | { 10 | "name": "pear/http2", 11 | "version": "v2.0.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/pear/HTTP2.git", 15 | "reference": "72e15b4faa86f6109c6fc3aa82c5515b6453b3b5" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/pear/HTTP2/zipball/72e15b4faa86f6109c6fc3aa82c5515b6453b3b5", 20 | "reference": "72e15b4faa86f6109c6fc3aa82c5515b6453b3b5", 21 | "shasum": "" 22 | }, 23 | "require-dev": { 24 | "phpunit/phpunit": "^9" 25 | }, 26 | "type": "library", 27 | "autoload": { 28 | "psr-0": { 29 | "HTTP2": "./" 30 | } 31 | }, 32 | "notification-url": "https://packagist.org/downloads/", 33 | "license": [ 34 | "BSD-2-Clause" 35 | ], 36 | "authors": [ 37 | { 38 | "name": "Michael Wallner", 39 | "email": "mike@php.net", 40 | "role": "Lead" 41 | }, 42 | { 43 | "name": "Philippe Jausions", 44 | "email": "jausions@php.net", 45 | "role": "Lead" 46 | } 47 | ], 48 | "description": "Miscellaneous HTTP utilities", 49 | "homepage": "http://pear.php.net/package/HTTP2", 50 | "support": { 51 | "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP2", 52 | "source": "https://github.com/pear/HTTP2" 53 | }, 54 | "time": "2023-03-22T20:22:11+00:00" 55 | }, 56 | { 57 | "name": "pear/http_request2", 58 | "version": "v2.6.0", 59 | "source": { 60 | "type": "git", 61 | "url": "https://github.com/pear/HTTP_Request2.git", 62 | "reference": "f010a16ccddd1ee7d2ee085e8006ee712c00f706" 63 | }, 64 | "dist": { 65 | "type": "zip", 66 | "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/f010a16ccddd1ee7d2ee085e8006ee712c00f706", 67 | "reference": "f010a16ccddd1ee7d2ee085e8006ee712c00f706", 68 | "shasum": "" 69 | }, 70 | "require": { 71 | "pear/net_url2": "^2.2.0", 72 | "pear/pear_exception": "^1.0.0", 73 | "php": ">=5.6.0" 74 | }, 75 | "require-dev": { 76 | "yoast/phpunit-polyfills": "^1.0.0" 77 | }, 78 | "suggest": { 79 | "ext-curl": "Allows using cURL as a request backend.", 80 | "ext-fileinfo": "Adds support for looking up mime-types using finfo.", 81 | "ext-openssl": "Allows handling SSL requests when not using cURL.", 82 | "ext-zlib": "Allows handling gzip compressed responses." 83 | }, 84 | "type": "library", 85 | "autoload": { 86 | "psr-0": { 87 | "HTTP_Request2": "" 88 | } 89 | }, 90 | "notification-url": "https://packagist.org/downloads/", 91 | "license": [ 92 | "BSD-3-Clause" 93 | ], 94 | "authors": [ 95 | { 96 | "name": "Alexey Borzov", 97 | "email": "avb@php.net" 98 | } 99 | ], 100 | "description": "Provides an easy way to perform HTTP requests.", 101 | "homepage": "https://pear.php.net/package/HTTP_Request2", 102 | "keywords": [ 103 | "PEAR", 104 | "curl", 105 | "http", 106 | "request" 107 | ], 108 | "support": { 109 | "docs": "https://pear.php.net/manual/en/package.http.http-request2.php", 110 | "issues": "https://github.com/pear/HTTP_Request2/issues", 111 | "source": "https://github.com/pear/HTTP_Request2" 112 | }, 113 | "time": "2023-11-01T19:51:41+00:00" 114 | }, 115 | { 116 | "name": "pear/net_url2", 117 | "version": "v2.2.2", 118 | "source": { 119 | "type": "git", 120 | "url": "https://github.com/pear/Net_URL2.git", 121 | "reference": "07fd055820dbf466ee3990abe96d0e40a8791f9d" 122 | }, 123 | "dist": { 124 | "type": "zip", 125 | "url": "https://api.github.com/repos/pear/Net_URL2/zipball/07fd055820dbf466ee3990abe96d0e40a8791f9d", 126 | "reference": "07fd055820dbf466ee3990abe96d0e40a8791f9d", 127 | "shasum": "" 128 | }, 129 | "require": { 130 | "php": ">=5.1.4" 131 | }, 132 | "require-dev": { 133 | "phpunit/phpunit": ">=3.3.0" 134 | }, 135 | "type": "library", 136 | "extra": { 137 | "branch-alias": { 138 | "dev-master": "2.2.x-dev" 139 | } 140 | }, 141 | "autoload": { 142 | "classmap": [ 143 | "Net/URL2.php" 144 | ] 145 | }, 146 | "notification-url": "https://packagist.org/downloads/", 147 | "include-path": [ 148 | "./" 149 | ], 150 | "license": [ 151 | "BSD-3-Clause" 152 | ], 153 | "authors": [ 154 | { 155 | "name": "David Coallier", 156 | "email": "davidc@php.net" 157 | }, 158 | { 159 | "name": "Tom Klingenberg", 160 | "email": "tkli@php.net" 161 | }, 162 | { 163 | "name": "Christian Schmidt", 164 | "email": "chmidt@php.net" 165 | } 166 | ], 167 | "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.", 168 | "homepage": "https://github.com/pear/Net_URL2", 169 | "keywords": [ 170 | "PEAR", 171 | "net", 172 | "networking", 173 | "rfc3986", 174 | "uri", 175 | "url" 176 | ], 177 | "support": { 178 | "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", 179 | "source": "https://github.com/pear/Net_URL2" 180 | }, 181 | "time": "2017-08-25T06:16:11+00:00" 182 | }, 183 | { 184 | "name": "pear/pear_exception", 185 | "version": "v1.0.2", 186 | "source": { 187 | "type": "git", 188 | "url": "https://github.com/pear/PEAR_Exception.git", 189 | "reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0" 190 | }, 191 | "dist": { 192 | "type": "zip", 193 | "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/b14fbe2ddb0b9f94f5b24cf08783d599f776fff0", 194 | "reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0", 195 | "shasum": "" 196 | }, 197 | "require": { 198 | "php": ">=5.2.0" 199 | }, 200 | "require-dev": { 201 | "phpunit/phpunit": "<9" 202 | }, 203 | "type": "class", 204 | "extra": { 205 | "branch-alias": { 206 | "dev-master": "1.0.x-dev" 207 | } 208 | }, 209 | "autoload": { 210 | "classmap": [ 211 | "PEAR/" 212 | ] 213 | }, 214 | "notification-url": "https://packagist.org/downloads/", 215 | "include-path": [ 216 | "." 217 | ], 218 | "license": [ 219 | "BSD-2-Clause" 220 | ], 221 | "authors": [ 222 | { 223 | "name": "Helgi Thormar", 224 | "email": "dufuz@php.net" 225 | }, 226 | { 227 | "name": "Greg Beaver", 228 | "email": "cellog@php.net" 229 | } 230 | ], 231 | "description": "The PEAR Exception base class.", 232 | "homepage": "https://github.com/pear/PEAR_Exception", 233 | "keywords": [ 234 | "exception" 235 | ], 236 | "support": { 237 | "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception", 238 | "source": "https://github.com/pear/PEAR_Exception" 239 | }, 240 | "time": "2021-03-21T15:43:46+00:00" 241 | }, 242 | { 243 | "name": "pear/services_libravatar", 244 | "version": "v0.2.4", 245 | "source": { 246 | "type": "git", 247 | "url": "https://github.com/pear/Services_Libravatar.git", 248 | "reference": "8b9fda8c896afb18fdedc60ead29ee305ea222e9" 249 | }, 250 | "dist": { 251 | "type": "zip", 252 | "url": "https://api.github.com/repos/pear/Services_Libravatar/zipball/8b9fda8c896afb18fdedc60ead29ee305ea222e9", 253 | "reference": "8b9fda8c896afb18fdedc60ead29ee305ea222e9", 254 | "shasum": "" 255 | }, 256 | "require-dev": { 257 | "phpunit/phpunit": "^5.7.0" 258 | }, 259 | "type": "library", 260 | "autoload": { 261 | "psr-0": { 262 | "Services": "./Services/" 263 | } 264 | }, 265 | "notification-url": "https://packagist.org/downloads/", 266 | "include-path": [ 267 | "./" 268 | ], 269 | "license": [ 270 | "MIT" 271 | ], 272 | "authors": [ 273 | { 274 | "name": "Christian Weiske", 275 | "email": "cweiske@php.net", 276 | "role": "Developer" 277 | }, 278 | { 279 | "name": "Melissa Draper", 280 | "email": "melissa@meldraweb.com", 281 | "role": "Lead" 282 | } 283 | ], 284 | "description": "API interfacing class for libravatar.org", 285 | "homepage": "http://pear.php.net/package/Services_Libravatar", 286 | "support": { 287 | "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Services_Libravatar", 288 | "source": "https://github.com/pear/Services_Libravatar" 289 | }, 290 | "time": "2017-08-23T20:23:02+00:00" 291 | }, 292 | { 293 | "name": "pear2/services_linkback", 294 | "version": "v0.4.0", 295 | "source": { 296 | "type": "git", 297 | "url": "https://github.com/pear2/Services_Linkback.git", 298 | "reference": "61790889871cae0bc6e54adb2637b9e0ec93275f" 299 | }, 300 | "dist": { 301 | "type": "zip", 302 | "url": "https://api.github.com/repos/pear2/Services_Linkback/zipball/61790889871cae0bc6e54adb2637b9e0ec93275f", 303 | "reference": "61790889871cae0bc6e54adb2637b9e0ec93275f", 304 | "shasum": "" 305 | }, 306 | "require": { 307 | "ext-xmlrpc": "*", 308 | "pear/http2": "^2.0", 309 | "pear/http_request2": "^2.5", 310 | "pear/net_url2": "^2.2" 311 | }, 312 | "require-dev": { 313 | "pear/stream_var": "^2.0", 314 | "phpunit/phpunit": "^9", 315 | "squizlabs/php_codesniffer": "~2.6" 316 | }, 317 | "type": "library", 318 | "autoload": { 319 | "psr-0": { 320 | "PEAR2\\Services\\Linkback\\": "src" 321 | } 322 | }, 323 | "notification-url": "https://packagist.org/downloads/", 324 | "license": [ 325 | "LGPL-3.0+" 326 | ], 327 | "authors": [ 328 | { 329 | "name": "Christian Weiske", 330 | "email": "cweiske@php.net", 331 | "homepage": "http://cweiske.de/" 332 | } 333 | ], 334 | "description": "Pingback+webmention client and server implementation ", 335 | "homepage": "http://pear2.php.net/PEAR2_Services_Linkback", 336 | "support": { 337 | "email": "pear-general@lists.php.net", 338 | "issues": "https://github.com/pear2/Services_Linkback/issues/", 339 | "source": "https://github.com/pear2/Services_Linkback/tree/v0.4.0" 340 | }, 341 | "time": "2023-03-22T21:18:04+00:00" 342 | }, 343 | { 344 | "name": "symfony/polyfill-ctype", 345 | "version": "v1.28.0", 346 | "source": { 347 | "type": "git", 348 | "url": "https://github.com/symfony/polyfill-ctype.git", 349 | "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" 350 | }, 351 | "dist": { 352 | "type": "zip", 353 | "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", 354 | "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", 355 | "shasum": "" 356 | }, 357 | "require": { 358 | "php": ">=7.1" 359 | }, 360 | "provide": { 361 | "ext-ctype": "*" 362 | }, 363 | "suggest": { 364 | "ext-ctype": "For best performance" 365 | }, 366 | "type": "library", 367 | "extra": { 368 | "branch-alias": { 369 | "dev-main": "1.28-dev" 370 | }, 371 | "thanks": { 372 | "name": "symfony/polyfill", 373 | "url": "https://github.com/symfony/polyfill" 374 | } 375 | }, 376 | "autoload": { 377 | "files": [ 378 | "bootstrap.php" 379 | ], 380 | "psr-4": { 381 | "Symfony\\Polyfill\\Ctype\\": "" 382 | } 383 | }, 384 | "notification-url": "https://packagist.org/downloads/", 385 | "license": [ 386 | "MIT" 387 | ], 388 | "authors": [ 389 | { 390 | "name": "Gert de Pagter", 391 | "email": "BackEndTea@gmail.com" 392 | }, 393 | { 394 | "name": "Symfony Community", 395 | "homepage": "https://symfony.com/contributors" 396 | } 397 | ], 398 | "description": "Symfony polyfill for ctype functions", 399 | "homepage": "https://symfony.com", 400 | "keywords": [ 401 | "compatibility", 402 | "ctype", 403 | "polyfill", 404 | "portable" 405 | ], 406 | "support": { 407 | "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" 408 | }, 409 | "funding": [ 410 | { 411 | "url": "https://symfony.com/sponsor", 412 | "type": "custom" 413 | }, 414 | { 415 | "url": "https://github.com/fabpot", 416 | "type": "github" 417 | }, 418 | { 419 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 420 | "type": "tidelift" 421 | } 422 | ], 423 | "time": "2023-01-26T09:26:14+00:00" 424 | }, 425 | { 426 | "name": "symfony/polyfill-mbstring", 427 | "version": "v1.28.0", 428 | "source": { 429 | "type": "git", 430 | "url": "https://github.com/symfony/polyfill-mbstring.git", 431 | "reference": "42292d99c55abe617799667f454222c54c60e229" 432 | }, 433 | "dist": { 434 | "type": "zip", 435 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", 436 | "reference": "42292d99c55abe617799667f454222c54c60e229", 437 | "shasum": "" 438 | }, 439 | "require": { 440 | "php": ">=7.1" 441 | }, 442 | "provide": { 443 | "ext-mbstring": "*" 444 | }, 445 | "suggest": { 446 | "ext-mbstring": "For best performance" 447 | }, 448 | "type": "library", 449 | "extra": { 450 | "branch-alias": { 451 | "dev-main": "1.28-dev" 452 | }, 453 | "thanks": { 454 | "name": "symfony/polyfill", 455 | "url": "https://github.com/symfony/polyfill" 456 | } 457 | }, 458 | "autoload": { 459 | "files": [ 460 | "bootstrap.php" 461 | ], 462 | "psr-4": { 463 | "Symfony\\Polyfill\\Mbstring\\": "" 464 | } 465 | }, 466 | "notification-url": "https://packagist.org/downloads/", 467 | "license": [ 468 | "MIT" 469 | ], 470 | "authors": [ 471 | { 472 | "name": "Nicolas Grekas", 473 | "email": "p@tchwork.com" 474 | }, 475 | { 476 | "name": "Symfony Community", 477 | "homepage": "https://symfony.com/contributors" 478 | } 479 | ], 480 | "description": "Symfony polyfill for the Mbstring extension", 481 | "homepage": "https://symfony.com", 482 | "keywords": [ 483 | "compatibility", 484 | "mbstring", 485 | "polyfill", 486 | "portable", 487 | "shim" 488 | ], 489 | "support": { 490 | "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" 491 | }, 492 | "funding": [ 493 | { 494 | "url": "https://symfony.com/sponsor", 495 | "type": "custom" 496 | }, 497 | { 498 | "url": "https://github.com/fabpot", 499 | "type": "github" 500 | }, 501 | { 502 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 503 | "type": "tidelift" 504 | } 505 | ], 506 | "time": "2023-07-28T09:04:16+00:00" 507 | }, 508 | { 509 | "name": "symfony/polyfill-php80", 510 | "version": "v1.28.0", 511 | "source": { 512 | "type": "git", 513 | "url": "https://github.com/symfony/polyfill-php80.git", 514 | "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" 515 | }, 516 | "dist": { 517 | "type": "zip", 518 | "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", 519 | "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", 520 | "shasum": "" 521 | }, 522 | "require": { 523 | "php": ">=7.1" 524 | }, 525 | "type": "library", 526 | "extra": { 527 | "branch-alias": { 528 | "dev-main": "1.28-dev" 529 | }, 530 | "thanks": { 531 | "name": "symfony/polyfill", 532 | "url": "https://github.com/symfony/polyfill" 533 | } 534 | }, 535 | "autoload": { 536 | "files": [ 537 | "bootstrap.php" 538 | ], 539 | "psr-4": { 540 | "Symfony\\Polyfill\\Php80\\": "" 541 | }, 542 | "classmap": [ 543 | "Resources/stubs" 544 | ] 545 | }, 546 | "notification-url": "https://packagist.org/downloads/", 547 | "license": [ 548 | "MIT" 549 | ], 550 | "authors": [ 551 | { 552 | "name": "Ion Bazan", 553 | "email": "ion.bazan@gmail.com" 554 | }, 555 | { 556 | "name": "Nicolas Grekas", 557 | "email": "p@tchwork.com" 558 | }, 559 | { 560 | "name": "Symfony Community", 561 | "homepage": "https://symfony.com/contributors" 562 | } 563 | ], 564 | "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", 565 | "homepage": "https://symfony.com", 566 | "keywords": [ 567 | "compatibility", 568 | "polyfill", 569 | "portable", 570 | "shim" 571 | ], 572 | "support": { 573 | "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" 574 | }, 575 | "funding": [ 576 | { 577 | "url": "https://symfony.com/sponsor", 578 | "type": "custom" 579 | }, 580 | { 581 | "url": "https://github.com/fabpot", 582 | "type": "github" 583 | }, 584 | { 585 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 586 | "type": "tidelift" 587 | } 588 | ], 589 | "time": "2023-01-26T09:26:14+00:00" 590 | }, 591 | { 592 | "name": "twig/twig", 593 | "version": "v3.8.0", 594 | "source": { 595 | "type": "git", 596 | "url": "https://github.com/twigphp/Twig.git", 597 | "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" 598 | }, 599 | "dist": { 600 | "type": "zip", 601 | "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", 602 | "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", 603 | "shasum": "" 604 | }, 605 | "require": { 606 | "php": ">=7.2.5", 607 | "symfony/polyfill-ctype": "^1.8", 608 | "symfony/polyfill-mbstring": "^1.3", 609 | "symfony/polyfill-php80": "^1.22" 610 | }, 611 | "require-dev": { 612 | "psr/container": "^1.0|^2.0", 613 | "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" 614 | }, 615 | "type": "library", 616 | "autoload": { 617 | "psr-4": { 618 | "Twig\\": "src/" 619 | } 620 | }, 621 | "notification-url": "https://packagist.org/downloads/", 622 | "license": [ 623 | "BSD-3-Clause" 624 | ], 625 | "authors": [ 626 | { 627 | "name": "Fabien Potencier", 628 | "email": "fabien@symfony.com", 629 | "homepage": "http://fabien.potencier.org", 630 | "role": "Lead Developer" 631 | }, 632 | { 633 | "name": "Twig Team", 634 | "role": "Contributors" 635 | }, 636 | { 637 | "name": "Armin Ronacher", 638 | "email": "armin.ronacher@active-4.com", 639 | "role": "Project Founder" 640 | } 641 | ], 642 | "description": "Twig, the flexible, fast, and secure template language for PHP", 643 | "homepage": "https://twig.symfony.com", 644 | "keywords": [ 645 | "templating" 646 | ], 647 | "support": { 648 | "issues": "https://github.com/twigphp/Twig/issues", 649 | "source": "https://github.com/twigphp/Twig/tree/v3.8.0" 650 | }, 651 | "funding": [ 652 | { 653 | "url": "https://github.com/fabpot", 654 | "type": "github" 655 | }, 656 | { 657 | "url": "https://tidelift.com/funding/github/packagist/twig/twig", 658 | "type": "tidelift" 659 | } 660 | ], 661 | "time": "2023-11-21T18:54:41+00:00" 662 | } 663 | ], 664 | "packages-dev": [], 665 | "aliases": [], 666 | "minimum-stability": "stable", 667 | "stability-flags": [], 668 | "prefer-stable": false, 669 | "prefer-lowest": false, 670 | "platform": [], 671 | "platform-dev": [], 672 | "plugin-api-version": "2.3.0" 673 | } 674 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc.