Browse Source

updated LICENSE and README + upload of the whole project files and sql dump

Francesco Arcarese 1 year ago
parent
commit
7e50298209
100 changed files with 16031 additions and 141 deletions
  1. 1
    0
      .gitignore
  2. 14
    123
      LICENSE
  3. 53
    1
      README.md
  4. 0
    14
      WEB/LICENSE
  5. 0
    3
      WEB/README.md
  6. 75
    0
      bin/cake
  7. 27
    0
      bin/cake.bat
  8. 12
    0
      bin/cake.php
  9. 13
    0
      client.ini.dist
  10. 53
    0
      composer.json
  11. 4227
    0
      composer.lock
  12. 38
    0
      config/.env.default
  13. 386
    0
      config/app.default.php
  14. 393
    0
      config/app.php
  15. 203
    0
      config/bootstrap.php
  16. 28
    0
      config/bootstrap_cli.php
  17. 89
    0
      config/paths.php
  18. 41
    0
      config/requirements.php
  19. 179
    0
      config/routes.php
  20. 18
    0
      config/schema/i18n.sql
  21. 15
    0
      config/schema/sessions.sql
  22. 15
    0
      index.php
  23. 41
    0
      phpunit.xml.dist
  24. 0
    0
      plugins/empty
  25. 165
    0
      sql/prosume.sql
  26. 85
    0
      src/Application.php
  27. 246
    0
      src/Console/Installer.php
  28. 156
    0
      src/Controller/ApiController.php
  29. 84
    0
      src/Controller/AppController.php
  30. 31
    0
      src/Controller/BlocksController.php
  31. 0
    0
      src/Controller/Component/empty
  32. 72
    0
      src/Controller/ErrorController.php
  33. 228
    0
      src/Controller/MainController.php
  34. 69
    0
      src/Controller/PagesController.php
  35. 283
    0
      src/Controller/SSPController.php
  36. 160
    0
      src/Controller/UsersController.php
  37. 111
    0
      src/Controller/XhrController.php
  38. 0
    0
      src/Model/Behavior/empty
  39. 13
    0
      src/Model/Entity/Block.php
  40. 55
    0
      src/Model/Entity/User.php
  41. 10
    0
      src/Model/Table/BlocksTable.php
  42. 93
    0
      src/Model/Table/UsersTable.php
  43. 81
    0
      src/Shell/ConsoleShell.php
  44. 34
    0
      src/Template/Blocks/index.ctp
  45. 19
    0
      src/Template/Blocks/view.ctp
  46. 34
    0
      src/Template/Blocks/wallet.ctp
  47. 1
    0
      src/Template/Cell/empty
  48. 1281
    0
      src/Template/Common/adminlte.ctp
  49. 1276
    0
      src/Template/Common/main.ctp
  50. 329
    0
      src/Template/Element/Eprosume/Views/charts.ctp
  51. 243
    0
      src/Template/Element/Eprosume/Views/datatable.ctp
  52. 75
    0
      src/Template/Element/Eprosume/Views/set_price.ctp
  53. 73
    0
      src/Template/Element/Eprosume/Views/transfer.ctp
  54. 22
    0
      src/Template/Element/Eprosume/chartsToolbar.ctp
  55. 44
    0
      src/Template/Element/Eprosume/dataTableToolbar.ctp
  56. 6
    0
      src/Template/Element/Eprosume/footer.ctp
  57. 38
    0
      src/Template/Element/Eprosume/header.ctp
  58. 34
    0
      src/Template/Element/Eprosume/leftSideColumn.ctp
  59. 21
    0
      src/Template/Element/Eprosume/mainHeader.ctp
  60. 18
    0
      src/Template/Element/Eprosume/scripts.ctp
  61. 10
    0
      src/Template/Element/Flash/default.ctp
  62. 6
    0
      src/Template/Element/Flash/error.ctp
  63. 6
    0
      src/Template/Element/Flash/success.ctp
  64. 20
    0
      src/Template/Email/html/default.ctp
  65. 16
    0
      src/Template/Email/text/default.ctp
  66. 76
    0
      src/Template/Eprosume/standard.ctp
  67. 38
    0
      src/Template/Error/error400.ctp
  68. 43
    0
      src/Template/Error/error500.ctp
  69. 24
    0
      src/Template/Layout/Email/html/default.ctp
  70. 16
    0
      src/Template/Layout/Email/text/default.ctp
  71. 16
    0
      src/Template/Layout/ajax.ctp
  72. 58
    0
      src/Template/Layout/default.ctp
  73. 39
    0
      src/Template/Layout/eprosume_error.ctp
  74. 47
    0
      src/Template/Layout/error.ctp
  75. 11
    0
      src/Template/Layout/rss/default.ctp
  76. 86
    0
      src/Template/Main/block_i_d.ctp
  77. 66
    0
      src/Template/Main/charts.ctp
  78. 84
    0
      src/Template/Main/hgm.ctp
  79. 350
    0
      src/Template/Main/hgm_i_d.ctp
  80. 75
    0
      src/Template/Main/history.ctp
  81. 111
    0
      src/Template/Main/history_daily.ctp
  82. 91
    0
      src/Template/Main/history_hgm.ctp
  83. 4
    0
      src/Template/Main/index.ctp
  84. 72
    0
      src/Template/Main/payment.ctp
  85. 76
    0
      src/Template/Main/price_history.ctp
  86. 89
    0
      src/Template/Main/profile.ctp
  87. 95
    0
      src/Template/Main/set_price.ctp
  88. 128
    0
      src/Template/Main/tabellasemplice.html
  89. 150
    0
      src/Template/Main/transfer.ctp
  90. 16
    0
      src/Template/Pages/eprosume.ctp
  91. 276
    0
      src/Template/Pages/home.ctp
  92. 1271
    0
      src/Template/Pages/index.html
  93. 88
    0
      src/Template/Users/add.ctp
  94. 95
    0
      src/Template/Users/edit.ctp
  95. 113
    0
      src/Template/Users/index.ctp
  96. 62
    0
      src/Template/Users/login.ctp
  97. 97
    0
      src/Template/Users/view.ctp
  98. 506
    0
      src/Utility/EprosumeModel.php
  99. 193
    0
      src/Utility/WalletEprosumeModel.php
  100. 0
    0
      src/View/AjaxView.php

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+client.ini

+ 14
- 123
LICENSE View File

@@ -1,123 +1,14 @@
1
-GNU AFFERO GENERAL PUBLIC LICENSE
2
-Version 3, 19 November 2007
3
-Copyright (C) 2007 Free Software Foundation, Inc. <http s ://fsf.org/>
4
-Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
5
-Preamble
6
-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.
7
-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.
8
-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.
9
-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.
10
-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.
11
-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.
12
-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.
13
-The precise terms and conditions for copying, distribution and modification follow.
14
-TERMS AND CONDITIONS
15
-   0. Definitions.
16
-   "This License" refers to version 3 of the GNU Affero General Public License.
17
-   "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
18
-   "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.
19
-   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.
20
-   A "covered work" means either the unmodified Program or a work based on the Program.
21
-   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.
22
-   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.
23
-   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.
24
-   1. Source Code.
25
-   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.
26
-   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.
27
-   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.
28
-   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
29
-   subprograms and other parts of the work.
30
-   The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
31
-   The Corresponding Source for a work in source code form is that same work.
32
-   2. Basic Permissions.
33
-   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.
34
-   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.
35
-   Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
36
-   3. Protecting Users' Legal Rights From Anti-Circumvention Law.
37
-   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.
38
-   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.
39
-   4. Conveying Verbatim Copies.
40
-   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.
41
-   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.
42
-   5. Conveying Modified Source Versions.
43
-   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:
44
-      a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
45
-      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".
46
-      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.
47
-      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.
48
-   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.
49
-   6. Conveying Non-Source Forms.
50
-   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:
51
-      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.
52
-      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.
53
-      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.
54
-      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.
55
-      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.
56
-   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.
57
-   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.
58
-   "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.
59
-   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).
60
-   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.
61
-   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.
62
-   7. Additional Terms.
63
-   "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.
64
-   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.
65
-   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:
66
-      a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
67
-      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
68
-      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
69
-      d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
70
-      e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
71
-      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.
72
-   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.
73
-   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.
74
-   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.
75
-   8. Termination.
76
-   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).
77
-   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.
78
-   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.
79
-   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.
80
-   9. Acceptance Not Required for Having Copies.
81
-   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.
82
-   10. Automatic Licensing of Downstream Recipients.
83
-   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.
84
-   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.
85
-   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.
86
-   11. Patents.
87
-   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".
88
-   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.
89
-   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.
90
-   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 s ue 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.
91
-   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
92
-   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.
93
-   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.
94
-   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.
95
-   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.
96
-   12. No Surrender of Others' Freedom.
97
-   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
98
-   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.
99
-   13. Remote Network Interaction; Use with the GNU General Public License.
100
-   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.
101
-   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.
102
-   14. Revised Versions of this License.
103
-   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.
104
-   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.
105
-   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.
106
-   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.
107
-   15. Disclaimer of Warranty.
108
-   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.
109
-   16. Limitation of Liability.
110
-   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.
111
-   17. Interpretation of Sections 15 and 16.
112
-   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
113
-How to Apply These Terms to Your New Programs
114
-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.
115
-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.
116
-<one line to give the program's name and a brief idea of what it does.>
117
-Copyright (C) <year> <name of author>
118
-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.
119
-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.
120
-You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http s ://www.gnu.org/licenses/>.
121
-Also add information on how to contact you by electronic and paper mail.
122
-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.
123
-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 s ://www.gnu.org/licenses/>.
1
+
2
+WEB Interfaces of PROSUME srl GridAbility Solution
3
+Copyright (C) 2019 PROSUME srl, Milan, Italy: https://prosume.io
4
+
5
+This program is free software: you can redistribute it and/or modify it under 
6
+the terms of the GNU Affero General Public License as published by the 
7
+Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8
+
9
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
10
+without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
11
+See the GNU Affero General Public License for more details.
12
+You should have received a copy of the GNU Affero General Public License along with this program. 
13
+If not, see <http s ://www.gnu.org/licenses/>.
14
+

+ 53
- 1
README.md View File

@@ -1,3 +1,55 @@
1 1
 # WEB
2 2
 
3
-Web Interfaces of PROSUME
3
+Web Interfaces of PROSUME
4
+
5
+## Stack
6
+The Web Interfaces is built upon CakePHP v3.7 Framework. The `composer.lock` is provided as the related vendors files.
7
+Javascript and CSS frameworks/library are also provided in the `webroot/` directory.
8
+The Web Interfaces are backed by a MariaDB and the schema is provided in the `sql/` directory.
9
+The HTTP server could be Apache or Nginx or else. For Apache the needed `.htaccess` files are provided.
10
+An example of Nginx configuration could be
11
+
12
+    server {
13
+        listen 80;
14
+        listen [::]:80;
15
+
16
+        server_name *serverName*;
17
+        server_tokens off;
18
+
19
+        client_max_body_size 128M;
20
+        
21
+        root /path/to/webroot;
22
+            index index.php index.html index.htm;
23
+
24
+        error_log  /path/to/error.log  warn;
25
+        access_log  /path/to/access.log  combined;
26
+
27
+        location / {
28
+            try_files $uri $uri/ /index.php?$uri&$args;
29
+        }
30
+
31
+        location = /robots.txt {
32
+                log_not_found off;
33
+                access_log off;
34
+        }
35
+
36
+        location ~ \.php$ {
37
+                set $newurl $request_uri;
38
+                include fastcgi_params;
39
+                fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
40
+                fastcgi_pass unix:/var/run/php/php*VERSION*-fpm.sock;
41
+                try_files $uri =404;
42
+                fastcgi_index index.php;
43
+                fastcgi_param REQUEST_URI $newurl;
44
+        }
45
+    }
46
+
47
+## Configuration
48
+- `./client.ini.dist` has to be copied as `client.ini` and the 3 variables of the wallet group has to be changed setting the path to the utility account key, the path of configuration file in YAML format and the path of the prosume-cli executable. Change also the databaseb settings in the related group.
49
+- in the database table `conf` change as needed the values accordingly to your needs pointing out the name of the utility account and the settings for the automatic top ups for both PRS and TFT tokens.
50
+- `./logs/` and `./tmp` directory must be writable by the user that run the web server.
51
+
52
+## Cronjob
53
+The following cron has to be set for an user able to execute a php command and to write in the `./locks` directory
54
+
55
+    */5 * * * * /usr/bin/php -f /path/to/webroot/readhistory.php

