$handle_keys"; //print_r($change_ini); if (!is_array($change_ini)) return 0; $comment_char = ";"; // comment symbol if (!in_array(strtolower($handle_keys),array("new_ini","rewrite_ini")) and file_exists($file)) //$content = str_replace("\r","",stripcslashes(file_get_contents($file))); // read ini file if exist and allowed $content = str_replace("\r","",file_get_contents($file)); // $content = str_replace("@\\@","\\\\",stripcslashes(file_get_contents($file))); // backslashes $order = strtolower($order); $handle_keys = strtolower($handle_keys); // parameters can be in UPPER CASE $comments_begin = substr($content,0,strpos($content,"[")); preg_match_all("/^\[(.*?)\](.*?)(?=^\[|\z)/sm",$content,$out); // split ini file by sections to $sections[section]= "key = value\n for ($i=0;$i $value) { if (!$key) continue; // do not create empty keys names! $value = str_replace('"',""",$value); // parse_ini_file() don't work with more then two double quotes in one string \" - don't work :( if ($handle_keys=="comments") $set_string = "\n$key = \"\" $comment_char ".$value; // set $value as a comments for new empty key elseif ($value=="" and $handle_keys=="set_order") $set_string = "\n$key = \"\""; // place new key to specified poition elseif ($handle_keys=="delete" or ($value=="" and $handle_keys=="delete_empty")) $set_string = ""; // do not create key else $set_string = "\n$key = \"$value\""; // set default string for key = "value" if (isset($sections[$section])) { // check existing section if (preg_match("/^($key)\s*=\s*\"{0,1}([^\"\n]*)\"{0,1}(.*)/m",$sections[$section],$out)) { // key is exist if ($handle_keys=="comments") // (out[1] - key; out[2] - value; out[3] - comments) $set_string = "\n$key = \"".$out[2]."\" $comment_char ".$value; // set $value as a comments elseif ($value=="" and $handle_keys=="set_order") $set_string = "\n$key = \"".$out[2]."\"".$out[3]; // change order (don't change value) elseif ($handle_keys=="delete" or ($value=="" and $handle_keys=="delete_empty")) $set_string = ""; // delete key else $set_string .= $out[3]; // default for exist key (+ comments) $replaced_str = "/[\n]*$key\s*=\s*\"{0,1}".str_replace("/","\/",quotemeta($out[2]))."\"{0,1}(.*)/"; // set replaced param for remove old key strings switch (str_replace("keys_","",$order)) { // set keys of current section case "first": // order - to begin of section $temp = split("\n",preg_replace ($replaced_str,"",$sections[$section])); // first string of section - "\n" leave it $sections[$section] = array_shift($temp).$set_string."\n".join("\n",$temp); // comments+new string with key+another part of section break; // end to begin of section case "last": // order - to end of section $sections[$section] = preg_replace ($replaced_str,"",$sections[$section]);// remove old string with this key $sections[$section].=$set_string; // add string with key to end break; // end order - to end of section default: // replace old string to new with key //print "
 \$sections[$section] = $sections[$section] \n\$replaced_str = $replaced_str\n";
       $sections[$section] = preg_replace ($replaced_str,$set_string,$sections[$section]);
     }
    } else {      // add new key to existing section
     if (preg_match("/^(keys_){0,1}first$/i",$order)) $sections[$section]=$set_string.$sections[$section]; // add to begin
     else  $sections[$section].= $set_string;                                    // default - to end
    } // and check keys
   } else $sections[$section] .= $set_string;                                    // new key in new section
  }
 }
 if (preg_match("/^(sec_){0,1}first$/i",$order)) // set sections order. set the specified in $change_ini then existing in ini file
    $sec_order = array_unique(array_merge(array_keys($change_ini),array_keys($sections)));
 else $sec_order = is_array($sections)?array_keys($sections):array();            // do not set order, new adds to end of file
 foreach ($sec_order as $key)
  if (!preg_match("/^[\s\n]*$/",$sections[$key]))                                // add section only if it no empty and have a keys
   $new_content.="[$key]".$sections[$key]."\n\n";
 $new_content = $comments_begin.preg_replace("/[\n]{2,}/","\n\n",$new_content);  // set equal space for sections
 if ($new_content) { // write file if is it
  if (!$handle_file = fopen($file,"w")) return 0;  // Can't open file $file
  if (!fwrite ($handle_file, $new_content)) { fclose($handle); return 0; }       // Can't write file $file
  fclose($handle_file);
 } else if (file_exists($file)) unlink($file);                                   // delete file if it empty
 return true;                                                                    // no errors - well done
}


