..will make a new module and not just some new module, nope let's make a fully automatic injection script! This tutorial is the first step into making this. Let's first explain what we're..
xAnalyze is a module that can search through corrupt data and configuration files in order to find the exact position of errors
<?php
/* Appearance of tools definer
Author: Remco Kouw
Site: http://www.hacksuite.com
Last Edit: 15-03-2015
*/
if(!defined('IN_SCRIPT')){
exit;
}
$_CONTEXT['subtitle'] = "Appearance";
// target files we need, so make sure they are present
$aFiles = array($_PATHS['functions_root']."/fwrite.php",$_PATHS['data_root']."/appearance.php");
for($x=0;$x<count($aFiles);$x++){
(!IsThere($aFiles[$x]) ? include_once($_PATHS['end']) : include_once($aFiles[$x]));
}
// correct values
$aValues = array(0,1);
$sCode = (isset($sCode) ? $sCode : "");
$sTemplate = "";
if(!isset($_POST['sent'])){
/* construct form */
$sCode .= " <form method=\"post\">\n";
$sCode .= " <div class=\"emboss borderr5 border1pxtrans pad5 edgeglow overflw\">\n";
$sCode .= " <div class=\"embosshdrnocenter border1pxtrans pad10\">Enable or disable certain features in your suite</div>\n";
foreach($_CONTEXT['rightdisplay'] as $sKey=>$iValue){
$sCode .= " <div class=\"cc_record\">\n";
$sCode .= " <div class=\"flt pad3 w200\">\n";
if(!isset($_POST[$sKey]) || !in_array($_POST[$sKey],$aValues)){
// if the form field is invalid or missing just set the option to enabled
$_POST[$sKey] = 1;
}
$sCode .= str_replace("_"," ",$sKey)."\n";
$sCode .= " </div>\n";
$sCode .= " <div class=\"flt pad3 w300\">\n";
$sCode .= " <select name=\"".$sKey."\">\n";
if($iValue==1){
$sCode .= " <option value=\"1\" selected>enabled</option>\n";
$sCode .= " <option value=\"0\">disabled</option>\n";
}
else{
$sCode .= " <option value=\"0\" selected>disabled</option>";
$sCode .= " <option value=\"1\">enabled</option>";
}
$sCode .= " </select>\n";
$sCode .= " </div>\n";
$sCode .= " </div>\n";
$sCode .= " <div class=\"clear\"></div>\n";
}
$sCode .= " <div class=\"cc_record\">\n";
$sCode .= " <div class=\"flt pad3\"><input type=\"hidden\" name=\"iCFG\" value=\"".$_POST['iCFG']."\" /><input type=\"submit\" name=\"sent\" value=\"Change Style\" /></div>\n";
$sCode .= " </div>\n";
$sCode .= " <div class=\"clear\"></div>\n";
$sCode .= " </div>\n";
$sCode .= " </form>\n";
}
else{
/* form has been sent */
$sTemplate = "<?php\n";
$sTemplate .= "/* appearance */\n";
$sTemplate .= "\$_CONTEXT['rightdisplay'] = array();\n";
foreach($_CONTEXT['rightdisplay'] as $sKey=>$iValue){
if(!isset($_POST[$sKey]) || !in_array($_POST[$sKey],$aValues)){
// if the form field is invalid or missing just set the option to enabled
$_POST[$sKey] = 1;
}
$sTemplate .= "\$_CONTEXT['rightdisplay']['".$sKey."'] = ".$_POST[$sKey].";\n";
}
$sTemplate .= "?>";
if(!WriteF($aFiles[1],$sTemplate,"w")){
// update failed
include_once($_CONTEXT['end']);
}
else{
$sCode .= "<div class=\"spacingmsg\">".$_CONTEXT['result_headers']['result']."Update succeeded, click <a href=\"configuration.php\">here</a> to continue</div>\n";
}
}
?>