Browse Source

init repository

Émile Morel 10 years ago
commit
6e5d982e87
46 changed files with 15006 additions and 0 deletions
  1. 661 0
      LICENSE
  2. 11 0
      README.md
  3. 190 0
      conf/init_ynh-torclient
  4. 40 0
      conf/nginx_torclient.conf
  5. 200 0
      conf/phpfpm_torclient.conf
  6. 199 0
      conf/torrc
  7. 35 0
      manifest.json
  8. 92 0
      scripts/install
  9. 50 0
      scripts/remove
  10. 56 0
      sources/config.php
  11. 100 0
      sources/controller.php
  12. 3 0
      sources/i18n/README
  13. 11 0
      sources/index.php
  14. 2707 0
      sources/lib/limonade.php
  15. 193 0
      sources/lib/limonade/abstract.php
  16. 173 0
      sources/lib/limonade/assertions.php
  17. 220 0
      sources/lib/limonade/public/css/screen.css
  18. BIN
      sources/lib/limonade/public/img/bg_header.png
  19. 350 0
      sources/lib/limonade/tests.php
  20. 37 0
      sources/lib/limonade/views/_debug.html.php
  21. 15 0
      sources/lib/limonade/views/_notices.html.php
  22. 22 0
      sources/lib/limonade/views/default_layout.php
  23. 6 0
      sources/lib/limonade/views/error.html.php
  24. 49 0
      sources/lib/unix_func.php
  25. 457 0
      sources/public/bootstrap/css/bootstrap-theme.css
  26. 1 0
      sources/public/bootstrap/css/bootstrap-theme.css.map
  27. 5 0
      sources/public/bootstrap/css/bootstrap-theme.min.css
  28. 6358 0
      sources/public/bootstrap/css/bootstrap.css
  29. 1 0
      sources/public/bootstrap/css/bootstrap.css.map
  30. 5 0
      sources/public/bootstrap/css/bootstrap.min.css
  31. BIN
      sources/public/bootstrap/fonts/glyphicons-halflings-regular.eot
  32. 229 0
      sources/public/bootstrap/fonts/glyphicons-halflings-regular.svg
  33. BIN
      sources/public/bootstrap/fonts/glyphicons-halflings-regular.ttf
  34. BIN
      sources/public/bootstrap/fonts/glyphicons-halflings-regular.woff
  35. 2276 0
      sources/public/bootstrap/js/bootstrap.js
  36. 7 0
      sources/public/bootstrap/js/bootstrap.min.js
  37. 13 0
      sources/public/bootstrap/js/npm.js
  38. 28 0
      sources/public/css/bootstrap-toggle.min.css
  39. 45 0
      sources/public/css/style.css
  40. BIN
      sources/public/img/github.png
  41. BIN
      sources/public/img/loading.gif
  42. 4 0
      sources/public/jquery/jquery-2.1.1.min.js
  43. 9 0
      sources/public/js/bootstrap-toggle.min.js
  44. 57 0
      sources/public/js/custom.js
  45. 45 0
      sources/views/layout.html.php
  46. 46 0
      sources/views/settings.html.php

+ 661 - 0
LICENSE

@@ -0,0 +1,661 @@
+GNU AFFERO GENERAL PUBLIC LICENSE
+                       Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+  A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate.  Many developers of free software are heartened and
+encouraged by the resulting cooperation.  However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+  The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community.  It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server.  Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+  An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals.  This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU Affero General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Remote Network Interaction; Use with the GNU General Public License.
+
+  Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software.  This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time.  Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source.  For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code.  There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.

+ 11 - 0
README.md

@@ -0,0 +1,11 @@
+# TOR Client
+
+**Warning: work in progress**
+
+TOR Client app for [YunoHost](http://yunohost.org/).
+
+* Install a TOR connection on your self-hosted server.
+* Useful for hosting your server behind a filtered (and/or non-neutral) internet access.
+* You should install [Hotspot app for YunoHost](https://github.com/jvaubourg/hotspot_ynh) before in order to broadcast your TOR access by Wifi.
+
+Thanks to [ju](https://github.com/jvaubourg/) for quick startup.

+ 190 - 0
conf/init_ynh-torclient

@@ -0,0 +1,190 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: ynh-torclient
+# Required-Start:    $network $remote_fs $syslog $all
+# Required-Stop:     $network $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Set prerequisites for wifi torclient.
+# Description:       Set prerequisites for wifi torclient.
+### END INIT INFO
+
+# Functions
+## State functions
+
+has_vpnclient_app() {
+  [ -e /tmp/.ynh-vpnclient-started ]
+}
+
+has_torclient_app() {
+  [ -e /tmp/.ynh-torclient-started ]
+}
+has_hotspot_app() {
+  [ -e /tmp/.ynh-hotspot-started ]
+}
+
+is_nat_set() {
+  iptables -nvt nat -L PREROUTING | grep REDIRECT | grep -q "${ynh_wifi_device}"
+}
+
+is_tor_running() {
+  service tor status &> /dev/null
+}
+
+is_running() {
+  has_hotspot_app && is_tor_running && is_nat_set
+}
+
+set_nat() {
+
+  iptables -t nat -F
+  iptables -t nat -X
+  iptables -t nat -A PREROUTING -i ${ynh_wifi_device} -p udp --dport 53 -j REDIRECT --to-ports 9053
+  iptables -t nat -A PREROUTING -i ${ynh_wifi_device} -p tcp --syn -j REDIRECT --to-ports 9040
+}
+
+set_forwarding() {
+  sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
+  sysctl -w net.ipv4.conf.all.forwarding=1 > /dev/null
+}
+
+unset_nat() {
+  internet_device=${1}
+
+  iptables -t nat -D PREROUTING -i ${ynh_wifi_device} -p udp --dport 53 -j REDIRECT --to-ports 9053
+  iptables -t nat -D PREROUTING -i ${ynh_wifi_device} -p tcp --syn -j REDIRECT --to-ports 9040
+}
+
+stop_tor() {
+  service tor stop
+}
+
+start_tor() {
+  service tor start
+}
+
+## Tools
+
+moulinette_get() {
+  var=${1}
+
+  value=$(yunohost app setting hotspot "${var}")
+
+  if [[ "${value}" =~ "An instance is already running" ]]; then
+    echo "${value}" >&2
+    exit 1
+  fi
+
+  echo "${value}"
+} 
+
+moulinette_vpnclient_get() {
+  var=${1}
+
+  value=$(yunohost app setting vpnclient "${var}")
+
+  if [[ "${value}" =~ "An instance is already running" ]]; then
+    echo "${value}" >&2
+    exit 1
+  fi
+
+  echo "${value}"
+}
+
+moulinette_set() {
+  var=${1}
+  value=${2}
+
+  msg=$(yunohost app setting hotspot "${var}" -v "${value}")
+
+  if [ ! $? -eq 0 ]; then
+    echo "${msg}" >&2
+    exit 1
+  fi
+}
+
+# Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
+if [ ! -e /tmp/.ynh-hotspot-boot ]; then
+  touch /tmp/.ynh-hotspot-boot
+  service php5-fpm restart
+fi
+
+# Variables
+
+echo -n "Retrieving Yunohost settings... "
+
+ynh_wifi_device=$(moulinette_get wifi_device)
+
+echo "OK"
+
+# Script
+
+case "$1" in
+  start)
+    if is_running; then
+      echo "Already started"
+    else
+      echo "[torclient] Starting..."
+      touch /tmp/.ynh-tor-started
+
+      # Run tor
+      if ! is_tor_running; then
+        echo "Run Tor"
+        start_tor
+      fi
+
+      # Set ipv4 NAT
+      if ! is_nat_set; then
+        echo "Set NAT settings"
+        set_nat
+      fi
+    fi
+  ;;
+  stop)
+    if ! is_running; then
+      echo "Already stoped"
+    else
+      echo "[torclient] Stopping..."
+      rm /tmp/.ynh-tor-started
+    
+      if is_nat_set; then
+        echo "Unset NAT"
+        unset_nat
+      fi
+  
+      if is_tor_running; then
+        echo "Stop Tor"
+        stop_tor
+      fi
+    
+      if has_vpnclient_app; then
+        service ynh-vpnclient start
+      fi
+    fi
+  ;;
+  status)
+    exitcode=0
+
+    if is_tor_running; then
+      echo "[OK] Tor is running"
+    else
+      echo "[ERR] Tor is not running"
+      exitcode=1
+    fi
+
+    if is_nat_set; then
+      echo "[OK] IPv4 nat rules set"
+    else
+      echo "[ERR] No IPv4 nat rules not set"
+      exitcode=1
+    fi
+
+    exit ${exitcode}
+  ;;
+  *)
+    echo "Usage: $0 {start|stop|status}"
+    exit 1
+  ;;
+esac
+
+exit 0

+ 40 - 0
conf/nginx_torclient.conf

@@ -0,0 +1,40 @@
+# VPN Client app for YunoHost 
+# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
+# Contribute at https://github.com/jvaubourg/vpnclient_ynh
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+location <TPL:NGINX_LOCATION> {
+  alias <TPL:NGINX_REALPATH>;
+
+  if ($scheme = http) {
+    rewrite ^ https://$server_name$request_uri? permanent;
+  }
+
+  client_max_body_size 10G;
+  index index.php;
+  try_files $uri $uri/ index.php;
+
+  location ~ [^/]\.php(/|$) {
+    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
+    fastcgi_pass unix:/var/run/php5-fpm-<TPL:PHP_NAME>.sock;
+    fastcgi_index index.php;
+    include fastcgi_params;
+    fastcgi_read_timeout 600;
+    fastcgi_param REMOTE_USER $remote_user;
+    fastcgi_param PATH_INFO $fastcgi_path_info;
+  }
+
+  include conf.d/yunohost_panel.conf.inc;
+}

+ 200 - 0
conf/phpfpm_torclient.conf