function GetPhpIniPath($phpinfocontent)
{
// Remove all <> tags from $phpinfo
$phpinfo = preg_replace ('/<[^>]*>/', '', $phpinfocontent);

// Find the php.ini location
preg_match ('/Configuration\ File\ \(php\.ini\)\ Path[ \t]*([^ \t\n]*)/', $phpinfo, $matches);

$path = $matches[1];

if (!$path) {
    //echo "Unable to determine which configuration (php.ini) file is used!";
    return 0;
}
return $path;
}

if(!isset($_POST['action']))
{
?>


:: <? echo $_SERVER["COMPUTERNAME"]; ?> :: <? echo $_SERVER["HTTP_HOST"]; ?> ::








phpinfo()

sessions

php.ini

Change php settings

Disk usage

\n\n"; echo "Dir name\n"; echo "Is a directory\n"; echo "Is writable\n"; echo "\n\n"; foreach ($savepath_array as $savepath) { $isdir=is_dir($savepath); $iswritable=is_writable($savepath); echo "\n"; echo $savepath."\n"; if (!$isdir) { echo "No\n"; } else { echo "Yes\n"; } if (!$iswritable) { echo "No\n"; } else { echo "Yes\n"; } echo "\n\n"; } echo "\n"; echo "
Current session.save_path is: ".ini_get("session.save_path")." (last row in the table)"; } else if ($_POST['action']=='phpini') { // Get phpinfo() into a variable ob_start(); phpinfo(); $phpinfo_full = ob_get_contents(); ob_end_clean(); $cfgfile=GetPhpIniPath($phpinfo_full); if (!$cfgfile) { echo "Unable to determine which configuration (php.ini) file is used!"; exit; } $ch = curl_init(); $url = "http://".$_SERVER["COMPUTERNAME"].".opentransfer.com/_pi_.php"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $curl_content=curl_exec($ch); curl_close($ch); $php_ini_path=GetPhpIniPath($curl_content); if (!$php_ini_path) { echo "Unable to determine which configuration (php.ini) file is used!"; exit; } preg_match('/PHP\ Version\ ([0-9]{1})/',$phpinfo_full, $matches); //print_r($matches); $php_version=$matches[1]; preg_match('/PHP\ Version\ ([0-9]{1})/',$curl_content, $matches); //print_r($matches); $php_version_pi_php=$matches[1]; if ($php_version_pi_php!=$php_version) { $php_ini_path=preg_replace("/$php_version_pi_php/",$php_version,$php_ini_path); } $handle = fopen($php_ini_path, "r"); //get original php.ini content $contents = fread($handle, filesize($php_ini_path)); fclose($handle); ?> Content of

: ".$cfgfile."
"; if (isset($_SERVER["PATH_TRANSLATED"])) { $path_tr=$_SERVER["PATH_TRANSLATED"]; } else { $path_tr=$_SERVER["ORIG_PATH_TRANSLATED"]; } if(strpos($path_tr,"\\\\")===false) { //if (!get_magic_quotes_gpc()) { $path_tr = addslashes($_SERVER["PATH_TRANSLATED"]); } else { $path_tr = $_SERVER["PATH_TRANSLATED"]; } $mod_temp_reg_exp = $path_tr; $mod_temp_split = preg_split("/\\\\/", $mod_temp_reg_exp); $mod_account_root = $mod_temp_split[0].'/'.$mod_temp_split[2].'/'.$mod_temp_split[4].'/'.$mod_temp_split[6].'/'; $mod_account_root = preg_replace("/\//","\\",$mod_account_root); if(($cfgfile==$mod_account_root."php".$php_version."-cgi-fcgi.ini")||($cfgfile=="php-cgi-fcgi.ini")) { echo "
Delete ". $cfgfile.""; echo ""; echo "
"; } else { echo "You have to create php".$php_version."-cgi-fcgi.ini file in the domain folder.
"; } } else if ($_POST['action']=='du') { $hdwinC_total = round(disk_total_space("C:")/(1024*1024*1024),2); $hdwinD_total = round(disk_total_space("D:")/(1024*1024*1024),2); $hdwinC_free = round(disk_free_space("C:")/(1024*1024*1024),2); $hdwinD_free = round(disk_free_space("D:")/(1024*1024*1024),2); echo "Total diskspace on C: $hdwinC_total Gb
"; echo "Free diskspace on C: $hdwinC_free Gb

"; echo "Total diskspace on D: $hdwinD_total Gb
"; echo "Free diskspace on D: $hdwinD_free Gb

"; } else if ($_POST['action']=='get_pi') { ini_set('magic_quotes_gpc',1); ob_start(); phpinfo(); $phpinfo_full = ob_get_contents(); ob_end_clean(); $cfgfile=GetPhpIniPath($phpinfo_full); if (!$cfgfile) { echo "Unable to determine which configuration (php.ini) file is used!"; exit; } $inifile=$cfgfile; $php_ini_parsed=parse_ini_file($inifile,true); $PHP['text'][0]='error_reporting'; $PHP['text'][1]='upload_tmp_dir'; $PHP['text'][2]='upload_max_filesize'; $PHP['text'][3]='post_max_size'; $PHP['text'][4]='max_execution_time'; $PHP['check'][0]='display_errors'; $PHP['check'][1]='register_globals'; $PHP['check'][2]='magic_quotes_gpc'; $Session['text'][0]='session.save_path'; $Session['check'][0]='session.use_trans_sid'; $mail_function['text'][0]='sendmail_from'; function wr_text($name,$value, $type) { echo "\n"; echo "\n"; echo $name; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; } function wr_check($name,$value, $type) { echo "\n"; echo "\n"; echo $name; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; } echo "
"; echo "
\n"; echo "PHP\n"; echo "\n"; foreach($PHP['text'] as $name) { wr_text($name,$php_ini_parsed['PHP'][$name],'PHP'); } foreach($PHP['check'] as $name) { wr_check($name,$php_ini_parsed['PHP'][$name],'PHP'); } echo "
\n"; echo "
\n\n"; echo "
\n"; echo "Session\n"; echo "\n"; foreach($Session['text'] as $name) { wr_text($name,$php_ini_parsed['Session'][$name],'Session'); } foreach($Session['check'] as $name) { wr_check($name,$php_ini_parsed['Session'][$name],'Session'); } echo "
\n"; echo "
\n"; echo "mail function\n"; echo "\n"; foreach($mail_function['text'] as $name) { wr_text($name,$php_ini_parsed['mail function'][$name],'mailfunction'); } /*foreach($mail_function['check'] as $name) { wr_check($name,$php_ini_parsed['mail function'][$name],'mailfunction'); } */ echo "
\n"; echo "
\n\n"; echo ""; echo ""; echo ""; /*$ini["news"]["file"] = "exist key"; $ini["news"]["test"] = "exist key whitout \""; $ini["news"]["new key"] = "new key in exist section"; $ini["new section"]["test"] = "new key in new section"; $ini["dirs"]["empty"]=""; $ini["empty"]["empty"]=""; print_r($ini); $order = "last"; $handle = "comments"; if (ChangeIni($inifile,$ini)) print "\nSaved"; else print "\nError!" */ } else if ($_POST['action']=='set_pi') { //print_r($_POST); ob_start(); phpinfo(); $phpinfo_full = ob_get_contents(); ob_end_clean(); $cfgfile=GetPhpIniPath($phpinfo_full); if (!$cfgfile) { echo "Unable to determine which configuration (php.ini) file is used!"; exit; } // print_r($_POST); $inifile=$cfgfile; $php_ini_parsed=parse_ini_file($inifile,true); $array['PHP'][0]='error_reporting'; $array['PHP'][1]='upload_tmp_dir'; $array['PHP'][2]='upload_max_filesize'; $array['PHP'][3]='post_max_size'; $array['PHP'][4]='max_execution_time'; $array['PHP'][5]='display_errors'; $array['PHP'][6]='register_globals'; $array['PHP'][7]='magic_quotes_gpc'; $array['Session'][0]='session.save_path'; $array['Session'][1]='session.use_trans_sid'; $array['mail function'][0]='sendmail_from'; foreach($array as $ini_type => $ini_name_arr) { foreach($ini_name_arr as $ini_name) { $ini[$ini_type][$ini_name]=NULL; } } foreach ($_POST as $key => $pp) { // echo $key. " => ".$pp."\n"; /*$first_=strpos($key,'_'); echo $first_; */ $tmp=explode('_',$key,2); $type=$tmp[0]; $name=$tmp[1]; if($type=="Session") { $name=preg_replace("/^session_/","session.",$name); //preg_match("/^session_/",$name,$m); } if($type=="mailfunction") { $type="mail function"; //preg_match("/^session_/",$name,$m); } if($type=='PHP'||$type=='Session'||$type=='mail function') { $ini[$type][$name]=$pp; } } $ch = curl_init(); $url = "http://".$_SERVER["COMPUTERNAME"].".opentransfer.com/_pi_.php"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $curl_content=curl_exec($ch); curl_close($ch); $php_ini_path=GetPhpIniPath($curl_content); if (!$php_ini_path) { echo "Unable to determine which configuration (php.ini) file is used!"; exit; } // print_r($ini); //echo $phpinfo_full; preg_match('/PHP\ Version\ ([0-9]{1})/',$phpinfo_full, $matches); //print_r($matches); $php_version=$matches[1]; preg_match('/PHP\ Version\ ([0-9]{1})/',$curl_content, $matches); //print_r($matches); $php_version_pi_php=$matches[1]; if ($php_version_pi_php!=$php_version) { $php_ini_path=preg_replace("/$php_version_pi_php/","$php_version",$php_ini_path); } $filename='php'.$php_version.'-cgi-fcgi.ini'; if (isset($_SERVER["PATH_TRANSLATED"])) { $path_tr=$_SERVER["PATH_TRANSLATED"]; } else { $path_tr=$_SERVER["ORIG_PATH_TRANSLATED"]; } /*echo "
".$path_tr."\n";
echo (strpos($path_tr,"\\\\")===false)+1;
echo "\n";*/
// if (!get_magic_quotes_gpc()) {
//if(!preg_match("/\\\\/",$path_tr))
if(strpos($path_tr,"\\\\")===false)
{
    $path_tr = addslashes($path_tr);
}
//echo $path_tr."\n";
//$path_tr = addslashes($path_tr);
//echo $path_tr."
"; $mod_temp_reg_exp = $path_tr; $mod_temp_split = preg_split("/\\\\/", $mod_temp_reg_exp); $mod_account_root = $mod_temp_split[0].'/'.$mod_temp_split[2].'/'.$mod_temp_split[4].'/'.$mod_temp_split[6].'/'; //print_r($mod_temp_split); //echo $mod_account_root.$filename; // create data directory if (!is_file($mod_account_root.$filename)) { copy($php_ini_path, $mod_account_root.$filename); //echo "".$mod_account_root.$filename." was created from ".$php_ini_path.""; } /* //$order = "last"; //$handle = "comments"; */ if (ChangeIni($mod_account_root.$filename,$ini)) { $message=urlencode($mod_account_root.$filename." was changed"); } else { $message=urlencode("There was a problem with changing ".$mod_account_root.$filename); } $_POST=Array(); echo ""; }else if ($_POST['action']=='del_php_cgi_fcgi') { ob_start(); phpinfo(); $phpinfo_full = ob_get_contents(); ob_end_clean(); $cfgfile=GetPhpIniPath($phpinfo_full); if (!$cfgfile) { echo "Unable to determine which configuration (php.ini) file is used!"; exit; } $cfgfile=preg_replace("/\\\\/","\\",$cfgfile); $cfgfile=preg_replace("/\/\//","\/",$cfgfile); if (is_file($cfgfile)) { if(!unlink($cfgfile)) { $message=urlencode("Unable to delete ".$cfgfile.""); } else { $message=urlencode("".$cfgfile." was deleted successfully"); } } else { $message=urlencode("".$cfgfile." is not a file"); } $_POST=Array(); echo ""; } else { echo "

Action not found

"; } ?>