Add PHP script on owncloud source code

10

#1

Hello,
I’m making a custom NAS using owncloud. I implemented a daemon in order to manage external disk power. The main idea is to switch the disk power when clients aren’t using the owncloud’s services. I created a PHP script to switch on the disk (where there is data directory ) . I add my php lines on /index.php but nothing happened when I’m going to the web page.
Where can i put my PHP lines in order to execute them when a client request come.
Thank’s !


#2

You shouldn’t change the source code. ownCloud is extendable with apps. You need to write a filesystem app. Probably, write hooks satisfy your needs. https://doc.owncloud.org/server/10.0/developer_manual/app/


#3

Thanks a lot, I will check Middleware.


#4

You should listen to file events, middleware only affects request which is come for your app routes. Good luck.


#5

I don’t need to manage data directories, just to call some php lines when people make request on the server. So if I put the root on my app routes and add my script on beforeController method, will it work ?


#6

Nope, it does not work. Like I said beforeController method only works for your app’s controller. You need to use hooks: https://doc.owncloud.org/server/10.0/developer_manual/app/fundamentals/hooks.html


#7

Ok, I will work on it. Thanks a lot !