';
if (isset($GLOBALS["GOTMLS"]["tmp"]["stuffbox"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["stuffbox"])) {
echo '
';
}
echo '
';
}
function GOTMLS_get_scan_history() {
global $wpdb;
$GOTMLS_nonce_context = __FUNCTION__."285";
$GOTMLS_nonce = GOTMLS_set_nonce($GOTMLS_nonce_context);
$imported = 0;
$LastScan = '';
if (isset($_GET["GOTMLS_clear_history"]) && (strlen($clear_hist = preg_replace('/[^0-9a-f]++]i/', "", $_GET["GOTMLS_clear_history"])) == 32) && GOTMLS_get_nonce($GOTMLS_nonce_context) && GOTMLS_user_can()) {
if (($ors = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_date FROM `$wpdb->posts` WHERE post_type = %s AND post_name = %s", 'gotmls_results', $clear_hist), ARRAY_A)) && isset($ors[0]["post_parent"]) && is_numeric($ors[0]["post_parent"]) && ($ors[0]["post_parent"] > 0) && ($wpdb->get_results($wpdb->prepare("SELECT COUNT(ID) FROM `$wpdb->posts` WHERE post_type = %s AND post_parent = %s", 'gotmls_results', $ors[0]["ID"]), ARRAY_A)) && ($cleared = $wpdb->query($wpdb->prepare("DELETE FROM `$wpdb->posts` WHERE post_type = %s AND post_date < %s", 'gotmls_results', $ors[0]["post_date"]))))
$wpdb->update($wpdb->posts, array("post_parent" => 0), array("post_type" => 'gotmls_results', "ID" => $ors[0]["ID"]));
$LastScan .= sprintf(__("Cleared %s records from the history.",'gotmls'), $cleared);
}
$SQL = $wpdb->prepare("SELECT * FROM `$wpdb->posts` WHERE post_type = %s ORDER BY post_date DESC", 'gotmls_results');
$units = array("seconds"=>60,"minutes"=>60,"hours"=>24,"days"=>365,"years"=>10);
if (!($prs = $wpdb->get_results($SQL, ARRAY_A))) {
if ($ors = $wpdb->get_results($wpdb->prepare("SELECT substring_index(option_name, '/', -1) AS `mt`, option_name, option_value FROM `$wpdb->options` WHERE option_name LIKE %s ORDER BY mt ASC", 'GOTMLS_scan_log/%'), ARRAY_A)) {
$parent = 0;
foreach ($ors as $row) {
$GOTMLS_scanlog = (isset($row["option_name"])?get_option($row["option_name"], array()):array());
$option_names = explode("/", "/".$row["option_name"]);
$mt = array_pop($option_names);
if (strlen($mt) && is_numeric($mt)) {
$insert = array("post_name" => md5($mt), "post_content" => json_encode($GOTMLS_scanlog), "post_author" => GOTMLS_get_current_user_id(0), "post_type" => 'gotmls_results', "post_date_gmt" => date("Y-m-d H:i:s", (int) $mt), "post_parent" => $parent);
if (isset($GOTMLS_scanlog["scan"]["type"]) && strlen($GOTMLS_scanlog["scan"]["type"]))
$insert["post_title"] = GOTMLS_sanitize($GOTMLS_scanlog["scan"]["type"]);
else
$insert["post_title"] = "Unknown scan type";
if (isset($GOTMLS_scanlog["scan"]["dir"]) && @is_dir($GOTMLS_scanlog["scan"]["dir"]))
$insert["post_title"] .= " of ".basename($GOTMLS_scanlog["scan"]["dir"]);
if (isset($GOTMLS_scanlog["scan"]["start"]) && is_numeric($GOTMLS_scanlog["scan"]["start"])) {
$insert["post_date"] = date("Y-m-d H:i:s", $GOTMLS_scanlog["scan"]["start"]);
$insert["post_modified"] = date("Y-m-d H:i:s", $GOTMLS_scanlog["scan"]["start"]);
$ukeys = array_keys($units);
$insert["post_title"] .= " on ".date("Y-m-d", $GOTMLS_scanlog["scan"]["start"]);
if (isset($GOTMLS_scanlog["scan"]["finish"]) && is_numeric($GOTMLS_scanlog["scan"]["finish"]) && ($GOTMLS_scanlog["scan"]["finish"] >= $GOTMLS_scanlog["scan"]["start"])) {
$insert["post_modified"] = date("Y-m-d H:i:s", $GOTMLS_scanlog["scan"]["finish"]);
$insert["post_modified_gmt"] = date("Y-m-d H:i:s", $GOTMLS_scanlog["scan"]["finish"]);
$time = ($GOTMLS_scanlog["scan"]["finish"] - $GOTMLS_scanlog["scan"]["start"]);
for ($unit = $ukeys[0], $key=0; (isset($units[$ukeys[$key]]) && $key < (count($ukeys) - 1) && $time >= (2 * $units[$ukeys[$key]])); $unit = $ukeys[++$key])
$time = floor($time/$units[$ukeys[$key]]);
if (1 == $time)
$unit = substr($unit, 0, -1);
if ($time)
$insert["post_title"] .= " ran for $time $unit";
} else
$insert["post_title"] .= " was not finished!";
} else
$insert["post_title"] .= " failed to started!";
if ($inserted = $wpdb->insert($wpdb->posts, $insert)) {
$imported++;
$parent = $wpdb->insert_id;
} else
return sprintf(__("Failed to Import Scan History ID %s : %s",'gotmls'), $mt, $wpdb->last_error);
} else
return sprintf(__("Error: Failed to migrate old Scan History from %s.",'gotmls'), $row["option_name"]);
}
if ($cleared = $wpdb->query($wpdb->prepare("DELETE FROM `$wpdb->options` WHERE option_name LIKE %s", 'GOTMLS_scan_log/%')))
$LastScan .= sprintf(__("Converted %s of %s records from the Scan History into the new Scan Log record. Future Scans will now store more result data in the new Log.",'gotmls'), $imported, $cleared);
$prs = $wpdb->get_results($SQL, ARRAY_A);
}
}
if ($prs && is_array($prs) && count($prs)) {
$scans = 0;
$PreScan = '';
} else
$LastScan .= '
'.__("No Scans have been logged",'gotmls').'
';
return "$LastScan\n";
}
function GOTMLS_get_whitelists() {
global $wpdb, $post;
$Q_Page = '';
if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"])) {
$Q_Page .= '
'.__("Globally White-listed files",'gotmls').''.__("# of patterns",'gotmls').''.__("Date Updated",'gotmls').'
';
foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"] as $file => $non_threats) {
if (isset($non_threats[0])) {
$updated = GOTMLS_sexagesimal($non_threats[0]);
unset($non_threats[0]);
} else
$updated = "Unknown";
$Q_Page .= '- '.count($non_threats).''.$updated."$file
\n";
}
if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"])) {
$Q_Page .= ''.__("WordPress Core files",'gotmls').''.__("# of files",'gotmls').'
';
foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["wp_core"] as $ver => $files) {
$Q_Page .= '- '.count($files)."Version $ver
\n";
}
}
$Q_Page .= "
";
}
$my_query = new WP_Query(array("orderby" => 'date', "post_type" => 'GOTMLS_quarantine', "post_status" => array('pending'), "posts_per_page" => 500));
if ($my_query->have_posts()) {
$Q_Page .= '
";
}
wp_reset_query();
return "$Q_Page\n";
}
function GOTMLS_Quarantine_Trash() {
global $wpdb;
$Q_Page = '
\n";
}
function GOTMLS_ajax_View_Quarantine() {
GOTMLS_ajax_load_update();
die(GOTMLS_html_tags(array("html" => array("body" => GOTMLS_get_header().GOTMLS_box(GOTMLS_Quarantine_Trash().__("View Quarantine",'gotmls'), GOTMLS_get_quarantine())))));
}
function GOTMLS_View_Quarantine() {
GOTMLS_ajax_load_update();
$echo = GOTMLS_box($Q_Page = "Whitelists", GOTMLS_get_whitelists());
if (!isset($_GET['Whitelists']))
$echo .= "\n\n";
$echo .= GOTMLS_box(GOTMLS_Quarantine_Trash().__("View Quarantine",'gotmls'), GOTMLS_get_quarantine());
GOTMLS_display_header();
echo "$echo\n