Jump to content

flydev

Members
  • Posts

    1,360
  • Joined

  • Last visited

  • Days Won

    49

Everything posted by flydev

  1. Hi @fmgoodman Please post the Apache and the PHP error logs. Also, what is the ownership of /var/www/lib/php/session|cookie ? You can also try to troubleshoot by changing the session.save_path and session.cookie_path of your php.ini file from /var/www/lib/php/session|cookie to /tmp If you can't get it working, I offer you a ninja session on your server ?
  2. For my project I need an implementation of Basic Auth, so I added a new option 'Basic Auth' available in the module config : and then, in the Router.php file, method handle(), I added the following code : // Basic HTTP Authentication if($authMethod === 'basic' && $routeNeedsAuth) { $authHeader = self::getAuthorizationHeader(); if(!$authHeader) { self::displayError('Bad Request', 400); } $hash = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; $authHeader = explode(':', $hash, 2); if(!isset($authHeader[0]) || !isset($authHeader[1])) { self::displayError('No Authorization Header found', 400); } $credentials = new \StdClass(); $credentials->user = $authHeader[0]; $credentials->pass = $authHeader[1]; RestApiHelper::checkAndSanitizeRequiredParameters($credentials, ['user|selectorValue', 'pass|text']); $loggedin = wire('session')->login($credentials->user, $credentials->pass); if(!$loggedin) { self::displayError('user does not have authorization', 401); } } and in the method getAuthorizationHeader() I added : if(array_key_exists('php_auth_user', $headers)) return ['user' => $headers['php_auth_user'], 'pass' => $headers['php_auth_pw']]; It works, but does it make sense ? Edit: Pull Request : https://github.com/thomasaull/RestApi/pull/3
  3. @thomasaull I noticed something annoying in the API endpoint config field, I need to open the devtools and remove the `pattern` attribute manually in order to save the settings, look : If you are short on time, I can send a PR.
  4. Hi, The used settings (port) look not secure. try theses settings :
  5. @Steve_Stifler Just before going to tutorials, have a look at those discussions, for sure it will interest you / make you enthousiast / make you ?
  6. Hi @Zahari M. also you could read those threads to see a usecase :
  7. Hi @gottberg There is a bit of work to get images, as the way you are doing return Images Objects and not array. You can have a look at this file to see the "complexity" to retrieve those objects : https://github.com/microcipcip/processvue/blob/master/site-processvue/templates/inc/pagefields.php#L236 Or you can build your own images array before assigning it to the API answer : See updated ImageHelper.php file at the bottom of this post. /* route : 'page' => [ ['GET', '{id:\d+}', Example::class, 'getPage', ["auth" => false]] ] */ // get page route answer function public static function getPage($data) { $data = RestApiHelper::checkAndSanitizeRequiredParameters($data, ['id|int']); $response = new \StdClass(); $p = wire('pages')->get($data->id); if(!$p ->id) throw new \Exception('Page not found'); $response->id = $p->id; $response->name = $p->name; $response->title = $p->title; $response->body = $p->body; $response->sidebar = $p->sidebar; $response->summary = $p->summary; // our own images array $images = array(); foreach ($p->images as $image) { array_push($images, array( $image->name => array( 'url' => $image->url, 'filename' => $image->filename, 'width' => $image->width, 'height' => $image->height // ... ) ) ); } $response->images = $images; return $response; } Result : --- Edit : The image class helper : <?php namespace ProcessWire; /** * InputfieldImage Helper * Use for single image * * Usage : * $image is your ProcessWire PageImage * return ImageHelper::get($image, [400, 800, 1200, 2000, 2500]); */ class ImageHelper { public static function get ($image, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $response->urls = []; $response->description = $image->description; $response->name = $image->basename; $response->width = $image->width; $response->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($response->urls, $url); } return $response; } } /** * InputfieldImage Helper * Use for multiple images * * Usage : * $images is your ProcessWire PageImages * return ImagesHelper::get($images, [400, 800, 1200, 2000, 2500]); */ class ImagesHelper { public static function get($images, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->images = []; $img = new \StdClass(); // our own images array $imagesArr = array(); foreach ($images as $image) { $img->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $img->urls = []; $img->description = $image->description; $img->name = $image->basename; $img->width = $image->width; $img->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($img->urls, $url); } array_push($response->images, $img); } return $response; } }
  8. Hi Rudy, Storing a JSON array in a TextArea should works as expected without doing anything than saving the field in a standard fashion. protected static function getDefaultData() { return array( 'json_config' => '' ); } public static function getModuleConfigInputfields(array $data) { $data = array_merge(self::getDefaultData(), $data); $modules = wire('modules'); $fields = new InputfieldWrapper(); $field = $modules->get("InputfieldTextarea"); $field->label = __('JSON Config'); $field->attr('name+id', 'json_config'); $field->attr('value', $data['json_config']); $fields->append($field); return $fields; }
  9. Hey @horst It is solved ? If not, you might could try what is suggested in this answer on StackExchange : https://webmasters.stackexchange.com/questions/116301/how-to-force-ssl-and-www-for-a-subdomain-as-an-independent-domain Edit: ok, didn't read the post's update.
  10. @Pete I can build Windows desktop app only or multi-device application if needed, but I cannot start coding something before three weeks. Language used will be C++ or Pascal, so if it is not to far, let's discuss this in PM ?
  11. Okay I get your point. I made a 30 lines CSS Only switcher that should work with other theme than UiKit : https://codepen.io/flydev/pen/QYYZVL
  12. Hi Peter, It's hard to find something without the logs and the phpinfo() result, we can only make assumptions. What say the logs ? Could be something related to the PHP Garbage Collection mystery.. Hard to tell at this point and even worse with shared host. Also, it's possible that Plesk have a script run by a CRON job which delete sessions EACH HOUR, that could be the issue too! ask your host about that or look into your panel. A suggestion before starting scratching your head by modifying some values in the php.ini file would be to test the same form submission but with a different session handler configured, eg, SessionHandlerDB and SessionHandlerRedis. Setting up the last one for testing is quite simple, configure the Redis server on your computer to listen all interface (::1), open the right port (6379 by default) in your firewall/box and set the connection information in the config.php of your website, done, test it now. And as always, if you want me to have a ninja session on your server settings, ping by PM ?
  13. With this lib for example: https://github.com/zhiyul/Switch (there are multi choice on Github), load it on your module ___init() (add it to your scripts queue) and then in your module js file, call var el = document.querySelector('.checkbox-switch'); var mySwitch = new Switch(el, options); then do send your ajax request in the onChange event. Hope you get it. If you need a real example, just ask.
  14. If you are on a unix based system then you should give a try to Tasker/DataSet as @dragan said or look at the pcntl extension used in conjunction with the lib PHP League CSV. On windows (because the pcntl extension is not supported) I am used to write a custom import script with the same lib (PHP League) and calling `set_time_limit()` in the loop after importing X records. I import and create something like ~15k pages each night, it work pretty good.
  15. Very nice idea, thanks for sharing it with us ? Do not hesitate do register your modules in the modules directory.
  16. Hello guys, Which version are you using ? I just tested it with Duplicator 1.2.9 and everything works fine on my side a part an issue already reported in dev thread which is related to the "restore" procedure. Is there anything in the Duplicator logs ? Or maybe something in the ProcessWire logs (errors or exceptions) and at least in the PHP error log file ? Please, feel free to post/report things there :
  17. Hi @MarcoPLY Not really helping here, but the update about WireHttp and cURL came in ProcessWire 3.0.124 and it say : https://github.com/processwire/processwire/blob/dev/wire/core/WireHttp.php#L670 I am curious to see from where its happening. What is your registration code ? It is the LoginRegister module which is triggering this exception ? (sorry, I have trouble expressing myself, I'm sick ? )
  18. @mtcode https://processwire.com/docs/start/structure/templates/#scalability-and-customizability
  19. Hello @Demo Feel free to contact me or @Jguiselin via PM ?
  20. Just in case, I use those alias to install or upgrade my installs : # ProcessWire Wireshell bash alias # grab and install the latest ProcessWire development version from the latest commit alias pwnew='wireshell new --sha=`git ls-remote https://github.com/processwire/processwire refs/heads/dev | cut -f1`' # upgrade to the latest ProcessWire development version from the latest commit alias pwup='wireshell upgrade --sha=`git ls-remote https://github.com/processwire/processwire refs/heads/dev | cut -f1`' https://gist.github.com/flydev-fr/addcf54fa8348de20115d3c1314ddb3d
  21. Hi and welcome ! Great first contribution ? FYI there is one similar field (I think) based on Chosen there : @Sergio https://github.com/sebi2020/InputfieldTagify https://yaireo.github.io/tagify/
  22. You could follow or show to us the full stack trace to see which Textformatter is being called. Are they all set in the field option / details tab ? if yes, you might from there compare which one is missing ?
×
×
  • Create New...