From nzskiwi at gmail.com Wed Sep 5 04:08:25 2012 From: nzskiwi at gmail.com (Simon) Date: Wed, 5 Sep 2012 21:08:25 +1200 Subject: [pmwiki-devel] PHP warning in totalcounter Message-ID: I'm seeing lots of errors in my log [25-Aug-2012 14:33:42] PHP Warning: chmod() [function.chmod]: Operation not permitted in /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1163 [25-Aug-2012 14:33:42] PHP Warning: chmod() [function.chmod]: Operation not permitted in /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1174 Can anyone give me a quick heads up on what might need to be fixed? ta Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: From 5ko at 5ko.fr Wed Sep 5 19:17:31 2012 From: 5ko at 5ko.fr (Petko Yotov) Date: Thu, 06 Sep 2012 02:17:31 +0200 Subject: [pmwiki-devel] PHP warning in totalcounter References: Message-ID: Simon writes: > [25-Aug-2012 14:33:42] PHP Warning: ?chmod() [ href='function.chmod'>function.chmod]: Operation not permitted in > /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1174 > > Can anyone give me a quick heads up on what might need to be fixed? I haven't used or reviewed that recipe, but if nothing is mentioned about your problem on the cookbook page or on the talk page, and if nobody replies on the mailing list, you may try to contact the authors directly -- they may be unsubscribed from the mailing lists. Petko From nzskiwi at gmail.com Thu Sep 6 01:22:04 2012 From: nzskiwi at gmail.com (Simon) Date: Thu, 6 Sep 2012 18:22:04 +1200 Subject: [pmwiki-devel] PHP warning in totalcounter In-Reply-To: References: <51d05e14f991493a8b7da9216152298c@IU-MSSG-HUB103.ads.iu.edu> Message-ID: thanks Simon //Windows 9x FLOCK Alternative - Chozo4 //Passes multiple instance stress testing //http://mechresource.myvnc.com/board //Modified (breaks and returns 0 on failure, // or returns 1 on success) by Mateusz Czaplinski, 22.01.2008 function aquirelock($wp) { //Check if lock doesn't exist or our target is unwritable if(file_exists("$wp.l") || !is_writable($wp)) return 0; //create the lock - hide warnings and pass empty if already created from racing return @ fopen("$wp.l", 'x'); } function dblock($wp) { global $TotalCounterEnableChmods; //Check for lockfile handle - if empty , another process raced the lock so report a failure $ftw = aquirelock($wp); if( !$ftw ) return 0; if($TotalCounterEnableChmods) chmod($wp, 0444); //set the target file to read-only // LINE 1163 fwrite($ftw, 'lock'); //write the lockfile with 4bytes if($TotalCounterEnableChmods) chmod("$wp.l", 0444); //set the lockfile to read only (OPTIONAL) fclose($ftw); //close our lockfile clearstatcache(); //Clear the stat cache return 1; } // Note: don't call it if 'dblock()' returned 0 ! function dbexport_unlock($wp, $data, $meth) { global $TotalCounterEnableChmods; if($TotalCounterEnableChmods) chmod($wp, 0666); //Set the target file to read+write // LINE 1174 //Write the passed string to the target file then close fwrite($ftw = fopen($wp, $meth), $data); fclose($ftw); //Validate the written data ujsing a string comparison $check = file_get_contents($wp); if ($check != $data) echo "Data Mismatch - Locking FAILED!
"; chmod("$wp.l", 0666); //Set the lockfile to read+write (OPTIONAL) unlink("$wp.l"); //Release the lockfile by removing it } On 6 September 2012 13:30, Weldon Sams wrote: > Would you copy some of the lines around 1174 in a reply? > > Weldon > > > On Wed, Sep 5, 2012 at 5:08 AM, Simon wrote: > >> I'm seeing lots of errors in my log >> >> [25-Aug-2012 14:33:42] PHP Warning: chmod() [> href='function.chmod'>function.chmod]: Operation not permitted in >> /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1163 >> [25-Aug-2012 14:33:42] PHP Warning: chmod() [> href='function.chmod'>function.chmod]: Operation not permitted in >> /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1174 >> >> Can anyone give me a quick heads up on what might need to be fixed? >> >> ta >> >> Simon >> > > -- ____ http://kiwiwiki.co.nz -------------- next part -------------- An HTML attachment was scrubbed... URL: From nzskiwi at gmail.com Thu Sep 6 03:09:11 2012 From: nzskiwi at gmail.com (Simon) Date: Thu, 6 Sep 2012 20:09:11 +1200 Subject: [pmwiki-devel] Calling CGI from PHP Message-ID: I've got a legacy html page which calls a cgi (perl) script As an interim step to replacing this script (with something clever from PmWiki) I've tried to invoke the script from within a recipe on a page . The recipe is Markup('ClubNight', 'fulltext', '/\\(:clubnight:\\)/ei', "Keep(ClubNight())"); function ClubNight() { $retval = 'retval is '; $lastline = ''; $output = ''; // Create a stream $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" ) ); $context = stream_context_create($opts); // Open the file using the HTTP headers set above $retval .= 'a' . file_get_contents('http://ttc.org.nz/cgi-bin/tuesday.pl', false, $context); $lastline = system ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output); $retval .= 'b' . $output; $lastline = exec ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output); $retval .= 'c' . $output; $lastline = exec("./cgi-bin/tuesday.pl", $output); $retval .= 'd' . $output; return $retval; } I don't get the result I expect on the page , and wonder if anyone can spot anything obvious that I have got wrong. I'm sure safe mode is on. tia Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: From 5ko at 5ko.fr Fri Sep 7 02:44:39 2012 From: 5ko at 5ko.fr (Petko Yotov) Date: Fri, 07 Sep 2012 09:44:39 +0200 Subject: [pmwiki-devel] Calling CGI from PHP References: Message-ID: Simon writes: > As an interim step to replacing this script (with something clever from > PmWiki) I've tried to invoke the script from within a recipe on > a page. > > > The recipe is > > Markup('ClubNight', 'fulltext', '/\\(:clubnight:\\)/ei', > ? "Keep(ClubNight())"); > function ClubNight() { > ? $retval = 'retval is '; ? > ? $lastline = ''; > ? $output = ''; > ? // Create a stream > $opts = array( > ? 'http'=>array( > ? ? 'method'=>"GET", > ? ? 'header'=>"Accept-language: en\r\n"? > ? ) > ); > ? $context = stream_context_create($opts); > // Open the file using the HTTP headers set above > ? $retval .= 'a' . file_get_contents(' bin/tuesday.pl>http://ttc.org.nz/cgi-bin/tuesday.pl', false, $context); This should work unless some restrictions are set on that PHP installation. You may also try simply file_get_contents('http://ttc.org.nz/cgi-bin/tuesday.pl'); > ? $lastline = system ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output); This would probably never work. You normally cannot execute remote files. > ? $retval .= 'b' . $output; > ? $lastline = exec ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output); > ? $retval .= 'c' . $output; Same here. > ? $lastline = exec("./cgi-bin/tuesday.pl", $output); This will likely be "../cgi-bin/tuesday.pl" with 2 dots, because it looks like your running pmwiki.php file is in a directory pmwiki, while the cgi- bin directory looks like it is in the document root, and not inside the pmwiki directory. > ? return $retval; For testing purposes, in order to see the array values rather than 'Array', try return pre_r($retval); Petko From 5ko at 5ko.fr Fri Sep 7 02:48:34 2012 From: 5ko at 5ko.fr (Petko Yotov) Date: Fri, 07 Sep 2012 09:48:34 +0200 Subject: [pmwiki-devel] Calling CGI from PHP References: Message-ID: Petko Yotov writes: >> ? $retval .= 'c' . $output; > > For testing purposes, in order to see the array values rather than 'Array', > try > > return pre_r($retval); This was incorrect, sorry. You can use the pre_r() function on all $output variables above, not on $retval: $retval .= 'c' . pre_r($output); Petko From nzskiwi at gmail.com Fri Sep 7 23:53:29 2012 From: nzskiwi at gmail.com (Simon) Date: Sat, 8 Sep 2012 16:53:29 +1200 Subject: [pmwiki-devel] Calling CGI from PHP In-Reply-To: References: Message-ID: A big thanks to Petko and Peter B who got me heading in the right direction. I've documented this at http://www.pmwiki.org/wiki/Cookbook/RunCGI I hope it helps someone else Simon On 7 September 2012 19:48, Petko Yotov <5ko at 5ko.fr> wrote: > Petko Yotov writes: > >> $retval .= 'c' . $output; >>> >> >> For testing purposes, in order to see the array values rather than >> 'Array', try >> >> return pre_r($retval); >> > > This was incorrect, sorry. You can use the pre_r() function on all $output > variables above, not on $retval: > > $retval .= 'c' . pre_r($output); > > > Petko > > > ______________________________**_________________ > pmwiki-devel mailing list > pmwiki-devel at pmichaud.com > http://www.pmichaud.com/**mailman/listinfo/pmwiki-devel > -- ____ http://kiwiwiki.co.nz -------------- next part -------------- An HTML attachment was scrubbed... URL: