Skip to content

Commit

Permalink
use font-awesome from node_modules,and elfinder connector
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine WEBER committed Apr 28, 2017
1 parent cbf2712 commit a7cfaa2
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 89 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OMV Web Desk

![Preview](https://github.com/TwanoO67/ng2-os/raw/master/src/assets/demo.gif)
![Preview](https://github.com/TwanoO67/ng2-os/raw/master/src/demo.gif)

# English description

Expand Down Expand Up @@ -45,7 +45,7 @@ Pour ajouter le navigateur de fichier, vous pouvez télécharger [ElFinder](http
et le placer dans le même dossier que précédemment (en utilisant les fichier se trouvant dans "elfinder")


## Securisation
## Securisation
Pour securiser cet écran derriere une page de login, vous pouvez utiliser le contenu du dossier "omv".
Celui-ci limite l'accès au index.html, avec un index.php dans lequel votre session OpenMediaVault, pour vous servir de son login.

Expand All @@ -63,4 +63,3 @@ dans votre conf nginx rajouter:
rewrite ^(.*)$ /index.php break;
}
}

File renamed without changes
Binary file modified dist/assets/.DS_Store
Binary file not shown.
158 changes: 87 additions & 71 deletions omv/elfinder/php/connector.minimal.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,93 @@
<?php

error_reporting(0); // Set E_ALL for debuging

//AW - verif si session omv
session_start();
if(
!isset($_SESSION['authenticated'])
|| !$_SESSION['authenticated']
|| !$_SESSION['username']
|| !$_SESSION['username'] === ""
){
exit;
}
require_once("openmediavault/autoloader.inc");
require_once("openmediavault/env.inc");
use OMV\Rpc\Rpc;

//Verif si le username est clean pour déduire un nom de dossier
$dossier = "../files/anonymous/";
if( strpos($_SESSION['username'],'.') === false && strpos($_SESSION['username'],'/') === false){
$dossier = "../files/".$_SESSION['username']."/";
}
// Display errors if debugging is enabled.
if (TRUE === \OMV\Environment::getBoolean("OMV_DEBUG_PHP")){
ini_set("display_errors", 1);
}

$session = &\OMV\Session::getInstance();
$session->start();

$roots = [];

if ($session->isAuthenticated() /*&& !$session->isTimeout()*/) {

if($session->getUsername() == 'admin'){
$roots = [
[
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => "/media", // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '/media', // URL to files (REQUIRED)
//'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
'uploadAllow' => array('all'),//array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
]
];
}
else{
//echo "<script> OMV = {}; OMV.USERNAME = '".$session->getUsername()."'; </script>";
$rpcServiceMngr = \OMV\Rpc\ServiceManager::getInstance();
$rpcServiceMngr->initializeServices();
// Initialize the data models.
$modelMngr = \OMV\DataModel\Manager::getInstance();
$modelMngr->load();

$service = "ShareMgmt";
$method = "getList";
$params = array(
"start" => 0 ,
"limit" => null
);
//$context = Rpc::createContext($session->getUsername(), $session->getRole());
//var_dump($context);exit;
$admin_context = Rpc::createContext("admin", OMV_ROLE_ADMINISTRATOR);

$result = Rpc::call($service, $method, $params, $admin_context, Rpc::MODE_REMOTE);

foreach($result['data'] as $folder){
if($folder['privileges'] !== '' && is_array($folder['privileges']['privilege']) ){
foreach($folder['privileges']['privilege'] as $perm){
if($perm['name'] === $session->getUsername()){
$dossier = $folder['mntent']['dir'].'/'.$folder['reldirpath'];

// load composer autoload before load elFinder autoload If you need composer
//require './vendor/autoload.php';
$conf = array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => $dossier, // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) .$dossier, // URL to files (REQUIRED)
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
);

//ecriture
if($perm['perms'] === 7){
//All Mimetypes, or array('image', 'text/plain') allowed to upload
$conf = array_merge($conf, ['uploadAllow' => ['all']]);
}
else{
$conf = array_merge($conf, ['uploadDeny' => ['all']]);
}

$roots[] = $conf;
}
/*else{
echo "coucou";
}*/
}
}
}
}
}
else{
echo "pas de session";
exit;
}

//exit;

// elFinder autoload
require './autoload.php';
Expand All @@ -30,46 +96,6 @@
// Enable FTP connector netmount
elFinder::$netDrivers['ftp'] = 'FTP';
// ===============================================

/**
* # Dropbox volume driver need `composer require dropbox-php/dropbox-php:dev-master@dev`
* OR "dropbox-php's Dropbox" and "PHP OAuth extension" or "PEAR's HTTP_OAUTH package"
* * dropbox-php: http://www.dropbox-php.com/
* * PHP OAuth extension: http://pecl.php.net/package/oauth
* * PEAR's HTTP_OAUTH package: http://pear.php.net/package/http_oauth
* * HTTP_OAUTH package require HTTP_Request2 and Net_URL2
*/
// // Required for Dropbox.com connector support
// // On composer
// elFinder::$netDrivers['dropbox'] = 'Dropbox';
// // OR on pear
// include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDropbox.class.php';

// // Dropbox driver need next two settings. You can get at https://www.dropbox.com/developers
// define('ELFINDER_DROPBOX_CONSUMERKEY', '');
// define('ELFINDER_DROPBOX_CONSUMERSECRET', '');
// define('ELFINDER_DROPBOX_META_CACHE_PATH',''); // optional for `options['metaCachePath']`
// ===============================================

// // Required for Google Drive network mount
// // Installation by composer
// // `composer require nao-pon/flysystem-google-drive:~1.1 google/apiclient:~2.0@rc nao-pon/elfinder-flysystem-driver-ext`
// // Enable network mount
// elFinder::$netDrivers['googledrive'] = 'FlysystemGoogleDriveNetmount';
// // GoogleDrive Netmount driver need next two settings. You can get at https://console.developers.google.com
// // AND reuire regist redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=googledrive&host=1"
// define('ELFINDER_GOOGLEDRIVE_CLIENTID', '');
// define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', '');
// ===============================================

/**
* Simple function to demonstrate how to control file access using "accessControl" callback.
* This method will disable accessing files/folders starting from '.' (dot)
*
* @param string $attr attribute name (read|write|locked|hidden)
* @param string $path file path relative to volume root directory started with directory separator
* @return bool|null
**/
function access($attr, $path, $data, $volume) {
return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot)
? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
Expand All @@ -81,18 +107,8 @@ function access($attr, $path, $data, $volume) {
// https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => $dossier, // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '/'.$dossier, // URL to files (REQUIRED)
'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
'uploadAllow' => array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
)
)
);
'locale' => "fr_FR.UTF-8",
'roots' => $roots);

// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
Expand Down
22 changes: 11 additions & 11 deletions omv/login/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

// Load and initialize the RPC services that are not handled by the
// engine daemon.
/*$directory = build_path(DIRECTORY_SEPARATOR, \OMV\Environment::get("OMV_DOCUMENTROOT_DIR"), "rpc");
$directory = build_path(DIRECTORY_SEPARATOR, \OMV\Environment::get("OMV_DOCUMENTROOT_DIR"), "rpc");
foreach (listdir($directory, "inc") as $path) {
require_once $path;
}*/
}


$rpcServiceMngr = \OMV\Rpc\ServiceManager::getInstance();
Expand All @@ -30,28 +30,28 @@
$modelMngr->load();
$session = &\OMV\Session::getInstance();


if ( $session->isAuthenticated() && $session->isTimeout() ) {
session_destroy();
session_start();
//$session = &\OMV\Session::getInstance();
}

$params = array(
"username" => $_POST['username'],
"password" => $_POST['password']
);

$object = \OMV\Rpc\Rpc::call("UserMgmt", "authUser", $params, ['username' => 'admin', 'role' => OMV_ROLE_ADMINISTRATOR], \OMV\Rpc\Rpc::MODE_REMOTE, TRUE);
if (!is_null($object) && (TRUE === $object['authenticated'])) {
if ($session->isAuthenticated()) {
// Is the current session registered to the user to be authenticated?
if ($session->getUsername() !== $params['username']) {
$session->commit();
throw new \OMV\ErrorMsgException( \OMV\ErrorMsgException::E_SESSION_ALREADY_AUTHENTICATED );
}
} else {
if ( ! $session->isAuthenticated() ){
// Initialize session.
$role = ($params['username'] === "admin") ? OMV_ROLE_ADMINISTRATOR : OMV_ROLE_USER;
$session->initialize($params['username'], $role);
$session->commit();
}
$session->commit();
}
echo json_encode($object);

}
else{
echo "{'error':'No login information sent.'}";
Expand Down
2 changes: 0 additions & 2 deletions omv/login/config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
return [
"omv_api_rpc" => "http://YOUR-OPENMEDIAVAULT-IP/rpc.php",
"desktop_background" => "/assets/img/bg.jpg",
"login_background" => "http://i.imgur.com/W8IdvVk.jpg",
"login_avatar" => "https://pbs.twimg.com/profile_images/1453596088/dessin_antoine_400x400.png"
];

Binary file removed src/assets/screenshot.png
Binary file not shown.
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html>
<head>
<meta charset="utf-8">
<title>Ng2OsNew</title>
<title>WebDesk</title>
<base href="/">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<!--link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"-->

<script type="text/javascript" src="webdesk_config.js"></script>
<script>
Expand Down
2 changes: 2 additions & 0 deletions src/styles.css → src/styles.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* You can add global styles to this file, and also import other style files */
@import "../node_modules/font-awesome/css/font-awesome.css";

*, :before, :after { box-sizing: border-box; }
html {
font: 300 16px/1.618 "Helvetica Neue", Helvetica, sans-serif;
Expand Down

0 comments on commit a7cfaa2

Please sign in to comment.