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