
So strange that functions respond so different on different systems. Did you refreshed the page like 20 times to see if the result is stable?
Moderator: leecollings
Egregius wrote:You forgot line 29 of https://github.com/Egregius/LUA-Pass2PH ... ss2php.php wich checks if result is filled.
This is because there's nothing in the lua file to check if it was the last item in the devicechanged table. Therefor the passed string always ends with # resulting in an empty value in the $c array.
The foreach $c was added because devicechanged sometimes holds multiple devices.
But, there's smething else wrong. Maybe try with a absolute path? Maybe I have that folder in the include path of php.ini.
Code: Select all
// LINE 29 oF EGREGIUS
//28: foreach($c as $device=>$status)
//29: if(!empty($status))
//30: if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')) include 'pass2php/'.$device.'.php';
//31: include 'pass2php/__CRON.php';
foreach($c as $device=>$status)
lg('Step 2: Changed device = '.$device);
if(!empty($status))
{
$devicer=str_replace(" ","_",$device);
//lg('Step 2a: File to look for is: pass2php'.$device.'.php');
// lg('Step 2b: File to look for is: pass2php/'.$devicer.'.php');
lg((stream_resolve_include_path('pass2php/'.$device.'.php'));
lg((stream_resolve_include_path('pass2php/'.$devicer.'.php'));
if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')){
lg('Step 3: executing file '.$device.'.php');
include 'pass2php/'.$device.'.php';
}elseif(false!==stream_resolve_include_path('pass2php/'.$devicer.'.php')){
lg('Step 3: executing file '.$devicer.'.php');
include 'pass2php/'.$devicer.'.php';
}
}
Yes it was quite a refreshment... Pressing F5Egregius wrote:I forgot what is on line 29
So strange that functions respond so different on different systems. Did you refreshed the page like 20 times to see if the result is stable?
Code: Select all
0.06914 absolute stream_resolve_include_path OK
0.05889 relative stream_resolve_include_path OK
0.20790 absolute file_exists OK
0.07200 relative file_exists OK
0.05221 absolute is_file OK
0.03195 relative is_file OK
Code: Select all
$c=ex($_REQUEST['c']);$s=ex($_REQUEST['s']);
foreach($c as $device=>$status)
if(@include '/volume1/web/secure/pass2php/'.$device.'.php'){apcu_store('t'.$device,time);$dev=$device;}
if(!isset($dev))die();
Damn. I just rewrote the thing to 'define'.Egregius wrote:I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
Let starts with replace curl by file_get_contents. that sounds reasonable and keeping variables in functions where you actually use themEgregius wrote:No, you don't HAVE to, you might.
If you don't use cset and cget (or not much) don't bother.
I have for the moment 286 temporary variables in cache, then it starts to cound.
You don't HAVE to adopt all changes I do. You can use whatever version you feel good with.
Code: Select all
Notice: Undefined index: c in /var/www/html/secure/pass2php.php on line 3
Notice: Undefined index: s in /var/www/html/secure/pass2php.php on line 3
About curl versus file_get_contents, have you tried:Egregius wrote:I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
Code: Select all
curl_setopt($ch,CURLOPT_TIMEOUT,1);
Squeezing the last ms out of the response (waiting) times, nice. Keep up the good work.Sneezydevil wrote:About curl versus file_get_contents, have you tried:Egregius wrote:I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
I did the same but then did a benchmark. In that benchmark curl with the timeout was the fastest, but have not been able to try it in the script, to see if everything still works as aspected.Code: Select all
curl_setopt($ch,CURLOPT_TIMEOUT,1);
Nope, don't think I had that option.Sneezydevil wrote: About curl versus file_get_contents, have you tried:
I did the same but then did a benchmark. In that benchmark curl with the timeout was the fastest, but have not been able to try it in the script, to see if everything still works as aspected.Code: Select all
curl_setopt($ch,CURLOPT_TIMEOUT,1);
The script can only be called by the lua script as that one passes the c and s array.mitchellengelage wrote:I wanted to try your script but i can't seem to get it working, looks like the same problem 1 page back with Sincze. I tried debugging it with your comment here:
viewtopic.php?f=23&t=12343&start=160#p110324
But step 1 won't show in the log. With the new check-in running the curl manually or via browser I also receiveWhich seems okay and looks like the pass2php file is not called? Any ideas what i've done wrong?Code: Select all
Notice: Undefined index: c in /var/www/html/secure/pass2php.php on line 3 Notice: Undefined index: s in /var/www/html/secure/pass2php.php on line 3
You need to use the www folder of apache2/nginx for the php page.denisj wrote:If I make an alone page out of domoticz www folder, it's work
But if I make a page phpinfo inside www folder of domoticz I take an error: "501 Not Implemented"![]()
I must find the configuration file of domoticz internal web server.
Thanks again
Denis
Users browsing this forum: No registered users and 1 guest