-
Posts
7,529 -
Joined
-
Last visited
-
Days Won
160
Everything posted by kongondo
-
Do you need to sanitize radio buttons or checkboxes when using POST?
kongondo replied to SamC's topic in General Support
It's always good to sanitise and validate. You don't lose anything. The only things you don't sanitise are passwords (just validate) and usually, a submit button (just check if post sent). Regarding the radio buttons, you are using $sanitizer->option which is validating the options sent. Implicitly, you are sanitising here as well since you provide the array of sanitised values. Yes. Sanitise it too as necessary. But, these depend on what you are going to do with the values. General practice though is to sanitise at the earliest opportunity. There is also encoding of html entities if you are going to be echoing back input values. So, this... echo $sanitizer->entities($str); -
?? This is the ProcessWire forum. Please clarify your post.
-
I've been using the Auto-Open Markdown Preview extension. Works a treat. Only problem I have with it is that it does not auto-close the preview when the markdown file is closed.
- 246 replies
-
- 1
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
@gmclelland, Moderator note: Moved your post here as it seems to be related to this module.
-
Something like this... // your functions function doSomething($) { // @note: non-self-executing function // 'config' is a global PW variable var text = config.demo; $("h2.tagline").addClass("color-red"); console.log(text); } // ready jQuery(document).ready(function ($) { doSomething($);// pass jQuery ($) if needed });
-
Here's a ProcessWire 3 example. ProcessWire does all the heavy lifting regarding headers, etc. Please see comments in the code and the assumptions made. In this example, we assume a download link is present on the page. Modify the code to suit your needs, if you find it useful . <?php namespace ProcessWire; // @todo: you can add an Array $options parameter to pass to $files->zip() function createZip($zipfile = '', $filesToZip = array()) { // @see: https://processwire.com/api/ref/files/ $files = wire('files'); // @todo: error checks here, e.g. if $zipfile (destination) is empty; // save zipped files to disk // @see: https://processwire.com/api/ref/files/zip/ $files->zip($zipfile, $filesToZip); // force download of zipped files // @see: https://processwire.com/api/ref/files/send/ $files->send($zipfile, array( 'forceDownload' => true, 'exit' => false )); // delete zip file on server after download unlink($zipfile); exit; } $result = array(); $imagesArray = array(); $zipImages = array(); // grab and sanitize image names string in $_GET parameter 'images' // in this example, names are comma-separated $images = $sanitizer->entities($input->get->images); // if we have a 'get' input if($images) { // create array of image names (array('image-1.jpg', 'image2.jpg')) etc $imagesArray = explode(',', $images); // sanitize each image name as per ProcessWire filename expectations $imagesArray = $sanitizer->array($imagesArray, 'filename'); // if we got an array of sanitized image names if(count($imagesArray)) { // get the image repository // in this example, we store all images in one page in... // ... an image field named 'images' $imagesPage = $pages->get("/zip-files/zip-file-images/"); // create selector to find images requested in $_GET // this example assumes $_GET parameter 'images' contains image basenames // @note: we make sure image names are lowercase // selector: "basename=image-1.jpg|image2.jpg" $imagesSelector = mb_strtolower(implode('|', $imagesArray)); $images = $imagesPage->images->find("basename={$imagesSelector}"); // if we got a match if($images->count) { // create array of full disk paths to the image files $zipImages = $images->explode('filename'); // just making sure we got an array back if(count($zipImages)) { // name of zip file to create (or update) $zipfile = $config->paths->assets . "my_zip_".time().".zip"; // create zip file + force download //$result = createZip($zipfile, $zipImages); createZip($zipfile, $zipImages); } } } } // assuming $_GET will contain image basenames $downloadImagesLink = "/zip-files/zip-file-test/?images=abstract.jpg,Tree-Wide.jpg,fashion.jpg,dessert.jpg,citrus_fun.jpg"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title; ?></title> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" /> </head> <body> <h1><?php echo $page->title; ?></h1> <?php $out = "<p>Download Zipped Images</p>"; $out .= "<p><a href='{$downloadImagesLink}'>Click to download</a></p>"; echo $out; ?> </body> </html>
-
In that case, it's probably useful to show a PW warning notice for Superusers that some pages are hidden even for them. You might get tired of seeing the warning though :-)...but that can be set to show once per login session I suppose.
-
HEEELP! This request was aborted because it appears to be forged!
kongondo replied to Pixrael's topic in General Support
Excellent work on solving this! I am curios though, how would upgrading MySQL cause this? It seems the site was working OK pre-the upgrade. -
Preview/Discussion: RockDataTables
kongondo replied to bernhard's topic in Module/Plugin Development
Thanks for this! A while back (actually, a long time ago), I thought I'd checked them all but it seems there's quite a number of new kids on the block (unless I missed them first time round ). I would have loved a Pivot Tables feature (aggrid has this in the paid version). Sorry to hijack your thread Bernhard... -
OK. Since your priority is to get you site up and running, is it possible to, are you able to create an alternative database using your older MySQL version? Assuming you have a backup of the site pre-the upgrade, you would then import it into the new database and point ProcessWire to that. That would give you a breather to sort out your main issue. Just thinking out loud here. You've probably thought of these things already.
-
Preview/Discussion: RockDataTables
kongondo replied to bernhard's topic in Module/Plugin Development
Ah, I see, thanks. -
Preview/Discussion: RockDataTables
kongondo replied to bernhard's topic in Module/Plugin Development
I'd never heard of this grid, so thanks! I just had a quick look and it looks very powerful. Btw, I couldn't find info about the differences between the free and paid versions. Do you know what these are? Thanks. -
It's always off when bootstrapping, so no need to set it yourself.
-
Hi @Sabrina, I've removed the link in your post. Given that you are a first time poster and there is no indication that you are using ProcessWire, your link could have been subtle advertising. This is not allowed. If I am wrong, please clarify. We'll be happy to help if your site is made using ProcessWire.
- 1 reply
-
- 3
-
-
- javascript
- plugin
-
(and 2 more)
Tagged with:
-
[SOLVED] Best way to search a site including hidden child pages
kongondo replied to Juergen's topic in General Support
I might not be getting the full picture here but... It should be found if you use 'include=hidden' in your selector. Assuming the hidden pages will always refer to their parents... $search = $pages->find('body%=something, include=hidden'); $out = '<ol>'; foreach ($search as $s) { // if page hidden, grab url of parent if($s->isHidden()) $url = $s->parent->url; // if at the top of the tree, just return the found page URL elseif($s->rootParent == $s) $url = $s->url; // normal find else $url = $s->url; $out .= '<li>' . $url . ' (original path: '. $s->url.')</li>';// just for testing } $out .= '</ol>'; echo $out; You might want to change the logic a bit -
Actually, you might not even have to rename it. If you save it in /site/modules/, ProcessWire will tell you that you have two similar modules, one in /wire/modules/ and the other in /site/modules/. It will give you a choice to decide which one to use. You'll choose the one in /site/. I'd go for renaming it though to avoid confusion and also so that the one in /wire/modules/ can still be used for its normal purpose.
-
Yep. Here's the relevant section. http://processwire.com/api/multi-language-support/code-i18n/#translation-function-calls-must-be-on-one-line-and-in-one-pair-of-quotes
-
Depending on your use case, here's two other options Clone PageAutocomplete, rename the file and class, .e.g PageAutocompleteCustom, edit it to do what you need. The advantage here is portability, no need to Hook into anything, get to know the inner workings of ProcessWire (especially Pagefields, etc). Lister/Lister pro: This option depends on what you mean by 'keyword'. If it means some other ProcessWire property, you can easily filter results in Lister using various criteria
-
I get you now. You are not talking about ProcessWire /admin/child/....(i.e. children of Page with ID 2) but hidden pages in general. In that case, the module class name, title and description are misleading IMHO. Maybe change to something else?
-
. Hmm, aren't admin pages hidden for non-superusers by default?
-
On form submit, check if field values exist
kongondo replied to louisstephens's topic in API & Templates
Cool. Just optimise it with get() instead of find(). You could also use OR:groups selector. <?php $existing_name_check = $pages->get("name=$post_name"); $existing_email_check= $pages->get("submission_email=$email"); if (count($existing_name_check)) { $session->redirect("?alert=existing-submission"); } else if (count($existing_email_check)) { $session->redirect("?alert=existing-submission"); } else { // create page $session->redirect("?alert=form-success"); } // OR...make it shorter $exists = false; if($pages->get("name=$post_name")->id) $exists = true; elseif($pages->get("submission_email=$email")->id) $exists = true; if ($exists) { $session->redirect("?alert=existing-submission"); } else { // create page $session->redirect("?alert=form-success"); } // OR..make it even shorter (OR:groups) $exists = false; // @todo: you might want to check if page is in the trash here, i.e. parent.id!=7, etc if($pages->get("(name=$post_name),(email=$email)")->id) $exists = true; if ($exists) { $session->redirect("?alert=existing-submission"); } else { // create page $session->redirect("?alert=form-success"); } -
On form submit, check if field values exist
kongondo replied to louisstephens's topic in API & Templates
I suspect that's the issue. According to Profields: Textarea docs, you have to search the entire field. Since you want to search for both $somePage->submissions->email and $somePage->submissions->name (assuming name is the name of one of the properties in your Profields: Textarea), based on the example in the Profields: Textarea docs, your get() query could be: $submitted = $pages->get("parent=/submissions/entries/, (submissions%={$post_name}),(submissions%={$email})");