1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: cInclude('includes', 'functions.upl.php');
18:
19:
20: $filename = cSecurity::escapeString($_REQUEST['file']);
21: $filename = str_replace('"', '', $filename);
22: $filename = str_replace("'", '', $filename);
23:
24:
25: $pathname = cSecurity::escapeString($_REQUEST['path']);
26: $pathname = str_replace('"', '', $pathname);
27: $pathname = str_replace("'", '', $pathname);
28:
29: $isZipFile = isArchive($filename);
30:
31: $page = new cGuiPage('upl_edit');
32:
33: $page->addStyle('jquery/plugins/timepicker.css');
34: $page->addScript('jquery/plugins/timepicker.js');
35: $page->addScript('include.upl_edit.js');
36:
37:
38: if (($lang_short = substr(strtolower($belang), 0, 2)) != 'en') {
39: $page->addScript('jquery/plugins/timepicker-' . $lang_short . '.js');
40: $page->addScript('jquery/plugins/datepicker-' . $lang_short . '.js');
41: }
42:
43: $form = new cGuiTableForm('properties');
44: $form->setVar('frame', $frame);
45: $form->setVar('area', 'upl');
46: $form->setVar('path', $pathname);
47: $form->setVar('file', $filename);
48: $form->setVar('action', 'upl_modify_file');
49: $form->setVar('startpage', cSecurity::toInteger($_REQUEST['startpage']));
50: $form->setVar('sortby', cSecurity::escapeString($_REQUEST['sortby']));
51: $form->setVar('sortmode', cSecurity::escapeString($_REQUEST['sortmode']));
52: $form->setVar('thumbnailmode', cSecurity::escapeString($_REQUEST['thumbnailmode']));
53:
54: $form->addHeader(i18n('Edit'));
55:
56: $properties = new cApiPropertyCollection();
57: $uploads = new cApiUploadCollection();
58:
59: if (cApiDbfs::isDbfs($_REQUEST['path'])) {
60: $qpath = $pathname . '/';
61: } else {
62: $qpath = $pathname;
63: }
64:
65: if ((is_writable($cfgClient[$client]['upl']['path'] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
66: $bDirectoryIsWritable = true;
67: } else {
68: $bDirectoryIsWritable = false;
69: }
70:
71: $uploads->select("idclient = '" . $client . "' AND dirname = '" . $qpath . "' AND filename='" . $filename . "'");
72:
73: if ($upload = $uploads->next()) {
74:
75:
76: $aListRows = array();
77: $aListRows['filename'] = i18n('File name');
78: $aListRows['path'] = i18n('Path');
79: $aListRows['replacefile'] = i18n('Replace file');
80: $aListRows['medianame'] = i18n('Media name');
81: $aListRows['description'] = i18n('Description');
82: $aListRows['keywords'] = i18n('Keywords');
83: $aListRows['medianotes'] = i18n('Internal notes');
84: $aListRows['copyright'] = i18n('Copyright');
85: $aListRows['protected'] = i18n('Protection');
86: $aListRows['timecontrol'] = i18n('Time control');
87: $aListRows['preview'] = i18n('Preview');
88: $aListRows['author'] = i18n('Author');
89: $aListRows['modified'] = i18n('Last modified by');
90:
91: if ($isZipFile) {
92: $id = $_GET['user_id'];
93:
94:
95: if (isset($_SESSION['zip']) && $_SESSION['zip'] === 'extract') {
96:
97: }
98:
99: $link = new cHTMLLink();
100: $link->appendContent(i18n('extract'));
101: $aListRows['zip'] = $link;
102: }
103: ($isZipFile) ? $aListRows['extractFolder'] = '<label class="ZipExtract">' . i18n('extractTo') . '</label>' : '';
104:
105:
106: if (!cApiDbfs::isDbfs($_REQUEST['path'])) {
107: unset($aListRows['protected']);
108: unset($aListRows['timecontrol']);
109: }
110:
111:
112: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upl_edit.Rows');
113: if ($_cecIterator->count() > 0) {
114: while ($chainEntry = $_cecIterator->next()) {
115: $newRowList = $chainEntry->execute($aListRows);
116: if (is_array($newRowList)) {
117: $aListRows = $newRowList;
118: }
119: }
120: }
121:
122: $iIdupl = $upload->get('idupl');
123:
124: $uploadMeta = new cApiUploadMeta();
125: $uploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang);
126:
127:
128: foreach ($aListRows as $sListRow => $sTitle) {
129: $sCell = '';
130: switch ($sListRow) {
131: case 'filename':
132: $sCell = $filename;
133: break;
134:
135: case 'zip':
136: $sCell = new cHTMLCheckbox('extractZip', '');
137: $sCell->setEvent('onclick', 'show();');
138:
139: break;
140:
141: case 'extractFolder':
142: $box = new cHTMLTextbox('efolder');
143: $box->setID('extractFolder');
144: $box->setValue(strstr($filename, '.', TRUE));
145: $box->setClass('ZipExtract');
146: $sCell = $box;
147: $checkbox = new cHTMLCheckbox('overwrite', i18n('overwrite'));
148: $checkbox->setID('overwrite');
149: $checkbox->setLabelText(i18n('overwrite'));
150: $checkbox->setClass('ZipExtract');
151:
152: $sCell .= $checkbox;
153: break;
154:
155: case 'path':
156: $sCell = generateDisplayFilePath($qpath, 65);
157: break;
158:
159: case 'replacefile':
160: $uplelement = new cHTMLUpload('file', 40);
161: $uplelement->setDisabled(!$bDirectoryIsWritable);
162: $sCell = $uplelement->render();
163: break;
164:
165: case 'medianame':
166: if ($uploadMeta->get('medianame')) {
167: $medianame = cSecurity::unFilter($uploadMeta->get('medianame'));
168: } else {
169: $medianame = $properties->getValue('upload', $qpath . $filename, 'file', 'medianame');
170: }
171:
172: $mnedit = new cHTMLTextbox('medianame', $medianame, 60);
173: $sCell = $mnedit->render();
174: break;
175:
176: case 'description':
177: if ($uploadMeta->get('description')) {
178: $description = cSecurity::unFilter($uploadMeta->get('description'));
179: } else {
180: $description = '';
181: }
182:
183: $dsedit = new cHTMLTextarea('description', $description);
184: $sCell = $dsedit->render();
185: break;
186:
187: case 'keywords':
188: if ($uploadMeta->get('keywords')) {
189: $keywords = cSecurity::unFilter($uploadMeta->get('keywords'));
190: } else {
191: $keywords = $properties->getValue('upload', $qpath . $filename, 'file', 'keywords');
192: }
193:
194: $kwedit = new cHTMLTextarea('keywords', $keywords);
195: $sCell = $kwedit->render();
196: break;
197:
198: case 'medianotes':
199: if ($uploadMeta->get('internal_notice')) {
200: $medianotes = cSecurity::unFilter($uploadMeta->get('internal_notice'));
201: } else {
202: $medianotes = $properties->getValue('upload', $qpath . $filename, 'file', 'medianotes');
203: }
204:
205: $moedit = new cHTMLTextarea('medianotes', $medianotes);
206: $sCell = $moedit->render();
207: break;
208:
209: case 'copyright':
210: if ($uploadMeta->get('copyright')) {
211: $copyright = cSecurity::unFilter($uploadMeta->get('copyright'));
212: } else {
213: $copyright = $properties->getValue('upload', $qpath . $filename, 'file', 'copyright');
214: }
215:
216: $copyrightEdit = new cHTMLTextarea('copyright', $copyright);
217: $sCell = $copyrightEdit->render();
218: break;
219:
220: case 'protected':
221: $vprotected = $properties->getValue('upload', $qpath . $filename, 'file', 'protected');
222: $protected = new cHTMLCheckbox('protected', '1');
223: $protected->setChecked($vprotected);
224: $protected->setLabelText(i18n('Protected for non-logged in users'));
225: $sCell = $protected->render();
226: break;
227:
228: case 'timecontrol':
229: $iTimeMng = (int) $properties->getValue('upload', $qpath . $filename, 'file', 'timemgmt');
230: $sStartDate = $properties->getValue('upload', $qpath . $filename, 'file', 'datestart');
231: $sEndDate = $properties->getValue('upload', $qpath . $filename, 'file', 'dateend');
232:
233: $oTimeCheckbox = new cHTMLCheckbox('timemgmt', i18n('Use time control'));
234: $oTimeCheckbox->setChecked($iTimeMng);
235:
236: $sHtmlTimeMng = $oTimeCheckbox->render();
237: $sHtmlTimeMng .= "<table id='dbfsTimecontrol' class='borderless' border='0' cellpadding='0' cellspacing='0'>\n";
238: $sHtmlTimeMng .= "<tr><td><label for='datestart'>" . i18n('Start date') . "</label></td>\n";
239: $sHtmlTimeMng .= '<td><input type="text" name="datestart" id="datestart" value="' . $sStartDate . '" size="20" maxlength="40" class="text_medium">' .
240: '</td></tr>';
241: $sHtmlTimeMng .= "<tr><td><label for='dateend'>" . i18n('End date') . "</label></td>\n";
242: $sHtmlTimeMng .= '<td><input type="text" name="dateend" id="dateend" value="' . $sEndDate . '" size="20" maxlength="40" class="text_medium">' .
243: '</td></tr>';
244: $sHtmlTimeMng .= "</table>\n";
245:
246: $sCell = $sHtmlTimeMng;
247: break;
248:
249: case 'preview':
250: if (cApiDbfs::isDbfs($_REQUEST['path'])) {
251: $sCell = '<a target="_blank" href="' . cRegistry::getFrontendUrl() . "dbfs.php?file=" . $qpath . $filename . '"><img alt="" class="bordered" src="' . uplGetThumbnail($qpath . $filename, 350) . '"></a>';
252: } else {
253: $sCell = '<a target="_blank" href="' . $cfgClient[$client]['upl']['htmlpath'] . $qpath . $filename . '"><img alt="" class="bordered" src="' . uplGetThumbnail($qpath . $filename, 350) . '"></a>';
254: }
255: break;
256:
257: case 'author':
258: $oUser = new cApiUser($upload->get('author'));
259: $sCell = $oUser->get('username') . ' (' . displayDatetime($upload->get('created')) . ')';
260: break;
261:
262: case 'modified':
263: $oUser = new cApiUser($upload->get('modifiedby'));
264: $sCell = $oUser->get('username') . ' (' . displayDatetime($upload->get('lastmodified')) . ')';
265: break;
266:
267: default:
268:
269: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upl_edit.RenderRows');
270:
271: if ($_cecIterator->count() > 0) {
272: $contents = array();
273: while ($chainEntry = $_cecIterator->next()) {
274: $contents[] = $chainEntry->execute($iIdupl, $qpath, $filename, $sListRow);
275: }
276: }
277: $sCell = implode('', $contents);
278: }
279: $form->add($sTitle, $sCell);
280: }
281:
282: if ($bDirectoryIsWritable == false) {
283: $pager->displayError(i18n('Directory not writable') . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
284: }
285:
286: $page->set('s', 'FORM', $form->render());
287: } else {
288: $page->displayCriticalError(sprintf(i18n('Could not load file %s'), $filename));
289: }
290:
291: $page->render();
292:
293: 294: 295: 296: 297:
298: function isArchive($fileName) {
299:
300: if (substr(strrchr($fileName, '.'), 1) === 'zip') {
301: return true;
302: } else {
303: return false;
304: }
305: }
306: