-
Posts
2,765 -
Joined
-
Last visited
-
Days Won
40
Everything posted by Macrura
-
yep - in my case we also hash the client ID: $client_key = $calendar->client_select->id; $ak_hashed = $sanitizer->text($input->get->access_key); $access_key = $hashids->decrypt($ak_hashed); if($client_key != $access_key[0]) exit('Invalid Access Key'); As Teppo points out, using 2 hash IDs, one for the the page and one for the user and then seeing if the user has access to that page is an additional security. In my case these are not users, but simple pages storing contact info; You could also get real PW users and then use ACL to check for access...
-
Using Hashids you can accept encrypted page IDs in a querystring, decode them for use in selectors. Why would you want to do this? In my case I have a private calendar feed where each calendar is a page, but i don't want people seeing the page IDs and then possibly guessing another person's calendar id. 1.) include the hashids class, either with the composer or in my case i'm using the old version which is 1 php file (you can find this in the wordpress plugin version). 2.) Depending on which version you use, the method is different; read the docs to see which version you need; my code is relevant to the old 0.1.3 version which is good enough for this application. include('./classes/hashids.php'); $hashids = new hashids('your_unique_salt_here'); if($input->get->cal_id) { // the cal id coming in is a text hash ID: $cal_id = $sanitizer->text($input->get->cal_id); // decrypt the hash ID to the integer $cal_id = $hashids->decrypt($cal_id); // Look up the calendar: $calendar = $pages->get($cal_id[0]); if( !$calendar->id ) exit('Calendar not found.'); // at this point you would execute your actions, e.g. render your calendar feed etc.. exit(); } You would also need a way to generate your links wherever you are sending or displaying them, with the hashed ID. $calId = $hashids->encrypt($calendar->id);
-
portable web server. with PW... bitnami?
- 30 replies
-
- deployment
- tools
-
(and 1 more)
Tagged with:
-
no problem.. have you echo'd what PW is generating for your $page->Header_select->contactAddress ?
-
you would retrieve the email address like: $emailTo = $page->Header_select->contactAddress; BTW - you are mixing up your cases, your variable is camelCase, your page select is underscore_case with the first letter capitalized, and your page field is camelCase. For clarity and ease I would recommend at least being consistent with your field naming, e.g. always use underscore_case (no caps) or camelCase.
-
no idea what you're talking about, but if you post some code and more info, it should be a piece of cake.... email is a strong point for PW (wiremail, mandrill integration...)
-
Remove duplicates in a foreach loop (but count them)
Macrura replied to Reid Bramblett's topic in Getting Started
cool -
We could drink Club Mate instead of coffee, for this 1 day
-
Remove duplicates in a foreach loop (but count them)
Macrura replied to Reid Bramblett's topic in Getting Started
you mean counting like this? $kids = $pages->find("template=poi, has_parent=$page"); $interests = new PageArray(); foreach ($kids as $k) $interests->import($k->interests); $iTotal = count($interests); foreach ($interests as $i) $i->useCount = count($pages->find("interests=$i")); echo "<h3>Interests ($iTotal)</h3>"; echo '<ul>'; foreach ($interests->sort("-useCount") as $i) { echo "<li><a href='interest/$i->name'>$i->title</a> ($i->useCount)</li>"; } echo '</ul>'; -
Remove duplicates in a foreach loop (but count them)
Macrura replied to Reid Bramblett's topic in Getting Started
ok i fixed the code for the 2nd one adding the missing close ) however the first example should work, there can't be duplicate pages in the PageArray(), so you must be doing something funky if you are getting the same 'interest' tag. Are you positive you don't have duplicates in your system - are the interests all stored under the same parent? You should check; if you do have duplicate interest titles in your system PW can't remove the duplicates from the array because it is keyed to the page ID. you could sort the array by title and then check to see if the previous item has the same title and then skip it, that's an easy way to exclude duplicates. -
Remove duplicates in a foreach loop (but count them)
Macrura replied to Reid Bramblett's topic in Getting Started
you have some options... <?php // version using PageArray(); $kids = $pages->find("template=poi, has_parent=$page"); $interests = new PageArray(); foreach ($kids as $k) $interests->import($k->interests); echo '<ul>'; foreach ($interests as $i) { echo "<li><a href='interest/$i->name'>$i->title</a></li>"; } echo '</ul>'; // or find all interests, cycle through but ignore those that don't apply to this page $interests = $pages->find("template=interest"); echo '<ul>'; foreach ($interests as $i) { if(!count($pages->find("template=poi, has_parent=$page, interests=$i"))) continue; echo "<li><a href='interest/$i->name'>$i->title</a></li>"; } echo '</ul>'; ?> wow, 3 replies! -
isnot would be expressed by the false of is if(!$page->is("template=foo|bar"))
-
Kraken: Drop Jumbo with Astro Navbar. Conversion to ProcessWire
Macrura replied to Christophe's topic in General Support
i think the referenced functions are simply conditional and foreach statements that are crafted to get a needed output. If you are doing a mega menu, you just need to analyze the structure/pattern and try and see if there is some way to foreach through your page tree or menu tree and get the output you want. -
how are you getting that partial=true, i can't see how the render method takes any arguments, at least not here: http://cheatsheet.processwire.com/page/built-in-methods-reference/page-render/ perhaps you could use wireRenderFile, or wireIncludeFile
-
having some trouble with CC, i'm supplying an array, like this: $mail->cc($array); and i know my array is good, and CC works for 1 CC (I have $mail->sendSingle(true); ) but it will only CC the last member of the array, no matter which array type i input. ...... OK - forget this, i just updated to the latest version and this was fixed...
-
Kraken: Drop Jumbo with Astro Navbar. Conversion to ProcessWire
Macrura replied to Christophe's topic in General Support
Can you post your page tree structure, and then how you want that to translate into the menu, this way a function can be written to get the menu to output according to that structure, but with the required markup. -
Perhaps a quick way to troubleshoot would be to look at a formbuilder form, an example of which is the showcase submission form (categories field). Looking at the source code of that might possibly reveal any dependencies; Also that may be running in an iframe, which is the default embed method for FB.
-
so far it is not affecting existing accounts.
-
Kraken: Drop Jumbo with Astro Navbar. Conversion to ProcessWire
Macrura replied to Christophe's topic in General Support
there are some examples of custom functions to generate specific menus; maybe this could provide some ideas: https://processwire.com/talk/topic/9033-mega-menu/?p=87201 -
are you using the api to generate your form, or manually coding it?
-
right, that's good to know (nevermind my dumb question)... i guess MSN changes the $page context, even though you set the variable outside of the options...in other words $page when in options means the menu item page, not the page being viewed;
-
Repeater won't save repeater items added programmatically
Macrura replied to efiguerola's topic in API & Templates
Wouldn't you need to save the repeater like this? $channel->save('tvChannelGrid'); // Save the repeater. that's how i usually save fields; not sure if you would need to save the page after that. -
since that app was made, PW has grown a lot, and now you could probably achieve a lot of those views in the stock admin, e.g. using lister, page tables etc..
-
@Peter Knight - won't $myimage always be the icon for the current page? $myimage = $page->images->getTag('icon')->width(50)->url; or does the $page context change inside the MSN loop? ... curious about your solution