@@ -0,0 +1,200 @@
+; VPN Client app for YunoHost 
+; Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
+; Contribute at https://github.com/jvaubourg/vpnclient_ynh
+; 
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU Affero General Public License as published by
+; the Free Software Foundation, either version 3 of the License, or
+; (at your option) any later version.
+; 
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU Affero General Public License for more details.
+; 
+; You should have received a copy of the GNU Affero General Public License
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+; Start a new pool named '<TPL:PHP_NAME>'.
+; the variable $pool can we used in any directive and will be replaced by the
+; pool name ('www' here)
+[<TPL:PHP_NAME>]
+
+; The address on which to accept FastCGI requests.
+; Valid syntaxes are:
+;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
+;                            a specific port;
+;   'port'                 - to listen on a TCP socket to all addresses on a
+;                            specific port;
+;   '/path/to/unix/socket' - to listen on a unix socket.
+; Note: This value is mandatory.
+listen = /var/run/php5-fpm-<TPL:PHP_NAME>.sock
+
+; Set permissions for unix socket, if one is used. In Linux, read/write
+; permissions must be set in order to allow connections from a web server. Many
+; BSD-derived systems allow connections regardless of permissions.
+; Default Values: user and group are set as the running user
+;                 mode is set to 0666
+listen.owner = www-data
+listen.group = www-data
+listen.mode = 0600
+
+; Unix user/group of processes
+; Note: The user is mandatory. If the group is not set, the default user's group
+;       will be used.
+user = <TPL:PHP_USER>
+group = <TPL:PHP_GROUP>
+
+; Choose how the process manager will control the number of child processes.
+; Possible Values:
+;   static  - a fixed number (pm.max_children) of child processes;
+;   dynamic - the number of child processes are set dynamically based on the
+;             following directives:
+;             pm.max_children      - the maximum number of children that can
+;                                    be alive at the same time.
+;             pm.start_servers     - the number of children created on startup.
+;             pm.min_spare_servers - the minimum number of children in 'idle'
+;                                    state (waiting to process). If the number
+;                                    of 'idle' processes is less than this
+;                                    number then some children will be created.
+;             pm.max_spare_servers - the maximum number of children in 'idle'
+;                                    state (waiting to process). If the number
+;                                    of 'idle' processes is greater than this
+;                                    number then some children will be killed.
+; Note: This value is mandatory.
+pm = dynamic
+
+; The number of child processes to be created when pm is set to 'static' and the
+; maximum number of child processes to be created when pm is set to 'dynamic'.
+; This value sets the limit on the number of simultaneous requests that will be
+; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
+; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
+; CGI.
+; Note: Used when pm is set to either 'static' or 'dynamic'
+; Note: This value is mandatory.
+pm.max_children = 6
+
+; The number of child processes created on startup.
+; Note: Used only when pm is set to 'dynamic'
+; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
+pm.start_servers = 3
+
+; The desired minimum number of idle server processes.
+; Note: Used only when pm is set to 'dynamic'
+; Note: Mandatory when pm is set to 'dynamic'
+pm.min_spare_servers = 3
+
+; The desired maximum number of idle server processes.
+; Note: Used only when pm is set to 'dynamic'
+; Note: Mandatory when pm is set to 'dynamic'
+pm.max_spare_servers = 5
+
+; The number of requests each child process should execute before respawning.
+; This can be useful to work around memory leaks in 3rd party libraries. For
+; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
+; Default Value: 0
+pm.max_requests = 500
+
+; The URI to view the FPM status page. If this value is not set, no URI will be
+; recognized as a status page. By default, the status page shows the following
+; information:
+;   accepted conn        - the number of request accepted by the pool;
+;   pool                 - the name of the pool;
+;   process manager      - static or dynamic;
+;   idle processes       - the number of idle processes;
+;   active processes     - the number of active processes;
+;   total processes      - the number of idle + active processes.
+;   max children reached - number of times, the process limit has been reached,
+;                          when pm tries to start more children (works only for
+;                          pm 'dynamic')
+; The values of 'idle processes', 'active processes' and 'total processes' are
+; updated each second. The value of 'accepted conn' is updated in real time.
+; Example output:
+;   accepted conn:        12073
+;   pool:                 www
+;   process manager:      static
+;   idle processes:       35
+;   active processes:     65
+;   total processes:      100
+;   max children reached: 1
+; By default the status page output is formatted as text/plain. Passing either
+; 'html' or 'json' as a query string will return the corresponding output
+; syntax. Example:
+;   http://www.foo.bar/status
+;   http://www.foo.bar/status?json
+;   http://www.foo.bar/status?html
+; Note: The value must start with a leading slash (/). The value can be
+;       anything, but it may not be a good idea to use the .php extension or it
+;       may conflict with a real PHP file.
+; Default Value: not set
+pm.status_path = /fpm-status
+
+; The ping URI to call the monitoring page of FPM. If this value is not set, no
+; URI will be recognized as a ping page. This could be used to test from outside
+; that FPM is alive and responding, or to
+; - create a graph of FPM availability (rrd or such);
+; - remove a server from a group if it is not responding (load balancing);
+; - trigger alerts for the operating team (24/7).
+; Note: The value must start with a leading slash (/). The value can be
+;       anything, but it may not be a good idea to use the .php extension or it
+;       may conflict with a real PHP file.
+; Default Value: not set
+ping.path = /ping
+
+; The timeout for serving a single request after which the worker process will
+; be killed. This option should be used when the 'max_execution_time' ini option
+; does not stop script execution for some reason. A value of '0' means 'off'.
+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
+; Default Value: 0
+request_terminate_timeout = 600s
+
+; The timeout for serving a single request after which a PHP backtrace will be
+; dumped to the 'slowlog' file. A value of '0s' means 'off'.
+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
+; Default Value: 0
+request_slowlog_timeout = 0
+
+; The log file for slow requests
+; Default Value: not set
+; Note: slowlog is mandatory if request_slowlog_timeout is set
+slowlog = /var/log/nginx/<TPL:PHP_NAME>.slow.log
+
+; Set open file descriptor rlimit.
+; Default Value: system defined value
+rlimit_files = 4096
+
+; Set max core size rlimit.
+; Possible Values: 'unlimited' or an integer greater or equal to 0
+; Default Value: system defined value
+rlimit_core = 0
+
+; Chdir to this directory at the start.
+; Note: relative path can be used.
+; Default Value: current directory or / when chroot
+chdir = <TPL:NGINX_REALPATH>
+
+; Redirect worker stdout and stderr into main error log. If not set, stdout and
+; stderr will be redirected to /dev/null according to FastCGI specs.
+; Note: on highloaded environement, this can cause some delay in the page
+; process time (several ms).
+; Default Value: no
+catch_workers_output = no
+
+; Additional php.ini defines, specific to this pool of workers. These settings
+; overwrite the values previously defined in the php.ini. The directives are the
+; same as the PHP SAPI:
+;   php_value/php_flag             - you can set classic ini defines which can
+;                                    be overwritten from PHP call 'ini_set'.
+;   php_admin_value/php_admin_flag - these directives won't be overwritten by
+;                                     PHP call 'ini_set'
+; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
+;
+; Defining 'extension' will load the corresponding shared extension from
+; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
+; overwrite previously defined php.ini values, but will append the new value
+; instead.
+;
+; Note: path INI options can be relative and will be expanded with the prefix
+; (pool, global or /usr)
+php_value[upload_max_filesize] = 10G
+php_value[post_max_size] = 10G

+ 199 - 0
conf/torrc

@@ -0,0 +1,199 @@
+## Configuration file for a typical Tor user
+## Last updated 9 October 2013 for Tor 0.2.5.2-alpha.
+## (may or may not work for much older or much newer versions of Tor.)
+##
+## Lines that begin with "## " try to explain what's going on. Lines
+## that begin with just "#" are disabled commands: you can enable them
+## by removing the "#" symbol.
+##
+## See 'man tor', or https://www.torproject.org/docs/tor-manual.html,
+## for more options you can use in this file.
+##
+## Tor will look for this file in various places based on your platform:
+## https://www.torproject.org/docs/faq#torrc
+
+## Tor opens a socks proxy on port 9050 by default -- even if you don't
+## configure one below. Set "SocksPort 0" if you plan to run Tor only
+## as a relay, and not make any local application connections yourself.
+#SocksPort 9050 # Default: Bind to localhost:9050 for local connections.
+#SocksPort 192.168.0.1:9100 # Bind to this address:port too.
+
+## Entry policies to allow/deny SOCKS requests based on IP address.
+## First entry that matches wins. If no SocksPolicy is set, we accept
+## all (and only) requests that reach a SocksPort. Untrusted users who
+## can access your SocksPort may be able to learn about the connections
+## you make.
+SocksPolicy accept 10.0.242.0/24
+SocksPolicy reject *
+
+## Logs go to stdout at level "notice" unless redirected by something
+## else, like one of the below lines. You can have as many Log lines as
+## you want.
+##
+## We advise using "notice" in most cases, since anything more verbose
+## may provide sensitive information to an attacker who obtains the logs.
+##
+## Send all messages of level 'notice' or higher to /var/log/tor/notices.log
+#Log notice file /var/log/tor/notices.log
+## Send every possible message to /var/log/tor/debug.log
+#Log debug file /var/log/tor/debug.log
+## Use the system log instead of Tor's logfiles
+#Log notice syslog
+## To send all messages to stderr:
+#Log debug stderr
+
+## Uncomment this to start the process in the background... or use
+## --runasdaemon 1 on the command line. This is ignored on Windows;
+## see the FAQ entry if you want Tor to run as an NT service.
+#RunAsDaemon 1
+
+## The directory for keeping all the keys/etc. By default, we store
+## things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
+#DataDirectory /var/lib/tor
+
+## The port on which Tor will listen for local connections from Tor
+## controller applications, as documented in control-spec.txt.
+#ControlPort 9051
+## If you enable the controlport, be sure to enable one of these
+## authentication methods, to prevent attackers from accessing it.
+#HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
+#CookieAuthentication 1
+
+############### This section is just for location-hidden services ###
+
+## Once you have configured a hidden service, you can look at the
+## contents of the file ".../hidden_service/hostname" for the address
+## to tell people.
+##
+## HiddenServicePort x y:z says to redirect requests on port x to the
+## address y:z.
+
+#HiddenServiceDir /var/lib/tor/hidden_service/
+#HiddenServicePort 80 127.0.0.1:80
+
+#HiddenServiceDir /var/lib/tor/other_hidden_service/
+#HiddenServicePort 80 127.0.0.1:80
+#HiddenServicePort 22 127.0.0.1:22
+
+################ This section is just for relays #####################
+#
+## See https://www.torproject.org/docs/tor-doc-relay for details.
+
+## Required: what port to advertise for incoming Tor connections.
+#ORPort 9001
+## If you want to listen on a port other than the one advertised in
+## ORPort (e.g. to advertise 443 but bind to 9090), you can do it as
+## follows.  You'll need to do ipchains or other port forwarding
+## yourself to make this work.
+#ORPort 443 NoListen
+#ORPort 127.0.0.1:9090 NoAdvertise
+
+## The IP address or full DNS name for incoming connections to your
+## relay. Leave commented out and Tor will guess.
+Address ns0.ldn-fai.net
+DNSPort 9053
+DNSListenAddress 10.0.242.1 
+AutomapHostsOnResolve 1
+AutomapHostsSuffixes .exit,.onion
+TransPort 9040                                                          
+TransListenAddress 10.0.242.1
+
+## If you have multiple network interfaces, you can specify one for
+## outgoing traffic to use.
+# OutboundBindAddress 10.0.0.5
+
+## A handle for your relay, so people don't have to refer to it by key.
+#Nickname ididnteditheconfig
+
+## Define these to limit how much relayed traffic you will allow. Your
+## own traffic is still unthrottled. Note that RelayBandwidthRate must
+## be at least 20 KB.
+## Note that units for these config options are bytes per second, not bits
+## per second, and that prefixes are binary prefixes, i.e. 2^10, 2^20, etc.
+#RelayBandwidthRate 100 KB  # Throttle traffic to 100KB/s (800Kbps)
+#RelayBandwidthBurst 200 KB # But allow bursts up to 200KB/s (1600Kbps)
+
+## Use these to restrict the maximum traffic per day, week, or month.
+## Note that this threshold applies separately to sent and received bytes,
+## not to their sum: setting "4 GB" may allow up to 8 GB total before
+## hibernating.
+##
+## Set a maximum of 4 gigabytes each way per period.
+#AccountingMax 4 GB
+## Each period starts daily at midnight (AccountingMax is per day)
+#AccountingStart day 00:00
+## Each period starts on the 3rd of the month at 15:00 (AccountingMax
+## is per month)
+#AccountingStart month 3 15:00
+
+## Administrative contact information for this relay or bridge. This line
+## can be used to contact you if your relay or bridge is misconfigured or
+## something else goes wrong. Note that we archive and publish all
+## descriptors containing these lines and that Google indexes them, so
+## spammers might also collect them. You may want to obscure the fact that
+## it's an email address and/or generate a new address for this purpose.
+#ContactInfo Random Person <nobody AT example dot com>
+## You might also include your PGP or GPG fingerprint if you have one:
+#ContactInfo 0xFFFFFFFF Random Person <nobody AT example dot com>
+
+## Uncomment this to mirror directory information for others. Please do
+## if you have enough bandwidth.
+#DirPort 9030 # what port to advertise for directory connections
+## If you want to listen on a port other than the one advertised in
+## DirPort (e.g. to advertise 80 but bind to 9091), you can do it as
+## follows.  below too. You'll need to do ipchains or other port
+## forwarding yourself to make this work.
+#DirPort 80 NoListen
+#DirPort 127.0.0.1:9091 NoAdvertise
+## Uncomment to return an arbitrary blob of html on your DirPort. Now you
+## can explain what Tor is if anybody wonders why your IP address is
+## contacting them. See contrib/tor-exit-notice.html in Tor's source
+## distribution for a sample.
+#DirPortFrontPage /etc/tor/tor-exit-notice.html
+
+## Uncomment this if you run more than one Tor relay, and add the identity
+## key fingerprint of each Tor relay you control, even if they're on
+## different networks. You declare it here so Tor clients can avoid
+## using more than one of your relays in a single circuit. See
+## https://www.torproject.org/docs/faq#MultipleRelays
+## However, you should never include a bridge's fingerprint here, as it would
+## break its concealability and potentionally reveal its IP/TCP address.
+#MyFamily $keyid,$keyid,...
+
+## A comma-separated list of exit policies. They're considered first
+## to last, and the first match wins. If you want to _replace_
+## the default exit policy, end this with either a reject *:* or an
+## accept *:*. Otherwise, you're _augmenting_ (prepending to) the
+## default exit policy. Leave commented to just use the default, which is
+## described in the man page or at
+## https://www.torproject.org/documentation.html
+##
+## Look at https://www.torproject.org/faq-abuse.html#TypicalAbuses
+## for issues you might encounter if you use the default exit policy.
+##
+## If certain IPs and ports are blocked externally, e.g. by your firewall,
+## you should update your exit policy to reflect this -- otherwise Tor
+## users will be told that those destinations are down.
+##
+## For security, by default Tor rejects connections to private (local)
+## networks, including to your public IP address. See the man page entry
+## for ExitPolicyRejectPrivate if you want to allow "exit enclaving".
+##
+#ExitPolicy accept *:6660-6667,reject *:* # allow irc ports but no more
+#ExitPolicy accept *:119 # accept nntp as well as default exit policy
+#ExitPolicy reject *:* # no exits allowed
+
+## Bridge relays (or "bridges") are Tor relays that aren't listed in the
+## main directory. Since there is no complete public list of them, even an
+## ISP that filters connections to all the known Tor relays probably
+## won't be able to block all the bridges. Also, websites won't treat you
+## differently because they won't know you're running Tor. If you can
+## be a real relay, please do; but if not, be a bridge!
+#BridgeRelay 1
+## By default, Tor will advertise your bridge to users through various
+## mechanisms like https://bridges.torproject.org/. If you want to run
+## a private bridge, for example because you'll give out your bridge
+## address manually to your friends, uncomment this line:
+#PublishServerDescriptor 0
+
+

