this one i don`t understand? This is the same line you ask me to comment out in pass2php.php?Egregius wrote:OK that's good. Remove the lg line again, or place // before it to place it as a comment, could be usefull later.
Then in pass2php.php add this:Then we know that the path and filename is good.Code: Select all
<?php lg($device.' = '.$status)
Pass2PHP
Moderator: leecollings
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Yes, but now it's placed inside pass2php/TEST.php
We need to check step by step where the script stops by adding lg commands.
Edit: oh, sorry, forgot to change the filename in my previous post.
We need to check step by step where the script stops by adding lg commands.
Edit: oh, sorry, forgot to change the filename in my previous post.
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
Ok now i understand... you said to put this line pass2php.php. If i put this line in pass2php/TEST.php nothing happens in the log when i press the switch:Egregius wrote:Yes, but now it's placed inside pass2php/TEST.php
We need to check step by step where the script stops by adding lg commands.
Edit: oh, sorry, forgot to change the filename in my previous post.
Code: Select all
2017-01-30 10:31:57.457 User: Admin initiated a switch command (563/TEST/On)
2017-01-30 10:31:57.457 (Dummy) Light/Switch (TEST)
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Wait a minute, where did you get this part?
That should be a path, not a url:
Code: Select all
if(@include 'http://127.0.0.1/secure/pass2php/'.$device.'.php'){
Code: Select all
if(@include '/volume1/web/secure/pass2php/'.$device.'.php'){
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
Ok edited pass2php.php with following information but still don`t get to see anything in log:Egregius wrote:Wait a minute, where did you get this part?That should be a path, not a url:Code: Select all
if(@include 'http://127.0.0.1/secure/pass2php/'.$device.'.php'){
Code: Select all
if(@include '/volume1/web/secure/pass2php/'.$device.'.php'){
Code: Select all
<?php error_reporting(E_ALL);ini_set("display_errors","on");date_default_timezone_set('Europe/Amsterdam');
define('time',$_SERVER['REQUEST_TIME']);$actions=0;
$c=ex($_REQUEST['c']);
//lg('4. Egregius Start of Pass2PHP');
foreach($c as $device=>$status){
// lg($device.' = '.$status);
if(@include '/var/www/html/secure/pass2php/'.$device.'.php'){
//Filter the 'set level' stuff away for dimmers
if(in_array($device,array('Verlichting Slaapkamer'))){
if($status=='Off')apcu_store('s'.$device,'Off');
else apcu_store('s'.$device,filter_var($status,FILTER_SANITIZE_NUMBER_INT));
}else apcu_store('s'.$device,$status);
apcu_store('t'.$device,time);
$dev=$device;
}
}
if(!isset($dev))die();
include '/var/www/html/secure/pass2php/__CRON.php';
function sw($idx,$action='',$info=''){
lg('SWITCH '.$idx.' '.$action.' '.$info);
if(empty($action))file_get_contents('http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd=Toggle');
else file_get_contents('http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd='.$action);
global $actions;$actions=$actions+1;
}
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Permissions are good on the folder/file so the user that runs the webserver can read them?
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
yep all users have read acces to the mapEgregius wrote:Permissions are good on the folder/file so the user that runs the webserver can read them?
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
What is the output of this command in bash?
Code: Select all
cat /var/www/html/secure/pass2php/TEST.php
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
found the error i think.... when running as user pi i get a acces denied error. How can i change apache2 settings to run command as root without losing security....Egregius wrote:What is the output of this command in bash?
Code: Select all
cat /var/www/html/secure/pass2php/TEST.php
or maybe its better to move the map to a new dir under /home/pi/ ?
EDIT: changed file to another directory which pi user has rights to but still nothings happens when pressing TEST switch.
Code: Select all
<?php error_reporting(E_ALL);ini_set("display_errors","on");date_default_timezone_set('Europe/Amsterdam');
define('time',$_SERVER['REQUEST_TIME']);$actions=0;
$c=ex($_REQUEST['c']);
//lg('4. Egregius Start of Pass2PHP');
foreach($c as $device=>$status){
// lg($device.' = '.$status);
if(@include '/home/pi/domoticz/scripts/lua/pass2php/pass2php/'.$device.'.php'){
//Filter the 'set level' stuff away for dimmers
if(in_array($device,array('Verlichting Slaapkamer'))){
if($status=='Off')apcu_store('s'.$device,'Off');
else apcu_store('s'.$device,filter_var($status,FILTER_SANITIZE_NUMBER_INT));
}else apcu_store('s'.$device,$status);
apcu_store('t'.$device,time);
$dev=$device;
}
}
Code: Select all
raspberrypi% cat /home/pi/domoticz/scripts/lua/pass2php/pass2php/TEST.php
<?php
lg($device.' = '.$status)
if($s['TEST']=='On')sw($i['Verlichting Dressoir'],'On');
?>%
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Never run a webserver as root...
You should check under wich user your webserver runs, mostly www-data or similar
That user needs access to the secure/pass2php folder and the TEST.php file
You should check under wich user your webserver runs, mostly www-data or similar
That user needs access to the secure/pass2php folder and the TEST.php file
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
Its running as user and group piEgregius wrote:Never run a webserver as root...
You should check under wich user your webserver runs, mostly www-data or similar
That user needs access to the secure/pass2php folder and the TEST.php file
EDIT: Ok changed everything back to www-data and make www-date the owner of var/www folder. Added pi to the user-group www-data and set the permission to 775.... But still nothings happens when i press the switch button Looks like the TEST.php isn`t being found or something.. is there anyway to log this which call is being made (or isn`t made)
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
make a file /var/www/test.php:
Call the page in your browser http://192.168.x.x/test.php
Output must be something like 'call to undefined function lg...' because that function doesn't exist in that file.
I'm expecting a output like 'file not found', or 'permission denied',...
Code: Select all
<?php
error_reporting(E_ALL);
ini_set("display_errors","on");
include('/var/www/secure/pass2php/TEST.php');
Output must be something like 'call to undefined function lg...' because that function doesn't exist in that file.
I'm expecting a output like 'file not found', or 'permission denied',...
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
You are right.....Egregius wrote:make a file /var/www/test.php:Call the page in your browser http://192.168.x.x/test.phpCode: Select all
<?php error_reporting(E_ALL); ini_set("display_errors","on"); include('/var/www/secure/pass2php/TEST.php');
Output must be something like 'call to undefined function lg...' because that function doesn't exist in that file.
I'm expecting a output like 'file not found', or 'permission denied',...
Code: Select all
Warning: include(/var/www/html/secure/pass2php/TEST.php): failed to open stream: Permission denied in /var/www/html/test.php on line 4
Warning: include(): Failed opening '/var/www/html/secure/pass2php/TEST.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/test.php on line 4
Thanx for helping me out so fast! really appreciate it
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
If www-data is the user that runs the webserver
sudo chmod 755 /var/www/secure
sudo chmod 755 /var/www/secure/pass2php
cd /var/www/secure
sudo chmod 644 *
cd /var/www/secure/pass2php
sudo chmod 644 *
So, 755 for dirs (read/write/execute for owner, read/execute for others) and 644 for php files (read/write for owner, read for others).
sudo chmod 755 /var/www/secure
sudo chmod 755 /var/www/secure/pass2php
cd /var/www/secure
sudo chmod 644 *
cd /var/www/secure/pass2php
sudo chmod 644 *
So, 755 for dirs (read/write/execute for owner, read/execute for others) and 644 for php files (read/write for owner, read for others).
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
ok did this all but makes no changes... still getting acces denied. Is this because domoticz is running as pi? or is this all php related?Egregius wrote:If www-data is the user that runs the webserver
sudo chmod 755 /var/www/secure
sudo chmod 755 /var/www/secure/pass2php
cd /var/www/secure
sudo chmod 644 *
cd /var/www/secure/pass2php
sudo chmod 644 *
So, 755 for dirs (read/write/execute for owner, read/execute for others) and 644 for php files (read/write for owner, read for others).
Or do i have to restart apache or php or something after this changes?
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
This is apache related, but very strange.
Are there other files in /var/www
otherwise, chmod everything
sudo chmod -R 777 /var/www
that gives everybode read/write/execute permissions on /var/www and everything below that.
Are there other files in /var/www
otherwise, chmod everything
sudo chmod -R 777 /var/www
that gives everybode read/write/execute permissions on /var/www and everything below that.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
And you're sure /var/www/html is the root of Apache? Isn't that normally just /var/www?
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
on raspbian jessie this has changed to /var/www/html if have read somewhere. Now did chmod 777 and now it executed at least its giving me another error instead of acces denied:Egregius wrote:And you're sure /var/www/html is the root of Apache? Isn't that normally just /var/www?
Code: Select all
Parse error: syntax error, unexpected 'if' (T_IF) in /var/www/html/secure/pass2php/TEST.php on line 3
now the output in domoticz is this when pressing the switch TEST:
Code: Select all
2017-01-30 18:16:45.317 User: Admin initiated a switch command (563/TEST/On)
2017-01-30 18:16:45.317 (Dummy) Light/Switch (TEST)
2017-01-30 18:16:45.798 => TEST = On
Code: Select all
<?php
lg($device.' = '.$status);
if($s['TEST']=='On')sw($i['Verlichting Dressoir'],'On');
if($s['TEST']=='Off')sw($i['Verlichting Dressoir'],'Off');
?>
Last edited by dutchdevil83 on Monday 30 January 2017 18:21, edited 1 time in total.
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Lol, yes, a simple ; can break a whole script.
It should have been in the domoticz log, if you look at it in bash (not in web ui).
It should have been in the domoticz log, if you look at it in bash (not in web ui).
-
- Posts: 130
- Joined: Monday 31 October 2016 19:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Netherlands
- Contact:
Re: LUA Pass2php
what do you mean look into the log in bash? Is there another way to acces domoticz log and does that give more information why my switch is not switching? Maybe i need the code with APCU command in it because all is stored now with APCU_store ?Egregius wrote:Lol, yes, a simple ; can break a whole script.
It should have been in the domoticz log, if you look at it in bash (not in web ui).
EDIT: Have something working but it only switch when using the IDX... This code is working for turning my test lights on and off:
Code: Select all
<?php
lg($device.' = '.$status);
if ($status=="On") {
lg("Switching on..");
sw(580,'On');
} else {
lg("Switching off...");
sw(580,'Off');
}
Code: Select all
2017-01-30 20:21:29.916 User: Admin initiated a switch command (563/TEST/On)
2017-01-30 20:21:30.356 (Dummy) Light/Switch (TEST)
2017-01-30 20:21:30.872 => TEST = On
2017-01-30 20:21:30.874 => Switching on..
2017-01-30 20:21:30.876 => SWITCH 580 On
2017-01-30 20:21:30.877 User: Admin initiated a switch command (580/Verlichting Dressoir/On)
2017-01-30 20:21:30.878 OpenZWave: Domoticz has send a Switch command! NodeID: 43 (0x2b)
2017-01-30 20:21:30.879 (Zwave) Light/Switch (Verlichting Dressoir)
Code: Select all
sw($i['Verlichting Dressoir'],'On');
Code: Select all
sw(apcu_fetch('sVerlichting Dressoir'),'On');
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
Who is online
Users browsing this forum: No registered users and 1 guest