├── .gitignore ├── LICENSE ├── README.rst ├── composer.json ├── composer.lock ├── data ├── config.php.dist ├── schema.sql └── templates │ ├── auth-choose.htm │ ├── auth-index.htm │ ├── index.htm │ ├── latest-atom.htm │ ├── latest.htm │ ├── post-like.htm │ ├── post-reply.htm │ └── user.htm ├── scripts └── dump-schema.sh ├── src └── anoweco │ ├── Linkback.php │ ├── Storage.php │ ├── Urls.php │ └── autoload.php └── www ├── .htaccess ├── auth.php ├── comment.php ├── css ├── auth-choose.css ├── index.css ├── latest.css └── user.css ├── favicon.ico ├── img ├── anonymous.svg └── logo.png ├── index.php ├── latest-atom.php ├── latest.php ├── micropub.php ├── robots.txt ├── token.php ├── user.php └── www-header.php /.gitignore: -------------------------------------------------------------------------------- 1 | /data/config.php 2 | /README.html 3 | /vendor/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ******************************** 2 | anoweco - anonymous web comments 3 | ******************************** 4 | Anonymous web comments for the indieweb. 5 | 6 | Provides everything needed to comment on sites that implement webmentions 7 | and microformats as specified by https://indieweb.org/: 8 | 9 | - IndieAuth endpoint that allows anyone to log in anonymously 10 | - Micropub endpoint for storing comments and likes to other posts 11 | - Each new comment/like is announced via linkback to the original URL 12 | (webmention or pingback) 13 | 14 | Public instance available on https://commentpara.de/ 15 | 16 | 17 | ============ 18 | Dependencies 19 | ============ 20 | * PHP 5.4+ 21 | * PEAR's Net_URL 22 | * PEAR's Services_Libravatar 23 | * PEAR2's Services_Linkback 24 | * Twig 25 | 26 | 27 | ============= 28 | About anoweco 29 | ============= 30 | 31 | Source code 32 | =========== 33 | anoweco's source code is available from http://git.cweiske.de/anoweco.git 34 | or the `mirror on github`__. 35 | 36 | __ https://github.com/cweiske/anoweco 37 | 38 | 39 | License 40 | ======= 41 | anoweco is licensed under the `AGPL v3 or later`__. 42 | 43 | __ http://www.gnu.org/licenses/agpl.html 44 | 45 | 46 | Author 47 | ====== 48 | anoweco was written by `Christian Weiske`__. 49 | 50 | __ http://cweiske.de/ 51 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /data/config.php.dist: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /data/schema.sql: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CREATE TABLE `comments` ( 5 | `comment_id` int(11) NOT NULL AUTO_INCREMENT, 6 | `comment_user_id` int(11) NOT NULL, 7 | `comment_published` datetime NOT NULL, 8 | `comment_of_url` varchar(2048) NOT NULL, 9 | `comment_type` varchar(32) NOT NULL, 10 | `comment_json` mediumtext NOT NULL, 11 | `comment_pingstate` varchar(6) NOT NULL, 12 | PRIMARY KEY (`comment_id`) 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 14 | 15 | 16 | CREATE TABLE `users` ( 17 | `user_id` int(11) NOT NULL AUTO_INCREMENT, 18 | `user_name` varchar(128) NOT NULL, 19 | `user_imageurl` varchar(1024) NOT NULL, 20 | PRIMARY KEY (`user_id`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 22 | 23 | 24 | -------------------------------------------------------------------------------- /data/templates/auth-choose.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Select your identity 5 | 6 | 7 | 8 |

Select your identity

9 |

10 | You may log in to {{client_id}} with any identity you like. 11 |

12 | 13 |
14 | {% for key, value in auth %} 15 | 16 | {% endfor %} 17 | 18 | 23 | 24 | 29 |
30 |
31 | 32 | 33 |
34 |
35 | 36 | 38 |
39 |
40 | .. or use this email's avatar image: 41 |
42 |
43 | 44 | 45 |
46 |
47 | 48 |