+ 0
- 14
WEB/LICENSE View File

@@ -1,14 +0,0 @@
1
-
2
-WEB Interfaces of PROSUME srl GridAbility Solution
3
-Copyright (C) 2019 PROSUME srl, Milan, Italy: https://prosume.io
4
-
5
-This program is free software: you can redistribute it and/or modify it under 
6
-the terms of the GNU Affero General Public License as published by the 
7
-Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8
-
9
-This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
10
-without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
11
-See the GNU Affero General Public License for more details.
12
-You should have received a copy of the GNU Affero General Public License along with this program. 
13
-If not, see <http s ://www.gnu.org/licenses/>.
14
-

+ 0
- 3
WEB/README.md View File

@@ -1,3 +0,0 @@
1
-# WEB
2
-
3
-Web Interfaces of PROSUME

+ 75
- 0
bin/cake View File

@@ -0,0 +1,75 @@
1
+#!/usr/bin/env sh
2
+################################################################################
3
+#
4
+# Cake is a shell script for invoking CakePHP shell commands
5
+#
6
+# CakePHP(tm) :  Rapid Development Framework (https://cakephp.org)
7
+# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
8
+#
9
+# Licensed under The MIT License
10
+# For full copyright and license information, please see the LICENSE.txt
11
+# Redistributions of files must retain the above copyright notice.
12
+#
13
+# @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
14
+# @link          https://cakephp.org CakePHP(tm) Project
15
+# @since         1.2.0
16
+# @license       https://opensource.org/licenses/mit-license.php MIT License
17
+#
18
+################################################################################
19
+
20
+# Canonicalize by following every symlink of the given name recursively
21
+canonicalize() {
22
+    NAME="$1"
23
+    if [ -f "$NAME" ]
24
+    then
25
+        DIR=$(dirname -- "$NAME")
26
+        NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
27
+    fi
28
+    while [ -h "$NAME" ]; do
29
+        DIR=$(dirname -- "$NAME")
30
+        SYM=$(readlink "$NAME")
31
+        NAME=$(cd "$DIR" > /dev/null && cd $(dirname -- "$SYM") > /dev/null && pwd)/$(basename -- "$SYM")
32
+    done
33
+    echo "$NAME"
34
+}
35
+
36
+# Find a CLI version of PHP
37
+findCliPhp() {
38
+    for TESTEXEC in php php-cli /usr/local/bin/php
39
+    do
40
+        SAPI=`echo "<?= PHP_SAPI ?>" | $TESTEXEC 2>/dev/null`
41
+        if [ "$SAPI" = "cli" ]
42
+        then
43
+            echo $TESTEXEC
44
+            return
45
+        fi
46
+    done
47
+    echo "Failed to find a CLI version of PHP; falling back to system standard php executable" >&2
48
+    echo "php";
49
+}
50
+
51
+# If current path is a symlink, resolve to real path
52
+realname="$0"
53
+if [ -L "$realname" ] 
54
+then
55
+	realname=$(readlink -f "$0")
56
+fi
57
+
58
+CONSOLE=$(dirname -- "$(canonicalize "$realname")")
59
+APP=$(dirname "$CONSOLE")
60
+
61
+# If your CLI PHP is somewhere that this doesn't find, you can define a PHP environment
62
+# variable with the correct path in it.
63
+if [ -z "$PHP" ]
64
+then
65
+    PHP=$(findCliPhp)
66
+fi
67
+
68
+if [ $(basename $realname) != 'cake' ]
69
+then
70
+    exec $PHP "$CONSOLE"/cake.php $(basename $realname) "$@"
71
+else
72
+    exec $PHP "$CONSOLE"/cake.php "$@"
73
+fi
74
+
75
+exit

+ 27
- 0
bin/cake.bat View File

@@ -0,0 +1,27 @@
1
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2
+::
3
+:: Cake is a Windows batch script for invoking CakePHP shell commands
4
+::
5
+:: CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
6
+:: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
7
+::
8
+:: Licensed under The MIT License
9
+:: Redistributions of files must retain the above copyright notice.
10
+::
11
+:: @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
12
+:: @link          https://cakephp.org CakePHP(tm) Project
13
+:: @since         2.0.0
14
+:: @license       https://opensource.org/licenses/mit-license.php MIT License
15
+::
16
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
17
+
18
+@echo off
19
+
20
+SET app=%0
21
+SET lib=%~dp0
22
+
23
+php "%lib%cake.php" %*
24
+
25
+echo.
26
+
27
+exit /B %ERRORLEVEL%

+ 12
- 0
bin/cake.php View File

@@ -0,0 +1,12 @@
1
+#!/usr/bin/php -q
2
+<?php
3
+// Check platform requirements
4
+require dirname(__DIR__) . '/config/requirements.php';
5
+require dirname(__DIR__) . '/vendor/autoload.php';
6
+
7
+use App\Application;
8
+use Cake\Console\CommandRunner;
9
+
10
+// Build the runner with an application and root executable name.
11
+$runner = new CommandRunner(new Application(dirname(__DIR__) . '/config'), 'cake');
12
+exit($runner->run($argv));

+ 13
- 0
client.ini.dist View File

@@ -0,0 +1,13 @@
1
+;<?php
2
+;die();
3
+charset=utf8mb4
4
+host=localhost
5
+name=dbname
6
+pass=dbpassword
7
+user=dbuser
8
+[wallet]
9
+account = /path/to/utility_account.txt
10
+configuration = /path/to/configuration_file.yaml
11
+executable = /path/to/cli_executable
12
+;*/
13
+;?>

+ 53
- 0
composer.json View File

@@ -0,0 +1,53 @@
1
+{
2
+    "name": "cakephp/app",
3
+    "description": "CakePHP skeleton app",
4
+    "homepage": "https://cakephp.org",
5
+    "type": "project",
6
+    "license": "MIT",
7
+    "require": {
8
+        "php": ">=5.6",
9
+        "cakephp/cakephp": "3.7.*",
10
+        "cakephp/migrations": "^2.0.0",
11
+        "cakephp/plugin-installer": "^1.0",
12
+        "mobiledetect/mobiledetectlib": "2.*"
13
+    },
14
+    "require-dev": {
15
+        "cakephp/bake": "^1.9.0",
16
+        "cakephp/cakephp-codesniffer": "^3.0",
17
+        "cakephp/debug_kit": "^3.17.0",
18
+        "josegonzalez/dotenv": "3.*",
19
+        "phpunit/phpunit": "^5|^6",
20
+        "psy/psysh": "@stable"
21
+    },
22
+    "suggest": {
23
+        "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
24
+        "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility."
25
+    },
26
+    "autoload": {
27
+        "psr-4": {
28
+            "App\\": "src/"
29
+        }
30
+    },
31
+    "autoload-dev": {
32
+        "psr-4": {
33
+            "App\\Test\\": "tests/",
34
+            "Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
35
+        }
36
+    },
37
+    "scripts": {
38
+        "post-install-cmd": "App\\Console\\Installer::postInstall",
39
+        "post-create-project-cmd": "App\\Console\\Installer::postInstall",
40
+        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
41
+        "check": [
42
+            "@test",
43
+            "@cs-check"
44
+        ],
45
+        "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
46
+        "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
47
+        "test": "phpunit --colors=always"
48
+    },
49
+    "prefer-stable": true,
50
+    "config": {
51
+        "sort-packages": true
52
+    }
53
+}

+ 4227
- 0
composer.lock
File diff suppressed because it is too large
View File


+ 38
- 0
config/.env.default View File

@@ -0,0 +1,38 @@
1
+#!/usr/bin/env bash
2
+# Used as a default to seed config/.env which
3
+# enables you to use environment variables to configure
4
+# the aspects of your application that vary by
5
+# environment.
6
+#
7
+# Having this file in production is considered a **SECURITY RISK** and also decreases
8
+# the boostrap performance of your application.
9
+#
10
+# To use this file, first copy it into `config/.env`. Also ensure the related
11
+# code block for loading this file is uncommented in `config/boostrap.php`
12
+#
13
+# In development .env files are parsed by PHP
14
+# and set into the environment. This provides a simpler
15
+# development workflow over standard environment variables.
16
+export APP_NAME="__APP_NAME__"
17
+export DEBUG="true"
18
+export APP_ENCODING="UTF-8"
19
+export APP_DEFAULT_LOCALE="en_US"
20
+export APP_DEFAULT_TIMEZONE="UTC"
21
+export SECURITY_SALT="__SALT__"
22
+
23
+# Uncomment these to define cache configuration via environment variables.
24
+#export CACHE_DURATION="+2 minutes"
25
+#export CACHE_DEFAULT_URL="file://tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}"
26
+#export CACHE_CAKECORE_URL="file://tmp/cache/persistent?prefix=${APP_NAME}_cake_core&serialize=true&duration=${CACHE_DURATION}"
27
+#export CACHE_CAKEMODEL_URL="file://tmp/cache/models?prefix=${APP_NAME}_cake_model&serialize=true&duration=${CACHE_DURATION}"
28
+
29
+# Uncomment these to define email transport configuration via environment variables.
30
+#export EMAIL_TRANSPORT_DEFAULT_URL=""
31
+
32
+# Uncomment these to define database configuration via environment variables.
33
+#export DATABASE_URL="mysql://my_app:secret@localhost/${APP_NAME}?encoding=utf8&timezone=UTC&cacheMetadata=true&quoteIdentifiers=false&persistent=false"
34
+#export DATABASE_TEST_URL="mysql://my_app:secret@localhost/test_${APP_NAME}?encoding=utf8&timezone=UTC&cacheMetadata=true&quoteIdentifiers=false&persistent=false"
35
+
36
+# Uncomment these to define logging configuration via environment variables.
37
+#export LOG_DEBUG_URL="file://logs/?levels[]=notice&levels[]=info&levels[]=debug&file=debug"
38
+#export LOG_ERROR_URL="file://logs/?levels[]=warning&levels[]=error&levels[]=critical&levels[]=alert&levels[]=emergency&file=error"

+ 386
- 0
config/app.default.php View File

