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
    • 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
  • generateJs
  • getAktuellType
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • 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
  • strCheckTreeForErrors
  • 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: $page = new cGuiPage("upl_files_overview", "", 0);
 34: 
 35: $appendparameters = $_REQUEST["appendparameters"];
 36: $file = $_REQUEST['file'];
 37: 
 38: if (!is_array($browserparameters) && ($appendparameters != "imagebrowser" || $appendparameters != "filebrowser")) {
 39:     $browserparameters = array();
 40: }
 41: 
 42: if (!$sess->isRegistered("upl_last_path")) {
 43:     // register last path (upl_last_path) in session
 44:     $sess->register("upl_last_path");
 45: } elseif (!isset($path)) {
 46:     // if no path is given the last path is used
 47:     $path = $upl_last_path;
 48: }
 49: // if path doesn't exist use root path
 50: // this might happen when the last path is that of another client or deleted outside CONTENIDO
 51: if (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]["upl"]["path"] . $path)) {
 52:     $path = '';
 53: }
 54: // remember current path as last path
 55: $upl_last_path = $path;
 56: 
 57: $uploads = new cApiUploadCollection();
 58: 
 59: $dbfs = new cApiDbfsCollection();
 60: 
 61: if (cApiDbfs::isDbfs($path)) {
 62:     $qpath = $path . "/";
 63: } else {
 64:     $qpath = $path;
 65: }
 66: 
 67: if ($path && $action != '') {
 68:     $sReloadScript = "<script type=\"text/javascript\">
 69:                         var left_bottom = parent.parent.frames['left'].frames['left_bottom'];
 70:                         if (left_bottom) {
 71:                             var href = left_bottom.location.href;
 72:                             href = href.replace(/&path.*/, '');
 73:                             left_bottom.location.href = href+'&path='+'" . $path . "';
 74:                             if (typeof top.content.left.left_top.refresh != 'undefined') {
 75:                                 top.content.left.left_top.refresh();
 76:                             }
 77:                         }
 78:                     </script>";
 79: } else {
 80:     $sReloadScript = "";
 81: }
 82: 
 83: if ((is_writable($cfgClient[$client]["upl"]["path"] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
 84:     $bDirectoryIsWritable = true;
 85: } else {
 86:     $bDirectoryIsWritable = false;
 87: }
 88: 
 89: 
 90: if ($action == "upl_modify_file") {
 91: 
 92:     $extractFolder = NULL;
 93:     $uplPath = $cfgClient[$client]['upl']['path'];
 94: 
 95:     if (isset($_REQUEST['path']) && $_REQUEST['path'] != NULL) {
 96:         $uplPath .= $_REQUEST['path'];
 97:     }
 98: 
 99:     if (isset($_REQUEST['efolder']) && $_REQUEST['efolder'] != NULL) {
100:         $extractFolder = $_REQUEST['efolder'];
101:     }
102: 
103:     if (isset($_REQUEST['extractZip']) && !isset($_REQUEST['overwrite'])) {
104:         $zipFile = $uplPath . $_REQUEST['file'];
105:         cZipArchive::extract($zipFile, $uplPath, $extractFolder);
106:     }
107:     if (isset($_REQUEST['extractZip']) && isset($_REQUEST['overwrite'])) {
108:         $zipFile = $uplPath . $_REQUEST['file'];
109:         cZipArchive::extractOverRide($zipFile, $uplPath, $extractFolder);
110:     }
111:     // Did the user upload a new file?
112:     if ($bDirectoryIsWritable == true && count($_FILES) == 1 && ($_FILES["file"]["size"] > 0) && ($_FILES["file"]["name"] != "")) {
113:         if ($_FILES['file']['tmp_name'] != "") {
114:             $tmp_name = $_FILES['file']['tmp_name'];
115:             $_cecIterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPreprocess");
116: 
117:             if ($_cecIterator->count() > 0) {
118:                 // Copy file to a temporary location
119:                 move_uploaded_file($tmp_name, $backendPath . $cfg["path"]["temp"] . $file);
120:                 $tmp_name = $backendPath . $cfg["path"]["temp"] . $file;
121: 
122:                 while ($chainEntry = $_cecIterator->next()) {
123:                     if (cApiDbfs::isDbfs($path)) {
124:                         $sPathPrepend = '';
125:                         $sPathApppend = '/';
126:                     } else {
127:                         $sPathPrepend = $cfgClient[$client]['upl']['path'];
128:                         $sPathApppend = '';
129:                     }
130: 
131:                     $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name']));
132: 
133:                     if ($modified !== false) {
134:                         $tmp_name = $modified;
135:                     }
136:                 }
137:             }
138: 
139:             if (cApiDbfs::isDbfs($path)) {
140:                 $dbfs->writeFromFile($tmp_name, $qpath . $file);
141:                 unlink($_FILES['file']['tmp_name']);
142:             } else {
143:                 unlink($cfgClient[$client]['upl']['path'] . $path . $file);
144: 
145:                 if (is_uploaded_file($tmp_name)) {
146:                     move_uploaded_file($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
147:                 } else {
148:                     rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
149:                 }
150:             }
151:         }
152:     }
153: 
154:     $uploads->select("idclient = '$client' AND dirname = '$qpath' AND filename='$file'");
155:     $upload = $uploads->next();
156: 
157:     // $upload->set("description", stripslashes($description));
158:     $upload->store();
159: 
160:     $properties = new cApiPropertyCollection();
161:     $properties->setValue("upload", $qpath . $file, "file", "protected", stripslashes($protected));
162: 
163:     $bTimeMng = (isset($_REQUEST['timemgmt']) && strlen($_REQUEST['timemgmt']) > 1);
164:     $properties->setValue("upload", $qpath . $file, "file", "timemgmt", ($bTimeMng) ? 1 : 0);
165:     if ($bTimeMng) {
166:         $properties->setValue("upload", $qpath . $file, "file", "datestart", $_REQUEST['datestart']);
167:         $properties->setValue("upload", $qpath . $file, "file", "dateend", $_REQUEST['dateend']);
168:     }
169: 
170:     $author = $auth->auth['uid'];
171:     $created = date('Y-m-d H:i:s');
172: 
173:     $iIdupl = $upload->get("idupl");
174:     if (!empty($iIdupl) && $iIdupl > 0) {
175:         // check for new entry:
176:         $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
177:         if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
178:             // Update existing entry
179:             $oUploadMeta->set('medianame', $medianame);
180:             $oUploadMeta->set('description', $description);
181:             $oUploadMeta->set('keywords', $keywords);
182:             $oUploadMeta->set('internal_notice', $medianotes);
183:             $oUploadMeta->set('copyright', $copyright);
184:             $oUploadMeta->set('modified', $created);
185:             $oUploadMeta->set('modifiedby', $author);
186:             $oUploadMeta->store();
187:         } else {
188:             // Create new entry
189:             $oUploadMetaColl = new cApiUploadMetaCollection();
190:             $oUploadMeta = $oUploadMetaColl->create($iIdupl, $lang, $medianame, $description, $keywords, $medianotes, $copyright, $author, $created, $created, $author);
191:         }
192:     }
193: }
194: 
195: if ($action == "upl_multidelete" && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
196:     if (is_array($fdelete)) {
197:         // array of cApiUpload objects to be passed to chain function
198:         $uploadObjects = array();
199: 
200:         // Check if it is in the upload table
201:         foreach ($fdelete as $file) {
202:             $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
203:             if (false !== $item = $uploads->next()) {
204:                 if (cApiDbfs::isDbfs($qpath)) {
205:                     $dbfs->remove($qpath . $file);
206: 
207:                     // call chain once for each deleted file
208:                     $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.Delete");
209:                     if ($_cecIterator->count() > 0) {
210:                         while (false !== $chainEntry = $_cecIterator->next()) {
211:                             $chainEntry->execute($item->get('idupl'), $qpath, $file);
212:                         }
213:                     }
214:                 } else {
215:                     $uploads->delete($item->get('idupl'));
216:                 }
217: 
218:                 // add current upload object to array in order to be processed
219:                 array_push($uploadObjects, $item);
220:             }
221:         }
222: 
223:         // call chain once for all deleted files
224:         $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.DeleteBatch");
225:         if ($_cecIterator->count() > 0) {
226:             while (false !== $chainEntry = $_cecIterator->next()) {
227:                 $chainEntry->execute($uploadObjects);
228:             }
229:         }
230:     }
231: }
232: 
233: if ($action == "upl_delete" && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
234:     // array of cApiUpload objects to be passed to chain function
235:     $uploadObjects = array();
236: 
237:     $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
238:     // FIXME Code is similar/redundant to cApiUploadCollection->delete(), in
239:     // previous version from UploadCollection->delete() too
240:     if (false !== $item = $uploads->next()) {
241:         if (cApiDbfs::isDbfs($qpath)) {
242:             $dbfs->remove($qpath . $file);
243:         } else {
244:             unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
245:         }
246: 
247:         // call chain for deleted file
248:         $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.Delete");
249:         if ($_cecIterator->count() > 0) {
250:             while (false !== $chainEntry = $_cecIterator->next()) {
251:                 $chainEntry->execute($uploads->f('idupl'), $qpath, $file);
252: 
253:                 // add current upload object to array in order to be processed
254:                 array_push($uploadObjects, $item);
255:             }
256:         }
257: 
258:         // call chain once for all deleted files
259:         $_cecIterator = cRegistry::getCecRegistry()->getIterator("Contenido.Upl_edit.DeleteBatch");
260:         if ($_cecIterator->count() > 0) {
261:             while (false !== $chainEntry = $_cecIterator->next()) {
262:                 $chainEntry->execute($uploadObjects);
263:             }
264:         }
265:     }
266: }
267: 
268: if ($action == "upl_upload" && $bDirectoryIsWritable == true) {
269:     if ($perm->have_perm_area_action($area, "upl_upload")) {
270:         if (count($_FILES) == 1) {
271:             foreach ($_FILES['file']['name'] as $key => $value) {
272:                 if (isUtf8($_FILES['file']['name'][$key])) {
273:                     $_FILES['file']['name'][$key] = utf8_decode($_FILES['file']['name'][$key]);
274:                 }
275:                 if ($_FILES['file']['tmp_name'][$key] != "") {
276:                     $tmp_name = $_FILES['file']['tmp_name'][$key];
277:                     $_cecIterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPreprocess");
278: 
279:                     if ($_cecIterator->count() > 0) {
280:                         // Copy file to a temporary location
281:                         move_uploaded_file($tmp_name, $backendPath . $cfg["path"]["temp"] . $_FILES['file']['name'][$key]);
282:                         $tmp_name = $backendPath . $cfg["path"]["temp"] . $_FILES['file']['name'][$key];
283: 
284:                         while ($chainEntry = $_cecIterator->next()) {
285:                             if (cApiDbfs::isDbfs($path)) {
286:                                 $sPathPrepend = '';
287:                                 $sPathApppend = '/';
288:                             } else {
289:                                 $sPathPrepend = $cfgClient[$client]['upl']['path'];
290:                                 $sPathApppend = '';
291:                             }
292: 
293:                             $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name'][$key]));
294:                             if ($modified !== false) {
295:                                 $tmp_name = $modified;
296:                             }
297:                         }
298:                     }
299: 
300:                     if (cApiDbfs::isDbfs($qpath)) {
301:                         $dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
302:                         unlink($tmp_name);
303:                     } else {
304:                         if (is_uploaded_file($tmp_name)) {
305:                             $final_filename = $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]);
306: 
307:                             move_uploaded_file($tmp_name, $final_filename);
308: 
309:                             $iterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPostprocess");
310:                             while ($chainEntry = $iterator->next()) {
311:                                 $chainEntry->execute($final_filename);
312:                             }
313:                         } else {
314:                             rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
315:                         }
316:                     }
317:                 }
318:             }
319:         }
320:     } else {
321:         $page->displayError(i18n("Permission denied"));
322:         $page->render();
323:         die();
324:     }
325: }
326: 
327: if ($action == "upl_renamefile" && $bDirectoryIsWritable == true) {
328:     $newname = str_replace("/", "", $newname);
329:     rename($cfgClient[$client]['upl']['path'] . $path . $oldname, $cfgClient[$client]['upl']['path'] . $path . $newname);
330: }
331: 
332: class UploadList extends FrontendList {
333: 
334:     var $dark;
335:     var $size;
336: 
337:     function convert($field, $data) {
338:         global $cfg, $path, $sess, $cfgClient, $client, $appendparameters;
339: 
340:         $backendUrl = cRegistry::getBackendUrl();
341: 
342:         if ($field == 4) {
343:             return humanReadableSize($data);
344:         }
345: 
346:         if ($field == 3) {
347:             if ($appendparameters == "imagebrowser" || $appendparameters == "filebrowser") {
348:                 if (cApiDbfs::isDbfs($path . '/' . $data)) {
349:                     $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>';
350:                 } else {
351:                     $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>';
352:                 }
353:             } else {
354:                 $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
355:                 $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);
356:             }
357:             return $mstr;
358:         }
359: 
360:         if ($field == 5) {
361:             return uplGetFileTypeDescription($data);
362:         }
363: 
364:         if ($field == 2) {
365:             // If this file is an image, try to open
366:             $fileType = strtolower(getFileType($data));
367:             switch ($fileType) {
368:                 case "png":
369:                 case "gif":
370:                 case "tiff":
371:                 case "bmp":
372:                 case "jpeg":
373:                 case "jpg":
374:                 case "bmp":
375:                 case "iff":
376:                 case "xbm":
377:                 case "wbmp":
378:                     $frontendURL = cRegistry::getFrontendUrl();
379: 
380:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
381:                     $sCacheName = substr($sCacheThumbnail, strrpos($sCacheThumbnail, "/") + 1, strlen($sCacheThumbnail) - (strrchr($sCacheThumbnail, '/') + 1));
382:                     $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
383:                     if (cFileHandler::exists($sFullPath)) {
384:                         $aDimensions = getimagesize($sFullPath);
385:                         $iWidth = $aDimensions[0];
386:                         $iHeight = $aDimensions[1];
387:                     } else {
388:                         $iWidth = 0;
389:                         $iHeight = 0;
390:                     }
391: 
392:                     if (cApiDbfs::isDbfs($data)) {
393:                         $href = $frontendURL . "dbfs.php?file=" . $data;
394:                     } else {
395:                         $href = $frontendURL . $cfgClient[$client]["upload"] . $data;
396:                     }
397:                     $retValue = '<a class="jsZoom" href="' . $href . '">
398:                            <img class="hover" name="smallImage" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
399:                            <img class="preview" name="prevImage" src="' . $sCacheThumbnail . '">
400:                        </a>';
401:                     return $retValue;
402:                     break;
403:                 default:
404:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
405:                     return '<img class="hover_none" name="smallImage" src="' . $sCacheThumbnail . '">';
406:             }
407:         }
408: 
409:         return $data;
410:     }
411: 
412: }
413: 
414: uplSyncDirectory($path);
415: 
416: if ($sortby == "") {
417:     $sortby = 3;
418:     $sortmode = "ASC";
419: }
420: 
421: if ($startpage == "") {
422:     $startpage = 1;
423: }
424: 
425: $thisfile = $sess->url("main.php?idarea=$area&frame=$frame&path=$path&thumbnailmode=$thumbnailmode&appendparameters=$appendparameters");
426: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby&appendparameters=$appendparameters";
427: 
428: if ($sortby == 3 && $sortmode == "DESC") {
429:     $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_down.gif" border="0"></a>';
430: } else {
431:     if ($sortby == 3) {
432:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_up.gif" border="0"></a>';
433:     } else {
434:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
435:     }
436: }
437: 
438: if ($sortby == 4 && $sortmode == "DESC") {
439:     $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" border="0"></a>';
440: } else {
441:     if ($sortby == 4) {
442:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" border="0"></a>';
443:     } else {
444:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
445:     }
446: }
447: 
448: if ($sortby == 5 && $sortmode == "DESC") {
449:     $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" border="0"></a>';
450: } else {
451:     if ($sortby == 5) {
452:         $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>';
453:     } else {
454:         $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
455:     }
456: }
457: 
458: // Multiple deletes at top of table
459: if ($perm->have_perm_area_action("upl", "upl_multidelete") && $bDirectoryIsWritable == true) {
460:     $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;";
461:     $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>';
462: } else {
463:     $sDelete = '';
464: }
465: 
466: if (cApiDbfs::isDbfs($path)) {
467:     $mpath = $path . "/";
468: } else {
469:     $mpath = "upload/" . $path;
470: }
471: 
472: $sDisplayPath = generateDisplayFilePath($mpath, 85);
473: 
474: $sToolsRow = '<tr>
475:                <th colspan="6" id="cat_navbar">
476:                    <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>
477:                        ' . $sDelete . '
478:                    <div class="toolsRight">
479:                    ' . i18n("Path:") . " " . $sDisplayPath . '
480:                    </div>
481:                </th>
482:            </tr>';
483: $sSpacedRow = '<tr height="10">
484:                    <td colspan="6" class="emptyCell"></td>
485:               </tr>';
486: 
487: // List wraps
488: 
489: $pagerwrap = '<tr>
490:                <th colspan="6" id="cat_navbar">
491:                    <div class="toolsRight">
492:                        <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
493:                        <div class="vAlignMiddle">-C-PAGE-</div>
494:                        <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
495:                    </div>
496:                    <span class="vAlignMiddle">' . i18n("Files per Page") . ' -C-FILESPERPAGE-</span>
497:                </th>
498:            </tr>';
499: 
500: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
501:                ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
502:               <tr>
503:                    <th>' . i18n("Mark") . '</th>
504:                    <th>' . i18n("Preview") . '</th>
505:                    <th width="100%">' . $fnsort . '</th>
506:                    <th>' . $sizesort . '</th>
507:                    <th>' . $typesort . '</th>
508:                    <th>' . i18n("Actions") . '</th>
509:                </tr>';
510: $itemwrap = '<tr>
511:                    <td align="center">%s</td>
512:                    <td align="center">%s</td>
513:                    <td class="vAlignTop nowrap">%s</td>
514:                    <td class="vAlignTop nowrap">%s</td>
515:                    <td class="vAlignTop nowrap">%s</td>
516:                    <td class="vAlignTop nowrap">%s</td>
517:                </tr>';
518: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
519: 
520: // Object initializing
521: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
522: 
523: $uploads = new cApiUploadCollection();
524: 
525: // Fetch data
526: if (substr($path, strlen($path) - 1, 1) != "/") {
527:     if ($path != "") {
528:         $qpath = $path . "/";
529:     }
530: } else {
531:     $qpath = $path;
532: }
533: 
534: $uploads->select("idclient = '$client' AND dirname = '$qpath'");
535: 
536: $user = new cApiUser($auth->auth["uid"]);
537: 
538: if ($thumbnailmode == '') {
539:     $current_mode = $user->getUserProperty('upload_folder_thumbnailmode', md5($path));
540:     if ($current_mode != '') {
541:         $thumbnailmode = $current_mode;
542:     } else {
543:         $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
544:     }
545: }
546: 
547: switch ($thumbnailmode) {
548:     case 10:
549:         $numpics = 10;
550:         break;
551:     case 25:
552:         $numpics = 25;
553:         break;
554:     case 50:
555:         $numpics = 50;
556:         break;
557:     case 100:
558:         $numpics = 100;
559:         break;
560:     case 200:
561:         $numpics = 200;
562:         break;
563:     default:
564:         $thumbnailmode = 100;
565:         $numpics = 15;
566:         break;
567: }
568: 
569: $user->setUserProperty('upload_folder_thumbnailmode', md5($path), $thumbnailmode);
570: 
571: $list2->setResultsPerPage($numpics);
572: 
573: $list2->size = $thumbnailmode;
574: 
575: $rownum = 0;
576: 
577: $properties = new cApiPropertyCollection();
578: 
579: while ($item = $uploads->next()) {
580:     $filename = $item->get("filename");
581: 
582:     $bAddFile = true;
583: 
584:     if ($appendparameters == "imagebrowser") {
585:         $restrictvar = "restrict_" . $appendparameters;
586:         if (array_key_exists($restrictvar, $browserparameters)) {
587:             $fileType = strtolower(getFileType($filename));
588:             if (count($browserparameters[$restrictvar]) > 0) {
589:                 $bAddFile = false;
590:                 if (in_array($fileType, $browserparameters[$restrictvar])) {
591:                     $bAddFile = true;
592:                 }
593:             }
594:         }
595:     }
596: 
597:     $dirname = $item->get("dirname");
598:     $filesize = $item->get("size");
599: 
600:     if ($filesize == 0) {
601:         if (cFileHandler::exists($cfgClient[$client]["upl"]["path"] . $dirname . $filename)) {
602:             $filesize = filesize($cfgClient[$client]["upl"]["path"] . $dirname . $filename);
603:         }
604:     }
605: 
606:     $actions = "";
607: 
608:     $medianame = $properties->getValue("upload", $path . $filename, "file", "medianame");
609:     $medianotes = $properties->getValue("upload", $path . $filename, "file", "medianotes");
610: 
611:     $todo = new TODOLink("upload", $path . $filename, "File $path$filename", "");
612: 
613:     $proptitle = i18n("Display properties");
614: 
615:     if ($appendparameters == "imagebrowser" || $appendparameters == "filebrowser") {
616:         $mstr = "";
617:     } else {
618:         $tmp_mstr = '<a href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
619:         $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\'">');
620:     }
621: 
622:     $actions = $mstr . $actions;
623: 
624:     $showfilename = $filename;
625: 
626:     $check = new cHTMLCheckbox("fdelete[]", $filename);
627: 
628:     $mark = $check->toHTML(false);
629: 
630:     if ($bAddFile == true) {
631:         // 'bgcolor' is just a placeholder...
632:         $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, strtolower(getFileType($filename)), $todo->render() . $actions);
633:         $rownum++;
634:     }
635: }
636: 
637: if ($rownum == 0) {
638: 
639:     header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
640: }
641: 
642: if ($sortmode == "ASC") {
643:     $list2->sort($sortby, SORT_ASC);
644: } else {
645:     $list2->sort($sortby, SORT_DESC);
646: }
647: 
648: if ($startpage < 1) {
649:     $startpage = 1;
650: }
651: 
652: if ($startpage > $list2->getNumPages()) {
653:     $startpage = $list2->getNumPages();
654: }
655: 
656: $list2->setListStart($startpage);
657: 
658: // Create scroller
659: if ($list2->getCurrentPage() > 1) {
660:     $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
661: } else {
662:     $prevpage = '&nbsp;';
663: }
664: 
665: if ($list2->getCurrentPage() < $list2->getNumPages()) {
666:     $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
667: } else {
668:     $nextpage = '&nbsp;';
669: }
670: 
671: // curpage = $list2->getCurrentPage() . " / ". $list2->getNumPages();
672: 
673: if ($list2->getNumPages() > 1) {
674:     $num_pages = $list2->getNumPages();
675: 
676:     $paging_form .= "<script type=\"text/javascript\">
677:        function jumpToPage(select) {
678:            var pagenumber = select.selectedIndex + 1;
679:            url = '" . $sess->url('main.php') . "';
680:            document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
681:        }
682:    </script>";
683:     $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
684:     for ($i = 1; $i <= $num_pages; $i++) {
685:         if ($i == $startpage) {
686:             $selected = " selected";
687:         } else {
688:             $selected = "";
689:         }
690:         $paging_form .= "<option value=\"$i\"$selected>$i</option>";
691:     }
692: 
693:     $paging_form .= "</select>";
694: } else {
695:     $paging_form = "1";
696: }
697: $curpage = $paging_form . " / " . $list2->getNumPages();
698: 
699: $scroller = $prevpage . $nextpage;
700: $output = $list2->output(true);
701: $output = str_replace("-C-SCROLLLEFT-", $prevpage, $output);
702: $output = str_replace("-C-SCROLLRIGHT-", $nextpage, $output);
703: $output = str_replace("-C-PAGE-", i18n("Page") . " " . $curpage, $output);
704: 
705: $select = new cHTMLSelectElement("thumbnailmode");
706: 
707: $values = array(
708:     10 => "10",
709:     25 => "25",
710:     50 => "50",
711:     100 => "100",
712:     200 => "200"
713: );
714: 
715: $select->autoFill($values);
716: 
717: $select->setDefault($thumbnailmode);
718: $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;");
719: 
720: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
721: 
722: $output = str_replace("-C-FILESPERPAGE-", $topbar, $output);
723: 
724: $delform = new cHTMLForm("del");
725: $delform->setVar("area", $area);
726: $delform->setVar("action", "");
727: $delform->setVar("startpage", $startpage);
728: $delform->setVar("thumbnailmode", $thumbnailmode);
729: $delform->setVar("sortmode", $sortmode);
730: $delform->setVar("sortby", $sortby);
731: $delform->setVar("appendparameters", $appendparameters);
732: $delform->setVar("path", $path);
733: $delform->setVar("frame", 4);
734: // Table with (preview) images
735: $delform->appendContent($output);
736: 
737: $page->addScript($sess->url("iZoom.js.php"));
738: 
739: if ($bDirectoryIsWritable == false) {
740:     $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]["upl"]["path"] . $path . ')');
741: }
742: 
743: $jsScript = new cHTMLScript();
744: $jsScript->setAttribute('type', 'text/javascript');
745: 
746: $jsCode = '
747: (function($) {
748:    $(document).ready(function() {
749:        var $cindyCrawford = $("body");
750: 
751:        // Handler for clicked image anchors
752:        $cindyCrawford.delegate("a.jsZoom", "click", function() {
753:            iZoom($(this).attr("href"));
754:            return false;
755:        });
756: 
757:        // Handler for mouseover/mouseout on images
758:        $cindyCrawford.delegate("a.jsZoom img.hover", "mouseover", function() {
759:            correctPosition(this, $(this).attr("data-width"), $(this).attr("data-height"));
760:        });
761:        $cindyCrawford.delegate("a.jsZoom img.hover", "mouseout", function() {
762:            if (typeof(previewHideIe6) == "function") {
763:                previewHideIe6(this);
764:            };
765:        });
766:    });
767: })(jQuery);
768: ';
769: $jsScript->setContent($jsCode);
770: 
771: $page->setContent(array(
772:     $delform,
773:     $jsScript
774: ));
775: 
776: $page->render();
777: 
778: ?>
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0