Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/13/2020 in all areas

  1. This week I’ve been continuing to work on the new ProcessWire modules directory, this time focusing on the front-end editing aspects for module authors. This is the part that deviates the most from the existing modules directory (and makes revolutionary improvements upon it), so none of this is on the production server yet, and it’s going to take a little more time to develop. LoginRegisterPro and FormBuilder are saving a lot of time in the development. LoginRegisterPro handles the account management side, while all module editing forms are powered by FormBuilder. By next week I’m hoping I might be able to launch the new editing features so that module authors can begin to use the system, but we’ll see how it goes. This week there have also been several updates to the core dev branch, including both improvements and issue fixes. By next week I also expect to bump the version to 3.0.169. For more on the modules directory improvements, be sure to also see last week’s post.
    6 points
  2. I have built a couple of similar systems, it's actually not that difficult. You don't need a module for it, you can just write out the logic in your PHP template (I prefer to use custom page classes for stuff like this, but the template file will do fine). A good trick to get started is to separate the requirements into individual tasks that you can finish one by one. In your case, I would divide the requirements into the following tasks and questions: Create a data structure to hold your access codes, i.e. either a field or new template. (Optional) How and when are codes created? Manually or automated? For example, when a new concert is created in the system, you could generate a number of access codes automatically, or create a code when a reservation comes in. (Optional) How are codes distributed? For example, you could select a random code (or generate a new one, see above) when a registration comes in and send it in an autoresponse email. Create an interface for entering your individual code on a concert page, and validate the codes. Store the authorization (i.e. a valid entered code) so it can only be used by one person. Then you can think about how to solve those problems using either custom code or the tools that come with ProcessWire. Here are some suggestions: I usually use a Table field (part of the ProFields module), because it allows you to store a code alongside with information on it (like expiration date, used/available flag, etc) in a single field. I would have one dedicated template for access-protected events (in your case, concerts) and add one Table field to it which holds the codes for this event. You can solve this with simple hooks. For example, automatically creating a number of access codes when a new concert is created is only a matter of hooking Pages::add. Or if you want to create codes on demand during registration, hook into the relevant part of your registration process to create the codes when needed. I would build a simple registration form using FormBuilder, which already includes input validation, payments processing and autoresponder. Again, you can use hooks to insert an individual access code into the autoresponse email. You'll want to have a flag in your codes table which keeps track of whether this code has been used or not, to make sure each code can be used only once. You can do this in PHP directly in the template file: Check if the user is already authorized for this concert (see below), and if so, display the concert's content / stream / whatever. If the user is NOT authorized, display a form for entering the access code. If a code was submitted, check if the code is valid (i.e. it exists on this page, has not been activated yet — this should be a separate flag in your Table field — etc). If it is, store the authorization for this user (see below) and display the concerts content. You can use multiple approaches for this, depending on how serious you are about preventing misuse. A simple approach would be to store the authorization in a cookie or session. This would allow the same user to close and reopen the page (though using the session would mean the codes only stay active for the current browser session). This is pretty simple, but of course has it's limitations. For example, what if users want to switch from the desktop to a mobile phone? Distinguishing between one user switching devices and multiple users sharing an access code will be difficult. Another possibility is to user ProcessWire user accounts, requiring users to create an account and then adding the authorization for individual concerts to their account directly. Using accounts you could make access codes obsolete entirely. Of course, you'll have to find a solution against account sharing (I'm not sure if ProcessWire allows multiple simultaneous sessions for one account by default). Note that none of those solutions stop a really determined bad actor from sharing their access to your concerts, or the content you provide. The only solutions for this is to integrate DRM, which is really difficult and not really feasible for small websites. But both the solutions above should work mostly fine. Ok this text got longer than I intended, and I know it's not a complete solution. But you see the point – by breaking down the requirements into individual parts the system becomes much easier to build. You can pick and choose from existing solutions (ProcessWire user accounts, the FormBuilder and ProFields module, etc) and combine them with custom logic using hooks or the template file. The rest is just a matter of experience with ProcessWire and PHP. If you get stuck on coding specific steps of this system, make sure to post them here, there's always a good solution!
    5 points
  3. Perhaps you can remove them from showing up in the PWUpgrades module, because it's pretty confusing as it is and it's a new thing seeing them there.
    1 point
  4. Just jumping in to say that I had to also remove this line in order for www. forwarding to work. I think its supposed to check that is not running locally, so we don't force www. but even in prod my servers are running on localhost/ 127.0.0.1. CC @ryan as there may be a bug in the htaccess. Alternatively it may just need an updated comment to remove that line in prod ¯\_(ツ)_/¯
    1 point
  5. @bernhard - this might also be useful for getting PW's $config->ajax to work and also make Tracy capture the errors. Not sure how to do it within uikit requests. It's automatic with jquery.
    1 point
  6. Why I'm still using jQuery in 2019
    1 point
  7. You need to add: xhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest"); This is something that jquery does automatically, but you have to do yourself with vanilla JS. I think you may also need to add this inside your xhttp.onreadystatechange function. xhttp.getAllResponseHeaders();
    1 point
×
×
  • Create New...