Merge branch 'development' into 'permissions'

# Conflicts:
#   components/filemanager/class.filemanager.php
#   components/filemanager/controller.php
This commit is contained in:
xevidos 2019-07-17 15:55:45 +00:00
commit 954d6a43d0
6 changed files with 878 additions and 848 deletions

View file

@ -38,6 +38,8 @@ Current Tasks:
Task List:
* Add ability to login with LDAP
* Add archive management
* Add bookmark files
* Add custom market
* \- Add in new admin interface ( Check admin-portal branch for progress )
- Group Management
@ -46,13 +48,17 @@ Task List:
- Project Management
- System Settings
- User Management
* Add different code linters
* Add Drag and Drop natively to filemanager
* Add folder / filestructure upload ability
* Add if file could not be saved 5 times close the open file
* Add multi level users. ( Projects for only certain groups, Permission levels )
* Add mobile compatibility
* Add move files
* Add permissions module ( more in depth permissions such as read/write, delete, etc )
* Add print code
* Add support for more database systems ( MSSQL, Oracle, SQLite, Filesystem storage, etc )
* Add terminal support ( optional per permission level )
* Add in auto save timer that saves after the user stops typing instead of after every change
* Clean up update script
* Fix broken themes

View file

@ -1014,14 +1014,17 @@
uploadPositions: function() {
$.ajax( {
type: 'POST',
url: codiad.active.controller + '?action=save_positions',
data: {
positions: ( JSON.stringify( codiad.active.positions ) )
},
success: function( data ) {},
});
if( Object.keys( codiad.active.positions ).length > 0 ) {
$.ajax( {
type: 'POST',
url: codiad.active.controller + '?action=save_positions',
data: {
positions: ( JSON.stringify( codiad.active.positions ) )
},
success: function( data ) {},
});
}
},
savePosition: function() {

File diff suppressed because it is too large Load diff

View file

@ -1,99 +1,230 @@
<?php
/*
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
* as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact.
*/
/*
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
* as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact.
*/
require_once('../../common.php');
require_once('class.filemanager.php');
require_once( '../../common.php' );
require_once( 'class.filemanager.php' );
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
checkSession();
//////////////////////////////////////////////////////////////////
// Get Action
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Get Action
//////////////////////////////////////////////////////////////////
$response = array(
"status" => "none",
);
if (!empty($_GET['action'])) {
$action = $_GET['action'];
} else {
exit('{"status":"error","data":{"error":"No Action Specified"}}');
}
//////////////////////////////////////////////////////////////////
// Ensure Project Has Been Loaded
//////////////////////////////////////////////////////////////////
if (!isset($_SESSION['project'])) {
$_GET['action']='get_current';
$_GET['no_return']='true';
require_once('../project/controller.php');
}
//////////////////////////////////////////////////////////////////
// Security Check
//////////////////////////////////////////////////////////////////
$access = Permissions::get_access( $_GET['path'] );
if ( ! Permissions::check_access( "read", $access ) ) {
die( '{"status":"error","message":"Invalid access to ' . $_GET['path'] . '."}' );
$action = $_GET['action'];
} else {
$response["status"] = "error";
$response["data"] = array(
"error" => "No action specified"
);
exit( json_encode( $response ) );
}
//////////////////////////////////////////////////////////////////
// Define Root
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Ensure Project Has Been Loaded
//////////////////////////////////////////////////////////////////
$_GET['root'] = WORKSPACE;
//////////////////////////////////////////////////////////////////
// Handle Action
//////////////////////////////////////////////////////////////////
$Filemanager = new Filemanager($_GET, $_POST, $_FILES);
$Filemanager->project = @$_SESSION['project']['path'];
$Filemanager->access = $access;
switch ($action) {
case 'index':
$Filemanager->index();
break;
case 'search':
$Filemanager->search();
break;
case 'find':
$Filemanager->find();
break;
case 'open':
$Filemanager->open();
break;
case 'open_in_browser':
$Filemanager->openinbrowser();
break;
case 'create':
$Filemanager->create();
break;
case 'delete':
$Filemanager->delete();
break;
case 'deleteInner':
$Filemanager->delete( true );
break;
case 'modify':
$Filemanager->modify();
break;
case 'duplicate':
$Filemanager->duplicate();
break;
case 'upload':
$Filemanager->upload();
break;
default:
exit('{"status":"fail","data":{"error":"Unknown Action"}}');
if ( ! isset( $_SESSION['project'] ) ) {
$_GET['action'] = 'get_current';
$_GET['no_return'] = 'true';
require_once('../project/controller.php');
}
if( isset( $_GET["path"] ) ) {
$path = $_GET["path"];
} else {
$response["status"] = "error";
$response["message"] = "Missing path.";
exit( json_encode( $response ) );
}
//////////////////////////////////////////////////////////////////
// Security Check
//////////////////////////////////////////////////////////////////
if ( ! checkPath( $path ) ) {
$response["status"] = "error";
$response["message"] = "Invalid Path";
exit( json_encode( $response ) );
}
if( isset( $_GET["destination"] ) ) {
$destination = $_GET["destination"];
if ( ! checkPath( $destination ) ) {
$response["status"] = "error";
$response["message"] = "Invalid destination";
exit( json_encode( $response ) );
}
}
//////////////////////////////////////////////////////////////////
// Handle Action
//////////////////////////////////////////////////////////////////
$Filemanager = new Filemanager();
switch( $action ) {
case 'create':
if( isset( $_GET["type"] ) ) {
$type = $_GET["type"];
$response = $Filemanager->create( $path, $type );
} else {
$response["status"] = "error";
$response["message"] = "No filetype set";
}
break;
case 'delete':
$response = $Filemanager->delete( $path, true );
break;
case 'deleteInner':
$response = $Filemanager->delete( $path, true, true );
break;
case 'duplicate':
$response = $Filemanager->duplicate( $path, $destination );
break;
case 'find':
if( ! isset( $_GET["query"] ) ) {
$response["status"] = "error";
$response["message"] = "Missing search query.";
} else {
$query = $_GET["query"];
if( isset( $_GET["options"] ) ) {
$options = $_GET["options"];
}
$response = $Filemanager->find( $path, $query, @$options );
}
break;
case 'index':
$response = $Filemanager->index( $path );
break;
case 'modify':
if( isset( $_POST["content"] ) || isset( $_POST["patch"] ) ) {
$content = isset( $_POST["content"] ) ? $_POST["content"] : "";
$patch = isset( $_POST["patch"] ) ? $_POST["patch"] : false;
$mtime = isset( $_POST["mtime"] ) ? $_POST["mtime"] : 0;
if( get_magic_quotes_gpc() ){
$content = stripslashes( $content );
$patch = stripslashes( $patch );
$mtime = stripslashes( $mtime );
}
$response = $Filemanager->modify( $path, $content, $mtime );
} else {
$response["status"] = "error";
$response["message"] = "Missing modification content";
}
break;
case 'move':
if( isset( $destination ) ) {
$response = $Filemanager->move( $path, $destination );
} else {
$response["status"] = "error";
$response["message"] = "Missing destination";
}
break;
case 'open':
$response = $Filemanager->open( $path );
break;
case 'open_in_browser':
$response = $Filemanager->openinbrowser( $path );
break;
case 'rename':
if( isset( $destination ) ) {
$response = $Filemanager->move( $path, $destination );
} else {
$response["status"] = "error";
$response["message"] = "Missing destination";
}
break;
case 'search':
if( isset( $_GET["query"] ) ) {
$query = $_GET["query"];
if( isset( $_GET["options"] ) ) {
$options = $_GET["options"];
}
$response = $Filemanager->search( $path, $query );
} else {
$response["status"] = "error";
$response["message"] = "Missing search query.";
}
break;
case 'upload':
$response = $Filemanager->upload( $path );
break;
default:
$response["status"] = "error";
$response["data"] = array(
"error" => "Unknown action"
);
break;
}
exit( json_encode( $response ) );

View file

@ -14,147 +14,157 @@ require_once('class.filemanager.php');
checkSession();
?>
<form>
<?php
?><form><?php
switch($_GET['action']){
switch( $_GET['action'] ) {
//////////////////////////////////////////////////////////////////
// Create
//////////////////////////////////////////////////////////////////
case 'create':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<input type="hidden" name="type" value="<?php echo($_GET['type']); ?>">
<label><span class="icon-pencil"></span><?php echo i18n((ucfirst($_GET['type']))); ?></label>
<input type="text" name="object_name" autofocus="autofocus" autocomplete="off">
<button class="btn-left"><?php i18n("Create"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Rename
//////////////////////////////////////////////////////////////////
case 'rename':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<input type="hidden" name="type" value="<?php echo($_GET['type']); ?>">
<label><span class="icon-pencil"></span> <?php i18n("Rename"); ?> <?php echo i18n((ucfirst($_GET['type']))); ?></label>
<input type="text" name="object_name" autofocus="autofocus" autocomplete="off" value="<?php echo($_GET['short_name']); ?>">
<button class="btn-left"><?php i18n("Rename"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Delete
//////////////////////////////////////////////////////////////////
case 'delete':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Are you sure you wish to delete the following:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<button class="btn-left"><?php i18n("Delete"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Delete
//////////////////////////////////////////////////////////////////
case 'deleteInner':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Are you sure you wish to delete the contents of the following path:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<button class="btn-left"><?php i18n("Delete"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Preview
//////////////////////////////////////////////////////////////////
case 'preview':
?>
<label><?php i18n("Inline Preview"); ?></label>
<div><br><br><img src="<?php echo(str_replace(BASE_PATH . "/", "", WORKSPACE) . "/" . $_GET['path']); ?>"><br><br></div>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Close"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Preview
//////////////////////////////////////////////////////////////////
case 'music_preview':
?>
<label><?php i18n("Inline Preview"); ?></label>
<div><br><br>
<audio controls>
<source src="<?php echo(str_replace(BASE_PATH . "/", "", WORKSPACE) . "/" . $_GET['path']); ?>">
</audio>
<br><br></div>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Close"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Overwrite
//////////////////////////////////////////////////////////////////
case 'overwrite':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Would you like to overwrite or duplicate the following:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<select name="or_action">
<option value="0"><?php i18n("Overwrite Original"); ?></option>
<option value="1"><?php i18n("Create Duplicate"); ?></option>
</select>
<button class="btn-left"><?php i18n("Continue"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Search
//////////////////////////////////////////////////////////////////
case 'search':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<table class="file-search-table">
<tr>
<td width="65%">
<label><?php i18n("Search Files:"); ?></label>
<input type="text" name="search_string" autofocus="autofocus">
</td>
<td width="5%">&nbsp;&nbsp;</td>
<td>
<label><?php i18n("In:"); ?></label>
<select name="search_type">
<option value="0"><?php i18n("Current Project"); ?></option>
<?php if(checkAccess()) { ?>
<option value="1"><?php i18n("Workspace Projects"); ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<label><?php i18n("File Type:"); ?></label>
<input type="text" name="search_file_type" placeholder="<?php i18n("space seperated file types eg: js c php"); ?>">
</td>
</tr>
</table>
<pre id="filemanager-search-results"></pre>
<div id="filemanager-search-processing"></div>
<button class="btn-left"><?php i18n("Search"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Create
//////////////////////////////////////////////////////////////////
case 'create':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<input type="hidden" name="type" value="<?php echo($_GET['type']); ?>">
<label><span class="icon-pencil"></span><?php echo i18n((ucfirst($_GET['type']))); ?></label>
<input type="text" name="object_name" autofocus="autofocus" autocomplete="off">
<button class="btn-left"><?php i18n("Create"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Rename
//////////////////////////////////////////////////////////////////
case 'rename':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<input type="hidden" name="type" value="<?php echo($_GET['type']); ?>">
<label><span class="icon-pencil"></span> <?php i18n("Rename"); ?> <?php echo i18n((ucfirst($_GET['type']))); ?></label>
<input type="text" name="object_name" autofocus="autofocus" autocomplete="off" value="<?php echo($_GET['short_name']); ?>">
<button class="btn-left"><?php i18n("Rename"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Delete
//////////////////////////////////////////////////////////////////
case 'delete':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Are you sure you wish to delete the following:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<button class="btn-left"><?php i18n("Delete"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Delete
//////////////////////////////////////////////////////////////////
case 'deleteInner':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Are you sure you wish to delete the contents of the following path:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<button class="btn-left"><?php i18n("Delete"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Preview
//////////////////////////////////////////////////////////////////
case 'preview':
?>
<label><?php i18n("Inline Preview"); ?></label>
<div>
<?php
$source = str_replace( BASE_PATH . "/", "", WORKSPACE ) . "/" . $_GET['path'];
$type = mime_content_type( $source );
if( strpos( "audio", $type ) !== false ) {
?><audio controls><source src="<?php echo $source;?>"></audio><?php
} elseif( strpos( "image", $type ) !== false ) {
?><img src="<?php echo $source;?>"><?php
} else {
?><p>Error, unknown file type.</p><?php
}
?>
</div>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Close");?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Overwrite
//////////////////////////////////////////////////////////////////
case 'overwrite':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Would you like to overwrite or duplicate the following:"); ?></label>
<pre>
<?php
if( ! FileManager::isAbsPath( $_GET['path'] ) ) {
echo '/';
};
echo( $_GET['path'] );
?>
</pre>
<select name="or_action">
<option value="0"><?php i18n("Overwrite Original"); ?></option>
<option value="1"><?php i18n("Create Duplicate"); ?></option>
</select>
<button class="btn-left"><?php i18n("Continue"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Search
//////////////////////////////////////////////////////////////////
case 'search':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<table class="file-search-table">
<tr>
<td width="65%">
<label><?php i18n("Search Files:"); ?></label>
<input type="text" name="search_string" autofocus="autofocus">
</td>
<td width="5%">&nbsp;&nbsp;</td>
<td>
<label><?php i18n("In:"); ?></label>
<select name="search_type">
<option value="0"><?php i18n("Current Project"); ?></option>
<?php
if( checkAccess() ) {
?><option value="1"><?php i18n("Workspace Projects"); ?></option><?php
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<label><?php i18n("File Type:"); ?></label>
<input type="text" name="search_file_type" placeholder="<?php i18n("space seperated file types eg: js c php"); ?>">
</td>
</tr>
</table>
<pre id="filemanager-search-results"></pre>
<div id="filemanager-search-processing"></div>
<button class="btn-left"><?php i18n("Search"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
}
?>
</form>
?></form>

View file

@ -60,8 +60,6 @@
this.nodeListener();
this.auto_reload = ( await codiad.settings.get_option( "codiad.filemanager.autoReloadPreview" ) == "true" );
console.log( this.auto_reload );
amplify.subscribe( 'settings.save', async function() {
let option = ( await codiad.settings.get_option( "codiad.filemanager.autoReloadPreview" ) == "true" );
@ -731,7 +729,6 @@
} else if( path == this.clipboard ) {
codiad.message.error( i18n( 'Cannot Paste Directory Into Itself' ) );
} else {
let project = codiad.project.getCurrent();
var shortName = _this.getShortName( _this.clipboard );
if( $( '#file-manager a[data-path="' + path + '/' + shortName + '"]' )
.length ) { // Confirm overwrite?
@ -745,15 +742,13 @@
var duplicate = false;
if( $( '#modal-content form select[name="or_action"]' ).val() == 1 ) {
duplicate = true;
console.log( 'Dup!' );
//console.log( 'Dup!' );
}
_this.processPasteNode( path, duplicate );
});
} else { // No conflicts; proceed...
_this.processPasteNode( path, false );
}
codiad.filemanager.rescan( project );
}
},
@ -776,6 +771,7 @@
shortName: shortName,
duplicate: duplicate
});
codiad.filemanager.rescan( path );
}
});
},
@ -808,9 +804,9 @@
}
var newPath = temp.join( '/' ) + '/' + newName;
$.get( _this.controller, {
action: 'modify',
action: 'rename',
path: path,
new_name: newName
destination: newPath
}, function( data ) {
var renameResponse = codiad.jsend.parse( data );
let renamedMessage = "";