@@ -0,0 +1,386 @@
1
+<?php
2
+return [
3
+    /**
4
+     * Debug Level:
5
+     *
6
+     * Production Mode:
7
+     * false: No error messages, errors, or warnings shown.
8
+     *
9
+     * Development Mode:
10
+     * true: Errors and warnings shown.
11
+     */
12
+    'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
13
+
14
+    /**
15
+     * Configure basic information about the application.
16
+     *
17
+     * - namespace - The namespace to find app classes under.
18
+     * - defaultLocale - The default locale for translation, formatting currencies and numbers, date and time.
19
+     * - encoding - The encoding used for HTML + database connections.
20
+     * - base - The base directory the app resides in. If false this
21
+     *   will be auto detected.
22
+     * - dir - Name of app directory.
23
+     * - webroot - The webroot directory.
24
+     * - wwwRoot - The file path to webroot.
25
+     * - baseUrl - To configure CakePHP to *not* use mod_rewrite and to
26
+     *   use CakePHP pretty URLs, remove these .htaccess
27
+     *   files:
28
+     *      /.htaccess
29
+     *      /webroot/.htaccess
30
+     *   And uncomment the baseUrl key below.
31
+     * - fullBaseUrl - A base URL to use for absolute links. When set to false (default)
32
+     *   CakePHP generates required value based on `HTTP_HOST` environment variable.
33
+     *   However, you can define it manually to optimize performance or if you
34
+     *   are concerned about people manipulating the `Host` header.
35
+     * - imageBaseUrl - Web path to the public images directory under webroot.
36
+     * - cssBaseUrl - Web path to the public css directory under webroot.
37
+     * - jsBaseUrl - Web path to the public js directory under webroot.
38
+     * - paths - Configure paths for non class based resources. Supports the
39
+     *   `plugins`, `templates`, `locales` subkeys, which allow the definition of
40
+     *   paths for plugins, view templates and locale files respectively.
41
+     */
42
+    'App' => [
43
+        'namespace' => 'App',
44
+        'encoding' => env('APP_ENCODING', 'UTF-8'),
45
+        'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),
46
+        'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'),
47
+        'base' => false,
48
+        'dir' => 'src',
49
+        'webroot' => 'webroot',
50
+        'wwwRoot' => WWW_ROOT,
51
+        //'baseUrl' => env('SCRIPT_NAME'),
52
+        'fullBaseUrl' => false,
53
+        'imageBaseUrl' => 'img/',
54
+        'cssBaseUrl' => 'css/',
55
+        'jsBaseUrl' => 'js/',
56
+        'paths' => [
57
+            'plugins' => [ROOT . DS . 'plugins' . DS],
58
+            'templates' => [APP . 'Template' . DS],
59
+            'locales' => [APP . 'Locale' . DS],
60
+        ],
61
+    ],
62
+
63
+    /**
64
+     * Security and encryption configuration
65
+     *
66
+     * - salt - A random string used in security hashing methods.
67
+     *   The salt value is also used as the encryption key.
68
+     *   You should treat it as extremely sensitive data.
69
+     */
70
+    'Security' => [
71
+        'salt' => env('SECURITY_SALT', '__SALT__'),
72
+    ],
73
+
74
+    /**
75
+     * Apply timestamps with the last modified time to static assets (js, css, images).
76
+     * Will append a querystring parameter containing the time the file was modified.
77
+     * This is useful for busting browser caches.
78
+     *
79
+     * Set to true to apply timestamps when debug is true. Set to 'force' to always
80
+     * enable timestamping regardless of debug value.
81
+     */
82
+    'Asset' => [
83
+        //'timestamp' => true,
84
+        // 'cacheTime' => '+1 year'
85
+    ],
86
+
87
+    /**
88
+     * Configure the cache adapters.
89
+     */
90
+    'Cache' => [
91
+        'default' => [
92
+            'className' => 'Cake\Cache\Engine\FileEngine',
93
+            'path' => CACHE,
94
+            'url' => env('CACHE_DEFAULT_URL', null),
95
+        ],
96
+
97
+        /**
98
+         * Configure the cache used for general framework caching.
99
+         * Translation cache files are stored with this configuration.
100
+         * Duration will be set to '+2 minutes' in bootstrap.php when debug = true
101
+         * If you set 'className' => 'Null' core cache will be disabled.
102
+         */
103
+        '_cake_core_' => [
104
+            'className' => 'Cake\Cache\Engine\FileEngine',
105
+            'prefix' => 'myapp_cake_core_',
106
+            'path' => CACHE . 'persistent/',
107
+            'serialize' => true,
108
+            'duration' => '+1 years',
109
+            'url' => env('CACHE_CAKECORE_URL', null),
110
+        ],
111
+
112
+        /**
113
+         * Configure the cache for model and datasource caches. This cache
114
+         * configuration is used to store schema descriptions, and table listings
115
+         * in connections.
116
+         * Duration will be set to '+2 minutes' in bootstrap.php when debug = true
117
+         */
118
+        '_cake_model_' => [
119
+            'className' => 'Cake\Cache\Engine\FileEngine',
120
+            'prefix' => 'myapp_cake_model_',
121
+            'path' => CACHE . 'models/',
122
+            'serialize' => true,
123
+            'duration' => '+1 years',
124
+            'url' => env('CACHE_CAKEMODEL_URL', null),
125
+        ],
126
+
127
+        /**
128
+         * Configure the cache for routes. The cached routes collection is built the
129
+         * first time the routes are processed via `config/routes.php`.
130
+         * Duration will be set to '+2 seconds' in bootstrap.php when debug = true
131
+         */
132
+        '_cake_routes_' => [
133
+            'className' => 'Cake\Cache\Engine\FileEngine',
134
+            'prefix' => 'myapp_cake_routes_',
135
+            'path' => CACHE,
136
+            'serialize' => true,
137
+            'duration' => '+1 years',
138
+            'url' => env('CACHE_CAKEROUTES_URL', null),
139
+        ],
140
+    ],
141
+
142
+    /**
143
+     * Configure the Error and Exception handlers used by your application.
144
+     *
145
+     * By default errors are displayed using Debugger, when debug is true and logged
146
+     * by Cake\Log\Log when debug is false.
147
+     *
148
+     * In CLI environments exceptions will be printed to stderr with a backtrace.
149
+     * In web environments an HTML page will be displayed for the exception.
150
+     * With debug true, framework errors like Missing Controller will be displayed.
151
+     * When debug is false, framework errors will be coerced into generic HTTP errors.
152
+     *
153
+     * Options:
154
+     *
155
+     * - `errorLevel` - int - The level of errors you are interested in capturing.
156
+     * - `trace` - boolean - Whether or not backtraces should be included in
157
+     *   logged errors/exceptions.
158
+     * - `log` - boolean - Whether or not you want exceptions logged.
159
+     * - `exceptionRenderer` - string - The class responsible for rendering
160
+     *   uncaught exceptions. If you choose a custom class you should place
161
+     *   the file for that class in src/Error. This class needs to implement a
162
+     *   render method.
163
+     * - `skipLog` - array - List of exceptions to skip for logging. Exceptions that
164
+     *   extend one of the listed exceptions will also be skipped for logging.
165
+     *   E.g.:
166
+     *   `'skipLog' => ['Cake\Http\Exception\NotFoundException', 'Cake\Http\Exception\UnauthorizedException']`
167
+     * - `extraFatalErrorMemory` - int - The number of megabytes to increase
168
+     *   the memory limit by when a fatal error is encountered. This allows
169
+     *   breathing room to complete logging or error handling.
170
+     */
171
+    'Error' => [
172
+        'errorLevel' => E_ALL,
173
+        'exceptionRenderer' => 'Cake\Error\ExceptionRenderer',
174
+        'skipLog' => [],
175
+        'log' => true,
176
+        'trace' => true,
177
+    ],
178
+
179
+    /**
180
+     * Email configuration.
181
+     *
182
+     * By defining transports separately from delivery profiles you can easily
183
+     * re-use transport configuration across multiple profiles.
184
+     *
185
+     * You can specify multiple configurations for production, development and
186
+     * testing.
187
+     *
188
+     * Each transport needs a `className`. Valid options are as follows:
189
+     *
190
+     *  Mail   - Send using PHP mail function
191
+     *  Smtp   - Send using SMTP
192
+     *  Debug  - Do not send the email, just return the result
193
+     *
194
+     * You can add custom transports (or override existing transports) by adding the
195
+     * appropriate file to src/Mailer/Transport. Transports should be named
196
+     * 'YourTransport.php', where 'Your' is the name of the transport.
197
+     */
198
+    'EmailTransport' => [
199
+        'default' => [
200
+            'className' => 'Cake\Mailer\Transport\MailTransport',
201
+            /*
202
+             * The following keys are used in SMTP transports:
203
+             */
204
+            'host' => 'localhost',
205
+            'port' => 25,
206
+            'timeout' => 30,
207
+            'username' => null,
208
+            'password' => null,
209
+            'client' => null,
210
+            'tls' => null,
211
+            'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
212
+        ],
213
+    ],
214
+
215
+    /**
216
+     * Email delivery profiles
217
+     *
218
+     * Delivery profiles allow you to predefine various properties about email
219
+     * messages from your application and give the settings a name. This saves
220
+     * duplication across your application and makes maintenance and development
221
+     * easier. Each profile accepts a number of keys. See `Cake\Mailer\Email`
222
+     * for more information.
223
+     */
224
+    'Email' => [
225
+        'default' => [
226
+            'transport' => 'default',
227
+            'from' => 'you@localhost',
228
+            //'charset' => 'utf-8',
229
+            //'headerCharset' => 'utf-8',
230
+        ],
231
+    ],
232
+
233
+    /**
234
+     * Connection information used by the ORM to connect
235
+     * to your application's datastores.
236
+     *
237
+     * ### Notes
238
+     * - Drivers include Mysql Postgres Sqlite Sqlserver
239
+     *   See vendor\cakephp\cakephp\src\Database\Driver for complete list
240
+     * - Do not use periods in database name - it may lead to error.
241
+     *   See https://github.com/cakephp/cakephp/issues/6471 for details.
242
+     * - 'encoding' is recommended to be set to full UTF-8 4-Byte support.
243
+     *   E.g set it to 'utf8mb4' in MariaDB and MySQL and 'utf8' for any
244
+     *   other RDBMS.
245
+     */
246
+    'Datasources' => [
247
+        'default' => [
248
+            'className' => 'Cake\Database\Connection',
249
+            'driver' => 'Cake\Database\Driver\Mysql',
250
+            'persistent' => false,
251
+            'host' => 'localhost',
252
+            /*
253
+             * CakePHP will use the default DB port based on the driver selected
254
+             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
255
+             * the following line and set the port accordingly
256
+             */
257
+            //'port' => 'non_standard_port_number',
258
+            'username' => 'my_app',
259
+            'password' => 'secret',
260
+            'database' => 'my_app',
261
+            /*
262
+             * You do not need to set this flag to use full utf-8 encoding (internal default since CakePHP 3.6).
263
+             */
264
+            //'encoding' => 'utf8mb4',
265
+            'timezone' => 'UTC',
266
+            'flags' => [],
267
+            'cacheMetadata' => true,
268
+            'log' => false,
269
+
270
+            /**
271
+             * Set identifier quoting to true if you are using reserved words or
272
+             * special characters in your table or column names. Enabling this
273
+             * setting will result in queries built using the Query Builder having
274
+             * identifiers quoted when creating SQL. It should be noted that this
275
+             * decreases performance because each query needs to be traversed and
276
+             * manipulated before being executed.
277
+             */
278
+            'quoteIdentifiers' => false,
279
+
280
+            /**
281
+             * During development, if using MySQL < 5.6, uncommenting the
282
+             * following line could boost the speed at which schema metadata is
283
+             * fetched from the database. It can also be set directly with the
284
+             * mysql configuration directive 'innodb_stats_on_metadata = 0'
285
+             * which is the recommended value in production environments
286
+             */
287
+            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
288
+
289
+            'url' => env('DATABASE_URL', null),
290
+        ],
291
+
292
+        /**
293
+         * The test connection is used during the test suite.
294
+         */
295
+        'test' => [
296
+            'className' => 'Cake\Database\Connection',
297
+            'driver' => 'Cake\Database\Driver\Mysql',
298
+            'persistent' => false,
299
+            'host' => 'localhost',
300
+            //'port' => 'non_standard_port_number',
301
+            'username' => 'my_app',
302
+            'password' => 'secret',
303
+            'database' => 'test_myapp',
304
+            //'encoding' => 'utf8mb4',
305
+            'timezone' => 'UTC',
306
+            'cacheMetadata' => true,
307
+            'quoteIdentifiers' => false,
308
+            'log' => false,
309
+            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
310
+            'url' => env('DATABASE_TEST_URL', null),
311
+        ],
312
+    ],
313
+
314
+    /**
315
+     * Configures logging options
316
+     */
317
+    'Log' => [
318
+        'debug' => [
319
+            'className' => 'Cake\Log\Engine\FileLog',
320
+            'path' => LOGS,
321
+            'file' => 'debug',
322
+            'url' => env('LOG_DEBUG_URL', null),
323
+            'scopes' => false,
324
+            'levels' => ['notice', 'info', 'debug'],
325
+        ],
326
+        'error' => [
327
+            'className' => 'Cake\Log\Engine\FileLog',
328
+            'path' => LOGS,
329
+            'file' => 'error',
330
+            'url' => env('LOG_ERROR_URL', null),
331
+            'scopes' => false,
332
+            'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
333
+        ],
334
+        // To enable this dedicated query log, you need set your datasource's log flag to true
335
+        'queries' => [
336
+            'className' => 'Cake\Log\Engine\FileLog',
337
+            'path' => LOGS,
338
+            'file' => 'queries',
339
+            'url' => env('LOG_QUERIES_URL', null),
340
+            'scopes' => ['queriesLog'],
341
+        ],
342
+    ],
343
+
344
+    /**
345
+     * Session configuration.
346
+     *
347
+     * Contains an array of settings to use for session configuration. The
348
+     * `defaults` key is used to define a default preset to use for sessions, any
349
+     * settings declared here will override the settings of the default config.
350
+     *
351
+     * ## Options
352
+     *
353
+     * - `cookie` - The name of the cookie to use. Defaults to 'CAKEPHP'. Avoid using `.` in cookie names,
354
+     *   as PHP will drop sessions from cookies with `.` in the name.
355
+     * - `cookiePath` - The url path for which session cookie is set. Maps to the
356
+     *   `session.cookie_path` php.ini config. Defaults to base path of app.
357
+     * - `timeout` - The time in minutes the session should be valid for.
358
+     *    Pass 0 to disable checking timeout.
359
+     *    Please note that php.ini's session.gc_maxlifetime must be equal to or greater
360
+     *    than the largest Session['timeout'] in all served websites for it to have the
361
+     *    desired effect.
362
+     * - `defaults` - The default configuration set to use as a basis for your session.
363
+     *    There are four built-in options: php, cake, cache, database.
364
+     * - `handler` - Can be used to enable a custom session handler. Expects an
365
+     *    array with at least the `engine` key, being the name of the Session engine
366
+     *    class to use for managing the session. CakePHP bundles the `CacheSession`
367
+     *    and `DatabaseSession` engines.
368
+     * - `ini` - An associative array of additional ini values to set.
369
+     *
370
+     * The built-in `defaults` options are:
371
+     *
372
+     * - 'php' - Uses settings defined in your php.ini.
373
+     * - 'cake' - Saves session files in CakePHP's /tmp directory.
374
+     * - 'database' - Uses CakePHP's database sessions.
375
+     * - 'cache' - Use the Cache class to save sessions.
376
+     *
377
+     * To define a custom session handler, save it at src/Network/Session/<name>.php.
378
+     * Make sure the class implements PHP's `SessionHandlerInterface` and set
379
+     * Session.handler to <name>
380
+     *
381
+     * To use database sessions, load the SQL file located at config/schema/sessions.sql
382
+     */
383
+    'Session' => [
384
+        'defaults' => 'php',
385
+    ],
386
+];

