Jump to content

flydev

Members
  • Posts

    1,360
  • Joined

  • Last visited

  • Days Won

    49

Everything posted by flydev

  1. ? An issue was reported on github about the FTP functionality which was not working on PHP-8.1, which is fixed in the dev branch (Duplicator v1.4.24). As I didn't tested to backup a thing on GoogleDrive and Amazon S3, if you spot other issues, please feel free to report it in this same thread or fill a github issue. It might also be the time to implement something related to GDPR (package encryption) which I think was already discussed somewhere. Thanks you.
  2. It depend on how you configured the field. You can make it work by calling $page->images->first()->url The doc say: For more informations: https://processwire.com/docs/fields/images/
  3. Confirming that your snippet works fine here with LoginRegisterPro. But @Liam88 you have an issue, and if you are trying to debug/navigate to the url given by your $u->id link when there is no urlSegments, then you will end up on wrong user id, and then certainly on a random page ? // no urlSegment1 present // display links for user profiles? foreach($users->get('roles=login-register, sort=name') as $u) { echo "<li><a href='$u->id/'>$u->name</a></li>"; } $users->get() return a Page or null, so you are only getting iteration on the page's properties. You should use $users->find() to get the right $u page and his real id. Try with the correction and report back. And just a note: This method do not exist, it's isLoggedin(), with `Logged` and `in` in lowercase. Just in case to avoid future hassle ?
  4. But role is a thing, and permissions is another and this last is what you are looking for. Look there - https://processwire.com/docs/user-access/permissions/ - and try to play with them, then give a look at those modules : https://processwire.com/modules/admin-restrict-page-tree/ https://processwire.com/modules/custom-admin-menus/ For example, I have a role "accountant" and he do not have access to the page tree or any other features than the "accounting" module.
  5. Hi, you could use PageSum for simplicity. Just install the module and then for example: $selector = "parent=/products/, seller=$item"; // your selector $cnt = $pages->count($selector); // number of pages that match $selector if(!$cnt) echo 'No rated product found'; $sum = $pages->sum($selector, "rating"); // get sum of all matched products from "rating" field with "PageSum" $avg = $sum / $cnt; // math echo "Average rating of {$item->title} product (x$cnt) is ". number_format($avg, 2); // format number as needed
  6. Look at this example. Its made with the old version of RestAPI first made by @thomasaull years ago. To get the context, you can navigate to https://kingspark.fr and https://valideur.mykingspark.fr . I am speaking about a system which give the possibility to some of our client use their mobile or a barcode scanner device to give "free of charge parking" of their customer. Its composed with custom hardware, software and devices or mobile apps (you see it on GooglePlay). Image #1: List of Parkings // Image #2: The custom made SAGAS Terminal // Image 3: A configured User / Device available for registration and use. On the first picture, you can see a list of "Parkings", and some can have the "Valideur" functionality. We can configure attached devices and some users with specific role to get access for registration. And then, imagine the following. A customer land on the parking, grab a ticket and go to their rendezvous At the end, the guy in the office use his "Barcode Scanner" to "validate" the ticket of the customer; This mean that the customer will not pay anything when landing on the terminal to exit the parking, and when he will present the ticket on the barcode-reader installed on the terminal (the "black hole" you can see on the center in the picture), it will be recognized by another software and thought a call on ProcessWire Rest API backend. I made you two screencasts, the first is the software which once installed and registered, get the quota (number of validation available) from the user assigned to the license-code, and the second is my mobile which get notification sent from ProcessWire (by this module) from a monitoring system to get real-time information on registration. If you have any question, do not hesitate. There a more example, but you should get the whole idea ?
  7. What I would do in your scenario is: 1) Catch any \Exception and return a valid JSON with for example: $result = ['success' => false, 'error_msg' => 'Description of the error']; and log the exception original message in your logs 2) To "catch" a notice or warning, do that from a script that analyze a custom Apache ErrorLog and send you a mail on a pattern you would like to receive the mails. Just do not show "errors, mean warning, notice..." but log them into a custom Apache ErrorLog. 3) <- should be the first step, write Test Cases, test your code, and more over, do not upgrade a production code directly, as the most notice and warning you will get once your code is working is from deprecated code (PHP version, ProcessWire, Modules..). And do not forget that you can handle many scenario, eg., you can catch WireException, CustomException, \Exception. You could read some Ryan's code by opening files that are in the wire\core folder to get some example.
  8. I will take the time to answer your question a bit later @bernhard with some real example I use at work. But to get a general idea, when you go on the AppStore or GoolePlay, every app you see need to "discuss" with an (generally "Rest") API. Obviously there are many constraints to take into account when choosing the backend that will provide the API. For example, at work, I have servers that have to support quite heavy loads and that are written in Pascal. You can take a look there: https://synopse.info/files/html/Synopse mORMot Framework SAD 1.18.html#SOURCE (⚠️ it can hurt your head for the day ?) and read the general purpose and concept. I also have three ProcessWire backends (that need to be merged) that serve more user-oriented needs, such as apps delivered to customers or our technical maintenance group.
  9. @Liam88 you might try and ask @ryan if you could achieve it with the Pro Module `Likes`:
  10. Thank you for letting me know that they exist. I'm not even going to test them ? More seriously, the only thing I personnaly "miss" it's an official SomethingBidule_API core module maintained by @ryan . In the meantime, @Sebi is doing a great job, we just need people who want more functionalities, or rather something "more" solid, to do pull-requests.
  11. This IS NOT related directly to ProcessWire code. A critical CVE vulnerability was found in ZLib. Posting here in case some of you manage dedicated servers, and/or for checking if your hosting provider(s) do their job. more information: https://nvd.nist.gov/vuln/detail/CVE-2022-37434
  12. I am on mobile, so short answer. You can define your own error handler with `set_error_handler`. (Do not forget to restore the default handler, check the php doc.) Example: function send_email_on_notice() { … } set_error_handler("send_email_on_notice", E_NOTICE); […] restore_error_handler() Consider testing the behavior of it if you use it on a try/catch block.
  13. Hi, check the following thread, starting at this message (then read the whole thing) : ? And about locking a page before/after with your own logic:
  14. @bernhard sorry, forgot to include the link, edited the post.
  15. @bernhard you might want to take a look at this medium article, section mic/voice and OBS settings (I hope you are already using this one: https://github.com/obsproject/obs-studio/wiki).
  16. I think that some of your questions is just a matter of taste from every dev. Throwing my tastes below. I am personnaly not used to speak english with other people, and that's the most "complicated" thing to me when watching youtube video, anyway your accent is very good - I understand everything ?? It doesn't matter, everything need to be explained and you did very well. Taking time for learning is just required. (watched till the end last saturday with a coffee). Put this on the right-bottom corner, absolutely ! Both, make the video after writing the readme ?. I always end up on the video, after reading a readme, and if the readme only contain the link of the video, I feel very sad. Perhaps the sound of the voice should be a little higher pitched. No music for cencentration ! Or in the intro/Outro only ! ? You can be proud, thanks for it ?? Oh yes !
  17. You must write: `catch(\Exception $e)` as the object must be an instance of the Exception class or of a subclass (see/mean inheritance here) of the Exception class. A must read is this following blog post on Microsoft and then come back with questions if still any ?? https://docs.microsoft.com/en-us/archive/blogs/kcwalina/how-to-design-exception-hierarchies Excerpt from Krzysztof Cwalina (software architect) :
  18. A dumb question, disk or partition full ? You could also look at this answer on dba.stackexchange for identifying the issue: https://dba.stackexchange.com/a/48897/170766
  19. Just a thought before we go further. When is the 404 page displayed? On the index page (frontend) or only the admin page? If it's the second case, the .htaccess file is probably missing or the admin page entered may not be the right one (this can be checked in the database, table pages, id 2, column name) Otherwise, in the first case, check that you uploaded all the required processwire files (at least the index.php which will throw an error if the setup is ok, or as @DV-JF double or triple check your apache configuration on xampp.
  20. Ok, then to fix the error, in `ProcessLoginHistory` date format setting, put : Y-m-d H:i:s Then ping @teppo ?
  21. Ok then, first make a backup of the database, just in case, and please show us the full `call trace` logs shown on the tracy error (below the first error screen panel), along the ProcessWire version and MySQL version. You can also try to click on `Module Refresh` to see what happen. --- I didn't saw in first instance that the error was from the module `ProcessLoginHistory`, there must be a heck between the two modules. Will check. @Roych can you share the settings of `ProcessLoginHistory` and `ProcessLoginHistoryHooks` please ?
  22. To try it, you can just create a dummy page with page's name `hello` and paste the whole code in `ready.php` ?
  23. @Roych How did you changed the settings ? By hands or using the date picker ? Anyway, you can check if a weird date got saved in the module tables in the database. Open your database tool like `PHPMyAdmin` and check the following two tables : field_user_login_enabled_from field_user_login_enabled_until The values should be something like : 2022-08-23 00:00:00
  24. Check and try the following, I think the link provided all the infos. /// get and mod inputfield submit $wire->addHookBefore('InputfieldSubmit::render', function($event) { /// get page being edited from from query string $id = (int) $this->input->get->id; // ⚠️ sanitize it, do not trust your xss ninja admins $page = $this->pages->get($id); /// i.e. exit if page name is not 'hello' if($page->name !== 'hello') return; /// get the object the event occurred on $submit = $event->object; /// make sure to target the `submit save` button (it could be more than one button) $name = $submit->attr('name'); if($name !== 'submit_save') return; /// change the button's label (attribute: value) $submit->attr("value", "Foobar"); }); /// mod the inputfield submit dropdown $wire->addHookAfter('ProcessPageEdit::getSubmitActions', function($event) { $actions = $event->return; // array actions /// get page being edited from event's object $page = $event->object->getPage(); /// i.e. exit if page name is not 'hello' if($page->name !== 'hello') return; $actions['to_the_moon'] = [ 'value' => 'to_the_moon', 'icon' => 'moon-o', 'label' => '%s + Go Moon ?', // Save + Go Moon 'class' => '', ]; $event->return = $actions; }); /// process the new action dropdown $wire->addHookAfter('ProcessPageEdit::processSubmitAction', function($event) { $action = $event->arguments(0); // action name, i.e. 'cache' if($action === 'to_the_moon') { $event->message("Your page was rocketed to the moon ??", "nogroup"); } }); /// remove all the dropdown action but keep our new one $wire->addHookAfter('ProcessPageEdit::getSubmitActions', function($event) { $actions = $event->return; // array of actions, indexed by name /* bd($actions) ? 'exit' => array 'view' => array 'add' => array 'next' => array */ /// remove all action, let just keep our `to the moon` action foreach($actions as $action) { $name = $action['value']; if($name === 'to_the_moon') continue; unset($actions[$name]); } $event->return = $actions; }); /// bonus - add a second button on the current edit page $this->addHook('ProcessPageEdit::buildForm', function($event) { /// get page being edited from from query string $id = (int) $this->input->get->id; // ⚠️ sanitize it, do not trust your xss ninja admins $page = $this->pages->get($id); /// i.e. exit if page name is not 'hello' if($page->name !== 'hello') return; /// quite self explanatory $href = $this->config->urls->admin."page/edit/?id=$id&to=the_moon"; $field = $this->modules->get('InputfieldButton'); $field->attr('id+name', 'input_moon'); $field->attr('class', $field->class); $field->attr('value', 'To the moon ?'); $field->attr('href', $href); $event->return = $event->return->append($field); });
  25. Ok, then if you got redirected, it's a good thing. If you code the url, even hardcoded, you should be redirected to the checkout, but not in the admin.
×
×
  • Create New...