Can't get test plugin PHP to work


bobbintb

Recommended Posts

I am trying to write a plugin and just starting out with a simple test. I am trying to reverse engineering the dynamix autofan plugin. I removed the PHP from the page file and put in another PHP script:
https://github.com/prasathmani/tinyfilemanager/blob/master/tinyfilemanager.php
I keep getting a parsing error:
Parse error: syntax error, unexpected end of file in /usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php(522) : eval()'d code on line 4141

However, I can run the PHP just fine on a dev webserver. I'm not sure what the matter is. I simply removed everything below --- in the page file and copied and pasted the PHP. As far as I can tell, that should have worked. I see unraid uses PHP 7.4.15. My dev webserver is 7.4.25 so I don't image there would be an issue there. Any ideas?

Link to comment

You could try running the .page file from the Unraid console via the php -f option so it executes within an Unraid context in case the php conflicts with something that Unraid adds as standard to .page files

 

Also including a line reading 

error_reporting(E_ALL);		 // This option should only be enabled for testing purposes 

at the top of the file might provide additional information

Link to comment

Thanks for the suggestions.  Running it with php spit out a bunch of html. I save it and loaded it in my browser just fine. However, the php code has some config options at the beginning. If I set  $use_auth to false, then I get an index error :
 

Notice: Undefined index: HTTP_HOST in /usr/local/emhttp/plugins/dynamix.system.autofan/FanSettings.page on line 66
<h1>Root path "" not found! </h1>

this is line 66

$root_path = $_SERVER['DOCUMENT_ROOT'];

I get another issue with $_SERVER if I fix that. It seems $_SERVER is not set. But I'm not sure why the php -f command works in the first place, until I change $use_auth. I don't work in php much. Regardless, the error in the unraid UI doesn't change.

Edited by bobbintb
Link to comment

 The .page files are not really designed to work outside the Unraid GUI unless special action is taken in the PHP code to support this which if probably why you got the errors you mentioned.  In particular the code to handle multi-language support can sometimes have unexpected side-effects.  I was hoping that you might get useful error messages to help with debugging.

Link to comment
19 hours ago, itimpi said:

 The .page files are not really designed to work outside the Unraid GUI unless special action is taken in the PHP code to support this which if probably why you got the errors you mentioned.  In particular the code to handle multi-language support can sometimes have unexpected side-effects.  I was hoping that you might get useful error messages to help with debugging.

Understood. Well, I pretty much got the successful test I was looking for. I think the PHP I was using was just too complex and not meant for unraid, as you said. Thanks!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.