+ 393
- 0
config/app.php View File

@@ -0,0 +1,393 @@
1
+<?php
2
+$ini = parse_ini_file(dirname(__FILE__).'/../client.ini', true);
3
+$host = $ini['database']['host'] ?? null;
4
+$db   = $ini['database']['name'] ?? null;
5
+$user = $ini['database']['user'] ?? null;
6
+$pass = $ini['database']['pass'] ?? null;
7
+$charset = $ini['database']['charset'] ?? null;
8
+
9
+return [
10
+    /**
11
+     * Debug Level:
12
+     *
13
+     * Production Mode:
14
+     * false: No error messages, errors, or warnings shown.
15
+     *
16
+     * Development Mode:
17
+     * true: Errors and warnings shown.
18
+     */
19
+    'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),
20
+
21
+    /**
22
+     * Configure basic information about the application.
23
+     *
24
+     * - namespace - The namespace to find app classes under.
25
+     * - defaultLocale - The default locale for translation, formatting currencies and numbers, date and time.
26
+     * - encoding - The encoding used for HTML + database connections.
27
+     * - base - The base directory the app resides in. If false this
28
+     *   will be auto detected.
29
+     * - dir - Name of app directory.
30
+     * - webroot - The webroot directory.
31
+     * - wwwRoot - The file path to webroot.
32
+     * - baseUrl - To configure CakePHP to *not* use mod_rewrite and to
33
+     *   use CakePHP pretty URLs, remove these .htaccess
34
+     *   files:
35
+     *      /.htaccess
36
+     *      /webroot/.htaccess
37
+     *   And uncomment the baseUrl key below.
38
+     * - fullBaseUrl - A base URL to use for absolute links. When set to false (default)
39
+     *   CakePHP generates required value based on `HTTP_HOST` environment variable.
40
+     *   However, you can define it manually to optimize performance or if you
41
+     *   are concerned about people manipulating the `Host` header.
42
+     * - imageBaseUrl - Web path to the public images directory under webroot.
43
+     * - cssBaseUrl - Web path to the public css directory under webroot.
44
+     * - jsBaseUrl - Web path to the public js directory under webroot.
45
+     * - paths - Configure paths for non class based resources. Supports the
46
+     *   `plugins`, `templates`, `locales` subkeys, which allow the definition of
47
+     *   paths for plugins, view templates and locale files respectively.
48
+     */
49
+    'App' => [
50
+        'namespace' => 'App',
51
+        'encoding' => env('APP_ENCODING', 'UTF-8'),
52
+        'defaultLocale' => env('APP_DEFAULT_LOCALE', 'it_IT'),
53
+        'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'CET'),
54
+        'base' => false,
55
+        'dir' => 'src',
56
+        'webroot' => 'webroot',
57
+        'wwwRoot' => WWW_ROOT,
58
+        //'baseUrl' => env('SCRIPT_NAME'),
59
+        'fullBaseUrl' => false,
60
+        'imageBaseUrl' => 'img/',
61
+        'cssBaseUrl' => 'css/',
62
+        'jsBaseUrl' => 'js/',
63
+        'paths' => [
64
+            'plugins' => [ROOT . DS . 'plugins' . DS],
65
+            'templates' => [APP . 'Template' . DS],
66
+            'locales' => [APP . 'Locale' . DS],
67
+        ],
68
+    ],
69
+
70
+    /**
71
+     * Security and encryption configuration
72
+     *
73
+     * - salt - A random string used in security hashing methods.
74
+     *   The salt value is also used as the encryption key.
75
+     *   You should treat it as extremely sensitive data.
76
+     */
77
+    'Security' => [
78
+        'salt' => env('SECURITY_SALT', 'b9f23aba16cf2fb8a678a48e620406def7f6d11f'),
79
+    ],
80
+
81
+    /**
82
+     * Apply timestamps with the last modified time to static assets (js, css, images).
83
+     * Will append a querystring parameter containing the time the file was modified.
84
+     * This is useful for busting browser caches.
85
+     *
86
+     * Set to true to apply timestamps when debug is true. Set to 'force' to always
87
+     * enable timestamping regardless of debug value.
88
+     */
89
+    'Asset' => [
90
+        //'timestamp' => true,
91
+        // 'cacheTime' => '+1 year'
92
+    ],
93
+
94
+    /**
95
+     * Configure the cache adapters.
96
+     */
97
+    'Cache' => [
98
+        'default' => [
99
+            'className' => 'Cake\Cache\Engine\FileEngine',
100
+            'path' => CACHE,
101
+            'url' => env('CACHE_DEFAULT_URL', null),
102
+        ],
103
+
104
+        /**
105
+         * Configure the cache used for general framework caching.
106
+         * Translation cache files are stored with this configuration.
107
+         * Duration will be set to '+2 minutes' in bootstrap.php when debug = true
108
+         * If you set 'className' => 'Null' core cache will be disabled.
109
+         */
110
+        '_cake_core_' => [
111
+            'className' => 'Cake\Cache\Engine\FileEngine',
112
+            'prefix' => 'myapp_cake_core_',
113
+            'path' => CACHE . 'persistent/',
114
+            'serialize' => true,
115
+            'duration' => '+1 years',
116
+            'url' => env('CACHE_CAKECORE_URL', null),
117
+        ],
118
+
119
+        /**
120
+         * Configure the cache for model and datasource caches. This cache
121
+         * configuration is used to store schema descriptions, and table listings
122
+         * in connections.
123
+         * Duration will be set to '+2 minutes' in bootstrap.php when debug = true
124
+         */
125
+        '_cake_model_' => [
126
+            'className' => 'Cake\Cache\Engine\FileEngine',
127
+            'prefix' => 'myapp_cake_model_',
128
+            'path' => CACHE . 'models/',
129
+            'serialize' => true,
130
+            'duration' => '+1 years',
131
+            'url' => env('CACHE_CAKEMODEL_URL', null),
132
+        ],
133
+
134
+        /**
135
+         * Configure the cache for routes. The cached routes collection is built the
136
+         * first time the routes are processed via `config/routes.php`.
137
+         * Duration will be set to '+2 seconds' in bootstrap.php when debug = true
138
+         */
139
+        '_cake_routes_' => [
140
+            'className' => 'Cake\Cache\Engine\FileEngine',
141
+            'prefix' => 'myapp_cake_routes_',
142
+            'path' => CACHE,
143
+            'serialize' => true,
144
+            'duration' => '+1 years',
145
+            'url' => env('CACHE_CAKEROUTES_URL', null),
146
+        ],
147
+    ],
148
+
149
+    /**
150
+     * Configure the Error and Exception handlers used by your application.
151
+     *
152
+     * By default errors are displayed using Debugger, when debug is true and logged
153
+     * by Cake\Log\Log when debug is false.
154
+     *
155
+     * In CLI environments exceptions will be printed to stderr with a backtrace.
156
+     * In web environments an HTML page will be displayed for the exception.
157
+     * With debug true, framework errors like Missing Controller will be displayed.
158
+     * When debug is false, framework errors will be coerced into generic HTTP errors.
159
+     *
160
+     * Options:
161
+     *
162
+     * - `errorLevel` - int - The level of errors you are interested in capturing.
163
+     * - `trace` - boolean - Whether or not backtraces should be included in
164
+     *   logged errors/exceptions.
165
+     * - `log` - boolean - Whether or not you want exceptions logged.
166
+     * - `exceptionRenderer` - string - The class responsible for rendering
167
+     *   uncaught exceptions. If you choose a custom class you should place
168
+     *   the file for that class in src/Error. This class needs to implement a
169
+     *   render method.
170
+     * - `skipLog` - array - List of exceptions to skip for logging. Exceptions that
171
+     *   extend one of the listed exceptions will also be skipped for logging.
172
+     *   E.g.:
173
+     *   `'skipLog' => ['Cake\Http\Exception\NotFoundException', 'Cake\Http\Exception\UnauthorizedException']`
174
+     * - `extraFatalErrorMemory` - int - The number of megabytes to increase
175
+     *   the memory limit by when a fatal error is encountered. This allows
176
+     *   breathing room to complete logging or error handling.
177
+     */
178
+    'Error' => [
179
+        'errorLevel' => E_ALL,
180
+        'exceptionRenderer' => 'Cake\Error\ExceptionRenderer',
181
+        'skipLog' => [],
182
+        'log' => true,
183
+        'trace' => true,
184
+    ],
185
+
186
+    /**
187
+     * Email configuration.
188
+     *
189
+     * By defining transports separately from delivery profiles you can easily
190
+     * re-use transport configuration across multiple profiles.
191
+     *
192
+     * You can specify multiple configurations for production, development and
193
+     * testing.
194
+     *
195
+     * Each transport needs a `className`. Valid options are as follows:
196
+     *
197
+     *  Mail   - Send using PHP mail function
198
+     *  Smtp   - Send using SMTP
199
+     *  Debug  - Do not send the email, just return the result
200
+     *
201
+     * You can add custom transports (or override existing transports) by adding the
202
+     * appropriate file to src/Mailer/Transport. Transports should be named
203
+     * 'YourTransport.php', where 'Your' is the name of the transport.
204
+     */
205
+    'EmailTransport' => [
206
+        'default' => [
207
+            'className' => 'Cake\Mailer\Transport\MailTransport',
208
+            /*
209
+             * The following keys are used in SMTP transports:
210
+             */
211
+            'host' => '1.1.1.1',
212
+            'port' => 25,
213
+            'timeout' => 30,
214
+            'username' => null,
215
+            'password' => null,
216
+            'client' => null,
217
+            'tls' => null,
218
+            'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
219
+        ],
220
+    ],
221
+
222
+    /**
223
+     * Email delivery profiles
224
+     *
225
+     * Delivery profiles allow you to predefine various properties about email
226
+     * messages from your application and give the settings a name. This saves
227
+     * duplication across your application and makes maintenance and development
228
+     * easier. Each profile accepts a number of keys. See `Cake\Mailer\Email`
229
+     * for more information.
230
+     */
231
+    'Email' => [
232
+        'default' => [
233
+            'transport' => 'default',
234
+            'from' => 'you@localhost',
235
+            //'charset' => 'utf-8',
236
+            //'headerCharset' => 'utf-8',
237
+        ],
238
+    ],
239
+
240
+    /**
241
+     * Connection information used by the ORM to connect
242
+     * to your application's datastores.
243
+     *
244
+     * ### Notes
245
+     * - Drivers include Mysql Postgres Sqlite Sqlserver
246
+     *   See vendor\cakephp\cakephp\src\Database\Driver for complete list
247
+     * - Do not use periods in database name - it may lead to error.
248
+     *   See https://github.com/cakephp/cakephp/issues/6471 for details.
249
+     * - 'encoding' is recommended to be set to full UTF-8 4-Byte support.
250
+     *   E.g set it to 'utf8mb4' in MariaDB and MySQL and 'utf8' for any
251
+     *   other RDBMS.
252
+     */
253
+    'Datasources' => [
254
+        'default' => [
255
+            'className' => 'Cake\Database\Connection',
256
+            'driver' => 'Cake\Database\Driver\Mysql',
257
+            'persistent' => false,
258
+            'host' => $host,
259
+            /*
260
+             * CakePHP will use the default DB port based on the driver selected
261
+             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
262
+             * the following line and set the port accordingly
263
+             */
264
+            //'port' => 'non_standard_port_number',
265
+            'username' => $user,
266
+            'password' => $pass,
267
+            'database' => $db,
268
+            /*
269
+             * You do not need to set this flag to use full utf-8 encoding (internal default since CakePHP 3.6).
270
+             */
271
+            //'encoding' => 'utf8mb4',
272
+            'timezone' => 'UTC',
273
+            'flags' => [],
274
+            'cacheMetadata' => true,
275
+            'log' => false,
276
+
277
+            /**
278
+             * Set identifier quoting to true if you are using reserved words or
279
+             * special characters in your table or column names. Enabling this
280
+             * setting will result in queries built using the Query Builder having
281
+             * identifiers quoted when creating SQL. It should be noted that this
282
+             * decreases performance because each query needs to be traversed and
283
+             * manipulated before being executed.
284
+             */
285
+            'quoteIdentifiers' => false,
286
+
287
+            /**
288
+             * During development, if using MySQL < 5.6, uncommenting the
289
+             * following line could boost the speed at which schema metadata is
290
+             * fetched from the database. It can also be set directly with the
291
+             * mysql configuration directive 'innodb_stats_on_metadata = 0'
292
+             * which is the recommended value in production environments
293
+             */
294
+            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
295
+
296
+            'url' => env('DATABASE_URL', null),
297
+        ],
298
+
299
+        /**
300
+         * The test connection is used during the test suite.
301
+         */
302
+        'test' => [
303
+            'className' => 'Cake\Database\Connection',
304
+            'driver' => 'Cake\Database\Driver\Mysql',
305
+            'persistent' => false,
306
+            'host' => 'localhost',
307
+            //'port' => 'non_standard_port_number',
308
+            'username' => 'my_app',
309
+            'password' => 'secret',
310
+            'database' => 'test_myapp',
311
+            //'encoding' => 'utf8mb4',
312
+            'timezone' => 'UTC',
313
+            'cacheMetadata' => true,
314
+            'quoteIdentifiers' => false,
315
+            'log' => false,
316
+            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
317
+            'url' => env('DATABASE_TEST_URL', null),
318
+        ],
319
+    ],
320
+
321
+    /**
322
+     * Configures logging options
323
+     */
324
+    'Log' => [
325
+        'debug' => [
326
+            'className' => 'Cake\Log\Engine\FileLog',
327
+            'path' => LOGS,
328
+            'file' => 'debug',
329
+            'url' => env('LOG_DEBUG_URL', null),
330
+            'scopes' => false,
331
+            'levels' => ['notice', 'info', 'debug'],
332
+        ],
333
+        'error' => [
334
+            'className' => 'Cake\Log\Engine\FileLog',
335
+            'path' => LOGS,
336
+            'file' => 'error',
337
+            'url' => env('LOG_ERROR_URL', null),
338
+            'scopes' => false,
339
+            'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
340
+        ],
341
+        // To enable this dedicated query log, you need set your datasource's log flag to true
342
+        'queries' => [
343
+            'className' => 'Cake\Log\Engine\FileLog',
344
+            'path' => LOGS,
345
+            'file' => 'queries',
346
+            'url' => env('LOG_QUERIES_URL', null),
347
+            'scopes' => ['queriesLog'],
348
+        ],
349
+    ],
350
+
351
+    /**
352
+     * Session configuration.
353
+     *
354
+     * Contains an array of settings to use for session configuration. The
355
+     * `defaults` key is used to define a default preset to use for sessions, any
356
+     * settings declared here will override the settings of the default config.
357
+     *
358
+     * ## Options
359
+     *
360
+     * - `cookie` - The name of the cookie to use. Defaults to 'CAKEPHP'. Avoid using `.` in cookie names,
361
+     *   as PHP will drop sessions from cookies with `.` in the name.
362
+     * - `cookiePath` - The url path for which session cookie is set. Maps to the
363
+     *   `session.cookie_path` php.ini config. Defaults to base path of app.
364
+     * - `timeout` - The time in minutes the session should be valid for.
365
+     *    Pass 0 to disable checking timeout.
366
+     *    Please note that php.ini's session.gc_maxlifetime must be equal to or greater
367
+     *    than the largest Session['timeout'] in all served websites for it to have the
368
+     *    desired effect.
369
+     * - `defaults` - The default configuration set to use as a basis for your session.
370
+     *    There are four built-in options: php, cake, cache, database.
371
+     * - `handler` - Can be used to enable a custom session handler. Expects an
372
+     *    array with at least the `engine` key, being the name of the Session engine
373
+     *    class to use for managing the session. CakePHP bundles the `CacheSession`
374
+     *    and `DatabaseSession` engines.
375
+     * - `ini` - An associative array of additional ini values to set.
376
+     *
377
+     * The built-in `defaults` options are:
378
+     *
379
+     * - 'php' - Uses settings defined in your php.ini.
380
+     * - 'cake' - Saves session files in CakePHP's /tmp directory.
381
+     * - 'database' - Uses CakePHP's database sessions.
382
+     * - 'cache' - Use the Cache class to save sessions.
383
+     *
384
+     * To define a custom session handler, save it at src/Network/Session/<name>.php.
385
+     * Make sure the class implements PHP's `SessionHandlerInterface` and set
386
+     * Session.handler to <name>
387
+     *
388
+     * To use database sessions, load the SQL file located at config/schema/sessions.sql
389
+     */
390
+    'Session' => [
391
+        'defaults' => 'cake'
392
+    ],
393
+];

