1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: cInclude('includes', 'functions.file.php');
19:
20:
21: 22: 23: 24: 25: 26: 27: 28: 29:
30: function generateDisplayFilePath($sDisplayPath, $iLimit) {
31: $sDisplayPath = (string) $sDisplayPath;
32: $iLimit = (int) $iLimit;
33:
34: if (strlen($sDisplayPath) > $iLimit) {
35: $sDisplayPathShort = cApiStrTrimHard($sDisplayPath, $iLimit);
36:
37: $sTooltippString = '';
38: $iCharcount = 0;
39:
40: $aPathFragments = explode('/', $sDisplayPath);
41:
42: foreach ($aPathFragments as $sFragment) {
43: if ($sFragment != '') {
44: if (strlen($sFragment) > ($iLimit - 5)) {
45: $sFragment = cApiStrTrimHard($sFragment, $iLimit);
46: }
47:
48: if ($iCharcount + strlen($sFragment) + 1 > $iLimit) {
49: $sTooltippString .= '<br>' . $sFragment . '/';
50: $iCharcount = strlen($sFragment);
51: } else {
52: $iCharcount = $iCharcount + 1 + strlen($sFragment);
53: $sTooltippString .= $sFragment . '/';
54: }
55: }
56: }
57:
58: $sDisplayPath = '<span title="' . $sTooltippString . '" class="tooltip">' . $sDisplayPathShort . '</span>';
59: }
60: return $sDisplayPath;
61: }
62:
63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
76: function uplDirectoryListRecursive($sCurrentDir, $sStartDir = '', $aFiles = array(), $iDepth = -1, $sPathString = '') {
77: $iDepth++;
78:
79: $aDirsToExclude = uplGetDirectoriesToExclude();
80:
81:
82: if (empty($sStartDir)) {
83: $sStartDir = $sCurrentDir;
84: }
85:
86: if (chdir($sCurrentDir) == false) {
87: return $aFiles;
88: }
89: $hDir = opendir('.');
90:
91:
92: $aCurrentFiles = array();
93: while (false !== ($file = readdir($hDir))) {
94:
95: if (is_dir($file) && !in_array(strtolower($file), $aDirsToExclude)) {
96: $aCurrentFiles[] = $file;
97: }
98: }
99: sort($aCurrentFiles);
100:
101: foreach ($aCurrentFiles as $file) {
102: $sFilePathName = getcwd() . '/' . $file;
103: if ((filetype($sFilePathName) == 'dir') && (opendir($sFilePathName) !== false)) {
104: $_aFile = array(
105: 'name' => $file,
106: 'depth' => $iDepth,
107: 'pathstring' => $sPathString . $file . '/'
108: );
109:
110: $aFiles[] = $_aFile;
111:
112: $aFiles = uplDirectoryListRecursive($sFilePathName, getcwd(), $aFiles, $iDepth, $_aFile['pathstring']);
113: }
114: }
115:
116: closedir($hDir);
117: chdir($sStartDir);
118: return $aFiles;
119: }
120:
121: 122: 123: 124: 125: 126: 127:
128: function uplHasFiles($sDir) {
129: global $client, $cfgClient;
130:
131: if (!$hDir = @opendir($cfgClient[$client]['upl']['path'] . $sDir)) {
132: return false;
133: }
134:
135: $bHasContent = false;
136: if(is_dir($cfgClient[$client]['upl']['path'] . $sDir)){
137: while (false !== ($sDirEntry = readdir($hDir))) {
138: if ($sDirEntry != '.' && $sDirEntry != '..') {
139: $bHasContent = true;
140: break;
141: }
142: }
143: closedir($hDir);
144: }
145: return $bHasContent;
146: }
147:
148: 149: 150: 151: 152: 153:
154: function uplHasSubdirs($sDir) {
155: global $client, $cfgClient;
156:
157: if (!$hDir = @opendir($cfgClient[$client]['upl']['path'] . $sDir)) {
158: return true;
159: }
160:
161: $bHasSubdir = false;
162: if(is_dir($cfgClient[$client]['upl']['path'] . $sDir)){
163: while (false !== ($sDirEntry = readdir($hDir))) {
164: if ($sDirEntry != '.' && $sDirEntry != '..') {
165: if (is_dir($cfgClient[$client]['upl']['path'] . $sDir . $sDirEntry)) {
166: $bHasSubdir = true;
167: break;
168: }
169: }
170: }
171: closedir($hDir);
172: }
173:
174: return $bHasSubdir;
175: }
176:
177: 178: 179: 180: 181: 182: 183: 184:
185: function uplSyncDirectory($sPath) {
186: global $cfgClient, $client, $cfg, $db;
187:
188: if (cApiDbfs::isDbfs($sPath)) {
189: return uplSyncDirectoryDBFS($sPath);
190: }
191:
192: $oUploadsColl = new cApiUploadCollection();
193:
194:
195:
196: $sql = 'SELECT DISTINCT(dirname) AS dirname FROM ' . $cfg['tab']['upl'] . ' WHERE ' . 'idclient=' . (int) $client . ' AND dirname LIKE "' . $db->escape($sPath) . '%"';
197: $db->query($sql);
198: while ($db->nextRecord()) {
199: $sCurrDirname = $db->f('dirname');
200: $sSubDir = substr($sCurrDirname, strlen($sPath));
201: if (substr_count($sSubDir, '/') <= 1 && !cApiDbfs::isDbfs($sCurrDirname)) {
202:
203: $sFullPath = $cfgClient[$client]['upl']['path'] . $sCurrDirname;
204: if (!is_dir($sFullPath)) {
205: $oUploadsColl->deleteByDirname($sCurrDirname);
206: }
207: }
208: }
209:
210:
211:
212: $oUploadsColl->select("dirname='" . $oUploadsColl->escape($sPath) . "' AND idclient=" . (int) $client);
213: while (($oUpload = $oUploadsColl->next()) !== false) {
214: if (!cFileHandler::exists($cfgClient[$client]['upl']['path'] . $oUpload->get('dirname') . $oUpload->get('filename'))) {
215: $oUploadsColl->delete($oUpload->get('idupl'));
216: }
217: }
218:
219:
220: $sFullPath = $cfgClient[$client]['upl']['path'] . $sPath;
221: if (is_dir($sFullPath)) {
222: $aDirsToExclude = uplGetDirectoriesToExclude();
223: if (($hDir = opendir($sFullPath)) !== false) {
224: while (false !== ($file = readdir($hDir))) {
225:
226: if (!in_array(strtolower($file), $aDirsToExclude)) {
227: if (is_file($sFullPath . $file)) {
228: $oUploadsColl->sync($sPath, $file);
229: }
230: }
231: }
232: closedir($hDir);
233: }
234: }
235: }
236:
237: 238: 239: 240: 241:
242: function uplSyncDirectoryDBFS($sPath) {
243: global $cfgClient, $client, $cfg, $db;
244:
245: $oUploadsColl = new cApiUploadCollection();
246: $oPropertiesColl = new cApiPropertyCollection();
247: $oDBFSColl = new cApiDbfsCollection();
248:
249: if ($oDBFSColl->dir_exists($sPath)) {
250: $sStripPath = cApiDbfs::stripPath($sPath);
251: $oDBFSColl->select("dirname = '$sStripPath'");
252: while (($oFile = $oDBFSColl->next()) !== false) {
253: if ($oFile->get('filename') != '.') {
254: $oUploadsColl->sync($sPath . "/", $oFile->get('filename'));
255: }
256: }
257: }
258:
259: $oUploadsColl->select("dirname='$sPath/' AND idclient='$client'");
260: while (($oUpload = $oUploadsColl->next()) !== false) {
261: if (!$oDBFSColl->file_exists($oUpload->get('dirname') . $oUpload->get('filename'))) {
262: $oUploadsColl->delete($oUpload->get("idupl"));
263: }
264: }
265:
266: $oPropertiesColl->select("idclient='$client' AND itemtype='upload' AND type='file' AND itemid LIKE '" . $sPath . "%'");
267: while (($oProperty = $oPropertiesColl->next()) !== false) {
268: if (!$oDBFSColl->file_exists($oProperty->get('itemid'))) {
269: $oPropertiesColl->delete($oProperty->get('idproperty'));
270: }
271: }
272:
273: return;
274: }
275:
276: 277: 278: 279: 280: 281: 282: 283: 284:
285: function uplmkdir($sPath, $sName) {
286: global $cfgClient, $client, $action;
287:
288: if (cApiDbfs::isDbfs($sPath)) {
289: $sPath = cApiDbfs::stripPath($sPath);
290: $sFullPath = $sPath . '/' . $sName . '/.';
291:
292: $dbfs = new cApiDbfsCollection();
293: $dbfs->create($sFullPath);
294: return;
295: }
296:
297: $sName = uplCreateFriendlyName($sName);
298: $sName = strtr($sName, "'", '.');
299: if (cFileHandler::exists($cfgClient[$client]['upl']['path'] . $sPath . $sName)) {
300: $action = 'upl_mkdir';
301: return '0702';
302: } else {
303: $oldumask = umask(0);
304: @mkdir($cfgClient[$client]['upl']['path'] . $sPath . $sName, 0775);
305: umask($oldumask);
306: }
307: }
308:
309: 310: 311: 312: 313: 314: 315: 316: 317: 318:
319: function uplRenameDirectory($sOldName, $sNewName, $sParent) {
320: global $cfgClient, $client, $cfg, $db;
321:
322:
323: $sOldUplPath = $cfgClient[$client]['upl']['path'] . $sParent . $sOldName;
324: $sNewUplPath = $cfgClient[$client]['upl']['path'] . $sParent . $sNewName . '/';
325: if (!$bResult = rename($sOldUplPath, $sNewUplPath)) {
326: throw new cException("Couldn't rename upload path {$sOldUplPath} to {$sNewUplPath}");
327: }
328:
329:
330:
331: $oUploadColl = new cApiUploadCollection();
332: $oUploadColl->select("idclient=" . (int) $client . " AND dirname LIKE '" . $oUploadColl->escape($sParent . $sOldName) . "%'");
333: while (($oUpload = $oUploadColl->next()) !== false) {
334: $sDirName = $oUpload->get('dirname');
335: $sJunk = substr($sDirName, strlen($sParent) + strlen($sOldName));
336: $sNewName2 = $sParent . $sNewName . $sJunk;
337: $oUpload->set('dirname', $oUpload->escape($sNewName2), false);
338: $oUpload->store();
339: }
340:
341:
342:
343: $oPropertyColl = new cApiPropertyCollection();
344: $oPropertyColl->select("idclient=" . (int) $client . " AND itemtype='upload' AND type='file' AND itemid LIKE '" . $oPropertyColl->escape($sParent . $sOldName) . "%'");
345: while (($oProperty = $oPropertyColl->next()) !== false) {
346: $sDirName = $oProperty->get('itemid');
347: $sJunk = substr($sDirName, strlen($sParent) + strlen($sOldName));
348: $sNewName2 = $sParent . $sNewName . $sJunk;
349: $oProperty->set('itemid', $oProperty->escape($sNewName2), false);
350: $oProperty->store();
351: }
352: }
353:
354: 355: 356: 357: 358: 359: 360: 361: 362: 363:
364: function uplRecursiveDirectoryList($sDirectory, TreeItem $oRootItem, $iLevel, $sParent = '', $iRenameLevel = 0) {
365: $aInvalidDirectories = array();
366:
367: $hDir = @opendir($sDirectory);
368:
369: if ($hDir) {
370: $aDirsToExclude = uplGetDirectoriesToExclude();
371:
372: $aFiles = array();
373:
374:
375: foreach(cDirHandler::read($sDirectory,false,true) as $key => $file){
376:
377: if (!in_array(strtolower($file), $aDirsToExclude)) {
378: if (@chdir($sDirectory . $file . '/')) {
379: if (uplCreateFriendlyName($file) == $file) {
380: $aFiles[] = $file;
381: } else {
382: if ($_GET['force_rename'] == 'true') {
383: if ($iRenameLevel == 0 || $iRenameLevel == $iLevel) {
384: uplRenameDirectory($file, uplCreateFriendlyName($file), $sParent);
385: $iRenameLevel = $iLevel;
386: $aFiles[] = uplCreateFriendlyName($file);
387: } else {
388: $aInvalidDirectories[] = $file;
389: }
390: } else {
391: $aInvalidDirectories[] = $file;
392: }
393: }
394: }
395: }
396: }
397:
398: sort($aFiles);
399: foreach ($aFiles as $key => $file) {
400: $oItem = new TreeItem($file, $sDirectory . $file . '/', true);
401: $oItem->custom['level'] = $iLevel;
402: $oItem->custom['lastitem'] = ($key == count($aFiles) - 1);
403: $oItem->custom['parent'] = $sDirectory;
404:
405: $oRootItem->addItem($oItem);
406: $aArrayTemp = uplRecursiveDirectoryList($sDirectory . $file . '/', $oItem, $iLevel + 1, $sParent . $file . '/', $iRenameLevel);
407: $aInvalidDirectories = array_merge($aInvalidDirectories, $aArrayTemp);
408: unset($oItem);
409: }
410:
411: closedir($hDir);
412: }
413:
414: return $aInvalidDirectories;
415: }
416:
417: 418: 419: 420: 421: 422: 423:
424: function uplRecursiveDBDirectoryList($directory, TreeItem $oRootItem, $level, $client) {
425: $dbfs = new cApiDbfsCollection();
426: $dbfs->select("filename = '.' AND idclient=" . cSecurity::toInteger($client), 'dirname', 'dirname ASC');
427: $count = 0;
428: $lastlevel = 0;
429: $item['.'] = $oRootItem;
430:
431: $prevobj = array();
432: $lprevobj = new stdClass();
433:
434: while (($dbitem = $dbfs->next()) !== false) {
435: $dirname = $dbitem->get('dirname');
436: $level = substr_count($dirname, '/') + 2;
437: $file = basename($dbitem->get('dirname'));
438: $parent = dirname($dbitem->get('dirname'));
439:
440: if ($dirname != '.' && $file != '.') {
441: $item[$dirname] = new TreeItem($file, 'dbfs:/' . $dirname, true);
442: $item[$dirname]->custom['level'] = $level;
443: $item[$dirname]->custom['parent'] = $parent;
444: $item[$dirname]->custom['lastitem'] = true;
445:
446: if ($prevobj[$level]->custom['level'] == $level) {
447: if (is_object($prevobj[$level])) {
448: $prevobj[$level]->custom['lastitem'] = false;
449: }
450: }
451:
452: if ($lastlevel > $level) {
453: unset($prevobj[$lastlevel]);
454: $lprevobj->custom['lastitem'] = true;
455: }
456:
457: $prevobj[$level] = $item[$dirname];
458: $lprevobj = $item[$dirname];
459:
460: $lastlevel = $level;
461:
462: if (is_object($item[$parent])) {
463: $item[$parent]->addItem($item[$dirname]);
464: }
465:
466: $count++;
467: }
468: }
469: }
470:
471: 472: 473: 474: 475: 476: 477:
478: function uplGetThumbnail($sFile, $iMaxSize) {
479: global $client, $cfgClient;
480:
481: if ($iMaxSize == -1) {
482: return uplGetFileIcon($sFile);
483: }
484:
485: $sFileType = strtolower(getFileType($sFile));
486:
487: switch ($sFileType) {
488: case "png":
489: case "gif":
490: case "tiff":
491: case "tif":
492: case "bmp":
493: case "jpeg":
494: case "jpg":
495: case "bmp":
496: case "iff":
497: case "xbm":
498: case "wbmp":
499: $img = cApiImgScale($cfgClient[$client]['upl']['path'] . $sFile, $iMaxSize, $iMaxSize, false, false, 50);
500: if ($img !== false) {
501: return $img;
502: }
503: $img = cApiImgScale(cRegistry::getBackendPath() . 'images/unknown.jpg', $iMaxSize, $iMaxSize, false, false, 50);
504: if ($img !== false) {
505: return $img;
506: } else {
507: return uplGetFileIcon($sFile);
508: }
509: break;
510: default:
511: return uplGetFileIcon($sFile);
512: break;
513: }
514: }
515:
516: 517: 518: 519: 520: 521:
522: function uplGetFileIcon($sFile) {
523: global $cfg;
524:
525: $sPathFiletypes = cRegistry::getBackendUrl() . $cfg['path']['images'] . 'filetypes/';
526: $sFileType = strtolower(getFileType($sFile));
527:
528: switch ($sFileType) {
529: case "sxi":
530: case "sti":
531: case "pps":
532: case "pot":
533: case "kpr":
534: case "pptx":
535: case "potx":
536: case "pptm":
537: case "potm":
538: case "ppt":
539: $icon = "ppt.gif";
540: break;
541: case "doc":
542: case "dot":
543: case "sxw":
544: case "stw":
545: case "sdw":
546: case "docx":
547: case "dotx":
548: case "docm":
549: case "dotm":
550: case "kwd":
551: $icon = "word.gif";
552: break;
553: case "xls":
554: case "sxc":
555: case "stc":
556: case "xlw":
557: case "xlt":
558: case "csv":
559: case "ksp":
560: case "xlsx":
561: case "xltx":
562: case "xlsm":
563: case "xlsb":
564: case "xltm":
565: case "sdc":
566: $icon = "excel.gif";
567: break;
568: case "txt":
569: case "rtf":
570: $icon = "txt.gif";
571: break;
572: case "gif":
573: $icon = "gif.gif";
574: break;
575: case "png":
576: $icon = "png.gif";
577: break;
578: case "jpeg":
579: case "jpg":
580: $icon = "jpg.gif";
581: break;
582: case "html":
583: case "htm":
584: $icon = "html.gif";
585: break;
586: case "lha":
587: case "rar":
588: case "arj":
589: case "bz2":
590: case "bz":
591: case "gz":
592: case "tar":
593: case "tbz2":
594: case "tbz":
595: case "tgz":
596: case "zip":
597: $icon = "zip.gif";
598: break;
599: case "pdf":
600: $icon = "pdf.gif";
601: break;
602: case "mov":
603: case "avi":
604: case "mpg":
605: case "mpeg":
606: case "wmv":
607: $icon = "movie.gif";
608: break;
609: case "swf":
610: $icon = "swf.gif";
611: break;
612: case "js":
613: $icon = "js.gif";
614: break;
615: case "vcf":
616: $icon = "vcf.gif";
617: break;
618: case "odf":
619: $icon = "odf.gif";
620: break;
621: case "php":
622: $icon = "php.gif";
623: break;
624: case "mp3":
625: case "wma":
626: case "ogg":
627: case "mp4":
628: $icon = "sound.gif";
629: break;
630: case "psd":
631: case "ai":
632: case "eps":
633: case "cdr":
634: case "qxp":
635: case "ps":
636: $icon = "design.gif";
637: break;
638: case "css":
639: $icon = "css.gif";
640: break;
641: default:
642: if (cFileHandler::exists($sPathFiletypes . $sFileType . '.gif')) {
643: $icon = $sFileType . '.gif';
644: } else {
645: $icon = "unknown.gif";
646: }
647: break;
648: }
649:
650: return $sPathFiletypes . $icon;
651: }
652:
653: 654: 655: 656: 657: 658:
659: function uplGetFileTypeDescription($sExtension) {
660: global $cfg;
661:
662: switch ($sExtension) {
663:
664: case "sxi":
665: return (i18n("OpenOffice.org Presentation"));
666: case "sti":
667: return (i18n("OpenOffice.org Presentation Template"));
668: case "pps":
669: return (i18n("Microsoft PowerPoint Screen Presentation"));
670: case "pot":
671: return (i18n("Microsoft PowerPoint Presentation Template"));
672: case "kpr":
673: return (i18n("KDE KPresenter Document"));
674: case "ppt":
675: return (i18n("Microsoft PowerPoint Presentation Template"));
676:
677:
678: case "doc":
679: return (i18n("Microsoft Word Document or regular text file"));
680: case "dot":
681: return (i18n("Microsoft Word Template"));
682: case "sxw":
683: return (i18n("OpenOffice.org Text Document"));
684: case "stw":
685: return (i18n("OpenOffice.org Text Document Template"));
686: case "sdw":
687: return (i18n("StarOffice 5.0 Text Document"));
688: case "kwd":
689: return (i18n("KDE KWord Document"));
690:
691:
692: case "xls":
693: return (i18n("Microsoft Excel Worksheet"));
694: case "sxc":
695: return (i18n("OpenOffice.org Table"));
696: case "stc":
697: return (i18n("OpenOffice.org Table Template"));
698: case "xlw":
699: return (i18n("Microsoft Excel File"));
700: case "xlt":
701: return (i18n("Microsoft Excel Template"));
702: case "csv":
703: return (i18n("Comma Seperated Value File"));
704: case "ksp":
705: return (i18n("KDE KSpread Document"));
706: case "sdc":
707: return (i18n("StarOffice 5.0 Table"));
708:
709:
710: case "txt":
711: return (i18n("Plain Text"));
712: case "rtf":
713: return (i18n("Rich Text Format"));
714:
715:
716: case "gif":
717: return (i18n("GIF Image"));
718: case "png":
719: return (i18n("PNG Image"));
720: case "jpeg":
721: return (i18n("JPEG Image"));
722: case "jpg":
723: return (i18n("JPEG Image"));
724: case "tif":
725: return (i18n("TIFF Image"));
726: case "psd":
727: return (i18n("Adobe Photoshop Image"));
728:
729:
730: case "html":
731: return (i18n("Hypertext Markup Language Document"));
732: case "htm":
733: return (i18n("Hypertext Markup Language Document"));
734: case "css":
735: return (i18n("Cascading Style Sheets"));
736:
737:
738: case "lha":
739: return (i18n("LHA Archive"));
740: case "rar":
741: return (i18n("RAR Archive"));
742: case "arj":
743: return (i18n("ARJ Archive"));
744: case "bz2":
745: return (i18n("bz2-compressed File"));
746: case "bz":
747: return (i18n("bzip-compressed File"));
748: case "zip":
749: return (i18n("ZIP Archive"));
750: case "tar":
751: return (i18n("TAR Archive"));
752: case "gz":
753: return (i18n("GZ Compressed File"));
754:
755:
756: case "c":
757: return (i18n("C Program Code"));
758: case "c++":
759: case "cc":
760: case "cpp":
761: return (i18n("C++ Program Code"));
762: case "hpp":
763: case "h":
764: return (i18n("C or C++ Program Header"));
765: case "php":
766: case "php3":
767: case "php4":
768: return (i18n("PHP Program Code"));
769: case "phps":
770: return (i18n("PHP Source File"));
771:
772: case "pdf":
773: return (i18n("Adobe Acrobat Portable Document"));
774:
775:
776: case "mov":
777: return (i18n("QuickTime Movie"));
778: case "avi":
779: return (i18n("avi Movie"));
780: case "mpg":
781: case "mpeg":
782: return (i18n("MPEG Movie"));
783: case "wmv":
784: return (i18n("Windows Media Video"));
785: case "mp4":
786: return (i18n("MPEG-4 Movie"));
787:
788: default:
789: return (i18n($sExtension . "-File"));
790: }
791: }
792:
793: 794: 795: 796: 797: 798:
799: function uplCreateFriendlyName($filename) {
800: global $cfg, $lang;
801:
802: $oLang = new cApiLanguage();
803: $oLang->loadByPrimaryKey($lang);
804:
805: if (!is_array($cfg['upl']['allow_additional_chars'])) {
806: $filename = str_replace(" ", "_", $filename);
807: } elseif (in_array(' ', $cfg['upl']['allow_additional_chars']) === FALSE) {
808: $filename = str_replace(" ", "_", $filename);
809: }
810:
811: $chars = '';
812: if (is_array($cfg['upl']['allow_additional_chars'])) {
813: $chars = implode("", $cfg['upl']['allow_additional_chars']);
814: $chars = str_replace(array(
815: '-',
816: '[',
817: ']'
818: ), '', $chars);
819: }
820:
821: $filename = cApiStrReplaceDiacritics($filename, strtoupper($oLang->getField('encoding')));
822: $filename = preg_replace("/[^A-Za-z0-9._\-" . $chars . "]/i", '', $filename);
823:
824: return $filename;
825: }
826:
827: function uplSearch($searchfor) {
828: $client = cRegistry::getClientId();
829: $client = cSecurity::toInteger($client);
830: $lang = cRegistry::getLanguageId();
831: $lang = cSecurity::toInteger($lang);
832:
833: $uploadsColl = new cApiUploadCollection();
834: $uplMetaColl = new cApiUploadMetaCollection();
835:
836: $searchfordb = $uplMetaColl->escape($searchfor);
837:
838: $items = array();
839:
840:
841: $uplMetaColl->link('cApiUploadCollection');
842: $uplMetaColl->setWhereGroup('description', 'capiuploadcollection.idclient', $client);
843: $uplMetaColl->setWhereGroup('description', 'capiuploadmetacollection.idlang', $lang);
844: $uplMetaColl->setWhereGroup('description', 'capiuploadmetacollection.description', '%' . $searchfordb . '%', 'LIKE');
845: $uplMetaColl->query();
846: while (($item = $uplMetaColl->next()) !== false) {
847: $items[$item->get('idupl')] += (substr_count(strtolower($item->get('description')), strtolower($searchfor)) * 5);
848: }
849:
850:
851: $uplMetaColl->resetQuery();
852: $uplMetaColl->link('cApiUploadCollection');
853: $uplMetaColl->setWhereGroup('medianame', 'capiuploadcollection.idclient', $client);
854: $uplMetaColl->setWhereGroup('medianame', 'capiuploadmetacollection.idlang', $lang);
855: $uplMetaColl->setWhereGroup('medianame', 'capiuploadmetacollection.medianame', '%' . $searchfordb . '%', 'LIKE');
856: $uplMetaColl->query();
857: while (($item = $uplMetaColl->next()) !== false) {
858: $items[$item->get('idupl')] += (substr_count(strtolower($item->get('medianame')), strtolower($searchfor)) * 4);
859: }
860:
861:
862: $uploadsColl->select("idclient='" . $client . "' AND filename LIKE '%" . $searchfordb . "%'");
863: while (($item = $uploadsColl->next()) !== false) {
864: $items[$item->get('idupl')] += 4;
865: }
866:
867:
868: $uplMetaColl->resetQuery();
869: $uplMetaColl->link('cApiUploadCollection');
870: $uplMetaColl->setWhereGroup('keywords', 'capiuploadcollection.idclient', $client);
871: $uplMetaColl->setWhereGroup('keywords', 'capiuploadmetacollection.idlang', $lang);
872: $uplMetaColl->setWhereGroup('keywords', 'capiuploadmetacollection.keywords', '%' . $searchfordb . '%', 'LIKE');
873: $uplMetaColl->query();
874: while (($item = $uplMetaColl->next()) !== false) {
875: $items[$item->get('idupl')] += (substr_count(strtolower($item->get('keywords')), strtolower($searchfor)) * 3);
876: }
877:
878:
879: $uplMetaColl->resetQuery();
880: $uplMetaColl->link('cApiUploadCollection');
881: $uplMetaColl->setWhereGroup('copyright', 'capiuploadcollection.idclient', $client);
882: $uplMetaColl->setWhereGroup('copyright', 'capiuploadmetacollection.idlang', $lang);
883: $uplMetaColl->setWhereGroup('copyright', 'capiuploadmetacollection.copyright', '%' . $searchfordb . '%', 'LIKE');
884: $uplMetaColl->query();
885: while (($item = $uplMetaColl->next()) !== false) {
886: $items[$item->get('idupl')] += (substr_count(strtolower($item->get('copyright')), strtolower($searchfor)) * 2);
887: }
888:
889:
890: $uplMetaColl->resetQuery();
891: $uplMetaColl->link('cApiUploadCollection');
892: $uplMetaColl->setWhereGroup('internal_notice', 'capiuploadcollection.idclient', $client);
893: $uplMetaColl->setWhereGroup('internal_notice', 'capiuploadmetacollection.idlang', $lang);
894: $uplMetaColl->setWhereGroup('internal_notice', 'capiuploadmetacollection.internal_notice', '%' . $searchfordb . '%', 'LIKE');
895: $uplMetaColl->query();
896: while (($item = $uplMetaColl->next()) !== false) {
897: $items[$item->get('idupl')] += (substr_count(strtolower($item->get('internal_notice')), strtolower($searchfor)));
898: }
899:
900: return $items;
901: }
902:
903: 904: 905: 906: 907: 908:
909: function uplGetFileExtension($sFile) {
910:
911: $iDotPosition = strrpos($sFile, '.');
912: $sExtension = substr($sFile, $iDotPosition + 1);
913: if (strpos($sExtension, '/') !== false) {
914: return false;
915: } else {
916: return $sExtension;
917: }
918: }
919:
920: 921: 922: 923: 924: 925:
926: function uplGetDirectoriesToExclude() {
927: static $mDirsToExclude = null;
928: if (isset($mDirsToExclude)) {
929: return $mDirsToExclude;
930: }
931:
932: $mDirsToExclude = trim(getSystemProperty('system', 'upldirlist-dirstoexclude'));
933: if ($mDirsToExclude === '') {
934: $mDirsToExclude = '.,..,.svn,.cvs';
935: setSystemProperty('system', 'upldirlist-dirstoexclude', $mDirsToExclude);
936: }
937: $mDirsToExclude = explode(',', $mDirsToExclude);
938: foreach ($mDirsToExclude as $pos => $item) {
939: $mDirsToExclude[$pos] = trim($item);
940: }
941: return $mDirsToExclude;
942: }
943: