Jump to content

bernhard

Members
  • Posts

    6,221
  • Joined

  • Last visited

  • Days Won

    308

Everything posted by bernhard

  1. hi guys, i'm in a hurry so i try it short i wanted to make it visible what happens behind the scenes when you do different things in processwire backend, especially WHEN all the hookable methods are called (render > saveReady > save or the like) i tried a simple wire('log')->save('hookrecorder', __METHOD__); inside the pages::saveReady() method and that worked! next step: i tried to add this line to all hookable functions here: <?php $rustart = getrusage(); include('index.php'); wireCopy('wire_original', 'wire_tmp'); $dir_iterator = new RecursiveDirectoryIterator("wire_tmp"); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { if ($file->isFile() AND $file->getExtension() === "php") { $content = file_get_contents($file); $pattern = "/(\w+) function ___(\w+(?<!log))\((.*)\) *{/"; $replace = "$1 function ___$2($3) {\n wire('log')->save('hookrecorder', __METHOD__);"; /* // for debugging preg_match_all($pattern, $content, $matches); echo $file . "<br>"; if(is_array($matches[0]) AND count($matches[0]) > 0) { foreach($matches[0] as $match) { echo $match . '<br>'; } } echo "<br><br>";*/ $content = preg_replace($pattern, $replace, $content); file_put_contents($file, $content); } } //wireRmdir('wire_tmp', true); // Script end function rutime($ru, $rus, $index) { return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000)) - ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000)); } $ru = getrusage(); echo "This process used " . rutime($ru, $rustart, "utime") . " ms for its computations\n"; echo "It spent " . rutime($ru, $rustart, "stime") . " ms in system calls\n"; ?> it creates a directory wire_tmp with all the inserted log-statements. i replaced wire folder with wire_tmp folder (renamed it) and this does not work unfortunately (white screen, don't know if it would be different with debuggin true). i also tried to replace the wire/core/Wire.php file with the original one and to not log calls of "wire('log')" as i thought this may leed to errors (it's excluded in the regex) the idea is to save a page and then look all the hookable method calls up under setup > logs > hookrecorder and have a list like just now | pagexy | pages::save() just now | pagexy | pages::saveReady() just now | pagexy | pages::render() looking forward to hearing your opinions. should i exclude private methods or the like? or should i exclude whole files? or can i achieve what i want much simpler (eg server logging tools)?
  2. where do i define these settings?
  3. please mark your topic as solved so that others can immediately see it - saves time
  4. seems that mandrill updated their pricing as of 2015-07-15: http://blog.mandrill.com/new-simpler-pricing.html does this update also affect existing users? just curious, i have no account yet... btw: sendgrid has a free plan of 25.000 mails if you signup via their google partner site: https://sendgrid.com/partner/google
  5. Hi diogo, that's a pity but I can understand that this has no priority. Did some research and found https://github.com/layerssss/paste.js/blob/master/README.md
  6. I think "view" is good. there have been some additions to the core page field. it supports edit links with asmselect now: https://processwire.com/blog/posts/processwire-2.6.16-core-updates-more-on-prodrafts/#asmselect-gets-new-option-to-edit-selected-pages still i'm a huge fan of this module! thank you
  7. maybe try imagesmanager first https://processwire.com/talk/topic/3219-images-manager-beta/ see my sig how to search the forum
  8. sure possible why do you want to write directly to the DB? if you create pages you have all the benefits of processwire like page editing, pagination, file handling and so on. just use my example and replace: $parent = wire('pages')->get(1026); // your given id of the new parent $np->title = your part of the image filename that represents the title (see php string functions) $np->date (you have to create this field) = part of the filename that represents the date (year)
  9. does it behave differently for superusers? i had similar problems these days...
  10. you would have to name this file ImageBatcher.module and place it in your modules folder /site/modules then go to modules > install > new and maybe refresh, then install but this is no working and bulletproof code! use a dev-installation to test everything! here are lots of informations: https://processwire.com/api/modules/ https://processwire.com/api/hooks/
  11. class ImageBatcher extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Image Batcher', 'version' => 1, 'summary' => 'Do some additional actions after uploading an image', 'singular' => true, 'autoload' => true, ); } /** * Initialize the module * */ public function init() { // do additional action after upload $this->addHookAfter('InputfieldImage::fileAdded', $this, 'createPageFromImage'); } /** * create Page from uploaded Image * */ public function createPageFromImage($event) { $file = $event->arguments(0); $parent = wire('pages')->get('/batcher'); // didn't know how to get the current page dynamically // create new page $np = new Page(); $np->parent = $parent; $np->template = 'portrait'; $np->title = $file->name; $np->save(); // page has to be saved before adding images // add image $np->image->add($file->filename); $np->save(); } } played a little around... something like this? i didn't know how to get the current page dynamically... and i didn't manage to clear the added files from the "batcher" page because i got some errors i can't explore in detail right now. this thread should also give you useful information: https://processwire.com/talk/topic/8698-creating-page-for-every-image-uploaded/ edit: i think hooking the method fileAdded should keep you save from timeouts though other things may get more complicated as it are all ajax requests (like the error i got when trying to remove all uploaded images from the batcher page) edit2: of course you would have to check if the file was added to a "batcher" page. otherwise all your image uploads will create new pages. or you could bind the module to a specific imagefield only.
  12. hm... i have no idea where/how i could use this. could you please give me an example use case? don't want to miss this "brilliant idea" thank you
  13. found codemirror editor by coincidence and saw it has a nice fullscreen mode: http://codemirror.net/demo/fullscreen.html maybe it's useful for you
  14. hi craig, i'm not sure if i understand you. can you please go a little bit more into detail, thanks
  15. this new module could maybe do the job in most cases: https://processwire.com/talk/topic/10804-module-runtimemarkup-fieldtype-inputfield/
  16. hi thomas, how do you manage access control on site B? in other words, how does site B know what it is allowed to return to the user of site A? or is it all public data? thanks
  17. welcome tony, we had a very nice example of filtering a database in the showcase section some days ago: https://processwire.com/talk/topic/3671-ohmspeakercom/ http://ohmspeaker.com/speaker-filter/ good luck with your project!
  18. Maybe you could use http://modules.processwire.com/modules/process-dashboard/ ?
  19. i have a new mobile phone (android 4.4.2 + chrome 44.0.2403.133) and got some problems with some of my websites - but not all of them! logs say User 'admin' - Error: Session fingerprint changed (IP address or useragent) (IP: xx.xxx.xx.xxx) changing $config->sessionFingerprint to "8" (only useragent) solves the problem, but i'm not sure if that's the best solution... does this open any security holes? what is also strange is that there is one website where everything works fine. it's the only website with "session handler database" module installed so i thought this was the issue, but installing this module on another site led to "this ... appears to be forged", so i had to set fingerprint to 8 again. any insights would be very welcome, thank you
  20. welcome mauricius! that's insane drag&drop timeline?! what comes next? an online pw video editing module?! looks really awesome! thanks for the screencast. i also didn't know jssor.com
  21. i think so too, but anyway i think they did a great job. i'm usually also not a fan of heavily animated websites but imho in this case its nice
  22. cool marketing campaign and even cooler website: http://mcwhopper.com/
×
×
  • Create New...