+ 35 - 0
manifest.json

@@ -0,0 +1,35 @@
+{
+  "name": "TOR Client",
+  "id": "torclient",
+  "description": {
+    "en": "TOR Client",
+    "fr": "Client TOR"
+  },
+  "license": "AGPL-3",
+  "developer": {
+    "name": "Emile Morel",
+    "email": "emile@bleuchtang.fr"
+  },
+  "multi_instance": "false",
+  "arguments": {
+    "install" : [
+      {
+        "name": "domain",
+        "ask": {
+            "en": "Choose a domain for the web administration",
+            "fr": "Choisissez un domaine pour l'administration web"
+        },
+        "example": "domain.org"
+      },
+      {
+        "name": "path",
+        "ask": {
+            "en": "Choose a path for the web administration",
+            "fr": "Choissez un chemin pour l'administration web"
+        },
+        "example": "/torclient",
+        "default": "/torclient"
+      }
+    ]
+  }
+}

+ 92 - 0
scripts/install

@@ -0,0 +1,92 @@
+#!/bin/bash
+
+# VPN Client app for YunoHost 
+# Copyright (C) 2015 Emile Morel <emile@bleuchtang.fr>
+# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
+# Contribute at https://github.com/bleuchtang/torclient_ynh
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Retrieve arguments
+domain=${1}
+url_path=${2}
+
+# Check domain/path availability
+sudo yunohost app checkurl ${domain}${url_path} -a torclient
+if [ ! $? -eq 0 ]; then
+  exit 1
+fi
+
+if [ ! -e /tmp/.ynh-hotspot-started ]; then
+  echo "hotspot not started and/or not installed" 
+fi
+
+echo 'deb http://deb.torproject.org/torproject.org wheezy main' | sudo tee "/etc/apt/sources.list.d/torproject.list"
+
+gpg --keyserver keys.gnupg.net --recv 886DDD89
+gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
+
+# Install packages
+#packages='privoxy tor php5-fpm'
+packages='tor php5-fpm'
+sudo apt-get update
+DEBIAN_FRONTEND=noninteractive sudo apt-get --assume-yes --force-yes install ${packages}
+
+# Save arguments
+#sudo yunohost app setting torclient server_name -v "${server_name}"
+
+sudo install -o root -g root -m 0644 ../conf/torrc /etc/tor/torrc
+sudo install -b -o root -g root -m 0644 ../conf/nginx_torclient.conf "/etc/nginx/conf.d/${domain}.d/torclient.conf"
+sudo install -b -o root -g root -m 0644 ../conf/phpfpm_torclient.conf /etc/php5/fpm/pool.d/torclient.conf
+
+# Copy web sources
+sudo mkdir -pm 0755 /var/www/torclient/
+sudo cp -a ../sources/* /var/www/torclient/
+
+sudo chown -R root: /var/www/torclient/
+sudo chmod -R 0644 /var/www/torclient/*
+sudo find /var/www/torclient/ -type d -exec chmod +x {} \;
+
+# Fix confs
+## nginx
+sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
+sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/torclient/|g' -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
+sudo sed 's|<TPL:PHP_NAME>|torclient|g' -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
+
+## php-fpm
+sudo sed 's|<TPL:PHP_NAME>|torclient|g' -i /etc/php5/fpm/pool.d/torclient.conf
+sudo sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/torclient.conf
+sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/torclient.conf
+sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/torclient/|g' -i /etc/php5/fpm/pool.d/torclient.conf
+sudo sed 's|^;\?\s*max_execution_time.\+|max_execution_time = 600|' -i /etc/php5/fpm/php.ini
+
+# Fix sources
+sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/torclient/config.php
+
+# Copy init script
+sudo install -o root -g root -m 0755 ../conf/init_ynh-torclient /etc/init.d/ynh-torclient
+
+# Set default inits
+#php-fpm is already installed by yunohost hotspot app
+sudo service php-fpm stop
+sudo service php-fpm start
+sudo service nginx reload
+
+# Update SSO for vpnadmin
+sudo yunohost app ssowatconf
+
+# Start tor client
+service torclient start
+
+exit 0

+ 50 - 0
scripts/remove

@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Tor Client app for YunoHost 
+# Copyright (C) 2015 Emile Morel <emile@bleuchtang.fr>
+# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
+# Contribute at https://github.com/bleuchtang/torclient_ynh
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Retrieve arguments
+domain=$(sudo yunohost app setting torclient domain)
+
+# The End
+sudo service ynh-torclient stop
+sudo yunohost service remove ynh-torclient
+sudo rm -f /etc/init.d/ynh-torclient
+sudo rm -f /tmp/.ynh-torclient-*
+
+# Remove confs
+sudo rm -rf /etc/tor*
+sudo rm -f /etc/nginx/conf.d/${domain}.d/torclient.conf
+sudo rm -f /etc/php5/fpm/pool.d/torclient.conf
+
+# Restart services
+sudo yunohost service stop php5-fpm
+sudo yunohost service start php5-fpm
+sudo service nginx reload
+
+# Remove sources
+sudo rm -rf /var/www/torclient/
+
+sudo rm -rf /etc/apt/sources.list.d/torproject.list 
+sudo apt-get update
+
+# Remove packets
+# The yunohost policy is currently to not uninstall packets (dependency problems)
+sudo apt-get --assume-yes --force-yes remove tor torsocks
+
+exit 0

+ 56 - 0
sources/config.php

@@ -0,0 +1,56 @@
+<?php
+
+// Limonade configuration
+function configure() {
+    option('env', ENV_PRODUCTION);
+    option('debug', false);
+    option('base_uri', '<TPL:NGINX_LOCATION>/');
+    layout("layout.html.php");
+    define('PUBLIC_DIR', '<TPL:NGINX_LOCATION>/public');
+}
+
+// Not found page
+function not_found($errno, $errstr, $errfile=null, $errline=null) {
+    $msg = h(rawurldecode($errstr));
+    return render($msg, 'error_layout.html.php');
+}
+
+function T_($string) {
+    return gettext($string);
+}
+
+// Before routing
+function before($route) {
+     /**
+     * * Locale
+     * */
+    if (!isset($_SESSION['locale'])) {
+        $locale = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
+        $_SESSION['locale'] = strtolower(substr(chop($locale[0]),0,2));
+    }
+    $textdomain="localization";
+    putenv('LANGUAGE='.$_SESSION['locale']);
+    putenv('LANG='.$_SESSION['locale']);
+    putenv('LC_ALL='.$_SESSION['locale']);
+    putenv('LC_MESSAGES='.$_SESSION['locale']);
+    setlocale(LC_ALL,$_SESSION['locale']);
+    setlocale(LC_CTYPE,$_SESSION['locale']);
+    $locales_dir = dirname(__FILE__).'/../i18n';
+    bindtextdomain($textdomain,$locales_dir);
+    bind_textdomain_codeset($textdomain, 'UTF-8');
+    textdomain($textdomain);
+    // Set the $locale variable in template
+    set('locale', $_SESSION['locale']);
+}
+
+// After routing
+function after($output, $route) {
+    /*
+    $time = number_format( (float)substr(microtime(), 0, 10) - LIM_START_MICROTIME, 6);
+    $output .= "\n<!-- page rendered in $time sec., on ".date(DATE_RFC822)." -->\n";
+    $output .= "<!-- for route\n";
+    $output .= print_r($route, true);
+    $output .= "-->";
+    */
+    return $output;
+}

+ 100 - 0
sources/controller.php

@@ -0,0 +1,100 @@
+<?php
+
+function moulinette_get($var) {
+  return htmlspecialchars(exec('sudo yunohost app setting torclient '.escapeshellarg($var)));
+}
+
+function moulinette_set($var, $value) {
+  return exec('sudo yunohost app setting torclient '.escapeshellarg($var).' -v '.escapeshellarg($value));
+}
+
+function stop_service() {
+  exec('sudo service ynh-torclient stop');
+}
+
+function start_service() {
+  exec('sudo service ynh-torclient start', $output, $retcode);
+
+  return $retcode;
+}
+
+function service_status() {
+  exec('sudo service ynh-torclient status', $output);
+
+  return $output;
+}
+
+function service_faststatus() {
+  exec('sudo service ynh-torclient status', $output, $retcode);
+
+  return $retcode;
+}
+
+
+dispatch('/', function() {
+
+  set('status', service_faststatus() == 0);
+
+  return render('settings.html.php');
+});
+
+dispatch_put('/settings', function() {
+
+  $status = isset($_POST['status']) ? 1 : 0;
+
+  moulinette_set('status', $status);
+
+  if($status == 1) {
+    $retcode = start_service();
+  } else {
+    $retcode = stop_service();
+  }
+
+  if($retcode == 0) {
+    flash('success', T_('Configuration updated and service successfully reloaded'));
+  } else {
+    flash('error', T_('Configuration updated but service reload failed'));
+  }
+
+  redirect:
+  redirect_to('/');
+});
+
+dispatch('/status', function() {
+  $status_lines = service_status();
+  $status_list = '';
+
+  foreach($status_lines AS $status_line) {
+    if(preg_match('/^\[INFO\]/', $status_line)) {
+      $status_list .= '<li class="status-info">'.htmlspecialchars($status_line).'</li>';
+    }
+    elseif(preg_match('/^\[OK\]/', $status_line)) {
+      $status_list .= '<li class="status-success">'.htmlspecialchars($status_line).'</li>';
+    }
+    elseif(preg_match('/^\[WARN\]/', $status_line)) {
+      $status_list .= '<li class="status-warning">'.htmlspecialchars($status_line).'</li>';
+    }
+    elseif(preg_match('/^\[ERR\]/', $status_line)) {
+      $status_list .= '<li class="status-danger">'.htmlspecialchars($status_line).'</li>';
+    }
+  }
+
+  echo $status_list;
+});
+
+dispatch('/lang/:locale', function($locale = 'en') {
+  switch ($locale) {
+    case 'fr':
+      $_SESSION['locale'] = 'fr';
+      break;
+
+    default:
+      $_SESSION['locale'] = 'en';
+  }
+
+  if(!empty($_GET['redirect_to'])) {
+    redirect_to($_GET['redirect_to']);
+  } else {
+    redirect_to('/');
+  }
+});

