cyrilleinvalides/choupas/www/admin/editor.php

99 lines
2.3 KiB
PHP
Executable File

<?php
$func = include('includes/auth.php');
$func(function () {
$state = function ($str = 'null') {
static $start, $last;
if ( !$start ) {
$start = $last = $now = microtime(1);
$delta = '0';
} else {
$now = microtime(1);
$delta = $now - $last;
$last = $now;
}
echo "################### " . $str . " ###################\n" .
"##\n" .
"#\tpeak : " . (round(memory_get_peak_usage() / 1024) . "Ko") . "\n" .
"#\tcurrent : " . (round(memory_get_usage() / 1024) . "Ko") . "\n" .
"#\ttotal time : " . ( $now - $start ) . "\n" .
"#\ttime : " . $delta . "\n" .
"##\n".
"################### " . $str . " ###################\n";
return 1;
};
if ( empty($_GET['action']) )
echo EngineSystem::get('back')->load('pages/editor.html')->run()->getData('');
else switch ($_GET['action']) {
case 'read':
echo file_get_contents($_POST['file']);
break;
case 'save':
file_put_contents($_POST['file'], $_POST['content']);
break;
case 'mkdir':
mkdir($_POST['dir']);
break;
case 'list':
$x = new DSDirectory('.', !empty($_POST['target']) ? $_POST['target'] : null);
$res = $x->lister(true, 5);
echo EngineSystem::get('back')->load('pages/editor.list.html')->run(array('list' => $res))->getData('');
break;
case 'phpConsole':
eval($_POST['code']);
echo "\n\n";
break;
case 'sqlConsole':
$state('start');
/*
try {
$link = new Mysqli('localhost', 'root', 'd4rd4r_');
if ( $link->connect_errno )
throw new Exception($link->connect_error);
if ( !$link->multi_query($_POST['query']) )
throw new Exception($link->error);
$state('query');
$i = 0;
do {
$i++;
echo "Requete $i :\n";
$result = $link->use_result();
$r = array();
if ( $result instanceof Mysqli_Result) {
while ( $row = $result->fetch_assoc() )
$r[] = $row;
print_r($r);
$result->free();
} else echo "Requete OK, mais pas de données !";
echo "\n\n";
} while ( $link->more_results() && $link->next_result() );
} catch ( Exception $e ) {
echo("MySQL Error : " . $e->getMessage());
}
*/
print_r(Provider::get('invalides')->query($_POST['query']));
$state('end');
break;
}
});