mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-10 10:04:01 +02:00
299
build/libifm.php
299
build/libifm.php
File diff suppressed because one or more lines are too long
40
compiler.php
40
compiler.php
@@ -8,39 +8,40 @@
|
||||
|
||||
chdir( realpath( dirname( __FILE__ ) ) );
|
||||
|
||||
$IFM_SRC_MAIN = "src/main.php";
|
||||
$IFM_SRC_PHPFILES = array( "src/ifmarchive.php", "src/htpasswd.php" );
|
||||
$IFM_SRC_JS = "src/ifm.js";
|
||||
$IFM_SRC_PHP = array(
|
||||
0 => "src/main.php",
|
||||
1 => "src/ifmarchive.php",
|
||||
2 => "src/htpasswd.php"
|
||||
);
|
||||
|
||||
$IFM_BUILD_STANDALONE = "ifm.php";
|
||||
$IFM_BUILD_STANDALONE_COMPRESSED = "ifm.min.php";
|
||||
$IFM_BUILD_STANDALONE_COMPRESSED = "build/ifm.min.php";
|
||||
$IFM_BUILD_LIB_PHP = "build/libifm.php";
|
||||
|
||||
/**
|
||||
* Prepare main script
|
||||
* Concat PHP Files
|
||||
*/
|
||||
$main = file_get_contents( $IFM_SRC_MAIN );
|
||||
$includes = NULL;
|
||||
preg_match_all( "/\@\@\@([^\@]+)\@\@\@/", $main, $includes, PREG_SET_ORDER );
|
||||
foreach( $includes as $file ) {
|
||||
$main = str_replace( $file[0], file_get_contents( $file[1] ), $main );
|
||||
$compiled = array( "<?php" );
|
||||
foreach( $IFM_SRC_PHP as $phpfile ) {
|
||||
$lines = file( $phpfile );
|
||||
unset( $lines[0] ); // remove <?php line
|
||||
$compiled = array_merge( $compiled, $lines );
|
||||
}
|
||||
$compiled = join( $compiled );
|
||||
|
||||
/**
|
||||
* Add PHP files
|
||||
* Process includes
|
||||
*/
|
||||
$phpincludes = array();
|
||||
foreach( $IFM_SRC_PHPFILES as $file ) {
|
||||
$content = file( $file );
|
||||
unset( $content[0] ); // remove <?php line
|
||||
$phpincludes = array_merge( $phpincludes, $content );
|
||||
$includes = NULL;
|
||||
preg_match_all( "/\@\@\@file:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
|
||||
foreach( $includes as $file ) {
|
||||
$compiled = str_replace( $file[0], file_get_contents( $file[1] ), $compiled );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build standalone script
|
||||
*/
|
||||
file_put_contents( $IFM_BUILD_STANDALONE, $main );
|
||||
file_put_contents( $IFM_BUILD_STANDALONE, $phpincludes, FILE_APPEND );
|
||||
file_put_contents( $IFM_BUILD_STANDALONE, $compiled );
|
||||
file_put_contents( $IFM_BUILD_STANDALONE, '
|
||||
/**
|
||||
* start IFM
|
||||
@@ -57,5 +58,4 @@ $ifm->run();
|
||||
/**
|
||||
* Build library
|
||||
*/
|
||||
file_put_contents( $IFM_BUILD_LIB_PHP, $main );
|
||||
file_put_contents( $IFM_BUILD_LIB_PHP, $phpincludes, FILE_APPEND );
|
||||
file_put_contents( $IFM_BUILD_LIB_PHP, $compiled );
|
||||
|
75
src/ifm.js
75
src/ifm.js
@@ -14,6 +14,7 @@ function IFM( params ) {
|
||||
this.fileChanged = false; // flag for check if file was changed already
|
||||
this.currentDir = ""; // this is the global variable for the current directory; it is used for AJAX requests
|
||||
this.rootElement = "";
|
||||
this.search = {};
|
||||
|
||||
/**
|
||||
* Shows a bootstrap modal
|
||||
@@ -80,6 +81,13 @@ function IFM( params ) {
|
||||
* @param object data - object with items
|
||||
*/
|
||||
this.rebuildFileTable = function( data ) {
|
||||
if( data.status == "ERROR" ) {
|
||||
this.showMessage( data.message, "e" );
|
||||
return;
|
||||
} else if ( ! Array.isArray( data ) ) {
|
||||
this.showMessage( "Invalid data from server", "e" );
|
||||
return;
|
||||
}
|
||||
data.forEach( function( item ) {
|
||||
item.guid = self.generateGuid();
|
||||
item.linkname = ( item.name == ".." ) ? "[ up ]" : item.name;
|
||||
@@ -201,7 +209,24 @@ function IFM( params ) {
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
if( self.config.contextmenu ) {
|
||||
var contextMenu = new BootstrapMenu( '.clickable-row', {
|
||||
fetchElementData: function( $rowElem ) {
|
||||
var data = $rowElem.data();
|
||||
data.isDir = $rowElem.hasClass( 'isDir' );
|
||||
data.element = $rowElem[0];
|
||||
return data;
|
||||
},
|
||||
actions: [{
|
||||
name: 'download',
|
||||
onClick: function( item ) {
|
||||
console.log( item );
|
||||
$( '#d_' + item.element.children[0].children[0].id ).submit();
|
||||
},
|
||||
iconClass: "icon icon-cloud"
|
||||
}]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -850,6 +875,50 @@ function IFM( params ) {
|
||||
});
|
||||
};
|
||||
|
||||
this.showSearchDialog = function() {
|
||||
self.showModal( Mustache.render( self.templates.search, { lastSearch: self.search.lastSearch } ) );
|
||||
$( '#searchResults tbody' ).remove();
|
||||
$( '#searchResults' ).append( Mustache.render( self.templates.searchresults, { items: self.search.data } ) );
|
||||
$( '#searchPattern' ).on( 'keypress', function( e ) {
|
||||
if( e.keyCode == 13 ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
self.search.lastSearch = e.target.value;
|
||||
$.ajax({
|
||||
url: self.api,
|
||||
type: "POST",
|
||||
data: {
|
||||
api: "searchItems",
|
||||
dir: self.currentDir,
|
||||
pattern: e.target.value
|
||||
},
|
||||
dataType: "json",
|
||||
success: function( data ) {
|
||||
data.forEach( function(e) {
|
||||
e.folder = e.name.substr( 0, e.name.lastIndexOf( '/' ) );
|
||||
e.linkname = e.name.substr( e.name.lastIndexOf( '/' ) + 1 );
|
||||
});
|
||||
self.search.data = data;
|
||||
$('#searchResults').html( Mustache.render( self.templates.searchresults, { items: data } ) );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$( document ).on( 'click', 'a.searchitem', function( e ) {
|
||||
console.log( e );
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
self.changeDirectory( e.target.dataset.folder || e.target.parentNode.dataset.folder, { absolute: true } );
|
||||
self.hideModal();
|
||||
});
|
||||
$( document ).on( 'keypress', 'a.searchitem', function( e ) {
|
||||
console.log( e );
|
||||
e.preventDefault();
|
||||
if( e.key == "Enter" )
|
||||
e.target.click();
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// helper functions
|
||||
// --------------------
|
||||
@@ -1099,6 +1168,10 @@ function IFM( params ) {
|
||||
return;
|
||||
|
||||
switch( e.key ) {
|
||||
case '/':
|
||||
e.preventDefault();
|
||||
self.showSearchDialog();
|
||||
break;
|
||||
case 'g':
|
||||
e.preventDefault();
|
||||
$('#currentDir').focus();
|
||||
|
16
src/includes/BootstrapMenu.min.js
vendored
Normal file
16
src/includes/BootstrapMenu.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
241
src/main.php
241
src/main.php
@@ -50,6 +50,7 @@ class IFM {
|
||||
"showhtdocs" => 0,
|
||||
"showhiddenfiles" => 1,
|
||||
"showpath" => 0,
|
||||
"contextmenu" => 1
|
||||
);
|
||||
|
||||
private $config = array();
|
||||
@@ -98,49 +99,55 @@ class IFM {
|
||||
|
||||
$templates = array();
|
||||
$templates['app'] = <<<'f00bar'
|
||||
@@@src/templates/app.html@@@
|
||||
@@@file:src/templates/app.html@@@
|
||||
f00bar;
|
||||
$templates['login'] = <<<'f00bar'
|
||||
@@@src/templates/login.html@@@
|
||||
@@@file:src/templates/login.html@@@
|
||||
f00bar;
|
||||
$templates['filetable'] = <<<'f00bar'
|
||||
@@@src/templates/filetable.html@@@
|
||||
@@@file:src/templates/filetable.html@@@
|
||||
f00bar;
|
||||
$templates['footer'] = <<<'f00bar'
|
||||
@@@src/templates/footer.html@@@
|
||||
@@@file:src/templates/footer.html@@@
|
||||
f00bar;
|
||||
$templates['task'] = <<<'f00bar'
|
||||
@@@src/templates/task.html@@@
|
||||
@@@file:src/templates/task.html@@@
|
||||
f00bar;
|
||||
$templates['ajaxrequest'] = <<<'f00bar'
|
||||
@@@src/templates/modal.ajaxrequest.html@@@
|
||||
@@@file:src/templates/modal.ajaxrequest.html@@@
|
||||
f00bar;
|
||||
$templates['copymove'] = <<<'f00bar'
|
||||
@@@src/templates/modal.copymove.html@@@
|
||||
@@@file:src/templates/modal.copymove.html@@@
|
||||
f00bar;
|
||||
$templates['createdir'] = <<<'f00bar'
|
||||
@@@src/templates/modal.createdir.html@@@
|
||||
@@@file:src/templates/modal.createdir.html@@@
|
||||
f00bar;
|
||||
$templates['deletefile'] = <<<'f00bar'
|
||||
@@@src/templates/modal.deletefile.html@@@
|
||||
@@@file:src/templates/modal.deletefile.html@@@
|
||||
f00bar;
|
||||
$templates['extractfile'] = <<<'f00bar'
|
||||
@@@src/templates/modal.extractfile.html@@@
|
||||
@@@file:src/templates/modal.extractfile.html@@@
|
||||
f00bar;
|
||||
$templates['file'] = <<<'f00bar'
|
||||
@@@src/templates/modal.file.html@@@
|
||||
@@@file:src/templates/modal.file.html@@@
|
||||
f00bar;
|
||||
$templates['multidelete'] = <<<'f00bar'
|
||||
@@@src/templates/modal.multidelete.html@@@
|
||||
@@@file:src/templates/modal.multidelete.html@@@
|
||||
f00bar;
|
||||
$templates['remoteupload'] = <<<'f00bar'
|
||||
@@@src/templates/modal.remoteupload.html@@@
|
||||
@@@file:src/templates/modal.remoteupload.html@@@
|
||||
f00bar;
|
||||
$templates['renamefile'] = <<<'f00bar'
|
||||
@@@src/templates/modal.renamefile.html@@@
|
||||
@@@file:src/templates/modal.renamefile.html@@@
|
||||
f00bar;
|
||||
$templates['search'] = <<<'f00bar'
|
||||
@@@file:src/templates/modal.search.html@@@
|
||||
f00bar;
|
||||
$templates['searchresults'] = <<<'f00bar'
|
||||
@@@file:src/templates/modal.searchresults.html@@@
|
||||
f00bar;
|
||||
$templates['uploadfile'] = <<<'f00bar'
|
||||
@@@src/templates/modal.uploadfile.html@@@
|
||||
@@@file:src/templates/modal.uploadfile.html@@@
|
||||
f00bar;
|
||||
$this->templates = $templates;
|
||||
|
||||
@@ -175,23 +182,24 @@ f00bar;
|
||||
|
||||
public function getCSS() {
|
||||
print '
|
||||
<style type="text/css">';?> @@@src/includes/bootstrap.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@src/includes/bootstrap-treeview.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@src/includes/fontello-embedded.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@src/includes/animation.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@src/style.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/bootstrap.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/bootstrap-treeview.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/fontello-embedded.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/animation.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/style.css@@@ <?php print '</style>
|
||||
';
|
||||
}
|
||||
|
||||
public function getJS() {
|
||||
print '
|
||||
<script>';?> @@@src/includes/ace.js@@@ <?php print '</script>
|
||||
<script>';?> @@@src/includes/jquery.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@src/includes/bootstrap.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@src/includes/bootstrap-notify.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@src/includes/bootstrap-treeview.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@src/includes/mustache.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@src/ifm.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/ace.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/jquery.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/bootstrap.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/bootstrap-notify.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/bootstrap-treeview.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/BootstrapMenu.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/includes/mustache.min.js@@@ <?php print '</script>
|
||||
<script>';?> @@@file:src/ifm.js@@@ <?php print '</script>
|
||||
';
|
||||
}
|
||||
|
||||
@@ -258,6 +266,7 @@ f00bar;
|
||||
case "zipnload": $this->zipnload( $_REQUEST); break;
|
||||
case "remoteUpload": $this->remoteUpload( $_REQUEST ); break;
|
||||
case "multidelete": $this->deleteMultipleFiles( $_REQUEST ); break;
|
||||
case "searchItems": $this->searchItems( $_REQUEST ); break;
|
||||
case "getFolderTree": $this->getFolderTree( $_REQUEST ); break;
|
||||
default:
|
||||
echo json_encode( array( "status" => "ERROR", "message" => "Invalid api action given" ) );
|
||||
@@ -293,7 +302,6 @@ f00bar;
|
||||
*/
|
||||
|
||||
private function getFiles( $dir ) {
|
||||
$dir = $this->getValidDir( $dir );
|
||||
$this->chDirIfNecessary( $dir );
|
||||
|
||||
unset( $files ); unset( $dirs ); $files = array(); $dirs = array();
|
||||
@@ -305,52 +313,8 @@ f00bar;
|
||||
elseif( $result == "." ) {}
|
||||
elseif( $result != ".." && substr( $result, 0, 1 ) == "." && $this->config['showhiddenfiles'] != 1 ) {}
|
||||
else {
|
||||
$item = array();
|
||||
$item["name"] = $result;
|
||||
if( is_dir( $result ) ) {
|
||||
$item["type"] = "dir";
|
||||
if( $result == ".." )
|
||||
$item["icon"] = "icon icon-up-open";
|
||||
else
|
||||
$item["icon"] = "icon icon-folder-empty";
|
||||
} else {
|
||||
$item["type"] = "file";
|
||||
if( in_array( substr( $result, -7 ), array( ".tar.gz", ".tar.xz" ) ) )
|
||||
$type = substr( $result, -6 );
|
||||
elseif( substr( $result, -8 ) == ".tar.bz2" )
|
||||
$type = "tar.bz2";
|
||||
else
|
||||
$type = substr( strrchr( $result, "." ), 1 );
|
||||
$item["icon"] = $this->getTypeIcon( $type );
|
||||
$item["ext"] = strtolower($type);
|
||||
}
|
||||
if( $this->config['showlastmodified'] == 1 ) { $item["lastmodified"] = date( "d.m.Y, G:i e", filemtime( $result ) ); }
|
||||
if( $this->config['showfilesize'] == 1 ) {
|
||||
$item["size"] = filesize( $result );
|
||||
if( $item["size"] > 1073741824 ) $item["size"] = round( ( $item["size"]/1073741824 ), 2 ) . " GB";
|
||||
elseif($item["size"]>1048576)$item["size"] = round( ( $item["size"]/1048576 ), 2 ) . " MB";
|
||||
elseif($item["size"]>1024)$item["size"] = round( ( $item["size"]/1024 ), 2 ) . " KB";
|
||||
else $item["size"] = $item["size"] . " Byte";
|
||||
}
|
||||
if( $this->config['showpermissions'] > 0 ) {
|
||||
if( $this->config['showpermissions'] == 1 ) $item["fileperms"] = substr( decoct( fileperms( $result ) ), -3 );
|
||||
elseif( $this->config['showpermissions'] == 2 ) $item["fileperms"] = $this->filePermsDecode( fileperms( $result ) );
|
||||
if( $item["fileperms"] == "" ) $item["fileperms"] = " ";
|
||||
$item["filepermmode"] = ( $this->config['showpermissions'] == 1 ) ? "short" : "long";
|
||||
}
|
||||
if( $this->config['showowner'] == 1 ) {
|
||||
if ( function_exists( "posix_getpwuid" ) && fileowner($result) !== false ) {
|
||||
$ownerarr = posix_getpwuid( fileowner( $result ) );
|
||||
$item["owner"] = $ownerarr['name'];
|
||||
} else $item["owner"] = false;
|
||||
}
|
||||
if( $this->config['showgroup'] == 1 ) {
|
||||
if( function_exists( "posix_getgrgid" ) && filegroup( $result ) !== false ) {
|
||||
$grouparr = posix_getgrgid( filegroup( $result ) );
|
||||
$item["group"] = $grouparr['name'];
|
||||
} else $item["group"] = false;
|
||||
}
|
||||
if( is_dir( $result ) ) $dirs[] = $item;
|
||||
$item = $this->getItemInformation( $result );
|
||||
if( $item['type'] == "dir" ) $dirs[] = $item;
|
||||
else $files[] = $item;
|
||||
}
|
||||
}
|
||||
@@ -358,7 +322,57 @@ f00bar;
|
||||
}
|
||||
usort( $dirs, array( $this, "sortByName" ) );
|
||||
usort( $files, array( $this, "sortByName" ) );
|
||||
echo json_encode( array_merge( $dirs, $files ) );
|
||||
|
||||
$this->jsonResponse( array_merge( $dirs, $files ) );
|
||||
}
|
||||
|
||||
private function getItemInformation( $name ) {
|
||||
$item = array();
|
||||
$item["name"] = $name;
|
||||
if( is_dir( $name ) ) {
|
||||
$item["type"] = "dir";
|
||||
if( $name == ".." )
|
||||
$item["icon"] = "icon icon-up-open";
|
||||
else
|
||||
$item["icon"] = "icon icon-folder-empty";
|
||||
} else {
|
||||
$item["type"] = "file";
|
||||
if( in_array( substr( $name, -7 ), array( ".tar.gz", ".tar.xz" ) ) )
|
||||
$type = substr( $name, -6 );
|
||||
elseif( substr( $name, -8 ) == ".tar.bz2" )
|
||||
$type = "tar.bz2";
|
||||
else
|
||||
$type = substr( strrchr( $name, "." ), 1 );
|
||||
$item["icon"] = $this->getTypeIcon( $type );
|
||||
$item["ext"] = strtolower($type);
|
||||
}
|
||||
if( $this->config['showlastmodified'] == 1 ) { $item["lastmodified"] = date( "d.m.Y, G:i e", filemtime( $name ) ); }
|
||||
if( $this->config['showfilesize'] == 1 ) {
|
||||
$item["size"] = filesize( $name );
|
||||
if( $item["size"] > 1073741824 ) $item["size"] = round( ( $item["size"]/1073741824 ), 2 ) . " GB";
|
||||
elseif($item["size"]>1048576)$item["size"] = round( ( $item["size"]/1048576 ), 2 ) . " MB";
|
||||
elseif($item["size"]>1024)$item["size"] = round( ( $item["size"]/1024 ), 2 ) . " KB";
|
||||
else $item["size"] = $item["size"] . " Byte";
|
||||
}
|
||||
if( $this->config['showpermissions'] > 0 ) {
|
||||
if( $this->config['showpermissions'] == 1 ) $item["fileperms"] = substr( decoct( fileperms( $name ) ), -3 );
|
||||
elseif( $this->config['showpermissions'] == 2 ) $item["fileperms"] = $this->filePermsDecode( fileperms( $name ) );
|
||||
if( $item["fileperms"] == "" ) $item["fileperms"] = " ";
|
||||
$item["filepermmode"] = ( $this->config['showpermissions'] == 1 ) ? "short" : "long";
|
||||
}
|
||||
if( $this->config['showowner'] == 1 ) {
|
||||
if ( function_exists( "posix_getpwuid" ) && fileowner($name) !== false ) {
|
||||
$ownerarr = posix_getpwuid( fileowner( $name ) );
|
||||
$item["owner"] = $ownerarr['name'];
|
||||
} else $item["owner"] = false;
|
||||
}
|
||||
if( $this->config['showgroup'] == 1 ) {
|
||||
if( function_exists( "posix_getgrgid" ) && filegroup( $name ) !== false ) {
|
||||
$grouparr = posix_getgrgid( filegroup( $name ) );
|
||||
$item["group"] = $grouparr['name'];
|
||||
} else $item["group"] = false;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function getConfig() {
|
||||
@@ -397,6 +411,32 @@ f00bar;
|
||||
}
|
||||
}
|
||||
|
||||
private function searchItems( $d ) {
|
||||
$this->chDirIfNecessary( $d['dir'] );
|
||||
if( strpos( $d['pattern'], '/' ) !== false ) {
|
||||
echo json_decode( array( "status" => "ERROR", "message" => "Pattern must not contain slashes" ) );
|
||||
exit( 1 );
|
||||
}
|
||||
try {
|
||||
$results = $this->searchItemsRecursive( $d['pattern'] );
|
||||
echo json_encode( $results );
|
||||
} catch( Exception $e ) {
|
||||
echo json_encode( array( "status" => "ERROR", "message" => $e->getMessage() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private function searchItemsRecursive( $pattern, $dir="" ) {
|
||||
$items = array();
|
||||
$dir = $dir ? $dir : '.';
|
||||
foreach( glob( $this->pathCombine( $dir, $pattern ) ) as $result ) {
|
||||
array_push( $items, $this->getItemInformation( $result ) );
|
||||
}
|
||||
foreach( glob( $this->pathCombine( $dir, '*') , GLOB_ONLYDIR ) as $subdir ) {
|
||||
$items = array_merge( $items, $this->searchItemsRecursive( $pattern, $subdir ) );
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getFolderTree( $d ) {
|
||||
echo json_encode(
|
||||
array_merge(
|
||||
@@ -812,12 +852,59 @@ f00bar;
|
||||
echo json_encode( array( "status" => "error", "message" => "Corrupt parameter data" ) );
|
||||
}
|
||||
|
||||
//apis
|
||||
|
||||
/*
|
||||
help functions
|
||||
*/
|
||||
|
||||
private function log( $d ) {
|
||||
file_put_contents( $this->pathCombine( $this->getRootDir(), "debug.ifm.log" ), ( is_array( $d ) ? print_r( $d, true ) : $d ), FILE_APPEND );
|
||||
}
|
||||
|
||||
private function jsonResponse( $array ) {
|
||||
$this->convertToUTF8( $array );
|
||||
$json = json_encode( $array );
|
||||
if( $json === false ) {
|
||||
switch(json_last_error()) {
|
||||
case JSON_ERROR_NONE:
|
||||
echo ' - No errors';
|
||||
break;
|
||||
case JSON_ERROR_DEPTH:
|
||||
echo ' - Maximum stack depth exceeded';
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
echo ' - Underflow or the modes mismatch';
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
echo ' - Unexpected control character found';
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
echo ' - Syntax error, malformed JSON';
|
||||
break;
|
||||
case JSON_ERROR_UTF8:
|
||||
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
|
||||
break;
|
||||
default:
|
||||
echo ' - Unknown error';
|
||||
break;
|
||||
}
|
||||
|
||||
$this->jsonResponse( array( "status" => "ERROR", "message" => "Could not encode json: " . $err ) );
|
||||
} else {
|
||||
echo $json;
|
||||
}
|
||||
}
|
||||
|
||||
private function convertToUTF8( &$item ) {
|
||||
if( is_array( $item ) )
|
||||
array_walk(
|
||||
$item,
|
||||
array( $this, 'convertToUTF8' )
|
||||
);
|
||||
else
|
||||
if( function_exists( "mb_check_encoding" ) && ! mb_check_encoding( $item, "UTF-8" ) )
|
||||
$item = utf8_encode( $item );
|
||||
}
|
||||
|
||||
public function checkAuth() {
|
||||
if( $this->config['auth'] == 1 && ( ! isset( $_SESSION['auth'] ) || $_SESSION['auth'] !== true ) ) {
|
||||
$login_failed = false;
|
||||
|
10
src/templates/modal.search.html
Normal file
10
src/templates/modal.search.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<form id="searchForm">
|
||||
<div class="modal-body">
|
||||
<fieldset>
|
||||
<label>Pattern:</label>
|
||||
<input type="text" class="form-control" id="searchPattern" name="pattern" value="{{lastSearch}}"><br>
|
||||
<table id="searchResults" class="table">
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</form>
|
11
src/templates/modal.searchresults.html
Normal file
11
src/templates/modal.searchresults.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<tbody>
|
||||
{{#items}}
|
||||
<tr class="{{rowclasses}}" data-filename="{{name}}">
|
||||
<td>
|
||||
<a tabindex="0" id="{{guid}}" class="searchitem" {{{tooltip}}} data-type="{{type}}" data-folder="{{folder}}">
|
||||
<span class="{{icon}}"></span> {{linkname}} <span style="color:#999">({{folder}})</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/items}}
|
||||
</tbody>
|
Reference in New Issue
Block a user