Annotation of /mambo/branches/4.6/administrator/includes/admin.php
Parent Directory
|
Revision Log
Revision 129 - (view) (download)
| 1 : | mambo | 117 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: admin.php,v 1.1 2005/07/22 01:53:54 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | /** | ||
| 14 : | csouza | 129 | * Basic XML parsing of installation files |
| 15 : | ***/ | ||
| 16 : | |||
| 17 : | class mosBasicXML { | ||
| 18 : | var $opentags = array(); | ||
| 19 : | var $opencount; | ||
| 20 : | var $accept = array(); | ||
| 21 : | var $mosinstall = false; | ||
| 22 : | var $type; | ||
| 23 : | var $terminalError = false; | ||
| 24 : | var $errors = array(); | ||
| 25 : | |||
| 26 : | function mosBasicXML ($file) { | ||
| 27 : | //echo $file.'<br />'; | ||
| 28 : | $this->setTree(); | ||
| 29 : | $parser = xml_parser_create(); | ||
| 30 : | $startfunc = array ($this, 'start_element'); | ||
| 31 : | $endfunc = array ($this, 'end_element'); | ||
| 32 : | $charfunc = array ($this, 'character_data'); | ||
| 33 : | xml_set_element_handler ($parser, $startfunc, $endfunc); | ||
| 34 : | xml_set_character_data_handler ($parser, $charfunc); | ||
| 35 : | $fp = fopen($file, 'rb'); | ||
| 36 : | while ($data = fread($fp, 4096) AND !$this->terminalError) { | ||
| 37 : | $data = str_replace('&', ' ampersand ', $data); | ||
| 38 : | $ret = xml_parse($parser, $data, feof($fp)) or die (sprintf('XML ERROR: %s at line %d', | ||
| 39 : | xml_error_string(xml_get_error_code($parser)), | ||
| 40 : | xml_get_current_line_number($parser))); | ||
| 41 : | } | ||
| 42 : | if (count($this->opentags) != 0) { | ||
| 43 : | $tags = implode (', ', $this->opentags); | ||
| 44 : | trigger_error ("XML error - unclosed tag(s) ($tags) at end of file"); | ||
| 45 : | } | ||
| 46 : | xml_parser_free($parser); | ||
| 47 : | if (count($this->errors)) var_dump ($this->errors); | ||
| 48 : | } | ||
| 49 : | |||
| 50 : | function setTree () { | ||
| 51 : | $this->accept['MOSINSTALL'] = array ('NAME', 'CREATIONDATE', 'AUTHOR', 'COPYRIGHT', | ||
| 52 : | 'LICENSE', 'AUTHOREMAIL', 'AUTHORURL', 'VERSION', 'DESCRIPTION', 'FILES', 'GROUP', | ||
| 53 : | 'PARAMS', 'INSTALL', 'UNINSTALL', 'INSTALLFILE', 'UNINSTALLFILE', 'ADMINISTRATION', | ||
| 54 : | 'IMAGES', 'CSS'); | ||
| 55 : | $this->accept['PARAMS'] = array ('PARAM'); | ||
| 56 : | $this->accept['PARAM'] = array ('OPTION'); | ||
| 57 : | $this->accept['FILES'] = array ('FILENAME'); | ||
| 58 : | $this->accept['INSTALL'] = array ('QUERIES'); | ||
| 59 : | $this->accept['UNINSTALL'] = array ('QUERIES'); | ||
| 60 : | $this->accept['QUERIES'] = array ('QUERY'); | ||
| 61 : | $this->accept['ADMINISTRATION'] = array ('FILES', 'IMAGES', 'MENU'); | ||
| 62 : | $this->accept['IMAGES'] = array ('FILENAME'); | ||
| 63 : | $this->accept['MENU'] = array ('SUBMENU'); | ||
| 64 : | $this->accept['SUBMENU'] = array('MENU'); | ||
| 65 : | $this->accept['CSS'] = array('FILENAME'); | ||
| 66 : | } | ||
| 67 : | |||
| 68 : | function start_element ($parser, $element_name, $element_attrs) { | ||
| 69 : | if ($this->terminalError) return; | ||
| 70 : | $method = 'element_'.$element_name; | ||
| 71 : | $specific = array ($this, $method); | ||
| 72 : | if (is_callable($specific)) $this->$method($element_attrs); | ||
| 73 : | if ($this->mosinstall) { | ||
| 74 : | $container = $this->opentags[0]; | ||
| 75 : | if (!isset($this->accept[$container]) OR !is_array($this->accept[$container])) trigger_error ("XML error $container is not a valid containing element"); | ||
| 76 : | if (!in_array($element_name, $this->accept[$container])) trigger_error ("XML error $element_name not permitted within $container"); | ||
| 77 : | } | ||
| 78 : | if ($this->mosinstall OR $element_name == 'MOSINSTALL') { | ||
| 79 : | $this->opencount = array_unshift ($this->opentags, $element_name); | ||
| 80 : | $setdata = array ($this, 'set_data'); | ||
| 81 : | if (is_callable($setdata)) $this->set_data($element_attrs); | ||
| 82 : | $this->mosinstall = true; | ||
| 83 : | } | ||
| 84 : | else trigger_error ("XML expected MOSINSTALL but found $element_name"); | ||
| 85 : | // echo '<br />Start of '.$element_name; | ||
| 86 : | } | ||
| 87 : | |||
| 88 : | function end_element ($parser, $element_name) { | ||
| 89 : | if ($this->terminalError) return; | ||
| 90 : | $check = array_shift ($this->opentags); | ||
| 91 : | if ($check != $element_name) { | ||
| 92 : | $this->opencount = array_unshift ($this->opentags, $check); | ||
| 93 : | trigger_error("XML last open tag was $check, but found end of $element_name"); | ||
| 94 : | } | ||
| 95 : | else $this->opencount--; | ||
| 96 : | // echo '<br />End of '.$element_name; | ||
| 97 : | } | ||
| 98 : | |||
| 99 : | function character_data ($parser, $data) { | ||
| 100 : | // Should be overridden by inheriting class | ||
| 101 : | $this->errors[] = 'XML handler error - no method provided to deal with character data'; | ||
| 102 : | $this->terminalError = true; | ||
| 103 : | } | ||
| 104 : | |||
| 105 : | function element_mosinstall ($attrs) { | ||
| 106 : | if (isset($attrs['TYPE'])) $this->type = $attrs['TYPE']; | ||
| 107 : | else trigger_error ("XML error - mosinstall does not have type attribute"); | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | function getType () { | ||
| 111 : | return $this->type; | ||
| 112 : | } | ||
| 113 : | |||
| 114 : | } | ||
| 115 : | |||
| 116 : | /** | ||
| 117 : | * Extend basic parser to extract the description for a type of install file | ||
| 118 : | **/ | ||
| 119 : | |||
| 120 : | class mosXMLDescription extends mosBasicXML { | ||
| 121 : | var $values = array(); | ||
| 122 : | |||
| 123 : | function character_data ($parser, $data) { | ||
| 124 : | if ($this->terminalError) return; | ||
| 125 : | $data = trim($data); | ||
| 126 : | if ($data) { | ||
| 127 : | if (isset($this->opentags[1]) AND $this->opentags[1] == 'MOSINSTALL') $this->values[$this->opentags[0]] = $data; | ||
| 128 : | } | ||
| 129 : | } | ||
| 130 : | |||
| 131 : | function getDescription ($type) { | ||
| 132 : | if ($type == $this->type AND isset($this->values['DESCRIPTION'])) return $this->values['DESCRIPTION']; | ||
| 133 : | else return ''; | ||
| 134 : | } | ||
| 135 : | |||
| 136 : | function getName ($type) { | ||
| 137 : | if ($type == $this->type AND isset($this->values['NAME'])) return $this->values['NAME']; | ||
| 138 : | else return ''; | ||
| 139 : | } | ||
| 140 : | |||
| 141 : | function getGroup ($type) { | ||
| 142 : | if ($type == $this->type AND isset($this->values['GROUP'])) return $this->values['GROUP']; | ||
| 143 : | else return ''; | ||
| 144 : | } | ||
| 145 : | |||
| 146 : | function getCreationDate ($type) { | ||
| 147 : | if ($type == $this->type AND isset($this->values['CREATIONDATE'])) return $this->values['CREATIONDATE']; | ||
| 148 : | else return ''; | ||
| 149 : | } | ||
| 150 : | |||
| 151 : | function getAuthor ($type) { | ||
| 152 : | if ($type == $this->type AND isset($this->values['AUTHOR'])) return $this->values['AUTHOR']; | ||
| 153 : | else return ''; | ||
| 154 : | } | ||
| 155 : | |||
| 156 : | function getCopyright ($type) { | ||
| 157 : | if ($type == $this->type AND isset($this->values['COPYRIGHT'])) return $this->values['COPYRIGHT']; | ||
| 158 : | else return ''; | ||
| 159 : | } | ||
| 160 : | |||
| 161 : | function getAuthorEmail ($type) { | ||
| 162 : | if ($type == $this->type AND isset($this->values['AUTHOREMAIL'])) return $this->values['AUTHOREMAIL']; | ||
| 163 : | else return ''; | ||
| 164 : | } | ||
| 165 : | |||
| 166 : | function getAuthorUrl ($type) { | ||
| 167 : | if ($type == $this->type AND isset($this->values['AUTHORURL'])) return $this->values['AUTHORURL']; | ||
| 168 : | else return ''; | ||
| 169 : | } | ||
| 170 : | |||
| 171 : | function getVersion ($type) { | ||
| 172 : | if ($type == $this->type AND isset($this->values['VERSION'])) return $this->values['VERSION']; | ||
| 173 : | else return ''; | ||
| 174 : | } | ||
| 175 : | |||
| 176 : | } | ||
| 177 : | |||
| 178 : | /** | ||
| 179 : | mambo | 117 | * @param string THe template position |
| 180 : | */ | ||
| 181 : | function mosCountAdminModules( $position='left' ) { | ||
| 182 : | global $database, $my, $Itemid; | ||
| 183 : | |||
| 184 : | $query = "SELECT COUNT(m.id)" | ||
| 185 : | . "\nFROM #__modules AS m" | ||
| 186 : | . "\nWHERE m.published='1' AND m.position='$position' AND m.client_id='1'"; | ||
| 187 : | |||
| 188 : | $database->setQuery( $query ); | ||
| 189 : | return $database->loadResult(); | ||
| 190 : | } | ||
| 191 : | /** | ||
| 192 : | * Loads admin modules via module position | ||
| 193 : | * @param string The position | ||
| 194 : | * @param int 0 = no style, 1 = tabbed | ||
| 195 : | */ | ||
| 196 : | function mosLoadAdminModules( $position='left', $style=0 ) { | ||
| 197 : | global $database, $my, $acl; | ||
| 198 : | |||
| 199 : | $cache =& mosCache::getCache( 'com_content' ); | ||
| 200 : | |||
| 201 : | $query = "SELECT id, title, module, position, content, showtitle, params" | ||
| 202 : | . "\n FROM #__modules AS m" | ||
| 203 : | . "\n WHERE m.published = '1'" | ||
| 204 : | . "\n AND m.position='$position'" | ||
| 205 : | . "\n AND (m.client_id = 1)" | ||
| 206 : | . "\n ORDER BY m.ordering"; | ||
| 207 : | |||
| 208 : | $database->setQuery( $query ); | ||
| 209 : | $modules = $database->loadObjectList(); | ||
| 210 : | if($database->getErrorNum()) { | ||
| 211 : | echo "MA ".$database->stderr(true); | ||
| 212 : | return; | ||
| 213 : | } | ||
| 214 : | if (!$modules) $modules = array(); | ||
| 215 : | |||
| 216 : | switch ($style) { | ||
| 217 : | case 0: | ||
| 218 : | default: | ||
| 219 : | foreach ($modules as $module) { | ||
| 220 : | $params =& new mosParameters( $module->params ); | ||
| 221 : | if ( $module->module == '' ) { | ||
| 222 : | mosLoadCustomModule( $module, $params ); | ||
| 223 : | } else { | ||
| 224 : | mosLoadAdminModule( substr( $module->module, 4 ), $params ); | ||
| 225 : | } | ||
| 226 : | } | ||
| 227 : | break; | ||
| 228 : | |||
| 229 : | case 1: | ||
| 230 : | // Tabs | ||
| 231 : | $tabs = new mosTabs(1); | ||
| 232 : | $tabs->startPane( 'modules-' . $position ); | ||
| 233 : | foreach ($modules as $module) { | ||
| 234 : | $params =& new mosParameters( $module->params ); | ||
| 235 : | $editAllComponents = $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' ); | ||
| 236 : | // $authoriser = new mosAuthoriser($database); | ||
| 237 : | // $editAllComponents = $authoriser->checkPermission('mosUser', $my->id, 'edit', 'editAllComponents', 0); | ||
| 238 : | // special handling for components module | ||
| 239 : | if ( $module->module != 'mod_components' || ( $module->module == 'mod_components' && $editAllComponents ) ) { | ||
| 240 : | $tabs->startTab( $module->title, 'module' . $module->id ); | ||
| 241 : | if ( $module->module == '' ) { | ||
| 242 : | mosLoadCustomModule( $module, $params ); | ||
| 243 : | } else { | ||
| 244 : | mosLoadAdminModule( substr( $module->module, 4 ), $params ); | ||
| 245 : | } | ||
| 246 : | $tabs->endTab(); | ||
| 247 : | } | ||
| 248 : | } | ||
| 249 : | $tabs->endPane(); | ||
| 250 : | break; | ||
| 251 : | |||
| 252 : | case 2: | ||
| 253 : | // Div'd | ||
| 254 : | foreach ($modules as $module) { | ||
| 255 : | $params =& new mosParameters( $module->params ); | ||
| 256 : | echo '<div>'; | ||
| 257 : | if ( $module->module == '' ) { | ||
| 258 : | mosLoadCustomModule( $module, $params ); | ||
| 259 : | } else { | ||
| 260 : | mosLoadAdminModule( substr( $module->module, 4 ), $params ); | ||
| 261 : | } | ||
| 262 : | echo '</div>'; | ||
| 263 : | } | ||
| 264 : | break; | ||
| 265 : | } | ||
| 266 : | } | ||
| 267 : | /** | ||
| 268 : | * Loads an admin module | ||
| 269 : | */ | ||
| 270 : | function mosLoadAdminModule( $name, $params=NULL ) { | ||
| 271 : | global $mosConfig_absolute_path, $mosConfig_live_site; | ||
| 272 : | global $database, $my, $mainframe, $option, $acl; | ||
| 273 : | |||
| 274 : | $task = mosGetParam( $_REQUEST, 'task', '' ); | ||
| 275 : | // legacy support for $act | ||
| 276 : | $act = mosGetParam( $_REQUEST, 'act', '' ); | ||
| 277 : | |||
| 278 : | $name = str_replace( '/', '', $name ); | ||
| 279 : | $name = str_replace( '\\', '', $name ); | ||
| 280 : | $path = "$mosConfig_absolute_path/administrator/modules/mod_$name.php"; | ||
| 281 : | if (file_exists( $path )) { | ||
| 282 : | require $path; | ||
| 283 : | } | ||
| 284 : | } | ||
| 285 : | |||
| 286 : | function mosLoadCustomModule( &$module, &$params ) { | ||
| 287 : | global $mosConfig_absolute_path; | ||
| 288 : | |||
| 289 : | $rssurl = $params->get( 'rssurl', '' ); | ||
| 290 : | $rssitems = $params->get( 'rssitems', '' ); | ||
| 291 : | $rssdesc = $params->get( 'rssdesc', '' ); | ||
| 292 : | $moduleclass_sfx = $params->get( 'moduleclass_sfx', '' ); | ||
| 293 : | |||
| 294 : | echo '<table cellpadding="0" cellspacing="0" class="moduletable' . $moduleclass_sfx . '">'; | ||
| 295 : | |||
| 296 : | if ($module->content) { | ||
| 297 : | echo '<tr>'; | ||
| 298 : | echo '<td>' . $module->content . '</td>'; | ||
| 299 : | echo '</tr>'; | ||
| 300 : | } | ||
| 301 : | |||
| 302 : | // feed output | ||
| 303 : | if ( $rssurl ) { | ||
| 304 : | $cacheDir = $mosConfig_absolute_path .'/cache/'; | ||
| 305 : | if (!is_writable( $cacheDir )) { | ||
| 306 : | echo '<tr>'; | ||
| 307 : | echo '<td>Please make cache directory writable.</td>'; | ||
| 308 : | echo '</tr>'; | ||
| 309 : | } else { | ||
| 310 : | $LitePath = $mosConfig_absolute_path .'/includes/Cache/Lite.php'; | ||
| 311 : | require_once( $mosConfig_absolute_path .'/includes/domit/xml_domit_rss_lite.php'); | ||
| 312 : | $rssDoc =& new xml_domit_rss_document_lite(); | ||
| 313 : | $rssDoc->useCacheLite(true, $LitePath, $cacheDir, 3600); | ||
| 314 : | $rssDoc->loadRSS( $rssurl ); | ||
| 315 : | $totalChannels = $rssDoc->getChannelCount(); | ||
| 316 : | |||
| 317 : | for ($i = 0; $i < $totalChannels; $i++) { | ||
| 318 : | $currChannel =& $rssDoc->getChannel($i); | ||
| 319 : | echo '<tr>'; | ||
| 320 : | echo '<td><strong><a href="'. $currChannel->getLink() .'" target="_child">'; | ||
| 321 : | echo $currChannel->getTitle() .'</a></strong></td>'; | ||
| 322 : | echo '</tr>'; | ||
| 323 : | if ($rssdesc) { | ||
| 324 : | echo '<tr>'; | ||
| 325 : | echo '<td>'. $currChannel->getDescription() .'</td>'; | ||
| 326 : | echo '</tr>'; | ||
| 327 : | } | ||
| 328 : | |||
| 329 : | $actualItems = $currChannel->getItemCount(); | ||
| 330 : | $setItems = $rssitems; | ||
| 331 : | |||
| 332 : | if ($setItems > $actualItems) { | ||
| 333 : | $totalItems = $actualItems; | ||
| 334 : | } else { | ||
| 335 : | $totalItems = $setItems; | ||
| 336 : | } | ||
| 337 : | |||
| 338 : | for ($j = 0; $j < $totalItems; $j++) { | ||
| 339 : | $currItem =& $currChannel->getItem($j); | ||
| 340 : | |||
| 341 : | echo '<tr>'; | ||
| 342 : | echo '<td><strong><a href="'. $currItem->getLink() .'" target="_child">'; | ||
| 343 : | echo $currItem->getTitle() .'</a></strong> - '. $currItem->getDescription() .'</td>'; | ||
| 344 : | echo '</tr>'; | ||
| 345 : | } | ||
| 346 : | } | ||
| 347 : | } | ||
| 348 : | } | ||
| 349 : | echo '</table>'; | ||
| 350 : | } | ||
| 351 : | |||
| 352 : | function mosShowSource( $filename, $withLineNums=false ) { | ||
| 353 : | ini_set('highlight.html', '000000'); | ||
| 354 : | ini_set('highlight.default', '#800000'); | ||
| 355 : | ini_set('highlight.keyword','#0000ff'); | ||
| 356 : | ini_set('highlight.string', '#ff00ff'); | ||
| 357 : | ini_set('highlight.comment','#008000'); | ||
| 358 : | |||
| 359 : | if (!($source = @highlight_file( $filename, true ))) { | ||
| 360 : | return 'Operation Failed'; | ||
| 361 : | } | ||
| 362 : | $source = explode("<br />", $source); | ||
| 363 : | |||
| 364 : | $ln = 1; | ||
| 365 : | |||
| 366 : | $txt = ''; | ||
| 367 : | foreach( $source as $line ) { | ||
| 368 : | $txt .= "<code>"; | ||
| 369 : | if ($withLineNums) { | ||
| 370 : | $txt .= "<font color=\"#aaaaaa\">"; | ||
| 371 : | $txt .= str_replace( ' ', ' ', sprintf( "%4d:", $ln ) ); | ||
| 372 : | $txt .= "</font>"; | ||
| 373 : | } | ||
| 374 : | $txt .= "$line<br /><code>"; | ||
| 375 : | $ln++; | ||
| 376 : | } | ||
| 377 : | return $txt; | ||
| 378 : | } | ||
| 379 : | |||
| 380 : | function mosIsChmodable($file) | ||
| 381 : | { | ||
| 382 : | $perms = fileperms($file); | ||
| 383 : | if ($perms !== FALSE) | ||
| 384 : | if (@chmod($file, $perms ^ 0001)) { | ||
| 385 : | @chmod($file, $perms); | ||
| 386 : | return TRUE; | ||
| 387 : | } // if | ||
| 388 : | return FALSE; | ||
| 389 : | } // mosIsChmodable | ||
| 390 : | |||
| 391 : | /** | ||
| 392 : | * @param string An existing base path | ||
| 393 : | * @param string A path to create from the base path | ||
| 394 : | * @param int Directory permissions | ||
| 395 : | * @return boolean True if successful | ||
| 396 : | */ | ||
| 397 : | function mosMakePath($base, $path='', $mode = NULL) | ||
| 398 : | { | ||
| 399 : | global $mosConfig_dirperms; | ||
| 400 : | |||
| 401 : | // convert windows paths | ||
| 402 : | $path = str_replace( '\\', '/', $path ); | ||
| 403 : | $path = str_replace( '//', '/', $path ); | ||
| 404 : | |||
| 405 : | // check if dir exists | ||
| 406 : | if (file_exists( $base . $path )) return true; | ||
| 407 : | |||
| 408 : | // set mode | ||
| 409 : | $origmask = NULL; | ||
| 410 : | if (isset($mode)) { | ||
| 411 : | $origmask = @umask(0); | ||
| 412 : | } else { | ||
| 413 : | if ($mosConfig_dirperms=='') { | ||
| 414 : | // rely on umask | ||
| 415 : | $mode = 0777; | ||
| 416 : | } else { | ||
| 417 : | $origmask = @umask(0); | ||
| 418 : | $mode = octdec($mosConfig_dirperms); | ||
| 419 : | } // if | ||
| 420 : | } // if | ||
| 421 : | |||
| 422 : | $parts = explode( '/', $path ); | ||
| 423 : | $n = count( $parts ); | ||
| 424 : | $ret = true; | ||
| 425 : | if ($n < 1) { | ||
| 426 : | $ret = @mkdir($base, $mode); | ||
| 427 : | } else { | ||
| 428 : | $path = $base; | ||
| 429 : | for ($i = 0; $i < $n; $i++) { | ||
| 430 : | $path .= $parts[$i] . '/'; | ||
| 431 : | if (!file_exists( $path )) { | ||
| 432 : | if (!@mkdir( $path, $mode )) { | ||
| 433 : | $ret = false; | ||
| 434 : | break; | ||
| 435 : | } | ||
| 436 : | } | ||
| 437 : | } | ||
| 438 : | } | ||
| 439 : | if (isset($origmask)) @umask($origmask); | ||
| 440 : | return $ret; | ||
| 441 : | } | ||
| 442 : | |||
| 443 : | function &checkAdminSession (&$database) { | ||
| 444 : | // restore some session variables | ||
| 445 : | $my = new mosUser( $database ); | ||
| 446 : | $my->id = mosGetParam( $_SESSION, 'session_user_id', '' ); | ||
| 447 : | $my->username = mosGetParam( $_SESSION, 'session_username', '' ); | ||
| 448 : | $my->usertype = mosGetParam( $_SESSION, 'session_usertype', '' ); | ||
| 449 : | $my->gid = mosGetParam( $_SESSION, 'session_gid', '' ); | ||
| 450 : | |||
| 451 : | $session_id = mosGetParam( $_SESSION, 'session_id', '' ); | ||
| 452 : | $logintime = mosGetParam( $_SESSION, 'session_logintime', '' ); | ||
| 453 : | |||
| 454 : | // check against db record of session | ||
| 455 : | if ($session_id == md5( $my->id.$my->username.$my->usertype.$logintime )) { | ||
| 456 : | $database->setQuery( "SELECT * FROM #__session" | ||
| 457 : | . "\nWHERE session_id='$session_id'" | ||
| 458 : | . " AND username = '" . $database->getEscaped( $my->username ) . "'" | ||
| 459 : | . " AND userid = " . intval( $my->id ) | ||
| 460 : | ); | ||
| 461 : | if (!$result = $database->query()) { | ||
| 462 : | echo $database->stderr(); | ||
| 463 : | } | ||
| 464 : | if ($database->getNumRows( $result ) <> 1) $my = null; | ||
| 465 : | } | ||
| 466 : | else $my = null; | ||
| 467 : | |||
| 468 : | if ($my) { | ||
| 469 : | // update session timestamp | ||
| 470 : | $current_time = time(); | ||
| 471 : | $database->setQuery("UPDATE #__session SET time='$current_time' WHERE session_id='$session_id'"); | ||
| 472 : | $database->query(); | ||
| 473 : | // timeout old sessions | ||
| 474 : | $past = time()-1800; | ||
| 475 : | $database->setQuery( "DELETE FROM #__session WHERE time < '$past'" ); | ||
| 476 : | $database->query(); | ||
| 477 : | } | ||
| 478 : | return $my; | ||
| 479 : | } | ||
| 480 : | |||
| 481 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

