فهرست منبع

updated UserAcl, DBG log

Piotr Labudda 9 سال پیش
والد
کامیت
c30842c24f
5فایلهای تغییر یافته به همراه33 افزوده شده و 19 حذف شده
  1. 1 1
      SE/se-lib/Api/WfsLogger.php
  2. 2 3
      SE/se-lib/Api/WfsQgisServer.php
  3. 6 4
      SE/se-lib/DBG.php
  4. 5 1
      SE/se-lib/ProcesMenu.php
  5. 19 10
      SE/se-lib/UserAcl.php

+ 1 - 1
SE/se-lib/Api/WfsLogger.php

@@ -8,7 +8,7 @@ class Api_WfsLogger {
 	protected $_logFile;
 
 	public function __construct() {
-		$this->_logFile = ('production' == V::get('P5_ENV', 'production', $_SERVER)) ? "/tmp/wfs.log" : "/tmp/wfs-dev.log";
+		$this->_logFile = ('production' == V::get('P5_ENV', 'production', $_SERVER)) ? "/tmp/wfs.log" : "/tmp/dev-wfs.log";
 		if (!is_writable($this->_logFile)) {
 			$fp = @fopen($this->_logFile, "w");
 			if ($fp === false) return;

+ 2 - 3
SE/se-lib/Api/WfsQgisServer.php

@@ -3,6 +3,7 @@
 Lib::loadClass('Api_WfsServerBase');
 Lib::loadClass('Api_WfsException');
 Lib::loadClass('Api_WfsGeomTypeConverter');
+Lib::loadClass('DBG');
 
 class Api_WfsQgisServer extends Api_WfsServerBase {
 
@@ -204,13 +205,11 @@ if($DBG){echo '(geomFld: '.$geomFld.'):';print_r($acl->getFieldType($geomFld));e
 		$idDefaultDB = $db->_zasob_id;
 		$fullTblAclList = $this->_usrAcl->getTablesAcl();
 		foreach ($fullTblAclList as $tblAcl) {
-			$dataSourceName = 'default_db';// TODO: getSourceName
-			$tblName = $tblAcl->getName();
 			if ($idDefaultDB != $tblAcl->getDB()) {// hide non default_db tables
 				continue;
 			}
 			try {
-				$acl = $this->getAclFromTypeName($typeName = "p5_{$dataSourceName}:{$tblName}");
+				$acl = $this->getAclFromTypeName($typeName = "p5_" . $tblAcl->getSourceName() . ":" . $tblAcl->getName());
 			} catch (Exception $e) {
 				// TODO: error log $e->getMessage();
 			}

+ 6 - 4
SE/se-lib/DBG.php

@@ -236,7 +236,8 @@ class DBG {
 		if (!self::isActive()) return;
 		if ('Debug' == V::get('_route', '', $_REQUEST) && !V::get('DBG', '', $_REQUEST)) return;
 		static $_firstRun = true;
-		$logFileName = '/tmp/se-debug-' . implode('-', [
+		$prefix = ('production' == V::get('P5_ENV', 'production', $_SERVER)) ? "" : "dev-";
+		$logFileName = "/tmp/{$prefix}se-debug-" . implode('-', [
 			date("Y-m-d"),
 			User::getLogin(),
 			Request::getUserIp(),
@@ -253,7 +254,8 @@ class DBG {
 	public static function logAuth($mixedArg, $msg = '') {
 		if ('Debug' == V::get('_route', '', $_REQUEST) && !V::get('DBG', '', $_REQUEST)) return;
 		static $_firstRun = true;
-		$logFileName = '/tmp/se-auth-' . implode('-', [
+		$prefix = ('production' == V::get('P5_ENV', 'production', $_SERVER)) ? "" : "dev-";
+		$logFileName = "/tmp/{$prefix}se-auth-" . implode('-', [
 			date("Y-m-d"),
 			Request::getUserIp(),
 			V::get('REQUEST_TIME', '', $_SERVER)// [REQUEST_TIME] => 1485770466
@@ -266,7 +268,6 @@ class DBG {
 		self::_log($mixedArg, $type = 'array', $msg, $logFileName);
 	}
 	public static function _log($mixedArg, $type, $msg, $logFileName) {
-		// * TODO: debug to file based on session_id (/tmp/se-debug-{$date("Y-m-d")}-{$login}_{$ip}_{$session_id}.log)
 		$logInfo = [
 			'date' => date("Y-m-d H:i:s"),
 			'type' => $type,
@@ -329,7 +330,8 @@ class DBG {
 
 	public static function simpleLog($type, $msg) {
 		static $_idRequest = null;
-		$logFileName = "/tmp/se-log-{$type}.tsv.log";
+		$prefix = ('production' == V::get('P5_ENV', 'production', $_SERVER)) ? "" : "dev-";
+		$logFileName = "/tmp/{$prefix}se-log-{$type}.tsv.log";
 		if (null === $_idRequest) {
 			$_idRequest = substr(md5(date("Y-m-d") . Request::getUserIp() . V::get('REQUEST_TIME', '', $_SERVER)), 0, 6);
 			$firstMsg = V::get('REQUEST_METHOD', '', $_SERVER) . " " . V::get('REQUEST_URI', '', $_SERVER);

+ 5 - 1
SE/se-lib/ProcesMenu.php

@@ -27,10 +27,14 @@ class ProcesMenu {
 			$this->_user_id = V::get('_user_id', 0, $_REQUEST, 'int');
 			if (!$this->_user_id) {
 				$this->_user_id = User::getID();
+				$this->_acl = User::getAcl();
+			} else {
+				$this->_acl = UsersHelper::getUserAcl($this->_user_id);
 			}
+		} else {
+			$this->_acl = User::getAcl();
 		}
 
-		$this->_acl = UsersHelper::getUserAcl($this->_user_id);
 		if (!$this->_acl) {
 			die('Error Acl');
 		}

+ 19 - 10
SE/se-lib/UserAcl.php

@@ -6,24 +6,33 @@ Lib::loadClass('ProcesHelper');
 Lib::loadClass('TableAcl');
 Lib::loadClass('SchemaReader');
 Lib::loadClass('SchemaFactory');
+Lib::loadClass('DBG');
 
 class UserAcl {
 
-	var $_user_id;
-	var $_use_cache = false;
+	public $_user_id;
+	public $_use_cache = false;
+	public $_session_id = false;
 	/**
 	 * User groups (cached)
 	 */
-	var $_groups = array();
-	var $_proces_ids = array();
-	var $_proces_tree_flat = array();
-	var $_proces_used_ids = array();
-	var $_proces_used_map = array();
-	var $_proces_init_used_ids = array();
-
-	function __construct($user_id, $use_cache = false) {
+	public $_groups = array();
+	public $_proces_ids = array();
+	public $_proces_tree_flat = array();
+	public $_proces_used_ids = array();
+	public $_proces_used_map = array();
+	public $_proces_init_used_ids = array();
+
+	function __construct($user_id, $use_cache = false, $session_id = null) {
 		$this->_user_id = $user_id;
 		$this->_use_cache = $use_cache;
+		$this->_session_id = (null !== $session_id) ? $session_id : session_id();
+		DBG::simpleLog('auth', "UserAcl::__construct {{$user_id}, {$this->_session_id}}");
+		// try {
+		// 	throw new Exception("Error Processing Request");
+		// } catch (Exception $e) {
+		// 	DBG::simpleLog('auth', "UserAcl::__construct {{$user_id}, {$this->_session_id}} trace:" . "\n" . $e->getTraceAsString());
+		// }
 
 		$this->_cache_init();
 	}