Annotation of /mambo/branches/4.6/includes/mambo.php
Parent Directory
|
Revision Log
Revision 117 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: mambo.php,v 1.14 2005/11/14 21:56:04 eliasan Exp $ | ||
| 4 : | csouza | 39 | * @package Mambo With admin Language Pack for 4.5.3 by datahellas |
| 5 : | root | 1 | * @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 : | |||
| 11 : | mambo | 117 | class mosAuthoriser { |
| 12 : | var $connection = ''; | ||
| 13 : | var $perm_found; | ||
| 14 : | var $permissions = array(); | ||
| 15 : | var $assignments = array(); | ||
| 16 : | root | 1 | |
| 17 : | mambo | 117 | function mosAuthoriser () { |
| 18 : | $this->connection =& mamboDatabase::getInstance(); | ||
| 19 : | } | ||
| 20 : | root | 1 | |
| 21 : | mambo | 117 | <<<<<<< .mine |
| 22 : | root | 1 | @set_magic_quotes_runtime( 0 ); |
| 23 : | |||
| 24 : | if (@$mosConfig_error_reporting === 0) { | ||
| 25 : | error_reporting( 0 ); | ||
| 26 : | } else if (@$mosConfig_error_reporting > 0) { | ||
| 27 : | error_reporting( $mosConfig_error_reporting ); | ||
| 28 : | } | ||
| 29 : | |||
| 30 : | $local_backup_path = $mosConfig_absolute_path.'/administrator/backups'; | ||
| 31 : | $media_path = $mosConfig_absolute_path.'/media/'; | ||
| 32 : | $image_path = $mosConfig_absolute_path.'/images/stories'; | ||
| 33 : | $image_size = 100; | ||
| 34 : | |||
| 35 : | csouza | 39 | require_once( $mosConfig_absolute_path . "/includes/version.php" ); |
| 36 : | require_once( $mosConfig_absolute_path . "/includes/database.php" ); | ||
| 37 : | require_once( $mosConfig_absolute_path . "/includes/gacl.class.php" ); | ||
| 38 : | require_once( $mosConfig_absolute_path . "/includes/gacl_api.class.php" ); | ||
| 39 : | require_once( $mosConfig_absolute_path . "/includes/phpmailer/class.phpmailer.php" ); | ||
| 40 : | require_once( $mosConfig_absolute_path . "/includes/mamboxml.php" ); | ||
| 41 : | require_once( $mosConfig_absolute_path . "/includes/phpInputFilter/class.inputfilter.php" ); | ||
| 42 : | root | 1 | |
| 43 : | /** | ||
| 44 : | * Task routing class | ||
| 45 : | * @package Mambo | ||
| 46 : | * @abstract | ||
| 47 : | */ | ||
| 48 : | class mosAbstractTasker { | ||
| 49 : | /** @var array An array of the class methods to call for a task */ | ||
| 50 : | var $taskMap = null; | ||
| 51 : | /** @var string The name of the default task */ | ||
| 52 : | var $defaultTask = null; | ||
| 53 : | /** @var string The name of the current task*/ | ||
| 54 : | var $task = null; | ||
| 55 : | /** @var array An array of the class methods*/ | ||
| 56 : | var $_methods = null; | ||
| 57 : | /** @var string A url to redirect to */ | ||
| 58 : | var $_redirect = null; | ||
| 59 : | /** @var string A message about the operation of the task */ | ||
| 60 : | var $_message = null; | ||
| 61 : | |||
| 62 : | /** | ||
| 63 : | * Constructor | ||
| 64 : | */ | ||
| 65 : | function mosAbstractTasker() { | ||
| 66 : | $taskMap = array(); | ||
| 67 : | $this->_methods = array(); | ||
| 68 : | foreach (get_class_methods( get_class( $this ) ) as $method) { | ||
| 69 : | $this->_methods[] = strtolower( $method ); | ||
| 70 : | mambo | 117 | ======= |
| 71 : | function &getInstance () { | ||
| 72 : | static $instance; | ||
| 73 : | if (!is_object($instance)) { | ||
| 74 : | $instance =& new mosAuthoriser(); | ||
| 75 : | root | 1 | |
| 76 : | |||
| 77 : | |||
| 78 : | |||
| 79 : | |||
| 80 : | |||
| 81 : | |||
| 82 : | mambo | 117 | |
| 83 : | |||
| 84 : | |||
| 85 : | |||
| 86 : | |||
| 87 : | |||
| 88 : | |||
| 89 : | |||
| 90 : | |||
| 91 : | |||
| 92 : | |||
| 93 : | |||
| 94 : | |||
| 95 : | |||
| 96 : | |||
| 97 : | |||
| 98 : | |||
| 99 : | |||
| 100 : | |||
| 101 : | |||
| 102 : | |||
| 103 : | |||
| 104 : | |||
| 105 : | |||
| 106 : | |||
| 107 : | |||
| 108 : | |||
| 109 : | |||
| 110 : | |||
| 111 : | |||
| 112 : | |||
| 113 : | |||
| 114 : | |||
| 115 : | |||
| 116 : | |||
| 117 : | |||
| 118 : | |||
| 119 : | >>>>>>> .theirs | ||
| 120 : | root | 1 | } |
| 121 : | mambo | 117 | return $instance; |
| 122 : | root | 1 | } |
| 123 : | mambo | 117 | |
| 124 : | function doSQL ($sql) { | ||
| 125 : | $this->connection->setQuery($sql); | ||
| 126 : | if (!$this->connection->query()) { | ||
| 127 : | echo "<script> alert('".$this->connection->getErrorMsg()."'); window.history.go(-1); </script>\n"; | ||
| 128 : | exit(); | ||
| 129 : | root | 1 | } |
| 130 : | } | ||
| 131 : | mambo | 117 | |
| 132 : | function getAccessorData ($type, $id) { | ||
| 133 : | if (isset($this->perm_found[$type][$id])) return; | ||
| 134 : | $sql = "SELECT a.*, p.control, p.action, p.subject_type, p.subject_id, p.system FROM #__assignments AS a LEFT JOIN #__permissions AS p ON p.role=a.role WHERE a.access_type='$type'"; | ||
| 135 : | if (isset($this->perm_found[$type])) $sql .= " AND a.access_id='$id'"; | ||
| 136 : | else $sql .= " AND (a.access_id='$id' OR a.access_id='*' OR a.access_id='+')"; | ||
| 137 : | $this->doSQL($sql); | ||
| 138 : | $new_permissions = $this->connection->loadObjectList(); | ||
| 139 : | if ($new_permissions) $this->permissions = array_merge($this->permissions, $new_permissions); | ||
| 140 : | $this->perm_found[$type][$id] = 1; | ||
| 141 : | root | 1 | } |
| 142 : | mambo | 117 | |
| 143 : | function &getRoles ($type, $id) { | ||
| 144 : | $this->getAccessorData ($type, $id); | ||
| 145 : | $rolenames = array(); | ||
| 146 : | foreach ($this->permissions as $role) { | ||
| 147 : | if (strcasecmp($role->access_type, $type) == 0 | ||
| 148 : | AND ($role->access_id == $id OR $role->access_id == '*' OR ($role->access_id == '+' AND $id != 0)) | ||
| 149 : | AND !in_array($role->role,$rolenames)) $rolenames[] = $role->role; | ||
| 150 : | root | 1 | } |
| 151 : | mambo | 117 | return $rolenames; |
| 152 : | } | ||
| 153 : | root | 1 | |
| 154 : | mambo | 117 | function accessorPermissionOrControl ($mask, $a_type, $a_id, $action, $s_type='*', $s_id='*') { |
| 155 : | $this->getAccessorData ($a_type, $a_id); | ||
| 156 : | foreach ($this->permissions as $permission) { | ||
| 157 : | if ((strcasecmp($permission->access_type,$a_type) == 0 OR $permission->access_type == '*') | ||
| 158 : | AND (strcasecmp($permission->access_id,$a_id) == 0 OR $permission->access_id == '*') | ||
| 159 : | AND (strcasecmp($permission->action,$action)==0 OR $permission->action == '*' OR $action == '*') | ||
| 160 : | AND (strcasecmp($permission->subject_type,$s_type)==0 OR $s_type=='*') | ||
| 161 : | AND (strcasecmp($permission->subject_id,$s_id)==0 OR $permission->subject_id == '*') | ||
| 162 : | AND ($permission->control&$mask)) return 1; | ||
| 163 : | root | 1 | } |
| 164 : | mambo | 117 | return 0; |
| 165 : | root | 1 | } |
| 166 : | mambo | 117 | |
| 167 : | function checkPermission ($a_type, $a_id, $action, $s_type='*', $s_id='*') { | ||
| 168 : | return $this->accessorPermissionOrControl(2, $a_type, $a_id, $action, $s_type='*', $s_id='*'); | ||
| 169 : | root | 1 | } |
| 170 : | mambo | 117 | |
| 171 : | function checkControl ($a_type, $a_id, $action, $s_type='*', $s_id='*') { | ||
| 172 : | return $this->accessorPermissionOrControl(1, $a_type, $a_id, $action, $s_type='*', $s_id='*'); | ||
| 173 : | root | 1 | } |
| 174 : | mambo | 117 | |
| 175 : | function checkGrant ($a_type, $a_id, $action, $s_type='*', $s_id='*') { | ||
| 176 : | return $this->accessorPermissionOrControl(4, $a_type, $a_id, $action, $s_type='*', $s_id='*'); | ||
| 177 : | root | 1 | } |
| 178 : | |||
| 179 : | mambo | 117 | function rolePermissionOrControl ($mask, $role, $action, $s_type, $s_id) { |
| 180 : | $sql = "SELECT * FROM #__permissions WHERE role='$role'"; | ||
| 181 : | $this->connection->setQuery($sql); | ||
| 182 : | $permissions = $this->connection->loadObjectList(); | ||
| 183 : | if ($permissions) { | ||
| 184 : | foreach ($permissions as $permission) { | ||
| 185 : | if (strcasecmp($permission->role,$role) == 0 | ||
| 186 : | AND (strcasecmp($permission->action,$action)==0 OR $permission->action == '*') | ||
| 187 : | AND (strcasecmp($permission->subject_type,$s_type)==0) | ||
| 188 : | AND (strcasecmp($permission->subject_id,$s_id)==0 OR $permission->subject_id == '*') | ||
| 189 : | AND ($permission->control&$mask)) return 1; | ||
| 190 : | root | 1 | } |
| 191 : | } | ||
| 192 : | mambo | 117 | return 0; |
| 193 : | root | 1 | } |
| 194 : | mambo | 117 | |
| 195 : | function checkRolePermission ($role, $action, $s_type, $s_id) { | ||
| 196 : | return $this->rolePermissionOrControl(2, $role, $action, $s_type, $s_id); | ||
| 197 : | root | 1 | } |
| 198 : | |||
| 199 : | mambo | 117 | function checkRoleControl ($role, $action, $s_type, $s_id) { |
| 200 : | return $this->rolePermissionOrControl(1, $role, $action, $s_type, $s_id); | ||
| 201 : | } | ||
| 202 : | |||
| 203 : | <<<<<<< .mine | ||
| 204 : | root | 1 | $sessionCookieName = md5( 'site'.$GLOBALS['mosConfig_live_site'] ); |
| 205 : | csouza | 39 | |
| 206 : | root | 1 | $sessioncookie = mosGetParam( $_COOKIE, $sessionCookieName, null ); |
| 207 : | $usercookie = mosGetParam( $_COOKIE, 'usercookie', null ); | ||
| 208 : | |||
| 209 : | if ($session->load( md5( $sessioncookie . $_SERVER['REMOTE_ADDR'] ) )) { | ||
| 210 : | // Session cookie exists, update time in session table | ||
| 211 : | $session->time = time(); | ||
| 212 : | $session->update(); | ||
| 213 : | } else { | ||
| 214 : | $session->generateId(); | ||
| 215 : | $session->guest = 1; | ||
| 216 : | $session->username = ''; | ||
| 217 : | $session->time = time(); | ||
| 218 : | $session->gid = 0; | ||
| 219 : | |||
| 220 : | if (!$session->insert()) { | ||
| 221 : | die( $session->getError() ); | ||
| 222 : | } | ||
| 223 : | |||
| 224 : | setcookie( $sessionCookieName, $session->getCookie(), time() + 43200, '/' ); | ||
| 225 : | //$_COOKIE["sessioncookie"] = $session->getCookie(); | ||
| 226 : | |||
| 227 : | if ($usercookie) { | ||
| 228 : | // Remember me cookie exists. Login with usercookie info. | ||
| 229 : | $this->login($usercookie['username'], $usercookie['password']); | ||
| 230 : | } | ||
| 231 : | } | ||
| 232 : | mambo | 117 | ======= |
| 233 : | function checkRoleGrant ($role, $action, $s_type, $s_id) { | ||
| 234 : | return $this->rolePermissionOrControl(4, $role, $action, $s_type, $s_id); | ||
| 235 : | |||
| 236 : | |||
| 237 : | |||
| 238 : | |||
| 239 : | |||
| 240 : | |||
| 241 : | |||
| 242 : | |||
| 243 : | |||
| 244 : | |||
| 245 : | |||
| 246 : | |||
| 247 : | |||
| 248 : | |||
| 249 : | |||
| 250 : | |||
| 251 : | |||
| 252 : | |||
| 253 : | |||
| 254 : | |||
| 255 : | |||
| 256 : | |||
| 257 : | |||
| 258 : | |||
| 259 : | |||
| 260 : | |||
| 261 : | >>>>>>> .theirs | ||
| 262 : | root | 1 | } |
| 263 : | |||
| 264 : | mambo | 117 | <<<<<<< .mine |
| 265 : | root | 1 | /** |
| 266 : | * Login validation function | ||
| 267 : | * | ||
| 268 : | * Username and encoded password is compare to db entries in the mos_users | ||
| 269 : | * table. A successful validation updates the current session record with | ||
| 270 : | * the users details. | ||
| 271 : | */ | ||
| 272 : | function login( $username=null,$passwd=null ) { | ||
| 273 : | global $acl; | ||
| 274 : | |||
| 275 : | $usercookie = mosGetParam( $_COOKIE, 'usercookie', '' ); | ||
| 276 : | $sessioncookie = mosGetParam( $_COOKIE, 'sessioncookie', '' ); | ||
| 277 : | if (!$username || !$passwd) { | ||
| 278 : | $username = trim( mosGetParam( $_POST, 'username', '' ) ); | ||
| 279 : | $passwd = trim( mosGetParam( $_POST, 'passwd', '' ) ); | ||
| 280 : | $passwd = md5( $passwd ); | ||
| 281 : | $bypost = 1; | ||
| 282 : | } | ||
| 283 : | $remember = trim( mosGetParam( $_POST, 'remember', '' ) ); | ||
| 284 : | |||
| 285 : | if (!$username || !$passwd) { | ||
| 286 : | csouza | 39 | echo "<script> alert(\"".T_('Please complete the username and password fields.')."\"); window.history.go(-1); </script>\n"; |
| 287 : | root | 1 | exit(); |
| 288 : | } else { | ||
| 289 : | $this->_db->setQuery( "SELECT id, gid, block, usertype" | ||
| 290 : | . "\nFROM #__users" | ||
| 291 : | . "\nWHERE username='$username' AND password='$passwd'" | ||
| 292 : | ); | ||
| 293 : | $row = null; | ||
| 294 : | if ($this->_db->loadObject( $row )) { | ||
| 295 : | if ($row->block == 1) { | ||
| 296 : | csouza | 39 | echo "<script>alert(\"".T_('Your login has been blocked. Please contact the administrator.')."\"); window.history.go(-1); </script>\n"; |
| 297 : | root | 1 | exit(); |
| 298 : | } | ||
| 299 : | // fudge the group stuff | ||
| 300 : | $grp = $acl->getAroGroup( $row->id ); | ||
| 301 : | $row->gid = 1; | ||
| 302 : | |||
| 303 : | if ($acl->is_group_child_of( $grp->name, 'Registered', 'ARO' ) || | ||
| 304 : | $acl->is_group_child_of( $grp->name, 'Public Backend', 'ARO' )) { | ||
| 305 : | // fudge Authors, Editors, Publishers and Super Administrators into the Special Group | ||
| 306 : | $row->gid = 2; | ||
| 307 : | } | ||
| 308 : | $row->usertype = $grp->name; | ||
| 309 : | |||
| 310 : | $session =& $this->_session; | ||
| 311 : | $session->guest = 0; | ||
| 312 : | $session->username = $username; | ||
| 313 : | $session->userid = intval( $row->id ); | ||
| 314 : | $session->usertype = $row->usertype; | ||
| 315 : | $session->gid = intval( $row->gid ); | ||
| 316 : | |||
| 317 : | $session->update(); | ||
| 318 : | |||
| 319 : | $currentDate = date("Y-m-d\TH:i:s"); | ||
| 320 : | $query = "UPDATE #__users SET lastvisitDate='$currentDate' where id='$session->userid'"; | ||
| 321 : | $this->_db->setQuery($query); | ||
| 322 : | if (!$this->_db->query()) { | ||
| 323 : | die($this->_db->stderr(true)); | ||
| 324 : | } | ||
| 325 : | |||
| 326 : | if ($remember=="yes") { | ||
| 327 : | $lifetime = time() + 365*24*60*60; | ||
| 328 : | setcookie( "usercookie[username]", $username, $lifetime, "/" ); | ||
| 329 : | setcookie( "usercookie[password]", $passwd, $lifetime, "/" ); | ||
| 330 : | } | ||
| 331 : | //mosCache::cleanCache('com_content'); | ||
| 332 : | mosCache::cleanCache(); | ||
| 333 : | } else { | ||
| 334 : | if (isset($bypost)) { | ||
| 335 : | csouza | 39 | echo "<script>alert(\"".T_('Incorrect username or password. Please try again.')."\"); window.history.go(-1); </script>\n"; |
| 336 : | root | 1 | } else { |
| 337 : | $this->logout(); | ||
| 338 : | mosRedirect("index.php"); | ||
| 339 : | } | ||
| 340 : | exit(); | ||
| 341 : | mambo | 117 | ======= |
| 342 : | function &listPermissions ($a_type, $a_id, $action, $property) { | ||
| 343 : | $this->getAccessorData ($a_type, $a_id); | ||
| 344 : | $results = array(); | ||
| 345 : | foreach ($this->permissions as $permission) { | ||
| 346 : | if (strcasecmp($permission->access_type,$a_type) == 0 | ||
| 347 : | AND (strcasecmp($permission->access_id,$a_id) == 0 OR $permission->access_id == '*' OR ($permission->access_id == '+' AND $a_id != 0)) | ||
| 348 : | AND (strcasecmp($permission->action,$action) == 0 OR $permission->action == '*') | ||
| 349 : | AND $permission->subject_type != null AND $permission->subject_id != null) { | ||
| 350 : | $results[] = $permission->$property; | ||
| 351 : | |||
| 352 : | |||
| 353 : | |||
| 354 : | |||
| 355 : | |||
| 356 : | |||
| 357 : | |||
| 358 : | |||
| 359 : | |||
| 360 : | |||
| 361 : | |||
| 362 : | |||
| 363 : | |||
| 364 : | |||
| 365 : | |||
| 366 : | |||
| 367 : | |||
| 368 : | |||
| 369 : | |||
| 370 : | |||
| 371 : | |||
| 372 : | |||
| 373 : | |||
| 374 : | |||
| 375 : | |||
| 376 : | |||
| 377 : | |||
| 378 : | |||
| 379 : | |||
| 380 : | |||
| 381 : | |||
| 382 : | |||
| 383 : | |||
| 384 : | |||
| 385 : | |||
| 386 : | |||
| 387 : | |||
| 388 : | |||
| 389 : | |||
| 390 : | |||
| 391 : | |||
| 392 : | |||
| 393 : | |||
| 394 : | |||
| 395 : | |||
| 396 : | |||
| 397 : | |||
| 398 : | |||
| 399 : | |||
| 400 : | |||
| 401 : | |||
| 402 : | |||
| 403 : | |||
| 404 : | |||
| 405 : | |||
| 406 : | |||
| 407 : | |||
| 408 : | |||
| 409 : | |||
| 410 : | |||
| 411 : | |||
| 412 : | |||
| 413 : | |||
| 414 : | |||
| 415 : | |||
| 416 : | |||
| 417 : | |||
| 418 : | >>>>>>> .theirs | ||
| 419 : | root | 1 | } |
| 420 : | } | ||
| 421 : | mambo | 117 | return $results; |
| 422 : | root | 1 | } |
| 423 : | |||
| 424 : | mambo | 117 | } |
| 425 : | root | 1 | |
| 426 : | mambo | 117 | class mosAuthorisationAdmin { |
| 427 : | var $connection; | ||
| 428 : | var $roles = array(); | ||
| 429 : | root | 1 | |
| 430 : | mambo | 117 | function mosAuthorisationAdmin () { |
| 431 : | $this->connection =& mamboDatabase::getInstance(); | ||
| 432 : | root | 1 | } |
| 433 : | mambo | 117 | <<<<<<< .mine |
| 434 : | csouza | 39 | |
| 435 : | root | 1 | /** |
| 436 : | * @return mosUser A user object with the information from the current session | ||
| 437 : | */ | ||
| 438 : | function getUser() { | ||
| 439 : | $user = new mosUser( $this->_db ); | ||
| 440 : | mambo | 117 | ======= |
| 441 : | root | 1 | |
| 442 : | mambo | 117 | |
| 443 : | |||
| 444 : | |||
| 445 : | |||
| 446 : | |||
| 447 : | >>>>>>> .theirs | ||
| 448 : | |||
| 449 : | <<<<<<< .mine | ||
| 450 : | root | 1 | $user->id = intval( $this->_session->userid ); |
| 451 : | $user->username = $this->_session->username; | ||
| 452 : | $user->usertype = $this->_session->usertype; | ||
| 453 : | $user->gid = intval( $this->_session->gid ); | ||
| 454 : | |||
| 455 : | return $user; | ||
| 456 : | } | ||
| 457 : | /** | ||
| 458 : | * Loads the configuration.php file and assigns values to the internal variable | ||
| 459 : | * @param string The base path from which to load the configuration file | ||
| 460 : | */ | ||
| 461 : | function _setConfig( $basePath='.' ) { | ||
| 462 : | $this->_config = new stdClass(); | ||
| 463 : | |||
| 464 : | require( $basePath . '/configuration.php' ); | ||
| 465 : | |||
| 466 : | $this->_config->offline = $mosConfig_offline; | ||
| 467 : | $this->_config->host = $mosConfig_host; | ||
| 468 : | $this->_config->user = $mosConfig_user; | ||
| 469 : | $this->_config->password = $mosConfig_password; | ||
| 470 : | $this->_config->db = $mosConfig_db; | ||
| 471 : | $this->_config->dbprefix = $mosConfig_dbprefix; | ||
| 472 : | $this->_config->lang = $mosConfig_lang; | ||
| 473 : | $this->_config->absolute_path = $mosConfig_absolute_path; | ||
| 474 : | $this->_config->live_site = $mosConfig_live_site; | ||
| 475 : | $this->_config->sitename = $mosConfig_sitename; | ||
| 476 : | $this->_config->shownoauth = $mosConfig_shownoauth; | ||
| 477 : | $this->_config->useractivation = $mosConfig_useractivation; | ||
| 478 : | $this->_config->uniquemail = $mosConfig_uniquemail; | ||
| 479 : | $this->_config->offline_message = $mosConfig_offline_message; | ||
| 480 : | $this->_config->error_message = $mosConfig_error_message; | ||
| 481 : | $this->_config->lifetime = $mosConfig_lifetime; | ||
| 482 : | $this->_config->MetaDesc = $mosConfig_MetaDesc; | ||
| 483 : | $this->_config->MetaKeys = $mosConfig_MetaKeys; | ||
| 484 : | $this->_config->debug = $mosConfig_debug; | ||
| 485 : | $this->_config->vote = $mosConfig_vote; | ||
| 486 : | $this->_config->hideAuthor = $mosConfig_hideAuthor; | ||
| 487 : | $this->_config->hideCreateDate = $mosConfig_hideCreateDate; | ||
| 488 : | $this->_config->hideModifyDate = $mosConfig_hideModifyDate; | ||
| 489 : | $this->_config->hidePdf = $mosConfig_hidePdf; | ||
| 490 : | $this->_config->hidePrint = $mosConfig_hidePrint; | ||
| 491 : | $this->_config->hideEmail = $mosConfig_hideEmail; | ||
| 492 : | $this->_config->enable_log_items = $mosConfig_enable_log_items; | ||
| 493 : | $this->_config->enable_log_searches = $mosConfig_enable_log_searches; | ||
| 494 : | $this->_config->enable_stats = $mosConfig_enable_stats; | ||
| 495 : | $this->_config->sef = $mosConfig_sef; | ||
| 496 : | $this->_config->vote = $mosConfig_vote; | ||
| 497 : | $this->_config->hideModifyDate = $mosConfig_hideModifyDate; | ||
| 498 : | $this->_config->multipage_toc = $mosConfig_multipage_toc; | ||
| 499 : | $this->_config->allowUserRegistration = $mosConfig_allowUserRegistration; | ||
| 500 : | $this->_config->error_reporting = $mosConfig_error_reporting; | ||
| 501 : | mambo | 112 | $this->_config->mosConfig_register_globals = $mosConfig_register_globals; |
| 502 : | root | 1 | $this->_config->link_titles = $mosConfig_link_titles; |
| 503 : | $this->_config->list_limit = $mosConfig_list_limit; | ||
| 504 : | $this->_config->caching = $mosConfig_caching; | ||
| 505 : | $this->_config->cachepath = $mosConfig_cachepath; | ||
| 506 : | $this->_config->cachetime = $mosConfig_cachetime; | ||
| 507 : | $this->_config->mailer = $mosConfig_mailer; | ||
| 508 : | $this->_config->mailfrom = $mosConfig_mailfrom; | ||
| 509 : | $this->_config->fromname = $mosConfig_fromname; | ||
| 510 : | $this->_config->smtpauth = $mosConfig_smtpauth; | ||
| 511 : | $this->_config->smtpuser = $mosConfig_smtpuser; | ||
| 512 : | $this->_config->smtppass = $mosConfig_smtppass; | ||
| 513 : | $this->_config->smtphost = $mosConfig_smtphost; | ||
| 514 : | $this->_config->back_button = $mosConfig_back_button; | ||
| 515 : | $this->_config->item_navigation = $mosConfig_item_navigation; | ||
| 516 : | $this->_config->secret = $mosConfig_secret; | ||
| 517 : | $this->_config->pagetitles = $mosConfig_pagetitles; | ||
| 518 : | $this->_config->readmore = $mosConfig_readmore; | ||
| 519 : | $this->_config->hits = $mosConfig_hits; | ||
| 520 : | $this->_config->icons = $mosConfig_icons; | ||
| 521 : | |||
| 522 : | if (@$mosConfig_error_reporting === 0) { | ||
| 523 : | error_reporting( 0 ); | ||
| 524 : | } else if (@$mosConfig_error_reporting > 0) { | ||
| 525 : | error_reporting( $mosConfig_error_reporting ); | ||
| 526 : | mambo | 117 | ======= |
| 527 : | function &getInstance () { | ||
| 528 : | static $instance; | ||
| 529 : | if (!is_object($instance)) { | ||
| 530 : | $instance =& new mosAuthorisationAdmin(); | ||
| 531 : | root | 1 | |
| 532 : | |||
| 533 : | |||
| 534 : | |||
| 535 : | |||
| 536 : | |||
| 537 : | |||
| 538 : | |||
| 539 : | |||
| 540 : | |||
| 541 : | |||
| 542 : | |||
| 543 : | |||
| 544 : | |||
| 545 : | |||
| 546 : | |||
| 547 : | |||
| 548 : | |||
| 549 : | |||
| 550 : | |||
| 551 : | |||
| 552 : | |||
| 553 : | |||
| 554 : | |||
| 555 : | mambo | 117 | |
| 556 : | |||
| 557 : | |||
| 558 : | |||
| 559 : | |||
| 560 : | |||
| 561 : | |||
| 562 : | |||
| 563 : | |||
| 564 : | |||
| 565 : | |||
| 566 : | |||
| 567 : | |||
| 568 : | |||
| 569 : | |||
| 570 : | |||
| 571 : | |||
| 572 : | |||
| 573 : | |||
| 574 : | |||
| 575 : | |||
| 576 : | |||
| 577 : | |||
| 578 : | |||
| 579 : | |||
| 580 : | |||
| 581 : | |||
| 582 : | |||
| 583 : | |||
| 584 : | |||
| 585 : | |||
| 586 : | |||
| 587 : | |||
| 588 : | |||
| 589 : | |||
| 590 : | |||
| 591 : | |||
| 592 : | |||
| 593 : | |||
| 594 : | |||
| 595 : | |||
| 596 : | |||
| 597 : | |||
| 598 : | |||
| 599 : | |||
| 600 : | |||
| 601 : | |||
| 602 : | |||
| 603 : | >>>>>>> .theirs | ||
| 604 : | root | 1 | } |
| 605 : | mambo | 117 | return $instance; |
| 606 : | } | ||
| 607 : | root | 1 | |
| 608 : | mambo | 117 | function doSQL ($sql) { |
| 609 : | $this->connection->setQuery($sql); | ||
| 610 : | if (!$this->connection->query()) { | ||
| 611 : | echo "<script> alert('".$this->connection->getErrorMsg()."'); window.history.go(-1); </script>\n"; | ||
| 612 : | exit(); | ||
| 613 : | root | 1 | } |
| 614 : | mambo | 117 | } |
| 615 : | |||
| 616 : | function getRoles () { | ||
| 617 : | if (count($this->roles) == 0) { | ||
| 618 : | $sql = "SELECT DISTINCT role FROM #__assignments"; | ||
| 619 : | $this->connection->setQuery($sql); | ||
| 620 : | $this->roles = $this->connection->loadResultArray(); | ||
| 621 : | $sql = "SELECT DISTINCT role FROM #__permissions"; | ||
| 622 : | $this->connection->setQuery($sql); | ||
| 623 : | $more = $this->connection->loadResultArray(); | ||
| 624 : | foreach ($more as $role) $this->addRole($role); | ||
| 625 : | root | 1 | } |
| 626 : | mambo | 117 | return $this->roles; |
| 627 : | root | 1 | } |
| 628 : | mambo | 117 | |
| 629 : | function addRole ($role) { | ||
| 630 : | if (!in_array($role, $this->roles)) $this->roles[] = $role; | ||
| 631 : | } | ||
| 632 : | |||
| 633 : | function removeRole ($role) { | ||
| 634 : | $key = array_search($role, $this->roles); | ||
| 635 : | if ($key !== false) unset($this->roles[$key]); | ||
| 636 : | } | ||
| 637 : | |||
| 638 : | function &permissionHolders ($subject_type, $subject_id) { | ||
| 639 : | $sql = "SELECT role, action, control FROM #__permissions"; | ||
| 640 : | if ($subject_type != '*') $where[] = "(subject_type='$subject_type' OR subject_type='*')"; | ||
| 641 : | if ($subject_id != '*') $where[] = "(subject_id='$subject_id' OR subject_id='*')"; | ||
| 642 : | if (isset($where)) $sql .= " WHERE ".implode(' AND ', $where); | ||
| 643 : | $this->connection->setQuery($sql); | ||
| 644 : | $result = $this->connection->loadObjectList(); | ||
| 645 : | if (!$result) $result = array(); | ||
| 646 : | return $result; | ||
| 647 : | } | ||
| 648 : | |||
| 649 : | function &nonLocalPermissionHolders ($subject_type, $subject_id) { | ||
| 650 : | $sql = "SELECT role, action, control FROM #__permissions WHERE (action='*' OR subject_type='*' OR subject_id='*') AND ((subject_type='$subject_type' OR subject_type='*') AND (subject_id='$subject_id' OR subject_id='*'))"; | ||
| 651 : | $this->connection->setQuery($sql); | ||
| 652 : | $result = $this->connection->loadObjectList(); | ||
| 653 : | if (!$result) $result = array(); | ||
| 654 : | return $result; | ||
| 655 : | } | ||
| 656 : | |||
| 657 : | function permitSQL ($role, $control, $action, $subject_type, $subject_id) { | ||
| 658 : | $sql = "REPLACE INTO #__permissions (role, control, action, subject_type, subject_id) VALUES ('$role', '$control', '$action', '$subject_type', '$subject_id');"; | ||
| 659 : | return $sql; | ||
| 660 : | } | ||
| 661 : | root | 1 | |
| 662 : | mambo | 117 | function permit ($role, $control, $action, $subject_type, $subject_id) { |
| 663 : | $sql = $this->permitSQL($role, $control, $action, $subject_type, $subject_id); | ||
| 664 : | $this->doSQL($sql); | ||
| 665 : | $this->addRole($role); | ||
| 666 : | root | 1 | } |
| 667 : | |||
| 668 : | mambo | 117 | function assign ($role, $access_type, $access_id) { |
| 669 : | $sql = "REPLACE INTO #__assignments (role, access_type, access_id) VALUES ('$role', '$access_type', '$access_id')"; | ||
| 670 : | $this->doSQL($sql); | ||
| 671 : | $this->addRole($role); | ||
| 672 : | root | 1 | } |
| 673 : | |||
| 674 : | mambo | 117 | function dropAccess ($access_type, $access_id) { |
| 675 : | $sql = "DELETE FROM #__assignments WHERE access_type='$access_type' AND access_id='$access_id'"; | ||
| 676 : | $this->doSQL($sql); | ||
| 677 : | root | 1 | } |
| 678 : | |||
| 679 : | mambo | 117 | function &getControllingRoles ($access_type, $access_id, $action, $subject_type, $subject_id) { |
| 680 : | $sql = "SELECT a.role FROM #__permissions AS p, #__assignments AS a WHERE a.access_type='$access_type'" | ||
| 681 : | ." AND a.access_id='$access_id' AND a.role=p.role AND (p.control&1)" | ||
| 682 : | ." AND p.action='$action' AND p.subject_type='$subject_type' AND p.subject_id='$subject_id'"; | ||
| 683 : | $this->doSQL($sql); | ||
| 684 : | $roles = $this->connection->loadResultArray(); | ||
| 685 : | return $roles; | ||
| 686 : | root | 1 | } |
| 687 : | |||
| 688 : | mambo | 117 | function &getMyPermissions ($access_type, $access_id) { |
| 689 : | $sql = 'SELECT p.action, p.subject_type, p.subject_id, control FROM #__permissions AS p, #__assignments AS a' | ||
| 690 : | . " WHERE p.role=a.role AND a.access_type='$access_type' AND (a.access_id='$access_id' OR a.access_id='*')" | ||
| 691 : | . ' AND (p.control&1)'; | ||
| 692 : | $this->doSQL($sql); | ||
| 693 : | $permissions =& $this->connection->loadObjectList(); | ||
| 694 : | return $permissions; | ||
| 695 : | root | 1 | } |
| 696 : | |||
| 697 : | mambo | 117 | function getJointPermissions ($access_type, $access_id, $role) { |
| 698 : | $sql = "SELECT p2.control AS hiscontrol, p1.control AS mycontrol, p1.action, p1.subject_type, p1.subject_id" | ||
| 699 : | ." FROM `mos_assignments` AS a, `mos_permissions` AS p1 LEFT JOIN `mos_permissions` AS p2" | ||
| 700 : | ." ON (p2.role='$role' AND p1.action=p2.action AND p1.subject_type=p2.subject_type AND p1.subject_id=p2.subject_id)" | ||
| 701 : | ." WHERE (p1.control&1) AND p1.role=a.role AND a.access_type='$access_type' AND (a.access_id='$access_id' OR a.access_id='*')"; | ||
| 702 : | $this->doSQL($sql); | ||
| 703 : | $permissions =& $this->connection->loadObjectList(); | ||
| 704 : | return $permissions; | ||
| 705 : | root | 1 | } |
| 706 : | mambo | 117 | <<<<<<< .mine |
| 707 : | root | 1 | } |
| 708 : | |||
| 709 : | /** | ||
| 710 : | * Utility class for all HTML drawing classes | ||
| 711 : | * @package Mambo | ||
| 712 : | */ | ||
| 713 : | class mosHTML { | ||
| 714 : | function makeOption( $value, $text='' ) { | ||
| 715 : | $obj = new stdClass; | ||
| 716 : | $obj->value = $value; | ||
| 717 : | $obj->text = trim( $text ) ? $text : $value; | ||
| 718 : | return $obj; | ||
| 719 : | } | ||
| 720 : | |||
| 721 : | function writableCell( $folder ) { | ||
| 722 : | |||
| 723 : | echo '<tr>'; | ||
| 724 : | echo '<td class="item">' . $folder . '/</td>'; | ||
| 725 : | echo '<td align="left">'; | ||
| 726 : | csouza | 39 | echo is_writable( "../$folder" ) ? '<b><font color="green">'.T_('Writeable').'</font></b>' : '<b><font color="red">'.T_('Unwriteable').'</font></b>' . '</td>'; |
| 727 : | root | 1 | echo '</tr>'; |
| 728 : | } | ||
| 729 : | |||
| 730 : | /** | ||
| 731 : | * Generates an HTML select list | ||
| 732 : | * @param array An array of objects | ||
| 733 : | * @param string The value of the HTML name attribute | ||
| 734 : | * @param string Additional HTML attributes for the <select> tag | ||
| 735 : | * @param string The name of the object variable for the option value | ||
| 736 : | * @param string The name of the object variable for the option text | ||
| 737 : | * @param mixed The key that is selected | ||
| 738 : | * @returns string HTML for the select list | ||
| 739 : | */ | ||
| 740 : | function selectList( &$arr, $tag_name, $tag_attribs, $key, $text, $selected=NULL ) { | ||
| 741 : | reset( $arr ); | ||
| 742 : | $html = "\n<select name=\"$tag_name\" $tag_attribs>"; | ||
| 743 : | for ($i=0, $n=count( $arr ); $i < $n; $i++ ) { | ||
| 744 : | $k = $arr[$i]->$key; | ||
| 745 : | $t = $arr[$i]->$text; | ||
| 746 : | $id = @$arr[$i]->id; | ||
| 747 : | |||
| 748 : | $extra = ''; | ||
| 749 : | $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; | ||
| 750 : | if (is_array( $selected )) { | ||
| 751 : | foreach ($selected as $obj) { | ||
| 752 : | $k2 = $obj->$key; | ||
| 753 : | if ($k == $k2) { | ||
| 754 : | $extra .= " selected=\"selected\""; | ||
| 755 : | break; | ||
| 756 : | mambo | 117 | ======= |
| 757 : | |||
| 758 : | function getAccessLists ($access_type, $access_id, $action, $subject_type, $subject_id) { | ||
| 759 : | $authoriser = mosAuthoriser::getInstance(); | ||
| 760 : | if ($authoriser->checkControl($access_type, $access_id, $action, $subject_type, $subject_id)) { | ||
| 761 : | $cangrant = $authoriser->checkGrant($access_type, $access_id, $action, $subject_type, $subject_id); | ||
| 762 : | $permissions = $this->permissionHolders($subject_type, $subject_id); | ||
| 763 : | $allroles = $this->getRoles(); | ||
| 764 : | foreach ($allroles as $role) { | ||
| 765 : | $itemc[] = $optionc = mosHTML::makeOption($role, $role); | ||
| 766 : | $itema[] = $optiona = mosHTML::makeOption($role, $role); | ||
| 767 : | if ($cangrant) $itemg[] = $optiong = mosHTML::makeOption($role, $role); | ||
| 768 : | foreach ($permissions as $permission) { | ||
| 769 : | if (($permission->action == '*' OR $permission->action == $action) AND $permission->role == $role) { | ||
| 770 : | if ($permission->control & 1) $cselected[] = $optionc; | ||
| 771 : | if ($permission->control & 2) $aselected[] = $optiona; | ||
| 772 : | if ($cangrant AND $permission->control & 4) $gselected[] = $optiong; | ||
| 773 : | |||
| 774 : | |||
| 775 : | |||
| 776 : | |||
| 777 : | |||
| 778 : | |||
| 779 : | |||
| 780 : | |||
| 781 : | |||
| 782 : | |||
| 783 : | |||
| 784 : | |||
| 785 : | |||
| 786 : | |||
| 787 : | |||
| 788 : | |||
| 789 : | |||
| 790 : | |||
| 791 : | |||
| 792 : | |||
| 793 : | |||
| 794 : | |||
| 795 : | |||
| 796 : | |||
| 797 : | |||
| 798 : | |||
| 799 : | |||
| 800 : | |||
| 801 : | |||
| 802 : | |||
| 803 : | |||
| 804 : | |||
| 805 : | |||
| 806 : | >>>>>>> .theirs | ||
| 807 : | root | 1 | } |
| 808 : | } | ||
| 809 : | } | ||
| 810 : | mambo | 117 | $results[] = mosHTML::selectList($itema, $action.'_arole[]', 'multiple="multiple"', 'value', 'text', $aselected); |
| 811 : | $results[] = mosHTML::selectList($itemc, $action.'_crole[]', 'multiple="multiple"', 'value', 'text', $cselected); | ||
| 812 : | if ($cangrant) $results[] = mosHTML::selectList($itemg, $action.'_grole[]', 'multiple="multiple"', 'value', 'text', $gselected); | ||
| 813 : | root | 1 | } |
| 814 : | mambo | 117 | else $results = array(); |
| 815 : | return $results; | ||
| 816 : | root | 1 | } |
| 817 : | mambo | 117 | <<<<<<< .mine |
| 818 : | root | 1 | |
| 819 : | /** | ||
| 820 : | * Writes a select list of integers | ||
| 821 : | * @param int The start integer | ||
| 822 : | * @param int The end integer | ||
| 823 : | * @param int The increment | ||
| 824 : | * @param string The value of the HTML name attribute | ||
| 825 : | * @param string Additional HTML attributes for the <select> tag | ||
| 826 : | * @param mixed The key that is selected | ||
| 827 : | * @param string The printf format to be applied to the number | ||
| 828 : | * @returns string HTML for the select list | ||
| 829 : | */ | ||
| 830 : | function integerSelectList( $start, $end, $inc, $tag_name, $tag_attribs, $selected, $format="" ) { | ||
| 831 : | $start = intval( $start ); | ||
| 832 : | $end = intval( $end ); | ||
| 833 : | $inc = intval( $inc ); | ||
| 834 : | $arr = array(); | ||
| 835 : | for ($i=$start; $i <= $end; $i+=$inc) { | ||
| 836 : | $fi = $format ? sprintf( "$format", $i ) : "$i"; | ||
| 837 : | $arr[] = mosHTML::makeOption( $fi, $fi ); | ||
| 838 : | } | ||
| 839 : | |||
| 840 : | return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); | ||
| 841 : | } | ||
| 842 : | |||
| 843 : | /** | ||
| 844 : | * Writes a select list of month names based on Language settings | ||
| 845 : | * @param string The value of the HTML name attribute | ||
| 846 : | * @param string Additional HTML attributes for the <select> tag | ||
| 847 : | * @param mixed The key that is selected | ||
| 848 : | * @returns string HTML for the select list values | ||
| 849 : | */ | ||
| 850 : | function monthSelectList( $tag_name, $tag_attribs, $selected ) { | ||
| 851 : | $arr = array( | ||
| 852 : | csouza | 39 | mosHTML::makeOption( '01', T_('January') ), |
| 853 : | mosHTML::makeOption( '02', T_('February') ), | ||
| 854 : | mosHTML::makeOption( '03', T_('March') ), | ||
| 855 : | mosHTML::makeOption( '04', T_('April') ), | ||
| 856 : | mosHTML::makeOption( '05', T_('May') ), | ||
| 857 : | mosHTML::makeOption( '06', T_('June') ), | ||
| 858 : | mosHTML::makeOption( '07', T_('July') ), | ||
| 859 : | mosHTML::makeOption( '08', T_('August') ), | ||
| 860 : | mosHTML::makeOption( '09', T_('September') ), | ||
| 861 : | mosHTML::makeOption( '10', T_('October') ), | ||
| 862 : | mosHTML::makeOption( '11', T_('November') ), | ||
| 863 : | mosHTML::makeOption( '12', T_('December') ) | ||
| 864 : | root | 1 | ); |
| 865 : | |||
| 866 : | return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); | ||
| 867 : | } | ||
| 868 : | |||
| 869 : | /** | ||
| 870 : | * Generates an HTML select list from a tree based query list | ||
| 871 : | * @param array Source array with id and parent fields | ||
| 872 : | * @param array The id of the current list item | ||
| 873 : | * @param array Target array. May be an empty array. | ||
| 874 : | * @param array An array of objects | ||
| 875 : | * @param string The value of the HTML name attribute | ||
| 876 : | * @param string Additional HTML attributes for the <select> tag | ||
| 877 : | * @param string The name of the object variable for the option value | ||
| 878 : | * @param string The name of the object variable for the option text | ||
| 879 : | * @param mixed The key that is selected | ||
| 880 : | * @returns string HTML for the select list | ||
| 881 : | */ | ||
| 882 : | function treeSelectList( &$src_list, $src_id, $tgt_list, $tag_name, $tag_attribs, $key, $text, $selected ) { | ||
| 883 : | |||
| 884 : | // establish the hierarchy of the menu | ||
| 885 : | $children = array(); | ||
| 886 : | // first pass - collect children | ||
| 887 : | foreach ($src_list as $v ) { | ||
| 888 : | $pt = $v->parent; | ||
| 889 : | $list = @$children[$pt] ? $children[$pt] : array(); | ||
| 890 : | array_push( $list, $v ); | ||
| 891 : | $children[$pt] = $list; | ||
| 892 : | } | ||
| 893 : | // second pass - get an indent list of the items | ||
| 894 : | $ilist = mosTreeRecurse( 0, '', array(), $children ); | ||
| 895 : | |||
| 896 : | // assemble menu items to the array | ||
| 897 : | $this_treename = ''; | ||
| 898 : | foreach ($ilist as $item) { | ||
| 899 : | if ($this_treename) { | ||
| 900 : | if ($item->id != $src_id && strpos( $item->treename, $this_treename ) === false) { | ||
| 901 : | $tgt_list[] = mosHTML::makeOption( $item->id, $item->treename ); | ||
| 902 : | mambo | 117 | ======= |
| 903 : | |||
| 904 : | function resetPermissions ($action, $subject_type, $subject_id) { | ||
| 905 : | $control_types = array ('crole', 'arole', 'grole'); | ||
| 906 : | $control_values = array (1,2,4); | ||
| 907 : | $permissions = $this->nonLocalPermissionHolders($subject_type, $subject_id); | ||
| 908 : | $this->dropPermissions($action, $subject_type, $subject_id); | ||
| 909 : | foreach ($control_types as $i=>$type) { | ||
| 910 : | $key = $action.'_'.$type; | ||
| 911 : | if (isset($_POST[$key])) { | ||
| 912 : | foreach ($_POST[$key] as $role) { | ||
| 913 : | $value = isset($newpermits[$role]) ? $newpermits[$role] : 0; | ||
| 914 : | $newpermits[$role] = $value | $control_values[$i]; | ||
| 915 : | |||
| 916 : | |||
| 917 : | |||
| 918 : | |||
| 919 : | |||
| 920 : | |||
| 921 : | |||
| 922 : | |||
| 923 : | |||
| 924 : | |||
| 925 : | |||
| 926 : | |||
| 927 : | |||
| 928 : | |||
| 929 : | |||
| 930 : | |||
| 931 : | |||
| 932 : | |||
| 933 : | |||
| 934 : | |||
| 935 : | |||
| 936 : | |||
| 937 : | |||
| 938 : | |||
| 939 : | |||
| 940 : | |||
| 941 : | |||
| 942 : | |||
| 943 : | |||
| 944 : | |||
| 945 : | |||
| 946 : | |||
| 947 : | |||
| 948 : | |||
| 949 : | |||
| 950 : | |||
| 951 : | |||
| 952 : | |||
| 953 : | |||
| 954 : | |||
| 955 : | |||
| 956 : | |||
| 957 : | |||
| 958 : | |||
| 959 : | |||
| 960 : | |||
| 961 : | |||
| 962 : | |||
| 963 : | |||
| 964 : | |||
| 965 : | |||
| 966 : | |||
| 967 : | |||
| 968 : | |||
| 969 : | |||
| 970 : | |||
| 971 : | |||
| 972 : | |||
| 973 : | |||
| 974 : | |||
| 975 : | |||
| 976 : | |||
| 977 : | |||
| 978 : | |||
| 979 : | |||
| 980 : | |||
| 981 : | |||
| 982 : | |||
| 983 : | |||
| 984 : | |||
| 985 : | |||
| 986 : | |||
| 987 : | >>>>>>> .theirs | ||
| 988 : | root | 1 | } |
| 989 : | } | ||
| 990 : | } | ||
| 991 : | mambo | 117 | <<<<<<< .mine |
| 992 : | root | 1 | // build the html select list |
| 993 : | return mosHTML::selectList( $tgt_list, $tag_name, $tag_attribs, $key, $text, $selected ); | ||
| 994 : | } | ||
| 995 : | |||
| 996 : | /** | ||
| 997 : | * Writes a yes/no select list | ||
| 998 : | * @param string The value of the HTML name attribute | ||
| 999 : | * @param string Additional HTML attributes for the <select> tag | ||
| 1000 : | * @param mixed The key that is selected | ||
| 1001 : | * @returns string HTML for the select list values | ||
| 1002 : | */ | ||
| 1003 : | csouza | 39 | function yesnoSelectList( $tag_name, $tag_attribs, $selected, $yes=null, $no=null ) { |
| 1004 : | // modified by csouza for gettext localization | ||
| 1005 : | if (is_null($yes)) $yes = T_('Yes'); | ||
| 1006 : | if (is_null($yes)) $no = T_('No'); | ||
| 1007 : | |||
| 1008 : | $arr = array( | ||
| 1009 : | root | 1 | mosHTML::makeOption( '0', $no ), |
| 1010 : | mosHTML::makeOption( '1', $yes ), | ||
| 1011 : | ); | ||
| 1012 : | |||
| 1013 : | return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); | ||
| 1014 : | } | ||
| 1015 : | |||
| 1016 : | /** | ||
| 1017 : | * Generates an HTML radio list | ||
| 1018 : | * @param array An array of objects | ||
| 1019 : | * @param string The value of the HTML name attribute | ||
| 1020 : | * @param string Additional HTML attributes for the <select> tag | ||
| 1021 : | * @param mixed The key that is selected | ||
| 1022 : | * @param string The name of the object variable for the option value | ||
| 1023 : | * @param string The name of the object variable for the option text | ||
| 1024 : | * @returns string HTML for the select list | ||
| 1025 : | */ | ||
| 1026 : | function radioList( &$arr, $tag_name, $tag_attribs, $selected=null, $key='value', $text='text' ) { | ||
| 1027 : | reset( $arr ); | ||
| 1028 : | $html = ""; | ||
| 1029 : | for ($i=0, $n=count( $arr ); $i < $n; $i++ ) { | ||
| 1030 : | $k = $arr[$i]->$key; | ||
| 1031 : | $t = $arr[$i]->$text; | ||
| 1032 : | $id = @$arr[$i]->id; | ||
| 1033 : | |||
| 1034 : | $extra = ''; | ||
| 1035 : | $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; | ||
| 1036 : | if (is_array( $selected )) { | ||
| 1037 : | foreach ($selected as $obj) { | ||
| 1038 : | $k2 = $obj->$key; | ||
| 1039 : | if ($k == $k2) { | ||
| 1040 : | $extra .= " selected=\"selected\""; | ||
| 1041 : | mambo | 117 | ======= |
| 1042 : | $sql = ''; | ||
| 1043 : | foreach ($newpermits as $role=>$value) { | ||
| 1044 : | $needed = true; | ||
| 1045 : | foreach ($permissions as $permission) { | ||
| 1046 : | if (($permission->action == '*' OR $permission->action == $action) AND $permission->role == $role) { | ||
| 1047 : | if (($value & $permission->control) === $value) { | ||
| 1048 : | $needed = false; | ||
| 1049 : | |||
| 1050 : | |||
| 1051 : | |||
| 1052 : | |||
| 1053 : | |||
| 1054 : | |||
| 1055 : | |||
| 1056 : | |||
| 1057 : | |||
| 1058 : | |||
| 1059 : | |||
| 1060 : | |||
| 1061 : | |||
| 1062 : | |||
| 1063 : | |||
| 1064 : | |||
| 1065 : | |||
| 1066 : | |||
| 1067 : | |||
| 1068 : | |||
| 1069 : | |||
| 1070 : | |||
| 1071 : | |||
| 1072 : | |||
| 1073 : | |||
| 1074 : | |||
| 1075 : | |||
| 1076 : | |||
| 1077 : | |||
| 1078 : | |||
| 1079 : | |||
| 1080 : | |||
| 1081 : | |||
| 1082 : | |||
| 1083 : | |||
| 1084 : | |||
| 1085 : | |||
| 1086 : | |||
| 1087 : | |||
| 1088 : | |||
| 1089 : | |||
| 1090 : | |||
| 1091 : | >>>>>>> .theirs | ||
| 1092 : | root | 1 | break; |
| 1093 : | } | ||
| 1094 : | } | ||
| 1095 : | } | ||
| 1096 : | mambo | 117 | if ($needed) $sql .= $this->permitSQL ($role, $value, $action, $subject_type, $subject_id); |
| 1097 : | root | 1 | } |
| 1098 : | mambo | 117 | if ($sql) $this->doSQL($sql); |
| 1099 : | root | 1 | } |
| 1100 : | |||
| 1101 : | mambo | 117 | <<<<<<< .mine |
| 1102 : | root | 1 | /** |
| 1103 : | * Writes a yes/no radio list | ||
| 1104 : | * @param string The value of the HTML name attribute | ||
| 1105 : | * @param string Additional HTML attributes for the <select> tag | ||
| 1106 : | * @param mixed The key that is selected | ||
| 1107 : | * @returns string HTML for the radio list | ||
| 1108 : | */ | ||
| 1109 : | csouza | 39 | function yesnoRadioList( $tag_name, $tag_attribs, $selected, $yes=null, $no=null ) { |
| 1110 : | // modified by csouza for gettext localization | ||
| 1111 : | if (is_null($yes)) $yes = T_('Yes'); | ||
| 1112 : | if (is_null($yes)) $no = T_('No'); | ||
| 1113 : | |||
| 1114 : | $arr = array( | ||
| 1115 : | root | 1 | mosHTML::makeOption( '0', $no, true ), |
| 1116 : | mosHTML::makeOption( '1', $yes, true ) | ||
| 1117 : | ); | ||
| 1118 : | return mosHTML::radioList( $arr, $tag_name, $tag_attribs, $selected ); | ||
| 1119 : | mambo | 117 | ======= |
| 1120 : | function roleExists ($role) { | ||
| 1121 : | $sql = "SELECT COUNT(role) FROM #__permissions WHERE role='$role' GROUP BY role"; | ||
| 1122 : | $this->doSQL($sql); | ||
| 1123 : | if ($this->connection->loadResult()) return true; | ||
| 1124 : | $sql = "SELECT COUNT(role) FROM #__assignments WHERE role='$role' GROUP BY role"; | ||
| 1125 : | $this->doSQL($sql); | ||
| 1126 : | if ($this->connection->loadResult()) return true; | ||
| 1127 : | else return false; | ||
| 1128 : | |||
| 1129 : | |||
| 1130 : | |||
| 1131 : | |||
| 1132 : | |||
| 1133 : | |||
| 1134 : | |||
| 1135 : | |||
| 1136 : | |||
| 1137 : | >>>>>>> .theirs | ||
| 1138 : | root | 1 | } |
| 1139 : | |||
| 1140 : | mambo | 117 | function dropRole ($role) { |
| 1141 : | $sql = "DELETE FROM #__permissions WHERE action='administer' AND subject_type='$role' AND system=0"; | ||
| 1142 : | $this->doSQL($sql); | ||
| 1143 : | $sql = "DELETE a FROM #__assignments AS a LEFT JOIN #__permissions AS p ON a.role=p.role WHERE a.role='$role' AND (p.system=0 OR p.system=NULL)"; | ||
| 1144 : | $this->doSQL($sql); | ||
| 1145 : | $this->dropRolePermissions($role); | ||
| 1146 : | $this->removeRole($role); | ||
| 1147 : | root | 1 | } |
| 1148 : | |||
| 1149 : | mambo | 117 | <<<<<<< .mine |
| 1150 : | root | 1 | function sortIcon( $base_href, $field, $state='none' ) { |
| 1151 : | global $mosConfig_live_site; | ||
| 1152 : | |||
| 1153 : | $alts = array( | ||
| 1154 : | csouza | 39 | 'none' => T_('No Sorting'), |
| 1155 : | 'asc' => T_('Sort Ascending'), | ||
| 1156 : | 'desc' => T_('Sort Descending'), | ||
| 1157 : | root | 1 | ); |
| 1158 : | $next_state = 'asc'; | ||
| 1159 : | if ($state == 'asc') { | ||
| 1160 : | $next_state = 'desc'; | ||
| 1161 : | } else if ($state == 'desc') { | ||
| 1162 : | $next_state = 'none'; | ||
| 1163 : | } | ||
| 1164 : | |||
| 1165 : | $html = "<a href=\"$base_href&field=$field&order=$next_state\">" | ||
| 1166 : | . "<img src=\"$mosConfig_live_site/images/M_images/sort_$state.png\" width=\"12\" height=\"12\" border=\"0\" alt=\"{$alts[$next_state]}\" />" | ||
| 1167 : | . "</a>"; | ||
| 1168 : | return $html; | ||
| 1169 : | mambo | 117 | ======= |
| 1170 : | function dropRolePermissions ($role) { | ||
| 1171 : | $sql = "DELETE FROM #__permissions WHERE role='$role' AND system=0"; | ||
| 1172 : | $this->doSQL($sql); | ||
| 1173 : | $this->roles = array(); | ||
| 1174 : | |||
| 1175 : | |||
| 1176 : | |||
| 1177 : | |||
| 1178 : | |||
| 1179 : | |||
| 1180 : | |||
| 1181 : | |||
| 1182 : | |||
| 1183 : | |||
| 1184 : | |||
| 1185 : | |||
| 1186 : | |||
| 1187 : | |||
| 1188 : | |||
| 1189 : | >>>>>>> .theirs | ||
| 1190 : | root | 1 | } |
| 1191 : | |||
| 1192 : | mambo | 117 | <<<<<<< .mine |
| 1193 : | root | 1 | /** |
| 1194 : | * Writes Close Button | ||
| 1195 : | */ | ||
| 1196 : | function CloseButton ( &$params, $hide_js=NULL ) { | ||
| 1197 : | // displays close button in Pop-up window | ||
| 1198 : | if ( $params->get( 'popup' ) && !$hide_js ) { | ||
| 1199 : | ?> | ||
| 1200 : | <div align="center" style="margin-top: 30px; margin-bottom: 30px;"> | ||
| 1201 : | <a href='javascript:window.close();'> | ||
| 1202 : | <span class="small"> | ||
| 1203 : | csouza | 39 | <?php echo T_('Close Window');?> |
| 1204 : | root | 1 | </span> |
| 1205 : | </a> | ||
| 1206 : | </div> | ||
| 1207 : | <?php | ||
| 1208 : | } | ||
| 1209 : | mambo | 117 | ======= |
| 1210 : | function dropPermissions ($action, $subject_type, $subject_id) { | ||
| 1211 : | $sql = "DELETE FROM #__permissions WHERE action='$action' AND subject_type='$subject_type'AND subject_id='$subject_id' AND system=0"; | ||
| 1212 : | $this->doSQL($sql); | ||
| 1213 : | $this->roles = array(); | ||
| 1214 : | |||
| 1215 : | |||
| 1216 : | |||
| 1217 : | |||
| 1218 : | |||
| 1219 : | |||
| 1220 : | |||
| 1221 : | |||
| 1222 : | |||
| 1223 : | |||
| 1224 : | |||
| 1225 : | |||
| 1226 : | >>>>>>> .theirs | ||
| 1227 : | root | 1 | } |
| 1228 : | |||
| 1229 : | mambo | 117 | <<<<<<< .mine |
| 1230 : | root | 1 | /** |
| 1231 : | * Writes Back Button | ||
| 1232 : | */ | ||
| 1233 : | function BackButton ( &$params, $hide_js=NULL ) { | ||
| 1234 : | // Back Button | ||
| 1235 : | if ( $params->get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) { | ||
| 1236 : | ?> | ||
| 1237 : | <div class="back_button"> | ||
| 1238 : | <a href='javascript:history.go(-1)'> | ||
| 1239 : | csouza | 39 | <?php echo '['.T_('Back').']'; ?> |
| 1240 : | root | 1 | </a> |
| 1241 : | </div> | ||
| 1242 : | <?php | ||
| 1243 : | } | ||
| 1244 : | } | ||
| 1245 : | |||
| 1246 : | /** | ||
| 1247 : | * Cleans text of all formating and scripting code | ||
| 1248 : | */ | ||
| 1249 : | function cleanText ( &$text ) { | ||
| 1250 : | $text = preg_replace( "'<script[^>]*>.*?</script>'si", '', $text ); | ||
| 1251 : | $text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text ); | ||
| 1252 : | $text = preg_replace( '/<!--.+?-->/', '', $text ); | ||
| 1253 : | $text = preg_replace( '/{.+?}/', '', $text ); | ||
| 1254 : | $text = preg_replace( '/ /', ' ', $text ); | ||
| 1255 : | $text = preg_replace( '/&/', ' ', $text ); | ||
| 1256 : | $text = preg_replace( '/"/', ' ', $text ); | ||
| 1257 : | $text = strip_tags( $text ); | ||
| 1258 : | $text = htmlspecialchars( $text ); | ||
| 1259 : | return $text; | ||
| 1260 : | } | ||
| 1261 : | |||
| 1262 : | /** | ||
| 1263 : | * Writes Print icon | ||
| 1264 : | */ | ||
| 1265 : | function PrintIcon( &$row, &$params, $hide_js, $link, $status=NULL ) { | ||
| 1266 : | global $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid; | ||
| 1267 : | if ( $params->get( 'print' ) && !$hide_js ) { | ||
| 1268 : | // use default settings if none declared | ||
| 1269 : | if ( !$status ) { | ||
| 1270 : | $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; | ||
| 1271 : | } | ||
| 1272 : | |||
| 1273 : | // checks template image directory for image, if non found default are loaded | ||
| 1274 : | if ( $params->get( 'icons' ) ) { | ||
| 1275 : | csouza | 39 | $image = mosAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, T_('Print') ); |
| 1276 : | root | 1 | } else { |
| 1277 : | csouza | 39 | $image = _ICON_SEP .' '. T_('Print'). ' '. _ICON_SEP; |
| 1278 : | root | 1 | } |
| 1279 : | |||
| 1280 : | if ( $params->get( 'popup' ) && !$hide_js ) { | ||
| 1281 : | // Print Preview button - used when viewing page | ||
| 1282 : | ?> | ||
| 1283 : | <td align="right" width="100%" class="buttonheading"> | ||
| 1284 : | csouza | 39 | <a href="#" onclick="javascript:window.print(); return false" title="<?php echo T_('Print');?>"> |
| 1285 : | root | 1 | <?php echo $image;?> |
| 1286 : | </a> | ||
| 1287 : | </td> | ||
| 1288 : | <?php | ||
| 1289 : | } else { | ||
| 1290 : | // Print Button - used in pop-up window | ||
| 1291 : | ?> | ||
| 1292 : | <td align="right" width="100%" class="buttonheading"> | ||
| 1293 : | csouza | 39 | <a href="javascript:void window.open('<?php echo $link; ?>', 'win2', '<?php echo $status; ?>');" title="<?php echo T_('Print');?>"> |
| 1294 : | root | 1 | <?php echo $image;?> |
| 1295 : | </a> | ||
| 1296 : | </td> | ||
| 1297 : | <?php | ||
| 1298 : | } | ||
| 1299 : | } | ||
| 1300 : | } | ||
| 1301 : | |||
| 1302 : | /** | ||
| 1303 : | * simple Javascript Cloaking | ||
| 1304 : | * email cloacking | ||
| 1305 : | * by default replaces an email with a mailto link with email cloacked | ||
| 1306 : | */ | ||
| 1307 : | function emailCloaking( $mail, $mailto=1, $text='', $email=1 ) { | ||
| 1308 : | // convert text | ||
| 1309 : | $mail = mosHTML::encoding_converter( $mail ); | ||
| 1310 : | // split email by @ symbol | ||
| 1311 : | $mail = explode( '@', $mail ); | ||
| 1312 : | $mail_parts = explode( '.', $mail[1] ); | ||
| 1313 : | // random number | ||
| 1314 : | $rand = rand( 1, 100000 ); | ||
| 1315 : | |||
| 1316 : | $replacement = "\n<script language='JavaScript' type='text/javascript'> \n"; | ||
| 1317 : | $replacement .= "<!-- \n"; | ||
| 1318 : | $replacement .= "var prefix = 'ma' + 'il' + 'to'; \n"; | ||
| 1319 : | $replacement .= "var path = 'hr' + 'ef' + '='; \n"; | ||
| 1320 : | $replacement .= "var addy". $rand ." = '". @$mail[0] ."' + '@' + '". implode( "' + '.' + '", $mail_parts ) ."'; \n"; | ||
| 1321 : | if ( $mailto ) { | ||
| 1322 : | // special handling when mail text is different from mail addy | ||
| 1323 : | if ( $text ) { | ||
| 1324 : | if ( $email ) { | ||
| 1325 : | // convert text | ||
| 1326 : | $text = mosHTML::encoding_converter( $text ); | ||
| 1327 : | // split email by @ symbol | ||
| 1328 : | $text = explode( '@', $text ); | ||
| 1329 : | $text_parts = explode( '.', $text[1] ); | ||
| 1330 : | $replacement .= "var addy_text". $rand ." = '". @$text[0] ."' + '@' + '". implode( "' + '.' + '", @$text_parts ) ."'; \n"; | ||
| 1331 : | } else { | ||
| 1332 : | $text = mosHTML::encoding_converter( $text ); | ||
| 1333 : | $replacement .= "var addy_text". $rand ." = '". $text ."';\n"; | ||
| 1334 : | } | ||
| 1335 : | $replacement .= "document.write( '<a ' + path + '\'' + prefix + ':' + addy". $rand ." + '\'>' ); \n"; | ||
| 1336 : | $replacement .= "document.write( addy_text". $rand ." ); \n"; | ||
| 1337 : | $replacement .= "document.write( '<\/a>' ); \n"; | ||
| 1338 : | } else { | ||
| 1339 : | $replacement .= "document.write( '<a ' + path + '\'' + prefix + ':' + addy". $rand ." + '\'>' ); \n"; | ||
| 1340 : | $replacement .= "document.write( addy". $rand ." ); \n"; | ||
| 1341 : | $replacement .= "document.write( '<\/a>' ); \n"; | ||
| 1342 : | } | ||
| 1343 : | } else { | ||
| 1344 : | $replacement .= "document.write( addy". $rand ." ); \n"; | ||
| 1345 : | } | ||
| 1346 : | $replacement .= "//--> \n"; | ||
| 1347 : | $replacement .= "</script> \n"; | ||
| 1348 : | $replacement .= "<noscript> \n"; | ||
| 1349 : | csouza | 39 | $replacement .= T_('This email address is being protected from spam bots, you need Javascript enabled to view it'); |
| 1350 : | root | 1 | $replacement .= "\n</noscript> \n"; |
| 1351 : | |||
| 1352 : | return $replacement; | ||
| 1353 : | } | ||
| 1354 : | |||
| 1355 : | function encoding_converter( $text ) { | ||
| 1356 : | // replace vowels with character encoding | ||
| 1357 : | $text = str_replace( 'a', 'a', $text ); | ||
| 1358 : | $text = str_replace( 'e', 'e', $text ); | ||
| 1359 : | $text = str_replace( 'i', 'i', $text ); | ||
| 1360 : | $text = str_replace( 'o', 'o', $text ); | ||
| 1361 : | $text = str_replace( 'u', 'u', $text ); | ||
| 1362 : | |||
| 1363 : | return $text; | ||
| 1364 : | } | ||
| 1365 : | mambo | 117 | ======= |
| 1366 : | |||
| 1367 : | |||
| 1368 : | |||
| 1369 : | |||
| 1370 : | |||
| 1371 : | |||
| 1372 : | |||
| 1373 : | |||
| 1374 : | |||
| 1375 : | |||
| 1376 : | |||
| 1377 : | |||
| 1378 : | |||
| 1379 : | |||
| 1380 : | |||
| 1381 : | |||
| 1382 : | |||
| 1383 : | |||
| 1384 : | |||
| 1385 : | |||
| 1386 : | |||
| 1387 : | |||
| 1388 : | |||
| 1389 : | |||
| 1390 : | |||
| 1391 : | |||
| 1392 : | |||
| 1393 : | |||
| 1394 : | |||
| 1395 : | |||
| 1396 : | |||
| 1397 : | |||
| 1398 : | |||
| 1399 : | |||
| 1400 : | |||
| 1401 : | |||
| 1402 : | |||
| 1403 : | |||
| 1404 : | |||
| 1405 : | |||
| 1406 : | |||
| 1407 : | |||
| 1408 : | |||
| 1409 : | |||
| 1410 : | |||
| 1411 : | |||
| 1412 : | |||
| 1413 : | |||
| 1414 : | |||
| 1415 : | |||
| 1416 : | |||
| 1417 : | |||
| 1418 : | |||
| 1419 : | |||
| 1420 : | |||
| 1421 : | |||
| 1422 : | |||
| 1423 : | |||
| 1424 : | |||
| 1425 : | |||
| 1426 : | |||
| 1427 : | |||
| 1428 : | |||
| 1429 : | |||
| 1430 : | |||
| 1431 : | |||
| 1432 : | |||
| 1433 : | |||
| 1434 : | |||
| 1435 : | |||
| 1436 : | |||
| 1437 : | |||
| 1438 : | |||
| 1439 : | |||
| 1440 : | |||
| 1441 : | |||
| 1442 : | |||
| 1443 : | |||
| 1444 : | |||
| 1445 : | |||
| 1446 : | |||
| 1447 : | |||
| 1448 : | |||
| 1449 : | |||
| 1450 : | |||
| 1451 : | |||
| 1452 : | |||
| 1453 : | |||
| 1454 : | |||
| 1455 : | |||
| 1456 : | |||
| 1457 : | |||
| 1458 : | |||
| 1459 : | |||
| 1460 : | |||
| 1461 : | |||
| 1462 : | |||
| 1463 : | |||
| 1464 : | |||
| 1465 : | |||
| 1466 : | |||
| 1467 : | |||
| 1468 : | |||
| 1469 : | |||
| 1470 : | |||
| 1471 : | |||
| 1472 : | |||
| 1473 : | |||
| 1474 : | |||
| 1475 : | |||
| 1476 : | |||
| 1477 : | |||
| 1478 : | |||
| 1479 : | |||
| 1480 : | |||
| 1481 : | |||
| 1482 : | |||
| 1483 : | |||
| 1484 : | |||
| 1485 : | |||
| 1486 : | |||
| 1487 : | |||
| 1488 : | |||
| 1489 : | |||
| 1490 : | |||
| 1491 : | |||
| 1492 : | |||
| 1493 : | |||
| 1494 : | |||
| 1495 : | |||
| 1496 : | |||
| 1497 : | |||
| 1498 : | |||
| 1499 : | |||
| 1500 : | |||
| 1501 : | >>>>>>> .theirs | ||
| 1502 : | root | 1 | } |
| 1503 : | |||
| 1504 : | |||
| 1505 : | mambo | 117 | <<<<<<< .mine |
| 1506 : | root | 1 | /** |
| 1507 : | * @param database A database connector object | ||
| 1508 : | */ | ||
| 1509 : | function mosCategory( &$db ) { | ||
| 1510 : | $this->mosDBTable( '#__categories', 'id', $db ); | ||
| 1511 : | } | ||
| 1512 : | // overloaded check function | ||
| 1513 : | function check() { | ||
| 1514 : | // check for valid name | ||
| 1515 : | if (trim( $this->title ) == '') { | ||
| 1516 : | csouza | 39 | $this->_error = T_("Your Category must contain a title."); |
| 1517 : | root | 1 | return false; |
| 1518 : | } | ||
| 1519 : | if (trim( $this->name ) == '') { | ||
| 1520 : | csouza | 39 | $this->_error = T_("Your Category must have a name."); |
| 1521 : | root | 1 | return false; |
| 1522 : | } | ||
| 1523 : | // check for existing name | ||
| 1524 : | $this->_db->setQuery( "SELECT id FROM #__categories " | ||
| 1525 : | . "\nWHERE name='".$this->name."' AND section='".$this->section."'" | ||
| 1526 : | ); | ||
| 1527 : | |||
| 1528 : | $xid = intval( $this->_db->loadResult() ); | ||
| 1529 : | if ($xid && $xid != intval( $this->id )) { | ||
| 1530 : | csouza | 39 | $this->_error = T_("There is a category already with that name, please try again."); |
| 1531 : | root | 1 | return false; |
| 1532 : | } | ||
| 1533 : | return true; | ||
| 1534 : | } | ||
| 1535 : | } | ||
| 1536 : | |||
| 1537 : | mambo | 117 | ======= |
| 1538 : | |||
| 1539 : | |||
| 1540 : | |||
| 1541 : | |||
| 1542 : | |||
| 1543 : | |||
| 1544 : | |||
| 1545 : | |||
| 1546 : | |||
| 1547 : | |||
| 1548 : | |||
| 1549 : | |||
| 1550 : | |||
| 1551 : | |||
| 1552 : | |||
| 1553 : | |||
| 1554 : | |||
| 1555 : | |||
| 1556 : | |||
| 1557 : | |||
| 1558 : | |||
| 1559 : | |||
| 1560 : | |||
| 1561 : | |||
| 1562 : | |||
| 1563 : | |||
| 1564 : | |||
| 1565 : | |||
| 1566 : | |||
| 1567 : | |||
| 1568 : | |||
| 1569 : | >>>>>>> .theirs | ||
| 1570 : | root | 1 | /** |
| 1571 : | mambo | 117 | * Component database table class |
| 1572 : | root | 1 | * @package Mambo |
| 1573 : | */ | ||
| 1574 : | mambo | 117 | class mosComponent extends mosDBTable { |
| 1575 : | root | 1 | /** @var int Primary key */ |
| 1576 : | var $id=null; | ||
| 1577 : | mambo | 117 | /** @var string */ |
| 1578 : | root | 1 | var $name=null; |
| 1579 : | /** @var string */ | ||
| 1580 : | mambo | 117 | var $link=null; |
| 1581 : | root | 1 | /** @var int */ |
| 1582 : | mambo | 117 | var $menuid=null; |
| 1583 : | root | 1 | /** @var int */ |
| 1584 : | mambo | 117 | var $parent=null; |
| 1585 : | root | 1 | /** @var string */ |
| 1586 : | mambo | 117 | <<<<<<< .mine |
| 1587 : | mambo | 116 | var $params=''; |
| 1588 : | root | 1 | |
| 1589 : | /** | ||
| 1590 : | * @param database A database connector object | ||
| 1591 : | */ | ||
| 1592 : | function mosSection( &$db ) { | ||
| 1593 : | $this->mosDBTable( '#__sections', 'id', $db ); | ||
| 1594 : | } | ||
| 1595 : | // overloaded check function | ||
| 1596 : | function check() { | ||
| 1597 : | // check for valid name | ||
| 1598 : | if (trim( $this->title ) == '') { | ||
| 1599 : | csouza | 39 | $this->_error = T_("Your Section must contain a title."); |
| 1600 : | root | 1 | return false; |
| 1601 : | } | ||
| 1602 : | if (trim( $this->name ) == '') { | ||
| 1603 : | csouza | 39 | $this->_error = T_("Your Section must have a name."); |
| 1604 : | root | 1 | return false; |
| 1605 : | } | ||
| 1606 : | // check for existing name | ||
| 1607 : | $this->_db->setQuery( "SELECT id FROM #__sections " | ||
| 1608 : | . "\nWHERE name='$this->name' AND scope='$this->scope'" | ||
| 1609 : | ); | ||
| 1610 : | |||
| 1611 : | $xid = intval( $this->_db->loadResult() ); | ||
| 1612 : | if ($xid && $xid != intval( $this->id )) { | ||
| 1613 : | csouza | 39 | $this->_error = T_("There is a section already with that name, please try again."); |
| 1614 : | root | 1 | return false; |
| 1615 : | } | ||
| 1616 : | return true; | ||
| 1617 : | } | ||
| 1618 : | } | ||
| 1619 : | |||
| 1620 : | /** | ||
| 1621 : | * Module database table class | ||
| 1622 : | * @package Mambo | ||
| 1623 : | */ | ||
| 1624 : | class mosContent extends mosDBTable { | ||
| 1625 : | /** @var int Primary key */ | ||
| 1626 : | var $id=null; | ||
| 1627 : | mambo | 117 | ======= |
| 1628 : | var $admin_menu_link=null; | ||
| 1629 : | root | 1 | |
| 1630 : | |||
| 1631 : | |||
| 1632 : | |||
| 1633 : | |||
| 1634 : | |||
| 1635 : | |||
| 1636 : | |||
| 1637 : | |||
| 1638 : | |||
| 1639 : | |||
| 1640 : | mambo | 117 | |
| 1641 : | |||
| 1642 : | |||
| 1643 : | |||
| 1644 : | |||
| 1645 : | |||
| 1646 : | |||
| 1647 : | |||
| 1648 : | |||
| 1649 : | |||
| 1650 : | |||
| 1651 : | |||
| 1652 : | |||
| 1653 : | |||
| 1654 : | |||
| 1655 : | |||
| 1656 : | |||
| 1657 : | |||
| 1658 : | |||
| 1659 : | |||
| 1660 : | |||
| 1661 : | |||
| 1662 : | |||
| 1663 : | |||
| 1664 : | |||
| 1665 : | |||
| 1666 : | |||
| 1667 : | |||
| 1668 : | >>>>>>> .theirs | ||
| 1669 : | root | 1 | /** @var string */ |
| 1670 : | mambo | 117 | var $admin_menu_alt=null; |
| 1671 : | root | 1 | /** @var string */ |
| 1672 : | mambo | 117 | var $option=null; |
| 1673 : | root | 1 | /** @var string */ |
| 1674 : | var $ordering=null; | ||
| 1675 : | /** @var string */ | ||
| 1676 : | mambo | 117 | var $admin_menu_img=null; |
| 1677 : | root | 1 | /** @var int */ |
| 1678 : | mambo | 117 | var $iscore=null; |
| 1679 : | root | 1 | /** @var string */ |
| 1680 : | var $params=null; | ||
| 1681 : | |||
| 1682 : | /** | ||
| 1683 : | * @param database A database connector object | ||
| 1684 : | */ | ||
| 1685 : | mambo | 117 | function mosComponent( &$db ) { |
| 1686 : | $this->mosDBTable( '#__components', 'id', $db ); | ||
| 1687 : | root | 1 | } |
| 1688 : | } | ||
| 1689 : | |||
| 1690 : | |||
| 1691 : | mambo | 117 | <<<<<<< .mine |
| 1692 : | root | 1 | /** |
| 1693 : | * @param database A database connector object | ||
| 1694 : | */ | ||
| 1695 : | function mosUser( &$database ) { | ||
| 1696 : | $this->mosDBTable( '#__users', 'id', $database ); | ||
| 1697 : | } | ||
| 1698 : | |||
| 1699 : | /** | ||
| 1700 : | * Validation and filtering | ||
| 1701 : | * @return boolean True is satisfactory | ||
| 1702 : | */ | ||
| 1703 : | function check() { | ||
| 1704 : | global $mosConfig_uniquemail; | ||
| 1705 : | |||
| 1706 : | // filter malicious code | ||
| 1707 : | //$this->filter(); | ||
| 1708 : | |||
| 1709 : | // Validate user information | ||
| 1710 : | if (trim( $this->name ) == '') { | ||
| 1711 : | csouza | 39 | $this->_error = T_('Please enter your name.'); |
| 1712 : | root | 1 | return false; |
| 1713 : | } | ||
| 1714 : | |||
| 1715 : | if (trim( $this->username ) == '') { | ||
| 1716 : | csouza | 39 | $this->_error = T_('Please enter a user name.'); |
| 1717 : | root | 1 | return false; |
| 1718 : | } | ||
| 1719 : | |||
| 1720 : | if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", $this->username) || strlen( $this->username ) < 3) { | ||
| 1721 : | csouza | 39 | $this->_error = sprintf( T_("Please enter a valid %s. No spaces, more than %d characters and containing only the characters 0-9,a-z, or A-Z"), T_('Username:'), 2 ); |
| 1722 : | root | 1 | return false; |
| 1723 : | } | ||
| 1724 : | |||
| 1725 : | if ((trim($this->email == "")) || (preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email )==false)) { | ||
| 1726 : | csouza | 39 | $this->_error = T_('Please enter a valid e-mail address.'); |
| 1727 : | root | 1 | return false; |
| 1728 : | } | ||
| 1729 : | |||
| 1730 : | // check for existing username | ||
| 1731 : | $this->_db->setQuery( "SELECT id FROM #__users " | ||
| 1732 : | . "\nWHERE LOWER(username)=LOWER('$this->username') AND id!='$this->id'" | ||
| 1733 : | ); | ||
| 1734 : | |||
| 1735 : | $xid = intval( $this->_db->loadResult() ); | ||
| 1736 : | if ($xid && $xid != intval( $this->id )) { | ||
| 1737 : | csouza | 39 | $this->_error = T_('This username/password is already in use. Please try another.'); |
| 1738 : | root | 1 | return false; |
| 1739 : | } | ||
| 1740 : | |||
| 1741 : | if ($mosConfig_uniquemail) { | ||
| 1742 : | // check for existing email | ||
| 1743 : | $this->_db->setQuery( "SELECT id FROM #__users " | ||
| 1744 : | . "\nWHERE email='$this->email' AND id!='$this->id'" | ||
| 1745 : | ); | ||
| 1746 : | |||
| 1747 : | $xid = intval( $this->_db->loadResult() ); | ||
| 1748 : | if ($xid && $xid != intval( $this->id )) { | ||
| 1749 : | csouza | 39 | $this->_error = T_('This e-mail is already registered. If you forgot the password click on "Password Reminder" and new password will be sent to you.'); |
| 1750 : | root | 1 | return false; |
| 1751 : | } | ||
| 1752 : | } | ||
| 1753 : | |||
| 1754 : | return true; | ||
| 1755 : | } | ||
| 1756 : | |||
| 1757 : | function store( $updateNulls=false ) { | ||
| 1758 : | global $acl, $migrate; | ||
| 1759 : | $section_value = 'users'; | ||
| 1760 : | |||
| 1761 : | $k = $this->_tbl_key; | ||
| 1762 : | $key = $this->$k; | ||
| 1763 : | if( $key && !$migrate) { | ||
| 1764 : | // existing record | ||
| 1765 : | $ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls ); | ||
| 1766 : | // syncronise ACL | ||
| 1767 : | // single group handled at the moment | ||
| 1768 : | // trivial to expand to multiple groups | ||
| 1769 : | $groups = $acl->get_object_groups( $section_value, $this->$k, 'ARO' ); | ||
| 1770 : | $acl->del_group_object( $groups[0], $section_value, $this->$k, 'ARO' ); | ||
| 1771 : | $acl->add_group_object( $this->gid, $section_value, $this->$k, 'ARO' ); | ||
| 1772 : | |||
| 1773 : | $object_id = $acl->get_object_id( $section_value, $this->$k, 'ARO' ); | ||
| 1774 : | $acl->edit_object( $object_id, $section_value, $this->_db->getEscaped( $this->name ), $this->$k, 0, 0, 'ARO' ); | ||
| 1775 : | } else { | ||
| 1776 : | // new record | ||
| 1777 : | $ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key ); | ||
| 1778 : | // syncronise ACL | ||
| 1779 : | $acl->add_object( $section_value, $this->_db->getEscaped( $this->name ), $this->$k, null, null, 'ARO' ); | ||
| 1780 : | $acl->add_group_object( $this->gid, $section_value, $this->$k, 'ARO' ); | ||
| 1781 : | } | ||
| 1782 : | if( !$ret ) { | ||
| 1783 : | $this->_error = strtolower(get_class( $this ))."::store failed <br />" . $this->_db->getErrorMsg(); | ||
| 1784 : | return false; | ||
| 1785 : | } else { | ||
| 1786 : | return true; | ||
| 1787 : | } | ||
| 1788 : | } | ||
| 1789 : | |||
| 1790 : | function delete( $oid=null ) { | ||
| 1791 : | global $acl; | ||
| 1792 : | |||
| 1793 : | $k = $this->_tbl_key; | ||
| 1794 : | if ($oid) { | ||
| 1795 : | $this->$k = intval( $oid ); | ||
| 1796 : | } | ||
| 1797 : | $aro_id = $acl->get_object_id( 'users', $this->$k, 'ARO' ); | ||
| 1798 : | // $acl->del_object( $aro_id, 'ARO', true ); | ||
| 1799 : | |||
| 1800 : | $this->_db->setQuery( "DELETE FROM $this->_tbl WHERE $this->_tbl_key = '".$this->$k."'" ); | ||
| 1801 : | |||
| 1802 : | if ($this->_db->query()) { | ||
| 1803 : | // cleanup related data | ||
| 1804 : | |||
| 1805 : | // :: private messaging | ||
| 1806 : | $this->_db->setQuery( "DELETE FROM #__messages_cfg WHERE user_id='".$this->$k."'" ); | ||
| 1807 : | if (!$this->_db->query()) { | ||
| 1808 : | $this->_error = $this->_db->getErrorMsg(); | ||
| 1809 : | return false; | ||
| 1810 : | } | ||
| 1811 : | $this->_db->setQuery( "DELETE FROM #__messages WHERE user_id_to='".$this->$k."'" ); | ||
| 1812 : | if (!$this->_db->query()) { | ||
| 1813 : | $this->_error = $this->_db->getErrorMsg(); | ||
| 1814 : | return false; | ||
| 1815 : | } | ||
| 1816 : | |||
| 1817 : | return true; | ||
| 1818 : | } else { | ||
| 1819 : | $this->_error = $this->_db->getErrorMsg(); | ||
| 1820 : | return false; | ||
| 1821 : | } | ||
| 1822 : | } | ||
| 1823 : | } | ||
| 1824 : | |||
| 1825 : | mambo | 117 | ======= |
| 1826 : | |||
| 1827 : | |||
| 1828 : | |||
| 1829 : | |||
| 1830 : | |||
| 1831 : | |||
| 1832 : | |||
| 1833 : | |||
| 1834 : | |||
| 1835 : | |||
| 1836 : | |||
| 1837 : | |||
| 1838 : | |||
| 1839 : | |||
| 1840 : | |||
| 1841 : | |||
| 1842 : | |||
| 1843 : | |||
| 1844 : | |||
| 1845 : | |||
| 1846 : | |||
| 1847 : | |||
| 1848 : | |||
| 1849 : | |||
| 1850 : | |||
| 1851 : | |||
| 1852 : | |||
| 1853 : | |||
| 1854 : | |||
| 1855 : | |||
| 1856 : | |||
| 1857 : | |||
| 1858 : | |||
| 1859 : | |||
| 1860 : | |||
| 1861 : | |||
| 1862 : | |||
| 1863 : | |||
| 1864 : | |||
| 1865 : | |||
| 1866 : | |||
| 1867 : | |||
| 1868 : | |||
| 1869 : | |||
| 1870 : | |||
| 1871 : | |||
| 1872 : | |||
| 1873 : | |||
| 1874 : | |||
| 1875 : | |||
| 1876 : | |||
| 1877 : | |||
| 1878 : | |||
| 1879 : | |||
| 1880 : | |||
| 1881 : | |||
| 1882 : | |||
| 1883 : | |||
| 1884 : | |||
| 1885 : | |||
| 1886 : | |||
| 1887 : | |||
| 1888 : | |||
| 1889 : | |||
| 1890 : | |||
| 1891 : | |||
| 1892 : | |||
| 1893 : | |||
| 1894 : | |||
| 1895 : | |||
| 1896 : | |||
| 1897 : | |||
| 1898 : | |||
| 1899 : | |||
| 1900 : | |||
| 1901 : | |||
| 1902 : | |||
| 1903 : | |||
| 1904 : | |||
| 1905 : | |||
| 1906 : | |||
| 1907 : | |||
| 1908 : | |||
| 1909 : | |||
| 1910 : | |||
| 1911 : | |||
| 1912 : | |||
| 1913 : | |||
| 1914 : | |||
| 1915 : | |||
| 1916 : | |||
| 1917 : | |||
| 1918 : | |||
| 1919 : | |||
| 1920 : | |||
| 1921 : | |||
| 1922 : | |||
| 1923 : | |||
| 1924 : | |||
| 1925 : | |||
| 1926 : | |||
| 1927 : | |||
| 1928 : | |||
| 1929 : | |||
| 1930 : | |||
| 1931 : | |||
| 1932 : | |||
| 1933 : | |||
| 1934 : | |||
| 1935 : | |||
| 1936 : | |||
| 1937 : | |||
| 1938 : | |||
| 1939 : | |||
| 1940 : | |||
| 1941 : | |||
| 1942 : | |||
| 1943 : | |||
| 1944 : | |||
| 1945 : | |||
| 1946 : | |||
| 1947 : | |||
| 1948 : | |||
| 1949 : | |||
| 1950 : | |||
| 1951 : | |||
| 1952 : | |||
| 1953 : | |||
| 1954 : | |||
| 1955 : | |||
| 1956 : | |||
| 1957 : | |||
| 1958 : | |||
| 1959 : | >>>>>>> .theirs | ||
| 1960 : | root | 1 | /** |
| 1961 : | * Template Table Class | ||
| 1962 : | * | ||
| 1963 : | * Provides access to the mos_templates table | ||
| 1964 : | * @package Mambo | ||
| 1965 : | */ | ||
| 1966 : | class mosTemplate extends mosDBTable { | ||
| 1967 : | /** @var int */ | ||
| 1968 : | var $id=null; | ||
| 1969 : | /** @var string */ | ||
| 1970 : | var $cur_template=null; | ||
| 1971 : | /** @var int */ | ||
| 1972 : | var $col_main=null; | ||
| 1973 : | |||
| 1974 : | /** | ||
| 1975 : | * @param database A database connector object | ||
| 1976 : | */ | ||
| 1977 : | function mosTemplate( &$database ) { | ||
| 1978 : | $this->mosDBTable( '#__templates', 'id', $database ); | ||
| 1979 : | } | ||
| 1980 : | } | ||
| 1981 : | |||
| 1982 : | /** | ||
| 1983 : | * Class mosMambot | ||
| 1984 : | * @package Mambo | ||
| 1985 : | */ | ||
| 1986 : | class mosMambot extends mosDBTable { | ||
| 1987 : | /** @var int */ | ||
| 1988 : | var $id=null; | ||
| 1989 : | /** @var varchar */ | ||
| 1990 : | var $name=null; | ||
| 1991 : | /** @var varchar */ | ||
| 1992 : | var $element=null; | ||
| 1993 : | /** @var varchar */ | ||
| 1994 : | var $folder=null; | ||
| 1995 : | /** @var tinyint unsigned */ | ||
| 1996 : | var $access=null; | ||
| 1997 : | /** @var int */ | ||
| 1998 : | var $ordering=null; | ||
| 1999 : | /** @var tinyint */ | ||
| 2000 : | var $published=null; | ||
| 2001 : | /** @var tinyint */ | ||
| 2002 : | var $iscore=null; | ||
| 2003 : | /** @var tinyint */ | ||
| 2004 : | var $client_id=null; | ||
| 2005 : | /** @var int unsigned */ | ||
| 2006 : | var $checked_out=null; | ||
| 2007 : | /** @var datetime */ | ||
| 2008 : | var $checked_out_time=null; | ||
| 2009 : | /** @var text */ | ||
| 2010 : | var $params=null; | ||
| 2011 : | |||
| 2012 : | function mosMambot( &$db ) { | ||
| 2013 : | $this->mosDBTable( '#__mambots', 'id', $db ); | ||
| 2014 : | } | ||
| 2015 : | } | ||
| 2016 : | |||
| 2017 : | /** | ||
| 2018 : | * Module database table class | ||
| 2019 : | * @package Mambo | ||
| 2020 : | */ | ||
| 2021 : | class mosModule extends mosDBTable { | ||
| 2022 : | /** @var int Primary key */ | ||
| 2023 : | var $id=null; | ||
| 2024 : | /** @var string */ | ||
| 2025 : | var $title=null; | ||
| 2026 : | /** @var string */ | ||
| 2027 : | var $showtitle=null; | ||
| 2028 : | /** @var int */ | ||
| 2029 : | var $content=null; | ||
| 2030 : | /** @var int */ | ||
| 2031 : | var $ordering=null; | ||
| 2032 : | /** @var string */ | ||
| 2033 : | var $position=null; | ||
| 2034 : | /** @var boolean */ | ||
| 2035 : | var $checked_out=null; | ||
| 2036 : | /** @var time */ | ||
| 2037 : | var $checked_out_time=null; | ||
| 2038 : | /** @var boolean */ | ||
| 2039 : | var $published=null; | ||
| 2040 : | /** @var string */ | ||
| 2041 : | var $module=null; | ||
| 2042 : | /** @var int */ | ||
| 2043 : | var $numnews=null; | ||
| 2044 : | /** @var int */ | ||
| 2045 : | var $access=null; | ||
| 2046 : | /** @var string */ | ||
| 2047 : | var $params=null; | ||
| 2048 : | /** @var string */ | ||
| 2049 : | var $iscore=null; | ||
| 2050 : | /** @var string */ | ||
| 2051 : | var $client_id=null; | ||
| 2052 : | |||
| 2053 : | /** | ||
| 2054 : | * @param database A database connector object | ||
| 2055 : | */ | ||
| 2056 : | function mosModule( &$db ) { | ||
| 2057 : | $this->mosDBTable( '#__modules', 'id', $db ); | ||
| 2058 : | } | ||
| 2059 : | // overloaded check function | ||
| 2060 : | function check() { | ||
| 2061 : | // check for valid name | ||
| 2062 : | if (trim( $this->title ) == '') { | ||
| 2063 : | $this->_error = "Your Module must contain a title."; | ||
| 2064 : | return false; | ||
| 2065 : | } | ||
| 2066 : | |||
| 2067 : | // limitation has been removed | ||
| 2068 : | // check for existing title | ||
| 2069 : | //$this->_db->setQuery( "SELECT id FROM #__modules" | ||
| 2070 : | //. "\nWHERE title='$this->title'" | ||
| 2071 : | //); | ||
| 2072 : | // check for module of same name | ||
| 2073 : | //$xid = intval( $this->_db->loadResult() ); | ||
| 2074 : | //if ($xid && $xid != intval( $this->id )) { | ||
| 2075 : | // $this->_error = "There is a module already with that name, please try again."; | ||
| 2076 : | // return false; | ||
| 2077 : | //} | ||
| 2078 : | return true; | ||
| 2079 : | } | ||
| 2080 : | } | ||
| 2081 : | |||
| 2082 : | |||
| 2083 : | |||
| 2084 : | mambo | 117 | <<<<<<< .mine |
| 2085 : | root | 1 | function insert() { |
| 2086 : | $ret = $this->_db->insertObject( $this->_tbl, $this ); | ||
| 2087 : | |||
| 2088 : | if( !$ret ) { | ||
| 2089 : | csouza | 39 | $this->_error = strtolower(get_class( $this ))."::store() ". T_('failed') ." <br />" . $this->_db->stderr(); |
| 2090 : | root | 1 | return false; |
| 2091 : | } else { | ||
| 2092 : | return true; | ||
| 2093 : | } | ||
| 2094 : | } | ||
| 2095 : | |||
| 2096 : | function update( $updateNulls=false ) { | ||
| 2097 : | $ret = $this->_db->updateObject( $this->_tbl, $this, 'session_id', $updateNulls ); | ||
| 2098 : | |||
| 2099 : | if( !$ret ) { | ||
| 2100 : | csouza | 39 | $this->_error = strtolower(get_class( $this ))."::store() ". T_('failed') ." <br />" . $this->_db->stderr(); |
| 2101 : | root | 1 | return false; |
| 2102 : | } else { | ||
| 2103 : | return true; | ||
| 2104 : | } | ||
| 2105 : | } | ||
| 2106 : | |||
| 2107 : | function generateId() { | ||
| 2108 : | $failsafe = 20; | ||
| 2109 : | $randnum = 0; | ||
| 2110 : | while ($failsafe--) { | ||
| 2111 : | $randnum = md5( uniqid( microtime(), 1 ) ); | ||
| 2112 : | if ($randnum != "") { | ||
| 2113 : | $cryptrandnum = md5( $randnum ); | ||
| 2114 : | $this->_db->setQuery( "SELECT $this->_tbl_key FROM $this->_tbl WHERE $this->_tbl_key=MD5('$randnum')" ); | ||
| 2115 : | if(!$result = $this->_db->query()) { | ||
| 2116 : | die( $this->_db->stderr( true )); | ||
| 2117 : | // todo: handle gracefully | ||
| 2118 : | } | ||
| 2119 : | if ($this->_db->getNumRows($result) == 0) { | ||
| 2120 : | break; | ||
| 2121 : | } | ||
| 2122 : | } | ||
| 2123 : | } | ||
| 2124 : | $this->_session_cookie = $randnum; | ||
| 2125 : | $this->session_id = md5( $randnum . $_SERVER['REMOTE_ADDR'] ); | ||
| 2126 : | } | ||
| 2127 : | |||
| 2128 : | function getCookie() { | ||
| 2129 : | return $this->_session_cookie; | ||
| 2130 : | } | ||
| 2131 : | |||
| 2132 : | function purge( $inc=1800 ) { | ||
| 2133 : | $past = time() - $inc; | ||
| 2134 : | $query = "DELETE FROM $this->_tbl" | ||
| 2135 : | . "\nWHERE (time < $past)"; | ||
| 2136 : | $this->_db->setQuery($query); | ||
| 2137 : | |||
| 2138 : | return $this->_db->query(); | ||
| 2139 : | } | ||
| 2140 : | } | ||
| 2141 : | |||
| 2142 : | |||
| 2143 : | function mosObjectToArray($p_obj) | ||
| 2144 : | { | ||
| 2145 : | $retarray = null; | ||
| 2146 : | if(is_object($p_obj)) | ||
| 2147 : | { | ||
| 2148 : | $retarray = array(); | ||
| 2149 : | foreach (get_object_vars($p_obj) as $k => $v) | ||
| 2150 : | { | ||
| 2151 : | if(is_object($v)) | ||
| 2152 : | $retarray[$k] = mosObjectToArray($v); | ||
| 2153 : | else | ||
| 2154 : | $retarray[$k] = $v; | ||
| 2155 : | } | ||
| 2156 : | } | ||
| 2157 : | return $retarray; | ||
| 2158 : | } | ||
| 2159 : | mambo | 117 | ======= |
| 2160 : | |||
| 2161 : | |||
| 2162 : | |||
| 2163 : | |||
| 2164 : | |||
| 2165 : | |||
| 2166 : | |||
| 2167 : | |||
| 2168 : | |||
| 2169 : | |||
| 2170 : | |||
| 2171 : | |||
| 2172 : | |||
| 2173 : | |||
| 2174 : | |||
| 2175 : | |||
| 2176 : | |||
| 2177 : | |||
| 2178 : | |||
| 2179 : | |||
| 2180 : | |||
| 2181 : | |||
| 2182 : | |||
| 2183 : | |||
| 2184 : | |||
| 2185 : | |||
| 2186 : | |||
| 2187 : | |||
| 2188 : | |||
| 2189 : | |||
| 2190 : | |||
| 2191 : | |||
| 2192 : | |||
| 2193 : | |||
| 2194 : | |||
| 2195 : | |||
| 2196 : | |||
| 2197 : | |||
| 2198 : | |||
| 2199 : | |||
| 2200 : | |||
| 2201 : | |||
| 2202 : | |||
| 2203 : | |||
| 2204 : | |||
| 2205 : | |||
| 2206 : | |||
| 2207 : | |||
| 2208 : | |||
| 2209 : | |||
| 2210 : | |||
| 2211 : | |||
| 2212 : | |||
| 2213 : | |||
| 2214 : | |||
| 2215 : | |||
| 2216 : | |||
| 2217 : | |||
| 2218 : | |||
| 2219 : | |||
| 2220 : | |||
| 2221 : | |||
| 2222 : | |||
| 2223 : | |||
| 2224 : | |||
| 2225 : | |||
| 2226 : | |||
| 2227 : | |||
| 2228 : | |||
| 2229 : | |||
| 2230 : | |||
| 2231 : | |||
| 2232 : | |||
| 2233 : | |||
| 2234 : | >>>>>>> .theirs | ||
| 2235 : | root | 1 | /** |
| 2236 : | mambo | 117 | <<<<<<< .mine |
| 2237 : | root | 1 | * Checks the user agent string against known browsers |
| 2238 : | */ | ||
| 2239 : | function mosGetBrowser( $agent ) { | ||
| 2240 : | require( "includes/agent_browser.php" ); | ||
| 2241 : | |||
| 2242 : | if (preg_match( "/msie[\/\sa-z]*([\d\.]*)/i", $agent, $m ) | ||
| 2243 : | && !preg_match( "/webtv/i", $agent ) | ||
| 2244 : | && !preg_match( "/omniweb/i", $agent ) | ||
| 2245 : | && !preg_match( "/opera/i", $agent )) { | ||
| 2246 : | // IE | ||
| 2247 : | return "MS Internet Explorer $m[1]"; | ||
| 2248 : | } else if (preg_match( "/netscape.?\/([\d\.]*)/i", $agent, $m )) { | ||
| 2249 : | // Netscape 6.x, 7.x ... | ||
| 2250 : | return "Netscape $m[1]"; | ||
| 2251 : | } else if ( preg_match( "/mozilla[\/\sa-z]*([\d\.]*)/i", $agent, $m ) | ||
| 2252 : | && !preg_match( "/gecko/i", $agent ) | ||
| 2253 : | && !preg_match( "/compatible/i", $agent ) | ||
| 2254 : | && !preg_match( "/opera/i", $agent ) | ||
| 2255 : | && !preg_match( "/galeon/i", $agent ) | ||
| 2256 : | && !preg_match( "/safari/i", $agent )) { | ||
| 2257 : | // Netscape 3.x, 4.x ... | ||
| 2258 : | return "Netscape $m[2]"; | ||
| 2259 : | } else { | ||
| 2260 : | // Other | ||
| 2261 : | $found = false; | ||
| 2262 : | foreach ($browserSearchOrder as $key) { | ||
| 2263 : | if (preg_match( "/$key.?\/([\d\.]*)/i", $agent, $m )) { | ||
| 2264 : | $name = "$browsersAlias[$key] $m[1]"; | ||
| 2265 : | return $name; | ||
| 2266 : | break; | ||
| 2267 : | } | ||
| 2268 : | } | ||
| 2269 : | } | ||
| 2270 : | |||
| 2271 : | return 'Unknown'; | ||
| 2272 : | } | ||
| 2273 : | |||
| 2274 : | /** | ||
| 2275 : | * Checks the user agent string against known operating systems | ||
| 2276 : | */ | ||
| 2277 : | function mosGetOS( $agent ) { | ||
| 2278 : | require( "includes/agent_os.php" ); | ||
| 2279 : | |||
| 2280 : | foreach ($osSearchOrder as $key) { | ||
| 2281 : | if (preg_match( "/$key/i", $agent )) { | ||
| 2282 : | return $osAlias[$key]; | ||
| 2283 : | break; | ||
| 2284 : | } | ||
| 2285 : | } | ||
| 2286 : | |||
| 2287 : | return 'Unknown'; | ||
| 2288 : | } | ||
| 2289 : | |||
| 2290 : | /** | ||
| 2291 : | * @param string SQL with ordering As value and 'name field' AS text | ||
| 2292 : | * @param integer The length of the truncated headline | ||
| 2293 : | */ | ||
| 2294 : | function mosGetOrderingList( $sql, $chop='30' ) { | ||
| 2295 : | global $database; | ||
| 2296 : | |||
| 2297 : | $order = array(); | ||
| 2298 : | $database->setQuery( $sql ); | ||
| 2299 : | if (!($orders = $database->loadObjectList())) { | ||
| 2300 : | if ($database->getErrorNum()) { | ||
| 2301 : | echo $database->stderr(); | ||
| 2302 : | return false; | ||
| 2303 : | } else { | ||
| 2304 : | $order[] = mosHTML::makeOption( 1, 'first' ); | ||
| 2305 : | return $order; | ||
| 2306 : | } | ||
| 2307 : | } | ||
| 2308 : | $order[] = mosHTML::makeOption( 0, '0 first' ); | ||
| 2309 : | for ($i=0, $n=count( $orders ); $i < $n; $i++) { | ||
| 2310 : | |||
| 2311 : | if (strlen($orders[$i]->text) > $chop) { | ||
| 2312 : | $text = substr($orders[$i]->text,0,$chop)."..."; | ||
| 2313 : | } else { | ||
| 2314 : | $text = $orders[$i]->text; | ||
| 2315 : | } | ||
| 2316 : | |||
| 2317 : | $order[] = mosHTML::makeOption( $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); | ||
| 2318 : | } | ||
| 2319 : | $order[] = mosHTML::makeOption( $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' last' ); | ||
| 2320 : | |||
| 2321 : | return $order; | ||
| 2322 : | } | ||
| 2323 : | |||
| 2324 : | /** | ||
| 2325 : | * Makes a variable safe to display in forms | ||
| 2326 : | * | ||
| 2327 : | * Object parameters that are non-string, array, object or start with underscore | ||
| 2328 : | * will be converted | ||
| 2329 : | * @param object An object to be parsed | ||
| 2330 : | * @param int The optional quote style for the htmlspecialchars function | ||
| 2331 : | * @param string|array An optional single field name or array of field names not | ||
| 2332 : | * to be parsed (eg, for a textarea) | ||
| 2333 : | */ | ||
| 2334 : | function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) { | ||
| 2335 : | if (is_object( $mixed )) { | ||
| 2336 : | foreach (get_object_vars( $mixed ) as $k => $v) { | ||
| 2337 : | if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) { | ||
| 2338 : | continue; | ||
| 2339 : | } | ||
| 2340 : | if (is_string( $exclude_keys ) && $k == $exclude_keys) { | ||
| 2341 : | continue; | ||
| 2342 : | } else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) { | ||
| 2343 : | continue; | ||
| 2344 : | } | ||
| 2345 : | $mixed->$k = htmlspecialchars( $v, $quote_style ); | ||
| 2346 : | } | ||
| 2347 : | } | ||
| 2348 : | } | ||
| 2349 : | |||
| 2350 : | /** | ||
| 2351 : | * Checks whether a menu option is within the users access level | ||
| 2352 : | * @param int Item id number | ||
| 2353 : | * @param string The menu option | ||
| 2354 : | * @param int The users group ID number | ||
| 2355 : | * @param database A database connector object | ||
| 2356 : | * @return boolean True if the visitor's group at least equal to the menu access | ||
| 2357 : | */ | ||
| 2358 : | function mosMenuCheck( $Itemid, $menu_option, $task, $gid ) { | ||
| 2359 : | global $database; | ||
| 2360 : | $dblink="index.php?option=$menu_option"; | ||
| 2361 : | if ($Itemid!="" && $Itemid!=0) { | ||
| 2362 : | $database->setQuery( "SELECT access FROM #__menu WHERE id='$Itemid'" ); | ||
| 2363 : | } else { | ||
| 2364 : | if ($task!="") { | ||
| 2365 : | $dblink.="&task=$task"; | ||
| 2366 : | } | ||
| 2367 : | $database->setQuery( "SELECT access FROM #__menu WHERE link like '$dblink%'" ); | ||
| 2368 : | } | ||
| 2369 : | $results = $database->loadObjectList(); | ||
| 2370 : | $access = 0; | ||
| 2371 : | //echo "<pre>"; print_r($results); echo "</pre>"; | ||
| 2372 : | foreach ($results as $result) { | ||
| 2373 : | $access = max( $access, $result->access ); | ||
| 2374 : | } | ||
| 2375 : | return ($access <= $gid); | ||
| 2376 : | } | ||
| 2377 : | |||
| 2378 : | /** | ||
| 2379 : | * Returns formated date according to current local and adds time offset | ||
| 2380 : | * @param string date in datetime format | ||
| 2381 : | * @param string format optional format for strftime | ||
| 2382 : | * @param offset time offset if different than global one | ||
| 2383 : | * @returns formated date | ||
| 2384 : | */ | ||
| 2385 : | function mosFormatDate( $date, $format="", $offset="" ){ | ||
| 2386 : | global $mosConfig_offset; | ||
| 2387 : | if ( $format == '' ) { | ||
| 2388 : | // %Y-%m-%d %H:%M:%S | ||
| 2389 : | $format = _DATE_FORMAT_LC; | ||
| 2390 : | } | ||
| 2391 : | if ( $offset == '' ) { | ||
| 2392 : | $offset = $mosConfig_offset; | ||
| 2393 : | } | ||
| 2394 : | if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) { | ||
| 2395 : | $date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] ); | ||
| 2396 : | $date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-'; | ||
| 2397 : | } | ||
| 2398 : | return $date; | ||
| 2399 : | } | ||
| 2400 : | |||
| 2401 : | /** | ||
| 2402 : | * Returns current date according to current local and time offset | ||
| 2403 : | * @param string format optional format for strftime | ||
| 2404 : | * @returns current date | ||
| 2405 : | */ | ||
| 2406 : | function mosCurrentDate( $format="" ) { | ||
| 2407 : | global $mosConfig_offset; | ||
| 2408 : | if ($format=="") { | ||
| 2409 : | $format = _DATE_FORMAT_LC; | ||
| 2410 : | } | ||
| 2411 : | $date = strftime( $format, time() + ($mosConfig_offset*60*60) ); | ||
| 2412 : | return $date; | ||
| 2413 : | } | ||
| 2414 : | |||
| 2415 : | /** | ||
| 2416 : | * Utility function to provide ToolTips | ||
| 2417 : | * @param string ToolTip text | ||
| 2418 : | * @param string Box title | ||
| 2419 : | * @returns HTML code for ToolTip | ||
| 2420 : | */ | ||
| 2421 : | function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#' ) { | ||
| 2422 : | global $mosConfig_live_site; | ||
| 2423 : | |||
| 2424 : | if ( $width ) { | ||
| 2425 : | $width = ', WIDTH, \''.$width .'\''; | ||
| 2426 : | } | ||
| 2427 : | if ( $title ) { | ||
| 2428 : | $title = ', CAPTION, \''.$title .'\''; | ||
| 2429 : | } | ||
| 2430 : | if ( !$text ) { | ||
| 2431 : | $image = $mosConfig_live_site . '/includes/js/ThemeOffice/'. $image; | ||
| 2432 : | $text = '<img src="'. $image .'" border="0" />'; | ||
| 2433 : | } | ||
| 2434 : | $style = 'style="text-decoration: none; color: #333;"'; | ||
| 2435 : | if ( $href ) { | ||
| 2436 : | $style = ''; | ||
| 2437 : | } | ||
| 2438 : | $tip = "<a href=\"". $href ."\" onMouseOver=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</a>"; | ||
| 2439 : | return $tip; | ||
| 2440 : | } | ||
| 2441 : | |||
| 2442 : | /** | ||
| 2443 : | * Utility function to provide Warning Icons | ||
| 2444 : | * @param string Warning text | ||
| 2445 : | * @param string Box title | ||
| 2446 : | * @returns HTML code for Warning | ||
| 2447 : | */ | ||
| 2448 : | function mosWarning($warning, $title='Mambo Warning') { | ||
| 2449 : | global $mosConfig_live_site; | ||
| 2450 : | $tip = "<a href=\"#\" onMouseOver=\"return overlib('" . $warning . "', CAPTION, '$title', BELOW, RIGHT);\" onmouseout=\"return nd();\"><img src=\"" . $mosConfig_live_site . "/includes/js/ThemeOffice/warning.png\" border=\"0\" /></a>"; | ||
| 2451 : | return $tip; | ||
| 2452 : | } | ||
| 2453 : | |||
| 2454 : | function mosCreateGUID(){ | ||
| 2455 : | srand((double)microtime()*1000000); | ||
| 2456 : | $r = rand ; | ||
| 2457 : | $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); | ||
| 2458 : | $m = md5 ($u); | ||
| 2459 : | return($m); | ||
| 2460 : | } | ||
| 2461 : | |||
| 2462 : | function mosCompressID( $ID ){ | ||
| 2463 : | return(Base64_encode(pack("H*",$ID))); | ||
| 2464 : | } | ||
| 2465 : | |||
| 2466 : | function mosExpandID( $ID ) { | ||
| 2467 : | return ( implode(unpack("H*",Base64_decode($ID)), '') ); | ||
| 2468 : | } | ||
| 2469 : | |||
| 2470 : | /** | ||
| 2471 : | * Page generation time | ||
| 2472 : | * @package Mambo | ||
| 2473 : | */ | ||
| 2474 : | class mosProfiler { | ||
| 2475 : | var $start=0; | ||
| 2476 : | var $prefix=''; | ||
| 2477 : | |||
| 2478 : | function mosProfiler( $prefix='' ) { | ||
| 2479 : | $this->start = $this->getmicrotime(); | ||
| 2480 : | $this->prefix = $prefix; | ||
| 2481 : | } | ||
| 2482 : | |||
| 2483 : | function mark( $label ) { | ||
| 2484 : | return sprintf ( "\n<div class=\"profiler\">$this->prefix %.3f $label</div>", $this->getmicrotime() - $this->start ); | ||
| 2485 : | } | ||
| 2486 : | |||
| 2487 : | function getmicrotime(){ | ||
| 2488 : | list($usec, $sec) = explode(" ",microtime()); | ||
| 2489 : | return ((float)$usec + (float)$sec); | ||
| 2490 : | } | ||
| 2491 : | } | ||
| 2492 : | |||
| 2493 : | /** | ||
| 2494 : | * Function to create a mail object for futher use (uses phpMailer) | ||
| 2495 : | * @param string From e-mail address | ||
| 2496 : | * @param string From name | ||
| 2497 : | * @param string E-mail subject | ||
| 2498 : | * @param string Message body | ||
| 2499 : | * @return object Mail object | ||
| 2500 : | */ | ||
| 2501 : | function mosCreateMail( $from='', $fromname='', $subject, $body ) { | ||
| 2502 : | global $mosConfig_absolute_path, $mosConfig_sendmail; | ||
| 2503 : | global $mosConfig_smtpauth, $mosConfig_smtpuser; | ||
| 2504 : | global $mosConfig_smtppass, $mosConfig_smtphost; | ||
| 2505 : | global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailer; | ||
| 2506 : | |||
| 2507 : | $mail = new mosPHPMailer(); | ||
| 2508 : | |||
| 2509 : | $mail->PluginDir = $mosConfig_absolute_path .'/includes/phpmailer/'; | ||
| 2510 : | $mail->SetLanguage( 'en', $mosConfig_absolute_path . '/includes/phpmailer/language/' ); | ||
| 2511 : | $mail->CharSet = substr_replace(_ISO, '', 0, 8); | ||
| 2512 : | $mail->IsMail(); | ||
| 2513 : | $mail->From = $from ? $from : $mosConfig_mailfrom; | ||
| 2514 : | $mail->FromName = $fromname ? $fromname : $mosConfig_fromname; | ||
| 2515 : | $mail->Mailer = $mosConfig_mailer; | ||
| 2516 : | |||
| 2517 : | // Add smtp values if needed | ||
| 2518 : | if ( $mosConfig_mailer == 'smtp' ) { | ||
| 2519 : | $mail->SMTPAuth = $mosConfig_smtpauth; | ||
| 2520 : | $mail->Username = $mosConfig_smtpuser; | ||
| 2521 : | $mail->Password = $mosConfig_smtppass; | ||
| 2522 : | $mail->Host = $mosConfig_smtphost; | ||
| 2523 : | } else | ||
| 2524 : | |||
| 2525 : | // Set sendmail path | ||
| 2526 : | if ( $mosConfig_mailer == 'sendmail' ) { | ||
| 2527 : | if (isset($mosConfig_sendmail)) | ||
| 2528 : | $mail->Sendmail = $mosConfig_sendmail; | ||
| 2529 : | } // if | ||
| 2530 : | |||
| 2531 : | $mail->Subject = $subject; | ||
| 2532 : | $mail->Body = $body; | ||
| 2533 : | |||
| 2534 : | return $mail; | ||
| 2535 : | } | ||
| 2536 : | |||
| 2537 : | /** | ||
| 2538 : | * Mail function (uses phpMailer) | ||
| 2539 : | * @param string From e-mail address | ||
| 2540 : | * @param string From name | ||
| 2541 : | * @param string/array Recipient e-mail address(es) | ||
| 2542 : | * @param string E-mail subject | ||
| 2543 : | * @param string Message body | ||
| 2544 : | * @param boolean false = plain text, true = HTML | ||
| 2545 : | * @param string/array CC e-mail address(es) | ||
| 2546 : | * @param string/array BCC e-mail address(es) | ||
| 2547 : | * @param string/array Attachment file name(s) | ||
| 2548 : | * @param string/array Reply-to e-mail address | ||
| 2549 : | * @param string/array Reply-to name | ||
| 2550 : | */ | ||
| 2551 : | function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { | ||
| 2552 : | global $mosConfig_debug; | ||
| 2553 : | $mail = mosCreateMail( $from, $fromname, $subject, $body ); | ||
| 2554 : | |||
| 2555 : | // activate HTML formatted emails | ||
| 2556 : | if ( $mode ) { | ||
| 2557 : | $mail->IsHTML(true); | ||
| 2558 : | } | ||
| 2559 : | |||
| 2560 : | if( is_array($recipient) ) { | ||
| 2561 : | foreach ($recipient as $to) { | ||
| 2562 : | $mail->AddAddress($to); | ||
| 2563 : | } | ||
| 2564 : | } else { | ||
| 2565 : | $mail->AddAddress($recipient); | ||
| 2566 : | } | ||
| 2567 : | if (isset($cc)) { | ||
| 2568 : | if( is_array($cc) ) | ||
| 2569 : | foreach ($cc as $to) $mail->AddCC($to); | ||
| 2570 : | else | ||
| 2571 : | $mail->AddCC($cc); | ||
| 2572 : | } | ||
| 2573 : | if (isset($bcc)) { | ||
| 2574 : | if( is_array($bcc) ) | ||
| 2575 : | foreach ($bcc as $to) $mail->AddBCC($to); | ||
| 2576 : | else | ||
| 2577 : | $mail->AddBCC($bcc); | ||
| 2578 : | } | ||
| 2579 : | if ($attachment) { | ||
| 2580 : | if ( is_array($attachment) ) | ||
| 2581 : | foreach ($attachment as $fname) $mail->AddAttachment($fname); | ||
| 2582 : | else | ||
| 2583 : | $mail->AddAttachment($attachment); | ||
| 2584 : | } // if | ||
| 2585 : | if ($replyto) { | ||
| 2586 : | if ( is_array($replyto) ) { | ||
| 2587 : | reset($replytoname); | ||
| 2588 : | foreach ($replyto as $to) { | ||
| 2589 : | $toname = ((list($key, $value) = each($replytoname)) | ||
| 2590 : | ? $value : ""); | ||
| 2591 : | $mail->AddReplyTo($to, $toname); | ||
| 2592 : | } | ||
| 2593 : | } else | ||
| 2594 : | $mail->AddReplyTo($replyto, $replytoname); | ||
| 2595 : | } | ||
| 2596 : | $mailssend = $mail->Send(); | ||
| 2597 : | |||
| 2598 : | if( $mosConfig_debug ) { | ||
| 2599 : | //$mosDebug->message( "Mails send: $mailssend"); | ||
| 2600 : | } | ||
| 2601 : | if( $mail->error_count > 0 ) { | ||
| 2602 : | //$mosDebug->message( "The mail message $fromname <$from> about $subject to $recipient <b>failed</b><br /><pre>$body</pre>", false ); | ||
| 2603 : | //$mosDebug->message( "Mailer Error: " . $mail->ErrorInfo . "" ); | ||
| 2604 : | } | ||
| 2605 : | return $mailssend; | ||
| 2606 : | } // mosMail | ||
| 2607 : | |||
| 2608 : | /** | ||
| 2609 : | * Initialise GZIP | ||
| 2610 : | */ | ||
| 2611 : | function initGzip() { | ||
| 2612 : | global $mosConfig_gzip, $do_gzip_compress; | ||
| 2613 : | $do_gzip_compress = FALSE; | ||
| 2614 : | csouza | 39 | |
| 2615 : | root | 1 | //zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
| 2616 : | //that zlib.output_compression is not enable in the php.ini before turning on ob_gzhandler | ||
| 2617 : | if ( $mosConfig_gzip == 1 && (int)ini_get('zlib.output_compression') != 1 ) { | ||
| 2618 : | $phpver = phpversion(); | ||
| 2619 : | $useragent = mosGetParam( $_SERVER, 'HTTP_USER_AGENT', '' ); | ||
| 2620 : | $canZip = mosGetParam( $_SERVER, 'HTTP_ACCEPT_ENCODING', '' ); | ||
| 2621 : | |||
| 2622 : | if ( $phpver >= '4.0.4pl1' && | ||
| 2623 : | ( strpos($useragent,'compatible') !== false || | ||
| 2624 : | strpos($useragent,'Gecko') !== false | ||
| 2625 : | ) | ||
| 2626 : | ) { | ||
| 2627 : | if ( extension_loaded('zlib') ) { | ||
| 2628 : | ob_start( 'ob_gzhandler' ); | ||
| 2629 : | return; | ||
| 2630 : | } | ||
| 2631 : | } else if ( $phpver > '4.0' ) { | ||
| 2632 : | if ( strpos($canZip,'gzip') !== false ) { | ||
| 2633 : | if (extension_loaded( 'zlib' )) { | ||
| 2634 : | $do_gzip_compress = TRUE; | ||
| 2635 : | ob_start(); | ||
| 2636 : | ob_implicit_flush(0); | ||
| 2637 : | |||
| 2638 : | header( 'Content-Encoding: gzip' ); | ||
| 2639 : | return; | ||
| 2640 : | } | ||
| 2641 : | } | ||
| 2642 : | } | ||
| 2643 : | } | ||
| 2644 : | ob_start(); | ||
| 2645 : | } | ||
| 2646 : | |||
| 2647 : | /** | ||
| 2648 : | * Perform GZIP | ||
| 2649 : | */ | ||
| 2650 : | function doGzip() { | ||
| 2651 : | global $do_gzip_compress; | ||
| 2652 : | if ( $do_gzip_compress ) { | ||
| 2653 : | /** | ||
| 2654 : | *Borrowed from php.net! | ||
| 2655 : | */ | ||
| 2656 : | $gzip_contents = ob_get_contents(); | ||
| 2657 : | ob_end_clean(); | ||
| 2658 : | |||
| 2659 : | $gzip_size = strlen($gzip_contents); | ||
| 2660 : | $gzip_crc = crc32($gzip_contents); | ||
| 2661 : | |||
| 2662 : | $gzip_contents = gzcompress($gzip_contents, 9); | ||
| 2663 : | $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4); | ||
| 2664 : | |||
| 2665 : | echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; | ||
| 2666 : | echo $gzip_contents; | ||
| 2667 : | echo pack('V', $gzip_crc); | ||
| 2668 : | echo pack('V', $gzip_size); | ||
| 2669 : | } else { | ||
| 2670 : | ob_end_flush(); | ||
| 2671 : | } | ||
| 2672 : | } | ||
| 2673 : | |||
| 2674 : | /** | ||
| 2675 : | * Random password generator | ||
| 2676 : | * @return password | ||
| 2677 : | */ | ||
| 2678 : | function mosMakePassword() { | ||
| 2679 : | $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | ||
| 2680 : | $len = strlen($salt); | ||
| 2681 : | $makepass=""; | ||
| 2682 : | mt_srand(10000000*(double)microtime()); | ||
| 2683 : | for ($i = 0; $i < 8; $i++) | ||
| 2684 : | $makepass .= $salt[mt_rand(0,$len - 1)]; | ||
| 2685 : | return $makepass; | ||
| 2686 : | } | ||
| 2687 : | |||
| 2688 : | if (!function_exists('html_entity_decode')) { | ||
| 2689 : | /** | ||
| 2690 : | * html_entity_decode function for backward compatability in PHP | ||
| 2691 : | * @param string | ||
| 2692 : | * @param string | ||
| 2693 : | */ | ||
| 2694 : | function html_entity_decode ($string, $opt = ENT_COMPAT) { | ||
| 2695 : | |||
| 2696 : | $trans_tbl = get_html_translation_table (HTML_ENTITIES); | ||
| 2697 : | $trans_tbl = array_flip ($trans_tbl); | ||
| 2698 : | |||
| 2699 : | if ($opt & 1) { // Translating single quotes | ||
| 2700 : | // Add single quote to translation table; | ||
| 2701 : | // doesn't appear to be there by default | ||
| 2702 : | $trans_tbl["'"] = "'"; | ||
| 2703 : | } | ||
| 2704 : | |||
| 2705 : | if (!($opt & 2)) { // Not translating double quotes | ||
| 2706 : | // Remove double quote from translation table | ||
| 2707 : | unset($trans_tbl["""]); | ||
| 2708 : | } | ||
| 2709 : | |||
| 2710 : | return strtr ($string, $trans_tbl); | ||
| 2711 : | } | ||
| 2712 : | } | ||
| 2713 : | |||
| 2714 : | /** | ||
| 2715 : | * Plugin handler | ||
| 2716 : | * @package Mambo | ||
| 2717 : | */ | ||
| 2718 : | class mosMambotHandler { | ||
| 2719 : | /** @var array An array of functions in event groups */ | ||
| 2720 : | var $_events=null; | ||
| 2721 : | /** @var array An array of lists */ | ||
| 2722 : | var $_lists=null; | ||
| 2723 : | /** @var array An array of mambots */ | ||
| 2724 : | var $_bots=null; | ||
| 2725 : | /** @var int Index of the mambot being loaded */ | ||
| 2726 : | var $_loading=null; | ||
| 2727 : | |||
| 2728 : | /** | ||
| 2729 : | * Constructor | ||
| 2730 : | */ | ||
| 2731 : | function mosMambotHandler() { | ||
| 2732 : | $this->_events = array(); | ||
| 2733 : | } | ||
| 2734 : | /** | ||
| 2735 : | * Loads all the bot files for a particular group | ||
| 2736 : | * @param string The group name, relates to the sub-directory in the mambots directory | ||
| 2737 : | */ | ||
| 2738 : | function loadBotGroup( $group ) { | ||
| 2739 : | global $database, $my, $mosConfig_absolute_path; | ||
| 2740 : | global $_MAMBOTS; | ||
| 2741 : | |||
| 2742 : | $group = trim( $group ); | ||
| 2743 : | $database->setQuery( "SELECT folder, element, published, CONCAT_WS('/',folder,element) AS lookup" | ||
| 2744 : | . "\nFROM #__mambots" | ||
| 2745 : | . "\nWHERE published >= 1 AND access <= $my->gid AND folder='$group'" | ||
| 2746 : | . "\nORDER BY ordering" | ||
| 2747 : | ); | ||
| 2748 : | if (!($bots = $database->loadObjectList())) { | ||
| 2749 : | //echo "Error loading Mambots: " . $database->getErrorMsg(); | ||
| 2750 : | return false; | ||
| 2751 : | } | ||
| 2752 : | $n = count( $bots); | ||
| 2753 : | for ($i = 0; $i < $n; $i++) { | ||
| 2754 : | $path = $mosConfig_absolute_path . '/mambots/' . $bots[$i]->folder . '/' . $bots[$i]->element . '.php'; | ||
| 2755 : | if (file_exists( $path )) { | ||
| 2756 : | $this->_loading = count( $this->_bots ); | ||
| 2757 : | $this->_bots[] = $bots[$i]; | ||
| 2758 : | require_once( $path ); | ||
| 2759 : | $this->_loading = null; | ||
| 2760 : | } | ||
| 2761 : | } | ||
| 2762 : | return true; | ||
| 2763 : | } | ||
| 2764 : | /** | ||
| 2765 : | * Registers a function to a particular event group | ||
| 2766 : | * @param string The event name | ||
| 2767 : | * @param string The function name | ||
| 2768 : | */ | ||
| 2769 : | function registerFunction( $event, $function ) { | ||
| 2770 : | $this->_events[$event][] = array( $function, $this->_loading ); | ||
| 2771 : | } | ||
| 2772 : | /** | ||
| 2773 : | * Makes a option for a particular list in a group | ||
| 2774 : | * @param string The group name | ||
| 2775 : | * @param string The list name | ||
| 2776 : | * @param string The value for the list option | ||
| 2777 : | * @param string The text for the list option | ||
| 2778 : | */ | ||
| 2779 : | function addListOption( $group, $listName, $value, $text='' ) { | ||
| 2780 : | $this->_lists[$group][$listName][] = mosHTML::makeOption( $value, $text ); | ||
| 2781 : | } | ||
| 2782 : | /** | ||
| 2783 : | * @param string The group name | ||
| 2784 : | * @param string The list name | ||
| 2785 : | * @return array | ||
| 2786 : | */ | ||
| 2787 : | function getList( $group, $listName ) { | ||
| 2788 : | return $this->_lists[$group][$listName]; | ||
| 2789 : | } | ||
| 2790 : | /** | ||
| 2791 : | * Calls all functions associated with an event group | ||
| 2792 : | * @param string The event name | ||
| 2793 : | * @param array An array of arguments | ||
| 2794 : | * @param boolean True is unpublished bots are to be processed | ||
| 2795 : | * @return array An array of results from each function call | ||
| 2796 : | */ | ||
| 2797 : | function trigger( $event, $args=null, $doUnpublished=false ) { | ||
| 2798 : | $result = array(); | ||
| 2799 : | |||
| 2800 : | if ($args === null) { | ||
| 2801 : | $args = array(); | ||
| 2802 : | } | ||
| 2803 : | if ($doUnpublished) { | ||
| 2804 : | // prepend the published argument | ||
| 2805 : | array_unshift( $args, null ); | ||
| 2806 : | } | ||
| 2807 : | if (isset( $this->_events[$event] )) { | ||
| 2808 : | foreach ($this->_events[$event] as $func) { | ||
| 2809 : | if (function_exists( $func[0] )) { | ||
| 2810 : | if ($doUnpublished) { | ||
| 2811 : | $args[0] = $this->_bots[$func[1]]->published; | ||
| 2812 : | $result[] = call_user_func_array( $func[0], $args ); | ||
| 2813 : | } else if ($this->_bots[$func[1]]->published) { | ||
| 2814 : | $result[] = call_user_func_array( $func[0], $args ); | ||
| 2815 : | } | ||
| 2816 : | } | ||
| 2817 : | } | ||
| 2818 : | } | ||
| 2819 : | return $result; | ||
| 2820 : | } | ||
| 2821 : | /** | ||
| 2822 : | * Same as trigger but only returns the first event and | ||
| 2823 : | * allows for a variable argument list | ||
| 2824 : | * @param string The event name | ||
| 2825 : | * @return array The result of the first function call | ||
| 2826 : | */ | ||
| 2827 : | function call( $event ) { | ||
| 2828 : | $doUnpublished=false; | ||
| 2829 : | |||
| 2830 : | $args =& func_get_args(); | ||
| 2831 : | array_shift( $args ); | ||
| 2832 : | |||
| 2833 : | if (isset( $this->_events[$event] )) { | ||
| 2834 : | foreach ($this->_events[$event] as $func) { | ||
| 2835 : | if (function_exists( $func[0] )) { | ||
| 2836 : | if ($this->_bots[$func[1]]->published) { | ||
| 2837 : | return call_user_func_array( $func[0], $args ); | ||
| 2838 : | } | ||
| 2839 : | } | ||
| 2840 : | } | ||
| 2841 : | } | ||
| 2842 : | return null; | ||
| 2843 : | } | ||
| 2844 : | } | ||
| 2845 : | |||
| 2846 : | /** | ||
| 2847 : | mambo | 117 | ======= |
| 2848 : | |||
| 2849 : | |||
| 2850 : | |||
| 2851 : | |||
| 2852 : | |||
| 2853 : | |||
| 2854 : | |||
| 2855 : | |||
| 2856 : | |||
| 2857 : | |||
| 2858 : | |||
| 2859 : | |||
| 2860 : | |||
| 2861 : | |||
| 2862 : | |||
| 2863 : | |||
| 2864 : | |||
| 2865 : | |||
| 2866 : | |||
| 2867 : | |||
| 2868 : | |||
| 2869 : | |||
| 2870 : | |||
| 2871 : | |||
| 2872 : | |||
| 2873 : | |||
| 2874 : | |||
| 2875 : | |||
| 2876 : | |||
| 2877 : | |||
| 2878 : | |||
| 2879 : | |||
| 2880 : | |||
| 2881 : | |||
| 2882 : | |||
| 2883 : | |||
| 2884 : | |||
| 2885 : | |||
| 2886 : | |||
| 2887 : | |||
| 2888 : | |||
| 2889 : | |||
| 2890 : | |||
| 2891 : | |||
| 2892 : | |||
| 2893 : | |||
| 2894 : | |||
| 2895 : | |||
| 2896 : | |||
| 2897 : | |||
| 2898 : | |||
| 2899 : | |||
| 2900 : | |||
| 2901 : | |||
| 2902 : | |||
| 2903 : | |||
| 2904 : | |||
| 2905 : | |||
| 2906 : | |||
| 2907 : | |||
| 2908 : | |||
| 2909 : | |||
| 2910 : | |||
| 2911 : | |||
| 2912 : | |||
| 2913 : | |||
| 2914 : | |||
| 2915 : | |||
| 2916 : | |||
| 2917 : | |||
| 2918 : | |||
| 2919 : | |||
| 2920 : | |||
| 2921 : | |||
| 2922 : | |||
| 2923 : | |||
| 2924 : | |||
| 2925 : | |||
| 2926 : | |||
| 2927 : | |||
| 2928 : | |||
| 2929 : | |||
| 2930 : | |||
| 2931 : | |||
| 2932 : | |||
| 2933 : | |||
| 2934 : | |||
| 2935 : | |||
| 2936 : | |||
| 2937 : | |||
| 2938 : | |||
| 2939 : | |||
| 2940 : | |||
| 2941 : | |||
| 2942 : | |||
| 2943 : | |||
| 2944 : | |||
| 2945 : | |||
| 2946 : | |||
| 2947 : | |||
| 2948 : | |||
| 2949 : | |||
| 2950 : | |||
| 2951 : | |||
| 2952 : | |||
| 2953 : | |||
| 2954 : | |||
| 2955 : | |||
| 2956 : | |||
| 2957 : | |||
| 2958 : | |||
| 2959 : | |||
| 2960 : | |||
| 2961 : | |||
| 2962 : | |||
| 2963 : | |||
| 2964 : | |||
| 2965 : | |||
| 2966 : | |||
| 2967 : | |||
| 2968 : | |||
| 2969 : | |||
| 2970 : | |||
| 2971 : | |||
| 2972 : | |||
| 2973 : | |||
| 2974 : | |||
| 2975 : | |||
| 2976 : | |||
| 2977 : | |||
| 2978 : | |||
| 2979 : | |||
| 2980 : | |||
| 2981 : | |||
| 2982 : | |||
| 2983 : | |||
| 2984 : | |||
| 2985 : | |||
| 2986 : | |||
| 2987 : | |||
| 2988 : | |||
| 2989 : | |||
| 2990 : | |||
| 2991 : | |||
| 2992 : | |||
| 2993 : | |||
| 2994 : | |||
| 2995 : | |||
| 2996 : | |||
| 2997 : | |||
| 2998 : | |||
| 2999 : | |||
| 3000 : | |||
| 3001 : | |||
| 3002 : | |||
| 3003 : | |||
| 3004 : | |||
| 3005 : | |||
| 3006 : | |||
| 3007 : | |||
| 3008 : | |||
| 3009 : | |||
| 3010 : | |||
| 3011 : | |||
| 3012 : | |||
| 3013 : | |||
| 3014 : | |||
| 3015 : | |||
| 3016 : | |||
| 3017 : | |||
| 3018 : | |||
| 3019 : | |||
| 3020 : | |||
| 3021 : | |||
| 3022 : | |||
| 3023 : | |||
| 3024 : | |||
| 3025 : | |||
| 3026 : | |||
| 3027 : | |||
| 3028 : | |||
| 3029 : | |||
| 3030 : | |||
| 3031 : | |||
| 3032 : | |||
| 3033 : | |||
| 3034 : | |||
| 3035 : | |||
| 3036 : | |||
| 3037 : | |||
| 3038 : | |||
| 3039 : | |||
| 3040 : | |||
| 3041 : | |||
| 3042 : | |||
| 3043 : | |||
| 3044 : | |||
| 3045 : | |||
| 3046 : | |||
| 3047 : | |||
| 3048 : | |||
| 3049 : | |||
| 3050 : | |||
| 3051 : | |||
| 3052 : | |||
| 3053 : | |||
| 3054 : | |||
| 3055 : | |||
| 3056 : | |||
| 3057 : | |||
| 3058 : | |||
| 3059 : | |||
| 3060 : | |||
| 3061 : | |||
| 3062 : | |||
| 3063 : | |||
| 3064 : | |||
| 3065 : | |||
| 3066 : | |||
| 3067 : | |||
| 3068 : | |||
| 3069 : | |||
| 3070 : | |||
| 3071 : | |||
| 3072 : | |||
| 3073 : | |||
| 3074 : | |||
| 3075 : | |||
| 3076 : | |||
| 3077 : | |||
| 3078 : | |||
| 3079 : | |||
| 3080 : | |||
| 3081 : | |||
| 3082 : | |||
| 3083 : | |||
| 3084 : | |||
| 3085 : | |||
| 3086 : | |||
| 3087 : | |||
| 3088 : | |||
| 3089 : | |||
| 3090 : | |||
| 3091 : | |||
| 3092 : | |||
| 3093 : | |||
| 3094 : | |||
| 3095 : | |||
| 3096 : | |||
| 3097 : | |||
| 3098 : | |||
| 3099 : | |||
| 3100 : | |||
| 3101 : | |||
| 3102 : | |||
| 3103 : | |||
| 3104 : | |||
| 3105 : | |||
| 3106 : | |||
| 3107 : | |||
| 3108 : | |||
| 3109 : | |||
| 3110 : | |||
| 3111 : | |||
| 3112 : | |||
| 3113 : | |||
| 3114 : | |||
| 3115 : | |||
| 3116 : | |||
| 3117 : | |||
| 3118 : | |||
| 3119 : | |||
| 3120 : | |||
| 3121 : | |||
| 3122 : | |||
| 3123 : | |||
| 3124 : | |||
| 3125 : | |||
| 3126 : | |||
| 3127 : | |||
| 3128 : | |||
| 3129 : | |||
| 3130 : | |||
| 3131 : | |||
| 3132 : | |||
| 3133 : | |||
| 3134 : | |||
| 3135 : | |||
| 3136 : | |||
| 3137 : | |||
| 3138 : | |||
| 3139 : | |||
| 3140 : | |||
| 3141 : | |||
| 3142 : | |||
| 3143 : | |||
| 3144 : | |||
| 3145 : | |||
| 3146 : | |||
| 3147 : | |||
| 3148 : | |||
| 3149 : | |||
| 3150 : | |||
| 3151 : | |||
| 3152 : | |||
| 3153 : | |||
| 3154 : | |||
| 3155 : | |||
| 3156 : | |||
| 3157 : | |||
| 3158 : | |||
| 3159 : | |||
| 3160 : | |||
| 3161 : | |||
| 3162 : | |||
| 3163 : | |||
| 3164 : | |||
| 3165 : | |||
| 3166 : | |||
| 3167 : | |||
| 3168 : | |||
| 3169 : | |||
| 3170 : | |||
| 3171 : | |||
| 3172 : | |||
| 3173 : | |||
| 3174 : | |||
| 3175 : | |||
| 3176 : | |||
| 3177 : | |||
| 3178 : | |||
| 3179 : | |||
| 3180 : | |||
| 3181 : | |||
| 3182 : | |||
| 3183 : | |||
| 3184 : | |||
| 3185 : | |||
| 3186 : | |||
| 3187 : | |||
| 3188 : | |||
| 3189 : | |||
| 3190 : | |||
| 3191 : | |||
| 3192 : | |||
| 3193 : | |||
| 3194 : | |||
| 3195 : | |||
| 3196 : | |||
| 3197 : | |||
| 3198 : | |||
| 3199 : | |||
| 3200 : | |||
| 3201 : | |||
| 3202 : | |||
| 3203 : | |||
| 3204 : | |||
| 3205 : | |||
| 3206 : | |||
| 3207 : | |||
| 3208 : | |||
| 3209 : | |||
| 3210 : | |||
| 3211 : | |||
| 3212 : | |||
| 3213 : | |||
| 3214 : | |||
| 3215 : | |||
| 3216 : | |||
| 3217 : | |||
| 3218 : | |||
| 3219 : | |||
| 3220 : | |||
| 3221 : | |||
| 3222 : | |||
| 3223 : | |||
| 3224 : | |||
| 3225 : | |||
| 3226 : | |||
| 3227 : | |||
| 3228 : | |||
| 3229 : | |||
| 3230 : | |||
| 3231 : | |||
| 3232 : | |||
| 3233 : | |||
| 3234 : | |||
| 3235 : | |||
| 3236 : | |||
| 3237 : | |||
| 3238 : | |||
| 3239 : | |||
| 3240 : | |||
| 3241 : | |||
| 3242 : | |||
| 3243 : | |||
| 3244 : | |||
| 3245 : | |||
| 3246 : | |||
| 3247 : | |||
| 3248 : | |||
| 3249 : | |||
| 3250 : | |||
| 3251 : | |||
| 3252 : | |||
| 3253 : | |||
| 3254 : | |||
| 3255 : | |||
| 3256 : | |||
| 3257 : | |||
| 3258 : | |||
| 3259 : | |||
| 3260 : | |||
| 3261 : | |||
| 3262 : | |||
| 3263 : | |||
| 3264 : | |||
| 3265 : | |||
| 3266 : | |||
| 3267 : | |||
| 3268 : | |||
| 3269 : | |||
| 3270 : | |||
| 3271 : | |||
| 3272 : | |||
| 3273 : | |||
| 3274 : | |||
| 3275 : | |||
| 3276 : | |||
| 3277 : | |||
| 3278 : | |||
| 3279 : | |||
| 3280 : | |||
| 3281 : | |||
| 3282 : | |||
| 3283 : | |||
| 3284 : | |||
| 3285 : | |||
| 3286 : | |||
| 3287 : | |||
| 3288 : | |||
| 3289 : | |||
| 3290 : | |||
| 3291 : | |||
| 3292 : | |||
| 3293 : | |||
| 3294 : | |||
| 3295 : | |||
| 3296 : | |||
| 3297 : | |||
| 3298 : | |||
| 3299 : | |||
| 3300 : | |||
| 3301 : | |||
| 3302 : | |||
| 3303 : | |||
| 3304 : | |||
| 3305 : | |||
| 3306 : | |||
| 3307 : | |||
| 3308 : | |||
| 3309 : | |||
| 3310 : | |||
| 3311 : | |||
| 3312 : | |||
| 3313 : | |||
| 3314 : | |||
| 3315 : | |||
| 3316 : | |||
| 3317 : | |||
| 3318 : | |||
| 3319 : | |||
| 3320 : | |||
| 3321 : | |||
| 3322 : | |||
| 3323 : | |||
| 3324 : | |||
| 3325 : | |||
| 3326 : | |||
| 3327 : | |||
| 3328 : | |||
| 3329 : | |||
| 3330 : | |||
| 3331 : | |||
| 3332 : | |||
| 3333 : | |||
| 3334 : | |||
| 3335 : | |||
| 3336 : | |||
| 3337 : | |||
| 3338 : | |||
| 3339 : | |||
| 3340 : | |||
| 3341 : | |||
| 3342 : | |||
| 3343 : | |||
| 3344 : | |||
| 3345 : | |||
| 3346 : | |||
| 3347 : | |||
| 3348 : | |||
| 3349 : | |||
| 3350 : | |||
| 3351 : | |||
| 3352 : | |||
| 3353 : | |||
| 3354 : | |||
| 3355 : | |||
| 3356 : | |||
| 3357 : | |||
| 3358 : | |||
| 3359 : | |||
| 3360 : | |||
| 3361 : | |||
| 3362 : | |||
| 3363 : | |||
| 3364 : | |||
| 3365 : | |||
| 3366 : | |||
| 3367 : | |||
| 3368 : | |||
| 3369 : | |||
| 3370 : | |||
| 3371 : | |||
| 3372 : | |||
| 3373 : | |||
| 3374 : | |||
| 3375 : | |||
| 3376 : | |||
| 3377 : | |||
| 3378 : | |||
| 3379 : | |||
| 3380 : | |||
| 3381 : | |||
| 3382 : | |||
| 3383 : | |||
| 3384 : | |||
| 3385 : | |||
| 3386 : | |||
| 3387 : | |||
| 3388 : | |||
| 3389 : | |||
| 3390 : | |||
| 3391 : | |||
| 3392 : | |||
| 3393 : | |||
| 3394 : | |||
| 3395 : | |||
| 3396 : | |||
| 3397 : | |||
| 3398 : | |||
| 3399 : | |||
| 3400 : | |||
| 3401 : | |||
| 3402 : | |||
| 3403 : | |||
| 3404 : | |||
| 3405 : | |||
| 3406 : | |||
| 3407 : | |||
| 3408 : | |||
| 3409 : | |||
| 3410 : | |||
| 3411 : | |||
| 3412 : | |||
| 3413 : | |||
| 3414 : | |||
| 3415 : | |||
| 3416 : | |||
| 3417 : | |||
| 3418 : | |||
| 3419 : | |||
| 3420 : | |||
| 3421 : | |||
| 3422 : | |||
| 3423 : | |||
| 3424 : | |||
| 3425 : | |||
| 3426 : | |||
| 3427 : | |||
| 3428 : | |||
| 3429 : | |||
| 3430 : | |||
| 3431 : | |||
| 3432 : | |||
| 3433 : | |||
| 3434 : | |||
| 3435 : | |||
| 3436 : | |||
| 3437 : | |||
| 3438 : | |||
| 3439 : | |||
| 3440 : | |||
| 3441 : | |||
| 3442 : | |||
| 3443 : | |||
| 3444 : | |||
| 3445 : | |||
| 3446 : | |||
| 3447 : | |||
| 3448 : | |||
| 3449 : | |||
| 3450 : | |||
| 3451 : | |||
| 3452 : | |||
| 3453 : | |||
| 3454 : | |||
| 3455 : | |||
| 3456 : | |||
| 3457 : | |||
| 3458 : | >>>>>>> .theirs | ||
| 3459 : | root | 1 | * Tab Creation handler |
| 3460 : | * @package Mambo | ||
| 3461 : | * @author Phil Taylor | ||
| 3462 : | */ | ||
| 3463 : | class mosTabs { | ||
| 3464 : | /** @var int Use cookies */ | ||
| 3465 : | var $useCookies = 0; | ||
| 3466 : | |||
| 3467 : | /** | ||
| 3468 : | * Constructor | ||
| 3469 : | * Includes files needed for displaying tabs and sets cookie options | ||
| 3470 : | * @param int useCookies, if set to 1 cookie will hold last used tab between page refreshes | ||
| 3471 : | */ | ||
| 3472 : | function mosTabs($useCookies) { | ||
| 3473 : | global $mosConfig_live_site; | ||
| 3474 : | echo "<link id=\"luna-tab-style-sheet\" type=\"text/css\" rel=\"stylesheet\" href=\"" . $mosConfig_live_site. "/includes/js/tabs/tabpane.css\" />"; | ||
| 3475 : | echo "<script type=\"text/javascript\" src=\"". $mosConfig_live_site . "/includes/js/tabs/tabpane.js\"></script>"; | ||
| 3476 : | $this->useCookies = $useCookies; | ||
| 3477 : | } | ||
| 3478 : | |||
| 3479 : | /** | ||
| 3480 : | * creates a tab pane and creates JS obj | ||
| 3481 : | * @param string The Tab Pane Name | ||
| 3482 : | */ | ||
| 3483 : | function startPane($id){ | ||
| 3484 : | echo "<div class=\"tab-page\" id=\"".$id."\">"; | ||
| 3485 : | echo "<script type=\"text/javascript\">\n"; | ||
| 3486 : | echo " var tabPane1 = new WebFXTabPane( document.getElementById( \"".$id."\" ), ".$this->useCookies." )\n"; | ||
| 3487 : | echo "</script>\n"; | ||
| 3488 : | } | ||
| 3489 : | |||
| 3490 : | /** | ||
| 3491 : | * Ends Tab Pane | ||
| 3492 : | */ | ||
| 3493 : | function endPane() { | ||
| 3494 : | echo "</div>"; | ||
| 3495 : | } | ||
| 3496 : | |||
| 3497 : | /* | ||
| 3498 : | * Creates a tab with title text and starts that tabs page | ||
| 3499 : | * @param tabText - This is what is displayed on the tab | ||
| 3500 : | * @param paneid - This is the parent pane to build this tab on | ||
| 3501 : | */ | ||
| 3502 : | function startTab( $tabText, $paneid ) { | ||
| 3503 : | echo "<div class=\"tab-page\" id=\"".$paneid."\">"; | ||
| 3504 : | echo "<h2 class=\"tab\">".$tabText."</h2>"; | ||
| 3505 : | echo "<script type=\"text/javascript\">\n"; | ||
| 3506 : | echo " tabPane1.addTabPage( document.getElementById( \"".$paneid."\" ) );"; | ||
| 3507 : | echo "</script>"; | ||
| 3508 : | } | ||
| 3509 : | |||
| 3510 : | /* | ||
| 3511 : | * Ends a tab page | ||
| 3512 : | */ | ||
| 3513 : | function endTab() { | ||
| 3514 : | echo "</div>"; | ||
| 3515 : | } | ||
| 3516 : | } | ||
| 3517 : | |||
| 3518 : | |||
| 3519 : | mambo | 117 | <<<<<<< .mine |
| 3520 : | root | 1 | if ( $id ) { |
| 3521 : | $order = mosGetOrderingList( "SELECT ordering AS value, name AS text" | ||
| 3522 : | . "\n FROM #__menu" | ||
| 3523 : | . "\n WHERE menutype='". $row->menutype ."'" | ||
| 3524 : | . "\n AND parent='". $row->parent ."'" | ||
| 3525 : | . "\n AND published != '-2'" | ||
| 3526 : | . "\n ORDER BY ordering" | ||
| 3527 : | ); | ||
| 3528 : | $ordering = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); | ||
| 3529 : | } else { | ||
| 3530 : | csouza | 39 | $ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. T_('New items default to the last place. Ordering can be changed after this item is saved.'); |
| 3531 : | root | 1 | } |
| 3532 : | return $ordering; | ||
| 3533 : | } | ||
| 3534 : | |||
| 3535 : | /** | ||
| 3536 : | * build the select list for access level | ||
| 3537 : | */ | ||
| 3538 : | function Access( &$row ) { | ||
| 3539 : | global $database; | ||
| 3540 : | |||
| 3541 : | $query = 'SELECT id AS value, name AS text FROM #__groups ORDER BY id'; | ||
| 3542 : | $database->setQuery( $query ); | ||
| 3543 : | $groups = $database->loadObjectList(); | ||
| 3544 : | $access = mosHTML::selectList( $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ) ); | ||
| 3545 : | return $access; | ||
| 3546 : | } | ||
| 3547 : | |||
| 3548 : | /** | ||
| 3549 : | * build the select list for parent item | ||
| 3550 : | */ | ||
| 3551 : | function Parent( &$row ) { | ||
| 3552 : | global $database; | ||
| 3553 : | |||
| 3554 : | // get a list of the menu items | ||
| 3555 : | $query = "SELECT m.*" | ||
| 3556 : | . "\n FROM #__menu m" | ||
| 3557 : | . "\n WHERE menutype='$row->menutype'" | ||
| 3558 : | . "\n AND published <> -2" | ||
| 3559 : | . "\n ORDER BY ordering" | ||
| 3560 : | ; | ||
| 3561 : | $database->setQuery( $query ); | ||
| 3562 : | $mitems = $database->loadObjectList(); | ||
| 3563 : | |||
| 3564 : | // establish the hierarchy of the menu | ||
| 3565 : | $children = array(); | ||
| 3566 : | // first pass - collect children | ||
| 3567 : | foreach ( $mitems as $v ) { | ||
| 3568 : | $pt = $v->parent; | ||
| 3569 : | $list = @$children[$pt] ? $children[$pt] : array(); | ||
| 3570 : | array_push( $list, $v ); | ||
| 3571 : | $children[$pt] = $list; | ||
| 3572 : | } | ||
| 3573 : | // second pass - get an indent list of the items | ||
| 3574 : | $list = mosTreeRecurse( 0, '', array(), $children, 9999, 0, 0 ); | ||
| 3575 : | |||
| 3576 : | // assemble menu items to the array | ||
| 3577 : | $mitems = array(); | ||
| 3578 : | $mitems[] = mosHTML::makeOption( '0', 'Top' ); | ||
| 3579 : | $this_treename = ''; | ||
| 3580 : | foreach ( $list as $item ) { | ||
| 3581 : | if ( $this_treename ) { | ||
| 3582 : | if ( $item->id != $row->id && strpos( $item->treename, $this_treename ) === false) { | ||
| 3583 : | $mitems[] = mosHTML::makeOption( $item->id, $item->treename ); | ||
| 3584 : | } | ||
| 3585 : | } else { | ||
| 3586 : | if ( $item->id != $row->id ) { | ||
| 3587 : | $mitems[] = mosHTML::makeOption( $item->id, $item->treename ); | ||
| 3588 : | } else { | ||
| 3589 : | $this_treename = "$item->treename/"; | ||
| 3590 : | } | ||
| 3591 : | } | ||
| 3592 : | } | ||
| 3593 : | $parent = mosHTML::selectList( $mitems, 'parent', 'class="inputbox" size="1"', 'value', 'text', $row->parent ); | ||
| 3594 : | return $parent; | ||
| 3595 : | } | ||
| 3596 : | |||
| 3597 : | /** | ||
| 3598 : | * build a radio button option for published state | ||
| 3599 : | */ | ||
| 3600 : | function Published( &$row ) { | ||
| 3601 : | $published = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published ); | ||
| 3602 : | return $published; | ||
| 3603 : | } | ||
| 3604 : | |||
| 3605 : | /** | ||
| 3606 : | * build the link/url of a menu item | ||
| 3607 : | */ | ||
| 3608 : | function Link( &$row, $id, $link=NULL ) { | ||
| 3609 : | if ( $id ) { | ||
| 3610 : | if ( $link ) { | ||
| 3611 : | $link = $row->link; | ||
| 3612 : | } else { | ||
| 3613 : | $link = $row->link .'&Itemid='. $row->id; | ||
| 3614 : | } | ||
| 3615 : | } else { | ||
| 3616 : | $link = NULL; | ||
| 3617 : | } | ||
| 3618 : | return $link; | ||
| 3619 : | } | ||
| 3620 : | |||
| 3621 : | /** | ||
| 3622 : | * build the select list for target window | ||
| 3623 : | */ | ||
| 3624 : | function Target( &$row ) { | ||
| 3625 : | csouza | 39 | $click[] = mosHTML::makeOption( '0', T_('Parent Window With Browser Navigation') ); |
| 3626 : | $click[] = mosHTML::makeOption( '1', T_('New Window With Browser Navigation') ); | ||
| 3627 : | $click[] = mosHTML::makeOption( '2', T_('New Window Without Browser Navigation') ); | ||
| 3628 : | root | 1 | $target = mosHTML::selectList( $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) ); |
| 3629 : | return $target; | ||
| 3630 : | } | ||
| 3631 : | |||
| 3632 : | /** | ||
| 3633 : | * build the multiple select list for Menu Links/Pages | ||
| 3634 : | */ | ||
| 3635 : | function MenuLinks( &$lookup, $all=NULL, $none=NULL ) { | ||
| 3636 : | global $database; | ||
| 3637 : | |||
| 3638 : | // get a list of the menu items | ||
| 3639 : | $database->setQuery( "SELECT m.*" | ||
| 3640 : | . "\n FROM #__menu m" | ||
| 3641 : | . "\n WHERE type != 'separator'" | ||
| 3642 : | . "\n AND link NOT LIKE '%tp:/%'" | ||
| 3643 : | . "\n AND published = '1'" | ||
| 3644 : | . "\n ORDER BY menutype, parent, ordering" | ||
| 3645 : | ); | ||
| 3646 : | $mitems = $database->loadObjectList(); | ||
| 3647 : | $mitems_temp = $mitems; | ||
| 3648 : | |||
| 3649 : | // establish the hierarchy of the menu | ||
| 3650 : | $children = array(); | ||
| 3651 : | // first pass - collect children | ||
| 3652 : | foreach ( $mitems as $v ) { | ||
| 3653 : | $id = $v->id; | ||
| 3654 : | $pt = $v->parent; | ||
| 3655 : | $list = @$children[$pt] ? $children[$pt] : array(); | ||
| 3656 : | array_push( $list, $v ); | ||
| 3657 : | $children[$pt] = $list; | ||
| 3658 : | } | ||
| 3659 : | // second pass - get an indent list of the items | ||
| 3660 : | $list = mosTreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); | ||
| 3661 : | |||
| 3662 : | // Code that adds menu name to Display of Page(s) | ||
| 3663 : | $text_count = "0"; | ||
| 3664 : | $mitems_spacer = $mitems_temp[0]->menutype; | ||
| 3665 : | foreach ($list as $list_a) { | ||
| 3666 : | foreach ($mitems_temp as $mitems_a) { | ||
| 3667 : | if ($mitems_a->id == $list_a->id) { | ||
| 3668 : | // Code that inserts the blank line that seperates different menus | ||
| 3669 : | if ($mitems_a->menutype <> $mitems_spacer) { | ||
| 3670 : | $list_temp[] = mosHTML::makeOption( -999, '----' ); | ||
| 3671 : | $mitems_spacer = $mitems_a->menutype; | ||
| 3672 : | } | ||
| 3673 : | $text = $mitems_a->menutype." | ".$list_a->treename; | ||
| 3674 : | $list_temp[] = mosHTML::makeOption( $list_a->id, $text ); | ||
| 3675 : | if ( strlen($text) > $text_count) { | ||
| 3676 : | $text_count = strlen($text); | ||
| 3677 : | } | ||
| 3678 : | } | ||
| 3679 : | } | ||
| 3680 : | } | ||
| 3681 : | $list = $list_temp; | ||
| 3682 : | |||
| 3683 : | $mitems = array(); | ||
| 3684 : | if ( $all ) { | ||
| 3685 : | // prepare an array with 'all' as the first item | ||
| 3686 : | csouza | 39 | $mitems[] = mosHTML::makeOption( 0, T_('All') ); |
| 3687 : | root | 1 | // adds space, in select box which is not saved |
| 3688 : | $mitems[] = mosHTML::makeOption( -999, '----' ); | ||
| 3689 : | } | ||
| 3690 : | if ( $none ) { | ||
| 3691 : | // prepare an array with 'all' as the first item | ||
| 3692 : | csouza | 39 | $mitems[] = mosHTML::makeOption( -999, T_('None') ); |
| 3693 : | root | 1 | // adds space, in select box which is not saved |
| 3694 : | $mitems[] = mosHTML::makeOption( -999, '----' ); | ||
| 3695 : | } | ||
| 3696 : | // append the rest of the menu items to the array | ||
| 3697 : | foreach ($list as $item) { | ||
| 3698 : | $mitems[] = mosHTML::makeOption( $item->value, $item->text ); | ||
| 3699 : | } | ||
| 3700 : | $pages = mosHTML::selectList( $mitems, 'selections[]', 'class="inputbox" size="26" multiple="multiple"', 'value', 'text', $lookup ); | ||
| 3701 : | return $pages; | ||
| 3702 : | } | ||
| 3703 : | |||
| 3704 : | |||
| 3705 : | /** | ||
| 3706 : | * build the select list to choose a category | ||
| 3707 : | */ | ||
| 3708 : | function Category( &$menu, $id, $javascript='' ) { | ||
| 3709 : | global $database; | ||
| 3710 : | |||
| 3711 : | $query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" | ||
| 3712 : | . "\n FROM #__sections AS s" | ||
| 3713 : | . "\n INNER JOIN #__categories AS c ON c.section = s.id" | ||
| 3714 : | . "\n WHERE s.scope = 'content'" | ||
| 3715 : | . "\n ORDER BY s.name,c.name" | ||
| 3716 : | ; | ||
| 3717 : | $database->setQuery( $query ); | ||
| 3718 : | $rows = $database->loadObjectList(); | ||
| 3719 : | $category = ''; | ||
| 3720 : | if ( $id ) { | ||
| 3721 : | foreach ( $rows as $row ) { | ||
| 3722 : | if ( $row->value == $menu->componentid ) { | ||
| 3723 : | $category = $row->text; | ||
| 3724 : | } | ||
| 3725 : | } | ||
| 3726 : | $category .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />'; | ||
| 3727 : | $category .= '<input type="hidden" name="link" value="'. $menu->link .'" />'; | ||
| 3728 : | } else { | ||
| 3729 : | $category = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"'. $javascript, 'value', 'text' ); | ||
| 3730 : | $category .= '<input type="hidden" name="link" value="" />'; | ||
| 3731 : | } | ||
| 3732 : | return $category; | ||
| 3733 : | } | ||
| 3734 : | |||
| 3735 : | /** | ||
| 3736 : | * build the select list to choose a section | ||
| 3737 : | */ | ||
| 3738 : | function Section( &$menu, $id, $all=0 ) { | ||
| 3739 : | global $database; | ||
| 3740 : | |||
| 3741 : | $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" | ||
| 3742 : | . "\n FROM #__sections AS s" | ||
| 3743 : | . "\n WHERE s.scope = 'content'" | ||
| 3744 : | . "\n ORDER BY s.name" | ||
| 3745 : | ; | ||
| 3746 : | $database->setQuery( $query ); | ||
| 3747 : | if ( $all ) { | ||
| 3748 : | csouza | 39 | $rows[] = mosHTML::makeOption( 0, T_('- All Sections -') ); |
| 3749 : | root | 1 | $rows = array_merge( $rows, $database->loadObjectList() ); |
| 3750 : | } else { | ||
| 3751 : | $rows = $database->loadObjectList(); | ||
| 3752 : | } | ||
| 3753 : | |||
| 3754 : | if ( $id ) { | ||
| 3755 : | foreach ( $rows as $row ) { | ||
| 3756 : | if ( $row->value == $menu->componentid ) { | ||
| 3757 : | $section = $row->text; | ||
| 3758 : | } | ||
| 3759 : | } | ||
| 3760 : | $section .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />'; | ||
| 3761 : | $section .= '<input type="hidden" name="link" value="'. $menu->link .'" />'; | ||
| 3762 : | } else { | ||
| 3763 : | $section = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' ); | ||
| 3764 : | $section .= '<input type="hidden" name="link" value="" />'; | ||
| 3765 : | } | ||
| 3766 : | return $section; | ||
| 3767 : | } | ||
| 3768 : | |||
| 3769 : | /** | ||
| 3770 : | * build the select list to choose a component | ||
| 3771 : | */ | ||
| 3772 : | function Component( &$menu, $id ) { | ||
| 3773 : | global $database; | ||
| 3774 : | |||
| 3775 : | $query = "SELECT c.id AS value, c.name AS text, c.link" | ||
| 3776 : | . "\n FROM #__components AS c" | ||
| 3777 : | . "\n WHERE c.link <> ''" | ||
| 3778 : | . "\n ORDER BY c.name" | ||
| 3779 : | ; | ||
| 3780 : | $database->setQuery( $query ); | ||
| 3781 : | $rows = $database->loadObjectList( ); | ||
| 3782 : | |||
| 3783 : | if ( $id ) { | ||
| 3784 : | // existing component, just show name | ||
| 3785 : | foreach ( $rows as $row ) { | ||
| 3786 : | if ( $row->value == $menu->componentid ) { | ||
| 3787 : | $component = $row->text; | ||
| 3788 : | } | ||
| 3789 : | } | ||
| 3790 : | $component .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />'; | ||
| 3791 : | } else { | ||
| 3792 : | $component = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' ); | ||
| 3793 : | } | ||
| 3794 : | return $component; | ||
| 3795 : | } | ||
| 3796 : | |||
| 3797 : | /** | ||
| 3798 : | * build the select list to choose a component | ||
| 3799 : | */ | ||
| 3800 : | function ComponentName( &$menu, $id ) { | ||
| 3801 : | global $database; | ||
| 3802 : | |||
| 3803 : | $query = "SELECT c.id AS value, c.name AS text, c.link" | ||
| 3804 : | . "\n FROM #__components AS c" | ||
| 3805 : | . "\n WHERE c.link <> ''" | ||
| 3806 : | . "\n ORDER BY c.name" | ||
| 3807 : | ; | ||
| 3808 : | $database->setQuery( $query ); | ||
| 3809 : | $rows = $database->loadObjectList( ); | ||
| 3810 : | |||
| 3811 : | $component = 'Component'; | ||
| 3812 : | foreach ( $rows as $row ) { | ||
| 3813 : | if ( $row->value == $menu->componentid ) { | ||
| 3814 : | $component = $row->text; | ||
| 3815 : | } | ||
| 3816 : | } | ||
| 3817 : | |||
| 3818 : | return $component; | ||
| 3819 : | } | ||
| 3820 : | |||
| 3821 : | /** | ||
| 3822 : | * build the select list to choose an image | ||
| 3823 : | */ | ||
| 3824 : | function Images( $name, &$active, $javascript=NULL, $directory=NULL ) { | ||
| 3825 : | global $mosConfig_absolute_path; | ||
| 3826 : | |||
| 3827 : | if ( !$javascript ) { | ||
| 3828 : | $javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; | ||
| 3829 : | } | ||
| 3830 : | if ( !$directory ) { | ||
| 3831 : | $directory = '/images/stories'; | ||
| 3832 : | } | ||
| 3833 : | |||
| 3834 : | $imageFiles = mosReadDirectory( $mosConfig_absolute_path . $directory ); | ||
| 3835 : | csouza | 39 | $images = array( mosHTML::makeOption( '', T_('- Select Image -') ) ); |
| 3836 : | root | 1 | foreach ( $imageFiles as $file ) { |
| 3837 : | if ( eregi( "bmp|gif|jpg|png", $file ) ) { | ||
| 3838 : | $images[] = mosHTML::makeOption( $file ); | ||
| 3839 : | } | ||
| 3840 : | } | ||
| 3841 : | $images = mosHTML::selectList( $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); | ||
| 3842 : | |||
| 3843 : | return $images; | ||
| 3844 : | } | ||
| 3845 : | |||
| 3846 : | /** | ||
| 3847 : | * build the select list for Ordering of a specified Table | ||
| 3848 : | */ | ||
| 3849 : | function SpecificOrdering( &$row, $id, $query, $neworder=0 ) { | ||
| 3850 : | global $database; | ||
| 3851 : | |||
| 3852 : | if ( $neworder ) { | ||
| 3853 : | csouza | 39 | $text = T_('New items default to the first place. Ordering can be changed after this item is saved.'); |
| 3854 : | root | 1 | } else { |
| 3855 : | csouza | 39 | $text = T_('New items default to the last place. Ordering can be changed after this item is saved.'); |
| 3856 : | root | 1 | } |
| 3857 : | |||
| 3858 : | if ( $id ) { | ||
| 3859 : | $order = mosGetOrderingList( $query ); | ||
| 3860 : | $ordering = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); | ||
| 3861 : | } else { | ||
| 3862 : | $ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. $text; | ||
| 3863 : | } | ||
| 3864 : | return $ordering; | ||
| 3865 : | } | ||
| 3866 : | |||
| 3867 : | /** | ||
| 3868 : | * Select list of active users | ||
| 3869 : | */ | ||
| 3870 : | function UserSelect( $name, $active, $nouser=0, $javascript=NULL, $order='name' ) { | ||
| 3871 : | global $database, $my; | ||
| 3872 : | |||
| 3873 : | $query = "SELECT id AS value, name AS text" | ||
| 3874 : | . "\n FROM #__users" | ||
| 3875 : | . "\n WHERE block = '0'" | ||
| 3876 : | . "\n ORDER BY ". $order | ||
| 3877 : | ; | ||
| 3878 : | $database->setQuery( $query ); | ||
| 3879 : | if ( $nouser ) { | ||
| 3880 : | csouza | 39 | $users[] = mosHTML::makeOption( '0', T_('- No User -') ); |
| 3881 : | root | 1 | $users = array_merge( $users, $database->loadObjectList() ); |
| 3882 : | } else { | ||
| 3883 : | $users = $database->loadObjectList(); | ||
| 3884 : | } | ||
| 3885 : | |||
| 3886 : | $users = mosHTML::selectList( $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); | ||
| 3887 : | |||
| 3888 : | return $users; | ||
| 3889 : | } | ||
| 3890 : | |||
| 3891 : | /** | ||
| 3892 : | * Select list of positions - generally used for location of images | ||
| 3893 : | */ | ||
| 3894 : | function Positions( $name, $active=NULL, $javascript=NULL, $none=1, $center=1, $left=1, $right=1 ) { | ||
| 3895 : | if ( $none ) { | ||
| 3896 : | csouza | 39 | $pos[] = mosHTML::makeOption( '', T_('None') ); |
| 3897 : | root | 1 | } |
| 3898 : | if ( $center ) { | ||
| 3899 : | csouza | 39 | $pos[] = mosHTML::makeOption( 'center', T_('Center') ); |
| 3900 : | root | 1 | } |
| 3901 : | if ( $left ) { | ||
| 3902 : | csouza | 39 | $pos[] = mosHTML::makeOption( 'left', T_('Left') ); |
| 3903 : | root | 1 | } |
| 3904 : | if ( $right ) { | ||
| 3905 : | csouza | 39 | $pos[] = mosHTML::makeOption( 'right', T_('Right') ); |
| 3906 : | root | 1 | } |
| 3907 : | |||
| 3908 : | $positions = mosHTML::selectList( $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active ); | ||
| 3909 : | |||
| 3910 : | return $positions; | ||
| 3911 : | } | ||
| 3912 : | |||
| 3913 : | /** | ||
| 3914 : | * Select list of active categories for components | ||
| 3915 : | */ | ||
| 3916 : | function ComponentCategory( $name, $section, $active=NULL, $javascript=NULL, $order='ordering', $size=1, $sel_cat=1 ) { | ||
| 3917 : | global $database; | ||
| 3918 : | |||
| 3919 : | $query = "SELECT id AS value, name AS text" | ||
| 3920 : | . "\n FROM #__categories" | ||
| 3921 : | . "\n WHERE section = '". $section ."'" | ||
| 3922 : | . "\n AND published = '1'" | ||
| 3923 : | . "\n ORDER BY ". $order | ||
| 3924 : | ; | ||
| 3925 : | $database->setQuery( $query ); | ||
| 3926 : | if ( $sel_cat ) { | ||
| 3927 : | csouza | 39 | $categories[] = mosHTML::makeOption( '0', T_('- All Categories -') ); |
| 3928 : | root | 1 | $categories = array_merge( $categories, $database->loadObjectList() ); |
| 3929 : | } else { | ||
| 3930 : | $categories = $database->loadObjectList(); | ||
| 3931 : | } | ||
| 3932 : | |||
| 3933 : | if ( count( $categories ) < 1 ) { | ||
| 3934 : | csouza | 39 | mosRedirect( 'index2.php?option=com_categories§ion='. $section, T_('You must create a category first.') ); |
| 3935 : | root | 1 | } |
| 3936 : | |||
| 3937 : | $category = mosHTML::selectList( $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); | ||
| 3938 : | |||
| 3939 : | return $category; | ||
| 3940 : | } | ||
| 3941 : | |||
| 3942 : | /** | ||
| 3943 : | * Select list of active sections | ||
| 3944 : | */ | ||
| 3945 : | function SelectSection( $name, $active=NULL, $javascript=NULL, $order='ordering' ) { | ||
| 3946 : | global $database; | ||
| 3947 : | |||
| 3948 : | csouza | 39 | $categories[] = mosHTML::makeOption( '0', T_('- All Sections -') ); |
| 3949 : | root | 1 | $query = "SELECT id AS value, title AS text" |
| 3950 : | . "\n FROM #__sections" | ||
| 3951 : | . "\n WHERE published = '1'" | ||
| 3952 : | . "\n ORDER BY ". $order | ||
| 3953 : | ; | ||
| 3954 : | $database->setQuery( $query ); | ||
| 3955 : | $sections = array_merge( $categories, $database->loadObjectList() ); | ||
| 3956 : | |||
| 3957 : | $category = mosHTML::selectList( $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); | ||
| 3958 : | |||
| 3959 : | return $category; | ||
| 3960 : | } | ||
| 3961 : | |||
| 3962 : | /** | ||
| 3963 : | * Select list of menu items for a specific menu | ||
| 3964 : | */ | ||
| 3965 : | function Links2Menu( $type, $and ) { | ||
| 3966 : | global $database; | ||
| 3967 : | |||
| 3968 : | $query = "SELECT *" | ||
| 3969 : | . "\n FROM #__menu" | ||
| 3970 : | . "\n WHERE type = '". $type ."'" | ||
| 3971 : | . "\n AND published = '1'" | ||
| 3972 : | . $and | ||
| 3973 : | ; | ||
| 3974 : | $database->setQuery( $query ); | ||
| 3975 : | $menus = $database->loadObjectList(); | ||
| 3976 : | |||
| 3977 : | return $menus; | ||
| 3978 : | } | ||
| 3979 : | |||
| 3980 : | /** | ||
| 3981 : | * Select list of menus | ||
| 3982 : | */ | ||
| 3983 : | function MenuSelect( $name='menuselect', $javascript=NULL ) { | ||
| 3984 : | global $database; | ||
| 3985 : | |||
| 3986 : | $query = "SELECT params" | ||
| 3987 : | . "\n FROM #__modules" | ||
| 3988 : | . "\n WHERE module = 'mod_mainmenu'" | ||
| 3989 : | ; | ||
| 3990 : | $database->setQuery( $query ); | ||
| 3991 : | $menus = $database->loadObjectList(); | ||
| 3992 : | $total = count( $menus ); | ||
| 3993 : | for( $i = 0; $i < $total; $i++ ) { | ||
| 3994 : | $params = mosParseParams( $menus[$i]->params ); | ||
| 3995 : | $menuselect[$i]->value = $params->menutype; | ||
| 3996 : | $menuselect[$i]->text = $params->menutype; | ||
| 3997 : | } | ||
| 3998 : | // sort array of objects | ||
| 3999 : | SortArrayObjects( $menuselect, 'text', 1 ); | ||
| 4000 : | |||
| 4001 : | $menus = mosHTML::selectList( $menuselect, $name, 'class="inputbox" size="10" '. $javascript, 'value', 'text' ); | ||
| 4002 : | |||
| 4003 : | return $menus; | ||
| 4004 : | } | ||
| 4005 : | |||
| 4006 : | /** | ||
| 4007 : | * Internal function to recursive scan the media manager directories | ||
| 4008 : | * @param string Path to scan | ||
| 4009 : | * @param string root path of this folder | ||
| 4010 : | * @param array Value array of all existing folders | ||
| 4011 : | * @param array Value array of all existing images | ||
| 4012 : | */ | ||
| 4013 : | function ReadImages( $imagePath, $folderPath, &$folders, &$images ) { | ||
| 4014 : | $imgFiles = mosReadDirectory( $imagePath ); | ||
| 4015 : | |||
| 4016 : | foreach ($imgFiles as $file) { | ||
| 4017 : | $ff_ = $folderPath . $file .'/'; | ||
| 4018 : | $ff = $folderPath . $file; | ||
| 4019 : | $i_f = $imagePath .'/'. $file; | ||
| 4020 : | |||
| 4021 : | if ( is_dir( $i_f ) && $file <> 'CVS' ) { | ||
| 4022 : | $folders[] = mosHTML::makeOption( $ff_ ); | ||
| 4023 : | mosAdminMenus::ReadImages( $i_f, $ff_, $folders, $images ); | ||
| 4024 : | } else if ( eregi( "bmp|gif|jpg|png", $file ) && is_file( $i_f ) ) { | ||
| 4025 : | // leading / we don't need | ||
| 4026 : | $imageFile = substr( $ff, 1 ); | ||
| 4027 : | $images[$folderPath][] = mosHTML::makeOption( $imageFile, $file ); | ||
| 4028 : | } | ||
| 4029 : | } | ||
| 4030 : | } | ||
| 4031 : | |||
| 4032 : | function GetImageFolders( &$folders, $path ) { | ||
| 4033 : | $javascript = "onchange=\"changeDynaList( 'imagefiles', folderimages, document.adminForm.folders.options[document.adminForm.folders.selectedIndex].value, 0, 0); previewImage( 'imagefiles', 'view_imagefiles', '$path/' );\""; | ||
| 4034 : | $getfolders = mosHTML::selectList( $folders, 'folders', 'class="inputbox" size="1" '. $javascript, 'value', 'text', '/' ); | ||
| 4035 : | return $getfolders; | ||
| 4036 : | } | ||
| 4037 : | |||
| 4038 : | function GetImages( &$images, $path ) { | ||
| 4039 : | if ( !isset($images['/'] ) ) { | ||
| 4040 : | $images['/'][] = mosHTML::makeOption( '' ); | ||
| 4041 : | } | ||
| 4042 : | |||
| 4043 : | //$javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\" onfocus=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\""; | ||
| 4044 : | $javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\""; | ||
| 4045 : | $getimages = mosHTML::selectList( $images['/'], 'imagefiles', 'class="inputbox" size="10" multiple="multiple" '. $javascript , 'value', 'text', null ); | ||
| 4046 : | |||
| 4047 : | return $getimages; | ||
| 4048 : | } | ||
| 4049 : | |||
| 4050 : | function GetSavedImages( &$row, $path ) { | ||
| 4051 : | $images2 = array(); | ||
| 4052 : | foreach( $row->images as $file ) { | ||
| 4053 : | $temp = explode( '|', $file ); | ||
| 4054 : | if( strrchr($temp[0], '/') ) { | ||
| 4055 : | $filename = substr( strrchr($temp[0], '/' ), 1 ); | ||
| 4056 : | } else { | ||
| 4057 : | $filename = $temp[0]; | ||
| 4058 : | } | ||
| 4059 : | $images2[] = mosHTML::makeOption( $file, $filename ); | ||
| 4060 : | } | ||
| 4061 : | //$javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \" onfocus=\"previewImage( 'imagelist', 'view_imagelist', '$path/' )\""; | ||
| 4062 : | $javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \""; | ||
| 4063 : | $imagelist = mosHTML::selectList( $images2, 'imagelist', 'class="inputbox" size="10" '. $javascript, 'value', 'text' ); | ||
| 4064 : | |||
| 4065 : | return $imagelist; | ||
| 4066 : | } | ||
| 4067 : | |||
| 4068 : | /** | ||
| 4069 : | * Checks to see if an image exists in the current templates image directory | ||
| 4070 : | * if it does it loads this image. Otherwise the default image is loaded. | ||
| 4071 : | * Also can be used in conjunction with the menulist param to create the chosen image | ||
| 4072 : | * load the default or use no image | ||
| 4073 : | */ | ||
| 4074 : | function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name='image', $type=1, $align='middle' ) { | ||
| 4075 : | global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe; | ||
| 4076 : | $cur_template = $mainframe->getTemplate(); | ||
| 4077 : | |||
| 4078 : | if ( $param ) { | ||
| 4079 : | $image = $mosConfig_live_site. $param_directory . $param; | ||
| 4080 : | if ( $type ) { | ||
| 4081 : | $image = '<img src="'. $image .'" align="'. $align .'" alt="'. $alt .'" name="'. $name .'" border="0" />'; | ||
| 4082 : | } | ||
| 4083 : | } else if ( $param == -1 ) { | ||
| 4084 : | $image = ''; | ||
| 4085 : | } else { | ||
| 4086 : | if ( file_exists( $mosConfig_absolute_path .'/templates/'. $cur_template .'/images/'. $file ) ) { | ||
| 4087 : | $image = $mosConfig_live_site .'/templates/'. $cur_template .'/images/'. $file; | ||
| 4088 : | } else { | ||
| 4089 : | // outputs only path to image | ||
| 4090 : | $image = $mosConfig_live_site. $directory . $file; | ||
| 4091 : | } | ||
| 4092 : | |||
| 4093 : | // outputs actual html <img> tag | ||
| 4094 : | if ( $type ) { | ||
| 4095 : | $image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />'; | ||
| 4096 : | } | ||
| 4097 : | } | ||
| 4098 : | |||
| 4099 : | return $image; | ||
| 4100 : | } | ||
| 4101 : | |||
| 4102 : | /** | ||
| 4103 : | * Checks to see if an image exists in the current templates image directory | ||
| 4104 : | * if it does it loads this image. Otherwise the default image is loaded. | ||
| 4105 : | * Also can be used in conjunction with the menulist param to create the chosen image | ||
| 4106 : | * load the default or use no image | ||
| 4107 : | */ | ||
| 4108 : | function ImageCheckAdmin( $file, $directory='/administrator/images/', $param=NULL, $param_directory='/administrator/images/', $alt=NULL, $name=NULL, $type=1, $align='middle' ) { | ||
| 4109 : | global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe; | ||
| 4110 : | $cur_template = $mainframe->getTemplate(); | ||
| 4111 : | |||
| 4112 : | if ( $param ) { | ||
| 4113 : | $image = $mosConfig_live_site. $param_directory . $param; | ||
| 4114 : | if ( $type ) { | ||
| 4115 : | $image = '<img src="'. $image .'" align="'. $align .'" alt="'. $alt .'" name="'. $name .'" border="0" />'; | ||
| 4116 : | } | ||
| 4117 : | } else if ( $param == -1 ) { | ||
| 4118 : | $image = ''; | ||
| 4119 : | } else { | ||
| 4120 : | if ( file_exists( $mosConfig_absolute_path .'/administrator/templates/'. $cur_template .'/images/'. $file ) ) { | ||
| 4121 : | $image = $mosConfig_live_site .'/administrator/templates/'. $cur_template .'/images/'. $file; | ||
| 4122 : | } else { | ||
| 4123 : | $image = $mosConfig_live_site. $directory . $file; | ||
| 4124 : | } | ||
| 4125 : | |||
| 4126 : | // outputs actual html <img> tag | ||
| 4127 : | if ( $type ) { | ||
| 4128 : | $image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />'; | ||
| 4129 : | } | ||
| 4130 : | } | ||
| 4131 : | |||
| 4132 : | return $image; | ||
| 4133 : | } | ||
| 4134 : | |||
| 4135 : | function menutypes() { | ||
| 4136 : | global $database; | ||
| 4137 : | |||
| 4138 : | $query = "SELECT params" | ||
| 4139 : | . "\n FROM #__modules" | ||
| 4140 : | . "\n WHERE module = 'mod_mainmenu'" | ||
| 4141 : | . "\n ORDER BY title" | ||
| 4142 : | ; | ||
| 4143 : | $database->setQuery( $query ); | ||
| 4144 : | $modMenus = $database->loadObjectList(); | ||
| 4145 : | |||
| 4146 : | $query = "SELECT menutype" | ||
| 4147 : | . "\n FROM #__menu" | ||
| 4148 : | . "\n GROUP BY menutype" | ||
| 4149 : | . "\n ORDER BY menutype" | ||
| 4150 : | ; | ||
| 4151 : | $database->setQuery( $query ); | ||
| 4152 : | $menuMenus = $database->loadObjectList(); | ||
| 4153 : | |||
| 4154 : | $menuTypes = ''; | ||
| 4155 : | foreach ( $modMenus as $modMenu ) { | ||
| 4156 : | $check = 1; | ||
| 4157 : | mosMakeHtmlSafe( $modMenu) ; | ||
| 4158 : | $modParams = mosParseParams( $modMenu->params ); | ||
| 4159 : | $menuType = @$modParams->menutype; | ||
| 4160 : | if (!$menuType) { | ||
| 4161 : | $menuType = 'mainmenu'; | ||
| 4162 : | } | ||
| 4163 : | |||
| 4164 : | // stop duplicate menutype being shown | ||
| 4165 : | if ( !is_array( $menuTypes) ) { | ||
| 4166 : | // handling to create initial entry into array | ||
| 4167 : | $menuTypes[] = $menuType; | ||
| 4168 : | } else { | ||
| 4169 : | $check = 1; | ||
| 4170 : | foreach ( $menuTypes as $a ) { | ||
| 4171 : | if ( $a == $menuType ) { | ||
| 4172 : | $check = 0; | ||
| 4173 : | } | ||
| 4174 : | } | ||
| 4175 : | if ( $check ) { | ||
| 4176 : | $menuTypes[] = $menuType; | ||
| 4177 : | } | ||
| 4178 : | } | ||
| 4179 : | |||
| 4180 : | } | ||
| 4181 : | // add menutypes from mos_menu | ||
| 4182 : | foreach ( $menuMenus as $menuMenu ) { | ||
| 4183 : | $check = 1; | ||
| 4184 : | foreach ( $menuTypes as $a ) { | ||
| 4185 : | if ( $a == $menuMenu->menutype ) { | ||
| 4186 : | $check = 0; | ||
| 4187 : | } | ||
| 4188 : | } | ||
| 4189 : | if ( $check ) { | ||
| 4190 : | $menuTypes[] = $menuMenu->menutype; | ||
| 4191 : | } | ||
| 4192 : | } | ||
| 4193 : | |||
| 4194 : | // sorts menutypes | ||
| 4195 : | asort( $menuTypes ); | ||
| 4196 : | |||
| 4197 : | return $menuTypes; | ||
| 4198 : | } | ||
| 4199 : | |||
| 4200 : | /* | ||
| 4201 : | * loads files required for menu items | ||
| 4202 : | */ | ||
| 4203 : | function menuItem( $item ) { | ||
| 4204 : | global $mosConfig_absolute_path; | ||
| 4205 : | |||
| 4206 : | $path = $mosConfig_absolute_path .'/administrator/components/com_menus/'. $item .'/'; | ||
| 4207 : | include_once( $path . $item .'.class.php' ); | ||
| 4208 : | include_once( $path . $item .'.menu.html.php' ); | ||
| 4209 : | } | ||
| 4210 : | } | ||
| 4211 : | |||
| 4212 : | |||
| 4213 : | class mosCommonHTML { | ||
| 4214 : | |||
| 4215 : | function ContentLegend( ) { | ||
| 4216 : | ?> | ||
| 4217 : | <table cellspacing="0" cellpadding="4" border="0" align="center"> | ||
| 4218 : | <tr align="center"> | ||
| 4219 : | <td> | ||
| 4220 : | <img src="images/publish_y.png" width="12" height="12" border="0" alt="Pending" /> | ||
| 4221 : | </td> | ||
| 4222 : | <td> | ||
| 4223 : | csouza | 39 | <?php echo T_('Published, but is <u>Pending</u>') ?> | |
| 4224 : | root | 1 | </td> |
| 4225 : | <td> | ||
| 4226 : | <img src="images/publish_g.png" width="12" height="12" border="0" alt="Visible" /> | ||
| 4227 : | </td> | ||
| 4228 : | <td> | ||
| 4229 : | csouza | 39 | <?php echo T_('Published and is <u>Current</u>') ?> | |
| 4230 : | root | 1 | </td> |
| 4231 : | <td> | ||
| 4232 : | <img src="images/publish_r.png" width="12" height="12" border="0" alt="Finished" /> | ||
| 4233 : | </td> | ||
| 4234 : | <td> | ||
| 4235 : | csouza | 39 | <?php echo T_('Published, but has <u>Expired</u>') ?> | |
| 4236 : | root | 1 | </td> |
| 4237 : | <td> | ||
| 4238 : | <img src="images/publish_x.png" width="12" height="12" border="0" alt="Finished" /> | ||
| 4239 : | </td> | ||
| 4240 : | <td> | ||
| 4241 : | csouza | 39 | <?php echo T_('Not Published') ?> |
| 4242 : | root | 1 | </td> |
| 4243 : | </tr> | ||
| 4244 : | <tr> | ||
| 4245 : | <td colspan="8" align="center"> | ||
| 4246 : | csouza | 39 | <?php echo T_('Click on icon to toggle state.') ?> |
| 4247 : | root | 1 | </td> |
| 4248 : | </tr> | ||
| 4249 : | </table> | ||
| 4250 : | <?php | ||
| 4251 : | } | ||
| 4252 : | |||
| 4253 : | function menuLinksContent( &$menus ) { | ||
| 4254 : | ?> | ||
| 4255 : | <script language="javascript" type="text/javascript"> | ||
| 4256 : | function go2( pressbutton, menu, id ) { | ||
| 4257 : | var form = document.adminForm; | ||
| 4258 : | |||
| 4259 : | if (pressbutton == 'go2menu') { | ||
| 4260 : | form.menu.value = menu; | ||
| 4261 : | submitform( pressbutton ); | ||
| 4262 : | return; | ||
| 4263 : | } | ||
| 4264 : | |||
| 4265 : | if (pressbutton == 'go2menuitem') { | ||
| 4266 : | form.menu.value = menu; | ||
| 4267 : | form.menuid.value = id; | ||
| 4268 : | submitform( pressbutton ); | ||
| 4269 : | return; | ||
| 4270 : | } | ||
| 4271 : | } | ||
| 4272 : | </script> | ||
| 4273 : | <?php | ||
| 4274 : | foreach( $menus as $menu ) { | ||
| 4275 : | ?> | ||
| 4276 : | <tr> | ||
| 4277 : | <td colspan="2"> | ||
| 4278 : | <hr /> | ||
| 4279 : | </td> | ||
| 4280 : | </tr> | ||
| 4281 : | <tr> | ||
| 4282 : | <td width="90px" valign="top"> | ||
| 4283 : | csouza | 39 | <?php echo T_('Menu') ?> |
| 4284 : | root | 1 | </td> |
| 4285 : | <td> | ||
| 4286 : | csouza | 39 | <a href="javascript:go2( 'go2menu', '<?php echo $menu->menutype; ?>' );" title="<?php echo T_('Go to Menu') ?>"> |
| 4287 : | root | 1 | <?php echo $menu->menutype; ?> |
| 4288 : | </a> | ||
| 4289 : | </td> | ||
| 4290 : | </tr> | ||
| 4291 : | <tr> | ||
| 4292 : | <td width="90px" valign="top"> | ||
| 4293 : | csouza | 39 | <?php echo T_('Link Name') ?> |
| 4294 : | root | 1 | </td> |
| 4295 : | <td> | ||
| 4296 : | <strong> | ||
| 4297 : | <a href="javascript:go2( 'go2menuitem', '<?php echo $menu->menutype; ?>', '<?php echo $menu->id; ?>' );" title="Go to Menu Item"> | ||
| 4298 : | <?php echo $menu->name; ?> | ||
| 4299 : | </a> | ||
| 4300 : | </strong> | ||
| 4301 : | </td> | ||
| 4302 : | </tr> | ||
| 4303 : | <tr> | ||
| 4304 : | <td width="90px" valign="top"> | ||
| 4305 : | csouza | 39 | <?php echo T_('State') ?> |
| 4306 : | root | 1 | </td> |
| 4307 : | <td> | ||
| 4308 : | <?php | ||
| 4309 : | switch ( $menu->published ) { | ||
| 4310 : | case -2: | ||
| 4311 : | echo '<font color="red">Trashed</font>'; | ||
| 4312 : | break; | ||
| 4313 : | case 0: | ||
| 4314 : | echo 'UnPublished'; | ||
| 4315 : | break; | ||
| 4316 : | case 1: | ||
| 4317 : | default: | ||
| 4318 : | echo '<font color="green">Published</font>'; | ||
| 4319 : | break; | ||
| 4320 : | } | ||
| 4321 : | ?> | ||
| 4322 : | </td> | ||
| 4323 : | </tr> | ||
| 4324 : | <?php | ||
| 4325 : | } | ||
| 4326 : | ?> | ||
| 4327 : | <input type="hidden" name="menu" value="" /> | ||
| 4328 : | <input type="hidden" name="menuid" value="" /> | ||
| 4329 : | <?php | ||
| 4330 : | } | ||
| 4331 : | |||
| 4332 : | function menuLinksSecCat( &$menus ) { | ||
| 4333 : | ?> | ||
| 4334 : | <script language="javascript" type="text/javascript"> | ||
| 4335 : | function go2( pressbutton, menu, id ) { | ||
| 4336 : | var form = document.adminForm; | ||
| 4337 : | |||
| 4338 : | if (pressbutton == 'go2menu') { | ||
| 4339 : | form.menu.value = menu; | ||
| 4340 : | submitform( pressbutton ); | ||
| 4341 : | return; | ||
| 4342 : | } | ||
| 4343 : | |||
| 4344 : | if (pressbutton == 'go2menuitem') { | ||
| 4345 : | form.menu.value = menu; | ||
| 4346 : | form.menuid.value = id; | ||
| 4347 : | submitform( pressbutton ); | ||
| 4348 : | return; | ||
| 4349 : | } | ||
| 4350 : | } | ||
| 4351 : | </script> | ||
| 4352 : | <?php | ||
| 4353 : | foreach( $menus as $menu ) { | ||
| 4354 : | ?> | ||
| 4355 : | <tr> | ||
| 4356 : | <td colspan="2"> | ||
| 4357 : | <hr/> | ||
| 4358 : | </td> | ||
| 4359 : | </tr> | ||
| 4360 : | <tr> | ||
| 4361 : | <td width="90px" valign="top"> | ||
| 4362 : | csouza | 39 | <?php echo T_('Menu') ?> |
| 4363 : | root | 1 | </td> |
| 4364 : | <td> | ||
| 4365 : | <a href="javascript:go2( 'go2menu', '<?php echo $menu->menutype; ?>' );" title="Go to Menu"> | ||
| 4366 : | <?php echo $menu->menutype; ?> | ||
| 4367 : | </a> | ||
| 4368 : | </td> | ||
| 4369 : | </tr> | ||
| 4370 : | <tr> | ||
| 4371 : | <td width="90px" valign="top"> | ||
| 4372 : | csouza | 39 | <?php echo T_('Type') ?> |
| 4373 : | root | 1 | </td> |
| 4374 : | <td> | ||
| 4375 : | <?php echo $menu->type; ?> | ||
| 4376 : | </td> | ||
| 4377 : | </tr> | ||
| 4378 : | <tr> | ||
| 4379 : | <td width="90px" valign="top"> | ||
| 4380 : | csouza | 39 | <?php echo T_('Item Name') ?> |
| 4381 : | root | 1 | </td> |
| 4382 : | <td> | ||
| 4383 : | <strong> | ||
| 4384 : | <a href="javascript:go2( 'go2menuitem', '<?php echo $menu->menutype; ?>', '<?php echo $menu->id; ?>' );" title="Go to Menu Item"> | ||
| 4385 : | <?php echo $menu->name; ?> | ||
| 4386 : | </a> | ||
| 4387 : | </strong> | ||
| 4388 : | </td> | ||
| 4389 : | </tr> | ||
| 4390 : | <tr> | ||
| 4391 : | <td width="90px" valign="top"> | ||
| 4392 : | csouza | 39 | <?php echo T_('State') ?> |
| 4393 : | root | 1 | </td> |
| 4394 : | <td> | ||
| 4395 : | <?php | ||
| 4396 : | switch ( $menu->published ) { | ||
| 4397 : | case -2: | ||
| 4398 : | csouza | 39 | echo '<font color="red">'.T_('Trashed').'</font>'; |
| 4399 : | root | 1 | break; |
| 4400 : | case 0: | ||
| 4401 : | csouza | 39 | echo T_('UnPublished'); |
| 4402 : | root | 1 | break; |
| 4403 : | case 1: | ||
| 4404 : | default: | ||
| 4405 : | csouza | 39 | echo '<font color="green">'.T_('Published').'</font>'; |
| 4406 : | root | 1 | break; |
| 4407 : | } | ||
| 4408 : | ?> | ||
| 4409 : | </td> | ||
| 4410 : | </tr> | ||
| 4411 : | <?php | ||
| 4412 : | } | ||
| 4413 : | ?> | ||
| 4414 : | <input type="hidden" name="menu" value="" /> | ||
| 4415 : | <input type="hidden" name="menuid" value="" /> | ||
| 4416 : | <?php | ||
| 4417 : | } | ||
| 4418 : | |||
| 4419 : | function checkedOut( &$row, $overlib=1 ) { | ||
| 4420 : | $hover = ''; | ||
| 4421 : | if ( $overlib ) { | ||
| 4422 : | $date = mosFormatDate( $row->checked_out_time, '%A, %d %B %Y' ); | ||
| 4423 : | $time = mosFormatDate( $row->checked_out_time, '%H:%M' ); | ||
| 4424 : | $checked_out_text = '<table>'; | ||
| 4425 : | $checked_out_text .= '<tr><td>'. $row->editor .'</td></tr>'; | ||
| 4426 : | $checked_out_text .= '<tr><td>'. $date .'</td></tr>'; | ||
| 4427 : | $checked_out_text .= '<tr><td>'. $time .'</td></tr>'; | ||
| 4428 : | $checked_out_text .= '</table>'; | ||
| 4429 : | $hover = 'onMouseOver="return overlib(\''. $checked_out_text .'\', CAPTION, \'Checked Out\', BELOW, RIGHT);" onMouseOut="return nd();"'; | ||
| 4430 : | } | ||
| 4431 : | $checked = '<img src="images/checked_out.png" '. $hover .'/>'; | ||
| 4432 : | |||
| 4433 : | return $checked; | ||
| 4434 : | } | ||
| 4435 : | |||
| 4436 : | /* | ||
| 4437 : | * Loads all necessary files for JS Overlib tooltips | ||
| 4438 : | */ | ||
| 4439 : | function loadOverlib() { | ||
| 4440 : | global $mosConfig_live_site; | ||
| 4441 : | ?> | ||
| 4442 : | <script language="Javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script> | ||
| 4443 : | <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div> | ||
| 4444 : | <?php | ||
| 4445 : | } | ||
| 4446 : | |||
| 4447 : | |||
| 4448 : | /* | ||
| 4449 : | * Loads all necessary files for JS Calendar | ||
| 4450 : | */ | ||
| 4451 : | function loadCalendar() { | ||
| 4452 : | global $mosConfig_live_site; | ||
| 4453 : | ?> | ||
| 4454 : | <link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar-mos.css" title="green" /> | ||
| 4455 : | <!-- import the calendar script --> | ||
| 4456 : | <script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar.js"></script> | ||
| 4457 : | <!-- import the language module --> | ||
| 4458 : | <script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/lang/calendar-en.js"></script> | ||
| 4459 : | <?php | ||
| 4460 : | } | ||
| 4461 : | |||
| 4462 : | function AccessProcessing( &$row, $i ) { | ||
| 4463 : | if ( !$row->access ) { | ||
| 4464 : | $color_access = 'style="color: green;"'; | ||
| 4465 : | $task_access = 'accessregistered'; | ||
| 4466 : | } else if ( $row->access == 1 ) { | ||
| 4467 : | $color_access = 'style="color: red;"'; | ||
| 4468 : | $task_access = 'accessspecial'; | ||
| 4469 : | } else { | ||
| 4470 : | $color_access = 'style="color: black;"'; | ||
| 4471 : | $task_access = 'accesspublic'; | ||
| 4472 : | } | ||
| 4473 : | |||
| 4474 : | $href = ' | ||
| 4475 : | <a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'> | ||
| 4476 : | '. $row->groupname .' | ||
| 4477 : | </a>' | ||
| 4478 : | ; | ||
| 4479 : | |||
| 4480 : | return $href; | ||
| 4481 : | } | ||
| 4482 : | |||
| 4483 : | function CheckedOutProcessing( &$row, $i ) { | ||
| 4484 : | global $my; | ||
| 4485 : | |||
| 4486 : | if ( $row->checked_out ) { | ||
| 4487 : | $checked = mosCommonHTML::checkedOut( $row ); | ||
| 4488 : | } else { | ||
| 4489 : | $checked = mosHTML::idBox( $i, $row->id, ($row->checked_out && $row->checked_out != $my->id ) ); | ||
| 4490 : | } | ||
| 4491 : | |||
| 4492 : | return $checked; | ||
| 4493 : | } | ||
| 4494 : | |||
| 4495 : | function PublishedProcessing( &$row, $i ) { | ||
| 4496 : | $img = $row->published ? 'publish_g.png' : 'publish_x.png'; | ||
| 4497 : | $task = $row->published ? 'unpublish' : 'publish'; | ||
| 4498 : | csouza | 39 | $alt = $row->published ? T_('Published' ): T_('Unpublished'); |
| 4499 : | $action = $row->published ? T_('Unpublish Item') : T_('Publish item'); | ||
| 4500 : | root | 1 | |
| 4501 : | $href = ' | ||
| 4502 : | <a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task .'\')" title="'. $action .'"> | ||
| 4503 : | <img src="images/'. $img .'" border="0" alt="'. $alt .'" /> | ||
| 4504 : | </a>' | ||
| 4505 : | ; | ||
| 4506 : | |||
| 4507 : | return $href; | ||
| 4508 : | } | ||
| 4509 : | } | ||
| 4510 : | |||
| 4511 : | /** | ||
| 4512 : | * Sorts an Array of objects | ||
| 4513 : | */ | ||
| 4514 : | function SortArrayObjects_cmp( &$a, &$b ) { | ||
| 4515 : | global $csort_cmp; | ||
| 4516 : | |||
| 4517 : | if ( $a->$csort_cmp['key'] > $b->$csort_cmp['key'] ) { | ||
| 4518 : | return $csort_cmp['direction']; | ||
| 4519 : | } | ||
| 4520 : | |||
| 4521 : | if ( $a->$csort_cmp['key'] < $b->$csort_cmp['key'] ) { | ||
| 4522 : | return -1 * $csort_cmp['direction']; | ||
| 4523 : | } | ||
| 4524 : | |||
| 4525 : | return 0; | ||
| 4526 : | } | ||
| 4527 : | |||
| 4528 : | /** | ||
| 4529 : | * Sorts an Array of objects | ||
| 4530 : | * sort_direction [1 = Ascending] [-1 = Descending] | ||
| 4531 : | */ | ||
| 4532 : | function SortArrayObjects( &$a, $k, $sort_direction=1 ) { | ||
| 4533 : | global $csort_cmp; | ||
| 4534 : | |||
| 4535 : | $csort_cmp = array( | ||
| 4536 : | 'key' => $k, | ||
| 4537 : | 'direction' => $sort_direction | ||
| 4538 : | ); | ||
| 4539 : | |||
| 4540 : | usort( $a, 'SortArrayObjects_cmp' ); | ||
| 4541 : | |||
| 4542 : | unset( $csort_cmp ); | ||
| 4543 : | } | ||
| 4544 : | |||
| 4545 : | /** | ||
| 4546 : | * Sends mail to admin | ||
| 4547 : | */ | ||
| 4548 : | function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) { | ||
| 4549 : | global $mosConfig_live_site; | ||
| 4550 : | |||
| 4551 : | csouza | 39 | $subject = T_('User Submitted')." '$type'"; |
| 4552 : | $message = T_('_MAIL_MSG'); | ||
| 4553 : | $message = sprintf(T_('Hello %s,\n\n\nA user submitted %s:\n [ %s ]\n has been just been submitted by user:\n [ %s ]\n for %s.\n\n\n\n | ||
| 4554 : | Please go to %s/administrator to view and approve this %s.\n\n | ||
| 4555 : | Please do not respond to this message as it is automatically generated and is for information purposes only\n'), $adminName, $type, $title, $author, $mosConfig_live_site, $mosConfig_live_site, $type); | ||
| 4556 : | root | 1 | mosMail($mosConfig_mailfrom, $mosConfig_fromname, $adminEmail, $subject, $message); |
| 4557 : | } | ||
| 4558 : | |||
| 4559 : | /* | ||
| 4560 : | * Includes pathway file | ||
| 4561 : | */ | ||
| 4562 : | function mosPathWay() { | ||
| 4563 : | $Itemid = mosGetParam($_REQUEST,'Itemid',''); | ||
| 4564 : | require $GLOBALS['mosConfig_absolute_path'] . '/includes/pathway.php'; | ||
| 4565 : | } | ||
| 4566 : | |||
| 4567 : | /** | ||
| 4568 : | * Displays a not authorised message | ||
| 4569 : | * | ||
| 4570 : | * If the user is not logged in then an addition message is displayed. | ||
| 4571 : | */ | ||
| 4572 : | function mosNotAuth() { | ||
| 4573 : | global $my; | ||
| 4574 : | |||
| 4575 : | csouza | 39 | echo T_('You are not authorized to view this resource.'); |
| 4576 : | root | 1 | if ($my->id < 1) { |
| 4577 : | csouza | 39 | echo "<br />" . T_('You need to login.'); |
| 4578 : | root | 1 | } |
| 4579 : | } | ||
| 4580 : | |||
| 4581 : | /** | ||
| 4582 : | * Replaces & with & for xhtml compliance | ||
| 4583 : | * | ||
| 4584 : | * Needed to handle unicode conflicts due to unicode conflicts | ||
| 4585 : | */ | ||
| 4586 : | function ampReplace( $text ) { | ||
| 4587 : | $text = str_replace( '&#', '*-*', $text ); | ||
| 4588 : | $text = str_replace( '&', '&', $text ); | ||
| 4589 : | $text = str_replace( '*-*', '&#', $text ); | ||
| 4590 : | |||
| 4591 : | return $text; | ||
| 4592 : | } | ||
| 4593 : | |||
| 4594 : | /** | ||
| 4595 : | * Prepares results from search for display | ||
| 4596 : | * @param string The source string | ||
| 4597 : | * @param int Number of chars to trim | ||
| 4598 : | * @param string The searchword to select around | ||
| 4599 : | * @return string | ||
| 4600 : | */ | ||
| 4601 : | function mosPrepareSearchContent( $text, $length=200, $searchword ) { | ||
| 4602 : | // strips tags won't remove the actual jscript | ||
| 4603 : | $text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text ); | ||
| 4604 : | $text = preg_replace( '/{.+?}/', '', $text); | ||
| 4605 : | //$text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2', $text ); | ||
| 4606 : | return mosSmartSubstr( strip_tags( $text ), $length, $searchword ); | ||
| 4607 : | } | ||
| 4608 : | |||
| 4609 : | /** | ||
| 4610 : | * returns substring of characters around a searchword | ||
| 4611 : | * @param string The source string | ||
| 4612 : | * @param int Number of chars to return | ||
| 4613 : | * @param string The searchword to select around | ||
| 4614 : | * @return string | ||
| 4615 : | */ | ||
| 4616 : | function mosSmartSubstr($text, $length=200, $searchword) { | ||
| 4617 : | $wordpos = strpos(strtolower($text), strtolower($searchword)); | ||
| 4618 : | $halfside = intval($wordpos - $length/2 - strlen($searchword)); | ||
| 4619 : | if ($wordpos && $halfside > 0) { | ||
| 4620 : | return '...' . substr($text, $halfside, $length); | ||
| 4621 : | } else { | ||
| 4622 : | return substr( $text, 0, $length); | ||
| 4623 : | } | ||
| 4624 : | } | ||
| 4625 : | |||
| 4626 : | /** | ||
| 4627 : | * Chmods files and directories recursively to given permissions. Available from 4.5.2 up. | ||
| 4628 : | * @param path The starting file or directory (no trailing slash) | ||
| 4629 : | * @param filemode Integer value to chmod files. NULL = dont chmod files. | ||
| 4630 : | * @param dirmode Integer value to chmod directories. NULL = dont chmod directories. | ||
| 4631 : | * @return TRUE=all succeeded FALSE=one or more chmods failed | ||
| 4632 : | */ | ||
| 4633 : | function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL) | ||
| 4634 : | { | ||
| 4635 : | $ret = TRUE; | ||
| 4636 : | if (is_dir($path)) { | ||
| 4637 : | $dh = opendir($path); | ||
| 4638 : | while ($file = readdir($dh)) { | ||
| 4639 : | if ($file != '.' && $file != '..') { | ||
| 4640 : | $fullpath = $path.'/'.$file; | ||
| 4641 : | if (is_dir($fullpath)) { | ||
| 4642 : | if (!mosChmodRecursive($fullpath, $filemode, $dirmode)) | ||
| 4643 : | $ret = FALSE; | ||
| 4644 : | } else { | ||
| 4645 : | if (isset($filemode)) | ||
| 4646 : | if (!@chmod($fullpath, $filemode)) | ||
| 4647 : | $ret = FALSE; | ||
| 4648 : | } // if | ||
| 4649 : | } // if | ||
| 4650 : | } // while | ||
| 4651 : | closedir($dh); | ||
| 4652 : | if (isset($dirmode)) | ||
| 4653 : | if (!@chmod($path, $dirmode)) | ||
| 4654 : | $ret = FALSE; | ||
| 4655 : | } else { | ||
| 4656 : | if (isset($filemode)) | ||
| 4657 : | $ret = @chmod($path, $filemode); | ||
| 4658 : | } // if | ||
| 4659 : | return $ret; | ||
| 4660 : | } // mosChmodRecursive | ||
| 4661 : | |||
| 4662 : | /** | ||
| 4663 : | * Chmods files and directories recursively to mos global permissions. Available from 4.5.2 up. | ||
| 4664 : | * @param path The starting file or directory (no trailing slash) | ||
| 4665 : | * @param filemode Integer value to chmod files. NULL = dont chmod files. | ||
| 4666 : | * @param dirmode Integer value to chmod directories. NULL = dont chmod directories. | ||
| 4667 : | * @return TRUE=all succeeded FALSE=one or more chmods failed | ||
| 4668 : | */ | ||
| 4669 : | function mosChmod($path) | ||
| 4670 : | { | ||
| 4671 : | global $mosConfig_fileperms, $mosConfig_dirperms; | ||
| 4672 : | $filemode = NULL; | ||
| 4673 : | if ($mosConfig_fileperms != '') | ||
| 4674 : | $filemode = octdec($mosConfig_fileperms); | ||
| 4675 : | $dirmode = NULL; | ||
| 4676 : | if ($mosConfig_dirperms != '') | ||
| 4677 : | $dirmode = octdec($mosConfig_dirperms); | ||
| 4678 : | if (isset($filemode) || isset($dirmode)) | ||
| 4679 : | return mosChmodRecursive($path, $filemode, $dirmode); | ||
| 4680 : | return TRUE; | ||
| 4681 : | } // mosChmod | ||
| 4682 : | |||
| 4683 : | /** | ||
| 4684 : | * Function to convert array to integer values | ||
| 4685 : | */ | ||
| 4686 : | function mosArrayToInts( &$array, $default=null ) { | ||
| 4687 : | if (is_array( $array )) { | ||
| 4688 : | $n = count( $array ); | ||
| 4689 : | for ($i = 0; $i < $n; $i++) { | ||
| 4690 : | $array[$i] = intval( $array[$i] ); | ||
| 4691 : | } | ||
| 4692 : | } else { | ||
| 4693 : | if (is_null( $default )) { | ||
| 4694 : | return array(); | ||
| 4695 : | } else { | ||
| 4696 : | return array( $default ); | ||
| 4697 : | } | ||
| 4698 : | } | ||
| 4699 : | } | ||
| 4700 : | |||
| 4701 : | mambo | 117 | ======= |
| 4702 : | |||
| 4703 : | |||
| 4704 : | |||
| 4705 : | |||
| 4706 : | |||
| 4707 : | |||
| 4708 : | |||
| 4709 : | |||
| 4710 : | |||
| 4711 : | |||
| 4712 : | |||
| 4713 : | |||
| 4714 : | |||
| 4715 : | |||
| 4716 : | |||
| 4717 : | |||
| 4718 : | |||
| 4719 : | |||
| 4720 : | |||
| 4721 : | |||
| 4722 : | |||
| 4723 : | |||
| 4724 : | |||
| 4725 : | |||
| 4726 : | |||
| 4727 : | |||
| 4728 : | |||
| 4729 : | |||
| 4730 : | |||
| 4731 : |