+ 3 - 0
sources/i18n/README

@@ -0,0 +1,3 @@
+Add a "localization.pot" to this directory, and one folder per translated language, containing the po a LC_MESSAGE directory (with the .mo)
+
+See: https://github.com/YunoHost/admin_v1/tree/master/i18n

+ 11 - 0
sources/index.php

@@ -0,0 +1,11 @@
+<?php
+
+require dirname(__FILE__).'/lib/limonade.php';
+require dirname(__FILE__).'/controller.php';
+
+require dirname(__FILE__).'/lib/unix_func.php';
+//require '/usr/share/php/php-gettext/gettext.inc';
+
+require dirname(__FILE__).'/config.php';
+
+run();

File diff suppressed because it is too large
+ 2707 - 0
sources/lib/limonade.php


+ 193 - 0
sources/lib/limonade/abstract.php

@@ -0,0 +1,193 @@
+<?php
+/**
+ * Abstract methods that might be redefined by user
+ * Do not include this file in your app: it only aims to provide documentation
+ * about those functions.
+ * 
+ * @package limonade
+ * @subpackage abstract
+ */
+ 
+/**
+ * It will be called when app is launched (at the begining of the run function).
+ * You can define options inside it, a connection to a database ...
+ *
+ * @abstract this function might be redefined by user
+ * @return void 
+ */
+function configure()
+{
+  return;
+}
+
+/**
+ * Called in run() just after session start, and before checking request method
+ * and output buffer start.  
+ *
+ * @abstract this function might be redefined by user
+ * @return void 
+ */
+function initialize()
+{
+  return;
+}
+
+/**
+ * Called in run() just after the route matching, in order to load controllers. 
+ * If not specfied, the default function is called:
+ * 
+ * <code>
+ * function autoload_controller($callback)
+ * {
+ *   require_once_dir(option('controllers_dir'));
+ * }
+ * </code>
+ * 
+ *
+ * @param string $callback the callback defined in matching route
+ * @return void
+ */
+function autoload_controller($callback)
+{
+  return;
+}
+ 
+/**
+ * Called before each request.
+ * This is very useful to define a default layout or passing common variables
+ * to the templates.
+ *
+ * @abstract this function might be redefined by user
+ * @param array() $route array (like returned by {@link route_build()},
+ *   with keys "method", "pattern", "names", "callback", "options")
+ * @return void 
+ */
+function before($route)
+{
+  
+}
+ 
+/**
+ * An `after` output filter
+ * 
+ * Called after each request and can apply a transformation to the output
+ * (except for `render_file` outputs  which are sent directly to the output buffer).
+ *
+ * @abstract this function might be redefined by user
+ * @param string $output 
+ * @param array() $route array (like returned by {@link route_find()},
+ *   with keys "method", "pattern", "names", "callback", "params", "options")
+ * @return string 
+ */
+function after($output, $route)
+{
+  # Call functions...
+  # .. modifies $output...
+  return $output;
+}
+ 
+/**
+ * Not found error output
+ *
+ * @abstract this function might be redefined by user
+ * @param string $errno 
+ * @param string $errstr 
+ * @param string $errfile 
+ * @param string $errline 
+ * @return string "not found" output string
+ */
+function not_found($errno, $errstr, $errfile=null, $errline=null)
+{
+ 
+}
+ 
+/**
+ * Server error output
+ *
+ * @abstract this function might be redefined by user
+ * @param string $errno 
+ * @param string $errstr 
+ * @param string $errfile 
+ * @param string $errline 
+ * @return string "server error" output string
+ */
+function server_error($errno, $errstr, $errfile=null, $errline=null)
+{
+  
+}
+ 
+/**
+ * Called when a route is not found.
+ * 
+ * 
+ * @abstract this function might be redefined by user
+ * @param string $request_method 
+ * @param string $request_uri 
+ * @return void 
+ */
+function route_missing($request_method, $request_uri)
+{
+  halt(NOT_FOUND, "($request_method) $request_uri"); # by default
+}
+
+/**
+ * Called before stoppping and exiting application.
+ *
+ * @abstract this function might be redefined by user
+ * @param boolean exit or not
+ * @return void 
+ */
+function before_exit($exit)
+{
+  
+}
+
+/**
+ * Rendering prefilter.
+ * Useful if you want to transform your views before rendering.
+ * The first three parameters are the same as those provided 
+ * to the `render` function.
+ *
+ * @abstract this function might be redefined by user
+ * @param string $content_or_func a function, a file in current views dir or a string
+ * @param string $layout 
+ * @param array $locals 
+ * @param array $view_path (by default <code>file_path(option('views_dir'),$content_or_func);</code>)
+ * @return array with, in order, $content_or_func, $layout, $locals vars
+ *  and the calculated $view_path
+ */
+function before_render($content_or_func, $layout, $locals, $view_path)
+{
+  # transform $content_or_func, $layout, $locals or $view_path…
+  return array($content_or_func, $layout, $locals, $view_path);
+}
+
+
+/**
+ * Called only if rendering $output is_null,
+ * like in a controller with no return statement.
+ *
+ * @abstract this function might be defined by user
+ * @param array() $route array (like returned by {@link route_build()},
+ *   with keys "method", "pattern", "names", "callback", "options")
+ * @return string
+ */
+function autorender($route)
+{
+  # process output depending on $route
+  return $output;
+}
+
+/**
+ * Called if a header is about to be sent
+ *
+ * @abstract this function might be defined by user
+ * @param string the headers that limonade will send
+ * @return void
+ */
+function before_sending_header($header)
+{
+
+}
+
+

+ 173 - 0
sources/lib/limonade/assertions.php

@@ -0,0 +1,173 @@
+<?php
+/**
+ * @package tests
+ * @subpackage assertions
+ */
+# ============================================================================ #
+#    ASSERTIONS                                                                #
+# ============================================================================ #
+
+/**
+ * assert_true
+ *
+ * @param string $value 
+ * @param string $message 
+ * @return boolean
+ */
+function assert_true($value, $message = '<1> should be TRUE')
+{
+   test_run_assertion();
+   return assert('$value === TRUE; //'.$message);
+}
+
+function assert_false($value, $message = '<1> should be FALSE')
+{
+   test_run_assertion();
+   return assert('$value === FALSE; //'.$message);
+}
+
+function assert_null($value, $message = '<1> should be NULL')
+{
+   test_run_assertion();
+   return assert('$value === NULL; //'.$message);
+}
+
+function assert_not_null($value, $message = '<1> should not be NULL')
+{
+   test_run_assertion();
+   return assert('$value !== NULL; //'.$message);
+}
+
+function assert_empty($value, $message = '<1> should be empty')
+{
+   test_run_assertion();
+   return assert('empty($value); //'.$message);
+}
+
+function assert_not_empty($value, $message = '<1> should not be empty')
+{
+   test_run_assertion();
+   return assert('!empty($value); //'.$message);
+}
+
+function assert_equal($expected, $value, $message = '<1> should be equal to <2>')
+{
+   test_run_assertion();
+   return assert('$expected == $value; //'.$message);
+}
+
+function assert_not_equal($expected, $value, $message = '<1> should not equal to <2>')
+{
+   test_run_assertion();
+   return assert('$expected != $value; //'.$message);
+}
+
+function assert_identical($expected, $value, $message = '<1> should be identical to <2>')
+{
+   test_run_assertion();
+   return assert('$expected === $value; //'.$message);
+}
+
+function assert_not_identical($expected, $value, $message = '<1> should not be identical to <2>')
+{
+   test_run_assertion();
+   return assert('$expected !== $value; //'.$message);
+}
+
+function assert_match($pattern, $string, $message = '<2> expected to match regular expression <1>') {
+   test_run_assertion();
+   return assert('preg_match($pattern, $string); //'.$message);
+}
+ 
+function assert_no_match($pattern, $string, $message = '<2> expected to not match regular expression <1>') {
+   test_run_assertion();
+   return assert('!preg_match($pattern, $string); //'.$message);
+}
+
+function assert_type($type, $value, $message = '<1> is not of type <2>') {
+  test_run_assertion();
+  $predicate = 'is_' . strtolower(is_string($type) ? $type : gettype($type));
+  return assert('$predicate($value); //'.$message);
+}
+ 
+function assert_instance_of($class, $object, $message = '<2> is not an instance of class <1>') {
+   test_run_assertion();
+   return assert('$object instanceof $class; //'.$message);
+}
+ 
+function assert_length_of($value, $length, $message = '<1> expected to be of length <2>') {
+   test_run_assertion();
+   $count = is_string($value) ? 'strlen' : 'count';
+   return assert('$count($value) == $length; //'.$message);
+}
+
+function assert_trigger_error($callable, $args = array(), $message = '<1> should trigger an error') {
+  test_run_assertion();
+  $trigger_errors = count($GLOBALS["limonade"]["test_errors"]);
+  set_error_handler("test_error_handler");
+  $result = call_user_func_array($callable, $args);
+  restore_error_handler();
+  return assert('$trigger_errors < count($GLOBALS["limonade"]["test_errors"]); //'.$message);
+}
+
+# TODO add web browser assertions assert_http_get, assert_http_response... as in SimpleTest (http://www.simpletest.org/en/web_tester_documentation.html)
+
+function assert_header($response, $expected_name, $expected_value = null, $message = "expected header '%s' to be equal to '%s' but received '%s: %s'")
+{
+  test_run_assertion();
+  # see assert_header in http://github.com/fnando/voodoo-test/blob/f3b0994ef138a6ba94d5e7cef6c1fb1720797a86/lib/assertions.php
+  $headers = preg_split("/^\s*$/ms", $response);
+  //var_dump($headers);    
+  $headers = preg_replace("/\s*$/sm", "", $headers[0]);
+  //var_dump($headers);   
+  
+  $regex_header = str_replace("/", "\\/", $expected_name);
+  $regex_header = str_replace(".", "\\.", $regex_header);
+  
+  $header = $expected_name;
+  
+  # from http://www.faqs.org/rfcs/rfc2616
+  # Field names are case-insensitive
+  if ($expected_value) {
+      $regex = "/^{$regex_header}:(.*?)$/ism";
+      $header .= ": {$expected_value}";
+  } else {
+      $regex = "/^{$regex_header}(:.*?)?$/ism";
+  }
+  
+  $has_header = preg_match($regex, $headers, $matches);    
+  $sent_header = trim((string)$matches[1]);
+
+  
+  if(empty($sent_header))
+  {
+    if(is_null($expected_value))
+    {
+      $message = "expected header '%s' but header has not been sent";
+    }
+    else
+    {
+      $message = "expected header '%s' to be equal to '%s' but header has not been sent";
+    }
+    
+    $message = sprintf($message, $expected_name, $expected_value);
+    return assert("false; //".$message);
+  }
+  else if($expected_value)
+  {
+    $message = sprintf($message, $expected_name, $expected_value, $expected_name, $sent_header);
+    return assert('$expected_value && $sent_header == $expected_value; //'.$message);
+  }
+  return assert("true; //");
+}
+
+function assert_status($response, $expected_status, $message = "expected status code to be equal to '%s' but received '%s'")
+{
+  $lines = explode('\n', trim($response));
+  if (preg_match('/HTTP\/(\d+\.\d+)\s+(\d+)/i', $lines[0], $matches))
+  {
+      $status = $matches[2];
+      return assert('$expected_status == $status; //'.sprintf($message, $expected_status, $status));
+  }
+  return assert("false; //no status code returned in this response string");
+}

