Annotation of /trunk/lib/zoom.class.php
Parent Directory
|
Revision Log
Revision 2 - (view) (download)
| 1 : | andphe | 2 | <?php |
| 2 : | //zOOm Media Gallery// | ||
| 3 : | /** | ||
| 4 : | ----------------------------------------------------------------------- | ||
| 5 : | | zOOm Media Gallery! by Mike de Boer - a multi-gallery component | | ||
| 6 : | ----------------------------------------------------------------------- | ||
| 7 : | |||
| 8 : | ----------------------------------------------------------------------- | ||
| 9 : | | | | ||
| 10 : | | Author: Mike de Boer, <http://www.mikedeboer.nl> | | ||
| 11 : | | Copyright: copyright (C) 2007 by Mike de Boer | | ||
| 12 : | | Description: zOOm Media Gallery, a multi-gallery component for | | ||
| 13 : | | Joomla!. It's the most feature-rich gallery component | | ||
| 14 : | | for Joomla!! For documentation and a detailed list | | ||
| 15 : | | of features, check the zOOm homepage: | | ||
| 16 : | | http://www.zoomfactory.org | | ||
| 17 : | | License: GPL | | ||
| 18 : | | Filename: zoom.class.php | | ||
| 19 : | | | | ||
| 20 : | ----------------------------------------------------------------------- | ||
| 21 : | * @version $Id: zoom.class.php 142 2007-03-12 22:17:28Z spignataro $ | ||
| 22 : | * @package zOOmGallery | ||
| 23 : | * @author Mike de Boer <mailme@mikedeboer.nl> | ||
| 24 : | **/ | ||
| 25 : | // MOS Intruder Alerts | ||
| 26 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 27 : | if (!defined('_MOS_NOTRIM')) { | ||
| 28 : | define( "_MOS_NOTRIM", 0x0001 ); | ||
| 29 : | define( "_MOS_ALLOWHTML", 0x0002 ); | ||
| 30 : | define( "_MOS_ALLOWRAW", 0x0004 ); | ||
| 31 : | } | ||
| 32 : | |||
| 33 : | class zoom { | ||
| 34 : | //first, some of the default internal variables... | ||
| 35 : | /** | ||
| 36 : | * @var string | ||
| 37 : | * @access private | ||
| 38 : | */ | ||
| 39 : | var $_sql = null; | ||
| 40 : | /** | ||
| 41 : | * @var table | ||
| 42 : | * @access private | ||
| 43 : | */ | ||
| 44 : | var $_result = null; | ||
| 45 : | /** | ||
| 46 : | * @var array | ||
| 47 : | * @access public | ||
| 48 : | */ | ||
| 49 : | var $_CONFIG = null; | ||
| 50 : | /** | ||
| 51 : | * @var toolbox | ||
| 52 : | * @access public | ||
| 53 : | */ | ||
| 54 : | var $toolbox = null; | ||
| 55 : | /** | ||
| 56 : | * @var ftplib | ||
| 57 : | * @access public | ||
| 58 : | */ | ||
| 59 : | var $ftplib = null; | ||
| 60 : | /** | ||
| 61 : | * @var editmon | ||
| 62 : | * @access public | ||
| 63 : | */ | ||
| 64 : | var $EditMon = null; | ||
| 65 : | /** | ||
| 66 : | * @var gallery | ||
| 67 : | * @access public | ||
| 68 : | */ | ||
| 69 : | var $_gallery = null; | ||
| 70 : | /** | ||
| 71 : | * @var ecard | ||
| 72 : | * @access public | ||
| 73 : | */ | ||
| 74 : | var $ecard = null; | ||
| 75 : | /** | ||
| 76 : | * @var int | ||
| 77 : | * @access private | ||
| 78 : | */ | ||
| 79 : | var $_counter = null; | ||
| 80 : | /** | ||
| 81 : | * @var boolean | ||
| 82 : | * @access private | ||
| 83 : | */ | ||
| 84 : | var $_isAdmin = null; | ||
| 85 : | /** | ||
| 86 : | * @var privileges | ||
| 87 : | * @access public | ||
| 88 : | */ | ||
| 89 : | var $privileges = null; | ||
| 90 : | /** | ||
| 91 : | * @var int | ||
| 92 : | * @access public | ||
| 93 : | */ | ||
| 94 : | var $currUID = null; | ||
| 95 : | /** | ||
| 96 : | * @var int | ||
| 97 : | * @access public | ||
| 98 : | */ | ||
| 99 : | var $currGID = null; | ||
| 100 : | /** | ||
| 101 : | * @var int | ||
| 102 : | * @access public | ||
| 103 : | */ | ||
| 104 : | var $_startRow = null; | ||
| 105 : | /** | ||
| 106 : | * @var int | ||
| 107 : | * @access public | ||
| 108 : | */ | ||
| 109 : | var $_pageSize = null; | ||
| 110 : | /** | ||
| 111 : | * @var array | ||
| 112 : | * @access public | ||
| 113 : | */ | ||
| 114 : | var $_tabclass = null; | ||
| 115 : | /** | ||
| 116 : | * @var string | ||
| 117 : | * @access public | ||
| 118 : | */ | ||
| 119 : | var $_EXIF_cachefile = null; | ||
| 120 : | /** | ||
| 121 : | * @var array | ||
| 122 : | * @access public | ||
| 123 : | */ | ||
| 124 : | var $_CAT_LIST = null; | ||
| 125 : | /** | ||
| 126 : | * @var boolen | ||
| 127 : | * @access public | ||
| 128 : | */ | ||
| 129 : | var $_isWin = null; | ||
| 130 : | /** | ||
| 131 : | * @var boolean | ||
| 132 : | * @access public | ||
| 133 : | */ | ||
| 134 : | var $_isBackend = null; | ||
| 135 : | /** | ||
| 136 : | * @var int | ||
| 137 : | * @access public | ||
| 138 : | */ | ||
| 139 : | var $cmstype = null; | ||
| 140 : | /** | ||
| 141 : | * @var string | ||
| 142 : | * @access public | ||
| 143 : | */ | ||
| 144 : | var $_tempname = null; | ||
| 145 : | /** | ||
| 146 : | * @var int | ||
| 147 : | * @access private | ||
| 148 : | */ | ||
| 149 : | var $_folderCount = null; | ||
| 150 : | /** | ||
| 151 : | * @var int | ||
| 152 : | * @access private | ||
| 153 : | */ | ||
| 154 : | var $_fileCount = null; | ||
| 155 : | /** | ||
| 156 : | * @var byte | ||
| 157 : | * @access private | ||
| 158 : | */ | ||
| 159 : | var $_folderSize = null; | ||
| 160 : | /** | ||
| 161 : | * @var platform | ||
| 162 : | * @access public | ||
| 163 : | */ | ||
| 164 : | var $platform = null; | ||
| 165 : | /** | ||
| 166 : | * zOOm object contructor. | ||
| 167 : | * | ||
| 168 : | * @return zoom | ||
| 169 : | * @access public | ||
| 170 : | */ | ||
| 171 : | function zoom() { | ||
| 172 : | global $version; | ||
| 173 : | // initialize object variables with some values... | ||
| 174 : | $this->getConfig(); | ||
| 175 : | $this->currUID = -1; | ||
| 176 : | $this->currGID = -1; | ||
| 177 : | $this->_checkRights(); | ||
| 178 : | $this->_counter = 0; | ||
| 179 : | $this->_startRow = 0; | ||
| 180 : | $this->_tabclass = Array("sectiontableentry1", "sectiontableentry2"); | ||
| 181 : | $this->_EXIF_cachefile = "exif.dat"; | ||
| 182 : | $this->_isWin = (strtolower(PHP_OS) == 'winnt') ? true : false; | ||
| 183 : | $this->_isBackend = false; | ||
| 184 : | // get child-objects... | ||
| 185 : | $this->EditMon = new editmon(); | ||
| 186 : | // mambo version detection (which is necessary for backward-compatibility)... | ||
| 187 : | if (eregi("4\.5[ \t]", $version)) { | ||
| 188 : | $this->cmstype = 1; | ||
| 189 : | } else { | ||
| 190 : | $this->cmstype = 2; | ||
| 191 : | } | ||
| 192 : | if ($this->privileges->hasPrivileges()) { | ||
| 193 : | $this->ftplib = new ftplib(); | ||
| 194 : | } | ||
| 195 : | } | ||
| 196 : | /** | ||
| 197 : | * @return boolean | ||
| 198 : | * @desc check if the native OS is Windows (NT) or UNIX based. | ||
| 199 : | */ | ||
| 200 : | function isWin() { | ||
| 201 : | return $this->_isWin; | ||
| 202 : | } | ||
| 203 : | //--------------------zOOm Security Functions--------------------------// | ||
| 204 : | /** | ||
| 205 : | * @return void | ||
| 206 : | * @desc Check the usertype and privileges of the current session for admin or edit rights. | ||
| 207 : | * @access public | ||
| 208 : | */ | ||
| 209 : | function _checkRights() { | ||
| 210 : | global $my, $database; | ||
| 211 : | if (strtolower($my->usertype) == 'administrator' || strtolower($my->usertype) == 'superadministrator' || strtolower($my->usertype) == 'super administrator') { | ||
| 212 : | $this->_isAdmin = true; | ||
| 213 : | } else { | ||
| 214 : | $this->_isAdmin = false; | ||
| 215 : | } | ||
| 216 : | $this->currUID = intval($my->id); | ||
| 217 : | //if (isset($my->gid)) { | ||
| 218 : | if ($my->id > 0) { | ||
| 219 : | //get the exact ARO gid, because Mambo messed/ trims it up for some reason... | ||
| 220 : | $database->setQuery("SELECT gid FROM #__users WHERE id = '$my->id' LIMIT 1"); | ||
| 221 : | $result = $database->query(); | ||
| 222 : | while ($row = mysql_fetch_object($result)) { | ||
| 223 : | $gid = $row->gid; | ||
| 224 : | } | ||
| 225 : | } else { | ||
| 226 : | $gid = $my->gid; | ||
| 227 : | } | ||
| 228 : | $this->currGID = intval($gid); | ||
| 229 : | @$this->privileges = new privileges($database, $gid); | ||
| 230 : | } | ||
| 231 : | /** | ||
| 232 : | * @return string | ||
| 233 : | * @param int $userspass | ||
| 234 : | * @desc Create a HTML select list of users and permitted usertypes. | ||
| 235 : | * @access public | ||
| 236 : | */ | ||
| 237 : | function getUsersList($userspass = 0, $exclude = false) { | ||
| 238 : | global $database, $acl; | ||
| 239 : | // Create users List | ||
| 240 : | $database->setQuery("SELECT id, name, username FROM #__users ORDER BY name ASC"); | ||
| 241 : | if ($this->_result = $database->query()) { | ||
| 242 : | $musers = array(); | ||
| 243 : | $musers = array("<select name=\"members_opt[]\" id=\"members_opt\" class=\"inputbox\" size=\"20\" multiple=\"multiple\">\n"); | ||
| 244 : | $musers[] = "\t<option value=\"0\">"._ZOOM_USERSLIST_LINE1."</option>\n"; | ||
| 245 : | if(@in_array("1", $userspass) && !$exclude) { | ||
| 246 : | $musers[] = "\t<option value=\"1\" selected>"._ZOOM_USERSLIST_ALLOWALL."</option>\n"; | ||
| 247 : | } else { | ||
| 248 : | $musers[] = "\t<option value=\"1\">"._ZOOM_USERSLIST_ALLOWALL."</option>\n"; | ||
| 249 : | } | ||
| 250 : | $musers[] = "\t<option value=\"0\" disabled=\"true\">-----------</option>\n"; | ||
| 251 : | if (@in_array("2", $userspass) && !$exclude) { | ||
| 252 : | $musers[] = "\t<option value=\"2\" selected>".$acl->get_group_name('18')."</option>\n"; | ||
| 253 : | } else { | ||
| 254 : | $musers[] = "\t<option value=\"2\">".$acl->get_group_name('18')."</option>\n"; | ||
| 255 : | } | ||
| 256 : | |||
| 257 : | |||
| 258 : | $gtree = $acl->get_group_children_tree( null, 'USERS', false ); | ||
| 259 : | foreach($gtree as $group) { | ||
| 260 : | if($userspass == 0) { | ||
| 261 : | if($group->value == '29') { | ||
| 262 : | //$musers[] = "\t<option value=\"1\" disabled=\"true\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 263 : | } else if($group->value == '18') { | ||
| 264 : | //$musers[] = "\t<option value=\"2\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 265 : | } else if ($group->value == '30') { | ||
| 266 : | $musers[] = "\t<option value=\"23\" disabled=\"true\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 267 : | } else { | ||
| 268 : | $musers[] = "\t<option value=\"gid-".$group->value."\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 269 : | } | ||
| 270 : | } else { | ||
| 271 : | $mayadd = true; | ||
| 272 : | if (in_array("gid-".$group->value, $userspass)) { | ||
| 273 : | $selected = "selected"; | ||
| 274 : | if ($exclude) { | ||
| 275 : | $mayadd = false; | ||
| 276 : | } | ||
| 277 : | } else { | ||
| 278 : | $selected = ""; | ||
| 279 : | } | ||
| 280 : | if($group->value == '29') { | ||
| 281 : | //$musers[] = "\t<option value=\"1\" disabled=\"true\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 282 : | } else if($group->value == '18') { | ||
| 283 : | //$musers[] = "\t<option value=\"2\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 284 : | } else if($group->value == '30') { | ||
| 285 : | $musers[] = "\t<option value=\"0\" disabled=\"true\">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 286 : | } else { | ||
| 287 : | $musers[] = "\t<option value=\"gid-".$group->value."\"".$selected.">".$acl->get_group_name($group->value)."</option>\n"; | ||
| 288 : | } | ||
| 289 : | } | ||
| 290 : | } | ||
| 291 : | |||
| 292 : | $musers[] = "\t<option value=\"0\" disabled=\"true\">-----------</option>\n"; | ||
| 293 : | // append the rest of the users to the array | ||
| 294 : | // and select the already access-granted users from the passed userlist... | ||
| 295 : | while ($row = mysql_fetch_object($this->_result)) { | ||
| 296 : | if ($userspass == 0) { | ||
| 297 : | $musers[] = "\t<option value=\"".$row->id."\">".$row->id."-".$row->name."(".$row->username.")"."</option>\t"; | ||
| 298 : | } else { | ||
| 299 : | $mayadd = true; | ||
| 300 : | if (in_array($row->id, $userspass) ) { | ||
| 301 : | $selected = "selected"; | ||
| 302 : | if ($exclude) { | ||
| 303 : | $mayadd = false; | ||
| 304 : | } | ||
| 305 : | } else { | ||
| 306 : | $selected = ""; | ||
| 307 : | } | ||
| 308 : | if ($mayadd) { | ||
| 309 : | $musers[] = "\t<option value=\"".$row->id."\"".$selected.">".$row->id."-".$row->name."(".$row->username.")"."</option>\n"; | ||
| 310 : | } | ||
| 311 : | } | ||
| 312 : | } | ||
| 313 : | $musers[] = "</select>\n"; | ||
| 314 : | } | ||
| 315 : | return $musers; | ||
| 316 : | } | ||
| 317 : | //--------------------END zOOm Security Functions----------------------// | ||
| 318 : | //--------------------Filesystem Functions-----------------------------// | ||
| 319 : | |||
| 320 : | /** | ||
| 321 : | * @return boolean | ||
| 322 : | * @param string $dst_dir | ||
| 323 : | * @desc remove a gallery directory completely using the PHP ftp-library (SAFE MODE = ON) | ||
| 324 : | * @access public | ||
| 325 : | */ | ||
| 326 : | function ftp_rmAll($dst_dir) { | ||
| 327 : | $ar_files = $this->ftplib->nlist('', $dst_dir); | ||
| 328 : | //check whether we really got something from the ftp_nlist function | ||
| 329 : | if (is_array($ar_files)) { | ||
| 330 : | foreach ($ar_files as $dir) { | ||
| 331 : | if ($dir != "." && $dir != "..") { | ||
| 332 : | if ($ftplib->size($dir) === -1) { // dirname | ||
| 333 : | $this->ftp_rmAll($dir); // recursion | ||
| 334 : | } else { | ||
| 335 : | $this->ftplib->delete($dir); // del file | ||
| 336 : | } | ||
| 337 : | } | ||
| 338 : | } | ||
| 339 : | $this->ftplib->rmdir($dst_dir); // delete empty directories | ||
| 340 : | return true; | ||
| 341 : | } else { | ||
| 342 : | return false; | ||
| 343 : | } | ||
| 344 : | } | ||
| 345 : | /** | ||
| 346 : | * @return boolean | ||
| 347 : | * @param string $dir | ||
| 348 : | * @desc remove a gallery completely including sub-directories. | ||
| 349 : | * @access public | ||
| 350 : | */ | ||
| 351 : | function deldir($dir) { | ||
| 352 : | global $mosConfig_absolute_path; | ||
| 353 : | $result = true; | ||
| 354 : | if ($this->_CONFIG['safemodeON']) { | ||
| 355 : | $dir = substr($dir,strlen($mosConfig_absolute_path)); | ||
| 356 : | $ftp_dirtoremove = $this->_CONFIG['ftp_hostdir'].$dir; | ||
| 357 : | //remove directory | ||
| 358 : | $result = $this->ftp_rmAll($ftp_dirtoremove); //do it recursively with helper function | ||
| 359 : | return $result; | ||
| 360 : | } else { | ||
| 361 : | $current_dir = $this->platform->opendir($dir); | ||
| 362 : | while ($entryname = $this->platform->readdir($current_dir)) { | ||
| 363 : | if ($this->platform->is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")) { | ||
| 364 : | $this->deldir("${dir}/${entryname}"); | ||
| 365 : | } elseif($entryname != "." and $entryname!="..") { | ||
| 366 : | $this->platform->unlink("${dir}/${entryname}"); | ||
| 367 : | } | ||
| 368 : | } | ||
| 369 : | $this->platform->closedir($current_dir); | ||
| 370 : | $this->platform->rmdir("${dir}"); | ||
| 371 : | return true; | ||
| 372 : | } | ||
| 373 : | } | ||
| 374 : | /** | ||
| 375 : | * @return string | ||
| 376 : | * @desc Generate a random directory-name for a new gallery. | ||
| 377 : | * @access public | ||
| 378 : | */ | ||
| 379 : | function newdir() { | ||
| 380 : | $newdir = ""; | ||
| 381 : | srand((double) microtime() * 1000000); | ||
| 382 : | for ($acc = 1; $acc <= 6; $acc++){ | ||
| 383 : | $newdir .= chr(rand (0,25) + 65); | ||
| 384 : | } | ||
| 385 : | return $newdir; | ||
| 386 : | } | ||
| 387 : | /** | ||
| 388 : | * @return boolean | ||
| 389 : | * @param string $path | ||
| 390 : | * @param int $mode | ||
| 391 : | * @desc Create a directory (generally used when creating a new gallery) in ftp- or normal-mode. | ||
| 392 : | * @access public | ||
| 393 : | */ | ||
| 394 : | function createdir($path, $mode = '755') { //changed from 777 - Steven Pignataro | ||
| 395 : | global $mosConfig_absolute_path; | ||
| 396 : | $result = true; | ||
| 397 : | if ($this->_CONFIG['safemodeON']) { | ||
| 398 : | //append directory on host to the path... | ||
| 399 : | $path = $this->_CONFIG['ftp_hostdir']."/".$path; | ||
| 400 : | //initialize FTP connection | ||
| 401 : | $connected = $this->ftplib->connect($this->_CONFIG['ftp_server']); | ||
| 402 : | // login | ||
| 403 : | $login_result = $this->ftplib->login($this->_CONFIG['ftp_username'], $this->_CONFIG['ftp_pass']); | ||
| 404 : | // verify connection | ||
| 405 : | if (!$connected || !$login_result) { | ||
| 406 : | echo ("<strong>Error connecting FTP</strong><br />\n" | ||
| 407 : | . "Error connecting to FTP-Server ".$this->_CONFIG['ftp_server']." for user ".$this->_CONFIG['ftp_user_name']); | ||
| 408 : | $result = false; | ||
| 409 : | } else { | ||
| 410 : | //create directory | ||
| 411 : | //$result = ftp_mkdir($conn_id,$path); //this won't work with subdirectories | ||
| 412 : | $dir = split("/", $path); | ||
| 413 : | $path = ""; | ||
| 414 : | $result = true; | ||
| 415 : | for ($i = 1; $i < count($dir); $i++) { | ||
| 416 : | $path .= "/".$dir[$i]; | ||
| 417 : | //echo "$path\n"; | ||
| 418 : | if (!@$this->ftplib->chdir($path)) { | ||
| 419 : | @$this->ftplib->chdir("/"); | ||
| 420 : | if (!@$this->ftplib->mkdir($path)) { | ||
| 421 : | $result = false; | ||
| 422 : | break; | ||
| 423 : | } else { | ||
| 424 : | //@ftp_chmod($conn_id, $mode, $path); //this gives problems with some servers | ||
| 425 : | $chmod_cmd="CHMOD ".$mode." ".$path; | ||
| 426 : | $chmod=$this->ftplib->site($chmod_cmd); | ||
| 427 : | } | ||
| 428 : | } | ||
| 429 : | } | ||
| 430 : | } | ||
| 431 : | //Close connection | ||
| 432 : | $this->ftplib->quit(); | ||
| 433 : | } else { | ||
| 434 : | //prepend full path to Mambo to the $path variable... | ||
| 435 : | $path = $mosConfig_absolute_path."/".$path; | ||
| 436 : | $result = $this->platform->mkdir($path, $mode); | ||
| 437 : | @$this->platform->chmod($path, $mode); | ||
| 438 : | } | ||
| 439 : | return $result; | ||
| 440 : | } | ||
| 441 : | /** | ||
| 442 : | * @return boolean | ||
| 443 : | * @param int $mode | ||
| 444 : | * @desc Create a temporary directory in the Mambo 'media' dir with a unique name. | ||
| 445 : | * @access public | ||
| 446 : | */ | ||
| 447 : | function createTempDir($mode = '777') { | ||
| 448 : | $tmpdir = "media/".substr(uniqid("zoom_"), 0, 13); //support filesystems which only support 14 char dirnames | ||
| 449 : | if ($this->createdir($tmpdir, $mode)) { | ||
| 450 : | return $tmpdir; | ||
| 451 : | } else { | ||
| 452 : | return false; | ||
| 453 : | } | ||
| 454 : | } | ||
| 455 : | /** | ||
| 456 : | * @return boolean | ||
| 457 : | * @param string $filename | ||
| 458 : | * @param string $content | ||
| 459 : | * @desc Write content to a file on the filesystem. $filename needs to be a FULL path. | ||
| 460 : | * @access public | ||
| 461 : | */ | ||
| 462 : | function writefile($filename, $content) { | ||
| 463 : | if ($fp = $this->platform->fopen($filename, 'w+')) { | ||
| 464 : | fputs($fp, $content, strlen($content)); | ||
| 465 : | $this->platform->fclose($fp); | ||
| 466 : | } | ||
| 467 : | return true; | ||
| 468 : | } | ||
| 469 : | /** | ||
| 470 : | * @return boolean | ||
| 471 : | * @param string $extractdir | ||
| 472 : | * @param string $archivename | ||
| 473 : | * @desc Extract an archive (zip-file) to a given directory using the PCL library. | ||
| 474 : | * @access public | ||
| 475 : | */ | ||
| 476 : | function extractArchive($extractdir, $archivename) { | ||
| 477 : | global $mosConfig_absolute_path; | ||
| 478 : | if ($this->cmstype == 2) { | ||
| 479 : | $zlib_prefix = "$mosConfig_absolute_path/administrator/includes/pcl/"; | ||
| 480 : | } else { | ||
| 481 : | $zlib_prefix = "$mosConfig_absolute_path/administrator/classes/"; | ||
| 482 : | } | ||
| 483 : | require_once( $zlib_prefix."pclzip.lib.php" ); | ||
| 484 : | $zipfile = new PclZip($archivename); | ||
| 485 : | if ($this->_isWin) { | ||
| 486 : | define('OS_WINDOWS',1); | ||
| 487 : | } | ||
| 488 : | $ret = $zipfile->extract(PCLZIP_OPT_PATH, $extractdir); | ||
| 489 : | if($ret <= 0) { | ||
| 490 : | return false; | ||
| 491 : | } else { | ||
| 492 : | return true; | ||
| 493 : | } | ||
| 494 : | } | ||
| 495 : | /** | ||
| 496 : | * @return boolean | ||
| 497 : | * @param array $filelist | ||
| 498 : | * @param string $archivename | ||
| 499 : | * @param string $remove_dir | ||
| 500 : | * @desc Create an archive (zip-file) containing files from the array $filelist. | ||
| 501 : | * @access public | ||
| 502 : | */ | ||
| 503 : | function createArchive($filelist, $archivename, $remove_dir) { | ||
| 504 : | global $mosConfig_absolute_path; | ||
| 505 : | if ($this->cmstype == 2) { | ||
| 506 : | $zlib_prefix = "$mosConfig_absolute_path/administrator/includes/pcl/"; | ||
| 507 : | } else { | ||
| 508 : | $zlib_prefix = "$mosConfig_absolute_path/administrator/classes/"; | ||
| 509 : | } | ||
| 510 : | require_once($zlib_prefix."pclzip.lib.php"); | ||
| 511 : | $zipfile = new PclZip($archivename); | ||
| 512 : | if ($this->_isWin) { | ||
| 513 : | define('OS_WINDOWS',1); | ||
| 514 : | } | ||
| 515 : | $ret = $zipfile->create($filelist, '', $remove_dir); | ||
| 516 : | if($ret <= 0) { | ||
| 517 : | return false; | ||
| 518 : | } else { | ||
| 519 : | return true; | ||
| 520 : | } | ||
| 521 : | } | ||
| 522 : | /** | ||
| 523 : | * @return void | ||
| 524 : | * @param string $directory | ||
| 525 : | * @desc Calculate the size of directory, including sub-directories. | ||
| 526 : | * @access public | ||
| 527 : | */ | ||
| 528 : | function dirStatistics($directory) { | ||
| 529 : | $oldDir = getcwd(); | ||
| 530 : | $this->platform->chdir($directory); | ||
| 531 : | $directory = getcwd(); | ||
| 532 : | if ($open = $this->platform->opendir($directory)) { | ||
| 533 : | while ($file = $this->platform->readdir($open)) { | ||
| 534 : | if ($file == '..' || $file == '.') { continue; }; | ||
| 535 : | if ($this->platform->is_file($file)) { | ||
| 536 : | $this->_fileCount++; | ||
| 537 : | $this->_folderSize += filesize($file); | ||
| 538 : | } elseif($this->platform->is_dir($file)) { | ||
| 539 : | $this->_folderCount++; | ||
| 540 : | } | ||
| 541 : | } | ||
| 542 : | if ($this->_folderCount > 0) { | ||
| 543 : | $open2 = $this->platform->opendir($directory); | ||
| 544 : | while ($folders = $this->platform->readdir($open2)) { | ||
| 545 : | $folder = $directory.'/'.$folders; | ||
| 546 : | if ($folders == '..' || $folders == '.') { continue; }; | ||
| 547 : | if (is_dir($folder)) { | ||
| 548 : | $this->dirStatistics($folder); | ||
| 549 : | } | ||
| 550 : | } | ||
| 551 : | $this->platform->closedir($open2); | ||
| 552 : | } | ||
| 553 : | $this->platform->closedir($open); | ||
| 554 : | } | ||
| 555 : | $this->platform->chdir($oldDir); | ||
| 556 : | } | ||
| 557 : | /** | ||
| 558 : | * @return string | ||
| 559 : | * @param int $bytes | ||
| 560 : | * @desc Parse the byte-value returned by dirStatistics() to human readable formats. | ||
| 561 : | * @access public | ||
| 562 : | */ | ||
| 563 : | function parseFolderSize($bytes) { | ||
| 564 : | $size = $bytes / 1024; | ||
| 565 : | if ($size < 1024){ | ||
| 566 : | $size = number_format($size, 2); | ||
| 567 : | $size .= 'kb'; | ||
| 568 : | } else { | ||
| 569 : | if ($size / 1024 < 1024) { | ||
| 570 : | $size = number_format($size / 1024, 2); | ||
| 571 : | $size .= 'mb'; | ||
| 572 : | } elseif($size / 1024 / 1024 < 1024) { | ||
| 573 : | $size = number_format($size / 1024 / 1024, 2); | ||
| 574 : | $size .= 'gb'; | ||
| 575 : | } else { | ||
| 576 : | $size = number_format($size / 1024 / 1024 / 1024, 2); | ||
| 577 : | $size .= 'tb'; | ||
| 578 : | } | ||
| 579 : | } | ||
| 580 : | return $size; | ||
| 581 : | } | ||
| 582 : | /** | ||
| 583 : | * @return integer: the max upload size | ||
| 584 : | * @desc Get the max uploadsize | ||
| 585 : | * @access private | ||
| 586 : | * @author Teye Heimans | ||
| 587 : | */ | ||
| 588 : | function getMaxUploadSize() { | ||
| 589 : | static $iIniSize = false; | ||
| 590 : | |||
| 591 : | if (!$iIniSize) { | ||
| 592 : | $iPost = intval($this->_iniSizeToBytes(ini_get('post_max_size'))); | ||
| 593 : | $iUpl = intval($this->_iniSizeToBytes(ini_get('upload_max_filesize'))); | ||
| 594 : | $iIniSize = floor(($iPost < $iUpl) ? $iPost : $iUpl); | ||
| 595 : | } | ||
| 596 : | return $iIniSize; | ||
| 597 : | } | ||
| 598 : | |||
| 599 : | /** | ||
| 600 : | * @param string $sIniSize: The size we have to make to bytes | ||
| 601 : | * @return integer: the size in bytes | ||
| 602 : | * @desc Get the given size in bytes | ||
| 603 : | * @access private | ||
| 604 : | * @author Teye Heimans | ||
| 605 : | */ | ||
| 606 : | function _iniSizeToBytes($sIniSize) { | ||
| 607 : | $aIniParts = array(); | ||
| 608 : | if (!is_string($sIniSize)) { | ||
| 609 : | return false; | ||
| 610 : | } | ||
| 611 : | if (!preg_match ('/^(\d+)([bkm]*)$/i', $sIniSize, $aIniParts)) { | ||
| 612 : | return false; | ||
| 613 : | } | ||
| 614 : | |||
| 615 : | $iSize = $aIniParts[1]; | ||
| 616 : | $sUnit = strtolower($aIniParts[2]); | ||
| 617 : | |||
| 618 : | switch ($sUnit) { | ||
| 619 : | case 'm': | ||
| 620 : | return (int)($iSize * 1048576); | ||
| 621 : | case 'k': | ||
| 622 : | return (int)($iSize * 1024); | ||
| 623 : | case 'b': | ||
| 624 : | default: | ||
| 625 : | return (int)$iSize; | ||
| 626 : | } | ||
| 627 : | } | ||
| 628 : | /** | ||
| 629 : | * @return boolean | ||
| 630 : | * @param string $file | ||
| 631 : | * @desc Check if a file is within the filesize limits, set by the administrator. | ||
| 632 : | * @access public | ||
| 633 : | */ | ||
| 634 : | function acceptableSize($file) { | ||
| 635 : | if ($this->platform->is_file($file)) { | ||
| 636 : | $size = intval(($this->platform->filesize($file) / 1024)); | ||
| 637 : | if ($size <= intval($this->_CONFIG['maxsizekb'])) { | ||
| 638 : | return true; | ||
| 639 : | } else { | ||
| 640 : | return false; | ||
| 641 : | } | ||
| 642 : | } else { | ||
| 643 : | return false; | ||
| 644 : | } | ||
| 645 : | } | ||
| 646 : | //--------------------END Filesystem Functions-------------------------// | ||
| 647 : | //--------------------Accepted file format functions-------------------// | ||
| 648 : | /** | ||
| 649 : | * @return boolean | ||
| 650 : | * @param string $tag | ||
| 651 : | * @param int $isMime | ||
| 652 : | * @desc Check if the processed file can be accepted by zOOm. | ||
| 653 : | * @access public | ||
| 654 : | */ | ||
| 655 : | function acceptableFormat($tag, $isMime = false) { | ||
| 656 : | if ($isMime) { | ||
| 657 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 658 : | } | ||
| 659 : | return ($this->isImage($tag) || $this->isMovie($tag) || $this->isDocument($tag) || $this->isAudio($tag)); | ||
| 660 : | } | ||
| 661 : | /** | ||
| 662 : | * @return string | ||
| 663 : | * @desc Generate a regular expression from the file formats zOOm can accept for use with the function eregi(). | ||
| 664 : | * @access public | ||
| 665 : | */ | ||
| 666 : | function acceptableFormatRegexp() { | ||
| 667 : | return "(" . join("|", $this->_acceptableFormatList()) . ")"; | ||
| 668 : | } | ||
| 669 : | /** | ||
| 670 : | * @return string | ||
| 671 : | * @desc Generate a comma-seperated list of acceptable file-formats for display purposes only. | ||
| 672 : | * @access public | ||
| 673 : | */ | ||
| 674 : | function acceptableFormatCommaSep() { | ||
| 675 : | return join(", ", $this->_acceptableFormatList()); | ||
| 676 : | } | ||
| 677 : | /** | ||
| 678 : | * @return array | ||
| 679 : | * @desc Returns list of acceptable movie extensions. | ||
| 680 : | * @access private | ||
| 681 : | */ | ||
| 682 : | function _acceptableMovieList() { | ||
| 683 : | return array('avi', 'mpg', 'mpeg', 'swf', 'flv', 'wmv', 'mov', 'rm', 'swf'); | ||
| 684 : | } | ||
| 685 : | /** | ||
| 686 : | * @return array | ||
| 687 : | * @desc Returns list of acceptable image extensions. | ||
| 688 : | * @access private | ||
| 689 : | */ | ||
| 690 : | function _acceptableImageList() { | ||
| 691 : | return array('jpg', 'jpeg', 'gif', 'png'); | ||
| 692 : | } | ||
| 693 : | /** | ||
| 694 : | * @return array | ||
| 695 : | * @desc Returns list of acceptable document extensions. | ||
| 696 : | * @access private | ||
| 697 : | */ | ||
| 698 : | function _acceptableDocumentList() { | ||
| 699 : | return array('doc', 'ppt', 'pdf', 'rtf'); | ||
| 700 : | } | ||
| 701 : | /** | ||
| 702 : | * @return array | ||
| 703 : | * @desc Returns list of acceptable audio extensions. | ||
| 704 : | * @access private | ||
| 705 : | */ | ||
| 706 : | function _acceptableAudioList() { | ||
| 707 : | return array('mp3','ogg','wma'); | ||
| 708 : | } | ||
| 709 : | /** | ||
| 710 : | * @return array | ||
| 711 : | * @desc Returns list of audio extensions that can be played by the zOOm Player. | ||
| 712 : | * @access private | ||
| 713 : | */ | ||
| 714 : | function _playableAudioList() { | ||
| 715 : | return array('mp3','wma'); | ||
| 716 : | } | ||
| 717 : | /** | ||
| 718 : | * @return array | ||
| 719 : | * @desc Returns list of movie extensions that can be thumbnailed by FFMPEG (with absolute compatibility in mind). | ||
| 720 : | * @access public | ||
| 721 : | */ | ||
| 722 : | function thumbnailableMovieList() { | ||
| 723 : | // this list doesn't have to be this big, BUT these are the formats supported by FFmpeg... | ||
| 724 : | return array('avi', 'ac3', 'asf', 'asx', 'dv', 'm4v', 'mpg', 'mpeg', 'swf', 'flv', 'mjpeg', 'mov', 'mp4', 'm4a', 'rm', 'rpm', 'wc3', 'wmv', 'swf'); | ||
| 725 : | } | ||
| 726 : | /** | ||
| 727 : | * @return array | ||
| 728 : | * @desc Returns list of acceptable extensions that can be thumbnailed by the graphics library and/ or ffmpeg. | ||
| 729 : | */ | ||
| 730 : | function thumbnailableList() { | ||
| 731 : | return array_merge($this->_acceptableImageList(), $this->thumbnailableMovieList()); | ||
| 732 : | } | ||
| 733 : | /** | ||
| 734 : | * @return array | ||
| 735 : | * @desc Returns list of document extensions that can be indexed by zOOm. | ||
| 736 : | * @access private | ||
| 737 : | */ | ||
| 738 : | function _indexableList() { | ||
| 739 : | return array('pdf'); | ||
| 740 : | } | ||
| 741 : | /** | ||
| 742 : | * @return array | ||
| 743 : | * @desc Returns list of all acceptable extensions. | ||
| 744 : | * @access private | ||
| 745 : | */ | ||
| 746 : | function _acceptableFormatList() { | ||
| 747 : | return array_merge($this->_acceptableImageList(), $this->_acceptableMovieList(), $this->_acceptableDocumentList(), $this->_acceptableAudioList()); | ||
| 748 : | } | ||
| 749 : | /** | ||
| 750 : | * @return boolean | ||
| 751 : | * @param string $tag | ||
| 752 : | * @param int $isMime | ||
| 753 : | * @desc Check if a file is an image. | ||
| 754 : | * @access public | ||
| 755 : | */ | ||
| 756 : | function isImage($tag, $isMime = false) { | ||
| 757 : | if ($isMime) { | ||
| 758 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 759 : | } | ||
| 760 : | return in_array($tag, $this->_acceptableImageList()); | ||
| 761 : | } | ||
| 762 : | /** | ||
| 763 : | * @return boolean | ||
| 764 : | * @param string $tag | ||
| 765 : | * @param int $isMime | ||
| 766 : | * @desc Check if a file is a movie. | ||
| 767 : | * @access public | ||
| 768 : | */ | ||
| 769 : | function isMovie($tag, $isMime = false) { | ||
| 770 : | if ($isMime) { | ||
| 771 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 772 : | } | ||
| 773 : | return in_array($tag, $this->_acceptableMovieList()); | ||
| 774 : | } | ||
| 775 : | /** | ||
| 776 : | * @return boolean | ||
| 777 : | * @param string $tag | ||
| 778 : | * @param int $isMime | ||
| 779 : | * @desc Check if a file is an audio file. | ||
| 780 : | * @access public | ||
| 781 : | */ | ||
| 782 : | function isAudio($tag, $isMime = false) { | ||
| 783 : | if ($isMime) { | ||
| 784 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 785 : | } | ||
| 786 : | return in_array($tag, $this->_acceptableAudioList()); | ||
| 787 : | } | ||
| 788 : | /** | ||
| 789 : | * @return boolean | ||
| 790 : | * @param string $tag | ||
| 791 : | * @param int $isMime | ||
| 792 : | * @desc Check if a file can be played by the zOOm Player. | ||
| 793 : | * @access public | ||
| 794 : | */ | ||
| 795 : | function isPlayable($tag, $isMime = false) { | ||
| 796 : | if ($isMime) { | ||
| 797 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 798 : | } | ||
| 799 : | return in_array($tag, $this->_playableAudioList()); | ||
| 800 : | } | ||
| 801 : | /** | ||
| 802 : | * @return boolean | ||
| 803 : | * @param string $tag | ||
| 804 : | * @param int $isMime | ||
| 805 : | * @desc Check if a file is a Real Media file. | ||
| 806 : | * @access public | ||
| 807 : | */ | ||
| 808 : | function isRealmedia($tag, $isMime = false) { | ||
| 809 : | if ($isMime) { | ||
| 810 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 811 : | } | ||
| 812 : | if($tag == 'rm') { | ||
| 813 : | return true; | ||
| 814 : | } else { | ||
| 815 : | return false; | ||
| 816 : | } | ||
| 817 : | } | ||
| 818 : | /** | ||
| 819 : | * @return boolean | ||
| 820 : | * @param string $tag | ||
| 821 : | * @param int $isMime | ||
| 822 : | * @desc Check if a file is an Apple Quicktime file. | ||
| 823 : | * @access public | ||
| 824 : | */ | ||
| 825 : | function isQuicktime($tag, $isMime = false) { | ||
| 826 : | if ($isMime) { | ||
| 827 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 828 : | } | ||
| 829 : | if($tag == 'mov') { | ||
| 830 : | return true; | ||
| 831 : | } else { | ||
| 832 : | return false; | ||
| 833 : | } | ||
| 834 : | } | ||
| 835 : | /** | ||
| 836 : | * @return boolean | ||
| 837 : | * @param string $tag | ||
| 838 : | * @param int $isMime | ||
| 839 : | * @desc Check if a file is a Flash video file. | ||
| 840 : | * @access public | ||
| 841 : | */ | ||
| 842 : | function isFlashvideo($tag, $isMime = false) { | ||
| 843 : | if ($isMime) { | ||
| 844 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 845 : | } | ||
| 846 : | if($tag == 'flv') { | ||
| 847 : | return true; | ||
| 848 : | } else { | ||
| 849 : | return false; | ||
| 850 : | } | ||
| 851 : | } | ||
| 852 : | /** | ||
| 853 : | * @return boolean | ||
| 854 : | * @param string $tag | ||
| 855 : | * @param int $isMime | ||
| 856 : | * @desc Check if a file is a document. | ||
| 857 : | * @access public | ||
| 858 : | */ | ||
| 859 : | function isDocument($tag, $isMime = false) { | ||
| 860 : | if ($isMime) { | ||
| 861 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 862 : | } | ||
| 863 : | return in_array($tag, $this->_acceptableDocumentList()); | ||
| 864 : | } | ||
| 865 : | /** | ||
| 866 : | * @return boolean | ||
| 867 : | * @param string $tag | ||
| 868 : | * @param int $isMime | ||
| 869 : | * @desc Check if a file can be resized by the zOOm toolbox. | ||
| 870 : | * @access public | ||
| 871 : | */ | ||
| 872 : | function isThumbnailable($tag, $isMime = false) { | ||
| 873 : | if ($isMime) { | ||
| 874 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 875 : | } | ||
| 876 : | return in_array($tag, $this->thumbnailableList()); | ||
| 877 : | } | ||
| 878 : | /** | ||
| 879 : | * @return boolean | ||
| 880 : | * @param string $tag | ||
| 881 : | * @param int $isMime | ||
| 882 : | * @desc Check if a file is indexable by the zOOm toolbox. | ||
| 883 : | * @access public | ||
| 884 : | */ | ||
| 885 : | function isIndexable($tag, $isMime = false) { | ||
| 886 : | if ($isMime) { | ||
| 887 : | $tag = MIME_Helper::convertMimeToExtension($tag); | ||
| 888 : | } | ||
| 889 : | return in_array($tag, $this->_indexableList()); | ||
| 890 : | } | ||
| 891 : | //--------------------END Accepted file format functions---------------// | ||
| 892 : | //--------------------Module auto-detection----------------------------// | ||
| 893 : | /** | ||
| 894 : | * @return boolean | ||
| 895 : | * @desc Check if the zOOm Module by Per Lasse Baasch has been installed. | ||
| 896 : | * @access public | ||
| 897 : | */ | ||
| 898 : | function getModule() { | ||
| 899 : | global $database; | ||
| 900 : | $database->setQuery("SELECT title FROM #__modules WHERE module = 'mod_zoom'"); | ||
| 901 : | if ($this->_result = $database->query()) { | ||
| 902 : | if (mysql_num_rows($this->_result) != 0) { | ||
| 903 : | return true; | ||
| 904 : | } else { | ||
| 905 : | return false; | ||
| 906 : | } | ||
| 907 : | } else { | ||
| 908 : | return false; | ||
| 909 : | } | ||
| 910 : | |||
| 911 : | } | ||
| 912 : | //--------------------END Module auto-detection------------------------// | ||
| 913 : | //--------------------Cleaning String-datatype-------------------------// | ||
| 914 : | /** | ||
| 915 : | * @author Chris Tobin | ||
| 916 : | * @author Daniel Morris | ||
| 917 : | * @access protected | ||
| 918 : | * @param String $source | ||
| 919 : | * @return String $source | ||
| 920 : | */ | ||
| 921 : | function escapeString($string) { | ||
| 922 : | // depreciated function | ||
| 923 : | if (version_compare(phpversion(),"4.3.0", "<")) mysql_escape_string($string); | ||
| 924 : | // current function | ||
| 925 : | else mysql_real_escape_string($string); | ||
| 926 : | return $string; | ||
| 927 : | } | ||
| 928 : | /** | ||
| 929 : | * @return string | ||
| 930 : | * @param string $text | ||
| 931 : | * @param boolean $checkslashes | ||
| 932 : | * @desc Remove needless clutter from a given string. | ||
| 933 : | * @access public | ||
| 934 : | */ | ||
| 935 : | function cleanString($text, $checkslashes = true) { | ||
| 936 : | // code adapted from the phpDig package, | ||
| 937 : | // a PHP search engine/ webspider. | ||
| 938 : | // Copyright (C) 2001 - 2003, Antoine Bajolet, http://www.toiletoine.net/ | ||
| 939 : | // Copyright (C) 2003 - current, Charter, http://www.phpdig.net/ | ||
| 940 : | |||
| 941 : | //replace blank characters by spaces | ||
| 942 : | $text = trim($text); | ||
| 943 : | $text = ereg_replace("[\r\n\t]+"," ",$text); | ||
| 944 : | //delete content of head, script, and style tags | ||
| 945 : | $text = eregi_replace("<head[^>]*>.*</head>"," ",$text); | ||
| 946 : | $text = preg_replace("/<script[^>]*?>.*?<\/script>/is"," ",$text); // less conservative | ||
| 947 : | $text = eregi_replace("<style[^>]*>.*</style>"," ",$text); | ||
| 948 : | $text = preg_replace("/<iframe[^>]*?>.*?<\/iframe>/is"," ",$text); | ||
| 949 : | // clean tags | ||
| 950 : | /* $text = preg_replace("/<[\/\!]*?[^<>]*?>/is"," ",$text); */ | ||
| 951 : | $text = ereg_replace("[[:space:]]+"," ",$text); | ||
| 952 : | $text = ($checkslashes && get_magic_quotes_gpc()) ? stripslashes($text) : $text; | ||
| 953 : | return $text; | ||
| 954 : | } | ||
| 955 : | |||
| 956 : | /** | ||
| 957 : | * @return string | ||
| 958 : | * @param string $msg | ||
| 959 : | * @desc remove HTML tags from a string. | ||
| 960 : | * @access public | ||
| 961 : | */ | ||
| 962 : | function removeTags($msg) { | ||
| 963 : | $msg = strip_tags($msg); | ||
| 964 : | return $msg; | ||
| 965 : | } | ||
| 966 : | /** | ||
| 967 : | * @return string | ||
| 968 : | * @param string $it | ||
| 969 : | * @param string $text | ||
| 970 : | * @desc Highlight a substring in text red. | ||
| 971 : | * @access public | ||
| 972 : | */ | ||
| 973 : | function highlight($it, $text) { | ||
| 974 : | $replacement = '<font color="red">'.quotemeta($it).'</font>'; | ||
| 975 : | return eregi_replace($it, $replacement, $text); | ||
| 976 : | } | ||
| 977 : | /** | ||
| 978 : | * @return string | ||
| 979 : | * @param string $Name | ||
| 980 : | * @desc Switch to the next entry in an array safely. | ||
| 981 : | * @access public | ||
| 982 : | */ | ||
| 983 : | function getRequestShift($Name) { | ||
| 984 : | $Result = mosGetParam($_REQUEST,$Name); | ||
| 985 : | if (!$Result) { | ||
| 986 : | return null; | ||
| 987 : | } | ||
| 988 : | if (is_array($Result)) { | ||
| 989 : | return array_shift($Result); | ||
| 990 : | } | ||
| 991 : | return $Result; | ||
| 992 : | } | ||
| 993 : | /** | ||
| 994 : | * @return various | ||
| 995 : | * @param array $arr | ||
| 996 : | * @param string $name | ||
| 997 : | * @param various $def | ||
| 998 : | * @param int $mask | ||
| 999 : | * @desc Utility function to return a value from a named array or a specified default | ||
| 1000 : | * @access public | ||
| 1001 : | */ | ||
| 1002 : | function getParam(&$arr, $name, $def=null, $mask=0 ) { | ||
| 1003 : | $return = null; | ||
| 1004 : | if (isset($arr[$name])) { | ||
| 1005 : | $return = $arr[$name]; | ||
| 1006 : | if (is_string($return)) { | ||
| 1007 : | // trim data | ||
| 1008 : | if (!($mask&_MOS_NOTRIM)) { | ||
| 1009 : | $return = trim($return); | ||
| 1010 : | } | ||
| 1011 : | if ($mask&_MOS_ALLOWRAW) { | ||
| 1012 : | // do nothing | ||
| 1013 : | } else if (!($mask&_MOS_ALLOWHTML)) { | ||
| 1014 : | $return = $this->removeTags($return); | ||
| 1015 : | } else { | ||
| 1016 : | if (is_numeric($def)) { | ||
| 1017 : | // if default value is numeric set variable type to integer | ||
| 1018 : | $return = intval($return); | ||
| 1019 : | } | ||
| 1020 : | } | ||
| 1021 : | // account for magic quotes setting | ||
| 1022 : | if (!get_magic_quotes_gpc()) { | ||
| 1023 : | $return = addslashes($return); | ||
| 1024 : | } | ||
| 1025 : | } elseif (is_array($return)) { | ||
| 1026 : | if (!get_magic_quotes_gpc()) { | ||
| 1027 : | $return = $this->addSlashesOnArray($return); | ||
| 1028 : | } | ||
| 1029 : | } | ||
| 1030 : | return $return; | ||
| 1031 : | } else { | ||
| 1032 : | return $def; | ||
| 1033 : | } | ||
| 1034 : | } | ||
| 1035 : | /** | ||
| 1036 : | * AddSlash array | ||
| 1037 : | * This function traverses a multidimentional array and adds slashes to the values. | ||
| 1038 : | * NOTE that the input array is and argument by reference.!! | ||
| 1039 : | * Twin-function to stripSlashesOnArray | ||
| 1040 : | * | ||
| 1041 : | * @param array Multidimensional input array, (REFERENCE!) | ||
| 1042 : | * @return array | ||
| 1043 : | */ | ||
| 1044 : | function addSlashesOnArray(&$theArray) { | ||
| 1045 : | if (is_array($theArray)) { | ||
| 1046 : | reset($theArray); | ||
| 1047 : | while(list($Akey,$AVal)=each($theArray)) { | ||
| 1048 : | if (is_array($AVal)) { | ||
| 1049 : | $this->addSlashesOnArray($theArray[$Akey]); | ||
| 1050 : | } elseif (is_string($AVal)) { | ||
| 1051 : | $theArray[$Akey] = addslashes($AVal); | ||
| 1052 : | } | ||
| 1053 : | } | ||
| 1054 : | reset($theArray); | ||
| 1055 : | } | ||
| 1056 : | } | ||
| 1057 : | /** | ||
| 1058 : | * StripSlash array | ||
| 1059 : | * This function traverses a multidimentional array and strips slashes to the values. | ||
| 1060 : | * NOTE that the input array is and argument by reference.!! | ||
| 1061 : | * Twin-function to addSlashesOnArray | ||
| 1062 : | * | ||
| 1063 : | * @param array Multidimensional input array, (REFERENCE!) | ||
| 1064 : | * @return array | ||
| 1065 : | */ | ||
| 1066 : | function stripSlashesOnArray(&$theArray) { | ||
| 1067 : | if (is_array($theArray)) { | ||
| 1068 : | reset($theArray); | ||
| 1069 : | while(list($Akey,$AVal)=each($theArray)) { | ||
| 1070 : | if (is_array($AVal)) { | ||
| 1071 : | $this->stripSlashesOnArray($theArray[$Akey]); | ||
| 1072 : | } else { | ||
| 1073 : | $theArray[$Akey] = stripslashes($AVal); | ||
| 1074 : | } | ||
| 1075 : | } | ||
| 1076 : | reset($theArray); | ||
| 1077 : | } | ||
| 1078 : | } | ||
| 1079 : | /** | ||
| 1080 : | * Either slashes ($cmd=add) or strips ($cmd=strip) array $arr depending on $cmd | ||
| 1081 : | * | ||
| 1082 : | * @param array Multidimensional input array | ||
| 1083 : | * @param string "add" or "strip", depending on usage you wish. | ||
| 1084 : | * @return array | ||
| 1085 : | */ | ||
| 1086 : | function slashArray($arr,$cmd) { | ||
| 1087 : | if ($cmd=='strip') $this->stripSlashesOnArray($arr); | ||
| 1088 : | if ($cmd=='add') $this->addSlashesOnArray($arr); | ||
| 1089 : | return $arr; | ||
| 1090 : | } | ||
| 1091 : | /** | ||
| 1092 : | * Strip the slashes off a string safely, depending on the magic_quotes_gpc setting. | ||
| 1093 : | * | ||
| 1094 : | * @param $string | ||
| 1095 : | * @return string | ||
| 1096 : | */ | ||
| 1097 : | function stripslashesSafe($string) { | ||
| 1098 : | if (get_magic_quotes_gpc()) { | ||
| 1099 : | $string = stripslashes($string); | ||
| 1100 : | } | ||
| 1101 : | return $string; | ||
| 1102 : | } | ||
| 1103 : | /** | ||
| 1104 : | * Replace single or double quotes of a string with html equivalent. | ||
| 1105 : | * | ||
| 1106 : | * @param string $string | ||
| 1107 : | * @return string | ||
| 1108 : | */ | ||
| 1109 : | function quotesJS($string) { | ||
| 1110 : | return preg_replace("/['\"]/", """, $string); | ||
| 1111 : | } | ||
| 1112 : | /** | ||
| 1113 : | * @return string | ||
| 1114 : | * @param string $str | ||
| 1115 : | * @desc Returns a string with most UTF-8 characters converted to correct equivalents. | ||
| 1116 : | * @access public | ||
| 1117 : | */ | ||
| 1118 : | function htmlnumericentities($str) { | ||
| 1119 : | $str2 = htmlspecialchars($str, ENT_QUOTES); | ||
| 1120 : | |||
| 1121 : | return $str2; | ||
| 1122 : | } | ||
| 1123 : | function overlibfix($str) { | ||
| 1124 : | $str2 = str_replace("'","&#039",$str); | ||
| 1125 : | return $str2; | ||
| 1126 : | } | ||
| 1127 : | function revnumericentities($string) { | ||
| 1128 : | $string = str_replace ( '&', '&', $string ); | ||
| 1129 : | $string = str_replace ( ''', '\'', $string ); | ||
| 1130 : | $string = str_replace ( '"', '"', $string ); | ||
| 1131 : | $string = str_replace ( '<', '<', $string ); | ||
| 1132 : | $string = str_replace ( '>', '>', $string ); | ||
| 1133 : | return $string; | ||
| 1134 : | } | ||
| 1135 : | //--------------------END Cleaning Strings Datatype--------------------// | ||
| 1136 : | //--------------------URI Encryption functions-------------------------// | ||
| 1137 : | /** | ||
| 1138 : | * @return string | ||
| 1139 : | * @param string $string | ||
| 1140 : | * @desc Encrypt given URI parameters, so admin functions will not be available to hackers. | ||
| 1141 : | * @access public | ||
| 1142 : | */ | ||
| 1143 : | function encrypt($string) { | ||
| 1144 : | $convert = ''; | ||
| 1145 : | if (isset($string) && substr($string,1,4) != 'obfs') { | ||
| 1146 : | for ($i=0; $i < strlen($string); $i++) { | ||
| 1147 : | $dec = ord(substr($string,$i,1)); | ||
| 1148 : | if (strlen($dec) == 2) $dec = 0 . $dec; | ||
| 1149 : | $dec = 324 - $dec; | ||
| 1150 : | $convert .= $dec; | ||
| 1151 : | } | ||
| 1152 : | $convert = '{obfs:' . $convert . '}'; | ||
| 1153 : | return ($convert); | ||
| 1154 : | } else { | ||
| 1155 : | return $string; | ||
| 1156 : | } | ||
| 1157 : | } | ||
| 1158 : | /** | ||
| 1159 : | * @return string | ||
| 1160 : | * @param string $string | ||
| 1161 : | * @desc Decrypt a given URI parameter (which has to encrypted first!), so zOOm can use the original parameters again. | ||
| 1162 : | * @access public | ||
| 1163 : | */ | ||
| 1164 : | function decrypt($string) { | ||
| 1165 : | $convert = ''; | ||
| 1166 : | if (isset($string) && substr($string,1,4) == 'obfs') { | ||
| 1167 : | for ($i=6; $i < strlen($string)-1; $i = $i+3) { | ||
| 1168 : | $dec = substr($string,$i,3); | ||
| 1169 : | $dec = 324 - $dec; | ||
| 1170 : | $dec = chr($dec); | ||
| 1171 : | $convert .= $dec; | ||
| 1172 : | } | ||
| 1173 : | return ($convert); | ||
| 1174 : | } else { | ||
| 1175 : | return($string); | ||
| 1176 : | } | ||
| 1177 : | } | ||
| 1178 : | function hotlinkimage($cat_id, $type, $imgid, $key) { | ||
| 1179 : | global $mosConfig_live_site, $my; | ||
| 1180 : | $gallery = new gallery($cat_id, false); | ||
| 1181 : | if(!$key) { | ||
| 1182 : | $key = $gallery->getImageKey($imgid); | ||
| 1183 : | } else { | ||
| 1184 : | $imgid = $gallery->_images[$key]->_id; | ||
| 1185 : | } | ||
| 1186 : | $image = new image($imgid); | ||
| 1187 : | $image->getInfo(); | ||
| 1188 : | if($this->_CONFIG['hotlinkProtection']) { | ||
| 1189 : | $params = "uid=".$my->id."&catid=".$cat_id."&key=".$key."&type=".$type; | ||
| 1190 : | $params = $this->encrypt($params); | ||
| 1191 : | return $mosConfig_live_site."/components/com_zoom/www/image.php?q=".$params; | ||
| 1192 : | } else { | ||
| 1193 : | if($type == '0') { | ||
| 1194 : | return $mosConfig_live_site."/".$this->_CONFIG['imagepath'].$gallery->_dir."/".$image->_viewsize; | ||
| 1195 : | } elseif($type == '1') { | ||
| 1196 : | return $mosConfig_live_site."/".$this->_CONFIG['imagepath'].$gallery->_dir."/".$image->_filename; | ||
| 1197 : | } else { | ||
| 1198 : | return $image->_thumbnail; | ||
| 1199 : | } | ||
| 1200 : | } | ||
| 1201 : | } | ||
| 1202 : | //--------------------END URI Encryption functions---------------------// | ||
| 1203 : | //--------------------Date Handling functions--------------------------// | ||
| 1204 : | /** | ||
| 1205 : | * @return formatted date | ||
| 1206 : | * @param string $date in datetime format | ||
| 1207 : | * @desc Converts zooms date to a unix string and returns then local date as defined in the language string | ||
| 1208 : | * @access public | ||
| 1209 : | */ | ||
| 1210 : | function convertDate($date, $format = "", $offset = "") { | ||
| 1211 : | global $mosConfig_offset; | ||
| 1212 : | if ( $format == '' ) { | ||
| 1213 : | // %Y-%m-%d %H:%M:%S | ||
| 1214 : | $format = _ZOOM_DATEFORMAT; | ||
| 1215 : | } | ||
| 1216 : | if ( $offset == '' ) { | ||
| 1217 : | $offset = $mosConfig_offset; | ||
| 1218 : | } | ||
| 1219 : | if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) { | ||
| 1220 : | $date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] ); | ||
| 1221 : | $date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-'; | ||
| 1222 : | } | ||
| 1223 : | return $date; | ||
| 1224 : | } | ||
| 1225 : | //--------------------END Date Handling functions----------------------// | ||
| 1226 : | //--------------------Database Editing Functions-----------------------// | ||
| 1227 : | /** | ||
| 1228 : | * @return void | ||
| 1229 : | * @desc Get the data from the files zoom_config.php and safemode.php | ||
| 1230 : | * @access public | ||
| 1231 : | */ | ||
| 1232 : | function getConfig() { | ||
| 1233 : | global $database, $mosConfig_absolute_path, $zoomConfig; | ||
| 1234 : | foreach ($zoomConfig as $key => $val) { | ||
| 1235 : | $this->_CONFIG[$key] = $val; | ||
| 1236 : | } | ||
| 1237 : | // setup ACL permissions... | ||
| 1238 : | //$this->_mos_add_acl( 'action', 'edit', 'users', 'super administrator', 'content', 'all' ); | ||
| 1239 : | if (strlen($this->_CONFIG['safemodeversion']) > 0) { | ||
| 1240 : | $ftp_server = $ftp_username = $ftp_pass = $ftp_hostdir = ""; | ||
| 1241 : | include_once($mosConfig_absolute_path."/components/com_zoom/etc/safemode.php"); | ||
| 1242 : | //global $ftp_server, $ftp_username, $ftp_pass, $ftp_hostdir; | ||
| 1243 : | $this->_CONFIG['ftp_server'] = $ftp_server; | ||
| 1244 : | $this->_CONFIG['ftp_username'] = $ftp_username; | ||
| 1245 : | $this->_CONFIG['ftp_pass'] = $ftp_pass; | ||
| 1246 : | $this->_CONFIG['ftp_hostdir'] = $ftp_hostdir; | ||
| 1247 : | } | ||
| 1248 : | $this->_pageSize = $this->_CONFIG['PageSize']; | ||
| 1249 : | if ((bool) ini_get('safe_mode')) { | ||
| 1250 : | $this->_CONFIG['readEXIF'] = false; | ||
| 1251 : | $this->_CONFIG['readID3'] = false; | ||
| 1252 : | } | ||
| 1253 : | } | ||
| 1254 : | /** | ||
| 1255 : | * @return boolean | ||
| 1256 : | * @desc Save the newly entered configuration data into the files zoom_config.php and safemode.php | ||
| 1257 : | * @access public | ||
| 1258 : | */ | ||
| 1259 : | function saveConfig() { | ||
| 1260 : | global $database, $acl, $mosConfig_absolute_path; | ||
| 1261 : | $s01 = $this->stripslashesSafe($this->escapeString($_REQUEST['s01'])); | ||
| 1262 : | $s02 = $this->stripslashesSafe($this->escapeString($_REQUEST['s02'])); | ||
| 1263 : | $s03 = $this->stripslashesSafe($this->escapeString($_REQUEST['s03'])); | ||
| 1264 : | $s04 = $this->stripslashesSafe($this->escapeString($_REQUEST['s04'])); | ||
| 1265 : | $s05 = $this->stripslashesSafe($this->escapeString($_REQUEST['s05'])); | ||
| 1266 : | $s06 = $this->stripslashesSafe($this->escapeString($_REQUEST['s06'])); | ||
| 1267 : | $s07 = $this->stripslashesSafe($this->escapeString($_REQUEST['s07'])); | ||
| 1268 : | $s08 = $this->stripslashesSafe($this->escapeString($_REQUEST['s08'])); | ||
| 1269 : | $s09 = $this->stripslashesSafe($this->escapeString($_REQUEST['s09'])); | ||
| 1270 : | $s10 = $this->stripslashesSafe($this->escapeString($_REQUEST['s10'])); | ||
| 1271 : | $s11 = $this->stripslashesSafe($this->escapeString($_REQUEST['s11'])); | ||
| 1272 : | $s12 = $this->stripslashesSafe($this->escapeString($_REQUEST['s12'])); | ||
| 1273 : | $s13 = $this->stripslashesSafe($this->escapeString($_REQUEST['s13'])); | ||
| 1274 : | $s14 = $this->stripslashesSafe($this->escapeString($_REQUEST['s14'])); | ||
| 1275 : | //s15 has been deprecated: 'allow user upload' | ||
| 1276 : | $s16 = $this->stripslashesSafe($this->escapeString($_REQUEST['s16'])); | ||
| 1277 : | $s17 = $this->stripslashesSafe($this->escapeString($_REQUEST['s17'])); | ||
| 1278 : | // s18 is the CSS textarea...thus skipped. | ||
| 1279 : | $s19 = $this->stripslashesSafe($this->escapeString($_REQUEST['s19'])); | ||
| 1280 : | $s20 = $this->stripslashesSafe($this->escapeString($_REQUEST['s20'])); | ||
| 1281 : | $s21 = (isset($_REQUEST['s21'])) ? 1 : 0; | ||
| 1282 : | $s22 = $this->stripslashesSafe($this->escapeString($_REQUEST['s22'])); | ||
| 1283 : | $s23 = $this->stripslashesSafe($this->escapeString($_REQUEST['s23'])); | ||
| 1284 : | $s24 = $this->stripslashesSafe($this->escapeString($_REQUEST['s24'])); | ||
| 1285 : | $s25 = $this->stripslashesSafe($this->escapeString($_REQUEST['s25'])); | ||
| 1286 : | $s26 = $this->stripslashesSafe($this->escapeString($_REQUEST['s26'])); | ||
| 1287 : | // s27 has been deprecated 'access level' | ||
| 1288 : | $s28 = $this->stripslashesSafe($this->escapeString($_REQUEST['s28'])); | ||
| 1289 : | // s27 has been deprecated 'zoomModule' | ||
| 1290 : | // s30, s31, s32 have been deprecated => old user privs system. | ||
| 1291 : | $s33 = $this->stripslashesSafe($this->escapeString($_REQUEST['s33'])); | ||
| 1292 : | $s34 = $this->stripslashesSafe($this->escapeString($_REQUEST['s34'])); | ||
| 1293 : | $s35 = $this->stripslashesSafe($this->escapeString($_REQUEST['s35'])); | ||
| 1294 : | $s36 = $this->stripslashesSafe($this->escapeString($_REQUEST['s36'])); | ||
| 1295 : | $s37 = $this->stripslashesSafe($this->escapeString($_REQUEST['s37'])); | ||
| 1296 : | $s38 = $this->stripslashesSafe($this->escapeString($_REQUEST['s38'])); | ||
| 1297 : | $s39 = $this->stripslashesSafe($this->escapeString($_REQUEST['s39'])); | ||
| 1298 : | $s40 = $this->stripslashesSafe($this->escapeString($_REQUEST['s40'])); | ||
| 1299 : | $s41 = $this->stripslashesSafe($this->escapeString($_REQUEST['s41'])); | ||
| 1300 : | $s42 = $this->stripslashesSafe($this->escapeString($_REQUEST['s42'])); | ||
| 1301 : | $s43 = $this->stripslashesSafe($this->escapeString($_REQUEST['s43'])); | ||
| 1302 : | $s44 = $this->stripslashesSafe($this->escapeString($_REQUEST['s44'])); | ||
| 1303 : | $s45 = $this->stripslashesSafe($this->escapeString($_REQUEST['s45'])); | ||
| 1304 : | if(strlen($this->_CONFIG['safemodeversion']) > 0) { | ||
| 1305 : | $s46 = $this->stripslashesSafe($this->escapeString($_REQUEST['s46'])); | ||
| 1306 : | } else { | ||
| 1307 : | $s46 = 0; | ||
| 1308 : | } | ||
| 1309 : | // variables s47 till s49 are in use by the ftp feature and handled separately. | ||
| 1310 : | $s50 = $this->stripslashesSafe($this->escapeString($_REQUEST['s50'])); | ||
| 1311 : | $s51 = $this->stripslashesSafe($this->escapeString($_REQUEST['s51'])); | ||
| 1312 : | // variable s52 is in use by the ftp feature and handled seperately. | ||
| 1313 : | $s53 = $this->stripslashesSafe($this->escapeString($_REQUEST['s53'])); | ||
| 1314 : | $s54 = $this->stripslashesSafe($this->escapeString($_REQUEST['s54'])); | ||
| 1315 : | $s55 = $this->stripslashesSafe($this->escapeString($_REQUEST['s55'])); | ||
| 1316 : | $s56 = $this->stripslashesSafe($this->escapeString($_REQUEST['s56'])); | ||
| 1317 : | $s57 = $this->stripslashesSafe($this->escapeString($_REQUEST['s57'])); | ||
| 1318 : | $s58 = $this->stripslashesSafe($this->escapeString($_REQUEST['s58']));// mp3 configuration variable... | ||
| 1319 : | $s59 = $this->stripslashesSafe($this->escapeString($_REQUEST['s59'])); | ||
| 1320 : | // variable s60 is in use by the second CSS area, thus skipped... | ||
| 1321 : | $s60 = $this->stripslashesSafe($this->escapeString($_REQUEST['s61'])); | ||
| 1322 : | $s61 = $this->stripslashesSafe($this->escapeString($_REQUEST['s62'])); | ||
| 1323 : | $s62 = $this->stripslashesSafe($this->escapeString($_REQUEST['s63'])); | ||
| 1324 : | // s63 and s64 are deprecated because of Ajax rating implementation | ||
| 1325 : | $s65 = $this->stripslashesSafe($this->escapeString($_REQUEST['s65'])); | ||
| 1326 : | // watermarking vars (s66, s67 and 68) | ||
| 1327 : | $s66 = $this->stripslashesSafe($this->escapeString($_REQUEST['s66'])); | ||
| 1328 : | $s67 = $this->stripslashesSafe($this->escapeString($_REQUEST['s67'])); | ||
| 1329 : | $s68 = $this->stripslashesSafe($this->escapeString($_REQUEST['s68'])); | ||
| 1330 : | // variables s69 till s71 were in use by the zOOm Module. Deprecated. | ||
| 1331 : | // variable s72 = toptenOn (for Top Ten link on main page) | ||
| 1332 : | $s72 = $this->stripslashesSafe($this->escapeString($_REQUEST['s72'])); | ||
| 1333 : | // variable s73 = lastsubmOn (for Last Submition link on main page) | ||
| 1334 : | $s73 = $this->stripslashesSafe($this->escapeString($_REQUEST['s73'])); | ||
| 1335 : | // variable s74 = close (for close button in view.php) | ||
| 1336 : | $s74 = $this->stripslashesSafe($this->escapeString($_REQUEST['s74'])); | ||
| 1337 : | // variable s73 = mainscreen (for mainscreen link) | ||
| 1338 : | $s75 = $this->stripslashesSafe($this->escapeString($_REQUEST['s75'])); | ||
| 1339 : | // variable s76 = navbuttons (for buttons at the top on view.php) | ||
| 1340 : | $s76 = $this->stripslashesSafe($this->escapeString($_REQUEST['s76'])); | ||
| 1341 : | // variable s77 = property | ||
| 1342 : | $s77 = $this->stripslashesSafe($this->escapeString($_REQUEST['s77'])); | ||
| 1343 : | $s78 = $this->stripslashesSafe($this->escapeString($_REQUEST['s78'])); | ||
| 1344 : | $s79 = $this->stripslashesSafe($this->escapeString($_REQUEST['s79'])); | ||
| 1345 : | $s80 = $this->stripslashesSafe($this->escapeString($_REQUEST['s80'])); | ||
| 1346 : | $s81 = $this->stripslashesSafe($this->escapeString($_REQUEST['s81'])); | ||
| 1347 : | $s82 = intval($this->getParam($_REQUEST, 's82', 0)); | ||
| 1348 : | $s83 = intval($this->getParam($_REQUEST, 's83', 0)); | ||
| 1349 : | $s84 = intval($this->getParam($_REQUEST, 's84', 0)); | ||
| 1350 : | $s85 = intval($this->getParam($_REQUEST, 's85', 1)); | ||
| 1351 : | $s86 = intval($this->getParam($_REQUEST, 's86', 0)); | ||
| 1352 : | $s87 = intval($this->getParam($_REQUEST, 's87', 0)); | ||
| 1353 : | if(!isset($s29) || empty($s29)) { | ||
| 1354 : | $s29 = 0; | ||
| 1355 : | } | ||
| 1356 : | // the representation and meaning of each s-variable explains itself | ||
| 1357 : | // in the following statement: | ||
| 1358 : | $cfg_content = "<?php\n"; | ||
| 1359 : | $cfg_content .= "defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );\n"; | ||
| 1360 : | $cfg_content .= "\$zoomConfig['conversiontype'] = \"{$s01}\";\n"; | ||
| 1361 : | $cfg_content .= "\$zoomConfig['zoom_title'] = \"{$s28}\";\n"; | ||
| 1362 : | $cfg_content .= "\$zoomConfig['imagepath'] = \"{$s02}\";\n"; | ||
| 1363 : | $cfg_content .= "\$zoomConfig['IM_path'] = \"{$s03}\";\n"; | ||
| 1364 : | $cfg_content .= "\$zoomConfig['NETPBM_path'] = \"{$s04}\";\n"; | ||
| 1365 : | $cfg_content .= "\$zoomConfig['FFMPEG_path'] = \"{$s36}\";\n"; | ||
| 1366 : | $cfg_content .= "\$zoomConfig['PDF_path'] = \"{$s45}\";\n"; | ||
| 1367 : | $cfg_content .= "\$zoomConfig['override_FFMPEG'] = \"{$s82}\";\n"; | ||
| 1368 : | $cfg_content .= "\$zoomConfig['override_PDF'] = \"{$s83}\";\n"; | ||
| 1369 : | $cfg_content .= "\$zoomConfig['JPEGquality'] = \"{$s05}\";\n"; | ||
| 1370 : | $cfg_content .= "\$zoomConfig['maxsize'] = \"{$s26}\";\n"; | ||
| 1371 : | $cfg_content .= "\$zoomConfig['maxsizekb'] = \"{$s84}\";\n"; | ||
| 1372 : | $cfg_content .= "\$zoomConfig['size'] = \"{$s06}\";\n"; | ||
| 1373 : | $cfg_content .= "\$zoomConfig['columnsno'] = \"{$s07}\";\n"; | ||
| 1374 : | $cfg_content .= "\$zoomConfig['PageSize'] = \"{$s08}\";\n"; | ||
| 1375 : | $cfg_content .= "\$zoomConfig['orderMethod'] = \"{$s24}\";\n"; | ||
| 1376 : | $cfg_content .= "\$zoomConfig['catOrderMethod'] = \"{$s51}\";\n"; | ||
| 1377 : | $cfg_content .= "\$zoomConfig['viewtype'] = \"{$s85}\";\n"; | ||
| 1378 : | $cfg_content .= "\$zoomConfig['hotlinkProtection'] = \"{$s86}\";\n"; | ||
| 1379 : | $cfg_content .= "\$zoomConfig['commentsOn'] = \"{$s09}\";\n"; | ||
| 1380 : | $cfg_content .= "\$zoomConfig['cmtLength'] = \"{$s44}\";\n"; | ||
| 1381 : | $cfg_content .= "\$zoomConfig['anonymous_comments'] = \"{$s80}\";\n"; | ||
| 1382 : | $cfg_content .= "\$zoomConfig['galleryPrefix'] = \"{$s50}\";\n"; | ||
| 1383 : | $cfg_content .= "\$zoomConfig['showoccspace'] = \"{$s79}\";\n"; | ||
| 1384 : | $cfg_content .= "\$zoomConfig['dragdrop'] = \"{$s81}\";\n"; | ||
| 1385 : | $cfg_content .= "\$zoomConfig['ratingOn'] = \"{$s17}\";\n"; | ||
| 1386 : | $cfg_content .= "\$zoomConfig['toptenOn'] = \"{$s72}\";\n"; | ||
| 1387 : | $cfg_content .= "\$zoomConfig['lastsubmOn'] = \"{$s73}\";\n"; | ||
| 1388 : | $cfg_content .= "\$zoomConfig['close'] = \"{$s74}\";\n"; | ||
| 1389 : | $cfg_content .= "\$zoomConfig['mainscreen'] = \"{$s75}\";\n"; | ||
| 1390 : | $cfg_content .= "\$zoomConfig['navbuttons'] = \"{$s76}\";\n"; | ||
| 1391 : | $cfg_content .= "\$zoomConfig['properties'] = \"{$s77}\";\n"; | ||
| 1392 : | $cfg_content .= "\$zoomConfig['mediafound'] = \"{$s78}\";\n"; | ||
| 1393 : | $cfg_content .= "\$zoomConfig['zoomOn'] = \"{$s19}\";\n"; | ||
| 1394 : | $cfg_content .= "\$zoomConfig['popUpImages'] = \"{$s10}\";\n"; | ||
| 1395 : | $cfg_content .= "\$zoomConfig['catImg'] = \"{$s11}\";\n"; | ||
| 1396 : | $cfg_content .= "\$zoomConfig['slideshow'] = \"{$s12}\";\n"; | ||
| 1397 : | $cfg_content .= "\$zoomConfig['displaylogo'] = \"{$s13}\";\n"; | ||
| 1398 : | $cfg_content .= "\$zoomConfig['descrInGal'] = \"{$s86}\";\n"; | ||
| 1399 : | $cfg_content .= "\$zoomConfig['readEXIF'] = \"{$s14}\";\n"; | ||
| 1400 : | $cfg_content .= "\$zoomConfig['readID3'] = \"{$s58}\";\n"; | ||
| 1401 : | $cfg_content .= "\$zoomConfig['tempDescr'] = \"{$s16}\";\n"; | ||
| 1402 : | $cfg_content .= "\$zoomConfig['tempName'] = \"{$s20}\";\n"; | ||
| 1403 : | $cfg_content .= "\$zoomConfig['autonumber'] = \"{$s21}\";\n"; | ||
| 1404 : | $cfg_content .= "\$zoomConfig['showHits'] = \"{$s22}\";\n"; | ||
| 1405 : | $cfg_content .= "\$zoomConfig['showName'] = \"{$s38}\";\n"; | ||
| 1406 : | $cfg_content .= "\$zoomConfig['showDescr'] = \"{$s39}\";\n"; | ||
| 1407 : | $cfg_content .= "\$zoomConfig['showKeywords'] = \"{$s40}\";\n"; | ||
| 1408 : | $cfg_content .= "\$zoomConfig['showDate'] = \"{$s41}\";\n"; | ||
| 1409 : | $cfg_content .= "\$zoomConfig['showUsername'] = \"{$s59}\";\n"; | ||
| 1410 : | $cfg_content .= "\$zoomConfig['showFilename'] = \"{$s42}\";\n"; | ||
| 1411 : | $cfg_content .= "\$zoomConfig['showSearch'] = \"{$s37}\";\n"; | ||
| 1412 : | $cfg_content .= "\$zoomConfig['showMetaBox'] = \"{$s43}\";\n"; | ||
| 1413 : | $cfg_content .= "\$zoomConfig['animate_box'] = \"{$s65}\";\n"; | ||
| 1414 : | $cfg_content .= "\$zoomConfig['properties_state'] = \"{$s60}\";\n"; | ||
| 1415 : | $cfg_content .= "\$zoomConfig['meta_state'] = \"{$s61}\";\n"; | ||
| 1416 : | $cfg_content .= "\$zoomConfig['comments_state'] = \"{$s62}\";\n"; | ||
| 1417 : | $cfg_content .= "\$zoomConfig['catcolsno'] = \"{$s23}\";\n"; | ||
| 1418 : | $cfg_content .= "\$zoomConfig['utype'] = \"{$s27}\";\n"; | ||
| 1419 : | $cfg_content .= "\$zoomConfig['lightbox'] = \"{$s25}\";\n"; | ||
| 1420 : | $cfg_content .= "\$zoomConfig['ecards'] = \"{$s34}\";\n"; | ||
| 1421 : | $cfg_content .= "\$zoomConfig['ecards_lifetime'] = \"{$s35}\";\n"; | ||
| 1422 : | $cfg_content .= "\$zoomConfig['wm_apply'] = \"{$s66}\";\n"; | ||
| 1423 : | $cfg_content .= "\$zoomConfig['wm_file'] = \"{$s67}\";\n"; | ||
| 1424 : | $cfg_content .= "\$zoomConfig['wm_position'] = \"{$s68}\";\n"; | ||
| 1425 : | $cfg_content .= "\$zoomConfig['safemodeON'] = \"{$s46}\";\n"; | ||
| 1426 : | if ($this->_CONFIG['secret'] == "zoom") { | ||
| 1427 : | $this->_CONFIG['secret'] = $this->makePassword(16); | ||
| 1428 : | } | ||
| 1429 : | $cfg_content .= "\$zoomConfig['secret'] = \"{$this->_CONFIG['secret']}\";\n"; | ||
| 1430 : | $cfg_content .= "\$zoomConfig['version'] = \"{$this->_CONFIG['version']}\";\n"; | ||
| 1431 : | $cfg_content .= "\$zoomConfig['safemodeversion'] = \"{$this->_CONFIG['safemodeversion']}\";\n"; | ||
| 1432 : | $cfg_content .= "?>"; | ||
| 1433 : | $cfg_file = $mosConfig_absolute_path.'/components/com_zoom/etc/zoom_config.php'; | ||
| 1434 : | @$this->platform->chmod($cfg_file, '0766'); | ||
| 1435 : | $permission = is_writable($cfg_file); | ||
| 1436 : | if (!$permission) { | ||
| 1437 : | echo "Error: zOOm Configuration file ".$cfg_file." is not writable!"; | ||
| 1438 : | exit(); | ||
| 1439 : | } | ||
| 1440 : | $this->writefile($cfg_file, $cfg_content); | ||
| 1441 : | // now save the usermenu-item link, if the s33 was checked or delete it otherwise... | ||
| 1442 : | if ($s33 == 1 && !$this->issetUserMenu()) { | ||
| 1443 : | // all ok, insert menu-option... | ||
| 1444 : | $database->setQuery("INSERT INTO #__menu (`id`,`menutype`,`name`,`link`,`type`,`published`,`parent`,`componentid`,`sublevel`,`ordering`,`checked_out`,`checked_out_time`,`pollid`,`browserNav`,`access`,`utaccess`,`params`) VALUES ('','usermenu','Upload Media','index.php?option=com_zoom&page=admin','url','1','0','0','0','0','0','0000-00-00 00:00:00','0','0','1','2','')"); | ||
| 1445 : | $database->query(); | ||
| 1446 : | } elseif($s33 == 0 && $theId = $this->issetUserMenu()) { | ||
| 1447 : | $database->setQuery("DELETE FROM #__menu WHERE id = ".$theId); | ||
| 1448 : | $database->query(); | ||
| 1449 : | } | ||
| 1450 : | // save the privileges config into the mos_zoom_priv table... | ||
| 1451 : | $gtree = $acl->get_group_children_tree( null, 'USERS', false ); | ||
| 1452 : | foreach ($gtree as $group) { | ||
| 1453 : | if ($group->value != 29 && $group->value != 30) { | ||
| 1454 : | $privileges = new privileges($database, $group->value); | ||
| 1455 : | foreach ($privileges->getPrivileges() as $privilege => $value) { | ||
| 1456 : | $privileges->setPrivilege($privilege, $_REQUEST[$privilege.'_'.$group->value]); | ||
| 1457 : | } | ||
| 1458 : | if (!$privileges->savePrivileges()) { | ||
| 1459 : | return false; | ||
| 1460 : | } | ||
| 1461 : | } | ||
| 1462 : | } | ||
| 1463 : | return true; | ||
| 1464 : | } | ||
| 1465 : | /** | ||
| 1466 : | * @return string | ||
| 1467 : | * @param int $length | ||
| 1468 : | * @desc Generate a random set of characters, with a specific length $length | ||
| 1469 : | * @access public | ||
| 1470 : | */ | ||
| 1471 : | function makePassword($length) { | ||
| 1472 : | $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | ||
| 1473 : | $len = strlen($salt); | ||
| 1474 : | $makepass=""; | ||
| 1475 : | mt_srand(10000000*(double)microtime()); | ||
| 1476 : | for ($i = 0; $i < $length; $i++) | ||
| 1477 : | $makepass .= $salt[mt_rand(0,$len - 1)]; | ||
| 1478 : | return $makepass; | ||
| 1479 : | } | ||
| 1480 : | /** | ||
| 1481 : | * @return void | ||
| 1482 : | * @desc Standard optimization of the zOOm tables to remove unneeded overhead. | ||
| 1483 : | * @access public | ||
| 1484 : | */ | ||
| 1485 : | function optimizeTables() { | ||
| 1486 : | global $database; | ||
| 1487 : | $database->setQuery("SELECT * FROM #__zoom"); | ||
| 1488 : | $result = $database->query(); | ||
| 1489 : | $count = mysql_num_rows($result); | ||
| 1490 : | $id = array(); | ||
| 1491 : | $names = array(); | ||
| 1492 : | $descr = array(); | ||
| 1493 : | $keys = array(); | ||
| 1494 : | while($rows=mysql_fetch_array($result)){ | ||
| 1495 : | $id[] = $rows['catid']; | ||
| 1496 : | |||
| 1497 : | $str = $rows['catname']; | ||
| 1498 : | $names[] = htmlspecialchars($this->revnumericentities($str), ENT_QUOTES); | ||
| 1499 : | |||
| 1500 : | $descr[] = $rows['catdescr']; | ||
| 1501 : | |||
| 1502 : | $str = $rows['catkeywords']; | ||
| 1503 : | $keys[] = htmlspecialchars($this->revnumericentities($str), ENT_QUOTES); | ||
| 1504 : | } | ||
| 1505 : | |||
| 1506 : | for($i=0;$i<$count;$i++){ | ||
| 1507 : | $upgrade = "UPDATE `#__zoom` SET catname='$names[$i]', catdescr='$descr[$i]', catkeywords='$keys[$i]' WHERE catid='$id[$i]'"; | ||
| 1508 : | $database->setQuery($upgrade); | ||
| 1509 : | $database->query(); | ||
| 1510 : | } | ||
| 1511 : | $database->setQuery("OPTIMIZE TABLE `#__zoom`"); | ||
| 1512 : | $database->query(); | ||
| 1513 : | $database->setQuery("OPTIMIZE TABLE `#__zoomfiles`"); | ||
| 1514 : | $database->query(); | ||
| 1515 : | $database->setQuery("OPTIMIZE TABLE `#__zoom_comments`"); | ||
| 1516 : | $database->query(); | ||
| 1517 : | $database->setQuery("OPTIMIZE TABLE `#__zoom_editmon`"); | ||
| 1518 : | $database->query(); | ||
| 1519 : | $database->setQuery("OPTIMIZE TABLE `#__zoom_priv`"); | ||
| 1520 : | $database->query(); | ||
| 1521 : | } | ||
| 1522 : | /** | ||
| 1523 : | * @return void | ||
| 1524 : | * @desc Delete ALL zOOm related tables from the database and rebuild them from scratch | ||
| 1525 : | * @access public | ||
| 1526 : | */ | ||
| 1527 : | function wipeZoom() { | ||
| 1528 : | global $database, $mosConfig_absolute_path; | ||
| 1529 : | $query1 = "DROP TABLE #__zoom"; | ||
| 1530 : | $query2 = "CREATE TABLE #__zoom (" | ||
| 1531 : | . "\n catid int(11) NOT NULL auto_increment," | ||
| 1532 : | . "\n catname varchar(50) default '0'," | ||
| 1533 : | . "\n catdescr mediumtext default NULL," | ||
| 1534 : | . "\n catdir varchar(50) default '0'," | ||
| 1535 : | . "\n catimg int(11) default '0'," | ||
| 1536 : | . "\n catpassword varchar(100) NOT NULL default ''," | ||
| 1537 : | . "\n catkeywords varchar(240) NOT NULL default ''," | ||
| 1538 : | . "\n subcat_id int(11) NOT NULL default '0'," | ||
| 1539 : | . "\n pos int(3) NOT NULL default '0'," | ||
| 1540 : | . "\n hideMsg tinyint(1) NOT NULL default '0'," | ||
| 1541 : | . "\n shared tinyint(1) NOT NULL default '0'," | ||
| 1542 : | . "\n published tinyint(1) NOT NULL default '1'," | ||
| 1543 : | . "\n uid int(11) NOT NULL default '0'," | ||
| 1544 : | . "\n catmembers varchar(240) NOT NULL default ''," | ||
| 1545 : | . "\n custom_order int(20) default NULL," | ||
| 1546 : | . "\n PRIMARY KEY (catid)," | ||
| 1547 : | . "\n KEY catdir_search (catdir)," | ||
| 1548 : | . "\n KEY rel_subcats (subcat_id)" | ||
| 1549 : | . "\n ) TYPE=MyISAM"; | ||
| 1550 : | $database->setQuery($query1); | ||
| 1551 : | $database->query(); | ||
| 1552 : | $database->setQuery($query2); | ||
| 1553 : | $database->query(); | ||
| 1554 : | |||
| 1555 : | //Add tables if first time install | ||
| 1556 : | $query3 = "DROP TABLE #__zoom_comments"; | ||
| 1557 : | $query4 = "CREATE TABLE #__zoom_comments (" | ||
| 1558 : | . "\n cmtid int(11) NOT NULL auto_increment," | ||
| 1559 : | . "\n imgid int(11) NOT NULL default '0'," | ||
| 1560 : | . "\n cmtname varchar(40) NOT NULL default ''," | ||
| 1561 : | . "\n cmtcontent text NOT NULL," | ||
| 1562 : | . "\n cmtdate timestamp(14) NOT NULL," | ||
| 1563 : | . "\n PRIMARY KEY (cmtid)," | ||
| 1564 : | . "\n KEY imgid (imgid)" | ||
| 1565 : | . "\n ) TYPE=MyISAM"; | ||
| 1566 : | $database->setQuery($query3); | ||
| 1567 : | $database->query(); | ||
| 1568 : | $database->setQuery($query4); | ||
| 1569 : | $database->query(); | ||
| 1570 : | |||
| 1571 : | $query5 = "DROP TABLE #__zoom_ecards"; | ||
| 1572 : | $query6 = "CREATE TABLE #__zoom_ecards (" | ||
| 1573 : | . "\n ecdid varchar(25) NOT NULL default ''," | ||
| 1574 : | . "\n imgid int(11) NOT NULL default '0'," | ||
| 1575 : | . "\n to_name varchar(50) NOT NULL default ''," | ||
| 1576 : | . "\n from_name varchar(50) NOT NULL default ''," | ||
| 1577 : | . "\n to_email varchar(75) NOT NULL default ''," | ||
| 1578 : | . "\n from_email varchar(75) NOT NULL default ''," | ||
| 1579 : | . "\n message text NOT NULL," | ||
| 1580 : | . "\n end_date date NOT NULL default '0000-00-00'," | ||
| 1581 : | . "\n user_ip varchar(25) NOT NULL default ''," | ||
| 1582 : | . "\n PRIMARY KEY (ecdid)," | ||
| 1583 : | . "\n KEY ecard_img (imgid)" | ||
| 1584 : | . "\n ) TYPE=MyISAM"; | ||
| 1585 : | $database->setQuery($query5); | ||
| 1586 : | $database->query(); | ||
| 1587 : | $database->setQuery($query6); | ||
| 1588 : | $database->query(); | ||
| 1589 : | |||
| 1590 : | $query7 = "DROP TABLE #__zoom_editmon"; | ||
| 1591 : | $query8 = "CREATE TABLE #__zoom_editmon (" | ||
| 1592 : | . "\n edtid int(11) NOT NULL auto_increment," | ||
| 1593 : | . "\n user_session varchar(200) NOT NULL default '0'," | ||
| 1594 : | . "\n vote_time varchar(14) default NULL," | ||
| 1595 : | . "\n comment_time varchar(14) default NULL," | ||
| 1596 : | . "\n pass_time varchar(14) default NULL," | ||
| 1597 : | . "\n lightbox_time varchar(14) default NULL," | ||
| 1598 : | . "\n lightbox_file varchar(40) default NULL," | ||
| 1599 : | . "\n object_id int(11) NOT NULL default '0'," | ||
| 1600 : | . "\n PRIMARY KEY (edtid)," | ||
| 1601 : | . "\n KEY edit_session (user_session)," | ||
| 1602 : | . "\n KEY object (object_id)" | ||
| 1603 : | . "\n ) TYPE=MyISAM"; | ||
| 1604 : | $database->setQuery($query7); | ||
| 1605 : | $database->query(); | ||
| 1606 : | $database->setQuery($query8); | ||
| 1607 : | $database->query(); | ||
| 1608 : | |||
| 1609 : | $query9 = "DROP TABLE #__zoom_getid3_cache"; | ||
| 1610 : | $query10 = "CREATE TABLE #__zoom_getid3_cache (" | ||
| 1611 : | . "\n filename varchar(255) NOT NULL DEFAULT ''," | ||
| 1612 : | . "\n filesize INT(11) NOT NULL DEFAULT '0'," | ||
| 1613 : | . "\n filetime INT(11) NOT NULL DEFAULT '0'," | ||
| 1614 : | . "\n analyzetime INT(11) NOT NULL DEFAULT '0'," | ||
| 1615 : | . "\n value TEXT NOT NULL," | ||
| 1616 : | . "\n PRIMARY KEY (filename, filesize, filetime)" | ||
| 1617 : | . "\n ) TYPE=MyISAM"; | ||
| 1618 : | $database->setQuery($query9); | ||
| 1619 : | $database->query(); | ||
| 1620 : | $database->setQuery($query10); | ||
| 1621 : | $database->query(); | ||
| 1622 : | |||
| 1623 : | $query11 = "DROP TABLE #__zoomfiles"; | ||
| 1624 : | $query12 = "CREATE TABLE #__zoomfiles (" | ||
| 1625 : | . "\n imgid int(11) NOT NULL auto_increment," | ||
| 1626 : | . "\n imgname varchar(255) NOT NULL default ''," | ||
| 1627 : | . "\n imgfilename varchar(255) NOT NULL default ''," | ||
| 1628 : | . "\n imgdescr mediumtext default NULL," | ||
| 1629 : | . "\n imgkeywords varchar(255) default NULL," | ||
| 1630 : | . "\n imgdate datetime NOT NULL default '0000-00-00 00:00:00'," | ||
| 1631 : | . "\n imghits bigint(20) NOT NULL default '0'," | ||
| 1632 : | . "\n votenum int(11) NOT NULL default '0'," | ||
| 1633 : | . "\n votesum int(11) NOT NULL default '0'," | ||
| 1634 : | . "\n published tinyint(1) NOT NULL default '1'," | ||
| 1635 : | . "\n catid int(11) NOT NULL default '0'," | ||
| 1636 : | . "\n uid int(11) NOT NULL default '0'," | ||
| 1637 : | . "\n imgmembers varchar(240) NOT NULL default ''," | ||
| 1638 : | . "\n PRIMARY KEY (imgid)," | ||
| 1639 : | . "\n KEY img_catid (catid)," | ||
| 1640 : | . "\n KEY img_user (uid)" | ||
| 1641 : | . "\n ) TYPE=MyISAM"; | ||
| 1642 : | $database->setQuery($query11); | ||
| 1643 : | $database->query(); | ||
| 1644 : | $database->setQuery($query12); | ||
| 1645 : | $database->query(); | ||
| 1646 : | |||
| 1647 : | |||
| 1648 : | $query13 = "DROP TABLE #__zoom_priv"; | ||
| 1649 : | $query14 = "CREATE TABLE #__zoom_priv (" | ||
| 1650 : | . "\n gid int(11) NOT NULL default '0'," | ||
| 1651 : | . "\n priv_upload enum('0','1') NOT NULL default '1'," | ||
| 1652 : | . "\n priv_editmedium enum('0','1') NOT NULL default '1'," | ||
| 1653 : | . "\n priv_delmedium enum('0','1') NOT NULL default '1'," | ||
| 1654 : | . "\n priv_creategal enum('0','1') NOT NULL default '1'," | ||
| 1655 : | . "\n priv_editgal enum('0','1') NOT NULL default '1'," | ||
| 1656 : | . "\n priv_delgal enum('0','1') NOT NULL default '1'," | ||
| 1657 : | . "\n PRIMARY KEY (gid)" | ||
| 1658 : | . "\n ) TYPE=MyISAM"; | ||
| 1659 : | $query15 = "INSERT INTO #__zoom_priv VALUES (18, '0', '0', '0', '0', '0', '0')"; | ||
| 1660 : | $query16 = "INSERT INTO #__zoom_priv VALUES (19, '0', '0', '0', '0', '0', '0')"; | ||
| 1661 : | $query17 = "INSERT INTO #__zoom_priv VALUES (20, '0', '0', '0', '0', '0', '0')"; | ||
| 1662 : | $query18 = "INSERT INTO #__zoom_priv VALUES (21, '0', '0', '0', '0', '0', '0')"; | ||
| 1663 : | $query19 = "INSERT INTO #__zoom_priv VALUES (23, '0', '0', '0', '0', '0', '0')"; | ||
| 1664 : | $query20 = "INSERT INTO #__zoom_priv VALUES (24, '1', '1', '1', '1', '1', '1')"; | ||
| 1665 : | $query21 = "INSERT INTO #__zoom_priv VALUES (25, '1', '1', '1', '1', '1', '1')"; | ||
| 1666 : | $database->setQuery($query13); | ||
| 1667 : | $database->query(); | ||
| 1668 : | $database->setQuery($query14); | ||
| 1669 : | $database->query(); | ||
| 1670 : | $database->setQuery($query15); | ||
| 1671 : | $database->query(); | ||
| 1672 : | $database->setQuery($query16); | ||
| 1673 : | $database->query(); | ||
| 1674 : | $database->setQuery($query17); | ||
| 1675 : | $database->query(); | ||
| 1676 : | $database->setQuery($query18); | ||
| 1677 : | $database->query(); | ||
| 1678 : | $database->setQuery($query19); | ||
| 1679 : | $database->query(); | ||
| 1680 : | $database->setQuery($query20); | ||
| 1681 : | $database->query(); | ||
| 1682 : | $database->setQuery($query21); | ||
| 1683 : | $database->query(); | ||
| 1684 : | } | ||
| 1685 : | /** | ||
| 1686 : | * @return boolean | ||
| 1687 : | * @param string $dirname | ||
| 1688 : | * @desc Remove a directory on any filesystem COMPLETELY (including content) | ||
| 1689 : | * @access public | ||
| 1690 : | */ | ||
| 1691 : | function delete_directory($dirname) { | ||
| 1692 : | if ($this->_CONFIG['safemodeON']) { | ||
| 1693 : | $this->ftp_rmAll($dirname); | ||
| 1694 : | } else { | ||
| 1695 : | if (is_dir($dirname)) { | ||
| 1696 : | $dir_handle = opendir($dirname); | ||
| 1697 : | } | ||
| 1698 : | if (!$dir_handle) { | ||
| 1699 : | return false; | ||
| 1700 : | } | ||
| 1701 : | while($file = readdir($dir_handle)) { | ||
| 1702 : | if ($file != "." && $file != "..") { | ||
| 1703 : | if (!is_dir($dirname."/".$file)) { | ||
| 1704 : | unlink($dirname."/".$file); | ||
| 1705 : | } else { | ||
| 1706 : | $this->delete_directory($dirname.'/'.$file); | ||
| 1707 : | } | ||
| 1708 : | } | ||
| 1709 : | } | ||
| 1710 : | closedir($dir_handle); | ||
| 1711 : | rmdir($dirname); | ||
| 1712 : | return true; | ||
| 1713 : | } | ||
| 1714 : | } | ||
| 1715 : | //--------------------END Database Editing Functions-------------------// | ||
| 1716 : | //--------------------Database Querying Functions----------------------// | ||
| 1717 : | /** | ||
| 1718 : | * @return array | ||
| 1719 : | * @desc gentle solution to avoid the use of the pompous smilies-table. From the authors of phpBB... | ||
| 1720 : | * @access private | ||
| 1721 : | */ | ||
| 1722 : | function _getSmiliesTable() { | ||
| 1723 : | return array( | ||
| 1724 : | array(':!:', 'icon_exclaim.gif', 'Exclamation'), | ||
| 1725 : | array(':?:', 'icon_question.gif', 'Question'), | ||
| 1726 : | array(':D', 'icon_biggrin.gif', 'Very Happy'), | ||
| 1727 : | array(':d', 'icon_biggrin.gif', 'Very Happy'), | ||
| 1728 : | array(':-D', 'icon_biggrin.gif', 'Very Happy'), | ||
| 1729 : | array(':grin:', 'icon_biggrin.gif', 'Very Happy'), | ||
| 1730 : | array(':)', 'icon_smile.gif', 'Smile'), | ||
| 1731 : | array(':-)', 'icon_smile.gif', 'Smile'), | ||
| 1732 : | array(':smile:', 'icon_smile.gif', 'Smile'), | ||
| 1733 : | array(':(', 'icon_sad.gif', 'Sad'), | ||
| 1734 : | array(':-(', 'icon_sad.gif', 'Sad'), | ||
| 1735 : | array(':sad:', 'icon_sad.gif', 'Sad'), | ||
| 1736 : | array(':o', 'icon_surprised.gif', 'Surprised'), | ||
| 1737 : | array(':-o', 'icon_surprised.gif', 'Surprised'), | ||
| 1738 : | array(':eek:', 'icon_surprised.gif', 'Surprised'), | ||
| 1739 : | array(':shock:', 'icon_eek.gif', 'Shocked'), | ||
| 1740 : | array(':?', 'icon_confused.gif', 'Confused'), | ||
| 1741 : | array(':-?', 'icon_confused.gif', 'Confused'), | ||
| 1742 : | array(':???:', 'icon_confused.gif', 'Confused'), | ||
| 1743 : | array('8)', 'icon_cool.gif', 'Cool'), | ||
| 1744 : | array('8-)', 'icon_cool.gif', 'Cool'), | ||
| 1745 : | array(':cool:', 'icon_cool.gif', 'Cool'), | ||
| 1746 : | array(':lol:', 'icon_lol.gif', 'Laughing'), | ||
| 1747 : | array(':x', 'icon_mad.gif', 'Mad'), | ||
| 1748 : | array(':-x', 'icon_mad.gif', 'Mad'), | ||
| 1749 : | array(':mad:', 'icon_mad.gif', 'Mad'), | ||
| 1750 : | array(':P', 'icon_razz.gif', 'Razz'), | ||
| 1751 : | array(':p', 'icon_razz.gif', 'Razz'), | ||
| 1752 : | array(':-P', 'icon_razz.gif', 'Razz'), | ||
| 1753 : | array(':razz:', 'icon_razz.gif', 'Razz'), | ||
| 1754 : | array(':oops:', 'icon_redface.gif', 'Embarassed'), | ||
| 1755 : | array(':cry:', 'icon_cry.gif', 'Crying or Very sad'), | ||
| 1756 : | array(':evil:', 'icon_evil.gif', 'Evil or Very Mad'), | ||
| 1757 : | array(':twisted:', 'icon_twisted.gif', 'Twisted Evil'), | ||
| 1758 : | array(':roll:', 'icon_rolleyes.gif', 'Rolling Eyes'), | ||
| 1759 : | array(':wink:', 'icon_wink.gif', 'Wink'), | ||
| 1760 : | array(';)', 'icon_wink.gif', 'Wink'), | ||
| 1761 : | array(';-)', 'icon_wink.gif', 'Wink'), | ||
| 1762 : | array(':idea:', 'icon_idea.gif', 'Idea'), | ||
| 1763 : | array(':arrow:', 'icon_arrow.gif', 'Arrow'), | ||
| 1764 : | array(':|', 'icon_neutral.gif', 'Neutral'), | ||
| 1765 : | array(':-|', 'icon_neutral.gif', 'Neutral'), | ||
| 1766 : | array(':neutral:', 'icon_neutral.gif', 'Neutral'), | ||
| 1767 : | array(':mrgreen:', 'icon_mrgreen.gif', 'Mr. Green') | ||
| 1768 : | ); | ||
| 1769 : | } | ||
| 1770 : | /** | ||
| 1771 : | * @return void | ||
| 1772 : | * @param int $parent | ||
| 1773 : | * @param string $ident | ||
| 1774 : | * @param string $ident2 | ||
| 1775 : | * @desc Create a list of all galleries. | ||
| 1776 : | * @access private | ||
| 1777 : | */ | ||
| 1778 : | function _getCatList($parent, $ident='', $ident2='') { | ||
| 1779 : | global $database; | ||
| 1780 : | // The author of Coppermine Gallery inspired me for this piece of code. | ||
| 1781 : | // Main trick is the use of recursion. For every sub-category (or each level, | ||
| 1782 : | // or each value of pos) the entire method is called again. And so on...and so on... | ||
| 1783 : | $orderMethod = $this->getCatOrderMethod(); | ||
| 1784 : | $database->setQuery("SELECT catid, catname, pos, published, shared, uid FROM #__zoom WHERE subcat_id=$parent ORDER BY pos, $orderMethod"); | ||
| 1785 : | $this->_result = $database->query(); | ||
| 1786 : | $rowset = Array(); | ||
| 1787 : | while ($row = mysql_fetch_array($this->_result)) { | ||
| 1788 : | $rowset[] = $row; | ||
| 1789 : | } | ||
| 1790 : | foreach ($rowset as $subcat) { | ||
| 1791 : | if (((($subcat['uid'] == $this->currUID) || ($subcat['shared'] == 1)) | ||
| 1792 : | && ($this->privileges->hasPrivilege('priv_creategal') | $this->privileges->hasPrivilege('priv_editgal') | $this->privileges->hasPrivilege('priv_delgal') | $this->privileges->hasPrivilege('priv_upload'))) | ||
| 1793 : | || $this->_isAdmin) { | ||
| 1794 : | $this->_CAT_LIST[] = array( | ||
| 1795 : | 'id' => $subcat['catid'], | ||
| 1796 : | 'catname' => $ident.$subcat['catname'], | ||
| 1797 : | 'pos' => $subcat['pos'], | ||
| 1798 : | 'published' => $subcat['published'], | ||
| 1799 : | 'shared' => $subcat['shared'], | ||
| 1800 : | 'uid' => $subcat['uid'], | ||
| 1801 : | 'virtpath' => $ident2.$subcat['catname']); | ||
| 1802 : | } | ||
| 1803 : | $this->_getCatList($subcat['catid'], $ident.'> ', $ident2.$subcat['catname'].'> '); | ||
| 1804 : | } | ||
| 1805 : | } | ||
| 1806 : | /** | ||
| 1807 : | * @return array | ||
| 1808 : | * @param int $parent | ||
| 1809 : | * @desc Create a list of all galleries, stored/ returned as a multi-dimensional array. | ||
| 1810 : | * @access public | ||
| 1811 : | */ | ||
| 1812 : | function getCatListMulti($parent = 0) { | ||
| 1813 : | global $database; | ||
| 1814 : | // The author of Coppermine Gallery inspired me for this piece of code. | ||
| 1815 : | // Main trick is the use of recursion. For every sub-category (or each level, | ||
| 1816 : | // or each value of pos) the entire method is called again. And so on...and so on... | ||
| 1817 : | $database->setQuery("SELECT catid, catname, catdescr, catkeywords, subcat_id, pos, published, shared, uid FROM #__zoom WHERE subcat_id=$parent ORDER BY pos, ".$this->getCatOrderMethod()); | ||
| 1818 : | $this->_result = $database->query(); | ||
| 1819 : | $rowset = array(); | ||
| 1820 : | while ($row = mysql_fetch_array($this->_result)) { | ||
| 1821 : | $rowset[] = $row; | ||
| 1822 : | } | ||
| 1823 : | $cats = array(); | ||
| 1824 : | foreach ($rowset as $subcat) { | ||
| 1825 : | if (((($subcat['uid'] == $this->currUID) || ($subcat['shared'] == 1)) | ||
| 1826 : | && ($this->privileges->hasPrivilege('priv_creategal') | $this->privileges->hasPrivilege('priv_editgal') | $this->privileges->hasPrivilege('priv_delgal') | $this->privileges->hasPrivilege('priv_upload'))) | ||
| 1827 : | || $this->_isAdmin) { | ||
| 1828 : | $cats[$subcat['catid']]['catname'] = $subcat['catname']; | ||
| 1829 : | $cats[$subcat['catid']]['catdescr'] = $subcat['catdescr']; | ||
| 1830 : | $cats[$subcat['catid']]['catkeywords'] = $subcat['catkeywords']; | ||
| 1831 : | $cats[$subcat['catid']]['subcat_id'] = $subcat['subcat_id']; | ||
| 1832 : | $cats[$subcat['catid']]['pos'] = $subcat['pos']; | ||
| 1833 : | $cats[$subcat['catid']]['published'] = $subcat['published']; | ||
| 1834 : | $cats[$subcat['catid']]['shared'] = $subcat['shared']; | ||
| 1835 : | $cats[$subcat['catid']]['uid'] = $subcat['uid']; | ||
| 1836 : | |||
| 1837 : | $cats[$subcat['catid']]['children'] = $this->getCatListMulti($subcat['catid']); | ||
| 1838 : | } | ||
| 1839 : | } | ||
| 1840 : | return $cats; | ||
| 1841 : | } | ||
| 1842 : | /** | ||
| 1843 : | * @return array | ||
| 1844 : | * @desc Create an array filled with ALL the keywords that can be found in the zOOm tables. | ||
| 1845 : | * @access private | ||
| 1846 : | */ | ||
| 1847 : | function _getKeywordsList() { | ||
| 1848 : | global $database; | ||
| 1849 : | $database->setQuery("SELECT cat.catkeywords, img.imgkeywords AS keywords " | ||
| 1850 : | . " FROM #__zoom as cat " | ||
| 1851 : | . "LEFT JOIN" | ||
| 1852 : | . " #__zoomfiles AS img " | ||
| 1853 : | . "ON cat.catid" | ||
| 1854 : | . " WHERE cat.published = 1 " | ||
| 1855 : | . " AND cat.catkeywords <> '' " | ||
| 1856 : | . " AND cat.catpassword = '' " | ||
| 1857 : | . " AND img.published = 1 " | ||
| 1858 : | . " AND img.imgkeywords <> ''"); | ||
| 1859 : | if ($this->_result = $database->query()) { | ||
| 1860 : | $keywords = array(); | ||
| 1861 : | $newkeys = array(); | ||
| 1862 : | $allkeys = array(); | ||
| 1863 : | // first, put the keywords from both columns into an array... | ||
| 1864 : | while($row = mysql_fetch_object($this->_result)) { | ||
| 1865 : | $allkeys[] = (!empty($row->keywords)) ? $row->keywords : ""; | ||
| 1866 : | } | ||
| 1867 : | // now, delete empty rows... | ||
| 1868 : | $this->_counter = 0; | ||
| 1869 : | foreach ($allkeys as $akey) { | ||
| 1870 : | if (!empty($akey)) { | ||
| 1871 : | $newkeys[] = $akey; | ||
| 1872 : | } | ||
| 1873 : | } | ||
| 1874 : | // then, get each individual keyword and put it into the array '$keywords' | ||
| 1875 : | foreach ($newkeys as $newkey) { | ||
| 1876 : | $temp = explode(",", $newkey); | ||
| 1877 : | if (is_array($temp)) { | ||
| 1878 : | foreach ($temp as $t) { | ||
| 1879 : | if (!empty($t)) { | ||
| 1880 : | $keywords[] = $t; | ||
| 1881 : | } | ||
| 1882 : | } | ||
| 1883 : | } | ||
| 1884 : | } | ||
| 1885 : | // remove duplicate keywords... | ||
| 1886 : | $keywords = array_unique($keywords); | ||
| 1887 : | sort($keywords); | ||
| 1888 : | } | ||
| 1889 : | return $keywords; | ||
| 1890 : | } | ||
| 1891 : | /** | ||
| 1892 : | * @return int | ||
| 1893 : | * @param string $option | ||
| 1894 : | * @desc Find the Itemid back. | ||
| 1895 : | * @access public | ||
| 1896 : | */ | ||
| 1897 : | function getItemid($option) { | ||
| 1898 : | global $database; | ||
| 1899 : | //$database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=".$this->escapeString($option)."' AND published = 1"); | ||
| 1900 : | $database->setQuery("SELECT id FROM #__components j WHERE j.option=\"com_zoom\" LIMIT 1"); // We need the ItemId, not a menu id | ||
| 1901 : | if ($this->_result = $database->query()) { | ||
| 1902 : | $row = mysql_fetch_object($this->_result); | ||
| 1903 : | return $row->id; | ||
| 1904 : | } else { | ||
| 1905 : | return null; | ||
| 1906 : | } | ||
| 1907 : | } | ||
| 1908 : | /** | ||
| 1909 : | * @return string | ||
| 1910 : | * @desc Return the method of ordering of media. | ||
| 1911 : | * @access public | ||
| 1912 : | */ | ||
| 1913 : | function getOrderMethod() { | ||
| 1914 : | switch ($this->_CONFIG['orderMethod']) { | ||
| 1915 : | case 1: | ||
| 1916 : | return "imgdate ASC"; | ||
| 1917 : | break; | ||
| 1918 : | case 2: | ||
| 1919 : | return "imgdate DESC"; | ||
| 1920 : | break; | ||
| 1921 : | case 3: | ||
| 1922 : | return "imgfilename ASC"; | ||
| 1923 : | break; | ||
| 1924 : | case 4: | ||
| 1925 : | return "imgfilename DESC"; | ||
| 1926 : | break; | ||
| 1927 : | case 5: | ||
| 1928 : | return "imgname ASC"; | ||
| 1929 : | break; | ||
| 1930 : | case 6: | ||
| 1931 : | return "imgname DESC"; | ||
| 1932 : | break; | ||
| 1933 : | } | ||
| 1934 : | } | ||
| 1935 : | /** | ||
| 1936 : | * @return string | ||
| 1937 : | * @desc Return the method of ordering of galleries. | ||
| 1938 : | * @access public | ||
| 1939 : | */ | ||
| 1940 : | function getCatOrderMethod() { | ||
| 1941 : | // manual gallery ordering will be added later on... | ||
| 1942 : | switch ($this->_CONFIG['catOrderMethod']) { | ||
| 1943 : | case 1: | ||
| 1944 : | return "custom_order, catid ASC"; | ||
| 1945 : | break; | ||
| 1946 : | case 2: | ||
| 1947 : | return "custom_order, catid DESC"; | ||
| 1948 : | break; | ||
| 1949 : | case 3: | ||
| 1950 : | return "custom_order, catname ASC"; | ||
| 1951 : | break; | ||
| 1952 : | case 4: | ||
| 1953 : | return "custom_order, catname DESC"; | ||
| 1954 : | break; | ||
| 1955 : | } | ||
| 1956 : | } | ||
| 1957 : | /** | ||
| 1958 : | * @return void | ||
| 1959 : | * @param int $gallery_id | ||
| 1960 : | * @param boolean $galleryview | ||
| 1961 : | * @desc Create a new gallery object with the given gallery id. | ||
| 1962 : | * @access public | ||
| 1963 : | */ | ||
| 1964 : | function setGallery($gallery_id, $galleryview = false) { | ||
| 1965 : | $this->_gallery = null; | ||
| 1966 : | $this->_gallery = new gallery($gallery_id, $galleryview); | ||
| 1967 : | } | ||
| 1968 : | /** | ||
| 1969 : | * @return void | ||
| 1970 : | * @param int $id | ||
| 1971 : | * @desc Create a new ecard object with the given ecard-id. | ||
| 1972 : | * @access public | ||
| 1973 : | */ | ||
| 1974 : | function setEcard($id = 0) { | ||
| 1975 : | $this->ecard = null; | ||
| 1976 : | $this->ecard = new ecard($id); | ||
| 1977 : | } | ||
| 1978 : | /** | ||
| 1979 : | * @return boolean | ||
| 1980 : | * @desc Check if the link 'Upload Media' already exists in the Mambo user-menu. | ||
| 1981 : | * @access public | ||
| 1982 : | */ | ||
| 1983 : | function issetUserMenu(){ | ||
| 1984 : | global $database; | ||
| 1985 : | $database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_zoom&page=admin' LIMIT 1"); | ||
| 1986 : | if ($this->_result = $database->query()) { | ||
| 1987 : | if (mysql_num_rows($this->_result) > 0) { | ||
| 1988 : | $row = mysql_fetch_object($this->_result); | ||
| 1989 : | return $row->id; | ||
| 1990 : | } else { | ||
| 1991 : | return false; | ||
| 1992 : | } | ||
| 1993 : | } | ||
| 1994 : | } | ||
| 1995 : | /** | ||
| 1996 : | * @return object | ||
| 1997 : | * @param int $userid | ||
| 1998 : | * @desc Get info of a user with a given user-id. | ||
| 1999 : | * @access public | ||
| 2000 : | */ | ||
| 2001 : | function getUserInfo($userid) { | ||
| 2002 : | global $database; | ||
| 2003 : | $database->setQuery("SELECT name, username, email, usertype, registerDate, lastvisitDate FROM #__users WHERE id=$userid LIMIT 1"); | ||
| 2004 : | if ($result = $database->query()) { | ||
| 2005 : | return mysql_fetch_object($result); | ||
| 2006 : | } else { | ||
| 2007 : | return false; | ||
| 2008 : | } | ||
| 2009 : | } | ||
| 2010 : | /** | ||
| 2011 : | * @return void | ||
| 2012 : | * @param string $checkThis | ||
| 2013 : | * @param string $checkWhat | ||
| 2014 : | * @desc Check if a filename OR gallery-directory already exists and if it does; do something about it! | ||
| 2015 : | * @access public | ||
| 2016 : | */ | ||
| 2017 : | function checkDuplicate($checkThis, $checkWhat = 'filename') { | ||
| 2018 : | global $database; | ||
| 2019 : | // There are two things this function can check for: | ||
| 2020 : | // - duplicate filenames | ||
| 2021 : | // - duplicate directories (of galleries) | ||
| 2022 : | if ($checkWhat === "directory") { | ||
| 2023 : | $database->setQuery("SELECT catid FROM #__zoom WHERE catdir = '$checkThis'"); | ||
| 2024 : | if($this->_result = $database->query()){ | ||
| 2025 : | if (mysql_num_rows($this->_result) > 0) { | ||
| 2026 : | $newname = $this->newdir(); | ||
| 2027 : | $this->checkDuplicate($newname, 'directory'); | ||
| 2028 : | } else { | ||
| 2029 : | $this->_tempname = $checkThis; | ||
| 2030 : | } | ||
| 2031 : | } else { | ||
| 2032 : | $this->_tempname = $checkThis; | ||
| 2033 : | } | ||
| 2034 : | } else { | ||
| 2035 : | $database->setQuery("SELECT imgid FROM #__zoomfiles WHERE imgfilename = '$checkThis' AND catid = '".$this->_gallery->_id."'"); | ||
| 2036 : | if ($this->_result = $database->query()) { | ||
| 2037 : | if (mysql_num_rows($this->_result) > 0) { | ||
| 2038 : | // filename exists already for this gallery, so change the filename and test again... | ||
| 2039 : | // the filename will be changed accordingly: | ||
| 2040 : | // if a filename exists, add the suffix _{number} incrementally, | ||
| 2041 : | // thus 'afile_1.jpg' will become 'afile_2.jpg' and so on... | ||
| 2042 : | $newname = preg_replace( "/^(.+?)(_?)(\d*)(\.[^.]+)?$/e", "'\$1_'.(\$3+1).'\$4'", $checkThis ); | ||
| 2043 : | $this->checkDuplicate($newname); | ||
| 2044 : | } else { | ||
| 2045 : | $this->_tempname = $checkThis; | ||
| 2046 : | } | ||
| 2047 : | } else { | ||
| 2048 : | $this->_tempname = $checkThis; | ||
| 2049 : | } | ||
| 2050 : | } | ||
| 2051 : | } | ||
| 2052 : | //--------------------END Database Querying Functions------------------// | ||
| 2053 : | //--------------------Ajax specific functions--------------------------// | ||
| 2054 : | /** | ||
| 2055 : | * @return string | ||
| 2056 : | * @param string $type | ||
| 2057 : | * @desc Create the start of a ZMG XML output | ||
| 2058 : | * @access public | ||
| 2059 : | */ | ||
| 2060 : | function startXML($action) { | ||
| 2061 : | $iso = explode('=', _ISO); | ||
| 2062 : | echo header("Content-type:text/xml; charset=".$iso[1]); | ||
| 2063 : | echo header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | ||
| 2064 : | //HTTP/1.1 | ||
| 2065 : | echo header("Cache-Control: no-store, no-cache, must-revalidate"); | ||
| 2066 : | echo header("Cache-Control: post-check=0, pre-check=0", false); | ||
| 2067 : | //HTTP/1.0 | ||
| 2068 : | echo header("Pragma: no-cache"); | ||
| 2069 : | $xml = "<?xml version=\"1.0\" encoding=\"".$iso[1]."\" ?>"; | ||
| 2070 : | if ($action != "catsmgr_getlist" && $action != "playlist") { | ||
| 2071 : | $xml .= ("<zoom action=\"".$action."\">"); | ||
| 2072 : | } | ||
| 2073 : | return $xml; | ||
| 2074 : | } | ||
| 2075 : | /** | ||
| 2076 : | * @return string | ||
| 2077 : | * @desc Create the end of a ZMG XML output | ||
| 2078 : | * @access public | ||
| 2079 : | */ | ||
| 2080 : | function finishXML($action) { | ||
| 2081 : | $xml = ""; | ||
| 2082 : | if ($action != "catsmgr_getlist") { | ||
| 2083 : | $xml = ("</zoom>"); | ||
| 2084 : | } | ||
| 2085 : | return $xml; | ||
| 2086 : | } | ||
| 2087 : | /** | ||
| 2088 : | * @return string | ||
| 2089 : | * @desc Transforms an array of galleries into a hierarchial set of xml statements. | ||
| 2090 : | * @param array $cats | ||
| 2091 : | * @param string $xml | ||
| 2092 : | * @access public | ||
| 2093 : | */ | ||
| 2094 : | function catsArrayToXML($cats, $xml = "") { | ||
| 2095 : | foreach ($cats as $catid => $data) { | ||
| 2096 : | $data['catname'] = str_replace("&", "&", $data['catname']); | ||
| 2097 : | $xml .= ("<item text=\"".utf8_decode($data['catname'])."\" id=\"".$catid."\" noDelete=\"true\" noRename=\"false\"" | ||
| 2098 : | . " published=\"".$data['published']."\" keywords=\"".$data['catkeywords']."\"" | ||
| 2099 : | . " shared=\"".$data['shared']."\" uid=\"".$data['uid']."\" subcat_id=\"".$data['subcat_id']."\""); | ||
| 2100 : | if (count($data['children']) > 0) { | ||
| 2101 : | $xml .= " hasChildren=\"true\">".$this->catsArrayToXML($data['children']); | ||
| 2102 : | } else { | ||
| 2103 : | $xml .= " hasChildren=\"false\">"; | ||
| 2104 : | } | ||
| 2105 : | $xml .= "</item>"; | ||
| 2106 : | } | ||
| 2107 : | return $xml; | ||
| 2108 : | } | ||
| 2109 : | /** | ||
| 2110 : | * @return string | ||
| 2111 : | * @desc Provide a standardized way for the client to read server-side result messages/statuses. | ||
| 2112 : | * @param string $msg may be empty (will be the case when no error occurred) | ||
| 2113 : | * @param boolean $error Determines what status type has to be returned | ||
| 2114 : | * @access public | ||
| 2115 : | */ | ||
| 2116 : | function callbackResult($msg = 'none', $error = false) { | ||
| 2117 : | if ($error) { | ||
| 2118 : | $xml = "<result>KO</result><reason>$msg</reason>"; | ||
| 2119 : | } else { | ||
| 2120 : | $xml = "<result>OK</result><msg>$msg</msg>"; | ||
| 2121 : | } | ||
| 2122 : | return $xml; | ||
| 2123 : | } | ||
| 2124 : | /** | ||
| 2125 : | * @return string | ||
| 2126 : | * @desc Provide a generated HTML page with the necessary global Javascript variables. | ||
| 2127 : | * @param array $lang_const | ||
| 2128 : | * @access public | ||
| 2129 : | */ | ||
| 2130 : | function prepareAjax($lang_const) { | ||
| 2131 : | global $my, $mosConfig_live_site; | ||
| 2132 : | // needed to seperate the ISO number from the language file constant _ISO | ||
| 2133 : | $iso = explode( '=', _ISO ); | ||
| 2134 : | echo ("<script language=\"javascript\" type=\"text/javascript\">\n" | ||
| 2135 : | . "<!--\n" | ||
| 2136 : | . "\tvar id = '".md5($this->_CONFIG['secret'])."';\n" | ||
| 2137 : | . "\tvar IS_BACKEND = ".(($this->_isBackend) ? "true" : "false")."\n" | ||
| 2138 : | . "\tif (Zoom) {\n" | ||
| 2139 : | . "\t\tZoom.site_uri = document.location.protocol + '//' + document.location.host + document.location.pathname.replace(/\/(administrator\/)?index(2)?\.php$/i, '');//'".$mosConfig_live_site."';\n" | ||
| 2140 : | . "\t\tZoom.req_uri = Zoom.site_uri + \"/components/com_zoom/www/ajaxcallback.php\";\n" | ||
| 2141 : | . "\t\tZoom.uid = '".$my->id."';\n" | ||
| 2142 : | . "\t\tZoom.charset = '".$iso[1]."';\n" | ||
| 2143 : | . "\t}\n"); | ||
| 2144 : | if (is_array($lang_const)) { | ||
| 2145 : | foreach ($lang_const as $const => $val) { | ||
| 2146 : | echo ("\tvar ".$const." = '".$val."';\n"); | ||
| 2147 : | } | ||
| 2148 : | } | ||
| 2149 : | echo ("//-->\n" | ||
| 2150 : | . "</script>\n"); | ||
| 2151 : | } | ||
| 2152 : | //--------------------END Ajax specific functions----------------------// | ||
| 2153 : | //--------------------HTML content-creation functions------------------// | ||
| 2154 : | /** | ||
| 2155 : | * @return void | ||
| 2156 : | * @param int $key | ||
| 2157 : | * @desc Create the zOOm Slideshow | ||
| 2158 : | * @access public | ||
| 2159 : | */ | ||
| 2160 : | function createSlideshow($key) { | ||
| 2161 : | global $mosConfig_live_site; | ||
| 2162 : | ?> | ||
| 2163 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2164 : | <!-- | ||
| 2165 : | // (C) 2000 www.CodeLifter.com | ||
| 2166 : | // http://www.codelifter.com | ||
| 2167 : | // Free for all users, but leave in this header | ||
| 2168 : | // NS4-6,IE4-6 | ||
| 2169 : | // Fade effect only in IE; degrades gracefully | ||
| 2170 : | var stopstatus = 0; | ||
| 2171 : | |||
| 2172 : | // Set slideShowSpeed (milliseconds) | ||
| 2173 : | var slideShowSpeed = 8000; | ||
| 2174 : | |||
| 2175 : | // Duration of crossfade (seconds) | ||
| 2176 : | var crossFadeDuration = 3; | ||
| 2177 : | |||
| 2178 : | // Specify the image files | ||
| 2179 : | var Pic = new Array(); // don't touch this | ||
| 2180 : | <?php | ||
| 2181 : | $i = 0; | ||
| 2182 : | $j = 0; | ||
| 2183 : | while ($i<count($this->_gallery->_images)) { | ||
| 2184 : | $this->_gallery->_images[$i]->getInfo(); | ||
| 2185 : | if ($this->isImage($this->_gallery->_images[$i]->_type) && $this->_gallery->_images[$i]->isMember()) { | ||
| 2186 : | echo "Pic[$i] = '".$this->hotlinkImage($this->_gallery->_images[$i]->_catid, '0', $this->_gallery->_images[$i]->_id, null )."';\n\t\t"; | ||
| 2187 : | |||
| 2188 : | } | ||
| 2189 : | if ($i == $key) { | ||
| 2190 : | $j = $i; | ||
| 2191 : | } | ||
| 2192 : | $i++; | ||
| 2193 : | } | ||
| 2194 : | ?> | ||
| 2195 : | |||
| 2196 : | var t; | ||
| 2197 : | var j = <?php echo "$j" ?>; | ||
| 2198 : | var keyPic = '<?php echo $this->hotlinkImage($this->_gallery->_images[$key]->_catid, '0', $this->_gallery->_images[$key]->_id, null ); ?>'; | ||
| 2199 : | var p = Pic.length; | ||
| 2200 : | var pos = j; | ||
| 2201 : | var preLoad = new Array(); | ||
| 2202 : | |||
| 2203 : | function preLoadPic(index){ | ||
| 2204 : | if (Pic[index] != ''){ | ||
| 2205 : | window.status='Loading : '+Pic[index]; | ||
| 2206 : | preLoad[index] = new Image(); | ||
| 2207 : | preLoad[index].src = Pic[index]; | ||
| 2208 : | Pic[index] = ''; | ||
| 2209 : | window.status=''; | ||
| 2210 : | } | ||
| 2211 : | } | ||
| 2212 : | |||
| 2213 : | function runSlideShow(){ | ||
| 2214 : | if (stopstatus != '1'){ | ||
| 2215 : | for (var i = 0; i < document.images.length; i++) { | ||
| 2216 : | //if (document.getElementById('slideImage').src.indexOf('<?php echo $this->_gallery->_dir; ?>') >= 0 && document.getElementById('slideImage').src.indexOf('thumbs') == -1) { | ||
| 2217 : | document.getElementById('slideImage').src = preLoad[j].src; | ||
| 2218 : | new Effect.Appear(document.getElementById('slideImage'), {duration:1.0}); | ||
| 2219 : | //} | ||
| 2220 : | } | ||
| 2221 : | pos = j; | ||
| 2222 : | j = j + 1; | ||
| 2223 : | if (j > (p-1)) j=0; | ||
| 2224 : | t = setTimeout('runSlideShow()', slideShowSpeed); | ||
| 2225 : | preLoadPic(j); | ||
| 2226 : | } | ||
| 2227 : | } | ||
| 2228 : | |||
| 2229 : | function startSlideShow() { | ||
| 2230 : | stopstatus = 0; | ||
| 2231 : | <?php if ($this->_CONFIG['properties']) { echo "Element.hide($('details'));\n"; } ?> | ||
| 2232 : | <?php if ($this->_CONFIG['zoomOn']) { echo "document.getElementById('zImageBox').style.display = 'none';\n"; } else { echo "document.getElementById('zImage').style.display = 'none';\n"; } ?> | ||
| 2233 : | Element.show($('slideImage')); | ||
| 2234 : | runSlideShow(); | ||
| 2235 : | } | ||
| 2236 : | |||
| 2237 : | function endSlideShow(){ | ||
| 2238 : | stopstatus = 1; | ||
| 2239 : | for (var i = 0; i < document.images.length; i++) { | ||
| 2240 : | if (document.getElementById('slideImage').src.indexOf('<?php echo $this->_gallery->_dir; ?>') >= 0 && document.getElementById('slideImage').src.indexOf('thumbs') == -1) { | ||
| 2241 : | document.getElementById('slideImage').src = keyPic; | ||
| 2242 : | } | ||
| 2243 : | } | ||
| 2244 : | <?php if ($this->_CONFIG['properties']) { echo "Element.show($('details'));\n"; } ?> | ||
| 2245 : | <?php if ($this->_CONFIG['zoomOn']) { echo "document.getElementById('zImageBox').style.display = 'block';\n"; } else { echo "document.getElementById('zImage').style.display = 'block';\n"; } ?> | ||
| 2246 : | Element.hide($('slideImage')); | ||
| 2247 : | } | ||
| 2248 : | |||
| 2249 : | preLoadPic(j); | ||
| 2250 : | --> | ||
| 2251 : | </script> | ||
| 2252 : | <?php | ||
| 2253 : | } | ||
| 2254 : | |||
| 2255 : | // | ||
| 2256 : | // PLACEHOLDER | ||
| 2257 : | // | ||
| 2258 : | |||
| 2259 : | /** | ||
| 2260 : | * @return void | ||
| 2261 : | * @param string $formname | ||
| 2262 : | * @desc Create a script that submits a given form and reloads the page as well. | ||
| 2263 : | * @access public | ||
| 2264 : | */ | ||
| 2265 : | function createSubmitScript($formname) { | ||
| 2266 : | ?> | ||
| 2267 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2268 : | <!-- | ||
| 2269 : | function reloadPage() { | ||
| 2270 : | document.<?php echo $formname;?>.submit(); | ||
| 2271 : | return false; | ||
| 2272 : | } | ||
| 2273 : | // --> | ||
| 2274 : | </script> | ||
| 2275 : | <?php | ||
| 2276 : | } | ||
| 2277 : | /** | ||
| 2278 : | * @return void | ||
| 2279 : | * @desc Create a script which can check/ uncheck all the checkboxes with the same name in a form. | ||
| 2280 : | * @access public | ||
| 2281 : | */ | ||
| 2282 : | function createCheckAllScript() { | ||
| 2283 : | ?> | ||
| 2284 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2285 : | <!-- | ||
| 2286 : | function checkUncheckAll(oCheckbox, sName) | ||
| 2287 : | { | ||
| 2288 : | var el, i = 0, bWhich = oCheckbox.checked, oForm = oCheckbox.form; | ||
| 2289 : | while (el = oForm[i++]) | ||
| 2290 : | if (el.type == 'checkbox' && el.name == sName) el.checked = bWhich; | ||
| 2291 : | } | ||
| 2292 : | // --> | ||
| 2293 : | </script> | ||
| 2294 : | <?php | ||
| 2295 : | } | ||
| 2296 : | /** | ||
| 2297 : | * @return void | ||
| 2298 : | * @desc Create a script that can toggle the state of a form element. | ||
| 2299 : | * @access public | ||
| 2300 : | */ | ||
| 2301 : | function createFormControlScript() { | ||
| 2302 : | ?> | ||
| 2303 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2304 : | <!-- | ||
| 2305 : | var disabled = false; | ||
| 2306 : | |||
| 2307 : | function disable(theForm ,elmnt) { | ||
| 2308 : | document.forms[theForm].elements[elmnt].disabled = true; | ||
| 2309 : | disabled = true; | ||
| 2310 : | } | ||
| 2311 : | function enable(elmnt) { | ||
| 2312 : | document.forms[theForm].elements[elmnt].disabled = false; | ||
| 2313 : | disabled = false; | ||
| 2314 : | } | ||
| 2315 : | function toggleDisabled(elmnt) { | ||
| 2316 : | if (disabled == true) { | ||
| 2317 : | enable(elmnt); | ||
| 2318 : | } else { | ||
| 2319 : | disable(elmnt); | ||
| 2320 : | } | ||
| 2321 : | } | ||
| 2322 : | // --> | ||
| 2323 : | </script> | ||
| 2324 : | <?php | ||
| 2325 : | } | ||
| 2326 : | /** | ||
| 2327 : | * Echo CSS style to render the stars | ||
| 2328 : | * | ||
| 2329 : | */ | ||
| 2330 : | function createRatingCSS() { | ||
| 2331 : | global $mosConfig_live_site, $mainframe, $zoom; | ||
| 2332 : | $css = (" | ||
| 2333 : | <style type=\"text/css\"> | ||
| 2334 : | .unit-rating{ | ||
| 2335 : | margin:0; | ||
| 2336 : | padding:0; | ||
| 2337 : | position:relative; | ||
| 2338 : | height:15px; | ||
| 2339 : | width:75px; | ||
| 2340 : | display:block; | ||
| 2341 : | list-style:none; | ||
| 2342 : | cursor: pointer; | ||
| 2343 : | cursor: hand; | ||
| 2344 : | background: url('" . $mosConfig_live_site . "/components/com_zoom/www/images/rating/no_star.gif') top left; | ||
| 2345 : | } | ||
| 2346 : | |||
| 2347 : | .unit-rating li{ | ||
| 2348 : | float: left; | ||
| 2349 : | padding:0px; | ||
| 2350 : | margin:0px; | ||
| 2351 : | } | ||
| 2352 : | .unit-rating li a{ | ||
| 2353 : | display:block; | ||
| 2354 : | width:15px; | ||
| 2355 : | height:15px; | ||
| 2356 : | z-index:20; | ||
| 2357 : | position:absolute; | ||
| 2358 : | padding:0px; | ||
| 2359 : | } | ||
| 2360 : | .unit-rating li span{ | ||
| 2361 : | display: block; | ||
| 2362 : | width: 15px; | ||
| 2363 : | height: 15px; | ||
| 2364 : | text-decoration: none; | ||
| 2365 : | text-indent: -9000px; | ||
| 2366 : | z-index: 31; | ||
| 2367 : | position: absolute; | ||
| 2368 : | padding: 0px; | ||
| 2369 : | } | ||
| 2370 : | .hide{ | ||
| 2371 : | visibility:hidden; | ||
| 2372 : | display:none; | ||
| 2373 : | } | ||
| 2374 : | .unit-rating li a:hover{ | ||
| 2375 : | background: url('" . $mosConfig_live_site . "/components/com_zoom/www/images/rating/full_star.gif') top left; | ||
| 2376 : | z-index: 2; | ||
| 2377 : | left: 0px; | ||
| 2378 : | } | ||
| 2379 : | .unit-rating a.r1-unit{left: 0px;} | ||
| 2380 : | .unit-rating a.r1-unit:hover{width:15px;} | ||
| 2381 : | .unit-rating a.r2-unit{left:15px;} | ||
| 2382 : | .unit-rating a.r2-unit:hover{width: 30px;} | ||
| 2383 : | .unit-rating a.r3-unit{left: 30px;} | ||
| 2384 : | .unit-rating a.r3-unit:hover{width: 45px;} | ||
| 2385 : | .unit-rating a.r4-unit{left: 45px;} | ||
| 2386 : | .unit-rating a.r4-unit:hover{width: 60px;} | ||
| 2387 : | .unit-rating a.r5-unit{left: 60px;} | ||
| 2388 : | .unit-rating a.r5-unit:hover{width: 75px;} | ||
| 2389 : | .unit-rating a.r6-unit{left: 75px;} | ||
| 2390 : | .unit-rating a.r6-unit:hover{width: 90px;} | ||
| 2391 : | .unit-rating a.r7-unit{left: 90px;} | ||
| 2392 : | .unit-rating a.r7-unit:hover{width: 105px;} | ||
| 2393 : | .unit-rating a.r8-unit{left: 105px;} | ||
| 2394 : | .unit-rating a.r8-unit:hover{width: 120px;} | ||
| 2395 : | .unit-rating a.r9-unit{left: 120px;} | ||
| 2396 : | .unit-rating a.r9-unit:hover{width: 135px;} | ||
| 2397 : | .unit-rating a.r10-unit{left: 135px;} | ||
| 2398 : | .unit-rating a.r10-unit:hover{width: 150px;} | ||
| 2399 : | .unit-rating li.current-rating{ | ||
| 2400 : | background: url('" . $mosConfig_live_site . "/components/com_zoom/www/images/rating/full_voting_star.gif') left top repeat-x; | ||
| 2401 : | position: absolute; | ||
| 2402 : | padding-left:0px; | ||
| 2403 : | height: 15px; | ||
| 2404 : | display: block; | ||
| 2405 : | z-index: 1; | ||
| 2406 : | left:0px; | ||
| 2407 : | } | ||
| 2408 : | </style>"); | ||
| 2409 : | if ($zoom->_CONFIG['popUpImages']) { | ||
| 2410 : | echo $css; | ||
| 2411 : | } else { | ||
| 2412 : | $mainframe->addCustomHeadTag($css); | ||
| 2413 : | } | ||
| 2414 : | } | ||
| 2415 : | /** | ||
| 2416 : | * @return void | ||
| 2417 : | * @param string $status | ||
| 2418 : | * @desc Create a floating box which will inform the user of what zOOm is doing at a given time/ status. | ||
| 2419 : | * @access public | ||
| 2420 : | */ | ||
| 2421 : | function createProgressScript($status) { | ||
| 2422 : | global $mosConfig_live_site; | ||
| 2423 : | $animation = "$mosConfig_live_site/components/com_zoom/www/images/progress.gif"; | ||
| 2424 : | $display = "none"; | ||
| 2425 : | switch ($status) { | ||
| 2426 : | case 'upload': | ||
| 2427 : | $img_from = "$mosConfig_live_site/components/com_zoom/www/images/folder_small.gif"; | ||
| 2428 : | $img_to = "$mosConfig_live_site/components/com_zoom/www/images/web.gif"; | ||
| 2429 : | break; | ||
| 2430 : | case 'delete': | ||
| 2431 : | $img_from = "$mosConfig_live_site/components/com_zoom/www/images/web.gif"; | ||
| 2432 : | $img_to = "$mosConfig_live_site/components/com_zoom/www/images/trash.gif"; | ||
| 2433 : | $display = "visible"; | ||
| 2434 : | break; | ||
| 2435 : | case 'search': | ||
| 2436 : | $img_from = "$mosConfig_live_site/components/com_zoom/www/images/web.gif"; | ||
| 2437 : | $img_to = "$mosConfig_live_site/components/com_zoom/www/images/web.gif"; | ||
| 2438 : | break; | ||
| 2439 : | default: | ||
| 2440 : | $img_from = "$mosConfig_live_site/components/com_zoom/www/images/folder_small.gif"; | ||
| 2441 : | $img_to = "$mosConfig_live_site/components/com_zoom/www/images/web.gif"; | ||
| 2442 : | break; | ||
| 2443 : | } | ||
| 2444 : | ?> | ||
| 2445 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2446 : | <!-- | ||
| 2447 : | function hideMe(){ | ||
| 2448 : | Element.hide($('progress')); | ||
| 2449 : | } | ||
| 2450 : | |||
| 2451 : | function showMe(){ | ||
| 2452 : | var elProgress = $('progress'); | ||
| 2453 : | var winSize = Zoom.getWindowSize(); | ||
| 2454 : | var elSize = Zoom.getElementSize(elProgress); | ||
| 2455 : | var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body; | ||
| 2456 : | var dsocleft=0; | ||
| 2457 : | var dsoctop=document.all? iebody.scrollTop : pageYOffset; | ||
| 2458 : | elProgress.style.left = Math.round(((winSize.width - elSize.width) + dsocleft) / 2) + "px"; | ||
| 2459 : | elProgress.style.top = Math.round(((winSize.height - elSize.height) + dsoctop) / 2) + "px"; | ||
| 2460 : | Element.show(elProgress); | ||
| 2461 : | } | ||
| 2462 : | // --> | ||
| 2463 : | </script> | ||
| 2464 : | <style type="text/css"> | ||
| 2465 : | <!-- | ||
| 2466 : | #progress { | ||
| 2467 : | background-color: #fff; | ||
| 2468 : | z-index: 1000; | ||
| 2469 : | padding: 2px; | ||
| 2470 : | position: absolute; | ||
| 2471 : | top: 50%; | ||
| 2472 : | left: 50%; | ||
| 2473 : | width: 380px; | ||
| 2474 : | height: 60px; | ||
| 2475 : | border: solid 3px #666; | ||
| 2476 : | display: block; | ||
| 2477 : | } | ||
| 2478 : | --> | ||
| 2479 : | </style> | ||
| 2480 : | <div id="progress"> | ||
| 2481 : | <table border="0" cellpadding="0" cellspacing="0" width="100%"> | ||
| 2482 : | <tr> | ||
| 2483 : | <td align="right"><img src="<?php echo $img_from;?>" width="32" height="32" alt="" border="0" /></td> | ||
| 2484 : | <td align="center"><img src="<?php echo $animation;?>" alt="" border="0" /></td> | ||
| 2485 : | <td align="left"><img src="<?php echo $img_to;?>" width="32" height="32" alt="" border="0" /></td> | ||
| 2486 : | </tr> | ||
| 2487 : | <tr> | ||
| 2488 : | <td align="center" valign="middle" colspan="3"> | ||
| 2489 : | <p><?php echo _ZOOM_PROGRESS_DESCR;?></p> | ||
| 2490 : | </td> | ||
| 2491 : | </tr> | ||
| 2492 : | </table> | ||
| 2493 : | </div> | ||
| 2494 : | <?php | ||
| 2495 : | } | ||
| 2496 : | /** | ||
| 2497 : | * @return void | ||
| 2498 : | * @desc Show the progress DIV (createProgressScript() needs to be executed in advance for this function to work). | ||
| 2499 : | * @access public | ||
| 2500 : | */ | ||
| 2501 : | function showProgress() { | ||
| 2502 : | ?> | ||
| 2503 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2504 : | <!-- | ||
| 2505 : | showMe(); | ||
| 2506 : | // --> | ||
| 2507 : | </script> | ||
| 2508 : | <?php | ||
| 2509 : | } | ||
| 2510 : | /** | ||
| 2511 : | * @return void | ||
| 2512 : | * @desc Hide the progress DIV (createProgressScript() needs to be executed in advance for this function to work). | ||
| 2513 : | * @access public | ||
| 2514 : | */ | ||
| 2515 : | function hideProgress() { | ||
| 2516 : | ?> | ||
| 2517 : | <script language="JavaScript" type="text/JavaScript"> | ||
| 2518 : | <!-- | ||
| 2519 : | hideMe(); | ||
| 2520 : | // --> | ||
| 2521 : | </script> | ||
| 2522 : | <?php | ||
| 2523 : | } | ||
| 2524 : | |||
| 2525 : | /** | ||
| 2526 : | * @return void | ||
| 2527 : | * @desc Create the footer which appears at the bottom of every Admin/ User System page. | ||
| 2528 : | * @access public | ||
| 2529 : | */ | ||
| 2530 : | function adminFooter() { | ||
| 2531 : | ?> | ||
| 2532 : | <p align="center"> | ||
| 2533 : | <b>zOOm Media Gallery <?php echo $this->_CONFIG['version'];?></b><br />Copyright © 2005 - <?php echo strftime("%G")?> by <a href="http://www.zoomfactory.org" target="_blank">zOOmFactory.org</a>.</p> | ||
| 2534 : | <?php | ||
| 2535 : | } | ||
| 2536 : | /** | ||
| 2537 : | * @return string | ||
| 2538 : | * @param string $sel_name | ||
| 2539 : | * @param string $first_opt | ||
| 2540 : | * @param int $onchange | ||
| 2541 : | * @param int $sel | ||
| 2542 : | * @param int $exclude | ||
| 2543 : | * @desc Create a HTML dropdown form element which contains a list of galleries (ordered and indented). | ||
| 2544 : | * @access public | ||
| 2545 : | */ | ||
| 2546 : | function createCatDropdown($sel_name = "catid", $first_opt, $onchange=0, $sel=0, $exclude=0) { | ||
| 2547 : | if ($onchange==0) { | ||
| 2548 : | $html = "<select name=\"$sel_name\" id=\"$sel_name\" class=\"inputbox\">"; | ||
| 2549 : | } elseif ($onchange==1) { | ||
| 2550 : | $html = "<select name=\"$sel_name\" class=\"inputbox\" onchange=\"reloadPage()\">"; | ||
| 2551 : | } | ||
| 2552 : | $html .= $first_opt; | ||
| 2553 : | // NOW, I'm going to offer the users infinite level of navigation and gallery-creation; | ||
| 2554 : | // check the function 'getCatList()' for more info...code inspired by Coppermine. | ||
| 2555 : | $this->_CAT_LIST = null; | ||
| 2556 : | $this->_getCatList(0, "> ", "> "); | ||
| 2557 : | if (isset($this->_CAT_LIST)) { | ||
| 2558 : | foreach ($this->_CAT_LIST as $category) { | ||
| 2559 : | if ($category['id'] != $exclude || $exclude == 0) { | ||
| 2560 : | $html.= "<option value=\"".$category['id']."\"".($sel == $category['id'] ? " selected": "").">".$category['catname']."</option>\n"; | ||
| 2561 : | } | ||
| 2562 : | } | ||
| 2563 : | } | ||
| 2564 : | return $html."</select>"; | ||
| 2565 : | } | ||
| 2566 : | /** | ||
| 2567 : | * @return string | ||
| 2568 : | * @param string $xml | ||
| 2569 : | * @desc Create a HTML dropdown form element which contains a list of galleries (ordered and indented). | ||
| 2570 : | * @access public | ||
| 2571 : | */ | ||
| 2572 : | function createCatXML($xml = "") { | ||
| 2573 : | $this->_CAT_LIST = null; | ||
| 2574 : | $this->_getCatList(0, "> ", "> "); | ||
| 2575 : | if (isset($this->_CAT_LIST)) { | ||
| 2576 : | $xml .= "<gallery id=\"0\"><![CDATA[> "._ZOOM_TOPLEVEL."]]></gallery>"; | ||
| 2577 : | foreach ($this->_CAT_LIST as $category) { | ||
| 2578 : | $xml .= "<gallery id=\"".$category['id']."\"><![CDATA[".$category['catname']."]]></gallery>"; | ||
| 2579 : | } | ||
| 2580 : | |||
| 2581 : | } | ||
| 2582 : | return $xml; | ||
| 2583 : | } | ||
| 2584 : | |||
| 2585 : | /** | ||
| 2586 : | * @return string | ||
| 2587 : | * @desc Create the HTML body of the Gallery Manager. | ||
| 2588 : | * @access public | ||
| 2589 : | */ | ||
| 2590 : | function createCatMgrFormbody() { | ||
| 2591 : | // This function creates the table of catsmgr.php...it uses the 'virtpath'-column | ||
| 2592 : | // of the internal CAT_LIST variable. Check the 'getCatList()' function for more details... | ||
| 2593 : | global $Itemid, $mosConfig_live_site; | ||
| 2594 : | $html = ""; | ||
| 2595 : | $this->_CAT_LIST = null; | ||
| 2596 : | $this->_getCatList(0, '> ', '> '); | ||
| 2597 : | $i = 0; | ||
| 2598 : | $table_class = " class=\"adminlist\""; | ||
| 2599 : | $header_class = " class=\"title\""; | ||
| 2600 : | $this->_tabclass = array("row0", "row1"); | ||
| 2601 : | $html .= ("\n<div id=\"cats_list\"$table_class>\n" | ||
| 2602 : | . "\t<div$header_class>\n" | ||
| 2603 : | . "\t\t<div class=\"entry col1\"> </div>\n" | ||
| 2604 : | . "\t\t<div class=\"entry col2\">"._ZOOM_HD_NAME."</div>\n" | ||
| 2605 : | . "\t\t<div class=\"entry col3\">"._ZOOM_PUBLISHED."</div>\n" | ||
| 2606 : | . "\t\t<div class=\"entry col3\">"._ZOOM_SHARED."</div>\n" | ||
| 2607 : | . "\t\t<div class=\"entry col3\">"._ZOOM_HD_CREATEDBY."</div>\n" | ||
| 2608 : | . "\t</div>"); | ||
| 2609 : | if (isset($this->_CAT_LIST)) { | ||
| 2610 : | foreach ($this->_CAT_LIST as $category) { | ||
| 2611 : | $i++; | ||
| 2612 : | $bgcolor = ($i & 1) ? $this->_tabclass[1] : $this->_tabclass[0]; | ||
| 2613 : | $edit_link = "javascript:void(0);"; | ||
| 2614 : | if ($this->privileges->hasPrivilege('priv_editgal') || $this->_isAdmin) { | ||
| 2615 : | $edit_link = "index"; | ||
| 2616 : | if ($this->_isBackend) { | ||
| 2617 : | $edit_link .= "2"; | ||
| 2618 : | } | ||
| 2619 : | $edit_link .= ".php?option=com_zoom&page=catsmgr&task=edit&catid=".$category['id']."&Itemid=".$Itemid; | ||
| 2620 : | } | ||
| 2621 : | $html .= ("\n\t<div class=\"".$bgcolor." draggable\" id=\"cat_".$category['id']."\">\n" | ||
| 2622 : | . "\t\t<div class=\"entry col1\"><input type=\"checkbox\" name=\"catids[]\" value=\"".$category['id']."\" id=\"catno_$i\" /></div>\n" | ||
| 2623 : | . "\t\t<div class=\"entry col2\"><a href=\"".$edit_link."\">".$category['virtpath']."</a></div>\n" | ||
| 2624 : | . "\t\t<div class=\"entry col3\"><a href=\"javascript:"); | ||
| 2625 : | if ($this->_isAdmin || $this->privileges->hasPrivilege('priv_editgal')) { | ||
| 2626 : | $html .= "submitForm('publish', ".$category['id'].")"; | ||
| 2627 : | } else { | ||
| 2628 : | $html .= "void(0)"; | ||
| 2629 : | } | ||
| 2630 : | $html .= (";\"><img src=\"".$mosConfig_live_site."/components/com_zoom/www/images/"); | ||
| 2631 : | // special cells with published, shared and userid info... | ||
| 2632 : | $html .= ($category['published']) ? "publish_g.png\" onmouseover=\"return overlib('"._ZOOM_UNPUBLISH."');\" onmouseout=\"return nd();\"" : "publish_x.png\" onmouseover=\"return overlib('"._ZOOM_PUBLISH."');\" onmouseout=\"return nd();\""; | ||
| 2633 : | $html .= (" border=\"0\" /></a></div>\n" | ||
| 2634 : | . "\t\t<div class=\"entry col3\"><a href=\"javascript:"); | ||
| 2635 : | if ($this->_isAdmin || $this->privileges->hasPrivilege('priv_editgal')) { | ||
| 2636 : | $html .= "submitForm('share', ".$category['id'].")"; | ||
| 2637 : | } else { | ||
| 2638 : | $html .= "void(0)"; | ||
| 2639 : | } | ||
| 2640 : | $html .= (";\"><img src=\"".$mosConfig_live_site."/components/com_zoom/www/images/"); | ||
| 2641 : | $html .= ($category['shared']) ? "share_u.png\" onmouseover=\"return overlib('"._ZOOM_UNSHARE."');\" onmouseout=\"return nd();\"" : "share_l.png\" onmouseover=\"return overlib('"._ZOOM_SHARE."');\" onmouseout=\"return nd();\""; | ||
| 2642 : | $cat_user = $this->getUserInfo($category['uid']); | ||
| 2643 : | $html .= (" border=\"0\" /></a></div>\n" | ||
| 2644 : | . "\t\t<div class=\"entry col3\">".$cat_user->username."</div>\n" | ||
| 2645 : | . "\t</div>\n"); | ||
| 2646 : | } | ||
| 2647 : | } | ||
| 2648 : | $html .= ("\n\t<div$header_class>\n" | ||
| 2649 : | . "\t\t<div class=\"entry col1\"><input type=\"checkbox\" name=\"checkall\" onclick=\"checkUncheckAll(this, 'catid[]');\" id=\"checkall\" /></div>\n" | ||
| 2650 : | . "\t\t<div class=\"entry col2\" onmousedown=\"document.getElementById('checkall').checked = (document.getElementById('checkall').checked ? false : true);checkUncheckAll(document.getElementById('checkall'), 'catid[]');\">\n" | ||
| 2651 : | . "\t\t\t<strong><label onclick=\"javascript: return (document.getElementById('checkall') ? false : true);checkUncheckAll(document.getElementById('checkall'), 'catid[]');\" for=\"checkall\">"._ZOOM_HD_CHECKALL."</label></strong>\n" | ||
| 2652 : | . "\t\t</div>\n" | ||
| 2653 : | . "\t</div>\n" | ||
| 2654 : | . "</div>\n"); | ||
| 2655 : | return $html; | ||
| 2656 : | } | ||
| 2657 : | /** | ||
| 2658 : | * @return string | ||
| 2659 : | * @desc Create the HTML body of the Media Manager. | ||
| 2660 : | * @access public | ||
| 2661 : | */ | ||
| 2662 : | function createMediaEditForm($option, $page, $Itemid, $catid, $backend, $PageNo = 1) { | ||
| 2663 : | global $mosConfig_live_site, $mosConfig_absolute_path; | ||
| 2664 : | $this->createCheckAllScript(); | ||
| 2665 : | $i = 0; | ||
| 2666 : | $this->_counter = 0; | ||
| 2667 : | $table_class = ""; | ||
| 2668 : | $header_class = " class=\"sectiontableheader\""; | ||
| 2669 : | if ($this->_isBackend) { | ||
| 2670 : | $table_class = " class=\"adminlist\""; | ||
| 2671 : | $header_class = ""; | ||
| 2672 : | $this->_tabclass = array("row0", "row1"); | ||
| 2673 : | } | ||
| 2674 : | |||
| 2675 : | $i = 1; | ||
| 2676 : | $startRow = 0; | ||
| 2677 : | $PageSize = empty($_SESSION['zoom_mediapp']) ? 10 : $_SESSION['zoom_mediapp']; | ||
| 2678 : | |||
| 2679 : | //Set the page no | ||
| 2680 : | $startRow = ($PageNo - 1) * $PageSize; | ||
| 2681 : | //Total of record | ||
| 2682 : | $RecordCount = $this->_gallery->getNumOfImages();//Number of files in gallery | ||
| 2683 : | $endRow = $startRow + $PageSize - 1; // subtract one or it's one more than requested | ||
| 2684 : | if ($endRow >= $RecordCount) { | ||
| 2685 : | $endRow = $RecordCount - 1; | ||
| 2686 : | } | ||
| 2687 : | //Set Maximum Page | ||
| 2688 : | $MaxPage = ceil($RecordCount % $PageSize); | ||
| 2689 : | if ($RecordCount % $PageSize == 0) { | ||
| 2690 : | $MaxPage = ceil($RecordCount / $PageSize); | ||
| 2691 : | } else { | ||
| 2692 : | $MaxPage = ceil($RecordCount / $PageSize); | ||
| 2693 : | } | ||
| 2694 : | //Set the counter start | ||
| 2695 : | $CounterStart = 1; | ||
| 2696 : | //Counter End | ||
| 2697 : | $CounterEnd = $MaxPage; | ||
| 2698 : | ?> | ||
| 2699 : | <table width="80%" border="0" cellpadding="0" cellspacing="0"> | ||
| 2700 : | <tr> | ||
| 2701 : | <td align="center" width="50%"> | ||
| 2702 : | <?php | ||
| 2703 : | $c = 0; | ||
| 2704 : | //Print Page No | ||
| 2705 : | for ($c=$CounterStart; $c <= $CounterEnd; $c++) { | ||
| 2706 : | if($c < $MaxPage){ | ||
| 2707 : | if ($c == $PageNo) { | ||
| 2708 : | if ($c % $RecordCount == 0) { | ||
| 2709 : | echo "<u><strong>$c</strong></u> "; | ||
| 2710 : | } else { | ||
| 2711 : | echo "<u><strong>$c</strong></u> | "; | ||
| 2712 : | } | ||
| 2713 : | } elseif ($c % $RecordCount == 0) { | ||
| 2714 : | echo "<a href=\"". (($this->_isBackend) ? "index2.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c : sefReltoAbs("index.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c)) ."\"><strong>$c</strong></a> "; | ||
| 2715 : | } else { | ||
| 2716 : | echo "<a href=\"". (($this->_isBackend) ? "index2.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c : sefReltoAbs("index.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c)) ."\"><strong>$c</strong></a> | "; | ||
| 2717 : | }//END IF | ||
| 2718 : | } else { | ||
| 2719 : | if ($PageNo == $MaxPage) { | ||
| 2720 : | echo "<u><strong>$c</strong></u> "; | ||
| 2721 : | } else { | ||
| 2722 : | echo "<a href=\"". (($this->_isBackend) ? "index2.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c : sefReltoAbs("index.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c)) ."\"><strong>$c</strong></a> "; | ||
| 2723 : | } | ||
| 2724 : | } | ||
| 2725 : | } | ||
| 2726 : | echo $this->createMediaPPDropdown($PageSize); | ||
| 2727 : | ?> | ||
| 2728 : | </td> | ||
| 2729 : | <?php | ||
| 2730 : | if (!$this->_isBackend) { | ||
| 2731 : | ?> | ||
| 2732 : | <td align="right"> | ||
| 2733 : | <div align="right"> | ||
| 2734 : | <?php if ($this->_isAdmin || $this->privileges->hasPrivilege('priv_upload')) { ?> | ||
| 2735 : | <a href="<?php echo ($this->_isBackend) ? "index".$backend.".php?option=com_zoom&page=upload&return=mediamgr&catid=".$catid."&Itemid=".$Itemid."&PageNo=".$PageNo : sefReltoAbs("index.php?option=com_zoom&page=upload&return=mediamgr&catid=".$catid."&Itemid=".$Itemid."&PageNo=".$PageNo);?>" onmouseover="return overlib('<?php echo _ZOOM_UPLOAD;?>');" onmouseout="return nd();"><img src="<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/new.png" alt="" border="0" onmouseover="MM_swapImage('new','','<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/new_f2.png',1);" onmouseout="MM_swapImgRestore();" name="new" /></a> | ||
| 2736 : | <?php } if($this->_isAdmin || $this->privileges->hasPrivilege('priv_editmedium')) { ?> | ||
| 2737 : | <a href="javascript:submitbutton('edtimg');" onmouseover="return overlib('<?php echo _ZOOM_BUTTON_EDIT;?>');" onmouseout="return nd();"><img src="<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/edit.png" alt="" border="0" onmouseover="MM_swapImage('edit','','<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/edit_f2.png',1);" onmouseout="MM_swapImgRestore();" name="edit" /></a> | ||
| 2738 : | <?php } if ($this->_isAdmin) { ?> | ||
| 2739 : | <a href="javascript:submitbutton('move');" onmouseover="return overlib('<?php echo _ZOOM_MOVEFILES;?>');" onmouseout="return nd();"><img src="<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/move.png" alt="" border="0" onmouseover="MM_swapImage('movefiles','','<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/move_f2.png',1);" onmouseout="MM_swapImgRestore();" name="movefiles" /></a> | ||
| 2740 : | <?php } if ($this->_isAdmin || $this->privileges->hasPrivilege('priv_delmedium')) { ?> | ||
| 2741 : | <a href="javascript:submitbutton('delete');" onmouseover="return overlib('<?php echo _ZOOM_DELETE;?>');" onmouseout="return nd();"><img src="<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/delete.png" alt="" border="0" onmouseover="MM_swapImage('delete','','<?php echo $mosConfig_live_site;?>/components/com_zoom/www/images/admin/delete_f2.png',1);" onmouseout="MM_swapImgRestore();" name="delete" /></a> | ||
| 2742 : | <?php } ?> | ||
| 2743 : | </div> | ||
| 2744 : | </td> | ||
| 2745 : | <?php | ||
| 2746 : | } | ||
| 2747 : | ?> | ||
| 2748 : | </tr> | ||
| 2749 : | </table> | ||
| 2750 : | <form name="mediamgr" action="<?php echo ($this->_isBackend) ? "index2.php?option=com_zoom&page=mediamgr&Itemid=".$Itemid : sefReltoAbs("index.php?option=com_zoom&page=mediamgr&Itemid=".$Itemid)?>" method="post"> | ||
| 2751 : | <input type="hidden" name="task" value="" /> | ||
| 2752 : | <input type="hidden" name="return" value="mediamgr" /> | ||
| 2753 : | <input type="hidden" name="catid" value="<?php echo $this->_gallery->_id; ?>" /> | ||
| 2754 : | <input type="hidden" name="mediapp" value="" /> | ||
| 2755 : | <input type="hidden" name="PageNo" value="<?php echo $PageNo; ?>" /> | ||
| 2756 : | <table width="80%" border="0" cellspacing="0" cellpadding="0"> | ||
| 2757 : | <tr> | ||
| 2758 : | <td align="center"> | ||
| 2759 : | <div align="center"> | ||
| 2760 : | <?php | ||
| 2761 : | echo ("\t\t\t<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\"$table_class>\n" | ||
| 2762 : | . "\t\t\t<tr$header_class>\n" | ||
| 2763 : | . "\t\t\t\t<th width=\"50\"> </th>\n" | ||
| 2764 : | . "\t\t\t\t<th align=\"left\">"._ZOOM_NAME."</th>\n" | ||
| 2765 : | . "\t\t\t\t<th align=\"left\">"._ZOOM_FILENAME."</th>\n" | ||
| 2766 : | . "\t\t\t\t<th align=\"left\">"._ZOOM_HD_PREVIEW."</th>\n" | ||
| 2767 : | . "\t\t\t</tr>\n"); | ||
| 2768 : | if (($this->privileges->hasPrivilege('priv_editmedium') | $this->privileges->hasPrivilege('priv_delmedium')) || $this->_isAdmin) { | ||
| 2769 : | for ($counter = $startRow; $counter <= $endRow; $counter++) { | ||
| 2770 : | $image = $this->_gallery->_images[$counter]; | ||
| 2771 : | $i++; | ||
| 2772 : | $image->getInfo(); | ||
| 2773 : | $bgcolor = ($i & 1) ? $this->_tabclass[1] : $this->_tabclass[0]; | ||
| 2774 : | if ($this->_isAdmin || $this->privileges->hasPrivilege('priv_editmedium')) { | ||
| 2775 : | if ($this->_isBackend) { | ||
| 2776 : | $edit_link = "index2.php?option=com_zoom&page=mediamgr&task=edtimg&catid=".$image->_catid."&key=".$counter."&Itemid=".$Itemid."&PageNo=".$PageNo; | ||
| 2777 : | } else { | ||
| 2778 : | $edit_link = sefReltoAbs("index.php?option=com_zoom&page=mediamgr&task=edtimg&catid=".$image->_catid."&key=".$counter."&Itemid=".$Itemid."&PageNo=".$PageNo); | ||
| 2779 : | } | ||
| 2780 : | } else { | ||
| 2781 : | $edit_link = "javascript:void(0);"; | ||
| 2782 : | } | ||
| 2783 : | echo ("\t\t\t<tr class=\"".$bgcolor."\">\n" | ||
| 2784 : | . "\t\t\t\t<td align=\"center\" width=\"10\"><input type=\"checkbox\" name=\"keys[]\" value=\"".$counter."\" id=\"mediumno_$i\" /></td>\n" | ||
| 2785 : | . "\t\t\t\t<td onmousedown=\"document.getElementById('mediumno_$i').checked = (document.getElementById('mediumno_$i').checked ? false : true);\"><a href=\"".$edit_link."\">".$image->_name."</a><br /></td>\n" | ||
| 2786 : | . "\t\t\t\t<td onmousedown=\"document.getElementById('mediumno_$i').checked = (document.getElementById('mediumno_$i').checked ? false : true);\">".$image->_filename."<br />\n" | ||
| 2787 : | . "\t\t\t\t</td>\n" | ||
| 2788 : | . "\t\t\t\t<td onmousedown=\"document.getElementById('mediumno_$i').checked = (document.getElementById('mediumno_$i').checked ? false : true);\"><img src=\"".$this->hotlinkImage($catid, '2', $image->_id, null)."\" alt=\"\" border=\"0\" /></td>\n" | ||
| 2789 : | . "\t\t\t</tr>\n"); | ||
| 2790 : | $this->_counter++; | ||
| 2791 : | } | ||
| 2792 : | } | ||
| 2793 : | echo ("\t\t\t<tr$header_class>\n" | ||
| 2794 : | . "\t\t\t\t<th height=\"20\" align=\"center\"><input type=\"checkbox\" name=\"checkall\" onclick=\"checkUncheckAll(this, 'keys[]');\" id=\"checkall\" /></th>\n" | ||
| 2795 : | . "\t\t\t\t<th height=\"20\" align=\"left\" onmousedown=\"document.getElementById('checkall').checked = (document.getElementById('checkall').checked ? false : true);checkUncheckAll(document.getElementById('checkall'), 'keys[]');\">\n" | ||
| 2796 : | . "\t\t\t<strong><label onclick=\"javascript: return (document.getElementById('checkall') ? false : true);checkUncheckAll(document.getElementById('checkall'), 'keys[]');\" for=\"checkall\">"._ZOOM_HD_CHECKALL."</label></strong>\n" | ||
| 2797 : | . "\t\t\t\t</th>\n" | ||
| 2798 : | . "\t\t\t\t<th height=\"20\" align=\"center\">"); | ||
| 2799 : | $c = 0; | ||
| 2800 : | //Print Page No | ||
| 2801 : | for ($c=$CounterStart; $c <= $CounterEnd; $c++) { | ||
| 2802 : | if($c < $MaxPage){ | ||
| 2803 : | if ($c == $PageNo) { | ||
| 2804 : | if ($c % $RecordCount == 0) { | ||
| 2805 : | echo "<u><strong>$c</strong></u> "; | ||
| 2806 : | } else { | ||
| 2807 : | echo "<u><strong>$c</strong></u> | "; | ||
| 2808 : | } | ||
| 2809 : | } elseif ($c % $RecordCount == 0) { | ||
| 2810 : | echo "<a href=\"". (($this->_isBackend) ? "index2.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c : sefReltoAbs("index.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c)) ."\"><strong>$c</strong></a> "; | ||
| 2811 : | } else { | ||
| 2812 : | echo "<a href=\"". (($this->_isBackend) ? "index2.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c : sefReltoAbs("index.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c)) ."\"><strong>$c</strong></a> | "; | ||
| 2813 : | }//END IF | ||
| 2814 : | } else { | ||
| 2815 : | if ($PageNo == $MaxPage) { | ||
| 2816 : | echo "<u><strong>$c</strong></u> "; | ||
| 2817 : | } else { | ||
| 2818 : | echo "<a href=\"". (($this->_isBackend) ? "index2.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c : sefReltoAbs("index.php?option=com_zoom&page=".$page."&Itemid=".$Itemid."&catid=".$catid."&PageNo=".$c)) ."\"><strong>$c</strong></a> "; | ||
| 2819 : | } | ||
| 2820 : | } | ||
| 2821 : | } | ||
| 2822 : | echo $this->createMediaPPDropdown($PageSize); | ||
| 2823 : | echo ("</th>\n" | ||
| 2824 : | . "\t\t\t\t<th height=\"20\" align=\"center\"> </th>\n" | ||
| 2825 : | . "\t\t\t</tr>\n" | ||
| 2826 : | . "\t\t\t</table>\n" | ||
| 2827 : | . "\t\t\t</div>" | ||
| 2828 : | . "\t\t</td>" | ||
| 2829 : | . "\t</tr>" | ||
| 2830 : | . "\t</table>" | ||
| 2831 : | . "\t</form>"); | ||
| 2832 : | |||
| 2833 : | } | ||
| 2834 : | /** | ||
| 2835 : | * @return string | ||
| 2836 : | * @param mixed $crt_no | ||
| 2837 : | * @desc Build a dropdown select box with which the user may specify the number of media he/ she wants to view per page | ||
| 2838 : | * @access public | ||
| 2839 : | */ | ||
| 2840 : | function createMediaPPDropdown($crt_no) { | ||
| 2841 : | $html = "<select name=\"media_pp\" class=\"inputbox\" onchange=\"submitbutton('mediapp', this.value)\">\n"; | ||
| 2842 : | $values = array(5, 10, 25, 50, 100); | ||
| 2843 : | foreach ($values as $value) { | ||
| 2844 : | $html .= "<option value=\"$value\"".(($value == $crt_no) ? " selected" : "").">$value</option>"; | ||
| 2845 : | } | ||
| 2846 : | return $html . "</select>\n"; | ||
| 2847 : | } | ||
| 2848 : | /** | ||
| 2849 : | * @return void | ||
| 2850 : | * @param array $imagelist | ||
| 2851 : | * @param string $extractloc | ||
| 2852 : | * @desc Create a HTML table filled with media found by the 'scan' feature OR the zip-upload. | ||
| 2853 : | * @access public | ||
| 2854 : | */ | ||
| 2855 : | function createFileList(&$imagelist, $extractloc = "") { | ||
| 2856 : | global $mosConfig_live_site, $mosConfig_absolute_path; | ||
| 2857 : | $this->createCheckAllScript(); | ||
| 2858 : | $tabcnt = 0; | ||
| 2859 : | $this->_counter = 0; | ||
| 2860 : | $i = 0; | ||
| 2861 : | $table_class = " class=\"adminform\""; | ||
| 2862 : | $header_class = " class=\"sectiontableheader\""; | ||
| 2863 : | if ($this->_isBackend) { | ||
| 2864 : | $table_class = " class=\"adminlist\""; | ||
| 2865 : | $header_class = ""; | ||
| 2866 : | $this->_tabclass = array("row0", "row1"); | ||
| 2867 : | } | ||
| 2868 : | echo ("<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"95%\"$table_class>\n" | ||
| 2869 : | . "\t\t\t<tr$header_class>\n" | ||
| 2870 : | . "\t\t\t\t<th width=\"50\"> </th>\n" | ||
| 2871 : | . "\t\t\t\t<th align=\"left\">"._ZOOM_FILENAME."</th>\n" | ||
| 2872 : | . "\t\t\t\t<th align=\"left\">"._ZOOM_HD_PREVIEW."</th>\n" | ||
| 2873 : | . "\t\t\t</tr>\n"); | ||
| 2874 : | foreach ($imagelist as $image) { | ||
| 2875 : | $i++; | ||
| 2876 : | $bgcolor = ($i & 1) ? $this->_tabclass[1] : $this->_tabclass[0]; | ||
| 2877 : | $tag = strtolower(ereg_replace(".*\.([^\.]*)$", "\\1", $image)); | ||
| 2878 : | if ($this->isImage($tag)) { | ||
| 2879 : | if (!$this->platform->is_file($image)) { | ||
| 2880 : | $image_path = $mosConfig_absolute_path."/".$extractloc."/".$image; | ||
| 2881 : | $image_virt = $mosConfig_live_site."/".$extractloc."/".$image; | ||
| 2882 : | $imginfo = $this->platform->getimagesize($image_path); | ||
| 2883 : | $ratio = max($imginfo[0], $imginfo[1]) / $this->_CONFIG['size']; | ||
| 2884 : | $ratio = max($ratio, 1.0); | ||
| 2885 : | $imgWidth = (int)($imginfo[0] / $ratio); | ||
| 2886 : | $imgHeight = (int)($imginfo[1] / $ratio); | ||
| 2887 : | } else { | ||
| 2888 : | $image_path = $image; | ||
| 2889 : | $image_virt = $image_path; | ||
| 2890 : | $imginfo = $this->platform->getimagesize($image_virt); | ||
| 2891 : | $ratio = max($imginfo[0], $imginfo[1]) / $this->_CONFIG['size']; | ||
| 2892 : | $ratio = max($ratio, 1.0); | ||
| 2893 : | $imgWidth = (int)($imginfo[0] / $ratio); | ||
| 2894 : | $imgHeight = (int)($imginfo[1] / $ratio); | ||
| 2895 : | } | ||
| 2896 : | } elseif ($this->isAudio($tag)) { | ||
| 2897 : | $image_virt = $mosConfig_live_site."/components/com_zoom/www/images/filetypes/audio.png"; | ||
| 2898 : | $imgWidth = $imgHeight = 64; | ||
| 2899 : | } elseif ($this->isDocument($tag)) { | ||
| 2900 : | $image_virt = $mosConfig_live_site."/components/com_zoom/www/images/filetypes/document.png"; | ||
| 2901 : | $imgWidth = $imgHeight = 64; | ||
| 2902 : | } elseif ($this->isMovie($tag)) { | ||
| 2903 : | $image_virt = $mosConfig_live_site."/components/com_zoom/www/images/filetypes/video.png"; | ||
| 2904 : | $imgWidth = $imgHeight = 64; | ||
| 2905 : | } | ||
| 2906 : | echo ("\t\t\t<tr class=\"".$bgcolor."\">\n" | ||
| 2907 : | . "\t\t\t\t<td align=\"center\" width=\"10\"><input type=\"checkbox\" name=\"scannedimg[]\" value=\"".$this->_counter."\" id=\"mediumno_$i\" checked></td>\n" | ||
| 2908 : | . "\t\t\t\t<td width=\"100%\"><span onmousedown=\"document.getElementById('mediumno_$i').checked = (document.getElementById('mediumno_$i').checked ? false : true);\">".$image."</span><br />\n"); | ||
| 2909 : | if ($this->isImage($tag)) { | ||
| 2910 : | echo ("\t\t\t\t\t<input type=\"checkbox\" name=\"rotate[]\" value=\"1\">"._ZOOM_ROTATE." \n" | ||
| 2911 : | . "\t\t\t\t\t<input type=\"radio\" name=\"rotate".$this->_counter."\" value=\"90\">"._ZOOM_CLOCKWISE."\n" | ||
| 2912 : | . "\t\t\t\t\t<input type=\"radio\" name=\"rotate".$this->_counter."\" value=\"-90\">"._ZOOM_CCLOCKWISE."\n" | ||
| 2913 : | . "\t\t\t\t</td>\n"); | ||
| 2914 : | } else { | ||
| 2915 : | echo ("\t\t\t\t</td>\n"); | ||
| 2916 : | } | ||
| 2917 : | echo ("\t\t\t\t<td><img src=\"".$image_virt."\" border=\"0\" width=\"".$imgWidth."\" height=\"".$imgHeight."\"></td>\n" | ||
| 2918 : | . "\t\t\t</tr>\n"); | ||
| 2919 : | $tabcnt++ ; | ||
| 2920 : | $this->_counter++; | ||
| 2921 : | } | ||
| 2922 : | echo ("\t\t\t<tr$header_class>\n" | ||
| 2923 : | . "\t\t\t\t<th height=\"20\" align=\"center\" align=\"left\"><input type=\"checkbox\" name=\"checkall\" onclick=\"checkUncheckAll(this, 'scannedimg[]');\" id=\"checkall\" checked></th>\n" | ||
| 2924 : | . "\t\t\t\t<th height=\"20\" colspan=\"20\" align=\"left\" onmousedown=\"document.getElementById('checkall').checked = (document.getElementById('checkall').checked ? false : true);checkUncheckAll(document.getElementById('checkall'), 'scannedimg[]');\">\n" | ||
| 2925 : | . "\t\t\t<strong><label onclick=\"javascript: return (document.getElementById('checkall') ? false : true);checkUncheckAll(document.getElementById('checkall'), 'scannedimg[]');\" for=\"checkall\">"._ZOOM_HD_CHECKALL."</label></strong>\n" | ||
| 2926 : | . "\t\t\t\t</th>\n" | ||
| 2927 : | . "\t\t\t</tr>\n" | ||
| 2928 : | . "\t\t\t</table>\n"); | ||
| 2929 : | } | ||
| 2930 : | //--------------------END content-creation functions-------------------// | ||
| 2931 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

