XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
xoopskernel.php
Go to the documentation of this file.
1 <?php
22 defined('XOOPS_ROOT_PATH') or die('Restricted access');
23 
25 {
26  var $paths = array('XOOPS' => array(), 'www' => array(), 'var' => array(), 'lib' => array(), 'modules' => array(), 'themes' => array());
27 
31  function xos_kernel_Xoops2()
32  {
33  $this->paths['XOOPS'] = array(XOOPS_PATH, XOOPS_URL . 'browse.php');
34  $this->paths['www'] = array(XOOPS_ROOT_PATH, XOOPS_URL);
35  $this->paths['var'] = array(XOOPS_VAR_PATH, null);
36  $this->paths['lib'] = array(XOOPS_PATH, XOOPS_URL . 'browse.php');
37  $this->paths['modules'] = array(XOOPS_ROOT_PATH . '/modules', XOOPS_URL . '/modules');
38  $this->paths['themes'] = array(XOOPS_ROOT_PATH . '/themes', XOOPS_URL . '/themes');
39  }
40 
44  function path($url, $virtual = false)
45  {
46  // removed , $error_type = E_USER_WARNING
47  $path = '';
48  @list($root, $path) = explode('/', $url, 2);
49  if (!isset($this->paths[$root])) {
50  list($root, $path) = array('www', $url);
51  }
52  if (!$virtual) { // Returns a physical path
53  $path = $this->paths[$root][0] . '/' . $path;
54  $path = str_replace('/', DS, $path);
55  return $path;
56  }
57  return !isset($this->paths[$root][1] ) ? '' : ($this->paths[$root][1] . '/' . $path);
58  }
59 
63  function url($url )
64  {
65  return (false !== strpos($url, '://') ? $url : $this->path($url, true));
66  }
67 
71  function buildUrl( $url, $params = array() )
72  {
73  if ($url == '.') {
74  $url = $_SERVER['REQUEST_URI'];
75  }
76  $split = explode('?', $url);
77  if (count($split) > 1) {
78  list($url, $query) = $split;
79  parse_str($query, $query);
80  $params = array_merge($query, $params);
81  }
82  if (!empty($params)) {
83  foreach ($params as $k => $v) {
84  $params[$k] = $k . '=' . rawurlencode($v);
85  }
86  $url .= '?' . implode('&', $params);
87  }
88  return $url;
89  }
90 
96  function pathExists($path, $error_type)
97  {
98  if (file_exists($path)) {
99  return $path;
100  } else {
101  $GLOBALS['xoopsLogger']->triggerError($path, _XO_ER_FILENOTFOUND, __FILE__, __LINE__, $error_type);
102  return false;
103  }
104  }
105 
111  function gzipCompression()
112  {
116  if (empty($_SERVER['SERVER_NAME']) || substr(PHP_SAPI, 0, 3) == 'cli') {
117  xoops_setConfigOption('gzip_compression', 0);
118  }
119 
120  if (xoops_getConfigOption('gzip_compression') == 1 && extension_loaded('zlib') && !ini_get( 'zlib.output_compression')) {
121  if (@ini_get('zlib.output_compression_level') < 0) {
122  ini_set('zlib.output_compression_level', 6);
123  }
124  ob_start('ob_gzhandler');
125  }
126  }
127 
133  function pathTranslation()
134  {
139  if (!isset($_SERVER['PATH_TRANSLATED']) && isset($_SERVER['SCRIPT_FILENAME'])) {
140  $_SERVER['PATH_TRANSLATED'] =& $_SERVER['SCRIPT_FILENAME']; // For Apache CGI
141  } else if (isset($_SERVER['PATH_TRANSLATED']) && !isset($_SERVER['SCRIPT_FILENAME'])) {
142  $_SERVER['SCRIPT_FILENAME'] =& $_SERVER['PATH_TRANSLATED']; // For IIS/2K now I think :-(
143  }
147  if (empty($_SERVER['REQUEST_URI'])) { // Not defined by IIS
148  // Under some configs, IIS makes SCRIPT_NAME point to php.exe :-(
149  if (!($_SERVER['REQUEST_URI'] = @$_SERVER['PHP_SELF'])) {
150  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
151  }
152  if (isset( $_SERVER['QUERY_STRING'])) {
153  $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
154  }
155  }
156  }
157 
163  function themeSelect()
164  {
165  if (!empty($_POST['xoops_theme_select'] ) && in_array($_POST['xoops_theme_select'], xoops_getConfigOption('theme_set_allowed'))) {
166  xoops_setConfigOption('theme_set', $_POST['xoops_theme_select']);
167  $_SESSION['xoopsUserTheme'] = $_POST['xoops_theme_select'];
168  } else if (!empty($_SESSION['xoopsUserTheme']) && in_array($_SESSION['xoopsUserTheme'], xoops_getConfigOption('theme_set_allowed'))) {
169  xoops_setConfigOption('theme_set', $_SESSION['xoopsUserTheme']);
170  }
171  }
172 }
173 
174 ?>