49 | The e-mail address will not be stored. 50 |

51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /data/templates/auth-index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IndieAuth endpoint 5 | 6 | 7 |

IndieAuth endpoint

8 |

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 | -------------------------------------------------------------------------------- /data/templates/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

{{title}}

14 |

15 | Anonymous web comments for the indieweb. 16 |

17 | 18 | 19 |

Write a comment

20 |

21 | Write a reply to a blog post: 22 |

23 |
24 | 25 | 26 | 31 | 32 |
33 | 34 | 35 |

IndieAuth endpoint

36 |

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 |

Misc

48 |

49 | anoweco is open source. 50 | You may view the 51 | latest posts. 52 |

53 | 54 | 55 | -------------------------------------------------------------------------------- /data/templates/latest-atom.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | Latest comments 4 | 5 | 6 | {{lastComment.comment_published|date("c")}} 7 | {{baseUrl}}/latest-atom.php 8 | anoweco 9 | 10 | {% for comment in comments %} 11 | 12 | {{comment.comment_type}} #{{comment.comment_id}} to {{comment.domain}} 13 | 14 | {{baseUrl}}{{comment.url}} 15 | {{comment.comment_published|date("c")}} 16 | 17 | {{comment.user.user_name}} 18 | 19 | 20 | {{comment.comment_type}} to 21 | {{comment.comment_of_url}} 22 | 23 | 24 | {% endfor %} 25 | 26 | -------------------------------------------------------------------------------- /data/templates/latest.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Latest comments 6 | 7 | 8 | 9 | 10 | 11 |

Latest comments

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {% for comment in comments %} 23 | 24 | 25 | 26 | 27 | 28 | 29 | {% endfor %} 30 | 31 |
DateTypeUserFor domain
{{comment.comment_published}}{{comment.comment_type}}{{comment.user.user_name}}{{comment.domain}}
32 | 33 | 34 | -------------------------------------------------------------------------------- /data/templates/post-like.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Like of {{attribute(json, 'like-of').0}} 6 | 7 | 8 | 9 |

Like #{{crow.comment_id}}

10 |

11 | {% apply spaceless %} 12 | 13 | 14 | {{author.name}} 15 | {% endapply %} 16 | likes 17 | {{attribute(json, 'like-of').0}}. 19 |

20 | 21 | 22 | -------------------------------------------------------------------------------- /data/templates/post-reply.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Comment to {{attribute(json, 'in-reply-to').0}} 6 | 7 | 8 | 9 |

Comment #{{crow.comment_id}}

10 |

11 | {% apply spaceless %} 12 | 13 | 14 | {{author.name}} 15 | {% endapply %} 16 | wrote 17 | the following reply to 18 | {{attribute(json, 'in-reply-to').0}}: 20 |

21 |
{{htmlContent|raw}}
22 |

23 | Reply to this comment 24 |

25 | 26 | 27 | -------------------------------------------------------------------------------- /data/templates/user.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Profile of {{name}} 5 | 6 | 7 | 8 | 9 | 10 | 11 |

{{name}}

