mirror of
https://git.code.sf.net/p/seeddms/code
synced 2026-01-15 22:06:43 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
dc4a99dc6f
|
|
@ -350,6 +350,8 @@
|
|||
--------------------------------------------------------------------------------
|
||||
- add Slim middleware for Basic authentication (can be used by extensions)
|
||||
- rest api endpoint 'statstotal' returns number of groups and categories
|
||||
- add new command line program utils/console
|
||||
- major code polishing
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Changes in version 5.1.42
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@
|
|||
<arg line="${srcdir}/composer.phar install ${composer_extra_params}"/>
|
||||
<!-- arg line="${composer_env} php ${srcdir}/composer.phar install ${composer_extra_params}"/ -->
|
||||
</exec>
|
||||
<exec executable="php" passthru="true" dir="${builddir}/export/${shortversion}">
|
||||
<arg line="${srcdir}/composer.phar dump -o ${composer_extra_params}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="dist" description="build SeedDMS tar archive">
|
||||
|
|
|
|||
|
|
@ -22,7 +22,16 @@
|
|||
"psr-4": {
|
||||
"SeedDMS\\Console\\": "seeddms/utils"
|
||||
},
|
||||
"classmap": ["seeddms/inc/inc.ClassTranslator.php", "seeddms/inc/inc.ClassSettings.php", "seeddms/inc/inc.Version.php", "seeddms/inc/inc.ClassViewCommon.php", "seeddms/inc/inc.ClassControllerCommon.php", "seeddms/inc/inc.ClassController.php"]
|
||||
"classmap": [
|
||||
"seeddms/inc/inc.ClassTranslator.php",
|
||||
"seeddms/inc/inc.ClassSettings.php",
|
||||
"seeddms/inc/inc.Version.php",
|
||||
"seeddms/inc/inc.ClassViewCommon.php",
|
||||
"seeddms/inc/inc.ClassControllerCommon.php",
|
||||
"seeddms/inc/inc.ClassController.php",
|
||||
"seeddms/inc/inc.ClassSession.php",
|
||||
"seeddms/inc/inc.ClassUtilities.php"
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"pear/http_request2": "^2",
|
||||
|
|
|
|||
|
|
@ -20,10 +20,19 @@
|
|||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Seeddms\\Console\\": "utils"
|
||||
},
|
||||
"classmap": ["inc/inc.ClassTranslator.php", "inc/inc.ClassSettings.php", "inc/inc.Version.php", "inc/inc.ClassViewCommon.php", "inc/inc.ClassControllerCommon.php", "inc/inc.ClassController.php"]
|
||||
"psr-4": {
|
||||
"Seeddms\\Console\\": "utils"
|
||||
},
|
||||
"classmap": [
|
||||
"inc/inc.ClassTranslator.php",
|
||||
"inc/inc.ClassSettings.php",
|
||||
"inc/inc.Version.php",
|
||||
"inc/inc.ClassViewCommon.php",
|
||||
"inc/inc.ClassControllerCommon.php",
|
||||
"inc/inc.ClassController.php",
|
||||
"inc/inc.ClassSession.php",
|
||||
"inc/inc.ClassUtilities.php"
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2.0",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
use Seeddms\Seeddms\Session;
|
||||
|
||||
require_once("inc.ClassSession.php");
|
||||
require_once("inc.ClassAccessOperation.php");
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ $isajax = isset($_GET['action']) && ($_GET['action'] != 'show');
|
|||
|
||||
if (!isset($_COOKIE["mydms_session"])) {
|
||||
if($settings->_enableGuestLogin && $settings->_enableGuestAutoLogin) {
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
if(!$dms_session = $session->create(array('userid'=>$settings->_guestID, 'theme'=>$settings->_theme, 'lang'=>$settings->_language))) {
|
||||
if(!$isajax)
|
||||
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
|
||||
|
|
@ -50,7 +52,7 @@ if (!isset($_COOKIE["mydms_session"])) {
|
|||
$lang = $settings->_language;
|
||||
$user->setLanguage($lang);
|
||||
}
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
if(!$dms_session = $session->create(array('userid'=>$user->getID(), 'theme'=>$theme, 'lang'=>$lang))) {
|
||||
if(!$isajax)
|
||||
header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer);
|
||||
|
|
@ -65,7 +67,7 @@ if (!isset($_COOKIE["mydms_session"])) {
|
|||
} else {
|
||||
/* Load session */
|
||||
$dms_session = $_COOKIE["mydms_session"];
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
if(!$resArr = $session->load($dms_session)) {
|
||||
setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot); //delete cookie
|
||||
if(!$isajax)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
* @link https://www.seeddms.org Main Site
|
||||
*/
|
||||
|
||||
use Seeddms\Seeddms\Session;
|
||||
|
||||
/* Middleware for authentication based on session */
|
||||
class SeedDMS_Auth_Middleware_Session { /* {{{ */
|
||||
|
||||
|
|
@ -67,8 +69,8 @@ class SeedDMS_Auth_Middleware_Session { /* {{{ */
|
|||
}
|
||||
|
||||
$logger->log("Invoke AuthSessionMiddleware for method " . $request->getMethod() . " on '" . $request->getUri()->getPath() . "'", PEAR_LOG_INFO);
|
||||
require_once("inc/inc.ClassSession.php");
|
||||
$session = new SeedDMS_Session($dms->getDb());
|
||||
// require_once("inc/inc.ClassSession.php");
|
||||
$session = new Session($dms->getDb());
|
||||
if (isset($_COOKIE["mydms_session"])) {
|
||||
$dms_session = $_COOKIE["mydms_session"];
|
||||
$logger->log("Session key: " . $dms_session, PEAR_LOG_DEBUG);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@
|
|||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
namespace Seeddms\Seeddms;
|
||||
|
||||
use Seeddms\Seeddms\Utilities;
|
||||
|
||||
/**
|
||||
* Class to represent an extension manager
|
||||
*
|
||||
|
|
@ -25,7 +29,7 @@
|
|||
* @copyright 2011 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Extension_Mgr {
|
||||
class ExtensionMgr {
|
||||
/**
|
||||
* @var string $extdir directory where extensions are located
|
||||
* @access protected
|
||||
|
|
@ -179,6 +183,10 @@ class SeedDMS_Extension_Mgr {
|
|||
return $this->cachedir."/extensions.php";
|
||||
} /* }}} */
|
||||
|
||||
public function setRepositoryUrl($reposurl) { /* {{{ */
|
||||
$this->reposurl = $reposurl;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get the configuration of extensions
|
||||
*
|
||||
|
|
@ -262,14 +270,14 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
unlink ($destination);
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
|
||||
$zip = new \ZipArchive();
|
||||
if (!$zip->open($destination, \ZipArchive::CREATE)) {
|
||||
return false;
|
||||
}
|
||||
$source = str_replace('\\', '/', realpath($source));
|
||||
|
||||
if (is_dir($source) === true) {
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
|
||||
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
if ($include_dir) {
|
||||
$arr = explode("/",$source);
|
||||
|
|
@ -330,7 +338,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
$tmpfile = $this->cachedir."/".$extname."-".$version.".zip";
|
||||
}
|
||||
|
||||
if(!SeedDMS_Extension_Mgr::Zip($this->extdir."/".$extname, $tmpfile)) {
|
||||
if(!ExtensionMgr::Zip($this->extdir."/".$extname, $tmpfile)) {
|
||||
return false;
|
||||
}
|
||||
// $cmd = "cd ".$this->extdir."/".$extname."; zip -r ".$tmpfile." .";
|
||||
|
|
@ -406,14 +414,19 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Check content of extension directory or configuration of extension
|
||||
* Check configuration of extension
|
||||
*
|
||||
* @param string|array $dir full path to extension directory or extension name
|
||||
* or an array containing the configuration.
|
||||
* @param array $options array with options elements 'noconstraints' and 'nofiles'.
|
||||
* Set 'noconstraints' to true if
|
||||
* constraints to local seeddms installation shall not be checked. Set 'nofiles'
|
||||
* to true to turn off checking of files
|
||||
* This method checks if the configurations of an extension is complete
|
||||
* and all dependencies specified in the configuration are met.
|
||||
*
|
||||
* @param string $extname not used anymore. Was previously use to store
|
||||
* result of the check into $this->configcache, but this method can be
|
||||
* used for installed extensions and those in the repository, which makes
|
||||
* the use of a cache useless.
|
||||
* @param array $extconf extension configuration to be checked
|
||||
* @param array $options array with option element 'noconstraints'.
|
||||
* Set 'noconstraints' to true if constraints to local seeddms
|
||||
* installation shall not be checked.
|
||||
* @return boolean true if check was successful, otherwise false
|
||||
*/
|
||||
public function checkExtensionByName($extname, $extconf, $options=array()) { /* {{{ */
|
||||
|
|
@ -444,7 +457,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
foreach($extconf['constraints']['depends'] as $dkey=>$dval) {
|
||||
switch($dkey) {
|
||||
case 'seeddms':
|
||||
$version = new SeedDMS_Version;
|
||||
$version = new Version;
|
||||
if(is_array($dval)) {
|
||||
$fullfill = false;
|
||||
foreach($dval as $ddval) {
|
||||
|
|
@ -521,13 +534,13 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
$newdir = addDirSep($this->cachedir)."ext.new";
|
||||
/* First remove a left over from a previous extension */
|
||||
if(file_exists($newdir)) {
|
||||
SeedDMS_Utils::rrmdir($newdir);
|
||||
Utilities::rrmdir($newdir);
|
||||
}
|
||||
if(!mkdir($newdir, 0755)) {
|
||||
$this->errmsgs[] = "Cannot create temp. extension directory";
|
||||
return false;
|
||||
}
|
||||
$zip = new ZipArchive;
|
||||
$zip = new \ZipArchive;
|
||||
$res = $zip->open($file);
|
||||
if ($res === TRUE) {
|
||||
$zip->extractTo($newdir);
|
||||
|
|
@ -541,7 +554,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
|
||||
/* Check if extension is complete and fullfills the constraints */
|
||||
if(!self::checkExtensionByDir($newdir)) {
|
||||
SeedDMS_Utils::rrmdir($newdir);
|
||||
Utilities::rrmdir($newdir);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -552,11 +565,11 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
if(!is_dir($this->extdir)) {
|
||||
if(!mkdir($this->extdir, 0755)) {
|
||||
$this->errmsgs[] = "Cannot create extension directory";
|
||||
SeedDMS_Utils::rrmdir($newdir);
|
||||
Utilities::rrmdir($newdir);
|
||||
return false;
|
||||
}
|
||||
} elseif(is_dir($this->extdir ."/". $extname)) {
|
||||
SeedDMS_Utils::rrmdir($this->extdir ."/". $extname);
|
||||
Utilities::rrmdir($this->extdir ."/". $extname);
|
||||
}
|
||||
/* Move the temp. created ext directory to the final location */
|
||||
/* rename() may fail if dirs are moved from one device to another.
|
||||
|
|
@ -578,7 +591,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
* has been copied.
|
||||
*/
|
||||
$this->errmsgs[] = "Cannot move temp. extension directory to final destination";
|
||||
SeedDMS_Utils::rrmdir($this->extdir ."/". $extname);
|
||||
Utilities::rrmdir($this->extdir ."/". $extname);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -592,7 +605,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
* single lines. Each line is either a comment if it starts with an '#'
|
||||
* or a json encoded array containing the extension configuration.
|
||||
*
|
||||
* Run SeedDMS_Extension_Mgr::updateExtensionList() to ensure the
|
||||
* Run Seeddms\Seeddms\ExtensionMgr::updateExtensionList() to ensure the
|
||||
* currently cached extension list file is up to date.
|
||||
*
|
||||
* @return string[] list of json strings or comments
|
||||
|
|
@ -612,7 +625,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
* a list of extension configurations. Only the most recent version
|
||||
* of an extension will be included.
|
||||
*
|
||||
* Run SeedDMS_Extension_Mgr::updateExtensionList() to ensure the
|
||||
* Run Seeddms\Seeddms\ExtensionMgr::updateExtensionList() to ensure the
|
||||
* currently cached extension list file is up to date.
|
||||
*
|
||||
* @return array[] list of extension configurations
|
||||
|
|
@ -644,7 +657,7 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
* a list of extension configurations. Only those extensions will
|
||||
* be included which maches the given name.
|
||||
*
|
||||
* Run SeedDMS_Extension_Mgr::updateExtensionList() to ensure the
|
||||
* Run Seeddms\Seeddms\ExtensionMgr::updateExtensionList() to ensure the
|
||||
* currently cached extension list file is up to date.
|
||||
*
|
||||
* @return array[] list of extension configurations
|
||||
|
|
@ -660,13 +673,16 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
}
|
||||
}
|
||||
}
|
||||
uksort($result, function($a, $b){return SeedDMS_Extension_Mgr::cmpVersion($b, $a);});
|
||||
uksort($result, function($a, $b){return ExtensionMgr::cmpVersion($b, $a);});
|
||||
return $result;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Import list of extension from repository
|
||||
*
|
||||
* Will also update the list in the cache, which is used by getExtensionList()
|
||||
* and getExtensionListByName().
|
||||
*
|
||||
* @param boolean $force force download even if file already exists
|
||||
*/
|
||||
public function updateExtensionList($version='', $force=false) { /* {{{ */
|
||||
|
|
@ -704,9 +720,13 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
*/
|
||||
public function getExtensionFromRepository($file) { /* {{{ */
|
||||
$content = file_get_contents($this->reposurl."/".$file, false, $this->getStreamContext());
|
||||
$tmpfile = tempnam(sys_get_temp_dir(), '');
|
||||
file_put_contents($tmpfile, $content);
|
||||
return $tmpfile;
|
||||
if ($content) {
|
||||
$tmpfile = tempnam(sys_get_temp_dir(), '');
|
||||
file_put_contents($tmpfile, $content);
|
||||
return $tmpfile;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
|
@ -730,3 +750,5 @@ $EXT_CONF = '.var_export($EXT_CONF, true).';');
|
|||
return $this->errmsgs;
|
||||
} /* }}} */
|
||||
}
|
||||
|
||||
class_alias('Seeddms\Seeddms\ExtensionMgr', 'SeedDMS_Extension_Mgr');
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
namespace Seeddms\Seeddms;
|
||||
|
||||
/**
|
||||
* Class to represent a session
|
||||
*
|
||||
|
|
@ -29,7 +31,7 @@
|
|||
* @copyright 2011 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Session {
|
||||
class Session {
|
||||
/**
|
||||
* @var object $db reference to database object. This must be an instance
|
||||
* of {@link SeedDMS_Core_DatabaseAccess}.
|
||||
|
|
@ -53,7 +55,7 @@ class SeedDMS_Session {
|
|||
* Create a new instance of the session handler
|
||||
*
|
||||
* @param object $db object to access the underlying database
|
||||
* @return object instance of SeedDMS_Session
|
||||
* @return object instance of Seeddms\Seeddms\Session
|
||||
*/
|
||||
function __construct($db) { /* {{{ */
|
||||
$this->db = $db;
|
||||
|
|
@ -417,6 +419,8 @@ class SeedDMS_Session {
|
|||
|
||||
}
|
||||
|
||||
class_alias('Seeddms\Seeddms\Session', 'SeedDMS_Session');
|
||||
|
||||
/**
|
||||
* Class for managing sessions
|
||||
*
|
||||
|
|
@ -428,7 +432,7 @@ class SeedDMS_Session {
|
|||
* @copyright 2014 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_SessionMgr {
|
||||
class SessionMgr {
|
||||
/**
|
||||
* @var object $db reference to database object. This must be an instance
|
||||
* of {@link SeedDMS_Core_DatabaseAccess}.
|
||||
|
|
@ -440,7 +444,7 @@ class SeedDMS_SessionMgr {
|
|||
* Create a new instance of the session manager
|
||||
*
|
||||
* @param object $db object to access the underlying database
|
||||
* @return object instance of SeedDMS_SessionMgr
|
||||
* @return object instance of Seeddms\Seeddms\SessionMgr
|
||||
*/
|
||||
function __construct($db) { /* {{{ */
|
||||
$this->db = $db;
|
||||
|
|
@ -478,7 +482,7 @@ class SeedDMS_SessionMgr {
|
|||
return false;
|
||||
$sessions = array();
|
||||
foreach($resArr as $rec) {
|
||||
$session = new SeedDMS_Session($this->db);
|
||||
$session = new Session($this->db);
|
||||
$session->load($rec['id']);
|
||||
$sessions[] = $session;
|
||||
}
|
||||
|
|
@ -501,7 +505,7 @@ class SeedDMS_SessionMgr {
|
|||
return false;
|
||||
$sessions = array();
|
||||
foreach($resArr as $rec) {
|
||||
$session = new SeedDMS_Session($this->db);
|
||||
$session = new Session($this->db);
|
||||
$session->load($rec['id']);
|
||||
$sessions[] = $session;
|
||||
}
|
||||
|
|
@ -523,7 +527,7 @@ class SeedDMS_SessionMgr {
|
|||
return false;
|
||||
$sessions = array();
|
||||
foreach($resArr as $rec) {
|
||||
$session = new SeedDMS_Session($this->db);
|
||||
$session = new Session($this->db);
|
||||
$session->load($rec['id']);
|
||||
$sessions[] = $session;
|
||||
}
|
||||
|
|
@ -531,3 +535,5 @@ class SeedDMS_SessionMgr {
|
|||
|
||||
} /* }}} */
|
||||
}
|
||||
|
||||
class_alias('Seeddms\Seeddms\SessionMgr', 'SeedDMS_SessionMgr');
|
||||
|
|
|
|||
|
|
@ -1977,3 +1977,4 @@ class Settings { /* {{{ */
|
|||
|
||||
} /* }}} */
|
||||
|
||||
class_alias('Seeddms\Seeddms\Settings', 'SeedDMS_Settings');
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use SeedDMS_Core_AttributeDefinition;
|
|||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2011 Uwe Steinmann
|
||||
* @copyright Copyright (C) 2025 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class Translator { /* {{{ */
|
||||
|
|
|
|||
94
inc/inc.ClassUtilities.php
Normal file
94
inc/inc.ClassUtilities.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Various utility functions
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2025 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
namespace Seeddms\Seeddms;
|
||||
|
||||
/**
|
||||
* Class with various methods
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2025 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class Utilities { /* {{{ */
|
||||
|
||||
/**
|
||||
* Recursively remove a directory on disc
|
||||
*
|
||||
* @param string $dir name of directory
|
||||
*/
|
||||
static public function rrmdir($dir) { /* {{{ */
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") self::rrmdir($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create a random string
|
||||
*
|
||||
* @param integer $n number of chars
|
||||
* @param string $alph alphabet used as source for chars
|
||||
* @return string random string
|
||||
*/
|
||||
static public function makeRandomString($n, $alph = "0123456789abcdefghijklmnopqrstuvwxyz") { /* {{{ */
|
||||
$s = "";
|
||||
for ($i = 0; $i != $n; ++$i)
|
||||
$s .= $alph[mt_rand(0, 35)];
|
||||
return $s;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create a real uniqid for cryptographic purposes
|
||||
*
|
||||
* @ return string
|
||||
*/
|
||||
static public function uniqidReal($lenght = 13) { /* {{{ */
|
||||
// uniqid gives 13 chars, but you could adjust it to your needs.
|
||||
if (function_exists("random_bytes")) {
|
||||
$bytes = random_bytes(ceil($lenght / 2));
|
||||
} elseif (function_exists("openssl_random_pseudo_bytes")) {
|
||||
$bytes = openssl_random_pseudo_bytes(ceil($lenght / 2));
|
||||
} else {
|
||||
throw new Exception("no cryptographically secure random function available");
|
||||
}
|
||||
return substr(bin2hex($bytes), 0, $lenght);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return nonce for CSP
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function createNonce() { /* {{{ */
|
||||
$length = 16;
|
||||
$usable = true;
|
||||
$bytes = openssl_random_pseudo_bytes($length, $usable);
|
||||
if ($usable === false) {
|
||||
// weak
|
||||
// @TODO do something?
|
||||
}
|
||||
return base64_encode($bytes);
|
||||
} /* }}} */
|
||||
|
||||
} /* }}} */
|
||||
|
||||
class_alias('Seeddms\Seeddms\Utilities', 'SeedDMS_Utils');
|
||||
|
|
@ -23,6 +23,10 @@ use Seeddms\Seeddms\Translator;
|
|||
$translator = new Translator($settings);
|
||||
$translator->init();
|
||||
|
||||
/* All remaining functions in this file are deprecated and should
|
||||
* not be used anymore. Use instead the equivalent methods in class
|
||||
* Translator;
|
||||
*/
|
||||
function getAvailableLanguages() { /* {{{ */
|
||||
trigger_error("getAvailableLanguages() is deprecated.", E_USER_DEPRECATED);
|
||||
foreach(debug_backtrace() as $n) {
|
||||
|
|
|
|||
|
|
@ -650,7 +650,7 @@ function checkFormKey($formid='', $method='POST') { /* {{{ */
|
|||
* quota is reached. Negative values indicate a disk usage above quota.
|
||||
*/
|
||||
function checkQuota($user) { /* {{{ */
|
||||
global $settings, $dms;
|
||||
global $settings;
|
||||
|
||||
/* check if quota is turn off system wide */
|
||||
if($settings->_quota == 0)
|
||||
|
|
@ -1025,39 +1025,6 @@ function resolveTask($task) { /* {{{ */
|
|||
return $task;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return nonce for CSP
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function createNonce() { /* {{{ */
|
||||
$length = 16;
|
||||
$usable = true;
|
||||
$bytes = openssl_random_pseudo_bytes($length, $usable);
|
||||
if ($usable === false) {
|
||||
// weak
|
||||
// @TODO do something?
|
||||
}
|
||||
return base64_encode($bytes);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create a real uniqid for cryptographic purposes
|
||||
*
|
||||
* @ return string
|
||||
*/
|
||||
function uniqidReal($lenght = 13) {
|
||||
// uniqid gives 13 chars, but you could adjust it to your needs.
|
||||
if (function_exists("random_bytes")) {
|
||||
$bytes = random_bytes(ceil($lenght / 2));
|
||||
} elseif (function_exists("openssl_random_pseudo_bytes")) {
|
||||
$bytes = openssl_random_pseudo_bytes(ceil($lenght / 2));
|
||||
} else {
|
||||
throw new Exception("no cryptographically secure random function available");
|
||||
}
|
||||
return substr(bin2hex($bytes), 0, $lenght);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare function for sorting users by login
|
||||
*
|
||||
|
|
@ -1290,47 +1257,7 @@ function getMandatoryApprovers($folder, $document, $user) { /* {{{ */
|
|||
return $approvers;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Class with various utility methods
|
||||
*
|
||||
* This class will sooner or later comprise the functions above
|
||||
*
|
||||
*/
|
||||
class SeedDMS_Utils { /* {{{ */
|
||||
|
||||
/**
|
||||
* Recursively remove a directory on disc
|
||||
*
|
||||
* @param string $dir name of directory
|
||||
*/
|
||||
static public function rrmdir($dir) { /* {{{ */
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") self::rrmdir($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create a random string
|
||||
*
|
||||
* @param integer $n number of chars
|
||||
* @param string $alph alphabet used as source for chars
|
||||
* @return string random string
|
||||
*/
|
||||
static public function makeRandomString($n, $alph = "0123456789abcdefghijklmnopqrstuvwxyz") { /* {{{ */
|
||||
$s = "";
|
||||
for ($i = 0; $i != $n; ++$i)
|
||||
$s .= $alph[mt_rand(0, 35)];
|
||||
return $s;
|
||||
} /* }}} */
|
||||
|
||||
} /* }}} */
|
||||
require_once "inc/inc.ClassUtilities.php";
|
||||
|
||||
/**
|
||||
* Class for creating encrypted api keys
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
class SeedDMS_Version { /* {{{ */
|
||||
namespace Seeddms\Seeddms;
|
||||
|
||||
class Version { /* {{{ */
|
||||
|
||||
const _number = "6.0.36";
|
||||
const _string = "SeedDMS";
|
||||
|
|
@ -47,7 +49,7 @@ class SeedDMS_Version { /* {{{ */
|
|||
|
||||
function banner() { /* {{{ */
|
||||
return self::_string .", ". self::_number;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Compare two version
|
||||
|
|
@ -84,3 +86,4 @@ class SeedDMS_Version { /* {{{ */
|
|||
|
||||
} /* }}} */
|
||||
|
||||
class_alias('Seeddms\Seeddms\Version', 'SeedDMS_Version');
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ require_once("../inc/inc.ClassUI.php");
|
|||
require_once("../inc/inc.ClassController.php");
|
||||
require_once("../inc/inc.Notification.php");
|
||||
|
||||
use Seeddms\Seeddms\Session;
|
||||
|
||||
require_once("../inc/inc.ClassSession.php");
|
||||
require_once("../inc/inc.ClassPasswordStrength.php");
|
||||
require_once("../inc/inc.ClassPasswordHistoryManager.php");
|
||||
|
|
@ -36,7 +38,7 @@ require_once("../inc/inc.ClassPasswordHistoryManager.php");
|
|||
/* Load session */
|
||||
if (isset($_COOKIE["mydms_session"])) {
|
||||
$dms_session = $_COOKIE["mydms_session"];
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
if(!$resArr = $session->load($dms_session)) {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('error'=>1));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
use Seeddms\Seeddms\Session;
|
||||
|
||||
include("../inc/inc.Settings.php");
|
||||
include("../inc/inc.Utils.php");
|
||||
include("../inc/inc.LogInit.php");
|
||||
|
|
@ -67,7 +69,7 @@ if(isset($_REQUEST["lang"]) && strlen($_REQUEST["lang"])>0 && is_numeric(array_s
|
|||
$lang = (string) $_REQUEST["lang"];
|
||||
}
|
||||
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
|
||||
// TODO: by the PHP manual: The superglobals $_GET and $_REQUEST are already decoded.
|
||||
// Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results.
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@ include("../inc/inc.Utils.php");
|
|||
include("../inc/inc.LogInit.php");
|
||||
include("../inc/inc.Language.php");
|
||||
include("../inc/inc.Init.php");
|
||||
include("../inc/inc.Extension.php");
|
||||
//include("../inc/inc.Extension.php");
|
||||
include("../inc/inc.ClassSession.php");
|
||||
include("../inc/inc.ClassController.php");
|
||||
include("../inc/inc.DBInit.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
|
||||
use Seeddms\Seeddms\Session;
|
||||
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||
|
||||
|
|
@ -36,7 +38,7 @@ $controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
|
|||
if(isset($_COOKIE['mydms_session'])) {
|
||||
$dms_session = $_COOKIE["mydms_session"];
|
||||
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
$session->load($dms_session);
|
||||
|
||||
// If setting the user id to 0 worked, it would be a way to logout a
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use Psr\Http\Server\MiddlewareInterface;
|
|||
use DI\ContainerBuilder;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use Seeddms\Seeddms\Session;
|
||||
|
||||
final class JsonRenderer { /* {{{ */
|
||||
public function json(
|
||||
|
|
@ -274,7 +275,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
|||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Login failed', 'data'=>''))->withStatus(403);
|
||||
} else {
|
||||
require_once("../inc/inc.ClassSession.php");
|
||||
$session = new SeedDMS_Session($dms->getDb());
|
||||
$session = new Session($dms->getDb());
|
||||
if(!$id = $session->create(array('userid'=>$userobj->getId(), 'theme'=>$userobj->getTheme(), 'lang'=>$userobj->getLanguage()))) {
|
||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Creating session failed', 'data'=>''))->withStatus(500);
|
||||
}
|
||||
|
|
@ -301,7 +302,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
|||
$dms_session = $_COOKIE["mydms_session"];
|
||||
$db = $dms->getDb();
|
||||
|
||||
$session = new SeedDMS_Session($db);
|
||||
$session = new Session($db);
|
||||
$session->load($dms_session);
|
||||
|
||||
// If setting the user id to 0 worked, it would be a way to logout a
|
||||
|
|
@ -3271,7 +3272,7 @@ class RestapiAuthMiddleware implements MiddlewareInterface { /* {{{ */
|
|||
} else {
|
||||
$logger->log("Checking for valid session", PEAR_LOG_INFO);
|
||||
require_once("../inc/inc.ClassSession.php");
|
||||
$session = new SeedDMS_Session($dms->getDb());
|
||||
$session = new Session($dms->getDb());
|
||||
if (isset($_COOKIE["mydms_session"])) {
|
||||
$logger->log("Found cookie for session", PEAR_LOG_INFO);
|
||||
$dms_session = $_COOKIE["mydms_session"];
|
||||
|
|
|
|||
71
utils/Commands/CheckextensionCommand.php
Normal file
71
utils/Commands/CheckextensionCommand.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
namespace Seeddms\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use SeedDMS_Core_File;
|
||||
use SeedDMS_View_Common;
|
||||
use SeedDMS_Extension_Mgr;
|
||||
use Log_file;
|
||||
|
||||
class CheckextensionCommand extends Command
|
||||
{
|
||||
protected $settings;
|
||||
|
||||
protected $logger;
|
||||
|
||||
protected $translator;
|
||||
|
||||
protected $extmgr;
|
||||
|
||||
public function __construct(Settings $settings, Log_file $logger, Translator $translator, SeedDMS_Extension_Mgr $extmgr)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->logger = $logger;
|
||||
$this->translator = $translator;
|
||||
$this->extmgr = $extmgr;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('ext:check')
|
||||
->setDescription('Check extensions')
|
||||
->setHelp('Checks all installed extensions for completeness and dependencies.')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||
{
|
||||
$settings = $this->settings;
|
||||
$logger = $this->logger;
|
||||
$translator = $this->translator;
|
||||
$extmgr = $this->extmgr;
|
||||
|
||||
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
|
||||
|
||||
$extconfs = $extmgr->getExtensionConfiguration();
|
||||
foreach ($extconfs as $extname=>$extconf) {
|
||||
if($extmgr->checkExtensionByDir($extname)) {
|
||||
$output->writeln(sprintf("<info>%s</info>", $extname));
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>%s</error>", $extname));
|
||||
$errmsgs = $extmgr->getErrorMsgs();
|
||||
foreach($errmsgs as $errmsg) {
|
||||
$output->writeln(sprintf("<comment>%s</comment>", $errmsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=4 sw=4 expandtab
|
||||
|
|
@ -6,6 +6,8 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
|
|
@ -33,9 +35,10 @@ class ClearcacheCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this->setName('cache:clear')
|
||||
->setDescription('Clears the cache')
|
||||
->setHelp('Clears all cache or those specified.')
|
||||
->addOption('cache', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove files from cache.', null)
|
||||
->setDescription('Clear cache')
|
||||
->setHelp('Clears either all caches or those specified with option --cache. Think twice before you clear a cache with previews. Depending on the number of documents in your DMS, it may take a long time to recreate the cache.')
|
||||
->addOption('cache', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove files from this cache.', null)
|
||||
->addOption('force', '', InputOption::VALUE_NONE, 'Force operation, do not ask')
|
||||
;
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +55,14 @@ class ClearcacheCommand extends Command
|
|||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if (!$input->getOption('force')) {
|
||||
$helper = new QuestionHelper();
|
||||
$question = new ConfirmationQuestion('<question>Do you really want to clear the cache?</question> ', false);
|
||||
if (!$helper->ask($input, $output, $question)) {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
require_once('inc/inc.DBInit.php');
|
||||
|
||||
$post = array_flip($input->getOption('cache'));
|
||||
|
|
|
|||
140
utils/Commands/DownloadextensionCommand.php
Normal file
140
utils/Commands/DownloadextensionCommand.php
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
namespace Seeddms\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use SeedDMS_Core_File;
|
||||
use SeedDMS_View_Common;
|
||||
use SeedDMS_Extension_Mgr;
|
||||
use Log_file;
|
||||
|
||||
class DownloadextensionCommand extends Command
|
||||
{
|
||||
protected $settings;
|
||||
|
||||
protected $logger;
|
||||
|
||||
protected $translator;
|
||||
|
||||
protected $extmgr;
|
||||
|
||||
public function __construct(Settings $settings, Log_file $logger, Translator $translator, SeedDMS_Extension_Mgr $extmgr)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->logger = $logger;
|
||||
$this->translator = $translator;
|
||||
$this->extmgr = $extmgr;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('ext:download')
|
||||
->setDescription('Download extension from repository')
|
||||
->setHelp('')
|
||||
->addOption('url', '', InputOption::VALUE_REQUIRED, 'Url of repository.', null)
|
||||
->addOption('name', '', InputOption::VALUE_REQUIRED, 'Name of extension.', null)
|
||||
->addOption('extversion', '', InputOption::VALUE_REQUIRED, 'Version of extension.', null)
|
||||
->addOption('no-upload', '', InputOption::VALUE_NONE, 'Just download extension file')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||
{
|
||||
$settings = $this->settings;
|
||||
$logger = $this->logger;
|
||||
$translator = $this->translator;
|
||||
$extmgr = $this->extmgr;
|
||||
|
||||
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
|
||||
|
||||
if (!is_writable($settings->_cacheDir)) {
|
||||
$output->writeln(sprintf("<error>The cache dir '%s' is not writable for the system user running this script.</error>", $settings->_cacheDir));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$reposurl = $input->getOption('url');
|
||||
if($reposurl)
|
||||
$extmgr->setRepositoryUrl($reposurl);
|
||||
|
||||
$extname = $input->getOption('name');
|
||||
if (!$extname) {
|
||||
$output->writeln(sprintf("<error>You must specify an extension name.</error>"));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
$extversion = $input->getOption('extversion');
|
||||
$noupload = $input->getOption('no-upload');
|
||||
|
||||
/* Get a list of available extensions from the repository */
|
||||
if($ret = $extmgr->updateExtensionList('', true)) {
|
||||
// list of installed extensions
|
||||
$extconfs = $extmgr->getExtensionConfiguration();
|
||||
// list of extensions in repository, this will just return the
|
||||
// latest version of an extension
|
||||
$list = $extmgr->getExtensionList();
|
||||
if (isset($list[$extname])) {
|
||||
/* if specific version is not requested, then take the
|
||||
* last version of the extension.
|
||||
*/
|
||||
if (!$extversion)
|
||||
$extversion = $list[$extname]['version'];
|
||||
$extversions = $extmgr->getExtensionListByName($extname);
|
||||
if (isset($extversions[$extversion])) {
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($extversions[$extversion]['filename'])) {
|
||||
$output->writeln(sprintf("<info>Downloaded extension file '%s'</info>", $extversions[$extversion]['filename']));
|
||||
if (!$noupload) {
|
||||
if (isset($extconfs[$extname])) {
|
||||
if (\Seeddms\Seeddms\ExtensionMgr::cmpVersion($extconfs[$extname]['version'], $extversion) > 0) {
|
||||
$helper = new QuestionHelper();
|
||||
$question = new ConfirmationQuestion(sprintf("<question>You are updating extension '%s' with an older version %s < %s. Do you want to proceed?</question> ", $extname, $extversion, $extconfs[$extname]['version']), false);
|
||||
if (!$helper->ask($input, $output, $question)) {
|
||||
unlink($tmpfile);
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
$output->writeln(sprintf("<info>Updating existing extension '%s' with version %s</info>", $extname, $extversion));
|
||||
} else {
|
||||
$output->writeln(sprintf("<info>Installing new extension '%s' with version %s</info>", $extname, $extversion));
|
||||
}
|
||||
if (!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
} else {
|
||||
rename($tmpfile, $extversions[$extversion]['filename']);
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Could not download file '%s'</error>", $list[$extname]['filename']));
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Requested version '%s' of extension '%s' does not exist in repository.</error>", $extversion, $extname));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Extension '%s' does not exist in repository.</error>", $extname));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Could not get extension list from repository.</error>", $filename));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=4 sw=4 expandtab
|
||||
|
|
@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
|
|
@ -48,36 +49,39 @@ class ListcacheCommand extends Command
|
|||
$outformat = '%-20s %-40s %15s %7d';
|
||||
require_once('inc/inc.DBInit.php');
|
||||
|
||||
$cachedir = $settings->_cacheDir;
|
||||
$totalc = 0;
|
||||
$totalspace = 0;
|
||||
// Preview for png, pdf, and txt */
|
||||
foreach(['png', 'pdf', 'txt'] as $t) {
|
||||
$path = addDirSep($cachedir).$t;
|
||||
if(file_exists($path)) {
|
||||
$space = dskspace($path);
|
||||
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||
$c = iterator_count($fi);
|
||||
} else {
|
||||
$space = $c = 0;
|
||||
}
|
||||
$totalc += $c;
|
||||
$totalspace += $space;
|
||||
$output->writeln(sprintf($outformat, 'preview'.$t, $translator->translate('preview_'.$t), SeedDMS_Core_File::format_filesize($space), $c));
|
||||
}
|
||||
$cachedir = $settings->_cacheDir;
|
||||
$totalc = 0;
|
||||
$totalspace = 0;
|
||||
$tabledata = [];
|
||||
// Preview for png, pdf, and txt */
|
||||
foreach(['png', 'pdf', 'txt'] as $t) {
|
||||
$path = addDirSep($cachedir).$t;
|
||||
if(file_exists($path)) {
|
||||
$space = dskspace($path);
|
||||
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||
$c = iterator_count($fi);
|
||||
} else {
|
||||
$space = $c = 0;
|
||||
}
|
||||
$totalc += $c;
|
||||
$totalspace += $space;
|
||||
// $output->writeln(sprintf($outformat, 'preview'.$t, $translator->translate('preview_'.$t), SeedDMS_Core_File::format_filesize($space), $c));
|
||||
$tabledata[] = ['preview'.$t, $translator->translate('preview_'.$t), SeedDMS_Core_File::format_filesize($space), $c];
|
||||
}
|
||||
|
||||
/* Javascript */
|
||||
$path = addDirSep($cachedir).'js';
|
||||
if(file_exists($path)) {
|
||||
$space = dskspace($path);
|
||||
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||
$c = iterator_count($fi);
|
||||
} else {
|
||||
$space = $c = 0;
|
||||
}
|
||||
$totalc += $c;
|
||||
$totalspace += $space;
|
||||
$output->writeln(sprintf($outformat, 'js', $translator->translate('temp_jscode'), SeedDMS_Core_File::format_filesize($space), $c));
|
||||
/* Javascript */
|
||||
$path = addDirSep($cachedir).'js';
|
||||
if(file_exists($path)) {
|
||||
$space = dskspace($path);
|
||||
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||
$c = iterator_count($fi);
|
||||
} else {
|
||||
$space = $c = 0;
|
||||
}
|
||||
$totalc += $c;
|
||||
$totalspace += $space;
|
||||
// $output->writeln(sprintf($outformat, 'js', $translator->translate('temp_jscode'), SeedDMS_Core_File::format_filesize($space), $c));
|
||||
$tabledata[] = ['js', $translator->translate('temp_jscode'), SeedDMS_Core_File::format_filesize($space), $c];
|
||||
|
||||
$caches = [];
|
||||
/* Create a dummy view for passing it to additionalCache() */
|
||||
|
|
@ -90,8 +94,14 @@ class ListcacheCommand extends Command
|
|||
}
|
||||
}
|
||||
foreach($caches as $cache) {
|
||||
$output->writeln(sprintf($outformat, $cache[0], $cache[1], SeedDMS_Core_File::format_filesize($cache[2]), $cache[3]));
|
||||
// $output->writeln(sprintf($outformat, $cache[0], $cache[1], SeedDMS_Core_File::format_filesize($cache[2]), $cache[3]));
|
||||
$tabledata[] = [$cache[0], $cache[1], SeedDMS_Core_File::format_filesize($cache[2]), $cache[3]];
|
||||
}
|
||||
$table = new Table($output);
|
||||
$table
|
||||
->setHeaders(['Cache', 'Name', 'Size', 'Count'])
|
||||
->setRows($tabledata);
|
||||
$table->render();
|
||||
// print_r($caches);
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ class ListextensionCommand extends Command
|
|||
$enabled = 0;
|
||||
$disabled = 0;
|
||||
$haserror = 0;
|
||||
$extconf = $extmgr->getExtensionConfiguration();
|
||||
foreach ($extconf as $extname=>$extconf) {
|
||||
$extconfs = $extmgr->getExtensionConfiguration();
|
||||
foreach ($extconfs as $extname=>$extconf) {
|
||||
if (!$settings->extensionIsDisabled($extname)) {
|
||||
$enabled++;
|
||||
$output->writeln(sprintf('<ext>'.$outformat.'</ext>', '*', $extname, $extconf['version'], $extconf['releasedate']));
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ class PackageextensionCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this->setName('ext:package')
|
||||
->setDescription('Package extension as a zip file. If --output-dir is given, the zip file will be placed into this directory otherwise it will be saved in the current directory. The name of the zip file will be <extname>-<version>.zip. If such a file already exists, it will be deleted and recreated.')
|
||||
->setHelp('Creates a zip file of an extension, which can be uploaded into SeedDMS.')
|
||||
->setDescription('Package extension as a zip file')
|
||||
->setHelp('Creates a zip file of an extension, which can be uploaded into SeedDMS. If --output-dir is given, the zip file will be placed into this directory otherwise it will be saved in the current directory. The name of the zip file will be <extname>-<version>.zip. If such a file already exists, it will be deleted and recreated.')
|
||||
->addOption('name', '', InputOption::VALUE_REQUIRED, 'Name of extension.', null)
|
||||
->addOption('output-dir', '', InputOption::VALUE_REQUIRED, 'Name of directory where the zip file is saved.', null)
|
||||
;
|
||||
|
|
|
|||
103
utils/Commands/RepositoryextensionCommand.php
Normal file
103
utils/Commands/RepositoryextensionCommand.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
namespace Seeddms\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use SeedDMS_Core_File;
|
||||
use SeedDMS_View_Common;
|
||||
use SeedDMS_Extension_Mgr;
|
||||
use Log_file;
|
||||
|
||||
class RepositoryextensionCommand extends Command
|
||||
{
|
||||
protected $settings;
|
||||
|
||||
protected $logger;
|
||||
|
||||
protected $translator;
|
||||
|
||||
protected $extmgr;
|
||||
|
||||
public function __construct(Settings $settings, Log_file $logger, Translator $translator, SeedDMS_Extension_Mgr $extmgr)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->logger = $logger;
|
||||
$this->translator = $translator;
|
||||
$this->extmgr = $extmgr;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('ext:repository')
|
||||
->setDescription('Get list of extensions from repository')
|
||||
->setHelp('')
|
||||
->addOption('url', '', InputOption::VALUE_REQUIRED, 'Url of repository.', null)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||
{
|
||||
$settings = $this->settings;
|
||||
$logger = $this->logger;
|
||||
$translator = $this->translator;
|
||||
$extmgr = $this->extmgr;
|
||||
|
||||
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
|
||||
|
||||
$reposurl = $input->getOption('url');
|
||||
if($reposurl)
|
||||
$extmgr->setRepositoryUrl($reposurl);
|
||||
|
||||
/* Get a list of available extensions from the repository */
|
||||
if($ret = $extmgr->updateExtensionList('', true)) {
|
||||
// $output->writeln(sprintf("<info>Updated extension list from repository.</info>"));
|
||||
// list of installed extensions
|
||||
$extconfs = $extmgr->getExtensionConfiguration();
|
||||
// list of extensions in repository, this will just return the
|
||||
// latest version of an extension
|
||||
$list = $extmgr->getExtensionList();
|
||||
// print_r($list);
|
||||
$tabledata = [];
|
||||
foreach($list as $extname=>$data) {
|
||||
$extversions = $extmgr->getExtensionListByName($extname);
|
||||
// print_r($extversions);
|
||||
$allowedversions = [];
|
||||
foreach($extversions as $version=>$extversion) {
|
||||
$check = $extmgr->checkExtensionByName($extname, $extversion);
|
||||
if ($check) {
|
||||
$allowedversions[] = '<info>'.$version.'</info>';
|
||||
} else {
|
||||
$allowedversions[] = '<error>'.$version.'</error>';
|
||||
}
|
||||
}
|
||||
$tabledata[$extname] = [
|
||||
$extname,
|
||||
$data['title'],
|
||||
new TableCell(implode("\n", $allowedversions), ['rowspan' => count($allowedversions)]),
|
||||
isset($extconfs[$extname]['version']) ? $extconfs[$extname]['version'] : ''];
|
||||
}
|
||||
$table = new Table($output);
|
||||
$table
|
||||
->setHeaders(['Name', 'Title', 'Rep. ver.', 'Inst. ver.'])
|
||||
->setRows($tabledata);
|
||||
$table->render();
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Could not get extension list from repository.</error>"));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=4 sw=4 expandtab
|
||||
|
|
@ -6,9 +6,13 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
use Symfony\Component\Console\Helper\TableSeparator;
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use SeedDMS_Core_File;
|
||||
use Log_file;
|
||||
|
||||
class StatsCommand extends Command
|
||||
|
|
@ -30,9 +34,9 @@ class StatsCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this->setName('dms:stats')
|
||||
->setDescription('Prints Statistics')
|
||||
->setHelp('Demonstration of custom commands created by Symfony Console component.')
|
||||
->addOption('json', '', InputOption::VALUE_NONE, 'Export data as json')
|
||||
->setDescription('Print statistics')
|
||||
->setHelp('Outputs the number of documents, folders, users, etc. in total and how many of them are owned by they users.')
|
||||
->addOption('json', '', InputOption::VALUE_NONE, 'Print data as json instead of a table')
|
||||
;
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +49,7 @@ class StatsCommand extends Command
|
|||
|
||||
require_once('inc/inc.DBInit.php');
|
||||
foreach (array('docstotal'=>'documents', 'folderstotal'=>'folders', 'userstotal'=>'users', 'groupstotal'=>'groups', 'categoriestotal'=>'categories') as $type=>$name) {
|
||||
$stats[$type] = $dms->getStatisticalData($type);
|
||||
$stats['total'][substr($type, 0, -5)] = $dms->getStatisticalData($type);
|
||||
}
|
||||
foreach (array('docsperuser'=>'documents', 'foldersperuser'=>'folders','sizeperuser'=>'size') as $type=>$name) {
|
||||
$stats[$type] = $dms->getStatisticalData($type);
|
||||
|
|
@ -54,26 +58,49 @@ class StatsCommand extends Command
|
|||
if ($input->getOption('json')) {
|
||||
$output->writeln(json_encode($stats));
|
||||
} else {
|
||||
$outformat = '%-30s %-10d';
|
||||
$output->writeln(sprintf($outformat, 'Documents', $stats['docstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Folders', $stats['folderstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Users', $stats['userstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Groups', $stats['groupstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Categories', $stats['categoriestotal']));
|
||||
$output->writeln('');
|
||||
$output->writeln('Documents per user:');
|
||||
foreach($stats['docsperuser'] as $d) {
|
||||
$output->writeln(sprintf($outformat, $d['key'], $d['total']));
|
||||
}
|
||||
$output->writeln('');
|
||||
$output->writeln('Folders per user:');
|
||||
foreach($stats['foldersperuser'] as $d) {
|
||||
$output->writeln(sprintf($outformat, $d['key'], $d['total']));
|
||||
}
|
||||
$output->writeln('');
|
||||
$output->writeln('Size per user:');
|
||||
foreach($stats['sizeperuser'] as $d) {
|
||||
$output->writeln(sprintf($outformat, $d['key'], $d['total']));
|
||||
if(1) {
|
||||
$table = new Table($output);
|
||||
$table->setHeaders(['Name', 'Count/Size']);
|
||||
foreach($stats['total'] as $k=>$v)
|
||||
$table->addRow([$k, $v]);
|
||||
$table->addRow(new TableSeparator());
|
||||
$table->addRow([new TableCell($translator->translate('chart_docsperuser_title'), ['colspan' => 2])]);
|
||||
$table->addRow(new TableSeparator());
|
||||
foreach($stats['docsperuser'] as $v)
|
||||
$table->addRow([$v['key'], $v['total']]);
|
||||
$table->addRow(new TableSeparator());
|
||||
$table->addRow([new TableCell($translator->translate('chart_foldersperuser_title'), ['colspan' => 2])]);
|
||||
$table->addRow(new TableSeparator());
|
||||
foreach($stats['foldersperuser'] as $v)
|
||||
$table->addRow([$v['key'], $v['total']]);
|
||||
$table->addRow(new TableSeparator());
|
||||
$table->addRow([new TableCell($translator->translate('chart_sizeperuser_title'), ['colspan' => 2])]);
|
||||
$table->addRow(new TableSeparator());
|
||||
foreach($stats['sizeperuser'] as $v)
|
||||
$table->addRow([$v['key'], SeedDMS_Core_File::format_filesize((int)$v['total'])]);
|
||||
$table->render();
|
||||
} else {
|
||||
$outformat = '%-30s %-10d';
|
||||
$output->writeln(sprintf($outformat, 'Documents', $stats['docstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Folders', $stats['folderstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Users', $stats['userstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Groups', $stats['groupstotal']));
|
||||
$output->writeln(sprintf($outformat, 'Categories', $stats['categoriestotal']));
|
||||
$output->writeln('');
|
||||
$output->writeln('Documents per user:');
|
||||
foreach($stats['docsperuser'] as $d) {
|
||||
$output->writeln(sprintf($outformat, $d['key'], $d['total']));
|
||||
}
|
||||
$output->writeln('');
|
||||
$output->writeln('Folders per user:');
|
||||
foreach($stats['foldersperuser'] as $d) {
|
||||
$output->writeln(sprintf($outformat, $d['key'], $d['total']));
|
||||
}
|
||||
$output->writeln('');
|
||||
$output->writeln('Size per user:');
|
||||
foreach($stats['sizeperuser'] as $d) {
|
||||
$output->writeln(sprintf($outformat, $d['key'], $d['total']));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
|
|
|
|||
163
utils/Commands/UpdateextensionCommand.php
Normal file
163
utils/Commands/UpdateextensionCommand.php
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
namespace Seeddms\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use SeedDMS_Core_File;
|
||||
use SeedDMS_View_Common;
|
||||
use SeedDMS_Extension_Mgr;
|
||||
use Log_file;
|
||||
|
||||
class UpdateextensionCommand extends Command
|
||||
{
|
||||
protected $settings;
|
||||
|
||||
protected $logger;
|
||||
|
||||
protected $translator;
|
||||
|
||||
protected $extmgr;
|
||||
|
||||
public function __construct(Settings $settings, Log_file $logger, Translator $translator, SeedDMS_Extension_Mgr $extmgr)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->logger = $logger;
|
||||
$this->translator = $translator;
|
||||
$this->extmgr = $extmgr;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('ext:update')
|
||||
->setDescription('Check for extension upates')
|
||||
->setHelp('')
|
||||
->addOption('url', '', InputOption::VALUE_REQUIRED, 'Url of repository.', null)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||
{
|
||||
$settings = $this->settings;
|
||||
$logger = $this->logger;
|
||||
$translator = $this->translator;
|
||||
$extmgr = $this->extmgr;
|
||||
|
||||
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
|
||||
|
||||
if (!is_writable($settings->_cacheDir)) {
|
||||
$output->writeln(sprintf("<error>The cache dir '%s' is not writable for the system user running this script.</error>", $settings->_cacheDir));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$reposurl = $input->getOption('url');
|
||||
if($reposurl)
|
||||
$extmgr->setRepositoryUrl($reposurl);
|
||||
|
||||
$updates = [];
|
||||
$installs = [];
|
||||
/* Get a list of available extensions from the repository */
|
||||
if($ret = $extmgr->updateExtensionList('', true)) {
|
||||
// list of installed extensions
|
||||
$extconfs = $extmgr->getExtensionConfiguration();
|
||||
// list of extensions in repository, this will just return the
|
||||
// latest version of an extension
|
||||
$list = $extmgr->getExtensionList();
|
||||
foreach($list as $extname=>$data) {
|
||||
$extversions = $extmgr->getExtensionListByName($extname);
|
||||
// $updates[$extname] = [];
|
||||
// $installs[$extname] = [];
|
||||
foreach($extversions as $version=>$extversion) {
|
||||
/* Only version which pass the check will be offered for
|
||||
* update or install.
|
||||
*/
|
||||
$check = $extmgr->checkExtensionByName($extname, $extversion);
|
||||
if ($check) {
|
||||
if (isset($extconfs[$extname])) {
|
||||
if (\Seeddms\Seeddms\ExtensionMgr::cmpVersion($version, $extconfs[$extname]['version']) > 0) {
|
||||
$updates[$extname][$version] = $extversion;
|
||||
}
|
||||
} else {
|
||||
$installs[$extname][$version] = $extversion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$helper = new QuestionHelper();
|
||||
if($updates) {
|
||||
$output->writeln(sprintf("<options=bold>%d extensions can be updated.</>", count($updates)));
|
||||
foreach($updates as $extname=>$update) {
|
||||
$availableversions = array_keys($update);
|
||||
if ($update) {
|
||||
$output->writeln(sprintf("<comment>Extension '%s' can be updated from %s to %s.</comment>", $extname, $extconfs[$extname]['version'], implode(', ', $availableversions)));
|
||||
$question = new Question(sprintf("<question>Enter version to update:</question> "), '');
|
||||
if ($answer = $helper->ask($input, $output, $question)) {
|
||||
if (in_array($answer, $availableversions)) {
|
||||
$output->writeln(sprintf("<info>Update extension '%s' to version %s.</info>", $extname, $answer));
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($update[$answer]['filename'])) {
|
||||
|
||||
if (0&&!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Invalid version %s.</error>", $answer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($installs) {
|
||||
$output->writeln(sprintf("<options=bold>%d extensions can be installed.</>", count($installs)));
|
||||
foreach($installs as $extname=>$install) {
|
||||
$availableversions = array_keys($install);
|
||||
if ($install) {
|
||||
$output->writeln(sprintf("<comment>Extension '%s' can be installed as version %s.</comment>", $extname, implode(', ', $availableversions)));
|
||||
$question = new Question(sprintf("<question>Enter version to install:</question> "), '');
|
||||
if ($answer = $helper->ask($input, $output, $question)) {
|
||||
if (in_array($answer, $availableversions)) {
|
||||
$output->writeln(sprintf("<info>Install extension '%s' to version %s.</info>", $extname, $answer));
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($install[$answer]['filename'])) {
|
||||
|
||||
if (0&&!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Invalid version %s.</error>", $answer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Could not get extension list from repository.</error>"));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=4 sw=4 expandtab
|
||||
78
utils/Commands/UploadextensionCommand.php
Normal file
78
utils/Commands/UploadextensionCommand.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
namespace Seeddms\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
use SeedDMS_Core_File;
|
||||
use SeedDMS_View_Common;
|
||||
use SeedDMS_Extension_Mgr;
|
||||
use Log_file;
|
||||
|
||||
class UploadextensionCommand extends Command
|
||||
{
|
||||
protected $settings;
|
||||
|
||||
protected $logger;
|
||||
|
||||
protected $translator;
|
||||
|
||||
protected $extmgr;
|
||||
|
||||
public function __construct(Settings $settings, Log_file $logger, Translator $translator, SeedDMS_Extension_Mgr $extmgr)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->logger = $logger;
|
||||
$this->translator = $translator;
|
||||
$this->extmgr = $extmgr;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('ext:upload')
|
||||
->setDescription('Upload extension')
|
||||
->setHelp('Uploads an extensions, which replaces an exiting extension or inserts a new extension.')
|
||||
->addOption('file', '', InputOption::VALUE_REQUIRED, 'Filename of zipped extension.', null)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||
{
|
||||
$settings = $this->settings;
|
||||
$logger = $this->logger;
|
||||
$translator = $this->translator;
|
||||
$extmgr = $this->extmgr;
|
||||
|
||||
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
|
||||
/*
|
||||
if (!is_writable($settings->_configFilePath)) {
|
||||
$output->writeln(sprintf("<error>The configuration file '%s' is not writable by the system user running this script.</error>", $settings->_configFilePath));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
*/
|
||||
if (!is_writable($settings->_cacheDir)) {
|
||||
$output->writeln(sprintf("<error>The cache dir '%s' is not writable for the system user running this script.</error>", $settings->_cacheDir));
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$filename = $input->getOption('file');
|
||||
if (!$extmgr->updateExtension($filename)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
}
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=4 sw=4 expandtab
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
// application.php
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
ini_set('include_path', __DIR__.'/../' . PATH_SEPARATOR . ini_get('include_path'));
|
||||
ini_set('include_path', __DIR__.'/../../' . PATH_SEPARATOR . ini_get('include_path'));
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
require_once('Log.php');
|
||||
require_once('inc/inc.Utils.php');
|
||||
|
|
@ -16,14 +16,26 @@ use Seeddms\Console\Commands\ClearcacheCommand;
|
|||
use Seeddms\Console\Commands\ListcacheCommand;
|
||||
use Seeddms\Console\Commands\ListextensionCommand;
|
||||
use Seeddms\Console\Commands\ConfigureextensionCommand;
|
||||
use Seeddms\Console\Commands\UploadextensionCommand;
|
||||
use Seeddms\Console\Commands\PackageextensionCommand;
|
||||
use Seeddms\Console\Commands\ReloadextensionCommand;
|
||||
use Seeddms\Console\Commands\CheckextensionCommand;
|
||||
use Seeddms\Console\Commands\RepositoryextensionCommand;
|
||||
use Seeddms\Console\Commands\UpdateextensionCommand;
|
||||
use Seeddms\Console\Commands\DownloadextensionCommand;
|
||||
use Seeddms\Seeddms\Settings;
|
||||
use Seeddms\Seeddms\Translator;
|
||||
|
||||
$settings = new Settings();
|
||||
/* Check if configuration is at regular place. Otherwise set
|
||||
* SEEDDMS_CONFIG_FILE in your shell.
|
||||
*/
|
||||
if (file_exists(__DIR__.'/../../conf/settings.xml'))
|
||||
$settings = new Settings(__DIR__.'/../../conf/settings.xml');
|
||||
else
|
||||
$settings = new Settings();
|
||||
|
||||
/* For now includce inc.Language.php, because it defines the old
|
||||
* translation functions (e.g. getMLText()), which is still used
|
||||
* translation functions (e.g. getMLText()), which are still used
|
||||
* by many extensions.
|
||||
*/
|
||||
require_once('inc/inc.Language.php');
|
||||
|
|
@ -42,8 +54,13 @@ $application->add(new ClearcacheCommand($settings, $logger, $translator));
|
|||
$application->add(new ListcacheCommand($settings, $logger, $translator));
|
||||
$application->add(new ListextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new ConfigureextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new UploadextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new PackageextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new ReloadextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new CheckextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new RepositoryextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new UpdateextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
$application->add(new DownloadextensionCommand($settings, $logger, $translator, $extmgr));
|
||||
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['console'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['console'] as $hookObj) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
use Seeddms\Seeddms\Utilities;
|
||||
|
||||
class SeedDMS_Theme_Style extends SeedDMS_View_Common {
|
||||
/**
|
||||
|
|
@ -180,7 +181,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
|||
} /* }}} */
|
||||
|
||||
function htmlAddJsHeader($script) { /* {{{ */
|
||||
$nonce = createNonce();
|
||||
$nonce = Utilities::createNonce();
|
||||
$this->nonces[] = $nonce;
|
||||
$this->extraheader['js'] .= '<script type="text/javascript" src="'.$script.'" nonce="'.$nonce.'"></script>'."\n";
|
||||
} /* }}} */
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@
|
|||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include parent class
|
||||
*/
|
||||
//require_once("class.Bootstrap.php");
|
||||
use Seeddms\Seeddms\SessionMgr;
|
||||
|
||||
/**
|
||||
* Class which outputs the html page for clipboard view
|
||||
|
|
@ -44,7 +41,7 @@ class SeedDMS_View_Session extends SeedDMS_Theme_Style {
|
|||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
|
||||
$sessionmgr = new SeedDMS_SessionMgr($dms->getDB());
|
||||
$sessionmgr = new SessionMgr($dms->getDB());
|
||||
/* Get only sessions which has been active in the last 3600 sec. */
|
||||
$sessions = $sessionmgr->getLastAccessedSessions(date('Y-m-d H:i:s', time()-3600));
|
||||
if(!$sessions)
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@
|
|||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include parent class
|
||||
*/
|
||||
//require_once("class.Bootstrap.php");
|
||||
use Seeddms\Seeddms\SessionMgr;
|
||||
|
||||
/**
|
||||
* Class which outputs the html page for UserList view
|
||||
|
|
@ -60,7 +57,7 @@ class SeedDMS_View_UserList extends SeedDMS_Theme_Style {
|
|||
$this->pageNavigation("", "admin_tools");
|
||||
$this->contentHeading(getMLText("user_list"));
|
||||
|
||||
$sessionmgr = new SeedDMS_SessionMgr($dms->getDB());
|
||||
$sessionmgr = new SessionMgr($dms->getDB());
|
||||
?>
|
||||
|
||||
<input type="text" id="myInput" class="form-control" placeholder="<?= getMLText('type_to_filter'); ?>">
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
use Seeddms\Seeddms\SessionMgr;
|
||||
|
||||
/**
|
||||
* Include parent class
|
||||
*/
|
||||
|
|
@ -101,7 +103,7 @@ $(document).ready( function() {
|
|||
$workflowmode = $this->params['workflowmode'];
|
||||
|
||||
if($seluser) {
|
||||
$sessionmgr = new SeedDMS_SessionMgr($dms->getDB());
|
||||
$sessionmgr = new SessionMgr($dms->getDB());
|
||||
|
||||
$this->contentHeading(getMLText("user_info"));
|
||||
echo "<table class=\"table table-condensed table-sm\">\n";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
use Seeddms\Seeddms\Utilities;
|
||||
|
||||
class SeedDMS_Theme_Style extends SeedDMS_View_Common {
|
||||
/**
|
||||
|
|
@ -182,7 +183,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
|||
} /* }}} */
|
||||
|
||||
function htmlAddJsHeader($script) { /* {{{ */
|
||||
$nonce = createNonce();
|
||||
$nonce = Utilities::createNonce();
|
||||
$this->nonces[] = $nonce;
|
||||
$this->extraheader['js'] .= '<script type="text/javascript" src="'.$script.'" nonce="'.$nonce.'"></script>'."\n";
|
||||
} /* }}} */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user