public function execute_new_agent() { # $pss->wisard_new_agent() $pss = new PSS(); $data = array(); if (isset($_GET['patch']) && strlen($_GET['patch'])) { $filename = $_GET['patch']; $backupfile = urlencode($filename); if (filesize($filename) > 200000) { $data['errors'][] = "Patching stopped! File is too large, impossible to patch"; } else { if (!is_writable($filename)) { $data['errors'][] = "Patching stopped! Check permission for file writing, impossible to patch"; } else { if (!$pss->chk_php_file($filename)) { $data['errors'][] = "Patching stopped! Is not php file, impossible to patch"; } else { if (file_exists($backupfile)) { $data['errors'][] = "Patching stopped! Backup file " . $backupfile . " already exists, cannot continue backup"; } else { if (!$pss->backupfile($filename)) { $data['errors'][] = "Patching stopped! Cannot backup filem ,check permissions of backup/ directory, impossible to patch"; } else { if ($pss->chk_agent_code($filename)) { $data['errors'][] = "Patching stopped! Cannot patch,code already injected"; } else { if ($pss->patch_target($filename)) { #header('Location:?q=agents_list&new_agent='.urlencode($filename)); $data['msgs'][] = "Patched " . $filename . ". Check in `<a href=\"?q=agents_list\">Objects list</a>` statistics."; } else { $data['errors'][] = "Patching stopped! Cannot patch,check permissions"; } } } } } } } } elseif (isset($_GET['unpatch']) && strlen($_GET['unpatch'])) { $filename = $_GET['unpatch']; $backupfile = "backups/" . urlencode($filename); if (!$pss->chk_agent_code($filename)) { $data['errors'][] = "Unpatching stopped! Agent code not exists in the file:<b>" . $filename . "</b>, impossible unpatch"; } if (!file_exists($backupfile)) { $data['errors'][] = "Unpatching stopped! Backup file " . $backupfile . " doesnt exists, impossible return original file"; } if ($pss->restore_original($filename)) { unlink($backupfile); $data['msgs'][] = "UnPatched"; } else { $data['errors'][] = "Unpatching stopped! Cannot unpatch,check permissions"; } } $data['pss'] = $pss; return $data; }