12 |
13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/anoweco/autoload.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | if (file_exists(__DIR__ . '/../../lib/PEAR.php')) { 8 | //phing-installed dependencies available ("phing collectdeps") 9 | set_include_path( 10 | __DIR__ . '/../' 11 | . PATH_SEPARATOR . __DIR__ . '/../../lib/' 12 | . PATH_SEPARATOR . '.' 13 | ); 14 | } else if (file_exists(__DIR__ . '/../../lib/autoload.php')) { 15 | //composer-installed dependencies available 16 | set_include_path( 17 | __DIR__ . '/../' 18 | . PATH_SEPARATOR . '.' 19 | ); 20 | require_once __DIR__ . '/../../lib/autoload.php'; 21 | } else { 22 | //use default include path for dependencies 23 | set_include_path( 24 | __DIR__ . '/../' 25 | . PATH_SEPARATOR . get_include_path() 26 | ); 27 | } 28 | 29 | require_once __DIR__ . '/../../vendor/autoload.php'; 30 | spl_autoload_register( 31 | function ($class) { 32 | $file = str_replace(array('\\', '_'), '/', $class) . '.php'; 33 | if (stream_resolve_include_path($file)) { 34 | require $file; 35 | } 36 | } 37 | ); 38 | ?> 39 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/css/auth-choose.css: -------------------------------------------------------------------------------- 1 | body { 2 | max-width: 60ex; 3 | margin-left: auto; 4 | margin-right: auto; 5 | background-color: #EEE; 6 | } 7 | 8 | label.mode { 9 | display: block; 10 | padding: 2ex; 11 | background-color: #DDD; 12 | border-top: 1px solid #EEE; 13 | } 14 | div.data-mode { 15 | margin-left: 5ex; 16 | background-color: #DDD; 17 | } 18 | div.data-mode label { 19 | display: inline-block; 20 | width: 20ex; 21 | } 22 | div.data-mode div { 23 | padding: 2ex 2ex; 24 | border-top: 1px solid #EEE; 25 | } 26 | div.data-mode input { 27 | width: 34ex; 28 | } 29 | button { 30 | margin: 2ex; 31 | width: 20ex; 32 | height: 5ex; 33 | display: block; 34 | margin-left: auto; 35 | margin-right: auto; 36 | } 37 | p.note { 38 | text-align: center; 39 | color: #444; 40 | } -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /www/css/user.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | body { 5 | display: flex; 6 | height: 100%; 7 | margin: 0px; 8 | background-color: #EEF; 9 | } 10 | h1 { 11 | flex: 1 1 50%; 12 | align-self: stretch; 13 | text-align: right; 14 | margin-top: auto; 15 | margin-bottom: auto; 16 | order: 1; 17 | } 18 | #img { 19 | flex: 1 1 50%; 20 | align-self: stretch; 21 | text-align: center; 22 | margin: auto; 23 | order: 2; 24 | } 25 | img { 26 | width: 100%; 27 | height: auto; 28 | max-width: 50%; 29 | max-height: 50%; 30 | } 31 | 32 | @media all and (max-width: 640px) { 33 | body { 34 | flex-flow: column; 35 | } 36 | h1 { 37 | text-align: center; 38 | } 39 | #img { 40 | order: 0; 41 | } 42 | img { 43 | height: 50%; 44 | width: auto; 45 | margin-top: 13%; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /www/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cweiske/anoweco/77cb769b94d16b424ec7a0b1a8186000dd397b30/www/favicon.ico -------------------------------------------------------------------------------- /www/img/anonymous.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | Abstract user icon 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /www/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cweiske/anoweco/77cb769b94d16b424ec7a0b1a8186000dd397b30/www/img/logo.png -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | $title, 10 | 'baseurl' => Urls::full('/'), 11 | ) 12 | ); 13 | ?> -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | ?> -------------------------------------------------------------------------------- /www/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: /auth.php 3 | Disallow: /micropub.php 4 | Disallow: /token.php 5 | -------------------------------------------------------------------------------- /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/user.php: -------------------------------------------------------------------------------- 1 | getUser($id); 22 | if ($rowUser === null) { 23 | header('HTTP/1.0 404 Not Found'); 24 | header('Content-Type: text/plain'); 25 | echo "User not found\n"; 26 | exit(1); 27 | } 28 | 29 | render( 30 | 'user', 31 | array( 32 | 'baseurl' => Urls::full('/'), 33 | 'name' => $rowUser->user_name, 34 | 'url' => Urls::full(Urls::user($rowUser->user_id)), 35 | 'imageurl' => Urls::userImg($rowUser), 36 | ) 37 | ); 38 | ?> 39 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------