| | Copyright: copyright (C) 2004 by Mike de Boer | | Description: zOOm Image Gallery, a multi-gallery component for | | Mambo based on RSGallery by Ronald Smit. It's the most | | feature-rich gallery component for Mambo! | | Filename: zoom.class.php | | Version: 2.1.4 | | | ----------------------------------------------------------------------- **/ // MOS Intruder Alerts defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); class zoom{ //first, some of the default internal variables... var $_sql = null; var $_result = null; var $_CONFIG = null; var $_toolbox = null; var $_EditMon = null; var $_gallery = null; var $_ecard = null; var $_counter = null; var $_isAdmin = null; var $_isUser = null; var $_CurrUID = null; var $_startRow = null; var $_pageSize = null; var $_tabclass = null; var $_EXIF_cachefile = null; var $_CAT_LIST = null; var $_isWin = null; var $_isBackend = null; var $_tempname = null; //--------------------Default Constructor of the zOOm-class------------// function zoom(){ // initialize object variables with some values... $this->getConfig(); $this->_currUID = -1; $this->checkAdmin(true); $this->checkAdmin(false); $this->_counter = 0; $this->_startRow = 0; $this->_tabclass = Array("sectiontableentry1", "sectiontableentry2"); $this->_EXIF_cachefile = "exif.dat"; $this->_isWin = $this->_isWin = (strtolower(PHP_OS) == 'winnt'); $this->_isBackend = false; // get child-objects... $this->_EditMon = new editmon(); } function isWin(){ return $this->_isWin; } //--------------------END Constructor of the zOOm-class----------------// //--------------------zOOm Security Functions--------------------------// function checkAdmin($admin){ global $my; $gid = intval( $my->gid ); $username = $my->username; $usertype_lft = $this->getUsertypeLft(); if($admin){ if(strtolower($my->usertype) == 'administrator' || strtolower($my->usertype) == 'superadministrator' || strtolower($my->usertype) == 'super administrator'){ $this->_isAdmin = true; }else{ $this->_isAdmin = false; } }elseif($usertype_lft >= $this->_CONFIG['utype']){ $this->_isUser = true; }else{ $this->_isUser = false; } $this->_CurrUID = $my->id; } function getUsertypeLft(){ global $database, $my; $database->setQuery("SELECT lft FROM #__core_acl_aro_groups WHERE name = '".$my->usertype."' LIMIT 1"); if ($this->_result = $database->query()) { $row = mysql_fetch_object($this->_result); return $row->lft; } } function getUsersList($userspass = 0){ global $database; // Create users List $database->setQuery("SELECT id,name,username FROM #__users ORDER BY name ASC"); if ($this->_result = $database->query()) { $musers = array(); $musers = array(""; return $musers; } } //--------------------END zOOm Security Functions----------------------// //--------------------Filesystem Functions-----------------------------// function ftp_rmAll($conn_id,$dst_dir){ $ar_files = ftp_nlist($conn_id, $dst_dir); foreach($ar_files as $dir){ if($dir != "." && $dir != ".."){ if(ftp_size($conn_id,$dir)===-1){ // dirname $this->ftp_rmAll($conn_id,$dir); // recursion }else{ ftp_delete($conn_id,$dir); // del file } } } ftp_rmdir($conn_id, $dst_dir); // delete empty directories } function deldir($dir){ global $zoom; if($zoom->_CONFIG['safemodeON']){ //initialize FTP connection $conn_id = ftp_connect($zoom->_CONFIG['ftp_server']); // login $login_result = ftp_login($conn_id, $zoom->_CONFIG['ftp_username'], $zoom->_CONFIG['ftp_pass']); // verify connection if ((!$conn_id) || (!$login_result)){ echo ("Error connecting FTP
\n" . "Error connecting to FTP-Server ".$zoom->_CONFIG['ftp_server']." for user ".$zoom->_CONFIG['ftp_username']); return false; }else{ //create directory //$result = ftp_rmdir($conn_id,$path);//this won't work with subdirectory $this->ftp_rmAll($conn_id, $dir); //do it recursively with helper function } //Close connection ftp_quit($conn_id); return true; }else{ $current_dir = opendir($dir); while($entryname = readdir($current_dir)){ if(fs_is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ $this->deldir("${dir}/${entryname}"); }elseif($entryname != "." and $entryname!=".."){ fs_unlink("${dir}/${entryname}"); } } closedir($current_dir); rmdir(${dir}); return true; } } function newdir(){ $newdir = ""; srand((double) microtime() * 1000000); for ($acc = 1; $acc <= 6; $acc++){ $newdir .= chr(rand (0,25) + 65); } return $newdir; } function createdir($path, $mode = 0777){ global $mosConfig_absolute_path; if($zoom->_CONFIG['safemodeON']){ //append directory on host to the path... $path = $this->_CONFIG['ftp_hostdir']."/".$path; //initialize FTP connection $conn_id = ftp_connect($zoom->_CONFIG['ftp_server']); // login $login_result = ftp_login($conn_id, $this->_CONFIG['ftp_username'], $this->_CONFIG['ftp_pass']); // verify connection if ((!$conn_id) || (!$login_result)){ echo ("Error connecting FTP
\n" . "Error connecting to FTP-Server $ftp_server for user $ftp_user_name"); exit(); }else{ //create directory //$result = ftp_mkdir($conn_id,$path); //this won't work with subdirectorys $dir = split("/", $path); $path = ""; $result = true; for ($i = 1; $i < count($dir); $i++){ $path .= "/".$dir[$i]; //echo "$path\n"; if(!@ftp_chdir($conn_id,$path)){ @ftp_chdir($conn_id,"/"); if(!@ftp_mkdir($conn_id,$path)){ $result = false; break; }else{ //@ftp_chmod($conn_id, $mode, $path); //this gives problems with some servers $chmod_cmd="CHMOD ".$mode." ".$path; $chmod=ftp_site($conn_id, $chmod_cmd); } } } } //Close connection ftp_quit($conn_id); }else{ //append full path to Mambo to the $path variable... $path = $mosConfig_absolute_path."/".$path; $result = fs_mkdir($path, $mode); @chmod($path, $mode); } return $result; } function writefile($filename, $content){ if ($fp = fs_fopen("$filename", "w+")) { fputs($fp, $content, strlen($content)); fclose ($fp); return true; } } function extractArchive($extractdir, $archivename){ global $mosConfig_absolute_path, $version; $zlib_prefix = "$mosConfig_absolute_path/administrator/includes/pcl/"; require_once( $zlib_prefix."pclzip.lib.php" ); $zipfile = new PclZip($archivename); if($this->_isWin) define('OS_WINDOWS',1); $ret = $zipfile->extract(PCLZIP_OPT_PATH, $extractdir); if($ret <= 0) return false; else return true; } function createArchive($filelist, $archivename, $remove_dir){ global $mosConfig_absolute_path, $version; $zlib_prefix = "$mosConfig_absolute_path/administrator/includes/pcl/"; require_once( $zlib_prefix."pclzip.lib.php" ); $zipfile = new PclZip($archivename); if($this->_isWin) define('OS_WINDOWS',1); $ret = $zipfile->create($filelist, '', $remove_dir); if($ret <= 0) return false; else return true; } //--------------------END Filesystem Functions-------------------------// //--------------------Accepted file format functions-------------------// function acceptableFormat($tag){ return ($this->isImage($tag) || $this->isMovie($tag) || $this->isDocument($tag)); } function acceptableFormatRegexp(){ return "(" . join("|", $this->acceptableFormatList()) . ")"; } function acceptableFormatCommaSep(){ return join(", ", $this->acceptableFormatList()); } function acceptableMovieList(){ return array('avi', 'mpg', 'mpeg', 'wmv', 'mov', 'rm'); } function acceptableImageList(){ return array('jpg', 'jpeg', 'gif', 'png'); } function acceptableDocumentList(){ return array('doc', 'ppt', 'pdf', 'rtf'); } function thumbnailableMovieList(){ // this list doesn't have to be this big, BUT these are the formats supported by FFmpeg... return array('avi', 'ac3', 'asf', 'asx', 'dv', 'm4v', 'mpg', 'mpeg', 'mjpeg', 'mov', 'mp4', 'm4a', 'rm', 'rpm', 'wc3', 'wmv'); } function thumbnailableList(){ return array_merge($this->acceptableImageList(), $this->thumbnailableMovieList()); } function indexableList(){ return array('pdf'); } function acceptableFormatList(){ return array_merge($this->acceptableImageList(), $this->acceptableMovieList(), $this->acceptableDocumentList()); } function isImage($tag){ return in_array($tag, $this->acceptableImageList()); } function isMovie($tag){ return in_array($tag, $this->acceptableMovieList()); } function isRealmedia($tag){ if($tag == 'rm') return true; else return false; } function isQuicktime($tag){ if($tag == 'mov') return true; else return false; } function isDocument($tag){ return in_array($tag, $this->acceptableDocumentList()); } function isThumbnailable($tag){ return in_array($tag, $this->thumbnailableList()); } function isIndexable($tag){ return in_array($tag, $this->indexableList()); } //--------------------END Accepted file format functions---------------// //--------------------Module auto-detection----------------------------// function getModule(){ global $database; $database->setQuery("SELECT title FROM #__modules WHERE module = 'mod_zoom'"); if ($this->_result = $database->query()) { if(mysql_num_rows($this->_result) != 0){ return true; }else{ return false; } }else{ return false; } } //--------------------END Module auto-detection------------------------// //--------------------Cleaning String-datatype-------------------------// function cleanString($testString) { $forbidString=array("","",""); $looper=count($forbidString)-1; foreach($forbidString as $value) { $pos=strpos($testString,$value); if (is_integer($pos)) { $subFinish=$pos+strlen($value); $front=substr($testString,0,$pos); $end=substr($testString,$subFinish); $testString=$front.$end; } } return $testString; } function removeTags($msg) { $msg = strip_tags($msg); return $msg; } //--------------------END Cleaning Strings Datatype--------------------// //--------------------Date Handling functions--------------------------// function convertDate($zdate){ // converts zooms date to an unix string and returns then local date as defined in the language string $tmp_year = substr( $zdate, 6, 2 ); // year $tmp_mon = substr( $zdate, 3, 2 ); // month $tmp_day = substr( $zdate, 0, 2 ); // day $tmp_hour = substr( $zdate, 10, 2 ); // hour $tmp_min = substr( $zdate, 13, 2 ); // min $tmp_sec = substr( $zdate, 16, 2 ); // sec $new_date = mktime( $tmp_hour, $tmp_min, $tmp_sec, $tmp_mon, $tmp_day, $tmp_year ); $newdate = strftime ( _ZOOM_DATEFORMAT, $new_date ); return $newdate; } //--------------------END Date Handling functions----------------------// //--------------------Database Editing Functions-----------------------// function getConfig(){ global $database, $mosConfig_absolute_path, $zoomConfig; $this->_CONFIG['conversiontype'] = $zoomConfig['conversiontype']; $this->_CONFIG['zoom_title'] = $zoomConfig['zoom_title']; $this->_CONFIG['imagepath'] = $zoomConfig['imagepath']; $this->_CONFIG['IM_path'] = $zoomConfig['IM_path']; $this->_CONFIG['NETPBM_path'] = $zoomConfig['NETPBM_path']; $this->_CONFIG['FFMPEG_path'] = $zoomConfig['FFMPEG_path']; $this->_CONFIG['PDF_path'] = $zoomConfig['PDF_path']; $this->_CONFIG['JPEGquality'] = $zoomConfig['JPEGquality']; $this->_CONFIG['maxsize'] = $zoomConfig['maxsize']; $this->_CONFIG['size'] = $zoomConfig['size']; $this->_CONFIG['columnsno'] = $zoomConfig['columnsno']; $this->_CONFIG['PageSize'] = $zoomConfig['PageSize']; $this->_CONFIG['catOrderMethod'] = $zoomConfig['catOrderMethod']; $this->_CONFIG['orderMethod'] = $zoomConfig['orderMethod']; $this->_CONFIG['commentsOn'] = $zoomConfig['commentsOn']; $this->_CONFIG['cmtLength'] = $zoomConfig['cmtLength']; $this->_CONFIG['galleryPrefix'] = $zoomConfig['galleryPrefix']; $this->_CONFIG['ratingOn'] = $zoomConfig['ratingOn']; $this->_CONFIG['zoomOn'] = $zoomConfig['zoomOn']; $this->_CONFIG['popUpImages'] = $zoomConfig['popUpImages']; $this->_CONFIG['catImg'] = $zoomConfig['catImg']; $this->_CONFIG['slideshow'] = $zoomConfig['slideshow']; $this->_CONFIG['displaylogo'] = $zoomConfig['displaylogo']; $this->_CONFIG['allowUserUpload'] = $zoomConfig['allowUserUpload']; $this->_CONFIG['readEXIF'] = $zoomConfig['readEXIF']; $this->_CONFIG['tempDescr'] = $zoomConfig['tempDescr']; $this->_CONFIG['tempName'] = $zoomConfig['tempName']; $this->_CONFIG['autonumber'] = $zoomConfig['autonumber']; $this->_CONFIG['showHits'] = $zoomConfig['showHits']; $this->_CONFIG['showName'] = $zoomConfig['showName']; $this->_CONFIG['showDescr'] = $zoomConfig['showDescr']; $this->_CONFIG['showKeywords'] = $zoomConfig['showKeywords']; $this->_CONFIG['showDate'] = $zoomConfig['showDate']; $this->_CONFIG['showFilename'] = $zoomConfig['showFilename']; $this->_CONFIG['showSearch'] = $zoomConfig['showSearch']; $this->_CONFIG['showMetaBox'] = $zoomConfig['showMetaBox']; $this->_CONFIG['catcolsno'] = $zoomConfig['catcolsno']; $this->_CONFIG['utype'] = $zoomConfig['utype']; $this->_CONFIG['lightbox'] = $zoomConfig['lightbox']; $this->_CONFIG['ecards'] = $zoomConfig['ecards']; $this->_CONFIG['ecards_lifetime'] = $zoomConfig['ecards_lifetime']; $this->_CONFIG['zoomModule'] = $zoomConfig['zoomModule']; $this->_CONFIG['allowUserCreate'] = $zoomConfig['allowUserCreate']; $this->_CONFIG['allowUserDel'] = $zoomConfig['allowUserDel']; $this->_CONFIG['allowUserEdit'] = $zoomConfig['allowUserEdit']; $this->_CONFIG['safemodeON'] = $zoomConfig['safemodeON']; $this->_CONFIG['version'] = $zoomConfig['version']; $this->_CONFIG['safemodeversion'] = $zoomConfig['safemodeversion']; if(strlen($this->_CONFIG['safemodeversion']) > 0){ require_once($mosConfig_absolute_path."/components/com_zoom/safemode.php"); $this->_CONFIG['ftp_server'] = $ftp_server; $this->_CONFIG['ftp_username'] = $ftp_username; $this->_CONFIG['ftp_pass'] = $ftp_pass; $this->_CONFIG['ftp_hostdir'] = $ftp_hostdir; } } function saveConfig(){ global $database, $_REQUEST, $mosConfig_absolute_path; $s01 = mysql_escape_string($_REQUEST['s01']); $s02 = mysql_escape_string($_REQUEST['s02']); $s03 = mysql_escape_string($_REQUEST['s03']); $s04 = mysql_escape_string($_REQUEST['s04']); $s05 = mysql_escape_string($_REQUEST['s05']); $s06 = mysql_escape_string($_REQUEST['s06']); $s07 = mysql_escape_string($_REQUEST['s07']); $s08 = mysql_escape_string($_REQUEST['s08']); $s09 = mysql_escape_string($_REQUEST['s09']); $s10 = mysql_escape_string($_REQUEST['s10']); $s11 = mysql_escape_string($_REQUEST['s11']); $s12 = mysql_escape_string($_REQUEST['s12']); $s13 = mysql_escape_string($_REQUEST['s13']); $s14 = mysql_escape_string($_REQUEST['s14']); $s15 = mysql_escape_string($_REQUEST['s15']); $s16 = mysql_escape_string($_REQUEST['s16']); $s17 = mysql_escape_string($_REQUEST['s17']); // s18 is the CSS textarea...thus skipped. $s19 = mysql_escape_string($_REQUEST['s19']); $s20 = mysql_escape_string($_REQUEST['s20']); $s21 = (isset($HTTP_POST_VARS['s21'])) ? 1 : 0; $s22 = mysql_escape_string($_REQUEST['s22']); $s23 = mysql_escape_string($_REQUEST['s23']); $s24 = mysql_escape_string($_REQUEST['s24']); $s25 = mysql_escape_string($_REQUEST['s25']); $s26 = mysql_escape_string($_REQUEST['s26']); $s27 = mysql_escape_string($_REQUEST['s27']); $s28 = mysql_escape_string($_REQUEST['s28']); $s29 = mysql_escape_string($_REQUEST['s29']); $s30 = mysql_escape_string($_REQUEST['s30']); $s31 = mysql_escape_string($_REQUEST['s31']); $s32 = mysql_escape_string($_REQUEST['s32']); $s33 = mysql_escape_string($_REQUEST['s33']); $s34 = mysql_escape_string($_REQUEST['s34']); $s35 = mysql_escape_string($_REQUEST['s35']); $s36 = mysql_escape_string($_REQUEST['s36']); $s37 = mysql_escape_string($_REQUEST['s37']); $s38 = mysql_escape_string($_REQUEST['s38']); $s39 = mysql_escape_string($_REQUEST['s39']); $s40 = mysql_escape_string($_REQUEST['s40']); $s41 = mysql_escape_string($_REQUEST['s41']); $s42 = mysql_escape_string($_REQUEST['s42']); $s43 = mysql_escape_string($_REQUEST['s43']); $s44 = mysql_escape_string($_REQUEST['s44']); $s45 = mysql_escape_string($_REQUEST['s45']); if(strlen($zoom->_CONFIG['safemodeversion']) > 0){ $s46 = mysql_escape_string($_REQUEST['s46']); }else{ $s46 = 0; } // variables s47 till s49 are in use by the ftp feature and handled separately. $s50 = mysql_escape_string($_REQUEST['s50']); $s51 = mysql_escape_string($_REQUEST['s51']); // variable s52 is in use by the ftp feature and handled seperately. if(!isset($s29) || empty($s29)) $s29 = 0; // the representation and meaning of each s-variable explains itself // in the following sql-statement: $cfg_content = "_CONFIG['version']}\";\n"; $cfg_content .= "\$zoomConfig['safemodeversion'] = \"{$this->_CONFIG['safemodeversion']}\";\n"; $cfg_content .= "?>"; $cfg_file = $mosConfig_absolute_path.'/components/com_zoom/zoom_config.php'; @chmod ($cfg_file, 0766); $permission = is_writable($cfg_file); if (!$permission) { echo "Error: zOOm Configuration file ".$cfg_file." is not writable!"; exit(); } $this->writefile($cfg_file, $cfg_content); // now save the usermenu-item link, if the s33 was checked or delete it otherwise... if($s33 == 1 && !$this->issetUserMenu()){ // all ok, insert menu-option... $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','')"); $database->query(); }elseif($s33 == 0 && $theId = $this->issetUserMenu()){ $database->setQuery("DELETE FROM #__menu WHERE id = ".$theId); $database->query(); } return true; } // this function will be moved to the image.class.php (doesn't belong here anymore...) function saveImage($filename, $keywords, $name, $descr, $catid){ global $database; $uid = $this->_CurrUID; $database->setQuery("INSERT INTO #__zoomfiles (imgfilename,imgname, imgkeywords, imgdescr, imgdate, catid, uid, imgmembers) VALUES ('".mysql_escape_string($filename)."', '".mysql_escape_string($name)."', '".mysql_escape_string($keywords)."','".mysql_escape_string($descr)."', now(), '".mysql_escape_string($catid)."', '$uid', '1')"); if ($database->query()) { return true; }else{ return false; } } function optimizeTables(){ global $database; $database->setQuery("OPTIMIZE TABLE `#__zoom`"); $database->query(); $database->setQuery("OPTIMIZE TABLE `#__zoomfiles`"); $database->query(); $database->setQuery("OPTIMIZE TABLE `#__zoom_comments`"); $database->query(); $database->setQuery("OPTIMIZE TABLE `#__zoom_editmon`"); $database->query(); } //--------------------END Database Editing Functions-------------------// //--------------------Database Querying Functions----------------------// function getSmiliesTable(){ //gentle solution to avoid the use of the pompous smilies-table //from the authors of phpBB... return array( array(':!:', 'icon_exclaim.gif', 'Exclamation'), array(':?:', 'icon_question.gif', 'Question'), array(':D', 'icon_biggrin.gif', 'Very Happy'), array(':d', 'icon_biggrin.gif', 'Very Happy'), array(':-D', 'icon_biggrin.gif', 'Very Happy'), array(':grin:', 'icon_biggrin.gif', 'Very Happy'), array(':)', 'icon_smile.gif', 'Smile'), array(':-)', 'icon_smile.gif', 'Smile'), array(':smile:', 'icon_smile.gif', 'Smile'), array(':(', 'icon_sad.gif', 'Sad'), array(':-(', 'icon_sad.gif', 'Sad'), array(':sad:', 'icon_sad.gif', 'Sad'), array(':o', 'icon_surprised.gif', 'Surprised'), array(':-o', 'icon_surprised.gif', 'Surprised'), array(':eek:', 'icon_surprised.gif', 'Surprised'), array(':shock:', 'icon_eek.gif', 'Shocked'), array(':?', 'icon_confused.gif', 'Confused'), array(':-?', 'icon_confused.gif', 'Confused'), array(':???:', 'icon_confused.gif', 'Confused'), array('8)', 'icon_cool.gif', 'Cool'), array('8-)', 'icon_cool.gif', 'Cool'), array(':cool:', 'icon_cool.gif', 'Cool'), array(':lol:', 'icon_lol.gif', 'Laughing'), array(':x', 'icon_mad.gif', 'Mad'), array(':-x', 'icon_mad.gif', 'Mad'), array(':mad:', 'icon_mad.gif', 'Mad'), array(':P', 'icon_razz.gif', 'Razz'), array(':p', 'icon_razz.gif', 'Razz'), array(':-P', 'icon_razz.gif', 'Razz'), array(':razz:', 'icon_razz.gif', 'Razz'), array(':oops:', 'icon_redface.gif', 'Embarassed'), array(':cry:', 'icon_cry.gif', 'Crying or Very sad'), array(':evil:', 'icon_evil.gif', 'Evil or Very Mad'), array(':twisted:', 'icon_twisted.gif', 'Twisted Evil'), array(':roll:', 'icon_rolleyes.gif', 'Rolling Eyes'), array(':wink:', 'icon_wink.gif', 'Wink'), array(';)', 'icon_wink.gif', 'Wink'), array(';-)', 'icon_wink.gif', 'Wink'), array(':idea:', 'icon_idea.gif', 'Idea'), array(':arrow:', 'icon_arrow.gif', 'Arrow'), array(':|', 'icon_neutral.gif', 'Neutral'), array(':-|', 'icon_neutral.gif', 'Neutral'), array(':neutral:', 'icon_neutral.gif', 'Neutral'), array(':mrgreen:', 'icon_mrgreen.gif', 'Mr. Green') ); } function getCatList($parent, $ident='', $ident2=''){ global $database; // The author of Coppermine Gallery inspired me for this piece of code. // Main trick is the use of recursion. For every sub-category (or each level, // or each value of pos) the entire method is called again. And so on...and so on... $database->setQuery("SELECT catid, catname, shared, uid FROM #__zoom WHERE subcat_id=$parent ORDER BY pos"); $this->_result = $database->query(); $rowset = Array(); while($row = mysql_fetch_array($this->_result)) $rowset[] = $row; foreach($rowset as $subcat){ if(!$this->_isAdmin){ if(($subcat['uid'] == $this->_CurrUID) || ($subcat['shared'] == 1)){ $this->_CAT_LIST[] = array( 'id' => $subcat['catid'], 'catname' => $ident.$subcat['catname'], 'virtpath' => $ident2.$subcat['catname']); } }else{ $this->_CAT_LIST[] = array( 'id' => $subcat['catid'], 'catname' => $ident.$subcat['catname'], 'virtpath' => $ident2.$subcat['catname']); } $this->getCatList($subcat['catid'], $ident.'> ', $ident2.$subcat['catname'].'> '); } } function getKeywordsList(){ global $database; $database->setQuery("SELECT cat.catkeywords, img.imgkeywords FROM #__zoom AS cat, #__zoomfiles AS img WHERE cat.published = 1 AND img.published = 1 AND cat.catkeywords <> '' AND img.imgkeywords <> ''"); $this->_result = $database->query(); $keywords = array(); $newkeys = array(); $allkeys = array(); $catrow = array(); $imgrow = array(); // first, put the keywords from both columns into arrays... while($row = mysql_fetch_object($this->_result)){ $catrow[] = (!empty($row->catkeywords)) ? $row->catkeywords : ""; $imgrow[] = (!empty($row->imgkeywords)) ? $row->imgkeywords : ""; } // combine those two arrays... $allkeys = array_merge($catrow, $imgrow); // now, delete empty rows... $this->_counter = 0; foreach ($allkeys as $akey){ if(!empty($akey)) $newkeys[] = $akey; } // then, get each individual keyword and put it into the array '$keywords' foreach ($newkeys as $newkey){ $temp = explode(",", $newkey); if(is_array($temp)){ foreach ($temp as $t){ if(!empty($t)){ $keywords[] = $t; } } } } // remove duplicate keywords... $keywords = array_unique($keywords); sort($keywords); return $keywords; } function getItemid($option){ global $database; $database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=".mysql_escape_string($option)."'"); if ($this->_result = $database->query()) { $row = mysql_fetch_object($this->_result); return $row->id; } } function getOrderMethod(){ switch ($this->_CONFIG['orderMethod']){ case 1: return "imgname ASC"; break; case 2: return "imgname DESC"; break; case 3: return "imgfilename ASC"; break; case 4: return "imgfilename DESC"; break; case 5: return "imgdate ASC"; break; case 6: return "imgdate DESC"; break; } } function getCatOrderMethod(){ // manual gallery ordering will be added later on... switch ($this->_CONFIG['catOrderMethod']){ case 1: return "catid ASC"; break; case 2: return "catid DESC"; break; case 3: return "catname ASC"; break; case 4: return "catname DESC"; break; } } function setGallery($gallery_id, $galleryview = false){ $this->_gallery = null; $this->_gallery = new gallery($gallery_id, $galleryview); } function setEcard($id = 0){ $this->_ecard = null; $this->_ecard = new ecard($id); } function issetUserMenu(){ global $database; $database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_zoom&page=admin' LIMIT 1"); if ($this->_result = $database->query()) { if(mysql_num_rows($this->_result) > 0){ $row = mysql_fetch_object($this->_result); return $row->id; }else{ return false; } } } function checkDuplicate($filename){ global $database; $database->setQuery("SELECT imgid FROM #__zoomfiles WHERE imgfilename = '$filename'"); if($this->_result = $database->query()){ if(mysql_num_rows($this->_result) > 0){ // filename exists already in the database, so change the filename and test again... // the filename will be changed accordingly: // if a filename exists, add the suffix _{number} incrementally, // thus 'afile_1.jpg' will become 'afile_2.jpg' and so on... $newname = preg_replace( "/^(.+?)(_?)(\d*)(\.[^.]+)?$/e", "'\$1_'.(\$3+1).'\$4'", $filename ); $this->checkDuplicate($newname, $tag); }else{ $this->_tempname = $filename; } }else{ $this->_tempname = $filename; } } //--------------------END Database Querying Functions------------------// //--------------------HTML content-creation functions------------------// function createSlideshow($key){ global $zoom, $mosConfig_live_site; ?>

