..I will show you how to create native tools. I'm not going to make a new tool though, instead I will show you what is required to create one. You can find all the native tools in..
xAnalyze is a module that can search through corrupt data and configuration files in order to find the exact position of errors
<?php
/* Configure maintenance scanner
Author: Remco Kouw
Site: http://www.hacksuite.com
Last Edit: 05-02-2015
*/
session_cache_limiter('nocache');
header('Expires: '.gmdate('r',0));
header('Content-type: application/json');
$_DYNAMIC_ROOT = "..";
$bWriteMe = false;
include_once("../header.php");
$sDest = "../vars.php";
$aDataR = array();
$aDataR['jresult'] = false;
$aDataR['jmessage'] = "an error occured";
// target files we need, so make sure they are present
$aFiles = array($_PATHS['functions_root']."/fwrite.php",$_PATHS['functions_root']."/get_file_data.php");
for($x=0;$x<count($aFiles);$x++){
if(!file_exists($aFiles[$x])){
$aDataR['jmessage'] = "Missing required file: ".$aFiles[$x];
die(json_encode($aDataR));
}
@include_once($aFiles[$x]);
}
if(!is_writable($sDest)){
$aDataR['jmessage'] = "Make sure the file vars.php in root is writable";
}
else{
$sData = GetFileData($sDest);
$sMD5 = md5($sData);
if(isset($_POST['iUpdateMe'])){
switch($_POST['iUpdateMe']){
/* enable or disable maintenance scans */
case"0":
if(!isset($_POST['iUpdate']) || $_POST['iUpdate']!=1){
$aDataR['jmessage'] = "You need to select the checkbox in order to make changes";
}
else{
// update the settings
$sOld = "\$_CONTEXT['allow_maintenance_scan'] = ".($_CONTEXT['allow_maintenance_scan'] ? "true" : "false").";";
$sNew = "\$_CONTEXT['allow_maintenance_scan'] = ".($_CONTEXT['allow_maintenance_scan'] ? "false" : "true").";";
$sData = str_replace($sOld,$sNew,$sData);
$aDataR['jmessage'] = "Successfully updated maintenance scan settings";
$aDataR['jref'] = ($_CONTEXT['pass_access'] ? 0 : 1);
$bWriteMe = true;
}
break;
/* scan for log,configuration and data files that became bigger than $_CONTEXT['maxflsz'] */
case"1":
if(!isset($_POST['iUpdate']) || $_POST['iUpdate']!=1){
$aDataR['jmessage'] = "You need to select the checkbox in order to make changes";
}
else{
// update the settings
$sOld = "\$_CONTEXT['allow_filesizescan'] = ".($_CONTEXT['allow_filesizescan'] ? "true" : "false").";";
$sNew = "\$_CONTEXT['allow_filesizescan'] = ".($_CONTEXT['allow_filesizescan'] ? "false" : "true").";";
$sData = str_replace($sOld,$sNew,$sData);
$aDataR['jmessage'] = "Successfully updated filesize scan settings";
$aDataR['jref'] = ($_CONTEXT['allow_filesizescan'] ? 0 : 1);
$bWriteMe = true;
}
break;
/* maximum filesize of log,configuration and data files in KB */
case"2":
if(!isset($_POST['iFileSize']) || $_POST['iFileSize']==""){
$aDataR['jmessage'] = "No maximum filesize specified";
}
else{
$_POST['iFileSize'] = @intval($_POST['iFileSize']);
if(!is_int($_POST['iFileSize']) || $_POST['iFileSize']<11){
// invalid filesize value
$aDataR['jmessage'] = "Files need to be larger than 10KB";
}
else{
$sOld = "\$_CONTEXT['maxflsz'] = ".$_CONTEXT['maxflsz'].";";
$sNew = "\$_CONTEXT['maxflsz'] = ".$_POST['iFileSize'].";";
$sData = str_replace($sOld,$sNew,$sData);
$sMD5New = md5($sData);
if($sMD5New==$sMD5){
$aDataR['jmessage'] = "Nothing to update";
}
else{
$aDataR['jmessage'] = "Successfully updated maximum filesize";
$aDataR['jref'] = $_POST['iFileSize'];
$bWriteMe = true;
}
}
}
break;
/* analyzes logfiles */
case"3":
if(!isset($_POST['iUpdate']) || $_POST['iUpdate']!=1){
$aDataR['jmessage'] = "You need to select the checkbox in order to make changes";
}
else{
// update the settings
$sOld = "\$_CONTEXT['allow_logfileanalyze'] = ".($_CONTEXT['allow_logfileanalyze'] ? "true" : "false").";";
$sNew = "\$_CONTEXT['allow_logfileanalyze'] = ".($_CONTEXT['allow_logfileanalyze'] ? "false" : "true").";";
$sData = str_replace($sOld,$sNew,$sData);
$aDataR['jmessage'] = "Successfully updated log analyze scan settings";
$aDataR['jref'] = ($_CONTEXT['allow_logfileanalyze'] ? 0 : 1);
$bWriteMe = true;
}
break;
/* checks if all required functions are there */
case"4":
if(!isset($_POST['iUpdate']) || $_POST['iUpdate']!=1){
$aDataR['jmessage'] = "You need to select the checkbox in order to make changes";
}
else{
// update the settings
$sOld = "\$_CONTEXT['allow_functcheck'] = ".($_CONTEXT['allow_functcheck'] ? "true" : "false").";";
$sNew = "\$_CONTEXT['allow_functcheck'] = ".($_CONTEXT['allow_functcheck'] ? "false" : "true").";";
$sData = str_replace($sOld,$sNew,$sData);
$aDataR['jmessage'] = "Successfully updated function scan settings";
$aDataR['jref'] = ($_CONTEXT['allow_functcheck'] ? 0 : 1);
$bWriteMe = true;
}
break;
/* count the files in specific folders in order to minimize the amount of garbage */
case"5":
if(!isset($_POST['iUpdate']) || $_POST['iUpdate']!=1){
$aDataR['jmessage'] = "You need to select the checkbox in order to make changes";
}
else{
// update the settings
$sOld = "\$_CONTEXT['allow_filesindirscan'] = ".($_CONTEXT['allow_filesindirscan'] ? "true" : "false").";";
$sNew = "\$_CONTEXT['allow_filesindirscan'] = ".($_CONTEXT['allow_filesindirscan'] ? "false" : "true").";";
$sData = str_replace($sOld,$sNew,$sData);
$aDataR['jmessage'] = "Successfully updated files in directory scan settings";
$aDataR['jref'] = ($_CONTEXT['allow_filesindirscan'] ? 0 : 1);
$bWriteMe = true;
}
break;
/* maximum files in dir before reporting */
case"6":
if(!isset($_POST['iFiles']) || $_POST['iFiles']==""){
$aDataR['jmessage'] = "No maximum files specified";
}
else{
$_POST['iFiles'] = @intval($_POST['iFiles']);
if(!is_int($_POST['iFiles']) || $_POST['iFiles']<11){
// invalid filesize value
$aDataR['jmessage'] = "File amount should at least be more than 10 files";
}
else{
$sOld = "\$_CONTEXT['maxflsindir'] = ".$_CONTEXT['maxflsindir'].";";
$sNew = "\$_CONTEXT['maxflsindir'] = ".$_POST['iFiles'].";";
$sData = str_replace($sOld,$sNew,$sData);
$sMD5New = md5($sData);
if($sMD5New==$sMD5){
$aDataR['jmessage'] = "Nothing to update";
}
else{
$aDataR['jmessage'] = "Successfully updated maximum amount of files";
$aDataR['jref'] = $_POST['iFiles'];
$bWriteMe = true;
}
}
}
break;
/* global interval between a next maintenance scan */
case"7":
if(!isset($_POST['iAmount']) || $_POST['iAmount']==""){
$aDataR['jmessage'] = "No maximum filesize specified";
}
else{
$_POST['iAmount'] = @intval($_POST['iAmount']);
if(!is_int($_POST['iAmount']) || $_POST['iAmount']<=3600){
// invalid scan interval
$aDataR['jmessage'] = "Minimum scan interval must be an hour";
}
else{
$sOld = "\$_CONTEXT['nextscanseconds'] = ".$_CONTEXT['nextscanseconds'].";";
$sNew = "\$_CONTEXT['nextscanseconds'] = ".$_POST['iAmount'].";";
$sData = str_replace($sOld,$sNew,$sData);
$sMD5New = md5($sData);
if($sMD5New==$sMD5){
$aDataR['jmessage'] = "Nothing to update";
}
else{
$aDataR['jmessage'] = "Successfully updated interval";
$aDataR['jref'] = $_POST['iAmount'];
$bWriteMe = true;
}
}
}
break;
default:
}
}
else{
$aDataR['jmessage'] = "Invalid action specified";
}
}
if($bWriteMe){
WriteF($sDest,$sData,"w");
$aDataR['jresult'] = true;
}
echo json_encode($aDataR);
?>