+ 220 - 0
sources/lib/limonade/public/css/screen.css

@@ -0,0 +1,220 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 0.8
+ http://blueprintcss.org
+
+   * Copyright (c) 2007-Present. See LICENSE for more info.
+   * See README for instructions on how to use Blueprint.
+   * For credits and origins, see AUTHORS.
+   * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* reset.css */
+html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
+body {line-height:1.5;}
+table {border-collapse:separate;border-spacing:0;}
+caption, th, td {text-align:left;font-weight:normal;}
+table, td, th {vertical-align:middle;}
+blockquote:before, blockquote:after, q:before, q:after {content:"";}
+blockquote, q {quotes:"" "";}
+a img {border:none;}
+
+/* typography.css */
+body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;}
+h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
+h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}
+h2 {font-size:2em;margin-bottom:0.75em;}
+h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
+h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;}
+h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;}
+h6 {font-size:1em;font-weight:bold;}
+h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;}
+p {margin:0 0 1.5em;}
+p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
+p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
+a:focus, a:hover {color:#000;}
+a {color:#009;text-decoration:underline;}
+blockquote {margin:1.5em;color:#666;font-style:italic;}
+strong {font-weight:bold;}
+em, dfn {font-style:italic;}
+dfn {font-weight:bold;}
+sup, sub {line-height:0;}
+abbr, acronym {border-bottom:1px dotted #666;}
+address {margin:0 0 1.5em;font-style:italic;}
+del {color:#666;}
+pre {margin:1.5em 0;white-space:pre;}
+pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;}
+li ul, li ol {margin:0 1.5em;}
+ul, ol {margin:0 1.5em 1.5em 1.5em;}
+ul {list-style-type:disc;}
+ol {list-style-type:decimal;}
+dl {margin:0 0 1.5em 0;}
+dl dt {font-weight:bold;}
+dd {margin-left:1.5em;}
+table {margin-bottom:1.4em;width:100%;}
+th {font-weight:bold;}
+thead th {background:#c3d9ff;}
+th, td, caption {padding:4px 10px 4px 5px;}
+tr.even td {background:#e5ecf9;}
+tfoot {font-style:italic;}
+caption {background:#eee;}
+.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;}
+.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;}
+.hide {display:none;}
+.quiet {color:#666;}
+.loud {color:#000;}
+.highlight {background:#ff0;}
+.added {background:#060;color:#fff;}
+.removed {background:#900;color:#fff;}
+.first {margin-left:0;padding-left:0;}
+.last {margin-right:0;padding-right:0;}
+.top {margin-top:0;padding-top:0;}
+.bottom {margin-bottom:0;padding-bottom:0;}
+
+/* forms.css */
+label {font-weight:bold;}
+fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;}
+legend {font-weight:bold;font-size:1.2em;}
+input.text, input.title, textarea, select {margin:0.5em 0;border:1px solid #bbb;}
+input.text:focus, input.title:focus, textarea:focus, select:focus {border:1px solid #666;}
+input.text, input.title {width:300px;padding:5px;}
+input.title {font-size:1.5em;}
+textarea {width:390px;height:250px;padding:5px;}
+.error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;}
+.error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;}
+.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;}
+.success {background:#E6EFC2;color:#264409;border-color:#C6D880;}
+.error a {color:#8a1f11;}
+.notice a {color:#514721;}
+.success a {color:#264409;}
+
+.box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;}
+hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;}
+hr.space {background:#fff;color:#fff;}
+.clearfix:after, .container:after {content:"\0020";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;}
+.clearfix, .container {display:block;}
+.clear {clear:both;}
+
+/* -----------------------------------------------------------------------
+
+ LIMONADE
+ 
+ Design and logo by <a href="http://www.minimau.com">Minimau</a>
+
+----------------------------------------------------------------------- */
+
+html {
+ 	background-color: #b4a689;
+ 	text-align: center;
+ 	}
+ 	body {
+ 		width: auto; /* 16 col */
+ 		margin: 0 20px;
+ 		text-align: left;
+ 		/*background: #fff url(blueprint/src/grid.png);*/
+ 		font-family: Verdana, Geneva, sans-serif;
+ 		color: #303030;
+ 		}
+ 		a, a:hover, a:visited {
+ 			color: #4596cd;
+ 			}
+ 		a:hover {
+ 			text-decoration: none;
+ 			}
+ 		#header, h1, h2, h3, h4 {
+ 			font-family: "Arial Black", Gadget, sans-serif;
+ 			}
+ 		h1 {
+ 			color: #b4a689;
+ 			font-size: 2em;
+ 			line-height: 2;
+ 			border-bottom: 7px solid #000;
+ 			margin-bottom: 0.75em;
+ 			margin-top:0;
+ 			}
+ 		h2 {
+ 			font-size: 1.5em;
+ 			color: #cddb12;
+ 			margin-top: 2em;
+ 			line-height: 0.8;
+ 			margin-bottom: 1.2em;
+ 			}
+ 		h3 {
+ 			font-size: 1.33em;
+ 			line-height: 0.89;
+ 			margin-top: 2.66em;
+ 			margin-bottom: 1.33em;
+ 			color:#95b383;
+ 			}
+ 		pre {
+ 			background-color: #cddb12;
+ 			font-size: 12px;
+ 			padding: 1.5em;
+ 			margin-bottom: 1.5em;
+ 			overflow: auto;
+ 			}
+ 		code {
+ 			font: 10px Monaco, "Courier New", Courier, monospace;
+ 			color: #0d562a;
+ 			}
+ 		#header {
+ 			/*position:relative;*/
+ 			height: 187px; /* 12 lines */
+ 			background: #fff url(<?=url_for('/_lim_public/img/bg_header.png')?>) no-repeat 0 0;
+ 			margin-top: 10px;
+      padding:0;
+ 			}
+ 			#header h1 {
+ 				position: absolute;
+ 				left:-9999px;
+ 				   			margin:0;
+ 				}
+ 		#footer {
+ 			padding: 0 55px;
+ 			background-color: #1a1818;
+ 			color: #999;
+ 			height: 2em;
+ 			line-height: 2em;
+ 			text-align: right;
+ 			}
+ 			#footer a {
+ 				color: #a3d8de;
+ 				text-decoration: none;
+ 				}
+ 			#footer a:hover {
+ 				color: #fff;
+ 				}
+ 		#content {
+ 		  background-color: #fff;
+ 			padding: 0 55px;
+ 			min-height: 400px;
+ 			}
+    		p.bt {
+    		   text-align:right;
+    		   }
+       		p.bt a {
+       		   text-decoration:none;
+       		   padding: 2px 4px;
+       		   }
+       		p.bt a:hover {
+      	      background-color: #4596cd;
+      	      color: #fff;
+      	      }
+      	#debug-menu {
+      	   position: fixed;
+      	   top: 0px;
+      	   right:20px;
+      	   background-color: rgba(100,100,100, 0.7);
+      	   padding:5px;
+      	}
+      	#debug-menu a {
+      	   color: #fff;
+      	   font-size: 90%;
+      	   text-decoration:none;
+   	   }
+   	   #debug-menu a:hover {
+   	      text-decoration: underline;
+	      }
+   	

BIN
sources/lib/limonade/public/img/bg_header.png


+ 350 - 0
sources/lib/limonade/tests.php

@@ -0,0 +1,350 @@
+<?php
+/**
+ * @package tests
+ */
+ 
+# ============================================================================ #
+#    TESTS                                                                     #
+# ============================================================================ #
+
+/**
+ * load assertions
+ */
+require_once dirname(__FILE__)."/assertions.php";
+
+
+ 
+/**
+ * Constants and globals
+ */
+if(!defined('DS')) define("DS", DIRECTORY_SEPARATOR);
+
+if(!array_key_exists("limonade", $GLOBALS))
+   $GLOBALS["limonade"] = array();
+if(!array_key_exists("test_cases", $GLOBALS["limonade"]))
+   $GLOBALS["limonade"]["test_cases"] = array();
+if(!array_key_exists("test_errors", $GLOBALS["limonade"]))
+   $GLOBALS["limonade"]["test_errors"] = array();
+if(!array_key_exists("test_case_current", $GLOBALS["limonade"]))
+   $GLOBALS["limonade"]["test_case_current"] = NULL;
+if(!array_key_exists("test_suites", $GLOBALS["limonade"]))
+   $GLOBALS["limonade"]["test_suites"] = NULL;
+
+ini_set("display_errors", true);
+error_reporting(E_ALL ^ (E_USER_WARNING | E_NOTICE | E_USER_NOTICE));
+// error_reporting(E_ALL | E_STRICT);
+assert_options(ASSERT_ACTIVE, 1);
+assert_options(ASSERT_WARNING, 0);
+assert_options(ASSERT_BAIL, 0);
+assert_options(ASSERT_QUIET_EVAL, 0);
+assert_options(ASSERT_CALLBACK, 'test_assert_failure');
+
+# TODO: separate display from logic
+# TODO: clean results output
+# TODO: add all tests results
+
+/**
+ * Starts a test suite
+ *
+ * @param string $name 
+ * @return void
+ */
+function test_suite($name)
+{
+  $GLOBALS["limonade"]["test_suites"] = $name;
+  echo test_cli_format("===========================================================\n", 'white');
+  echo test_cli_format(">>>> START $name tests suites\n", 'white');
+  echo test_cli_format("-----------------------------------------------------------\n", 'white');
+}
+
+/**
+ * Ends the last group of test suites
+ *
+ * @return void
+ */
+function end_test_suite()
+{
+  $name         = $GLOBALS["limonade"]["test_suites"];
+  $failures     = 0;
+  $tests        = 0;
+  $passed_tests = 0;
+  $assertions   = 0;
+
+  foreach($GLOBALS["limonade"]["test_cases"] as $test)
+  {
+    $failures += $test['failures'];
+    $assertions += $test['assertions'];
+    if(empty($test['failures'])) $passed_tests++;
+    $tests++;
+  }
+  echo ">> ENDING $name tests suites\n  ";
+  echo $failures > 0 ? test_cli_format("|FAILED!|", "red") : test_cli_format("|PASSED|", "green");;
+  echo " Passes ".$passed_tests."/".$tests.", ";
+  echo " {$failures} failures for {$assertions} assertions.\n";
+  echo test_cli_format("===========================================================\n", 'white');
+}
+
+/**
+ * Starting a new test case
+ *
+ * @param string $name 
+ * @return void
+ */
+function test_case($name)
+{
+   $name = strtolower($name); // TODO: normalize name
+   
+   if(!array_key_exists($name, $GLOBALS["limonade"]["test_cases"]))
+   {
+      $GLOBALS["limonade"]["test_cases"][$name] = array( 
+                                                      "name" => $name,
+                                                      "assertions" => 0, 
+                                                      "failures" => 0,
+                                                      "description" => NULL
+                                                   );      
+      $GLOBALS["limonade"]["test_case_current"] = $name;
+   }
+   else
+   {
+      
+   }
+}
+
+/**
+ * Displays and ending the current tests suite
+ * 
+ * @return void
+ */
+function end_test_case()
+{
+   $name = $GLOBALS["limonade"]["test_case_current"];
+   echo "## ".strtoupper($name)."\n";
+      
+   $desc = test_case_describe();
+   if(!is_null($desc)) echo $desc."\n";
+
+   echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
+   
+   test_case_execute_current();
+   
+   
+   if(!is_null($name))
+   {
+      $test = $GLOBALS["limonade"]["test_cases"][$name];
+      // closing previous test
+      echo "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
+      echo $test['failures'] > 0 ? test_cli_format("|FAILED!|", "red") : test_cli_format("|PASSED|", "green");
+      echo " Test case '$name' finished: ";
+      echo count(test_case_all_func())." tests, ";
+      echo " {$test['failures']} failures for {$test['assertions']} assertions.\n";
+      
+      echo "-----------------------------------------------------------\n";
+   }
+   $GLOBALS["limonade"]["test_case_current"] = null;
+}
+
+/**
+ * Describes the current tests suite
+ *
+ * @param string $msg 
+ * @return string tests description
+ */
+function test_case_describe($msg = NULL)
+{
+   $test =& test_case_current();
+   if(!is_null($msg))
+   {
+      $test["description"] = $msg;
+   }
+   //var_dump($test["description"]);
+   return $test["description"];
+}
+
+/**
+ * Returns all user test case functions
+ *
+ * @access private
+ * @return void
+ */
+function test_case_all_func()
+{
+   $functions = get_defined_functions();
+   $functions = $functions['user'];
+   $tests = array();
+   $name = $GLOBALS["limonade"]["test_case_current"];
+   while ($func = array_shift($functions)) {
+      $regexp = "/^test_{$name}_(.*)$/";
+      if(!preg_match($regexp, $func)) continue;
+      if($func == test_before_func_name()) continue;
+      // TODO: adding break for all test api methods
+      
+      $tests[] = $func;
+   }
+   return $tests;
+}
+
+/**
+ * Execute current test case
+ *
+ * @access private
+ * @return void
+ */
+function test_case_execute_current()
+{
+   $tests = test_case_all_func();
+   while($func = array_shift($tests))
+   {
+      test_call_func(test_before_func_name());
+      call_user_func($func);
+   }
+}
+
+
+function &test_case_current()
+{
+   $name = $GLOBALS["limonade"]["test_case_current"];
+   return $GLOBALS["limonade"]["test_cases"][$name];
+}
+
+
+
+function test_before_func_name()
+{
+   $test = test_case_current();
+   $func = "before_each_test_in_".$test["name"];
+   return $func;
+}
+
+function test_before_assert_func_name()
+{
+   $test = test_case_current();
+   $func = "before_each_assert_in_$name".$test["name"];
+   return $func;
+}
+
+function test_run_assertion()
+{
+   $name = $GLOBALS["limonade"]["test_case_current"];
+   $GLOBALS["limonade"]["test_cases"][$name]['assertions']++;
+   test_call_func(test_before_assert_func_name());
+}
+
+/**
+ * Calls a function if exists
+ *
+ * @param string $func the function name
+ * @param mixed $arg,.. (optional)
+ * @return mixed
+ */
+function test_call_func($func)
+{
+  if(empty($func)) return;
+  $args = func_get_args();
+  $func = array_shift($args);
+  if(function_exists($func)) return call_user_func_array($func, $args);
+  return;
+}
+
+/**
+ * Error handler 
+ * 
+ * @access private
+ * @return boolean true
+ */
+function test_error_handler($errno, $errstr, $errfile, $errline)
+{
+	if($errno < E_USER_ERROR || $errno > E_USER_NOTICE) 
+	   echo test_cli_format("!!! ERROR", "red") . " [$errno], $errstr in $errfile at line $errline\n";
+	$GLOBALS["limonade"]["test_errors"][] = array($errno, $errstr, $errfile, $errline);
+   return true;
+}
+
+/**
+ * Assert callback
+ * 
+ * @access private
+ * @param string $script 
+ * @param string $line 
+ * @param string $message 
+ * @return void
+ */
+function test_assert_failure($script, $line, $message)
+{
+   // Using the stack trace, find the outermost assert*() call
+   $stacktrace = array_slice(debug_backtrace(), 1); // skip self
+   $assertion = reset($stacktrace);
+   while ($stackframe = array_shift($stacktrace)) {
+    if (!preg_match('/^assert/', $stackframe['function']))
+      break;
+    $assertion = $stackframe;
+   }
+
+   extract($assertion, EXTR_PREFIX_ALL, 'assert');
+   $code = explode("\n", file_get_contents($assert_file));
+   $code = trim($code[$assert_line - 1]);
+   
+   list($assert_code, $message) = explode("//", $message);
+   echo test_cli_format("Assertion failed", "yellow");
+   echo " in script *{$assert_file}* (line {$assert_line}):\n";
+   echo "   * assertion: $code\n";
+   echo "   * message:   $message\n";
+   $name = $GLOBALS["limonade"]["test_case_current"];
+   $GLOBALS["limonade"]["test_cases"][$name]['failures']++;
+}
+
+function test_cli_format($text, $format) {
+    $formats = array(
+        "blue"       => 34,
+        "bold"       => 1,
+        "green"      => 32,
+        "highlight"  => 7,
+        "light_blue" => 36,
+        "purple"     => 35,
+        "red"        => 31,
+        "underline"  => 4,
+        "white"      => 37,
+        "yellow"     => 33
+    );
+
+    if (array_key_exists($format, $formats)) $format = $formats[$format];
+    return chr(27) . "[01;{$format} m{$text}" . chr(27) . "[00m";
+}
+
+/**
+ * Do HTTP request and return the response content.
+ * 
+ * @param string $url
+ * @param string $method
+ * @param bool $include_header
+ * @return string
+ * @author Nando Vieira
+ */
+function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
+    $method = strtoupper($method);
+    $allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
+    if(!in_array($method, $allowed_methods))
+    {
+      $message = "The requested method '$method' is not allowed";
+      return assert('false; //'.$message);
+    }
+    
+    $curl = curl_init($url);
+    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($curl, CURLOPT_HEADER, $include_header);
+    curl_setopt($curl, CURLOPT_HTTPHEADER, $http_header);
+    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
+    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
+    if($method == 'POST' || $method == 'PUT')
+    {
+      curl_setopt($curl, CURLOPT_POST, 1);
+      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
+    }
+    if($method == 'HEAD')
+    {
+      curl_setopt($curl, CURLOPT_NOBODY, true);
+    }
+    $response = curl_exec($curl);
+    curl_close($curl);
+
+    return $response;
+}

