Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _processCmsTags
  • addArtspec
  • addslashes_deep
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • endsWith
  • extractNumber
  • generateDisplayFilePath
  • generateInfoButton
  • generateJs
  • getAktuellType
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • modTestModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setHelpContext
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • stripslashes_deep
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • xmlFileToArray
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the backend page for displaying files of a directory in upload section.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       Backend
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Timo Hummel
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: $backendPath = cRegistry::getBackendPath();
 19: 
 20: cInclude('includes', 'api/functions.frontend.list.php');
 21: cInclude('includes', 'functions.file.php');
 22: cInclude('classes', 'class.cziparchive.php');
 23: 
 24: //cInclude('includes', 'class.ziparchive.php');
 25: 
 26: if (!(int) $client > 0) {
 27:     // if there is no client selected, display empty page
 28:     $oPage = new cGuiPage("upl_files_overview");
 29:     $oPage->render();
 30:     return;
 31: }
 32: 
 33: $appendparameters = $_REQUEST["appendparameters"];
 34: $file = $_REQUEST['file'];
 35: 
 36: if (!is_array($browserparameters) && ($appendparameters != "imagebrowser" || $appendparameters != "filebrowser")) {
 37:     $browserparameters = array();
 38: }
 39: 
 40: if (!$sess->isRegistered("upl_last_path")) {
 41:     // register last path (upl_last_path) in session
 42:     $sess->register("upl_last_path");
 43: } elseif (!isset($path)) {
 44:     // if no path is given the last path is used
 45:     $path = $upl_last_path;
 46: }
 47: // if path doesn't exist use root path
 48: // this might happen when the last path is that of another client or deleted outside CONTENIDO
 49: if (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]["upl"]["path"] . $path)) {
 50:     $path = '';
 51: }
 52: // remember current path as last path
 53: $upl_last_path = $path;
 54: 
 55: $uploads = new cApiUploadCollection();
 56: 
 57: $dbfs = new cApiDbfsCollection();
 58: 
 59: if (cApiDbfs::isDbfs($path)) {
 60:     $qpath = $path . "/";
 61: } else {
 62:     $qpath = $path;
 63: }
 64: 
 65: if ($path && $action != '') {
 66:     $sReloadScript = "<script type=\"text/javascript\">
 67:                         var left_bottom = parent.parent.frames['left'].frames['left_bottom'];
 68:                         if (left_bottom) {
 69:                             var href = left_bottom.location.href;
 70:                             href = href.replace(/&path.*/, '');
 71:                             left_bottom.location.href = href+'&path='+'" . $path . "';
 72:                             if (typeof top.content.left.left_top.refresh != 'undefined') {
 73:                                 top.content.left.left_top.refresh();
 74:                             }
 75:                         }
 76:                     </script>";
 77: } else {
 78:     $sReloadScript = "";
 79: }
 80: 
 81: if ((is_writable($cfgClient[$client]["upl"]["path"] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
 82:     $bDirectoryIsWritable = true;
 83: } else {
 84:     $bDirectoryIsWritable = false;
 85: }
 86: 
 87: 
 88: if ($action == "upl_modify_file") {
 89: 
 90:     $extractFolder = NULL;
 91:     $uplPath =  $cfgClient[$client]['upl']['path'];
 92: 
 93:     if (isset($_REQUEST['path']) && $_REQUEST['path'] != NULL) {
 94:         $uplPath .= $_REQUEST['path'];
 95:     }
 96: 
 97:     if (isset($_REQUEST['efolder']) && $_REQUEST['efolder'] != NULL ) {
 98:         $extractFolder = $_REQUEST['efolder'];
 99:     }
100: 
101:     if (isset($_REQUEST['extractZip']) && !isset($_REQUEST['overwrite'])) {
102:         $zipFile = $uplPath . $_REQUEST['file'];
103:         cZipArchive::extract($zipFile, $uplPath ,$extractFolder);
104:     }
105:     if (isset($_REQUEST['extractZip']) && isset($_REQUEST['overwrite'])) {
106:         $zipFile = $uplPath . $_REQUEST['file'];
107:         cZipArchive::extractOverRide($zipFile, $uplPath, $extractFolder);
108:     }
109:     // Did the user upload a new file?
110:     if ($bDirectoryIsWritable == true && count($_FILES) == 1 && ($_FILES["file"]["size"] > 0) && ($_FILES["file"]["name"] != "")) {
111:         if ($_FILES['file']['tmp_name'] != "") {
112:             $tmp_name = $_FILES['file']['tmp_name'];
113:             $_cecIterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPreprocess");
114: 
115:             if ($_cecIterator->count() > 0) {
116:                 // Copy file to a temporary location
117:                 move_uploaded_file($tmp_name, $backendPath . $cfg["path"]["temp"] . $file);
118:                 $tmp_name = $backendPath . $cfg["path"]["temp"] . $file;
119: 
120:                 while ($chainEntry = $_cecIterator->next()) {
121:                     if (cApiDbfs::isDbfs($path)) {
122:                         $sPathPrepend = '';
123:                         $sPathApppend = '/';
124:                     } else {
125:                         $sPathPrepend = $cfgClient[$client]['upl']['path'];
126:                         $sPathApppend = '';
127:                     }
128: 
129:                     $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name']));
130: 
131:                     if ($modified !== false) {
132:                         $tmp_name = $modified;
133:                     }
134:                 }
135:             }
136: 
137:             if (cApiDbfs::isDbfs($path)) {
138:                 $dbfs->writeFromFile($tmp_name, $qpath . $file);
139:                 unlink($_FILES['file']['tmp_name']);
140:             } else {
141:                 unlink($cfgClient[$client]['upl']['path'] . $path . $file);
142: 
143:                 if (is_uploaded_file($tmp_name)) {
144:                     move_uploaded_file($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
145:                 } else {
146:                     rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
147:                 }
148:             }
149:         }
150:     }
151: 
152:     $uploads->select("idclient = '$client' AND dirname = '$qpath' AND filename='$file'");
153:     $upload = $uploads->next();
154: 
155:     // $upload->set("description", stripslashes($description));
156:     $upload->store();
157: 
158:     $properties = new cApiPropertyCollection();
159:     $properties->setValue("upload", $qpath . $file, "file", "protected", stripslashes($protected));
160: 
161:     $bTimeMng = (isset($_REQUEST['timemgmt']) && strlen($_REQUEST['timemgmt']) > 1);
162:     $properties->setValue("upload", $qpath . $file, "file", "timemgmt", ($bTimeMng) ? 1 : 0);
163:     if ($bTimeMng) {
164:         $properties->setValue("upload", $qpath . $file, "file", "datestart", $_REQUEST['datestart']);
165:         $properties->setValue("upload", $qpath . $file, "file", "dateend", $_REQUEST['dateend']);
166:     }
167: 
168:     $author = $auth->auth['uid'];
169:     $created = date('Y-m-d H:i:s');
170: 
171:     $iIdupl = $upload->get("idupl");
172:     if (!empty($iIdupl) && $iIdupl > 0) {
173:         // check for new entry:
174:         $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
175:         if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
176:             // Update existing entry
177:             $oUploadMeta->set('medianame', $medianame);
178:             $oUploadMeta->set('description', $description);
179:             $oUploadMeta->set('keywords', $keywords);
180:             $oUploadMeta->set('internal_notice', $medianotes);
181:             $oUploadMeta->set('copyright', $copyright);
182:             $oUploadMeta->set('modified', $created);
183:             $oUploadMeta->set('modifiedby', $author);
184:             $oUploadMeta->store();
185:         } else {
186:             // Create new entry
187:             $oUploadMetaColl = new cApiUploadMetaCollection();
188:             $oUploadMeta = $oUploadMetaColl->create($iIdupl, $lang, $medianame, $description, $keywords, $medianotes, $copyright, $author, $created, $created, $author);
189:         }
190:     }
191: }
192: 
193: if ($action == "upl_multidelete" && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
194:     if (is_array($fdelete)) {
195:         // array of cApiUpload objects to be passed to chain function
196:         $uploadObjects = array();
197: 
198:         // Check if it is in the upload table
199:         foreach ($fdelete as $file) {
200:             $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
201:             if (false !== $item = $uploads->next()) {
202:                 if (cApiDbfs::isDbfs($qpath)) {
203:                     $dbfs->remove($qpath . $file);
204: 
205:                     // call chain once for each deleted file
206:                     $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.Delete");
207:                     if ($_cecIterator->count() > 0) {
208:                         while (false !== $chainEntry = $_cecIterator->next()) {
209:                             $chainEntry->execute($item->get('idupl'), $qpath, $file);
210:                         }
211:                     }
212:                 } else {
213:                     $uploads->delete($item->get('idupl'));
214:                     unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
215:                 }
216: 
217:                 // add current upload object to array in order to be processed
218:                 array_push($uploadObjects, $item);
219:             }
220:         }
221: 
222:         // call chain once for all deleted files
223:         $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.DeleteBatch");
224:         if ($_cecIterator->count() > 0) {
225:             while (false !== $chainEntry = $_cecIterator->next()) {
226:                 $chainEntry->execute($uploadObjects);
227:             }
228:         }
229:     }
230: }
231: 
232: if ($action == "upl_delete" && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
233:     // array of cApiUpload objects to be passed to chain function
234:     $uploadObjects = array();
235: 
236:     $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
237:     // FIXME Code is similar/redundant to cApiUploadCollection->delete(), in
238:     // previous version from UploadCollection->delete() too
239:     if (false !== $item = $uploads->next()) {
240:         if (cApiDbfs::isDbfs($qpath)) {
241:             $dbfs->remove($qpath . $file);
242:         } else {
243:             unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
244:         }
245: 
246:         // call chain for deleted file
247:         $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.Delete");
248:         if ($_cecIterator->count() > 0) {
249:             while (false !== $chainEntry = $_cecIterator->next()) {
250:                 $chainEntry->execute($uploads->f('idupl'), $qpath, $file);
251: 
252:                 // add current upload object to array in order to be processed
253:                 array_push($uploadObjects, $item);
254:             }
255:         }
256: 
257:         // call chain once for all deleted files
258:         $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.DeleteBatch");
259:         if ($_cecIterator->count() > 0) {
260:             while (false !== $chainEntry = $_cecIterator->next()) {
261:                 $chainEntry->execute($uploadObjects);
262:             }
263:         }
264:     }
265: }
266: 
267: if ($action == "upl_upload" && $bDirectoryIsWritable == true) {
268:     if (count($_FILES) == 1) {
269:         foreach ($_FILES['file']['name'] as $key => $value) {
270:             if (isUtf8($_FILES['file']['name'][$key])) {
271:                 $_FILES['file']['name'][$key] = utf8_decode($_FILES['file']['name'][$key]);
272:             }
273:             if ($_FILES['file']['tmp_name'][$key] != "") {
274:                 $tmp_name = $_FILES['file']['tmp_name'][$key];
275:                 $_cecIterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPreprocess");
276: 
277:                 if ($_cecIterator->count() > 0) {
278:                     // Copy file to a temporary location
279:                     move_uploaded_file($tmp_name, $backendPath . $cfg["path"]["temp"] . $_FILES['file']['name'][$key]);
280:                     $tmp_name = $backendPath . $cfg["path"]["temp"] . $_FILES['file']['name'][$key];
281: 
282:                     while ($chainEntry = $_cecIterator->next()) {
283:                         if (cApiDbfs::isDbfs($path)) {
284:                             $sPathPrepend = '';
285:                             $sPathApppend = '/';
286:                         } else {
287:                             $sPathPrepend = $cfgClient[$client]['upl']['path'];
288:                             $sPathApppend = '';
289:                         }
290: 
291:                         $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name'][$key]));
292:                         if ($modified !== false) {
293:                             $tmp_name = $modified;
294:                         }
295:                     }
296:                 }
297: 
298:                 if (cApiDbfs::isDbfs($qpath)) {
299:                     $dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
300:                     unlink($tmp_name);
301:                 } else {
302:                     if (is_uploaded_file($tmp_name)) {
303:                         $final_filename = $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]);
304: 
305:                         move_uploaded_file($tmp_name, $final_filename);
306: 
307:                         $iterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPostprocess");
308:                         while ($chainEntry = $iterator->next()) {
309:                             $chainEntry->execute($final_filename);
310:                         }
311:                     } else {
312:                         rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
313:                     }
314:                 }
315:             }
316:         }
317:     }
318: }
319: 
320: if ($action == "upl_renamefile" && $bDirectoryIsWritable == true) {
321:     $newname = str_replace("/", "", $newname);
322:     rename($cfgClient[$client]['upl']['path'] . $path . $oldname, $cfgClient[$client]['upl']['path'] . $path . $newname);
323: }
324: 
325: class UploadList extends FrontendList {
326: 
327:     var $dark;
328:     var $size;
329: 
330:     function convert($field, $data) {
331:         global $cfg, $path, $sess, $cfgClient, $client, $appendparameters;
332: 
333:         $backendUrl = cRegistry::getBackendUrl();
334: 
335:         if ($field == 4) {
336:             return humanReadableSize($data);
337:         }
338: 
339:         if ($field == 3) {
340:             if ($appendparameters == "imagebrowser" || $appendparameters == "filebrowser") {
341:                 if (cApiDbfs::isDbfs($path . '/' . $data)) {
342:                     $mstr = '<a href="javascript://" onclick="javascript:parent.parent.frames[\'left\'].frames[\'left_top\'].document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]['htmlpath']['frontend'] . 'dbfs.php?file=' . $path . '/' . $data . '\'; window.returnValue=\'' . $cfgClient[$client]['htmlpath']['frontend'] . 'dbfs.php?file=' . $path . '/' . $data . '\'; window.close();"><img src="' . $backendUrl . $cfg["path"]["images"] . 'but_ok.gif" title="' . i18n("Use file") . '">&nbsp;' . $data . '</a>';
343:                 } else {
344:                     $mstr = '<a href="javascript://" onclick="javascript:parent.parent.frames[\'left\'].frames[\'left_top\'].document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]['htmlpath']['frontend'] . $cfgClient[$client]["upl"]["frontendpath"] . $path . $data . '\'; window.returnValue=\'' . $cfgClient[$client]['htmlpath']['frontend'] . $cfgClient[$client]["upl"]["frontendpath"] . $path . $data . '\'; window.close();"><img src="' . $backendUrl . $cfg["path"]["images"] . 'but_ok.gif" title="' . i18n("Use file") . '">&nbsp;' . $data . '</a>';
345:                 }
346:             } else {
347:                 $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
348:                 $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$data&appendparameters=$appendparameters&startpage=" . $_REQUEST['startpage'] . "&sortby=" . $_REQUEST['sortby'] . "&sortmode=" . $_REQUEST['sortmode'] . "&thumbnailmode=" . $_REQUEST['thumbnailmode']), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$data"), $data);
349:             }
350:             return $mstr;
351:         }
352: 
353:         if ($field == 5) {
354:             return uplGetFileTypeDescription($data);
355:         }
356: 
357:         if ($field == 2) {
358:             // If this file is an image, try to open
359:             $fileType = strtolower(getFileType($data));
360:             switch ($fileType) {
361:                 case "png":
362:                 case "gif":
363:                 case "tiff":
364:                 case "bmp":
365:                 case "jpeg":
366:                 case "jpg":
367:                 case "bmp":
368:                 case "iff":
369:                 case "xbm":
370:                 case "wbmp":
371:                     $frontendURL = cRegistry::getFrontendUrl();
372: 
373:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
374:                     $sCacheName = substr($sCacheThumbnail, strrpos($sCacheThumbnail, "/") + 1, strlen($sCacheThumbnail) - (strrchr($sCacheThumbnail, '/') + 1));
375:                     $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
376:                     if (cFileHandler::exists($sFullPath)) {
377:                         $aDimensions = getimagesize($sFullPath);
378:                         $iWidth = $aDimensions[0];
379:                         $iHeight = $aDimensions[1];
380:                     } else {
381:                         $iWidth = 0;
382:                         $iHeight = 0;
383:                     }
384: 
385:                     if (cApiDbfs::isDbfs($data)) {
386:                         $href = $frontendURL . "dbfs.php?file=" . $data;
387:                     } else {
388:                         $href = $frontendURL . $cfgClient[$client]["upload"] . $data;
389:                     }
390:                     $retValue = '<a class="jsZoom" href="' . $href . '">
391:                            <img class="hover" name="smallImage" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
392:                            <img class="preview" name="prevImage" src="' . $sCacheThumbnail . '">
393:                        </a>';
394:                     return $retValue;
395:                     break;
396:                 default:
397:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
398:                     return '<img class="hover_none" name="smallImage" src="' . $sCacheThumbnail . '">';
399:             }
400:         }
401: 
402:         return $data;
403:     }
404: 
405: }
406: 
407: uplSyncDirectory($path);
408: 
409: if ($sortby == "") {
410:     $sortby = 3;
411:     $sortmode = "ASC";
412: }
413: 
414: if ($startpage == "") {
415:     $startpage = 1;
416: }
417: 
418: $thisfile = $sess->url("main.php?idarea=$area&frame=$frame&path=$path&thumbnailmode=$thumbnailmode&appendparameters=$appendparameters");
419: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby&appendparameters=$appendparameters";
420: 
421: if ($sortby == 3 && $sortmode == "DESC") {
422:     $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_down.gif" border="0"></a>';
423: } else {
424:     if ($sortby == 3) {
425:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_up.gif" border="0"></a>';
426:     } else {
427:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
428:     }
429: }
430: 
431: if ($sortby == 4 && $sortmode == "DESC") {
432:     $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" border="0"></a>';
433: } else {
434:     if ($sortby == 4) {
435:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" border="0"></a>';
436:     } else {
437:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
438:     }
439: }
440: 
441: if ($sortby == 5 && $sortmode == "DESC") {
442:     $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" border="0"></a>';
443: } else {
444:     if ($sortby == 5) {
445:         $typesort = '<a class="gray" class="gray" href="' . $thisfile . '&sortby=5&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_up.gif" border="0"></a>';
446:     } else {
447:         $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
448:     }
449: }
450: 
451: // Multiple deletes at top of table
452: if ($perm->have_perm_area_action("upl", "upl_multidelete") && $bDirectoryIsWritable == true) {
453:     $sConfirmation = "showConfirmation('" . i18n('Are you sure you want to delete the selected files?') . "', function() { document.del.action.value = \'upl_multidelete\'; document.del.submit(); });return false;";
454:     $sDelete = '<a class="tableElement vAlignMiddle" href="javascript:void(0)" onclick="' . $sConfirmation . '"><img class="tableElement vAlignMiddle" src="images/delete.gif" title="' . i18n("Delete selected files") . '" alt="' . i18n("Delete selected files") . '" onmouseover="this.style.cursor=\'pointer\'"><span class="tableElement">' . i18n("Delete selected files") . '</span></a>';
455: } else {
456:     $sDelete = '';
457: }
458: 
459: if (cApiDbfs::isDbfs($path)) {
460:     $mpath = $path . "/";
461: } else {
462:     $mpath = "upload/" . $path;
463: }
464: 
465: $sDisplayPath = generateDisplayFilePath($mpath, 85);
466: 
467: $sToolsRow = '<tr>
468:                <th colspan="6" id="cat_navbar">
469:                    <a class="tableElement vAlignMiddle" href="javascript:invertSelection();"><img class="tableElement vAlignMiddle" src="images/but_invert_selection.gif" title="' . i18n("Flip Selection") . '" alt="' . i18n("Flip Selection") . '" onmouseover="this.style.cursor=\'pointer\'"> ' . i18n("Flip Selection") . '</a>
470:                        ' . $sDelete . '
471:                    <div class="toolsRight">
472:                    ' . i18n("Path:") . " " . $sDisplayPath . '
473:                    </div>
474:                </th>
475:            </tr>';
476: $sSpacedRow = '<tr height="10">
477:                    <td colspan="6" class="emptyCell"></td>
478:               </tr>';
479: 
480: // List wraps
481: 
482: $pagerwrap = '<tr>
483:                <th colspan="6" id="cat_navbar">
484:                    <div class="toolsRight">
485:                        <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
486:                        <div class="vAlignMiddle">-C-PAGE-</div>
487:                        <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
488:                    </div>
489:                    <span class="vAlignMiddle">' . i18n("Files per Page") . ' -C-FILESPERPAGE-</span>
490:                </th>
491:            </tr>';
492: 
493: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
494:                ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
495:               <tr>
496:                    <th>' . i18n("Mark") . '</th>
497:                    <th>' . i18n("Preview") . '</th>
498:                    <th width="100%">' . $fnsort . '</th>
499:                    <th>' . $sizesort . '</th>
500:                    <th>' . $typesort . '</th>
501:                    <th>' . i18n("Actions") . '</th>
502:                </tr>';
503: $itemwrap = '<tr>
504:                    <td align="center">%s</td>
505:                    <td align="center">%s</td>
506:                    <td class="vAlignTop nowrap">%s</td>
507:                    <td class="vAlignTop nowrap">%s</td>
508:                    <td class="vAlignTop nowrap">%s</td>
509:                    <td class="vAlignTop nowrap">%s</td>
510:                </tr>';
511: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
512: 
513: // Object initializing
514: $page = new cGuiPage("upl_files_overview", "", 0);
515: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
516: 
517: $uploads = new cApiUploadCollection();
518: 
519: // Fetch data
520: if (substr($path, strlen($path) - 1, 1) != "/") {
521:     if ($path != "") {
522:         $qpath = $path . "/";
523:     }
524: } else {
525:     $qpath = $path;
526: }
527: 
528: $uploads->select("idclient = '$client' AND dirname = '$qpath'");
529: 
530: $user = new cApiUser($auth->auth["uid"]);
531: 
532: if ($thumbnailmode == '') {
533:     $current_mode = $user->getUserProperty('upload_folder_thumbnailmode', md5($path));
534:     if ($current_mode != '') {
535:         $thumbnailmode = $current_mode;
536:     } else {
537:         $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
538:     }
539: }
540: 
541: switch ($thumbnailmode) {
542:     case 10:
543:         $numpics = 10;
544:         break;
545:     case 25:
546:         $numpics = 25;
547:         break;
548:     case 50:
549:         $numpics = 50;
550:         break;
551:     case 100:
552:         $numpics = 100;
553:         break;
554:     case 200:
555:         $numpics = 200;
556:         break;
557:     default:
558:         $thumbnailmode = 100;
559:         $numpics = 15;
560:         break;
561: }
562: 
563: $user->setUserProperty('upload_folder_thumbnailmode', md5($path), $thumbnailmode);
564: 
565: $list2->setResultsPerPage($numpics);
566: 
567: $list2->size = $thumbnailmode;
568: 
569: $rownum = 0;
570: 
571: $properties = new cApiPropertyCollection();
572: 
573: while ($item = $uploads->next()) {
574:     $filename = $item->get("filename");
575: 
576:     $bAddFile = true;
577: 
578:     if ($appendparameters == "imagebrowser") {
579:         $restrictvar = "restrict_" . $appendparameters;
580:         if (array_key_exists($restrictvar, $browserparameters)) {
581:             $fileType = strtolower(getFileType($filename));
582:             if (count($browserparameters[$restrictvar]) > 0) {
583:                 $bAddFile = false;
584:                 if (in_array($fileType, $browserparameters[$restrictvar])) {
585:                     $bAddFile = true;
586:                 }
587:             }
588:         }
589:     }
590: 
591:     $dirname = $item->get("dirname");
592:     $filesize = $item->get("size");
593: 
594:     if ($filesize == 0) {
595:         if (cFileHandler::exists($cfgClient[$client]["upl"]["path"] . $dirname . $filename)) {
596:             $filesize = filesize($cfgClient[$client]["upl"]["path"] . $dirname . $filename);
597:         }
598:     }
599: 
600:     $actions = "";
601: 
602:     $medianame = $properties->getValue("upload", $path . $filename, "file", "medianame");
603:     $medianotes = $properties->getValue("upload", $path . $filename, "file", "medianotes");
604: 
605:     $todo = new TODOLink("upload", $path . $filename, "File $path$filename", "");
606: 
607:     $proptitle = i18n("Display properties");
608: 
609:     if ($appendparameters == "imagebrowser" || $appendparameters == "filebrowser") {
610:         $mstr = "";
611:     } else {
612:         $tmp_mstr = '<a href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
613:         $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$filename&startpage=$startpage&sortby=$sortby&sortmode=$sortmode&thumbnailmode=$thumbnailmode"), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$filename"), '<img class="vAlignMiddle tableElement" alt="' . $proptitle . '" title="' . $proptitle . '" src="images/but_art_conf2.gif" onmouseover="this.style.cursor=\'pointer\'">');
614:     }
615: 
616:     $actions = $mstr . $actions;
617: 
618:     $showfilename = $filename;
619: 
620:     $check = new cHTMLCheckbox("fdelete[]", $filename);
621: 
622:     $mark = $check->toHTML(false);
623: 
624:     if ($bAddFile == true) {
625:         // 'bgcolor' is just a placeholder...
626:         $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, strtolower(getFileType($filename)), $todo->render() . $actions);
627:         $rownum++;
628:     }
629: }
630: 
631: if ($rownum == 0) {
632: 
633:     header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
634: }
635: 
636: if ($sortmode == "ASC") {
637:     $list2->sort($sortby, SORT_ASC);
638: } else {
639:     $list2->sort($sortby, SORT_DESC);
640: }
641: 
642: if ($startpage < 1) {
643:     $startpage = 1;
644: }
645: 
646: if ($startpage > $list2->getNumPages()) {
647:     $startpage = $list2->getNumPages();
648: }
649: 
650: $list2->setListStart($startpage);
651: 
652: // Create scroller
653: if ($list2->getCurrentPage() > 1) {
654:     $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
655: } else {
656:     $prevpage = '&nbsp;';
657: }
658: 
659: if ($list2->getCurrentPage() < $list2->getNumPages()) {
660:     $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
661: } else {
662:     $nextpage = '&nbsp;';
663: }
664: 
665: // curpage = $list2->getCurrentPage() . " / ". $list2->getNumPages();
666: 
667: if ($list2->getNumPages() > 1) {
668:     $num_pages = $list2->getNumPages();
669: 
670:     $paging_form .= "<script type=\"text/javascript\">
671:        function jumpToPage(select) {
672:            var pagenumber = select.selectedIndex + 1;
673:            url = '" . $sess->url('main.php') . "';
674:            document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
675:        }
676:    </script>";
677:     $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
678:     for ($i = 1; $i <= $num_pages; $i++) {
679:         if ($i == $startpage) {
680:             $selected = " selected";
681:         } else {
682:             $selected = "";
683:         }
684:         $paging_form .= "<option value=\"$i\"$selected>$i</option>";
685:     }
686: 
687:     $paging_form .= "</select>";
688: } else {
689:     $paging_form = "1";
690: }
691: $curpage = $paging_form . " / " . $list2->getNumPages();
692: 
693: $scroller = $prevpage . $nextpage;
694: $output = $list2->output(true);
695: $output = str_replace("-C-SCROLLLEFT-", $prevpage, $output);
696: $output = str_replace("-C-SCROLLRIGHT-", $nextpage, $output);
697: $output = str_replace("-C-PAGE-", i18n("Page") . " " . $curpage, $output);
698: 
699: $select = new cHTMLSelectElement("thumbnailmode");
700: 
701: $values = array(
702:     10 => "10",
703:     25 => "25",
704:     50 => "50",
705:     100 => "100",
706:     200 => "200"
707: );
708: 
709: $select->autoFill($values);
710: 
711: $select->setDefault($thumbnailmode);
712: $select->setEvent('change', "if (document.del.thumbnailmode[0] != 'undefined') document.del.thumbnailmode[0].value = this.value; if (document.del.thumbnailmode[1] != 'undefined') document.del.thumbnailmode[1].value = this.value; if (document.del.thumbnailmode[2] != 'undefined') document.del.thumbnailmode[2].value = this.value;");
713: 
714: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
715: 
716: $output = str_replace("-C-FILESPERPAGE-", $topbar, $output);
717: 
718: $delform = new cHTMLForm("del");
719: $delform->setVar("area", $area);
720: $delform->setVar("action", "");
721: $delform->setVar("startpage", $startpage);
722: $delform->setVar("thumbnailmode", $thumbnailmode);
723: $delform->setVar("sortmode", $sortmode);
724: $delform->setVar("sortby", $sortby);
725: $delform->setVar("appendparameters", $appendparameters);
726: $delform->setVar("path", $path);
727: $delform->setVar("frame", 4);
728: // Table with (preview) images
729: $delform->appendContent($output);
730: 
731: $page->addScript($sess->url("iZoom.js.php"));
732: 
733: if ($bDirectoryIsWritable == false) {
734:     $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]["upl"]["path"] . $path . ')');
735: }
736: 
737: $jsScript = new cHTMLScript();
738: $jsScript->setAttribute('type', 'text/javascript');
739: 
740: $jsCode = '
741: (function($) {
742:    $(document).ready(function() {
743:        var $cindyCrawford = $("body");
744: 
745:        // Handler for clicked image anchors
746:        $cindyCrawford.delegate("a.jsZoom", "click", function() {
747:            iZoom($(this).attr("href"));
748:            return false;
749:        });
750: 
751:        // Handler for mouseover/mouseout on images
752:        $cindyCrawford.delegate("a.jsZoom img.hover", "mouseover", function() {
753:            correctPosition(this, $(this).attr("data-width"), $(this).attr("data-height"));
754:        });
755:        $cindyCrawford.delegate("a.jsZoom img.hover", "mouseout", function() {
756:            if (typeof(previewHideIe6) == "function") {
757:                previewHideIe6(this);
758:            };
759:        });
760:    });
761: })(jQuery);
762: ';
763: $jsScript->setContent($jsCode);
764: 
765: $page->setContent(array(
766:  $delform,
767:  $jsScript
768: ));
769: 
770: $page->render();
771: 
772: ?>
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0