-
Posts
718 -
Joined
-
Last visited
-
Days Won
10
Everything posted by psy
-
Howto create and add language files to own modules
psy replied to cwsoft's topic in Multi-Language Support
Learnt the hard way that translations were a nightmare, both backend and frontend. Exuberant client wanted site in 15+ languages. There was a frontend language converter process module that relied on InputfieldCKeditor. Didn't work for me as the new preferred HTML inputfield uses TinyMCE. So I did a thing... Built my own module to convert all page active multilang fields via Google Cloud Translate. Works well and admin has the choice to enable/disable on page save. But currently has client-specific limitations and handling things like repeaters requires PW knowledge. It's frontend only. Happy to collaborate with another PW dev to make it viable for all and add to Download Modules. Let me know if you're interested. -
How to send Success 200 response to sender in webhook?
psy replied to psy's topic in General Support
@Denis Schultz so that's all I need? Just a header? -
I've set up a page to receive responses to events from another app's webhooks and it's working fine. The sending server needs to receive a http response of 200 before retrying. When the set number of retries fail, the web hook will be disabled by the sending host. From what I've read, often the 200 response will be returned auto-magically by the receiving host (in this case, PW). Doesn't appear to be happening. The sending host keeps retrying. I'd like to deliberately send the success response back to the sending host and I suspect https://processwire.com/api/ref/wire-http/send-status-header/ will be in the mix somewhere. Just not sure how to set it up. So far I have: <?php namespace ProcessWire: $phpInput = @file_get_contents("php://input"); $payload = json_decode($phpInput); if(!$payload->scope) exit(); // not valid BC webhook // need to send the 200 response here to let BC know the response was received successfully Guidance much appreciated. Cheers psy
-
Thank you for investigating @wbmnfktr ? I had tried re-saving in different formats without success. It was only when I made one image bigger and it uploaded that I realised the file size was triggering the issue. @netcarver's suggestion of a ModSecurity issue with the web host was 100% and nothing to do with PW.
-
@netcarver Using PW 3.0.210 and nothing special in .htaccess other than ProCache directives, https only and <IfModule mod_mime.c> AddType image/webp .webp </IfModule> Strange that it only happens on small images. No problem at all on larger image file sizes. I changed the default image quality from 90% to 100% in case that made the file invalid but no difference. All PHP image processing modules seem OK. As for ModSecurity, yes it's on a shared host that has ModSecurity. That's been a nightmare on many occasions for other things. I have the web host on speed dial. Good call to check that one.
-
There are many forum topics and suggested solutions to problems uploading images in PW admin. I've read all I can find but none address the problem I'm experiencing. It's consistent and repeatable. I have an image field in my template (duh!) and I can successfully upload any images with an approved image file type that has a file size over 10kb. Any images (png or jpg in this case) with file size of <10kb fail with the following error: I have even taken one of the small images, given it a bigger canvas in Photoshop, converted to PNG/JPG and successfully uploaded it. I could also hack it and make all my images bigger then use the api/image variations to reduce them on frontend output but that's not the point and a lot of unnecessary effort and wasted disk storage. Suggestions on how to fix the underlying problem most welcome. TIA Solved Thanks @netcarver for suggesting it may be a ModSecurity issue. Nailed it. Web host whitelisted my IP from their (obscure) rule and the uploads worked perfectly ?
-
Nothing in this post since 2020 then a client got this today... Similar to above comments, I'm convinced it's just a nasty extortion threat and should be ignored. Form is in Formbuilder iframe and full of all ProcessWire & FB sanity checks. Site is functional and no obvious hacks. Told client that if it was real, they should feel privileged to be the first ever recognised PW hack victim. Also feeling a bit chuffed that this little, local Aussie site was found on the global hacker network.
-
OMG solved! ? When I was digging into wire/core/WireHTTP I think the file got corrupted, maybe during an upload to my dev server (yes, still staging) Replaced it with a new copy and site is working again @netcarver truly appreciate your help and patience.
-
@netcarver I tried that on the frontend and it worked but now every time it has to wire a new page, or in admin perform some http task, it fails. My error logs are filling up fast
-
@ryan any ideas? Nothing that involves https works, eg admin 'Save' functions, frontend redirects.
-
Have uninstalled: TracyDebugger LoginRegisterPro (not used anyway) Very few other modules in use and still the error, admin & fe ?
-
@netcarver Thanks for your input. Site doesn't use any hooks Searched Google, forum but not repo. Will do so now. There was an old post that was vaguely similar but didn't have an answer. See link below Turning off the error may hide the error message but, you're right, it will totally obscute the real issue.
-
I've been working on a a new site for weeks. $session did it's normal, wonderful stuff until today when it didn't - boom!!! $session now occasionally holds vars from one page to another. The killer is $session->location or $session->redirect. Before redirecting, the page crashes with: I went back to basics with the default theme: Using ProcessWire 3.0.212 dev PHP v8.1 (tried 7.4 & 8.0 too) Error occurs in Chrome & Firefox Editing modules, eg turning TracyDebugger on/off also triggers the problem Error occurs in front and back end. Often, clicking on a link to a different page clears the error but $session still screwy. Have no idea why PW suddenly stopped correctly wiring $session. Is this a bug? Am I doing something wrong? Help & ideas on how to fix gratefully accepted. Solved: Upload a fresh copy of WireHTTP to my server. Previous version may have been corrupted in transit.
-
[solved] WireHTTP POST sending application/json data problem
psy replied to psy's topic in General Support
Solved! Instead of re-using the same $http object I'd used for multiple previous GET requests, I created a new one, ie $postHttp. Postman had "no-cache" as a header.. Thanks again for the tip @netcarver -
[solved] WireHTTP POST sending application/json data problem
psy replied to psy's topic in General Support
Thanks for the tips netcarver. Will compare the headers ? I had "Content-Type" then looked into WireHTTP.php where it's listed everywhere in lowercase, eg: <?php public function post($url, $data = array(), array $options = array()) { if(!isset($this->headers['content-type'])) $this->setHeader('content-type', 'application/x-www-form-urlencoded; charset=utf-8'); return $this->send($url, $data, 'POST', $options); } -
I'm trying to post json data to an endpoint with: <?php $http = new WireHttp(); $http->setHeaders([ 'X-Auth-Token' => 'XXXXXX', 'Accept'=> 'application/json', 'content-type' => 'application/json' ]); $myEndPoint = "https://myendpoint.com/api"; $params = [ 'parent_id' => 0, 'name' => "My Name", 'is_visible' => false ]; $paramsJSON = json_encode($params); $http->setData($paramsJSON); $response = $http->post($myEndPoint); if($http->getError()) { echo "HTTP request failed: " . $http->getError(); $this->die; } //..... } It fails every time no matter how I present the $params with: HTTP request failed: 400 Bad Request:. It works successfully when I post through Postman app. The endpoint & headers are correct and used successfully elsewhere with $http->get Help to fix much appreciated.
-
Have you set up your local URL's on the Home page 'Settings' tab, url fields ? It's usual to use the ISO Language (not Country) codes, eg 'de' for 'German'.
-
Is it possible to shorten the page title or make an alias for it?
psy replied to Boost's topic in General Support
An alternative approach using native PW is to make your titles the shorter version and use a field, eg 'headline' for the lengthy version. In your templates use: <h1><?=$page->get('headline|title')?></h1> This will output the headline if it's available and if not, the title. You can then also use the shorter version in front end menus, etc. In the admin page list, it will default to the shorter 'title' field. If you need the front end page URL to be the longer version for SEO, you could add a hook in templates/ready.php, eg (untested): <?php $wire->addHookBefore('Pages::saved', function(HookEvent $event) { $page = $event->arguments(0); // ensure it meets the requirements if (empty($page->headline) || $page->template !== 'your-template-name') return; // regenerate the page url from the headline field $page->url = wire('sanitizer')->pageName('headline'); // Populate back arguments $event->arguments(0, $page); }); And another way.... In your template, Advanced tab, under "List of fields to display in the Admin Page List", simply enter {name-of-your-shorter-field} -
3.x: To many languages breaks MySQL index limit
psy replied to phiro's topic in Multi-Language Support
-
Hi @Sebi Would you please give some actual code examples? I've tried all sorts of variations and if I manage to get a response, it's always in the default lang (English), eg: Thanks for all the work you've done with AppApi and the add-on modules. Hope you can help. Cheers psy SOLVED (almost!) In _init.php: In my page template javascript: In my AppApi custom class to make it multi-language: Everything seems to work fine EXCEPT when using AppApiPage on the home page. The response is still always in the default language.
-
Tip for the unwary... My admin site's default lang is 'en' - just happens as per install. Was surprised to see that the new TinyMCE inputfield menus etc defaulted to Russian ?. Solution: When configuring Modules -> InputfieldTinyMCE, ensure your 'default' lang is set to the correct lang code, eg "en-US"
-
@DV-JF it was running 3.0.200 and I upgraded to the latest dev 3.0.207 I also changed line 845 in PagesLoader.php to confirm if $options is an array: $options = is_array($options) && count($options) ? array_merge($defaults, $options) : $defaults; Switched the site back to PHP8 and it's working again. @ryan fyi
-
It worked before and now not ? The web server was recently upgraded to PHP8 and I know PHP8 is much stricter on argument typing than previous PHP versions, and this blip resulted in a Server 500 error: 2022-11-16 14:56:21 guest https://xxxxxxx.com/api/ Fatal Error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /home/xxxxxxx/public_html/wire/core/PagesLoader.php:845 The code was a 'page get' selector request in an ajax call. It all worked before the PHP update and I'm sure there are others using $pages->get() without issues on PHP8. $pages->get("id=". $sanitizer->int($data->pid)) I also tried it without the "id=". I think the problem is more that $options is a string in the line in the PagesLoader.php: <?php $options = count($options) ? array_merge($defaults, $options) : $defaults; Any ideas on how to fix? Thanks, psy Solution Changed line 845 in PagesLoader.php to confirm $options is an array and the site worked again. $options = is_array($options) && count($options) ? array_merge($defaults, $options) : $defaults;
-
On many of my sites I have a page for business information which includes: toggle for site down for maintenance or live combo field for business name, address, phone, email, contact name, etc functional field for common phrases The combo field is great in this scenario. The data is fairly static and I only need to add the one combo field for a bunch of 'sub' information, bits of which may be used throughout the site. The alternative is to create a fieldset with individual fields, all of which would only be used in a single template and have one entry per field.
-
[SOLVED] Chrome marks some of my language pages as dangerous
psy replied to psy's topic in Multi-Language Support
Hi @Jan Romero The PW docs refer to language codes. I didn't realise language codes and country codes were slightly different. Solution discovered by trial and error, and ironically, Google's Search help. Initially the warning only appeared when that lang page loaded, but once done so, the whole site had "Dangerous" in the browser address bar. Refreshing using the default lang cleared the message.