jQuery Plugin : "The BASH"

Hello dear readers. All of you love unix bash, do you? Good news: now you can integrate unix bash in your website. BASH looks like a bash, feels like a bash, and will be hated by all designers (the ones not involved with boring stuff like program code (uahh).

 

I also have added the BASH to my projects, nut much to read there, yet.

 

I want talk too much now, but just let the allmighty BASH speak for itself:

(try ls "files/img" -p or man ls or fread "index.php")

 

 

A really beautiful toy for all you geeks out there.

 

Want to have it? Take it home, install it on a webserver and feel like a hacker?

Since it's mainly JS you will find a hacky way to download it without any link.

 

Please note : The plugin needs jquery.fieldselection.js

 

Note further : all the really good stuff (namely sql, ls and fread by now) needs PHP or similar. Adjust the config setting bashPHP to your PHP (or similar) file, look at what comes in with $_GET from the BASH and react with some json_encode($myVar) stuff.

 

PS: here's some PHP sample code:

 

<?php
global $_USER;
switch ($_GET['cmd']) {
    case 'ls':
    
        if ($_USER->may('superuser') ||
                $_GET['dir'] == 'files/img/' ||
                $_GET['dir'] == 'files/img') {
            if (isset($_GET['offset'])) {
                $res = array_slice(scandir($_GET['dir']),$_GET['offset'],10);
            } else {
                $res = scandir($_GET['dir']);
            }
        } else {
            $res = array("scanning directories is not allowed in demo.");
        }
        
    break;
    case 'fread':
        
        if ($_USER->may('superuser')) {
            $res = file($_GET['file']);
        } else {
            $res = array("reading files is not allowed in demo.");
        }
            
    break;
    case 'sql':
        
        if ($_USER->may('superuser')) {
            $db = MySQL::getInstance();
            switch ($_GET['mode']) {
                case "get":
                    $res = $db->getEntry($_GET['sql']);
                break;
                default:
                    $res = $db->getEntry($_GET['sql']);
                break;    
            }
            //if (!empty($db->error())) $res = $db->error();
            
            
        } else {
            $res = array("sql queries is not allowed in demo.");
        }
            
    break;
    default :
        $res = "strange commands, hum?";
    break;
}
echo json_encode($res);
?>

Tags


2010-02-19 19:59:48 by palbertini

Kommentare

* Why use my real name?


* Pflichtfelder