zOOm Media Gallery _CONFIG['version'];?>
Copyright © 2004 by Mike de Boer.
© 2004 FOOOD's Icons. All rights reserved. COMMERCIAL! Visit him at Foood.net

'; }elseif ($onchange==1){ $html = ''; } function createKeywordsDropdown($sel_name, $first_opt, $onchange=0, $sel=0){ if ($onchange==0){ $html = "\n"; } $html .= $first_opt; $keywords = $this->getKeywordsList(); if(isset($keywords)){ foreach($keywords as $keyword){ $html.= "\n"; } } return $html."\n"; } function createCatDeleteForm(){ // This function creates the table of edit.php...it uses the 'virtpath'-column // of the internal CAT_LIST variable. Check the 'getCatList()' function for more details... global $Itemid; $html = ''; $this->_CAT_LIST = null; $this->getCatList(0, '> ', '> '); $i = 0; if(isset($this->_CAT_LIST)){ foreach($this->_CAT_LIST as $category){ $i++; $bgcolor = ($i & 1); // ? $$this->_tabclass[1] : $this->_tabclass[0]; $edit_link = "index"; if($this->_isBackend){ $edit_link .= "2"; } $edit_link .= ".php?option=com_zoom&page=catsmgr&task=edit&catid=".$category['id']."&Itemid=".$Itemid; $html .= ("\n\t\n" . "\t\t" . "\n\t\t".$category['virtpath']."\n" . "\t\n"); } } return $html; } function createMediaEditForm(){ global $Itemid; $this->_counter = 0; global $mosConfig_live_site, $mosConfig_absolute_path; $this->createCheckAllScript(); $tabcnt = 0; $this->_counter = 0; echo ("\n" . "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n"); foreach($this->_gallery->_images as $image){ $image->getInfo(); if($tabcnt > 1) $tabcnt = 0; $tag = ereg_replace(".*\.([^\.]*)$", "\\1", $image->_filename); $edit_link = "index"; if ($this->_isBackend) { $edit_link .= "2"; } $edit_link .= ".php?option=com_zoom&page=mediamgr&task=edit&catid=".$image->_catid."&keys=".$this->_counter."&Itemid=".$Itemid; echo ("\t\t\t_tabclass[$tabcnt]."\">\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n"); }else{ echo ("\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n"); } $tabcnt++ ; $this->_counter++; } echo ("\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n" . "\t\t\t
"._ZOOM_HD_CHECK.""._ZOOM_NAME.""._ZOOM_FILENAME.""._ZOOM_HD_PREVIEW."
_counter."\">".$image->_name."
".$image->_filename."
\n"); if ($this->isImage($tag)) { echo ("\t\t\t\t
_thumbnail."\" border=\"0\" />
 
"._ZOOM_HD_CHECKALL."\n" . "\t\t\t\t
\n"); } function createFileChooseForm($userfile, $userfile_name){ global $Itemid; $this->_counter = 0; $html = '
'; $html .= ''; $html .= ''; foreach ($userfile as $file){ $html.= ''; $html .= ''; $this->_counter++; } $html.= ''; $html .= '
 '._ZOOM_FILENAME.'
'.$file.'
'._ZOOM_HD_CHECKALL.'
'; return $html; } function createACLgroupList(){ global $database; $database->setQuery("SELECT lft, name FROM #__core_acl_aro_groups WHERE lft < 13 AND lft > 3 ORDER BY lft"); $this->_result = $database->query(); $html = ''; return $html; } function createFileList(&$imagelist, $extractloc = ""){ global $mosConfig_live_site, $mosConfig_absolute_path; $this->createCheckAllScript(); $tabcnt = 0; $this->_counter = 0; echo ("\n" . "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n"); foreach($imagelist as $image){ if($tabcnt > 1) $tabcnt = 0; $tag = ereg_replace(".*\.([^\.]*)$", "\\1", $image); if ($this->isImage($tag)) { if (!fs_is_file($image)) { $image_path = $mosConfig_absolute_path.$extractloc."/".$image; $image_virt = $mosConfig_live_site.$extractloc."/".$image; $imginfo = getimagesize($image_path); $ratio = max($imginfo[0], $imginfo[1]) / $this->_CONFIG['size']; $ratio = max($ratio, 1.0); $imgWidth = (int)($imginfo[0] / $ratio); $imgHeight = (int)($imginfo[1] / $ratio); }else{ $image_path = $image; $image_virt = $image_path; $imginfo = getimagesize($image_path); $ratio = max($imginfo[0], $imginfo[1]) / $this->_CONFIG['size']; $ratio = max($ratio, 1.0); $imgWidth = (int)($imginfo[0] / $ratio); $imgHeight = (int)($imginfo[1] / $ratio); } } echo ("\t\t\t_tabclass[$tabcnt]."\">\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n"); }else{ echo ("\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n"); } $tabcnt++ ; $this->_counter++; } echo ("\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\n" . "\t\t\t
"._ZOOM_HD_CHECK.""._ZOOM_FILENAME.""._ZOOM_HD_PREVIEW."
_counter."\" checked>".$image."
\n"); if ($this->isImage($tag)) { echo ("\t\t\t\t\t"._ZOOM_ROTATE."$nbsp;\n" . "\t\t\t\t\t_counter."\" value=\"90\">"._ZOOM_CLOCKWISE."\n" . "\t\t\t\t\t_counter."\" value=\"-90\">"._ZOOM_CCLOCKWISE."\n" . "\t\t\t\t
 
"._ZOOM_HD_CHECKALL."\n" . "\t\t\t\t
\n"); } function highlight($it, $text){ $replacement = ''.quotemeta($it).''; return eregi_replace($it, $replacement, $text); } //--------------------END content-creation functions-------------------// }