+ 203
- 0
config/bootstrap.php View File

@@ -0,0 +1,203 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * For full copyright and license information, please see the LICENSE.txt
8
+ * Redistributions of files must retain the above copyright notice.
9
+ *
10
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ * @link          https://cakephp.org CakePHP(tm) Project
12
+ * @since         0.10.8
13
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
14
+ */
15
+
16
+/*
17
+ * Configure paths required to find CakePHP + general filepath constants
18
+ */
19
+require __DIR__ . '/paths.php';
20
+
21
+/*
22
+ * Bootstrap CakePHP.
23
+ *
24
+ * Does the various bits of setup that CakePHP needs to do.
25
+ * This includes:
26
+ *
27
+ * - Registering the CakePHP autoloader.
28
+ * - Setting the default application paths.
29
+ */
30
+require CORE_PATH . 'config' . DS . 'bootstrap.php';
31
+
32
+use Cake\Cache\Cache;
33
+use Cake\Console\ConsoleErrorHandler;
34
+use Cake\Core\Configure;
35
+use Cake\Core\Configure\Engine\PhpConfig;
36
+use Cake\Core\Plugin;
37
+use Cake\Database\Type;
38
+use Cake\Datasource\ConnectionManager;
39
+use Cake\Error\ErrorHandler;
40
+use Cake\Http\ServerRequest;
41
+use Cake\Log\Log;
42
+use Cake\Mailer\Email;
43
+use Cake\Mailer\TransportFactory;
44
+use Cake\Utility\Inflector;
45
+use Cake\Utility\Security;
46
+
47
+/**
48
+ * Uncomment block of code below if you want to use `.env` file during development.
49
+ * You should copy `config/.env.default to `config/.env` and set/modify the
50
+ * variables as required.
51
+ *
52
+ * It is HIGHLY discouraged to use a .env file in production, due to security risks
53
+ * and decreased performance on each request. The purpose of the .env file is to emulate
54
+ * the presence of the environment variables like they would be present in production.
55
+ */
56
+// if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
57
+//     $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
58
+//     $dotenv->parse()
59
+//         ->putenv()
60
+//         ->toEnv()
61
+//         ->toServer();
62
+// }
63
+
64
+/*
65
+ * Read configuration file and inject configuration into various
66
+ * CakePHP classes.
67
+ *
68
+ * By default there is only one configuration file. It is often a good
69
+ * idea to create multiple configuration files, and separate the configuration
70
+ * that changes from configuration that does not. This makes deployment simpler.
71
+ */
72
+try {
73
+    Configure::config('default', new PhpConfig());
74
+    Configure::load('app', 'default', false);
75
+} catch (\Exception $e) {
76
+    exit($e->getMessage() . "\n");
77
+}
78
+
79
+/*
80
+ * Load an environment local configuration file.
81
+ * You can use a file like app_local.php to provide local overrides to your
82
+ * shared configuration.
83
+ */
84
+//Configure::load('app_local', 'default');
85
+
86
+/*
87
+ * When debug = true the metadata cache should only last
88
+ * for a short time.
89
+ */
90
+if (Configure::read('debug')) {
91
+    Configure::write('Cache._cake_model_.duration', '+2 minutes');
92
+    Configure::write('Cache._cake_core_.duration', '+2 minutes');
93
+    // disable router cache during development
94
+    Configure::write('Cache._cake_routes_.duration', '+2 seconds');
95
+}
96
+
97
+/*
98
+ * Set the default server timezone. Using UTC makes time calculations / conversions easier.
99
+ * Check http://php.net/manual/en/timezones.php for list of valid timezone strings.
100
+ */
101
+date_default_timezone_set(Configure::read('App.defaultTimezone'));
102
+
103
+/*
104
+ * Configure the mbstring extension to use the correct encoding.
105
+ */
106
+mb_internal_encoding(Configure::read('App.encoding'));
107
+
108
+/*
109
+ * Set the default locale. This controls how dates, number and currency is
110
+ * formatted and sets the default language to use for translations.
111
+ */
112
+ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
113
+
114
+/*
115
+ * Register application error and exception handlers.
116
+ */
117
+$isCli = PHP_SAPI === 'cli';
118
+if ($isCli) {
119
+    (new ConsoleErrorHandler(Configure::read('Error')))->register();
120
+} else {
121
+    (new ErrorHandler(Configure::read('Error')))->register();
122
+}
123
+
124
+/*
125
+ * Include the CLI bootstrap overrides.
126
+ */
127
+if ($isCli) {
128
+    require __DIR__ . '/bootstrap_cli.php';
129
+}
130
+
131
+/*
132
+ * Set the full base URL.
133
+ * This URL is used as the base of all absolute links.
134
+ *
135
+ * If you define fullBaseUrl in your config file you can remove this.
136
+ */
137
+if (!Configure::read('App.fullBaseUrl')) {
138
+    $s = null;
139
+    if (env('HTTPS')) {
140
+        $s = 's';
141
+    }
142
+
143
+    $httpHost = env('HTTP_HOST');
144
+    if (isset($httpHost)) {
145
+        Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
146
+    }
147
+    unset($httpHost, $s);
148
+}
149
+
150
+Cache::setConfig(Configure::consume('Cache'));
151
+ConnectionManager::setConfig(Configure::consume('Datasources'));
152
+TransportFactory::setConfig(Configure::consume('EmailTransport'));
153
+Email::setConfig(Configure::consume('Email'));
154
+Log::setConfig(Configure::consume('Log'));
155
+Security::setSalt(Configure::consume('Security.salt'));
156
+
157
+/*
158
+ * The default crypto extension in 3.0 is OpenSSL.
159
+ * If you are migrating from 2.x uncomment this code to
160
+ * use a more compatible Mcrypt based implementation
161
+ */
162
+//Security::engine(new \Cake\Utility\Crypto\Mcrypt());
163
+
164
+/*
165
+ * Setup detectors for mobile and tablet.
166
+ */
167
+ServerRequest::addDetector('mobile', function ($request) {
168
+    $detector = new \Detection\MobileDetect();
169
+
170
+    return $detector->isMobile();
171
+});
172
+ServerRequest::addDetector('tablet', function ($request) {
173
+    $detector = new \Detection\MobileDetect();
174
+
175
+    return $detector->isTablet();
176
+});
177
+
178
+/*
179
+ * Enable immutable time objects in the ORM.
180
+ *
181
+ * You can enable default locale format parsing by adding calls
182
+ * to `useLocaleParser()`. This enables the automatic conversion of
183
+ * locale specific date formats. For details see
184
+ * @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
185
+ */
186
+Type::build('time')
187
+    ->useImmutable();
188
+Type::build('date')
189
+    ->useImmutable();
190
+Type::build('datetime')
191
+    ->useImmutable();
192
+Type::build('timestamp')
193
+    ->useImmutable();
194
+
195
+/*
196
+ * Custom Inflector rules, can be set to correctly pluralize or singularize
197
+ * table, model, controller names or whatever other string is passed to the
198
+ * inflection functions.
199
+ */
200
+//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
201
+//Inflector::rules('irregular', ['red' => 'redlings']);
202
+//Inflector::rules('uninflected', ['dontinflectme']);
203
+//Inflector::rules('transliteration', ['/å/' => 'aa']);

