/dev/null 2>&1 &\nsleep 1\necho -n . >".FIFO."\n"; if ( @file_get_contents('omx_php.sh') != $omxsh ) { $processUser = posix_getpwuid(posix_geteuid()); if ( is_writable('/dev/vchiq') ) { echo '/dev/vchiq is writable - OK
'; } else { echo '/dev/vchiq is not writable for httpd user
'; echo 'you have to run shell command:
'; echo 'sudo usermod -a -G video '.$processUser['name'].'
'; echo 'this will allow http server user which runs omxplayer access /dev/vchiq to display video
'; die(); } if ( posix_mkfifo(FIFO, 0777) ) { echo FIFO.' is writable - OK
'; } else { echo 'can\'t create '.FIFO.' - please fix persmissions!
'; die(); } if ( chmod(FIFO,0777) ) { echo FIFO.' permissions - OK
'; } else { echo 'can\'t change permissions for '.FIFO.' - please fix persmissions!
'; die(); } unlink(FIFO); if ( file_put_contents('omx_php.sh', $omxsh) ) { chmod ('omx_php.sh', 0777); echo 'config saved - OK'; } else { echo 'error saving shell script - please fix permissions'; die(); } echo "

Please note - if you want to clear screen before player start please modify cls.sh to your needs and run this command from shell

"; echo "

sudo sh -c 'echo \"".$processUser['name']." ALL=(ALL) NOPASSWD: /bin/sh -c ./cls.sh\" >/etc/sudoers.d/".$processUser['name']." && chmod 0640 /etc/sudoers.d/".$processUser['name']."'

"; echo "

in short this command allows cls.sh script to do necessary tasks to clear screen and it can be done only using sudo, and command add this cls.sh scirpt rights to do so for apache

"; } ////////////////////////////////////////////////////////////////////////////////// // Explore the files via a web interface. $script = basename(__FILE__); // the name of this script $path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : dirname(__FILE__); // the path the script should access if ($_REQUEST['save'] == 'save') { if ( file_put_contents('cfg.php', "\n") ) { header("Location: omxplayer.php"); } else { echo 'error saving config file - please fix permissions'; die(); } } echo "

Please choose videos directory

"; echo "

Browsing Location:

"; $directories = array(); $files = array(); // Check we are focused on a dir if (is_dir($path)) { chdir($path); // Focus on the dir if ($handle = opendir('.')) { while (($item = readdir($handle)) !== false) { // Loop through current directory and divide files and directorys if(is_dir($item)){ array_push($directories, realpath($item)); } else { array_push($files, ($item)); } } closedir($handle); // Close the directory handle } else { echo "

Directory handle could not be obtained.

"; } } else { echo "

Path is not a directory

"; } asort($directories, SORT_NATURAL); asort($files, SORT_NATURAL); // There are now two arrays that contians the contents of the path. // List the directories as browsable navigation echo "

Navigation

"; echo ""; echo "

Files

"; echo ""; ?>