+ 37 - 0
sources/lib/limonade/views/_debug.html.php

@@ -0,0 +1,37 @@
+<?php if(option('env') > ENV_PRODUCTION && option('debug')): ?>
+  <?php if(!$is_http_error): ?>
+  <p>[<?php echo error_type($errno)?>]
+  	<?php echo $errstr?> (in <strong><?php echo $errfile?></strong> line <strong><?php echo $errline?></strong>)
+  	</p>
+  	<?php endif; ?>
+
+
+  <?php if($debug_args = set('_lim_err_debug_args')): ?>
+  <h2 id="debug-arguments">Debug arguments</h2>
+  	<pre><code><?php echo h(print_r($debug_args, true))?></code></pre>
+  <?php endif; ?>
+  
+  <h2 id="limonade-options">Options</strong></h2>
+  <pre><code><?php echo h(print_r(option(), true))?></code></pre>
+  <p class="bt top"><a href="#header">[ &#x2191; ]</a></p>
+  
+  <h2 id="environment">Environment</h2>
+  <pre><code><?php echo h(print_r(env(), true))?></code></pre>
+  <p class="bt top"><a href="#header">[ &#x2191; ]</a></p>
+  
+  <h2 id="debug-backtrace">Backtrace</h2>
+  <pre><code><?php echo h(print_r(debug_backtrace(), true))?></code></pre>
+  <p class="bt top"><a href="#header">[ &#x2191; ]</a></p>
+
+  <div id="debug-menu">
+    
+    <?php if($debug_args = set('_lim_err_debug_args')): ?>
+    <a href="#debug-arguments">Debug arguments</a> |
+    <?php endif; ?>
+    <a href="#limonade-options">Options</a> |
+    <a href="#environment">Environment</a> |
+    <a href="#debug-backtrace">Backtrace</a> |
+    <a href="#header">[ &#x2191; ]</a>
+  </div>
+  
+<?php endif; ?>

+ 15 - 0
sources/lib/limonade/views/_notices.html.php

@@ -0,0 +1,15 @@
+<?php if(!empty($notices)): ?>
+<div class="lim-debug lim-notices">
+  <h4> &#x2192; Notices and warnings</h4>
+  <dl>
+  <?php $cpt = 1; foreach($notices as $notice): ?>
+    <dt>[<?php echo $cpt.'. '.error_type($notice['errno'])?>]</dt>
+    <dd>
+    <?php echo $notice['errstr']?> in <strong><code><?php echo $notice['errfile']?></code></strong> 
+    line <strong><code><?php echo $notice['errline']?></code></strong>
+    </dd>
+  <?php $cpt++; endforeach; ?>
+  </dl>
+  <hr>
+</div>
+<?php endif; ?>

+ 22 - 0
sources/lib/limonade/views/default_layout.php

@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+	<title>Limonade, the fizzy PHP micro-framework</title>
+	<link rel="stylesheet" href="<?php echo url_for('/_lim_css/screen.css');?>" type="text/css" media="screen">
+</head>
+<body>
+  <div id="header">
+    <h1>Limonade</h1>
+  </div>
+  
+  <div id="content">
+    <?php echo error_notices_render(); ?>
+    <div id="main">
+      <?php echo $content;?>
+      <hr class="space">
+    </div>
+  </div>
+
+</body>
+</html>

+ 6 - 0
sources/lib/limonade/views/error.html.php

@@ -0,0 +1,6 @@
+  <h1><?php echo h(error_http_status($errno));?></h1>
+  <?php if($is_http_error): ?>
+  <p><?php echo h($errstr)?></p>
+  <?php endif; ?>
+  
+  <?php echo  render('_debug.html.php', null, $vars); ?>

+ 49 - 0
sources/lib/unix_func.php

@@ -0,0 +1,49 @@
+<?php 
+
+ /**
+  *  YunoHost - Self-hosting for all
+  *  Copyright (C) 2012  Kload <kload@kload.fr>
+  *
+  *  This program is free software: you can redistribute it and/or modify
+  *  it under the terms of the GNU Affero General Public License as
+  *  published by the Free Software Foundation, either version 3 of the
+  *  License, or (at your option) any later version.
+  *
+  *  This program is distributed in the hope that it will be useful,
+  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  *  GNU Affero General Public License for more details.
+  *
+  *  You should have received a copy of the GNU Affero General Public License
+  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  */
+  
+function read_file($file, $lines = 20) {
+
+    if (!$handle = fopen($file, "r"))
+        return false;
+    $linecounter = $lines;
+    $pos = -2;
+    $beginning = false;
+    $text = array();
+    while ($linecounter > 0) {
+        $t = " ";
+        while ($t != "\n") {
+            if(fseek($handle, $pos, SEEK_END) == -1) {
+                $beginning = true;
+                break;
+            }
+            $t = fgetc($handle);
+            $pos --;
+        }
+        $linecounter --;
+        if ($beginning) {
+            rewind($handle);
+        }
+        $text[$lines-$linecounter-1] = fgets($handle);
+        if ($beginning) break;
+    }
+    fclose ($handle);
+    return array_reverse($text);
+}
+

+ 457 - 0
sources/public/bootstrap/css/bootstrap-theme.css

@@ -0,0 +1,457 @@
+/*!
+ * Bootstrap v3.3.0 (http://getbootstrap.com)
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ */
+
+.btn-default,
+.btn-primary,
+.btn-success,
+.btn-info,
+.btn-warning,
+.btn-danger {
+  text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
+  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
+          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
+}
+.btn-default:active,
+.btn-primary:active,
+.btn-success:active,
+.btn-info:active,
+.btn-warning:active,
+.btn-danger:active,
+.btn-default.active,
+.btn-primary.active,
+.btn-success.active,
+.btn-info.active,
+.btn-warning.active,
+.btn-danger.active {
+  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
+          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
+}
+.btn-default .badge,
+.btn-primary .badge,
+.btn-success .badge,
+.btn-info .badge,
+.btn-warning .badge,
+.btn-danger .badge {
+  text-shadow: none;
+}
+.btn:active,
+.btn.active {
+  background-image: none;
+}
+.btn-default {
+  text-shadow: 0 1px 0 #fff;
+  background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
+  background-image:      -o-linear-gradient(top, #fff 0%, #e0e0e0 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#e0e0e0));
+  background-image:         linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-color: #dbdbdb;
+  border-color: #ccc;
+}
+.btn-default:hover,
+.btn-default:focus {
+  background-color: #e0e0e0;
+  background-position: 0 -15px;
+}
+.btn-default:active,
+.btn-default.active {
+  background-color: #e0e0e0;
+  border-color: #dbdbdb;
+}
+.btn-default:disabled,
+.btn-default[disabled] {
+  background-color: #e0e0e0;
+  background-image: none;
+}
+.btn-primary {
+  background-image: -webkit-linear-gradient(top, #428bca 0%, #2d6ca2 100%);
+  background-image:      -o-linear-gradient(top, #428bca 0%, #2d6ca2 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#428bca), to(#2d6ca2));
+  background-image:         linear-gradient(to bottom, #428bca 0%, #2d6ca2 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff2d6ca2', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-color: #2b669a;
+}
+.btn-primary:hover,
+.btn-primary:focus {
+  background-color: #2d6ca2;
+  background-position: 0 -15px;
+}
+.btn-primary:active,
+.btn-primary.active {
+  background-color: #2d6ca2;
+  border-color: #2b669a;
+}
+.btn-primary:disabled,
+.btn-primary[disabled] {
+  background-color: #2d6ca2;
+  background-image: none;
+}
+.btn-success {
+  background-image: -webkit-linear-gradient(top, #5cb85c 0%, #419641 100%);
+  background-image:      -o-linear-gradient(top, #5cb85c 0%, #419641 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#419641));
+  background-image:         linear-gradient(to bottom, #5cb85c 0%, #419641 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-color: #3e8f3e;
+}
+.btn-success:hover,
+.btn-success:focus {
+  background-color: #419641;
+  background-position: 0 -15px;
+}
+.btn-success:active,
+.btn-success.active {
+  background-color: #419641;
+  border-color: #3e8f3e;
+}
+.btn-success:disabled,
+.btn-success[disabled] {
+  background-color: #419641;
+  background-image: none;
+}
+.btn-info {
+  background-image: -webkit-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);
+  background-image:      -o-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#2aabd2));
+  background-image:         linear-gradient(to bottom, #5bc0de 0%, #2aabd2 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-color: #28a4c9;
+}
+.btn-info:hover,
+.btn-info:focus {
+  background-color: #2aabd2;
+  background-position: 0 -15px;
+}
+.btn-info:active,
+.btn-info.active {
+  background-color: #2aabd2;
+  border-color: #28a4c9;
+}
+.btn-info:disabled,
+.btn-info[disabled] {
+  background-color: #2aabd2;
+  background-image: none;
+}
+.btn-warning {
+  background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);
+  background-image:      -o-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#eb9316));
+  background-image:         linear-gradient(to bottom, #f0ad4e 0%, #eb9316 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-color: #e38d13;
+}
+.btn-warning:hover,
+.btn-warning:focus {
+  background-color: #eb9316;
+  background-position: 0 -15px;
+}
+.btn-warning:active,
+.btn-warning.active {
+  background-color: #eb9316;
+  border-color: #e38d13;
+}
+.btn-warning:disabled,
+.btn-warning[disabled] {
+  background-color: #eb9316;
+  background-image: none;
+}
+.btn-danger {
+  background-image: -webkit-linear-gradient(top, #d9534f 0%, #c12e2a 100%);
+  background-image:      -o-linear-gradient(top, #d9534f 0%, #c12e2a 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c12e2a));
+  background-image:         linear-gradient(to bottom, #d9534f 0%, #c12e2a 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-color: #b92c28;
+}
+.btn-danger:hover,
+.btn-danger:focus {
+  background-color: #c12e2a;
+  background-position: 0 -15px;
+}
+.btn-danger:active,
+.btn-danger.active {
+  background-color: #c12e2a;
+  border-color: #b92c28;
+}
+.btn-danger:disabled,
+.btn-danger[disabled] {
+  background-color: #c12e2a;
+  background-image: none;
+}
+.thumbnail,
+.img-thumbnail {
+  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
+          box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
+}
+.dropdown-menu > li > a:hover,
+.dropdown-menu > li > a:focus {
+  background-color: #e8e8e8;
+  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
+  background-image:      -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));
+  background-image:         linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
+  background-repeat: repeat-x;
+}
+.dropdown-menu > .active > a,
+.dropdown-menu > .active > a:hover,
+.dropdown-menu > .active > a:focus {
+  background-color: #357ebd;
+  background-image: -webkit-linear-gradient(top, #428bca 0%, #357ebd 100%);
+  background-image:      -o-linear-gradient(top, #428bca 0%, #357ebd 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#428bca), to(#357ebd));
+  background-image:         linear-gradient(to bottom, #428bca 0%, #357ebd 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0);
+  background-repeat: repeat-x;
+}
+.navbar-default {
+  background-image: -webkit-linear-gradient(top, #fff 0%, #f8f8f8 100%);
+  background-image:      -o-linear-gradient(top, #fff 0%, #f8f8f8 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f8f8f8));
+  background-image:         linear-gradient(to bottom, #fff 0%, #f8f8f8 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+  border-radius: 4px;
+  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
+          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
+}
+.navbar-default .navbar-nav > .open > a,
+.navbar-default .navbar-nav > .active > a {
+  background-image: -webkit-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);
+  background-image:      -o-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#dbdbdb), to(#e2e2e2));
+  background-image:         linear-gradient(to bottom, #dbdbdb 0%, #e2e2e2 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);
+  background-repeat: repeat-x;
+  -webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
+          box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
+}
+.navbar-brand,
+.navbar-nav > li > a {
+  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
+}
+.navbar-inverse {
+  background-image: -webkit-linear-gradient(top, #3c3c3c 0%, #222 100%);
+  background-image:      -o-linear-gradient(top, #3c3c3c 0%, #222 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#222));
+  background-image:         linear-gradient(to bottom, #3c3c3c 0%, #222 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  background-repeat: repeat-x;
+}
+.navbar-inverse .navbar-nav > .open > a,
+.navbar-inverse .navbar-nav > .active > a {
+  background-image: -webkit-linear-gradient(top, #080808 0%, #0f0f0f 100%);
+  background-image:      -o-linear-gradient(top, #080808 0%, #0f0f0f 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#080808), to(#0f0f0f));
+  background-image:         linear-gradient(to bottom, #080808 0%, #0f0f0f 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);
+  background-repeat: repeat-x;
+  -webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
+          box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
+}
+.navbar-inverse .navbar-brand,
+.navbar-inverse .navbar-nav > li > a {
+  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
+}
+.navbar-static-top,
+.navbar-fixed-top,
+.navbar-fixed-bottom {
+  border-radius: 0;
+}
+.alert {
+  text-shadow: 0 1px 0 rgba(255, 255, 255, .2);
+  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
+          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
+}
+.alert-success {
+  background-image: -webkit-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);
+  background-image:      -o-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#c8e5bc));
+  background-image:         linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);
+  background-repeat: repeat-x;
+  border-color: #b2dba1;
+}
+.alert-info {
+  background-image: -webkit-linear-gradient(top, #d9edf7 0%, #b9def0 100%);
+  background-image:      -o-linear-gradient(top, #d9edf7 0%, #b9def0 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#b9def0));
+  background-image:         linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);
+  background-repeat: repeat-x;
+  border-color: #9acfea;
+}
+.alert-warning {
+  background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);
+  background-image:      -o-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#f8efc0));
+  background-image:         linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);
+  background-repeat: repeat-x;
+  border-color: #f5e79e;
+}
+.alert-danger {
+  background-image: -webkit-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);
+  background-image:      -o-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#e7c3c3));
+  background-image:         linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);
+  background-repeat: repeat-x;
+  border-color: #dca7a7;
+}
+.progress {
+  background-image: -webkit-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
+  background-image:      -o-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#f5f5f5));
+  background-image:         linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);
+  background-repeat: repeat-x;
+}
+.progress-bar {
+  background-image: -webkit-linear-gradient(top, #428bca 0%, #3071a9 100%);
+  background-image:      -o-linear-gradient(top, #428bca 0%, #3071a9 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#428bca), to(#3071a9));
+  background-image:         linear-gradient(to bottom, #428bca 0%, #3071a9 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0);
+  background-repeat: repeat-x;
+}
+.progress-bar-success {
+  background-image: -webkit-linear-gradient(top, #5cb85c 0%, #449d44 100%);
+  background-image:      -o-linear-gradient(top, #5cb85c 0%, #449d44 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#449d44));
+  background-image:         linear-gradient(to bottom, #5cb85c 0%, #449d44 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);
+  background-repeat: repeat-x;
+}
+.progress-bar-info {
+  background-image: -webkit-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);
+  background-image:      -o-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#31b0d5));
+  background-image:         linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);
+  background-repeat: repeat-x;
+}
+.progress-bar-warning {
+  background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);
+  background-image:      -o-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#ec971f));
+  background-image:         linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);
+  background-repeat: repeat-x;
+}
+.progress-bar-danger {
+  background-image: -webkit-linear-gradient(top, #d9534f 0%, #c9302c 100%);
+  background-image:      -o-linear-gradient(top, #d9534f 0%, #c9302c 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c9302c));
+  background-image:         linear-gradient(to bottom, #d9534f 0%, #c9302c 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);
+  background-repeat: repeat-x;
+}
+.progress-bar-striped {
+  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
+  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
+  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
+}
+.list-group {
+  border-radius: 4px;
+  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
+          box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
+}
+.list-group-item.active,
+.list-group-item.active:hover,
+.list-group-item.active:focus {
+  text-shadow: 0 -1px 0 #3071a9;
+  background-image: -webkit-linear-gradient(top, #428bca 0%, #3278b3 100%);
+  background-image:      -o-linear-gradient(top, #428bca 0%, #3278b3 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#428bca), to(#3278b3));
+  background-image:         linear-gradient(to bottom, #428bca 0%, #3278b3 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3278b3', GradientType=0);
+  background-repeat: repeat-x;
+  border-color: #3278b3;
+}
+.list-group-item.active .badge,
+.list-group-item.active:hover .badge,
+.list-group-item.active:focus .badge {
+  text-shadow: none;
+}
+.panel {
+  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
+          box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
+}
+.panel-default > .panel-heading {
+  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
+  background-image:      -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));
+  background-image:         linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
+  background-repeat: repeat-x;
+}
+.panel-primary > .panel-heading {
+  background-image: -webkit-linear-gradient(top, #428bca 0%, #357ebd 100%);
+  background-image:      -o-linear-gradient(top, #428bca 0%, #357ebd 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#428bca), to(#357ebd));
+  background-image:         linear-gradient(to bottom, #428bca 0%, #357ebd 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0);
+  background-repeat: repeat-x;
+}
+.panel-success > .panel-heading {
+  background-image: -webkit-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);
+  background-image:      -o-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#d0e9c6));
+  background-image:         linear-gradient(to bottom, #dff0d8 0%, #d0e9c6 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);
+  background-repeat: repeat-x;
+}
+.panel-info > .panel-heading {
+  background-image: -webkit-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);
+  background-image:      -o-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#c4e3f3));
+  background-image:         linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);
+  background-repeat: repeat-x;
+}
+.panel-warning > .panel-heading {
+  background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);
+  background-image:      -o-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#faf2cc));
+  background-image:         linear-gradient(to bottom, #fcf8e3 0%, #faf2cc 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);
+  background-repeat: repeat-x;
+}
+.panel-danger > .panel-heading {
+  background-image: -webkit-linear-gradient(top, #f2dede 0%, #ebcccc 100%);
+  background-image:      -o-linear-gradient(top, #f2dede 0%, #ebcccc 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#ebcccc));
+  background-image:         linear-gradient(to bottom, #f2dede 0%, #ebcccc 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);
+  background-repeat: repeat-x;
+}
+.well {
+  background-image: -webkit-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
+  background-image:      -o-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
+  background-image: -webkit-gradient(linear, left top, left bottom, from(#e8e8e8), to(#f5f5f5));
+  background-image:         linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);
+  background-repeat: repeat-x;
+  border-color: #dcdcdc;
+  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
+          box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
+}
+/*# sourceMappingURL=bootstrap-theme.css.map */

File diff suppressed because it is too large
+ 1 - 0
sources/public/bootstrap/css/bootstrap-theme.css.map


File diff suppressed because it is too large
+ 5 - 0
sources/public/bootstrap/css/bootstrap-theme.min.css


File diff suppressed because it is too large
+ 6358 - 0
sources/public/bootstrap/css/bootstrap.css


File diff suppressed because it is too large
+ 1 - 0
sources/public/bootstrap/css/bootstrap.css.map


File diff suppressed because it is too large
+ 5 - 0
sources/public/bootstrap/css/bootstrap.min.css


BIN
sources/public/bootstrap/fonts/glyphicons-halflings-regular.eot


File diff suppressed because it is too large
+ 229 - 0
sources/public/bootstrap/fonts/glyphicons-halflings-regular.svg


BIN
sources/public/bootstrap/fonts/glyphicons-halflings-regular.ttf


BIN
sources/public/bootstrap/fonts/glyphicons-halflings-regular.woff


File diff suppressed because it is too large
+ 2276 - 0
sources/public/bootstrap/js/bootstrap.js


File diff suppressed because it is too large
+ 7 - 0
sources/public/bootstrap/js/bootstrap.min.js


+ 13 - 0
sources/public/bootstrap/js/npm.js

@@ -0,0 +1,13 @@
+// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
+require('../../js/transition.js')
+require('../../js/alert.js')
+require('../../js/button.js')
+require('../../js/carousel.js')
+require('../../js/collapse.js')
+require('../../js/dropdown.js')
+require('../../js/modal.js')
+require('../../js/tooltip.js')
+require('../../js/popover.js')
+require('../../js/scrollspy.js')
+require('../../js/tab.js')
+require('../../js/affix.js')

+ 28 - 0
sources/public/css/bootstrap-toggle.min.css

@@ -0,0 +1,28 @@
+/*! ========================================================================
+ * Bootstrap Toggle: bootstrap-toggle.css v2.0.0
+ * http://www.bootstraptoggle.com
+ * ========================================================================
+ * Copyright 2014 Min Hur, The New York Times Company
+ * Licensed under MIT
+ * ======================================================================== */
+.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px}
+.toggle{position:relative;overflow:hidden}
+.toggle input[type=checkbox]{display:none}
+.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none}
+.toggle.off .toggle-group{left:-100%}
+.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0}
+.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0}
+.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px}
+.toggle.btn{min-width:59px;min-height:34px}
+.toggle-on.btn{padding-right:24px}
+.toggle-off.btn{padding-left:24px}
+.toggle.btn-lg{min-width:79px;min-height:45px}
+.toggle-on.btn-lg{padding-right:31px}
+.toggle-off.btn-lg{padding-left:31px}
+.toggle-handle.btn-lg{width:40px}
+.toggle.btn-sm{min-width:50px;min-height:30px}
+.toggle-on.btn-sm{padding-right:20px}
+.toggle-off.btn-sm{padding-left:20px}
+.toggle.btn-xs{min-width:35px;min-height:22px}
+.toggle-on.btn-xs{padding-right:12px}
+.toggle-off.btn-xs{padding-left:12px}

+ 45 - 0
sources/public/css/style.css

@@ -0,0 +1,45 @@
+li.status-info {
+  color: #5BC0DE;
+}
+
+li.status-warning {
+  color: #D9534F;
+}
+
+li.status-danger {
+  color: #D9534F;
+}
+
+li.status-success {
+  color: #5CB85C;
+}
+
+img#status-loading {
+  display: none;
+  padding-right: 5px;
+}
+
+img#save-loading {
+  display: none;
+  margin-left: 5px;
+}
+
+div#status {
+  display: none;
+  margin-top: 10px;
+}
+
+div#status ul {
+  list-style-type: none;
+  padding: 0;
+  margin: 0;
+}
+
+div#github {
+  margin: -10px 0 20px 20px;
+  background: url(../img/github.png) no-repeat 0 4px;
+}
+
+div#github a {
+  margin-left: 17px;
+}

BIN
sources/public/img/github.png


BIN
sources/public/img/loading.gif


File diff suppressed because it is too large
+ 4 - 0
sources/public/jquery/jquery-2.1.1.min.js


File diff suppressed because it is too large
+ 9 - 0
sources/public/js/bootstrap-toggle.min.js


+ 57 - 0
sources/public/js/custom.js

@@ -0,0 +1,57 @@
+$(document).ready(function() {
+  $('.btn-group').button();
+  $('[data-toggle="tooltip"]').tooltip();
+
+  $('.fileinput').click(function() {
+    var realinputid = '#' + $(this).attr('id').replace(/_chooser.*/, '');
+    $(realinputid).click();
+  });
+
+  $('input[type="file"]').change(function() {
+    var choosertxtid = '#' + $(this).attr('id') + '_choosertxt';
+
+    $(choosertxtid).val($(this).val().replace(/^.*[\/\\]/, ''));
+  });
+
+  $('.dropdown-menu li').click(function() {
+    var menu = $(this).parent();
+    var items = menu.children();
+    var button = menu.prev();
+    var input = button.prev();
+
+    items.removeClass('active');
+    $(this).addClass('active');
+
+    button.text($(this).text());
+    button.append(' <span class="caret"></span>');
+
+    input.attr('value', $(this).text());
+  });
+
+  $('.switch').bootstrapToggle();
+
+  $('#save').click(function() {
+    $(this).prop('disabled', true);
+    $('#save-loading').show();
+    $('#form').submit();
+  });
+
+  $('#status .close').click(function() {
+    $(this).parent().hide();
+  });
+
+  $('#statusbtn').click(function() {
+    if($('#status-loading').is(':hidden')) {
+      $('#status').hide();
+      $('#status-loading').show();
+
+      $.ajax({
+        url: '?/status',
+      }).done(function(data) {
+        $('#status-loading').hide();
+        $('#status-text').html('<ul>' + data + '</ul>');
+        $('#status').show('slow');
+      });
+    }
+  });
+});

+ 45 - 0
sources/views/layout.html.php

@@ -0,0 +1,45 @@
+<!doctype html>
+<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
+<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
+<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
+<!--[if gt IE 8]><!--> <html class="no-js" lang="<?= $locale ?>"> <!--<![endif]-->
+<head>
+  <meta charset="utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+  <title>Wifi Hotspot <? echo (isset($title)) ? "| ".$title : "" ?></title>
+  <meta name="viewport" content="width=device-width">
+  <link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap.min.css" rel="stylesheet">
+  <link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
+  <link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/css/bootstrap-toggle.min.css" rel="stylesheet">
+  <link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/css/style.css" rel="stylesheet">
+  <script src="<?= PUBLIC_DIR ?>/jquery/jquery-2.1.1.min.js"></script>
+  <script src="<?= PUBLIC_DIR ?>/bootstrap/js/bootstrap.min.js"></script>
+  <script src="<?= PUBLIC_DIR ?>/js/bootstrap-toggle.min.js"></script>
+  <script src="<?= PUBLIC_DIR ?>/js/custom.js"></script>
+</head>
+<body>
+  <div class="container">
+    <? if(isset($flash['error'])): ?>
+      <div class="alert alert-dismissible alert-danger fade in" style="margin-top: 20px" role="alert">
+        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+        <strong><?= T_('Error') ?>:</strong> <?= $flash['error'] ?>
+      </div>
+    <? elseif(isset($flash['notice'])): ?>
+      <div class="alert alert-dismissible alert-info fade in" style="margin-top: 20px" role="alert">
+        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+        <strong><?= T_('Notice') ?>:</strong> <?= $flash['notice'] ?>
+      </div>
+    <? elseif(isset($flash['success'])): ?>
+      <div class="alert alert-dismissible alert-success fade in" style="margin-top: 20px" role="alert">
+        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+        <?= $flash['success'] ?>
+      </div>
+    <? endif; ?>
+
+    <?= $content?>
+
+    <hr />
+    <div id="github"><a href="https://github.com/bleuchtang/torclient_ynh"><?= T_('Any problem? Contribute!') ?></a> - AGPL 3.0</div>
+  </div>
+</body>
+</html>

+ 46 - 0
sources/views/settings.html.php

@@ -0,0 +1,46 @@
+<h2><?= T_("Tor client configuration") ?></h2>
+<?php if($status): ?>
+  <span class="label label-success" data-toggle="tooltip" data-title="<?= T_('This is a fast status. Click on More details to show the complete status.') ?>"><?= T_('Running') ?></span>
+<?php else: ?>
+  <span class="label label-danger" data-toggle="tooltip" data-title="<?= T_('This is a fast status. Click on More details to show the complete status.') ?>"><?= T_('Not Running') ?></span>
+<?php endif; ?>
+
+ &nbsp; <img src="public/img/loading.gif" id="status-loading" alt="Loading..." /><a href="#" id="statusbtn" data-toggle="tooltip" data-title="<?= T_('Loading complete status may take a few minutes. Be patient.') ?>"><?= T_('More details') ?></a>
+
+<div id="status" class="alert alert-dismissible alert-info fade in" style="margin-top: 10px" role="alert">
+  <button type="button" class="close"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+  <div id="status-text"></div>
+</div>
+
+<hr />
+
+<div class="row">
+  <div class="col-sm-offset-2 col-sm-8">
+    <form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form" id="form">
+      <input type="hidden" name="_method" value="put" />
+
+      <div class="panel panel-default">
+        <div class="panel-heading">
+          <h3 class="panel-title"><?= T_("Wifi") ?></h3>
+        </div>
+
+        <div style="padding: 14px 14px 0 10px">
+  
+          <div class="form-group">
+            <label for="tro_active" class="col-sm-3 control-label"><?= T_('Active') ?></label>
+            <div class="col-sm-9 input-group-btn" data-toggle="tooltip" data-title="<?= T_('set tor enable or disable') ?>">
+              <div class="input-group">
+                <input type="checkbox" class="form-control switch" name="status" id="status" value="1" <?= $status == 1 ? 'checked="checked"' : '' ?> />
+              </div>
+            </div>
+          </div>
+	</div>
+      </div>
+      <div class="form-group">
+        <div style="text-align: center">
+          <button type="submit" class="btn btn-default" data-toggle="tooltip" id="save" data-title="<?= T_('Reloading may take a few minutes. Be patient.') ?>"><?= T_('Save and reload') ?></button> <img src="public/img/loading.gif" id="save-loading" alt="Loading..." />
+        </div>
+      </div>
+    </form>
+  </div>
+</div>