Initial commit

This commit is contained in:
IllusionMan1212
2018-09-30 06:17:31 +02:00
commit 96ce7c0dce
75 changed files with 10420 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
require_once( 'config.php' );
$dir = WM_Config::$fileRoot . str_replace( '..', '', $_GET['dir'] );
if( $dir{strlen($dir)-1} != '/' ) {
$dir .= '/';
}
$find = '*.*';
switch( $_GET['type'] ) {
case 'images':
$find = '*.{png,gif,jpg,jpeg}';
break;
case 'scripts':
$find = '*.js';
break;
}
$dirs = glob( $dir.'*', GLOB_ONLYDIR );
if( $dirs === false ) { $dirs = array(); };
$files = glob( $dir.$find, GLOB_BRACE );
if( $files === false ) { $files = array(); }
$fileRootLength = strlen( WM_Config::$fileRoot );
foreach( $files as $i => $f ) {
$files[$i] = substr( $f, $fileRootLength );
}
foreach( $dirs as $i => $d ) {
$dirs[$i] = substr( $d, $fileRootLength );
}
$parent = substr($_GET['dir'], 0, strrpos($_GET['dir'], '/'));
echo json_encode( array(
'parent' => (empty($_GET['dir']) ? false : $parent),
'dirs' => $dirs,
'files' => $files
));
?>
+22
View File
@@ -0,0 +1,22 @@
<?php
class WM_Config {
public static $fileRoot = '../../../';
}
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map( 'stripslashes_deep', $value ) :
stripslashes($value);
return $value;
}
// revert magic quotes
if( function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ) {
$_GET = array_map( 'stripslashes_deep', $_GET );
$_POST = array_map( 'stripslashes_deep', $_POST );
}
?>
+21
View File
@@ -0,0 +1,21 @@
<?php
require_once( 'config.php' );
$globs = is_array($_GET['glob']) ? $_GET['glob'] : array($_GET['glob']);
$files = array();
foreach( $globs as $glob ) {
$pattern = WM_Config::$fileRoot . str_replace( '..', '', $glob );
$currentFiles = glob( $pattern );
if( $currentFiles !== false ) {
$files = array_merge( $files, $currentFiles );
}
}
$fileRootLength = strlen( WM_Config::$fileRoot );
foreach( $files as $i => $f ) {
$files[$i] = substr( $f, $fileRootLength );
}
echo json_encode( $files );
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
require_once( 'config.php' );
$result = array('error' => 0);
if( !empty($_POST['path']) && !empty($_POST['data']) ) {
$path = WM_Config::$fileRoot . str_replace( '..', '', $_POST['path'] );
if( preg_match('/\.js$/', $path) ) {
$success = @file_put_contents( $path, $_POST['data'] );
if( $success === false ) {
$result = array(
'error' => '2',
'msg' => "Couldn't write to file: $path"
);
}
}
else {
$result = array(
'error' => '3',
'msg' => "File must have a .js suffix"
);
}
}
else {
$result = array(
'error' => '1',
'msg' => "No Data or Path specified"
);
}
echo json_encode($result);
?>