Changeset 810
- Timestamp:
- Mar 4, 2024 12:30:57 AM (8 weeks ago)
- Location:
- trunk/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r805 r810 288 288 * 289 289 * @access public 290 * @param array $param Array of parameters (key => val pairs). 291 */ 292 public function setParam($param=null) 293 { 294 if (isset($param) && is_array($param)) { 295 // Merge new parameters with old overriding old ones that are passed. 296 $this->_params = array_merge($this->_params, $param); 297 298 if ($this->running) { 299 // Params that require additional processing if set during runtime. 300 foreach ($param as $key => $val) { 301 switch ($key) { 302 case 'namespace': 303 $this->logMsg(sprintf('Setting namespace not allowed', null), LOG_WARNING, __FILE__, __LINE__); 304 return false; 305 306 case 'session_name': 307 session_name($val); 308 return true; 309 310 case 'session_use_cookies': 311 if (session_status() !== PHP_SESSION_ACTIVE) { 312 ini_set('session.use_cookies', $val); 313 } else { 314 $this->logMsg('Unable to set session_use_cookies; session is already active', LOG_NOTICE, __FILE__, __LINE__); 315 } 316 return true; 317 318 case 'error_reporting': 319 ini_set('error_reporting', $val); 320 return true; 321 322 case 'display_errors': 323 ini_set('display_errors', $val); 324 return true; 325 326 case 'log_errors': 327 ini_set('log_errors', true); 328 return true; 329 330 case 'log_directory': 331 if (is_dir($val) && is_writable($val)) { 332 ini_set('error_log', $val . '/' . $this->getParam('php_error_log')); 333 } 334 return true; 290 * @param array $params Array of parameters (key => val pairs). 291 */ 292 public function setParam(Array $params) 293 { 294 if (!isset($params) || !is_array($params)) { 295 trigger_error(sprintf('%s failed; not an array: %s', __METHOD__, getDump($params, false, SC_DUMP_PRINT_R)), E_USER_ERROR); 296 } 297 298 // Merge new parameters with old overriding old ones that are passed. 299 $this->_params = array_merge($this->_params, $params); 300 301 if ($this->running) { 302 // Params that require additional processing if set during runtime. 303 foreach ($params as $key => $val) { 304 switch ($key) { 305 case 'namespace': 306 $this->logMsg(sprintf('Setting namespace not allowed', null), LOG_WARNING, __FILE__, __LINE__); 307 break; 308 309 case 'session_name': 310 session_name($val); 311 break; 312 313 case 'session_use_cookies': 314 if (session_status() !== PHP_SESSION_ACTIVE) { 315 ini_set('session.use_cookies', $val); 316 } else { 317 $this->logMsg('Unable to set session_use_cookies; session is already active', LOG_NOTICE, __FILE__, __LINE__); 335 318 } 319 break; 320 321 case 'error_reporting': 322 ini_set('error_reporting', $val); 323 break; 324 325 case 'php_timezone': 326 // Set timezone used by PHP. 327 $this->setTimezone($val); 328 break; 329 330 case 'db_timezone': 331 // Set timezone used by MySQL. 332 if (true === $this->getParam('enable_db_pdo')) { 333 $this->pdo->setParam(['timezone' => $val]); 334 } 335 if (true === $this->getParam('enable_db')) { 336 $this->db->setParam(['timezone' => $val]); 337 } 338 break; 339 340 case 'display_errors': 341 ini_set('display_errors', $val); 342 break; 343 344 case 'log_errors': 345 ini_set('log_errors', true); 346 break; 347 348 case 'log_directory': 349 if (is_dir($val) && is_writable($val)) { 350 ini_set('error_log', $val . '/' . $this->getParam('php_error_log')); 351 } 352 break; 336 353 } 337 354 } -
trunk/lib/DB.inc.php
r724 r810 119 119 * @param array $params Array of parameters (key => val pairs). 120 120 */ 121 public function setParam($params) 122 { 123 $app =& App::getInstance(); 124 125 if (isset($params) && is_array($params)) { 126 // Merge new parameters with old overriding only those passed. 127 $this->_params = array_merge($this->_params, $params); 128 } else { 129 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 121 public function setParam(Array $params) 122 { 123 if (!isset($params) || !is_array($params)) { 124 trigger_error(sprintf('%s failed; not an array: %s', __METHOD__, getDump($params, false, SC_DUMP_PRINT_R)), E_USER_ERROR); 125 } 126 127 // Merge new parameters with old overriding only those passed. 128 $this->_params = array_merge($this->_params, $params); 129 130 if ($this->isConnected()) { 131 // Params that require additional processing if set during runtime. 132 foreach ($params as $key => $val) { 133 switch ($key) { 134 case 'timezone': 135 // Set timezone used by MySQL. 136 $this->query(sprintf("SET time_zone = '%s';", $this->escapeString($val))); 137 break; 138 } 139 } 130 140 } 131 141 } -
trunk/lib/Email.inc.php
r776 r810 104 104 * @since 28 Nov 2005 12:59:41 105 105 */ 106 public function __construct( $params=null)106 public function __construct(Array $params=[]) 107 107 { 108 108 $app =& App::getInstance(); -
trunk/lib/Navigation.inc.php
r691 r810 55 55 * Navigation constructor. 56 56 */ 57 public function __construct( $params=null)57 public function __construct(Array $params=[]) 58 58 { 59 59 $app =& App::getInstance(); -
trunk/lib/PDO.inc.php
r747 r810 103 103 * @param string $params Configuration parameters for this object. 104 104 */ 105 public function __construct( $params=null)105 public function __construct(Array $params=[]) 106 106 { 107 107 // Set custom parameters. … … 131 131 * @param array $params Array of param keys and values to set. 132 132 */ 133 public function setParam($params=null) 134 { 135 if (isset($params) && is_array($params)) { 136 // Merge new parameters with old overriding only those passed. 137 $this->_params = array_merge($this->_params, $params); 133 public function setParam(Array $params) 134 { 135 if (!isset($params) || !is_array($params)) { 136 trigger_error(sprintf('%s failed; not an array: %s', __METHOD__, getDump($params, false, SC_DUMP_PRINT_R)), E_USER_ERROR); 137 } 138 139 // Merge new parameters with old overriding only those passed. 140 $this->_params = array_merge($this->_params, $params); 141 142 if ($this->isConnected()) { 143 // Params that require additional processing if set during runtime. 144 foreach ($params as $key => $val) { 145 switch ($key) { 146 case 'timezone': 147 // Set timezone used by MySQL. 148 $this->query(sprintf("SET time_zone = %s;", $this->quote($val))); 149 break; 150 } 151 } 138 152 } 139 153 }
Note: See TracChangeset
for help on using the changeset viewer.