<?  // PHPmyGallery - backend core - file permission check

/* File description:

This file checks if all necessary directories are on 777 (rwxrwxrwx)

### What this script does:
###
### Included from: adminmenu.index.php
### |
### | (Uses templates from admin/fileperms)
### +-+ Check if neccesary (Check if checking for 777 is neccesary)
###   +- File permissions (Check directories for 777, Try to set to 777, display Result)
###
*/ 

// directories & files to be checked
if($dbsystem == 'filesystem') {
    // Try to set file permissions if user asks to
    // Will only work if PHP may use the chmod command, not necesarry on
    // Windows systems, but won`t do any harm anyway.
    if ($_GET['chmodtry']=='true') {
        SetFilepermissions($fsdb_conf['tables']);
    }
    
    // Get permissions on needed files & directories & Make templates
    $pktpl_vars['template_admin_filepermsTableRows'] = '';
    foreach($fsdb_conf['tables'] as $dir) {
        $pktpl_vars['filename'] = $dir;
        if ( ChmodIs777($dir) ) {
            $pktpl_vars['tdclass']  = 'filepermsbgY';
            $pktpl_vars['fileperm'] = $l['permission_ok'];
        } // if
        else {
            $pktpl_vars['tdclass']  = 'filepermsbgN';
            $pktpl_vars['fileperm'] = $l['permission_nok'];
        } // else
        $pktpl_vars['template_admin_filepermsTableRows'] .= pktpl('adminmenu/fileperms/TableRow.html');
        
    } // foreach
} // if
else {
    $pktpl_vars['template_admin_filepermsTableRows'] = pktpl('adminmenu/fileperms/TableRowEmpty.html');
} // else

$pktpl_vars['template_admin_filepermsTableRows'] .= pktpl('adminmenu/fileperms/TableRowsHelp.html');

$pktpl_vars['template_admin_table'] = pktpl('adminmenu/fileperms/Table.html');

?>