my friend said that this would be the best way to work the script....
$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>";
}
echo <<<HTML
<br /><br />
<b>If CHMOD was not successful above then CHMOD the following files before continuing:</b><br /><br />
$file_list<br /><br />
<b>Command Lines:</b><br /><br />
$command_line1<br /><br />
or<br /><br />
$command_line2<br /><br />
<form action="$self" method="POST">
HTML;