KI114 Posted May 6, 2011 Share Posted May 6, 2011 Is there a way to run a PHP script every time a file is accessed in a certain folder? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/ Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 Do you need it real time or can it check every 2min or so? Also will this be on Win or Linux? incubi Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211573 Share on other sites More sharing options...
KI114 Posted May 6, 2011 Author Share Posted May 6, 2011 Would need to be real time Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211574 Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 Also will this be on Win or Linux? Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211575 Share on other sites More sharing options...
KI114 Posted May 6, 2011 Author Share Posted May 6, 2011 Linux. CentOS is this makes any difference Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211578 Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 Okay, no not real time. I guess you could if you use php CLI but man that would be bad. I would write a C++ app for it. incubi Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211580 Share on other sites More sharing options...
KI114 Posted May 6, 2011 Author Share Posted May 6, 2011 Alright thanks. I'll have to look into it Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211583 Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 Woops didn't mean to leave you hanging. Check these out http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html http://pyinotify.sourceforge.net/ They will use the linux notify built into the kernel. incubi Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211584 Share on other sites More sharing options...
Drummin Posted May 6, 2011 Share Posted May 6, 2011 Can't you just include the folder name to the top of each page and include the folder check script? On each page $section=("foldername"); include("foldercheck.php"); foldercheck.php IF ($section=="specificfolder"){ //run function } Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211586 Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 Hi Drummin, I wouldn't call that realtime as it were but sure you can do that. Or you could run the script on a cron job. incubi Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211588 Share on other sites More sharing options...
Drummin Posted May 6, 2011 Share Posted May 6, 2011 Hi Drummin, I wouldn't call that realtime as it were but sure you can do that. Or you could run the script on a cron job. incubi Well he did say WHEN a page is accessed, so WHEN the page is called, the script would run. Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211596 Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 I think OP wanded "Run script when folder accessed" So fire the script when something accesses in the folder not when the page is accessed incubi Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211599 Share on other sites More sharing options...
KI114 Posted May 6, 2011 Author Share Posted May 6, 2011 The problem is that it could be any file in the folder, not just other PHP scripts. Otherwise that'd be easy Quote Link to comment https://forums.phpfreaks.com/topic/235719-run-script-when-folder-accessed/#findComment-1211603 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.