+ 28
- 0
config/bootstrap_cli.php View File

@@ -0,0 +1,28 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * For full copyright and license information, please see the LICENSE.txt
8
+ * Redistributions of files must retain the above copyright notice.
9
+ *
10
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ * @link          https://cakephp.org CakePHP(tm) Project
12
+ * @since         3.0.0
13
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
14
+ */
15
+use Cake\Core\Configure;
16
+
17
+/**
18
+ * Additional bootstrapping and configuration for CLI environments should
19
+ * be put here.
20
+ */
21
+
22
+// Set the fullBaseUrl to allow URLs to be generated in shell tasks.
23
+// This is useful when sending email from shells.
24
+//Configure::write('App.fullBaseUrl', php_uname('n'));
25
+
26
+// Set logs to different files so they don't have permission conflicts.
27
+Configure::write('Log.debug.file', 'cli-debug');
28
+Configure::write('Log.error.file', 'cli-error');

+ 89
- 0
config/paths.php View File

@@ -0,0 +1,89 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * Redistributions of files must retain the above copyright notice.
8
+ *
9
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
10
+ * @link          https://cakephp.org CakePHP(tm) Project
11
+ * @since         3.0.0
12
+ * @license       MIT License (https://opensource.org/licenses/mit-license.php)
13
+ */
14
+
15
+/**
16
+ * Use the DS to separate the directories in other defines
17
+ */
18
+if (!defined('DS')) {
19
+    define('DS', DIRECTORY_SEPARATOR);
20
+}
21
+
22
+/**
23
+ * These defines should only be edited if you have cake installed in
24
+ * a directory layout other than the way it is distributed.
25
+ * When using custom settings be sure to use the DS and do not add a trailing DS.
26
+ */
27
+
28
+/**
29
+ * The full path to the directory which holds "src", WITHOUT a trailing DS.
30
+ */
31
+define('ROOT', dirname(__DIR__));
32
+
33
+/**
34
+ * The actual directory name for the application directory. Normally
35
+ * named 'src'.
36
+ */
37
+define('APP_DIR', 'src');
38
+
39
+/**
40
+ * Path to the application's directory.
41
+ */
42
+define('APP', ROOT . DS . APP_DIR . DS);
43
+
44
+/**
45
+ * Path to the config directory.
46
+ */
47
+define('CONFIG', ROOT . DS . 'config' . DS);
48
+
49
+/**
50
+ * File path to the webroot directory.
51
+ *
52
+ * To derive your webroot from your webserver change this to:
53
+ *
54
+ * `define('WWW_ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], DS) . DS);`
55
+ */
56
+define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
57
+
58
+/**
59
+ * Path to the tests directory.
60
+ */
61
+define('TESTS', ROOT . DS . 'tests' . DS);
62
+
63
+/**
64
+ * Path to the temporary files directory.
65
+ */
66
+define('TMP', ROOT . DS . 'tmp' . DS);
67
+
68
+/**
69
+ * Path to the logs directory.
70
+ */
71
+define('LOGS', ROOT . DS . 'logs' . DS);
72
+
73
+/**
74
+ * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
75
+ */
76
+define('CACHE', TMP . 'cache' . DS);
77
+
78
+/**
79
+ * The absolute path to the "cake" directory, WITHOUT a trailing DS.
80
+ *
81
+ * CakePHP should always be installed with composer, so look there.
82
+ */
83
+define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
84
+
85
+/**
86
+ * Path to the cake directory.
87
+ */
88
+define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
89
+define('CAKE', CORE_PATH . 'src' . DS);

+ 41
- 0
config/requirements.php View File

@@ -0,0 +1,41 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * For full copyright and license information, please see the LICENSE.txt
8
+ * Redistributions of files must retain the above copyright notice.
9
+ *
10
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ * @link          https://cakephp.org CakePHP(tm) Project
12
+ * @since         3.5.0
13
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
14
+ */
15
+
16
+/*
17
+ * You can empty out this file, if you are certain that you match all requirements.
18
+ */
19
+
20
+/*
21
+ * You can remove this if you are confident that your PHP version is sufficient.
22
+ */
23
+if (version_compare(PHP_VERSION, '5.6.0') < 0) {
24
+    trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.' . PHP_EOL, E_USER_ERROR);
25
+}
26
+
27
+/*
28
+ * You can remove this if you are confident you have intl installed.
29
+ */
30
+if (!extension_loaded('intl')) {
31
+    trigger_error('You must enable the intl extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
32
+}
33
+
34
+/*
35
+ * You can remove this if you are confident you have mbstring installed.
36
+ */
37
+if (!extension_loaded('mbstring')) {
38
+    trigger_error('You must enable the mbstring extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
39
+}
40
+
41
+setlocale (LC_ALL, "Italian");

+ 179
- 0
config/routes.php View File

@@ -0,0 +1,179 @@
1
+<?php
2
+/**
3
+ * Routes configuration
4
+ *
5
+ * In this file, you set up routes to your controllers and their actions.
6
+ * Routes are very important mechanism that allows you to freely connect
7
+ * different URLs to chosen controllers and their actions (functions).
8
+ *
9
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
10
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ *
12
+ * Licensed under The MIT License
13
+ * For full copyright and license information, please see the LICENSE.txt
14
+ * Redistributions of files must retain the above copyright notice.
15
+ *
16
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
17
+ * @link          https://cakephp.org CakePHP(tm) Project
18
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
19
+ */
20
+use Cake\Http\Middleware\CsrfProtectionMiddleware;
21
+use Cake\Routing\RouteBuilder;
22
+use Cake\Routing\Router;
23
+use Cake\Routing\Route\DashedRoute;
24
+
25
+/**
26
+ * The default class to use for all routes
27
+ *
28
+ * The following route classes are supplied with CakePHP and are appropriate
29
+ * to set as the default:
30
+ *
31
+ * - Route
32
+ * - InflectedRoute
33
+ * - DashedRoute
34
+ *
35
+ * If no call is made to `Router::defaultRouteClass()`, the class used is
36
+ * `Route` (`Cake\Routing\Route\Route`)
37
+ *
38
+ * Note that `Route` does not do any inflections on URLs which will result in
39
+ * inconsistently cased URLs when used with `:plugin`, `:controller` and
40
+ * `:action` markers.
41
+ *
42
+ * Cache: Routes are cached to improve performance, check the RoutingMiddleware
43
+ * constructor in your `src/Application.php` file to change this behavior.
44
+ *
45
+ */
46
+Router::defaultRouteClass(DashedRoute::class);
47
+
48
+Router::scope('/', function (RouteBuilder $routes) {
49
+    // Register scoped middleware for in scopes.
50
+    $routes->registerMiddleware('csrf', new CsrfProtectionMiddleware([
51
+        'httpOnly' => true
52
+    ]));
53
+
54
+
55
+    /**
56
+     * Here, we are connecting '/' (base path) to a controller called 'Pages',
57
+     * its action called 'display', and we pass a param to select the view file
58
+     * to use (in this case, src/Template/Pages/home.ctp)...
59
+     */
60
+    // $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
61
+
62
+    $routes->connect('/', ['controller' => 'Main', 'action' => 'history']);
63
+    $routes->scope('/gridability', function ($routes) {
64
+        $routes->applyMiddleware('csrf');
65
+        $routes->connect('/', ['controller' => 'Main', 'action' => 'history']);
66
+        $routes->connect('/history', ['controller' => 'Main', 'action' => 'history']);
67
+        $routes->connect('/history/:hgm_id', ['controller' => 'Main', 'action' => 'historyHgm']
68
+            ,['pass' =>['hgm_id']]);
69
+
70
+        $routes->connect('/history/daily', ['controller' => 'Main', 'action' => 'historyDaily']);
71
+        $routes->connect('/history/daily/:hgm_id', ['controller' => 'Main', 'action' => 'historyHgmDaily']
72
+            ,['pass' =>['hgm_id']]);
73
+
74
+        $routes->connect('/history/monthly', ['controller' => 'Main', 'action' => 'historyMonthly']);
75
+        $routes->connect('/history/monthly/:hgm_id', ['controller' => 'Main', 'action' => 'historyHgmMonthly']
76
+            ,['pass' =>['hgm_id']]);
77
+
78
+        $routes->connect('/balance', ['controller' => 'Main', 'action' => 'hgm']);
79
+        $routes->connect('/balance/:hgm_id', ['controller' => 'Main', 'action' => 'hgmID']
80
+            ,['pass' =>['hgm_id']]);
81
+
82
+        $routes->connect('/block/:block_id', ['controller' => 'Main', 'action' => 'blockID']
83
+            ,['pass' =>['block_id']]);
84
+
85
+        $routes->connect('/history/price', ['controller' => 'Main', 'action' => 'priceHistory']);
86
+        $routes->connect('/history/price/:hgm_id', ['controller' => 'Main', 'action' => 'priceHistoryHGM'],['pass' =>['hgm_id']]);
87
+
88
+        $routes->connect('/payment', ['controller' => 'Main', 'action' => 'payment']);
89
+
90
+        $routes->connect('/setprice', ['controller' => 'Main', 'action' => 'setPrice']);
91
+
92
+        $routes->connect('/transfer', ['controller' => 'Main', 'action' => 'transfer']);
93
+
94
+        $routes->connect('/profile', ['controller' => 'Main', 'action' => 'profile']);
95
+
96
+    });
97
+
98
+    $routes->scope('/xhr/', function ($routes) {
99
+        $routes->applyMiddleware('csrf');
100
+        $routes->connect('setprice', ['controller' => 'Xhr', 'action' => 'setPrice']);
101
+
102
+        $routes->connect('transfer', ['controller' => 'Xhr', 'action' => 'transfer']);
103
+
104
+        $routes->connect('history', ['controller' => 'Xhr', 'action' => 'history']);
105
+        $routes->connect('historyTransfer', ['controller' => 'Xhr', 'action' => 'historyTransfer']);
106
+
107
+        $routes->connect('payment', ['controller' => 'Xhr', 'action' => 'payment']);
108
+
109
+        $routes->connect('price/history', ['controller' => 'Xhr', 'action' => 'priceHistory']);
110
+
111
+        $routes->connect('block', ['controller' => 'Xhr', 'action' => 'blocks']);
112
+
113
+        $routes->connect('balances', ['controller' => 'Xhr', 'action' => 'balances']);
114
+
115
+        $routes->connect('charts/payments/:hgm_name', ['controller' => 'Xhr', 'action' => 'chartsPayments']
116
+            ,['pass' =>['hgm_name']]);
117
+
118
+    });
119
+
120
+    $routes->scope('/api/', function ($routes) {
121
+        $routes->connect('transfer', ['controller' => 'Api', 'action' => 'transfer']);
122
+
123
+        $routes->connect('history', ['controller' => 'Api', 'action' => 'history']);
124
+    
125
+        $routes->connect('payment', ['controller' => 'Api', 'action' => 'payment']);
126
+    
127
+        $routes->connect('price', ['controller' => 'Api', 'action' => 'price']);
128
+
129
+        $routes->connect('block', ['controller' => 'Api', 'action' => 'blocks']);
130
+    
131
+        $routes->connect('/block/:block_id', ['controller' => 'Api', 'action' => 'blockID']
132
+        ,['pass' =>['block_id']]);
133
+    
134
+        $routes->connect('balance', ['controller' => 'Api', 'action' => 'hgm']);
135
+        $routes->connect('balance/:hgm_id', ['controller' => 'Api', 'action' => 'hgmID']
136
+            ,['pass' =>['hgm_id']]);
137
+
138
+        $routes->connect('balances', ['controller' => 'Api', 'action' => 'balances']);
139
+    });
140
+
141
+
142
+    /**
143
+     * ...and connect the rest of 'Pages' controller's URLs.
144
+     */
145
+//    $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
146
+
147
+    /**
148
+     * Connect catchall routes for all controllers.
149
+     *
150
+     * Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
151
+     *
152
+     * ```
153
+     * $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);
154
+     * $routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);
155
+     * ```
156
+     *
157
+     * Any route class can be used with this method, such as:
158
+     * - DashedRoute
159
+     * - InflectedRoute
160
+     * - Route
161
+     * - Or your own route class
162
+     *
163
+     * You can remove these routes once you've connected the
164
+     * routes you want in your application.
165
+     */
166
+    $routes->fallbacks(DashedRoute::class);
167
+});
168
+
169
+/**
170
+ * If you need a different set of middleware or none at all,
171
+ * open new scope and define routes there.
172
+ *
173
+ * ```
174
+ * Router::scope('/api', function (RouteBuilder $routes) {
175
+ *     // No $routes->applyMiddleware() here.
176
+ *     // Connect API actions here.
177
+ * });
178
+ * ```
179
+ */

+ 18
- 0
config/schema/i18n.sql View File

@@ -0,0 +1,18 @@
1
+# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
2
+#
3
+# Licensed under The MIT License
4
+# For full copyright and license information, please see the LICENSE.txt
5
+# Redistributions of files must retain the above copyright notice.
6
+# MIT License (https://opensource.org/licenses/mit-license.php)
7
+
8
+CREATE TABLE i18n (
9
+    id int NOT NULL auto_increment,
10
+    locale varchar(6) NOT NULL,
11
+    model varchar(255) NOT NULL,
12
+    foreign_key int(10) NOT NULL,
13
+    field varchar(255) NOT NULL,
14
+    content text,
15
+    PRIMARY KEY (id),
16
+    UNIQUE INDEX I18N_LOCALE_FIELD(locale, model, foreign_key, field),
17
+    INDEX I18N_FIELD(model, foreign_key, field)
18
+);

+ 15
- 0
config/schema/sessions.sql View File

@@ -0,0 +1,15 @@
1
+# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
2
+#
3
+# Licensed under The MIT License
4
+# For full copyright and license information, please see the LICENSE.txt
5
+# Redistributions of files must retain the above copyright notice.
6
+# MIT License (https://opensource.org/licenses/mit-license.php)
7
+
8
+CREATE TABLE `sessions` (
9
+  `id` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
10
+  `created` datetime DEFAULT CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
11
+  `modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
12
+  `data` blob DEFAULT NULL, -- for PostgreSQL use bytea instead of blob
13
+  `expires` int(10) unsigned DEFAULT NULL,
14
+  PRIMARY KEY (`id`)
15
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 15
- 0
index.php View File

@@ -0,0 +1,15 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * For full copyright and license information, please see the LICENSE.txt
8
+ * Redistributions of files must retain the above copyright notice.
9
+ *
10
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ * @link          https://cakephp.org CakePHP(tm) Project
12
+ * @since         0.10.0
13
+ * @license       https://opensource.org/licenses/mit-license.php MIT License
14
+ */
15
+require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';

+ 41
- 0
phpunit.xml.dist View File

@@ -0,0 +1,41 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<phpunit
3
+    colors="true"
4
+    processIsolation="false"
5
+    stopOnFailure="false"
6
+    bootstrap="tests/bootstrap.php"
7
+    >
8
+    <php>
9
+        <ini name="memory_limit" value="-1"/>
10
+        <ini name="apc.enable_cli" value="1"/>
11
+    </php>
12
+
13
+    <!-- Add any additional test suites you want to run here -->
14
+    <testsuites>
15
+        <testsuite name="app">
16
+            <directory>tests/TestCase/</directory>
17
+        </testsuite>
18
+        <!-- Add plugin test suites here. -->
19
+    </testsuites>
20
+
21
+    <!-- Setup a listener for fixtures -->
22
+    <listeners>
23
+        <listener
24
+        class="\Cake\TestSuite\Fixture\FixtureInjector">
25
+            <arguments>
26
+                <object class="\Cake\TestSuite\Fixture\FixtureManager" />
27
+            </arguments>
28
+        </listener>
29
+    </listeners>
30
+
31
+    <!-- Ignore vendor tests in code coverage reports -->
32
+    <filter>
33
+        <whitelist>
34
+            <directory suffix=".php">src/</directory>
35
+            <directory suffix=".php">plugins/*/src/</directory>
36
+            <exclude>
37
+                <file>src/Console/Installer.php</file>
38
+            </exclude>
39
+        </whitelist>
40
+    </filter>
41
+</phpunit>

+ 0
- 0
plugins/empty View File


+ 165
- 0
sql/prosume.sql View File

@@ -0,0 +1,165 @@
1
+-- MySQL dump 10.17  Distrib 10.3.16-MariaDB, for debian-linux-gnu (x86_64)
2
+
3
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
4
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
5
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
6
+/*!40101 SET NAMES utf8mb4 */;
7
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
8
+/*!40103 SET TIME_ZONE='+00:00' */;
9
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
10
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
11
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
12
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
13
+
14
+--
15
+-- Table structure for table `balances`
16
+--
17
+
18
+DROP TABLE IF EXISTS `balances`;
19
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
20
+/*!40101 SET character_set_client = utf8 */;
21
+CREATE TABLE `balances` (
22
+  `hgm_id` int(11) NOT NULL,
23
+  `prs` double DEFAULT NULL,
24
+  `tft` double DEFAULT NULL,
25
+  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
26
+  KEY `hgm_id` (`hgm_id`),
27
+  CONSTRAINT `balances_ibfk_1` FOREIGN KEY (`hgm_id`) REFERENCES `hgm` (`id`)
28
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
29
+/*!40101 SET character_set_client = @saved_cs_client */;
30
+
31
+--
32
+-- Table structure for table `blocks`
33
+--
34
+
35
+DROP TABLE IF EXISTS `blocks`;
36
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
37
+/*!40101 SET character_set_client = utf8 */;
38
+CREATE TABLE `blocks` (
39
+  `id` int(11) NOT NULL AUTO_INCREMENT,
40
+  `blocknumber` int(11) DEFAULT NULL,
41
+  `wallet_type` varchar(50) DEFAULT NULL,
42
+  `wallet_from` varchar(50) DEFAULT NULL,
43
+  `wallet_to` varchar(50) DEFAULT NULL,
44
+  `asset` varchar(50) DEFAULT NULL,
45
+  `amount` decimal(15,8) DEFAULT NULL,
46
+  `timestamp` datetime DEFAULT NULL,
47
+  `memo_hash` char(32) DEFAULT NULL,
48
+  `tx_id` char(32) DEFAULT NULL,
49
+  `type` enum('measure','payment','transfer') DEFAULT NULL,
50
+  `purchased_sold` double DEFAULT NULL,
51
+  `buy_price` double DEFAULT NULL,
52
+  `sell_price` double DEFAULT NULL,
53
+  PRIMARY KEY (`id`),
54
+  KEY `blocknumber_timestamp_asset_wallet_from_wallet_to` (`blocknumber`,`timestamp`,`asset`,`wallet_from`,`wallet_to`,`memo_hash`)
55
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
56
+/*!40101 SET character_set_client = @saved_cs_client */;
57
+
58
+--
59
+-- Table structure for table `conf`
60
+--
61
+
62
+DROP TABLE IF EXISTS `conf`;
63
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
64
+/*!40101 SET character_set_client = utf8 */;
65
+CREATE TABLE `conf` (
66
+  `conf_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
67
+  `conf_value` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
68
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
69
+/*!40101 SET character_set_client = @saved_cs_client */;
70
+
71
+INSERT INTO `conf` VALUES 
72
+('utility_account','name_of_utility_account'),
73
+('topup_prs_limit','100'),
74
+('topup_tft_limit','100'),
75
+('topup_prs_transfer','100'),
76
+('topup_tft_transfer','100'),
77
+('topup_prs_memo','Automatic PRS top up'),
78
+('topup_tft_memo','Automatic TFT top up');
79
+
80
+--
81
+-- Table structure for table `hgm`
82
+--
83
+
84
+DROP TABLE IF EXISTS `hgm`;
85
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
86
+/*!40101 SET character_set_client = utf8 */;
87
+CREATE TABLE `hgm` (
88
+  `id` int(11) NOT NULL AUTO_INCREMENT,
89
+  `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
90
+  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ACTIVE' COMMENT 'Possible status are ACTIVE HIDDEN DELETED SUSPENDED',
91
+  `subid` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
92
+  `buy` double DEFAULT 0.1,
93
+  `sell` double DEFAULT 0.1,
94
+  `prs` double DEFAULT NULL,
95
+  `tft` double DEFAULT NULL,
96
+  `timestamp` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
97
+  PRIMARY KEY (`id`),
98
+  UNIQUE KEY `name` (`name`)
99
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
100
+/*!40101 SET character_set_client = @saved_cs_client */;
101
+
102
+--
103
+-- Table structure for table `memo`
104
+--
105
+
106
+DROP TABLE IF EXISTS `memo`;
107
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
108
+/*!40101 SET character_set_client = utf8 */;
109
+CREATE TABLE `memo` (
110
+  `id` int(11) NOT NULL AUTO_INCREMENT,
111
+  `block_id` int(11) DEFAULT NULL,
112
+  `memo_key` varchar(255) DEFAULT NULL,
113
+  `memo_value` varchar(512) DEFAULT NULL,
114
+  PRIMARY KEY (`id`),
115
+  KEY `block_id` (`block_id`),
116
+  KEY `memo_key` (`memo_key`),
117
+  KEY `memo_value` (`memo_value`)
118
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
119
+/*!40101 SET character_set_client = @saved_cs_client */;
120
+
121
+--
122
+-- Table structure for table `pending_payments`
123
+--
124
+
125
+DROP TABLE IF EXISTS `pending_payments`;
126
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
127
+/*!40101 SET character_set_client = utf8 */;
128
+CREATE TABLE `pending_payments` (
129
+  `tx_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
130
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
131
+/*!40101 SET character_set_client = @saved_cs_client */;
132
+
133
+--
134
+-- Table structure for table `users`
135
+--
136
+
137
+DROP TABLE IF EXISTS `users`;
138
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
139
+/*!40101 SET character_set_client = utf8 */;
140
+CREATE TABLE `users` (
141
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
142
+  `username` varchar(255) NOT NULL,
143
+  `password` varchar(255) NOT NULL,
144
+  `emailaddress` varchar(255) DEFAULT NULL,
145
+  `role` varchar(20) DEFAULT NULL,
146
+  `created` datetime DEFAULT NULL,
147
+  `modified` datetime DEFAULT NULL,
148
+  `hgm_id` int(11) DEFAULT NULL,
149
+  PRIMARY KEY (`id`)
150
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
151
+
152
+INSERT INTO `users` VALUES (1,'admin','$2y$10$012BWTuRtKQEwpM/lWA1FumB6rITsjgnOGWj1zveBZTEVseWWuQze','admin_email@example.com','admin', NOW(), NOW(), NULL);
153
+
154
+/*!40101 SET character_set_client = @saved_cs_client */;
155
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
156
+
157
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
158
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
159
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
160
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
161
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
162
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
163
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
164
+
165
+-- Dump completed on 2020-02-07 16:57:30

+ 85
- 0
src/Application.php View File

@@ -0,0 +1,85 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * For full copyright and license information, please see the LICENSE.txt
8
+ * Redistributions of files must retain the above copyright notice.
9
+ *
10
+ * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ * @link      https://cakephp.org CakePHP(tm) Project
12
+ * @since     3.3.0
13
+ * @license   https://opensource.org/licenses/mit-license.php MIT License
14
+ */
15
+namespace App;
16
+
17
+use Cake\Core\Configure;
18
+use Cake\Core\Exception\MissingPluginException;
19
+use Cake\Error\Middleware\ErrorHandlerMiddleware;
20
+use Cake\Http\BaseApplication;
21
+use Cake\Routing\Middleware\AssetMiddleware;
22
+use Cake\Routing\Middleware\RoutingMiddleware;
23
+
24
+/**
25
+ * Application setup class.
26
+ *
27
+ * This defines the bootstrapping logic and middleware layers you
28
+ * want to use in your application.
29
+ */
30
+class Application extends BaseApplication
31
+{
32
+    /**
33
+     * {@inheritDoc}
34
+     */
35
+    public function bootstrap()
36
+    {
37
+        // Call parent to load bootstrap from files.
38
+        parent::bootstrap();
39
+
40
+        if (PHP_SAPI === 'cli') {
41
+            try {
42
+                $this->addPlugin('Bake');
43
+            } catch (MissingPluginException $e) {
44
+                // Do not halt if the plugin is missing
45
+            }
46
+
47
+            $this->addPlugin('Migrations');
48
+        }
49
+
50
+        /*
51
+         * Only try to load DebugKit in development mode
52
+         * Debug Kit should not be installed on a production system
53
+         */
54
+        if (Configure::read('debug')) {
55
+            $this->addPlugin(\DebugKit\Plugin::class);
56
+        }
57
+    }
58
+
59
+    /**
60
+     * Setup the middleware queue your application will use.
61
+     *
62
+     * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup.
63
+     * @return \Cake\Http\MiddlewareQueue The updated middleware queue.
64
+     */
65
+    public function middleware($middlewareQueue)
66
+    {
67
+        $middlewareQueue
68
+            // Catch any exceptions in the lower layers,
69
+            // and make an error page/response
70
+            ->add(new ErrorHandlerMiddleware(null, Configure::read('Error')))
71
+
72
+            // Handle plugin/theme assets like CakePHP normally does.
73
+            ->add(new AssetMiddleware([
74
+                'cacheTime' => Configure::read('Asset.cacheTime')
75
+            ]))
76
+
77
+            // Add routing middleware.
78
+            // Routes collection cache enabled by default, to disable route caching
79
+            // pass null as cacheConfig, example: `new RoutingMiddleware($this)`
80
+            // you might want to disable this cache in case your routing is extremely simple
81
+            ->add(new RoutingMiddleware($this, '_cake_routes_'));
82
+
83
+        return $middlewareQueue;
84
+    }
85
+}

+ 246
- 0
src/Console/Installer.php View File

@@ -0,0 +1,246 @@
1
+<?php
2
+/**
3
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
+ * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
+ *
6
+ * Licensed under The MIT License
7
+ * For full copyright and license information, please see the LICENSE.txt
8
+ * Redistributions of files must retain the above copyright notice.
9
+ *
10
+ * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
+ * @link      https://cakephp.org CakePHP(tm) Project
12
+ * @since     3.0.0
13
+ * @license   https://opensource.org/licenses/mit-license.php MIT License
14
+ */
15
+namespace App\Console;
16
+
17
+if (!defined('STDIN')) {
18
+    define('STDIN', fopen('php://stdin', 'r'));
19
+}
20
+
21
+use Cake\Utility\Security;
22
+use Composer\Script\Event;
23
+use Exception;
24
+
25
+/**
26
+ * Provides installation hooks for when this application is installed via
27
+ * composer. Customize this class to suit your needs.
28
+ */
29
+class Installer
30
+{
31
+
32
+    /**
33
+     * An array of directories to be made writable
34
+     */
35
+    const WRITABLE_DIRS = [
36
+        'logs',
37
+        'tmp',
38
+        'tmp/cache',
39
+        'tmp/cache/models',
40
+        'tmp/cache/persistent',
41
+        'tmp/cache/views',
42
+        'tmp/sessions',
43
+        'tmp/tests'
44
+    ];
45
+
46
+    /**
47
+     * Does some routine installation tasks so people don't have to.
48
+     *
49
+     * @param \Composer\Script\Event $event The composer event object.
50
+     * @throws \Exception Exception raised by validator.
51
+     * @return void
52
+     */
53
+    public static function postInstall(Event $event)
54
+    {
55
+        $io = $event->getIO();
56
+
57
+        $rootDir = dirname(dirname(__DIR__));
58
+
59
+        static::createAppConfig($rootDir, $io);
60
+        static::createWritableDirectories($rootDir, $io);
61
+
62
+        // ask if the permissions should be changed
63
+        if ($io->isInteractive()) {
64
+            $validator = function ($arg) {
65
+                if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
66
+                    return $arg;
67
+                }
68
+                throw new Exception('This is not a valid answer. Please choose Y or n.');
69
+            };
70
+            $setFolderPermissions = $io->askAndValidate(
71
+                '<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',
72
+                $validator,
73
+                10,
74
+                'Y'
75
+            );
76
+
77
+            if (in_array($setFolderPermissions, ['Y', 'y'])) {
78
+                static::setFolderPermissions($rootDir, $io);
79
+            }
80
+        } else {
81
+            static::setFolderPermissions($rootDir, $io);
82
+        }
83
+
84
+        static::setSecuritySalt($rootDir, $io);
85
+
86
+        $class = 'Cake\Codeception\Console\Installer';
87
+        if (class_exists($class)) {
88
+            $class::customizeCodeceptionBinary($event);
89
+        }
90
+    }
91
+
92
+    /**
93
+     * Create the config/app.php file if it does not exist.
94
+     *
95
+     * @param string $dir The application's root directory.
96
+     * @param \Composer\IO\IOInterface $io IO interface to write to console.
97
+     * @return void
98
+     */
99
+    public static function createAppConfig($dir, $io)
100
+    {
101
+        $appConfig = $dir . '/config/app.php';
102
+        $defaultConfig = $dir . '/config/app.default.php';
103
+        if (!file_exists($appConfig)) {
104
+            copy($defaultConfig, $appConfig);
105
+            $io->write('Created `config/app.php` file');
106
+        }
107
+    }
108
+
109
+    /**
110
+     * Create the `logs` and `tmp` directories.
111
+     *
112
+     * @param string $dir The application's root directory.
113
+     * @param \Composer\IO\IOInterface $io IO interface to write to console.
114
+     * @return void
115
+     */
116
+    public static function createWritableDirectories($dir, $io)
117
+    {
118
+        foreach (static::WRITABLE_DIRS as $path) {
119
+            $path = $dir . '/' . $path;
120
+            if (!file_exists($path)) {
121
+                mkdir($path);
122
+                $io->write('Created `' . $path . '` directory');
123
+            }
124
+        }
125
+    }
126
+
127
+    /**
128
+     * Set globally writable permissions on the "tmp" and "logs" directory.
129
+     *
130
+     * This is not the most secure default, but it gets people up and running quickly.
131
+     *
132
+     * @param string $dir The application's root directory.
133
+     * @param \Composer\IO\IOInterface $io IO interface to write to console.
134
+     * @return void
135
+     */
136
+    public static function setFolderPermissions($dir, $io)
137
+    {
138
+        // Change the permissions on a path and output the results.
139
+        $changePerms = function ($path) use ($io) {
140
+            $currentPerms = fileperms($path) & 0777;
141
+            $worldWritable = $currentPerms | 0007;
142
+            if ($worldWritable == $currentPerms) {
143
+                return;
144
+            }
145
+
146
+            $res = chmod($path, $worldWritable);
147
+            if ($res) {
148
+                $io->write('Permissions set on ' . $path);
149
+            } else {
150
+                $io->write('Failed to set permissions on ' . $path);
151
+            }
152
+        };
153
+
154
+        $walker = function ($dir) use (&$walker, $changePerms) {
155
+            $files = array_diff(scandir($dir), ['.', '..']);
156
+            foreach ($files as $file) {
157
+                $path = $dir . '/' . $file;
158
+
159
+                if (!is_dir($path)) {
160
+                    continue;
161
+                }
162
+
163
+                $changePerms($path);
164
+                $walker($path);
165
+            }
166
+        };
167
+
168
+        $walker($dir . '/tmp');
169
+        $changePerms($dir . '/tmp');
170
+        $changePerms($dir . '/logs');
171
+    }
172
+
173
+    /**
174
+     * Set the security.salt value in the application's config file.
175
+     *
176
+     * @param string $dir The application's root directory.
177
+     * @param \Composer\IO\IOInterface $io IO interface to write to console.
178
+     * @return void
179
+     */
180
+    public static function setSecuritySalt($dir, $io)
181
+    {
182
+        $newKey = hash('sha256', Security::randomBytes(64));
183
+        static::setSecuritySaltInFile($dir, $io, $newKey, 'app.php');
184
+    }
185
+
186
+    /**
187
+     * Set the security.salt value in a given file
188
+     *
189
+     * @param string $dir The application's root directory.
190
+     * @param \Composer\IO\IOInterface $io IO interface to write to console.
191
+     * @param string $newKey key to set in the file
192
+     * @param string $file A path to a file relative to the application's root
193
+     * @return void
194
+     */
195
+    public static function setSecuritySaltInFile($dir, $io, $newKey, $file)
196
+    {
197
+        $config = $dir . '/config/' . $file;
198
+        $content = file_get_contents($config);
199
+
200
+        $content = str_replace('__SALT__', $newKey, $content, $count);
201
+
202
+        if ($count == 0) {
203
+            $io->write('No Security.salt placeholder to replace.');
204
+
205
+            return;
206
+        }
207
+
208
+        $result = file_put_contents($config, $content);
209
+        if ($result) {
210
+            $io->write('Updated Security.salt value in config/' . $file);
211
+
212
+            return;
213
+        }
214
+        $io->write('Unable to update Security.salt value.');
215
+    }
216
+
217
+    /**
218
+     * Set the APP_NAME value in a given file
219
+     *
220
+     * @param string $dir The application's root directory.
221
+     * @param \Composer\IO\IOInterface $io IO interface to write to console.
222
+     * @param string $appName app name to set in the file
223
+     * @param string $file A path to a file relative to the application's root
224
+     * @return void
225
+     */
226
+    public static function setAppNameInFile($dir, $io, $appName, $file)
227
+    {
228
+        $config = $dir . '/config/' . $file;
229
+        $content = file_get_contents($config);
230
+        $content = str_replace('__APP_NAME__', $appName, $content, $count);
231
+
232
+        if ($count == 0) {
233
+            $io->write('No __APP_NAME__ placeholder to replace.');
234
+
235
+            return;
236
+        }
237
+
238
+        $result = file_put_contents($config, $content);
239
+        if ($result) {
240
+            $io->write('Updated __APP_NAME__ value in config/' . $file);
241
+
242
+            return;
243
+        }
244
+        $io->write('Unable to update __APP_NAME__ value.');
245
+    }
246
+}

+ 156
- 0
src/Controller/ApiController.php View File

@@ -0,0 +1,156 @@
1
+<?php
2
+namespace App\Controller;
3
+
4
+use App\Utility\EprosumeModel;
5
+use App\Utility\WalletEprosumeModel;
6
+
7
+use Cake\Core\Configure;
8
+use Cake\Http\Exception\ForbiddenException;
9
+use Cake\Http\Exception\NotFoundException;
10
+use Cake\View\Exception\MissingTemplateException;
11
+
12
+use Cake\Event\Event;
13
+
14
+class ApiController extends SSPController
15
+{
16
+    private $user;
17
+
18
+    public function initialize()
19
+    {
20
+        $this->EprosumeModel = new EprosumeModel();
21
+        $this->WalletEprosumeModel = new WalletEprosumeModel();
22
+        $this->loadComponent('ApiAuth', [
23
+            'className' => 'Auth',
24
+            'authenticate' => [
25
+                'Basic' => [
26
+                    'fields' => ['username' => 'username', 'password' => 'password']
27
+                ]
28
+            ],
29
+            'userModel' => 'Users'
30
+        ]);
31
+    }
32
+
33
+    public function beforeFilter(Event $event)
34
+    {
35
+        if(!$this->user = $this->ApiAuth->identify()) {
36
+            return $this->response
37
+                ->withStatus(401);
38
+        }
39
+        if( 
40
+            $this->request->getEnv('REQUEST_METHOD') == "POST"
41
+            &&
42
+            $this->user["role"] != "admin"
43
+        ) {
44
+            return $this->response
45
+                ->withStatus(403);
46
+        }
47
+    }
48
+
49
+    public function blockID($block_id) {
50
+        $block = $this->EprosumeModel->blocksList(['id' => $block_id])->current();
51
+        return $block 
52
+            ? $this->response
53
+                ->withStatus(200)
54
+                ->withType('application/json')
55
+                ->withStringBody(
56
+                    json_encode(
57
+                        (function($array) {
58
+                            array_walk(
59
+                                $array,
60
+                                function(&$v,$k) use(&$array) {
61
+                                    if(!is_string($k)) {
62
+