hi im building my own CMS and i want to have automatic CHMODing for the people who use it so it saves them time and effort but the code my friend helped me with located bellow isnt working properly... idk if any of u know how to fix this way or if there is a better method for me to chmod these files.... thanks for the help
$files = "code.php:0666,config.php:0666,index_content.php:0666,header.php:0666,footer.php:0666,control_content.php:0666,users/:0777,includes/styles.php:0666,creation_log.php:0666,guests_online.php:0666";
$mod_dir = "";
$dir = "modules";
$handle=@opendir($dir);
$dir_arr = array();
while ($file = readdir($handle)) {
if ($file != "." && $file != ".." && $file != "index.html") {
if(is_dir($dir."/".$file)) {
if(file_exists($dir."/".$file."/chmod.php")) {
if(!instr("\$files",rf($dir."/".$file."/chmod.php"))) {
$chmod = "";
require($dir."/".$file."/chmod.php");
if($chmod != "") {
$mod_dir = $dir."/".$file;
$chmod_arr = explode(",",$chmod);
$new_list = "";
foreach($chmod_arr as $single_chmod) {
$sc_arr = explode(":",$single_chmod);
$files = $files.",".$mod_dir."/".$sc_arr[0].":".$sc_arr[1];
}
}
}
}
}
}
}
$files_arr = explode(",",$files);
$file_list = "";
$command_line1 = "";
$command_line2 = "";
foreach($files_arr as $single_file) {
$sf_arr = explode(":",$single_file);
if(@chmod($sf_arr[0], $sf_arr[1])) { echo $sf_arr[1]." :: CHMOD Successful.<br />\n"; }
echo @shell_exec("chmod ".$sf_arr[1]." ".$sf_arr[0]);
$command_line1 = $command_line1."chmod ".$sf_arr[1]." ".$sf_arr[0].";";
$command_line2 = $command_line2."site chmod ".$sf_arr[1]." ".$sf_arr[0].";";
$file_list = $file_list.$sf_arr[0]." <i>".$sf_arr[1]."<br>";
}
echo "Attempting to write a file.<br />";
if(@wf("code.php","w","<?php\n\$xcode = \"*\";\n?>")) {
echo "<font style='font-size: 13px; font-family: Arial; font-weight: bold;'>Successful</font>";
}
else {
echo "<font style='font-size: 13px; font-family: Arial; font-weight: bold; color: #FF0000;'>Error</font>";