Jump to content

horst

PW-Moderators
  • Posts

    4,077
  • Joined

  • Last visited

  • Days Won

    87

Everything posted by horst

  1. Maybe something like domain/processwire, but a referrer header could be set to anything one want, I guess. Better could be to use the REMOTE_ADDR. Does someone know how a variable for apache could be set by script? If this could be done everytime a superuser log in I could set this IP to a apache / environment variable for which access is allowed.
  2. hellomoto, welcome to the forums. I don't know this plugin. A quick view to it tells me that it handles some sort of FTP-Requests. If you like you can specify what you want to achieve with it in PW, - maybe someone here can help out with ideas or informations on how it could be done.
  3. Hi, on a site I want to disable access to original images and only allow to access thumbnails and watermarked image variations. EDIT: A good solution for protecting original images can be found a bit down in this thread: Old content of this initial post:
  4. I have had same behave. My Session-Key adminThemeColors is 'main' I also have copied over the main-classic.css to main.css to get the right PW-feeling Nice work, nice improvements, Ryan! PS: using the GET-Var in URL has only switched for one time to classic and with next loading (without GET-Var in URL it goes back to warm) I also have killed all session files etc. pp, - only copying main-classic.css to main.css worked for me.
  5. Not a good decission. Do you know all other tablenames (all none-PW-tables)? If yes, then take all but not this. If no, you may look for all tables beginning with field_ and minimum the tables: pages pages_access pages_parents pages_sortfields templates modules fields fieldgroups fieldgroups_fields But there may be more, depending of your installed thirdparty-modules! For example I have a table session_login_throttle and a table process_forgot_password in one DB. EDIT: and for those who are looking for backup tools, we have had already some threads/post about that: http://processwire.com/talk/topic/771-is-there-a-way-to-get-a-db-backup-from-within-pw/#entry6452 http://processwire.com/talk/topic/3052-open-dynamo-webspace-backup-tool/
  6. Hi Chrizz, welcome to the forums. Here is code for a module that hooks into the event you are looking for. Maybe it is a good starting point for you: http://processwire.com/talk/topic/4517-random-images-file-name/#entry44392 --- Also worth to look at, (if you don't know it now), is Somas ImagesManager: http://processwire.com/talk/topic/3219-images-manager-alpha/ and maybe for watermarking the PageImageManipulator: http://processwire.com/talk/topic/4264-release-page-image-manipulator/ --- EDIT: @Chrizz: after rereading your post I think the best way for you would be to use Somas ImagesManager because it does most of what you want and if you need to adjust something you also can hook into it like I have done with this module: http://processwire.com/talk/topic/3398-working-with-processwire-getting-exif-data-from-images/#entry33552
  7. @Raymond: 1) As a first workaround you may install PiM too, and set $config->imageManipulatorOptions sharpening to none. That way you can leave $config->imageSizerOptions as is, while all CropImages should be handled by PiM (the automaticly created) and with the manual created you need to select none in the dropdown-list. 2) can you send me or upload an example of this black lines/dots noises? There is a BUG in GD-Lib with Alpha-Transparency in PNG. It isn't recognized by some functions.
  8. on GitHub: https://github.com/ryancramerdesign/ProcessWire/pull/237 and https://github.com/horst-n/ProcessWire/commit/33e5b168a11bf2c6648d0ae7dc7e8d8c88e56305 in Forum: http://processwire.com/talk/topic/3768-processwire-231-dev-branch/page-5#entry43253 I'm on hurry, ...
  9. How do you adjust the crop? Can you provide code example? EDIT: Have not seen your second post when (sloooowly) writing this on mobile, Great you already have solved it!
  10. @soma: this is already filed as a Github issue and also fix is posted / committed. Ryan has said that he will work on that. (There is Github conversation and also posts somewhere in the Forums here, but I'm on mobile and Not able to link to it) I think currently it could be that some other parts (language) has higher prio and he is only one man. (?? maybe ??)
  11. Thanks to Ryan, in the dev-branch we now have Pageimage::isVariation() hookable. I have added a hook to the init() method of PiM $this->addHook('Pageimage::isVariation', $this, 'isVariationWithPim'); and with this method all valid pimVariations of a Pageimage get collected / deleted together with the other variations of the original image: public function isVariationWithPim($event) { $variationName = basename($event->arguments[0]); if('pim_'!=substr($variationName,0,4) || false!==$event->return) { // if the result of hooked method isn't false, or if the file doesn't start with 'pim_' we leave now return $event->return; } // ok, imagefile starts with 'pim_', does it belong to the pageimage? $pageimage = $event->object; // get the pageimage $basename = basename($pageimage->name, '.' . $pageimage->ext); // basename of pageimage $re = '/^pim_.*?' . $basename . '.*?' . '\.(gif|jpg|png)' . '$/'; // regexp to identify if it's a valid pim_variation if(preg_match($re, $variationName)) { // we have a match, now return array with imageinfo // (the following rows are taken from original method Pageimage::isVariation(), only regexp is modified) $re2 = '/^pim_.*?' . $basename . '\.' . // pim_(prefix)_myfile. '(\d+)x(\d+)' . // 50x50 '([pd]\d+x\d+|[a-z]{1,2})?' . // nw or p30x40 or d30x40 '\.(gif|jpg|jpeg|png)' . // .ext '$/'; preg_match($re2, $variationName, $matches); $info = array( 'original' => $basename . '.' . $pageimage->ext, 'width' => $matches[1], 'height' => $matches[2], 'crop' => (isset($matches[3]) ? $matches[3] : '') ); $event->return = $info; return $event->return; } return false; } The next release of PiM (0.1.1) will have that.
  12. Martijn, what's about to support it with PiM instead with ImageSizer? If I'm right, there isn't much support for interlaced JPEGs actually: limited browser support (render interlaced: chrome, Firefox, IE9+ | don't render interlaced: all Safari, all Opera) if browsers support it, they mostly only support foreground images but not interlaced background images (only Chrome render background images correct) if there is support for interlaced images, the cpu usage is multiple times then with basic-jpegs, (not very handy with mobile devices) And there is more (pro & con): http://calendar.perfplanet.com/2012/progressive-jpegs-a-new-best-practice/ I'm not sure, but the pro's seems limited to some more or less special usage only. ------ BTW: interlaced images could be really useful with responsive designs if the browsers would support them technically in a special way. For example if you have a source image of 1200 x 1600 and it is sent to a mobile phone, the mobile browser could stop downloading and rendering after the first (normally very blurry) image step is rendered. A desktop would download the complete file and also would render all steps (scanns). Would be very helpfull if (all) the browsers support that some day.
  13. I think this is not a good solution, ... ... because what's about if someone has a page tree like this: /portal/ /something1/ /something2/ /something3/ Than he turns on your rewriting and after that, the authors someday create pages under /portal/ like this: /portal/anything1/ /portal/anything2/ /portal/something1/
  14. horst

    Debugging tips

    When I need a quick info of assigned values I use a better readable version of var_dump: <?php /** * Original script from Stefan Eickhoff, 05.12.2002 * URL: http://aktuell.de.selfhtml.org/artikel/php/variablen/ * * @shortdesc output a better vardump. $outputMode: 1=Browser; 2=Commandline-Window; 3=StringVar; 4=file; * **/ function my_var_dump($v, $outputMode=2, $filename='') { // Ausgabe von var_dump ueber Output-Buffer in Variable einlesen ob_start(); var_dump($v); $content = ob_get_contents(); ob_end_clean(); // maximale Einrueckung ermitteln $m = 0; preg_match_all('#^(.*)=>#mU', $content, $stack); $lines = $stack[1]; $indents = array_map('strlen', $lines); if($indents) $m = max($indents) + 1; // Ausgabe von var_dump() an maximaler Einrueckung ausrichten $content = preg_replace('#^(.*)=>\\n\s+(\S)#eUm', '"\\1" .str_repeat(" ", $m - strlen("\\1")>1 ? $m - strlen("\\1") : 1). "\\2"', $content); // bei Array-Strukturen oeffnende Klammer { in neue Zeile $content = preg_replace('#^((\s*).*){$#m', "\\1\n\\2{", $content); // pre tags entfernen $content = str_replace(array('<pre>','</pre>'),'',$content); switch($outputMode) { case 1: // Output to Browser-Window echo '<pre style=" margin: 10px 10px 10px; padding: 10px 10px 10px 10px; background-color:#F2F2F2; color:#000; border: 1px solid #333; font-family: Lucida Console, Courier, monospace; font-size : 12px; overflow: visible;">'.$content.'</pre>'; break; case 2: // Output to Commandline-Window or to Browser as hidden comment echo isset($_SERVER['HTTP_HOST']) ? "\n<!--\n".$content."\n-->\n" : $content."\n"; break; case 3: // Output into a StringVar return '<pre style=" margin: 10px 10px 10px; padding: 10px 10px 10px 10px; background-color:#F2F2F2; color:#000; border: 1px solid #333; font-family: Lucida Console, Courier, monospace; font-size : 12px; overflow: visible;">'.$content.'</pre>'; break; case 4: // Output into a file, if a valid filename is given and we have write access to it //return $this->string2file(str_replace(array('>','"',' '), array('>','"',''), strip_tags($content)), $filename, true); break; } }
  15. Do you want to rename the original files on upload? If yes, here are some pieces of code I have collected in the forum from Soma. This could be a starting point for a module: <?php class ImageRenameOnUpload extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'ImageRenameOnUpload', 'version' => 100, 'summary' => '', 'href' => '', 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookBefore('InputfieldFile::fileAdded', $this, 'renameImage'); } public function renameImage($event) { $inputfield = $event->object; if($inputfield->name != 'images') return; // we assume images field !! name of the field is: images !! otherwise change it $p = $inputfield->value['page']; // get the page $image = $event->argumentsByName("pagefile"); // get the image $ext = $image->ext; // get extension $newBasename = 'my_random_name_' . time(); // create your random name here !! $p->images->trackChange("basename"); // prepare page to keep track for changes on basename //$image->removeVariations(); // isn't needed here, I think $image->rename($newBasename . '.' . $ext); // rename the image $p->save('images'); // save the page } } As of this code will work, you have to add something that refreshs your admin page at the end, because upload is via ajax request and the label presenting your imagefilename isn't updated now. But should be a good starting point. EDIT: Have changed addHookAfter to addHookBefore and then it all works, including updating the label with filename! Don't know really why in detail. Just have found out by trying!
  16. @Ryan: please, can we have pageimage::isVariation() hookable?
  17. horst

    Avatar for pwired

    No, he isn't dead, he is swooning. Help is on the way:
  18. I get this when clicking on a ANSWERED button when in "view new content" mode: the link lacks the id of the post. &pid= ...
  19. horst

    Avatar for pwired

    BTW, my new avatar is a snapshot me looking to anttis new avatar, and I will only change my after antti has changed his. Maybe someone around here has a facebook account and can have a look if his wife has shot and uploaded another image?
  20. horst

    Avatar for pwired

    If you are already scared yet, you definitely shouldn't come after midnight when my brothers will visit the forum too: and
  21. This is a great solution. It is like "named parameters" (what isn't implemented in PHP but in some other languages). I definitely will play around with that and report back here.
  22. Actually you only can use the method removePimVariations() on a per image base to delete all your testfiles! $img = $page->images->first(); $img->pimLoad('prefix')->removePimVariations(); and they all are gone. But automaticly delete them when deleting a original image isn't supported yet. At least if you delete them manually in the backend. If you delete them via the API, there should be a simple way / workaround to get it solved. How do you delete them? When deleteing images manually in the backend: If you really have much changes and therefor a lot of orphaned files, you may use the lazycron module (core, but you have to install it first) together with the delete-orphaned-files script. It would be much better to get rid of that automaticly as you said, but I need to find the way how to do it. And within next weeks there are no time available for extending PiM.
  23. horst

    Avatar for pwired

    GOOD NEWS for those with little children or with a sensitive mind: I have written a VB program that permanently scans the screen for the pink colored string apeisa and than places a 100x100px black rectangle positioned x +30 and y +50 on top of that screen area. For all of you who have little children and can work on windows, I can sell a licence for only 12,- € (per day) and if you don't want like to have these scensored black rectangle you can upgrade to the premium version for only + 4,- € (per day). The premium version places the old avatar picture of antti on top of the screen.
  24. or I'm wrong? - It is output into JS.
×
×
  • Create New...