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