-
Posts
807 -
Joined
-
Last visited
-
Days Won
10
Everything posted by kixe
-
PagefileSecure and Page::isPublic() hook not working
kixe replied to thetuningspoon's topic in API & Templates
1) Yes my example block all files, I made this just for testing. You have to modify it for your needs. 2) Yes. It looks like it is accessed directly. A http header will be sent by WireHttp::sendFile() and output the content of the given file if the page is unpublished. If you don't set $config->pagefileSecure = true; all files will stay accessible even if the page is unpublished. If you hook in Page::isPublic() and return false the name of the files directory changes and your .htaccess will prevent accessing files under the secured path. If you make changings in your page and save it the files directory will be renamed again. Thats why this solution is a bit hacky. I wouldn't go forward in this direction. You should look for another solution. -
related stuff: If you just want to update $page->of(false); $page->status = 2049; $page->save(); $page->status = 1; $page->save();
-
PagefileSecure and Page::isPublic() hook not working
kixe replied to thetuningspoon's topic in API & Templates
I ended up to do both: wire()->addHookAfter('Page::isPublic', function($e) { $e->return = false; }); wire()->addHookBefore('ProcessPageView::sendFile', function($e) { throw new Wire404Exception('File not found'); }); This is all a bit hacky, maybe you should follow the solution @LostKobrakai mentioned. -
PagefileSecure and Page::isPublic() hook not working
kixe replied to thetuningspoon's topic in API & Templates
I tried it out and it works for me. I set $config->pagefileSecure = true; and put the following hook in ready.php wire()->addHookBefore('ProcessPageView::sendFile', function($e) { throw new Wire404Exception('File not found'); }); -
@PWaddict I missed to add the hook which update pagenames even if language support isn't enabled. I fixed this in Version 2.0.3 If you use the module in single language mode this might have been the cause. Thanks for your help.
- 100 replies
-
- 2
-
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
I am sorry about that. Did you get any Errors? Exceptions? Please let me know. I tested the module in 2 different environments. It worked there without problems. @Robin S Thanks for the hint. I added a note to the config field and the readme.
- 100 replies
-
- 1
-
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
@PWaddict Thanks for the input. I made the module configurable with the option you mentioned. Furthermore I did some repairings for some special cases. Seems to work. Please try Version 2.0.2
- 100 replies
-
- 2
-
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
For testing purposes I am running a simple website providing vat exchange rates related to german tax law via api in different formats. http://umsatzsteuer-umrechnungskurse.org I have a template api.php where the api get vars are sanitized. A custom module process the input and provide the requested data by sending headers. One output function of my module as an example: /** * @param int/string year * @param int/string to year (optional) * @param bool return the € value referenced to the listed currency * @return bool/ json document * */ public function outputJSON($from_year, $to_year = null, $invert = false) { if (false === $json = $this->getStringJSON($from_year, $to_year, $invert)) return false; header('Content-Type: application/json; charset=utf-8'); print $json; } my template api.php $config->prependTemplateFile and $config->appendTemplateFile disabled via module settings. <?php // a data request if ($input->get->k) { // get the module $gvr = $modules->get('GermanVatExchangeRate'); // sanitize input $key = $sanitizer->name($input->get->k); $checkKey = $gvr->keyCheck($key, $max); // ... try { $result = $gvr->convert($curr, $value, $month, $year, $inv); // log api access $gvr->log($key); } catch (WireException $e) { $result = "ERROR: ".$e->getMessage(); } die($result); } // ... // something went wrong die('ERROR: Not specified'); } // not a data request render api page else { include_once('_init.php'); $content = $page->body; include_once('_main.php'); }
-
I posted an issue related to modules naming guide/ convention on github. https://github.com/processwire/processwire-issues/issues/164 Any guidelines using numbers in general in module names like @adrian or I did Process404Logger Process404Search HTML5Boilerplate
-
Allow urlSegments for this template. Create a selector including this urlSegment (user name). Read more about selectors: https://processwire.com/api/selectors/ Read more about urlSegments: https://processwire.com/api/variables/input/
-
Image field: check if first image is under a certain width
kixe replied to OpenBayou's topic in API & Templates
if ($page->imagefield->first()->width < 200) { // do something } -
in your config.php // min: 100, max: 259 default: 130 $config->adminThumbOptions = array_merge($config->adminThumbOptions, array('gridSize' => 100)); Smaller than 100 (like in your screenshot) is not possible using this approach. I tried this one too but didn't work. (I think it should!) $config->adminThumbOptions['gridSize'] = 100; Learn more about this by reading the comment in /wire/config.php
-
Default session lifetime is 86400 seconds. You can change this to any value you want. // config.php $config->sessionExpireSeconds = 86400; Allow/ disallow sessions (and the wire cookie) under conditions. Remind that you need this to have access to the backend admin. // config.php $config->sessionAllow = true; If you want to disable cookies only for the frontend /** * config.php * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // otherwise disallow session return false; }; If you want to use cookies respecting EU Cookie law I recommend Cans Module MarkupCookieConsent in combination with this settings. /** * config.php * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // user accepted cookies due to EU law (Module MarkupCookieConsent) if(!empty($_COOKIE['eu-cookie'])) return true; // otherwise disallow session return false; }; Use the core module SessionHandlerDB to store session vars in the database. Learn more about session setting options and sessions by reading the comments in the files /wire/config.php or /wire/core/Session.php of your processwire installation.
-
Image save issue in custom page edit process module
kixe replied to simon's topic in Module/Plugin Development
Have a look here: https://gist.github.com/somatonic/5233338 -
@neonwired Welcome. Please post your code otherwise it is difficult to help. PageImages is a WireArray. Depending on your fieldsettings you maybe need to access a specific image as follows $page->my_image_field->first() // first image of the field $page->my_image_field->last() // last image of the field $page->my_image_field->eq(4) // 5th image of the field
-
Your if statement use an assignment operator (=) instead of a comparison operator (==).
-
For the sake of completeness assuming the following fieldsettings under details tab 1=title echo $child->deals_store; // print the id as string var_dump($child->deals_store->id); // int(1) var_dump($child->deals_store->sort); // int(0) var_dump($child->deals_store->value); // string(0) "" var_dump($child->deals_store->title); // string(5) "title" using the option to add a value beside the id you can use the following setup 1=value|title var_dump($child->deals_store->value); // string(5) "value" for validation please keep in mind var_dump($child->deals_store == '1'); // bool(true) var_dump($child->deals_store == 1); // Notice: Object of class ProcessWire\SelectableOptionArray could not be converted to int if ($child->deals_store == '1') { // do something }
-
If you have a SSL certificate for your domain (https) the wire cookie is set with the secure flag by default. Have a look in wire/config.php /** * Use secure cookies when on HTTPS? * * When enabled, separate sessions will be maintained for * HTTP vs. HTTPS. This ensures the session is secure on HTTPS. * The tradeoff is that switching between HTTP and HTTPS means * that you may be logged in on one and not the other. * * 0 or false: secure cookies off * 1 or true: secure cookies on (default) * * @var int * */ $config->sessionCookieSecure = 1; In the .htaccess file you can force using https: # ----------------------------------------------------------------------------------------------- # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below. # ----------------------------------------------------------------------------------------------- # RewriteCond %{HTTPS} off # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # If the flag is enabled, the browser (should) send the cookie only via https.
-
There is always a limit for numeric values using mysql databases. The Processwire builtin FieldtypeInteger for example can store values between 0 and 4294967295. Creating a custom Fieldtype may store integer values until 18446744073709551615 if you use Data type BIGINT. (note: assuming you are talking about integer values. There are also limits for text and other stuff)
-
You maybe need to replace 'admin' with the name of your superuser, if it is not 'admin'. If your 'superuser' is 'admin' check in the database if a page (user) named 'admin' exist and if the correct parent (29) is assigned.
-
The following solution with 2 separated rules should produce only one redirect. RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] This one should work for your domain with a single rule RewriteCond %{HTTP_HOST} ^www\.grantdb.ca$ [OR] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://grantdb.ca/$1 [L,R=301] The issue in my suggestion above was that the first condition fills the variable %1% with the trailing slash which results in redirecting to https:///
-
@efiguerola Sorry for the late answer. I cannot reproduce this error. This is a Chrome specific error message, which could be related to firewall settings or other security settings on your machine. Since there is no Error logged in the system, everything is working as it should. Could you please try out with other browsers: Firefox, IE or Safari. What happens there? Did you make any settings, or does this happen immediately after creation of the field?
-
@joe_g Setting 'Maximum length' to '0' (indicates no maximum) under the 'Input' tab in the textfield setup will do the trick. Works for inputfieldText, but not for InputfieldTextarea. Setting 'Maximum length' to '0' is not meant for this and the missing trim() in InputfieldText::setAttributeValue() could be added in future PW versions. If you need the spaces in the output in general, its better to add via template file.
- 1 reply
-
- 1
-