mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	unified checking for settings.xml and accessing dms
This commit is contained in:
		
							parent
							
								
									a75fe94d95
								
							
						
					
					
						commit
						4e3922627b
					
				|  | @ -63,6 +63,8 @@ if(isset($options['v']) || isset($options['verѕion'])) { | |||
| /* Set alternative config file */ | ||||
| if(isset($options['config'])) { | ||||
| 	define('SEEDDMS_CONFIG_FILE', $options['config']); | ||||
| } elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) { | ||||
| 	define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']); | ||||
| } | ||||
| 
 | ||||
| /* Set parent folder or document */ | ||||
|  | @ -368,4 +370,3 @@ if($folder) { | |||
| 		exit(1); | ||||
| 	} | ||||
| } | ||||
| ?>
 | ||||
|  |  | |||
|  | @ -1,5 +1,11 @@ | |||
| <?php | ||||
| include("../inc/inc.ClassSettings.php"); | ||||
| if(isset($_SERVER['SEEDDMS_HOME'])) { | ||||
| 	ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = $_SERVER['SEEDDMS_HOME']; | ||||
| } else { | ||||
| 	ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = dirname($argv[0]); | ||||
| } | ||||
| 
 | ||||
| function usage() { /* {{{ */ | ||||
| 	echo "Usage:\n"; | ||||
|  | @ -12,6 +18,7 @@ function usage() { /* {{{ */ | |||
| 	echo "  -h, --help: print usage information and exit.\n"; | ||||
| 	echo "  -v, --version: print version and exit.\n"; | ||||
| 	echo "  --config: set alternative config file.\n"; | ||||
| 	echo "  -u <user>: login name of user\n"; | ||||
| 	echo "  -F <parent id>: id of parent folder\n"; | ||||
| 	echo "  -c <comment>: set comment for file\n"; | ||||
| 	echo "  -n <name>: set name of the folder\n"; | ||||
|  | @ -19,7 +26,7 @@ function usage() { /* {{{ */ | |||
| } /* }}} */ | ||||
| 
 | ||||
| $version = "0.0.1"; | ||||
| $shortoptions = "F:c:s:n:hv"; | ||||
| $shortoptions = "F:u:c:s:n:hv"; | ||||
| $longoptions = array('help', 'version', 'config:'); | ||||
| if(false === ($options = getopt($shortoptions, $longoptions))) { | ||||
| 	usage(); | ||||
|  | @ -40,16 +47,11 @@ if(isset($options['v']) || isset($options['verѕion'])) { | |||
| 
 | ||||
| /* Set alternative config file */ | ||||
| if(isset($options['config'])) { | ||||
| 	$settings = new Settings($options['config']); | ||||
| } else { | ||||
| 	$settings = new Settings(); | ||||
| 	define('SEEDDMS_CONFIG_FILE', $options['config']); | ||||
| } elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) { | ||||
| 	define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']); | ||||
| } | ||||
| 
 | ||||
| if(isset($settings->_extraPath)) | ||||
| 	ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); | ||||
| 
 | ||||
| require_once("SeedDMS/Core.php"); | ||||
| 
 | ||||
| if(isset($options['F'])) { | ||||
| 	$folderid = (int) $options['F']; | ||||
| } else { | ||||
|  | @ -58,6 +60,11 @@ if(isset($options['F'])) { | |||
| 	exit(1); | ||||
| } | ||||
| 
 | ||||
| $username = ''; | ||||
| if(isset($options['u'])) { | ||||
| 	$username = $options['u']; | ||||
| } | ||||
| 
 | ||||
| $comment = ''; | ||||
| if(isset($options['c'])) { | ||||
| 	$comment = $options['c']; | ||||
|  | @ -73,23 +80,49 @@ if(isset($options['n'])) { | |||
| 	$name = $options['n']; | ||||
| } | ||||
| 
 | ||||
| $db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase); | ||||
| $db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\""); | ||||
| //$db->_conn->debug = 1;
 | ||||
| include($myincpath."/inc/inc.Settings.php"); | ||||
| include($myincpath."/inc/inc.Init.php"); | ||||
| include($myincpath."/inc/inc.Extension.php"); | ||||
| include($myincpath."/inc/inc.DBInit.php"); | ||||
| include($myincpath."/inc/inc.ClassNotificationService.php"); | ||||
| include($myincpath."/inc/inc.ClassEmailNotify.php"); | ||||
| include($myincpath."/inc/inc.ClassController.php"); | ||||
| 
 | ||||
| $dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir); | ||||
| if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) { | ||||
| 	echo "Database update needed."; | ||||
| 	exit; | ||||
| /* Create a global user object {{{ */ | ||||
| if($username) { | ||||
| 	if(!($user = $dms->getUserByLogin($username))) { | ||||
| 		echo "No such user '".$username."'."; | ||||
| 		exit; | ||||
| 	} | ||||
| } else | ||||
| 	$user = $dms->getUser(1); | ||||
| 
 | ||||
| $dms->setUser($user); | ||||
| /* }}} */ | ||||
| 
 | ||||
| /* Create a global notifier object {{{ */ | ||||
| $notifier = new SeedDMS_NotificationService(); | ||||
| 
 | ||||
| if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) { | ||||
| 	foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) { | ||||
| 		if(method_exists($notificationObj, 'preAddService')) { | ||||
| 			$notificationObj->preAddService($dms, $notifier); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| $dms->setRootFolderID($settings->_rootFolderID); | ||||
| $dms->setMaxDirID($settings->_maxDirID); | ||||
| $dms->setEnableConverting($settings->_enableConverting); | ||||
| $dms->setViewOnlineFileTypes($settings->_viewOnlineFileTypes); | ||||
| if($settings->_enableEmail) { | ||||
| 	$notifier->addService(new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword)); | ||||
| } | ||||
| 
 | ||||
| /* Create a global user object */ | ||||
| $user = $dms->getUser(1); | ||||
| if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) { | ||||
| 	foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) { | ||||
| 		if(method_exists($notificationObj, 'postAddService')) { | ||||
| 			$notificationObj->postAddService($dms, $notifier); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| /* }}} */ | ||||
| 
 | ||||
| $folder = $dms->getFolder($folderid); | ||||
| 
 | ||||
|  | @ -108,11 +141,41 @@ if (!is_numeric($sequence)) { | |||
| 	exit(1); | ||||
| } | ||||
| 
 | ||||
| $res = $folder->addSubFolder($name, $comment, $user, $sequence); | ||||
| $controller = Controller::factory('AddSubFolder', array('dms'=>$dms, 'user'=>$user)); | ||||
| $controller->setParam('folder', $folder); | ||||
| $controller->setParam('name', $name); | ||||
| $controller->setParam('comment', $comment); | ||||
| $controller->setParam('sequence', $sequence); | ||||
| $controller->setParam('attributes', array()); | ||||
| $controller->setParam('notificationgroups', array()); | ||||
| $controller->setParam('notificationusers', array()); | ||||
| if(!$subFolder = $controller->run()) { | ||||
| 	echo "Could not add subfolder to folder\n"; | ||||
| } else { | ||||
| 	// Send notification to subscribers.
 | ||||
| 	if($notifier) { | ||||
| 		$fnl = $folder->getNotifyList(); | ||||
| 		$snl = $subFolder->getNotifyList(); | ||||
| 		$nl = array( | ||||
| 			'users'=>array_unique(array_merge($snl['users'], $fnl['users']), SORT_REGULAR), | ||||
| 			'groups'=>array_unique(array_merge($snl['groups'], $fnl['groups']), SORT_REGULAR) | ||||
| 		); | ||||
| 
 | ||||
| if (is_bool($res) && !$res) { | ||||
| 	echo "Could not add folder\n"; | ||||
| 	exit(1); | ||||
| 		$subject = "new_subfolder_email_subject"; | ||||
| 		$message = "new_subfolder_email_body"; | ||||
| 		$params = array(); | ||||
| 		$params['name'] = $subFolder->getName(); | ||||
| 		$params['folder_name'] = $folder->getName(); | ||||
| 		$params['folder_path'] = $folder->getFolderPathPlain(); | ||||
| 		$params['username'] = $user->getFullName(); | ||||
| 		$params['comment'] = $comment; | ||||
| 		$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$subFolder->getID(); | ||||
| 		$params['sitename'] = $settings->_siteName; | ||||
| 		$params['http_root'] = $settings->_httpRoot; | ||||
| 		$notifier->toList($user, $nl["users"], $subject, $message, $params); | ||||
| 		foreach ($nl["groups"] as $grp) { | ||||
| 			$notifier->toGroup($user, $grp, $subject, $message, $params); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| ?>
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,8 +1,10 @@ | |||
| <?php | ||||
| if(isset($_SERVER['SEEDDMS_HOME'])) { | ||||
| 	require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php"); | ||||
| 	ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = $_SERVER['SEEDDMS_HOME']; | ||||
| } else { | ||||
| 	require_once("../inc/inc.ClassSettings.php"); | ||||
| 	ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = dirname($argv[0]); | ||||
| } | ||||
| 
 | ||||
| function usage() { /* {{{ */ | ||||
|  | @ -41,9 +43,9 @@ if(isset($options['v']) || isset($options['verѕion'])) { | |||
| 
 | ||||
| /* Set alternative config file */ | ||||
| if(isset($options['config'])) { | ||||
| 	$settings = new Settings($options['config']); | ||||
| } else { | ||||
| 	$settings = new Settings(); | ||||
| 	define('SEEDDMS_CONFIG_FILE', $options['config']); | ||||
| } elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) { | ||||
| 	define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']); | ||||
| } | ||||
| 
 | ||||
| /* recreate index */ | ||||
|  | @ -52,14 +54,10 @@ if(isset($options['c'])) { | |||
| 	$recreate = true; | ||||
| } | ||||
| 
 | ||||
| if(isset($settings->_extraPath)) | ||||
| 	ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); | ||||
| //ini_set('include_path', $settings->_rootDir. PATH_SEPARATOR .ini_get('include_path'));
 | ||||
| 
 | ||||
| require_once("inc/inc.Init.php"); | ||||
| require_once("inc/inc.Extension.php"); | ||||
| require_once("inc/inc.DBInit.php"); | ||||
| require "vendor/autoload.php"; | ||||
| include($myincpath."/inc/inc.Settings.php"); | ||||
| include($myincpath."/inc/inc.Init.php"); | ||||
| include($myincpath."/inc/inc.Extension.php"); | ||||
| include($myincpath."/inc/inc.DBInit.php"); | ||||
| 
 | ||||
| if($settings->_fullSearchEngine == 'sqlitefts') { | ||||
| 	$indexconf = array( | ||||
|  | @ -164,4 +162,3 @@ tree($dms, $index, $indexconf, $folder); | |||
| 
 | ||||
| $index->commit(); | ||||
| $index->optimize(); | ||||
| ?>
 | ||||
|  |  | |||
|  | @ -1,8 +1,10 @@ | |||
| <?php | ||||
| if(isset($_SERVER['SEEDDMS_HOME'])) { | ||||
| 	require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php"); | ||||
| 	ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = $_SERVER['SEEDDMS_HOME']; | ||||
| } else { | ||||
| 	require_once("../inc/inc.ClassSettings.php"); | ||||
| 	ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = dirname($argv[0]); | ||||
| } | ||||
| 
 | ||||
| function usage() { /* {{{ */ | ||||
|  | @ -54,9 +56,9 @@ if(isset($options['v']) || isset($options['verѕion'])) { | |||
| 
 | ||||
| /* Set alternative config file */ | ||||
| if(isset($options['config'])) { | ||||
| 	$settings = new Settings($options['config']); | ||||
| } else { | ||||
| 	$settings = new Settings(); | ||||
| 	define('SEEDDMS_CONFIG_FILE', $options['config']); | ||||
| } elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) { | ||||
| 	define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']); | ||||
| } | ||||
| 
 | ||||
| /* Set maximum size of files included in xml file */ | ||||
|  | @ -85,11 +87,6 @@ if(isset($options['sections'])) { | |||
| 	$sections = explode(',', $options['sections']); | ||||
| } | ||||
| 
 | ||||
| if(isset($settings->_extraPath)) | ||||
| 	ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); | ||||
| 
 | ||||
| require_once("SeedDMS/Core.php"); | ||||
| 
 | ||||
| if(isset($options['folder'])) { | ||||
| 	$folderid = intval($options['folder']); | ||||
| } else { | ||||
|  | @ -462,16 +459,10 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 	} | ||||
| } /* }}} */ | ||||
| 
 | ||||
| $db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase); | ||||
| $db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\""); | ||||
| 
 | ||||
| $dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir); | ||||
| if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) { | ||||
| 	echo "Database update needed."; | ||||
| 	exit; | ||||
| } | ||||
| 
 | ||||
| $dms->setRootFolderID($settings->_rootFolderID); | ||||
| include($myincpath."/inc/inc.Settings.php"); | ||||
| include($myincpath."/inc/inc.Init.php"); | ||||
| include($myincpath."/inc/inc.Extension.php"); | ||||
| include($myincpath."/inc/inc.DBInit.php"); | ||||
| 
 | ||||
| echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; | ||||
| echo "<dms dbversion=\"".implode('.', array_slice($dms->getDBVersion(), 1, 3))."\" date=\"".date('Y-m-d H:i:s')."\">\n"; | ||||
|  |  | |||
|  | @ -1,10 +1,11 @@ | |||
| <?php | ||||
| if(isset($_SERVER['SEEDDMS_HOME'])) { | ||||
| 	require_once($_SERVER['SEEDDMS_HOME']."/inc/inc.ClassSettings.php"); | ||||
| 	ini_set('include_path', $_SERVER['SEEDDMS_HOME'].'/utils'. PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = $_SERVER['SEEDDMS_HOME']; | ||||
| } else { | ||||
| 	require_once("../inc/inc.ClassSettings.php"); | ||||
| 	ini_set('include_path', dirname($argv[0]). PATH_SEPARATOR .ini_get('include_path')); | ||||
| 	$myincpath = dirname($argv[0]); | ||||
| } | ||||
| require("Log.php"); | ||||
| 
 | ||||
| function usage() { /* {{{ */ | ||||
| 	echo "Usage:\n"; | ||||
|  | @ -1621,12 +1622,6 @@ if(isset($options['v']) || isset($options['verѕion'])) { | |||
| 	exit(0); | ||||
| } | ||||
| 
 | ||||
| $logfile = "xmlimport.log"; | ||||
| $logconf = array(); | ||||
| $logconf['timeformat'] = '%Y-%m-%d %H:%M:%S'; | ||||
| $logconf['lineFormat'] = '%{timestamp} %{priority} xmlimport: %{ident} %{message}'; | ||||
| $logger = Log::factory('file', $logfile, '', $logconf); | ||||
| 
 | ||||
| /* Check for debug mode */ | ||||
| $debug = false; | ||||
| if(isset($options['debug'])) { | ||||
|  | @ -1635,11 +1630,22 @@ if(isset($options['debug'])) { | |||
| 
 | ||||
| /* Set alternative config file */ | ||||
| if(isset($options['config'])) { | ||||
| 	$settings = new Settings($options['config']); | ||||
| } else { | ||||
| 	$settings = new Settings(); | ||||
| 	define('SEEDDMS_CONFIG_FILE', $options['config']); | ||||
| } elseif(isset($_SERVER['SEEDDMS_CONFIG_FILE'])) { | ||||
| 	define('SEEDDMS_CONFIG_FILE', $_SERVER['SEEDDMS_CONFIG_FILE']); | ||||
| } | ||||
| 
 | ||||
| include($myincpath."/inc/inc.Settings.php"); | ||||
| include($myincpath."/inc/inc.Init.php"); | ||||
| include($myincpath."/inc/inc.Extension.php"); | ||||
| include($myincpath."/inc/inc.DBInit.php"); | ||||
| 
 | ||||
| $logfile = "xmlimport.log"; | ||||
| $logconf = array(); | ||||
| $logconf['timeformat'] = '%Y-%m-%d %H:%M:%S'; | ||||
| $logconf['lineFormat'] = '%{timestamp} %{priority} xmlimport: %{ident} %{message}'; | ||||
| $logger = Log::factory('file', $logfile, '', $logconf); | ||||
| 
 | ||||
| if(isset($options['folder'])) { | ||||
| 	$folderid = intval($options['folder']); | ||||
| } else { | ||||
|  | @ -1765,4 +1771,3 @@ if($exportmapping) { | |||
| 		$logger->err("Could not open mapping file '".$exportmapping."'"); | ||||
| 	} | ||||
| } | ||||
| ?>
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann