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.upl.php");
19:
20: $isZipFile = isArchive($_REQUEST["file"]);
21:
22: $page = new cGuiPage("upl_edit");
23:
24: $page->addStyle("jquery/plugins/timepicker.css");
25: $page->addScript("jquery/plugins/timepicker.js");
26: $page->addScript("include.upl_edit.js");
27:
28:
29: if (($lang_short = substr(strtolower($belang), 0, 2)) != "en") {
30: $page->addScript("jquery/plugins/timepicker-" . $lang_short . ".js");
31: $page->addScript("jquery/plugins/datepicker-" . $lang_short . ".js");
32: }
33:
34: $form = new cGuiTableForm("properties");
35: $form->setVar("frame", $frame);
36: $form->setVar("area", "upl");
37: $form->setVar("path", $_REQUEST["path"]);
38: $form->setVar("file", $_REQUEST["file"]);
39: $form->setVar("action", "upl_modify_file");
40: $form->setVar("startpage", $_REQUEST["startpage"]);
41: $form->setVar("sortby", $_REQUEST["sortby"]);
42: $form->setVar("sortmode", $_REQUEST["sortmode"]);
43: $form->setVar("thumbnailmode", $_REQUEST["thumbnailmode"]);
44:
45: $form->addHeader(i18n("Edit"));
46:
47: if (isset($_REQUEST['zip'])) {
48: var_dump('zip');
49: }
50: $properties = new cApiPropertyCollection();
51: $uploads = new cApiUploadCollection();
52:
53: if (cApiDbfs::isDbfs($_REQUEST["path"])) {
54: $qpath = $_REQUEST["path"] . "/";
55: } else {
56: $qpath = $_REQUEST["path"];
57: }
58:
59: if ((is_writable($cfgClient[$client]["upl"]["path"] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
60: $bDirectoryIsWritable = true;
61: } else {
62: $bDirectoryIsWritable = false;
63: }
64:
65: $uploads->select("idclient = '" . $client . "' AND dirname = '" . $qpath . "' AND filename='" . $_REQUEST["file"] . "'");
66:
67: if ($upload = $uploads->next()) {
68:
69:
70: $aListRows = array();
71: $aListRows["filename"] = i18n("File name");
72: $aListRows["path"] = i18n("Path");
73: $aListRows["replacefile"] = i18n("Replace file");
74: $aListRows["medianame"] = i18n("Media name");
75: $aListRows["description"] = i18n("Description");
76: $aListRows["keywords"] = i18n("Keywords");
77: $aListRows["medianotes"] = i18n("Internal notes");
78: $aListRows["copyright"] = i18n("Copyright");
79: $aListRows["protected"] = i18n("Protection");
80: $aListRows["timecontrol"] = i18n("Time control");
81: $aListRows["preview"] = i18n("Preview");
82: $aListRows["author"] = i18n("Author");
83: $aListRows["modified"] = i18n("Last modified by");
84:
85: if ($isZipFile) {
86: $id = $_GET['user_id'];
87:
88:
89: if (isset($_SESSION['zip']) && $_SESSION['zip'] === 'extract') {
90:
91: }
92:
93: $link = new cHTMLLink();
94: $link->appendContent(i18n("extract"));
95: $aListRows["zip"] = $link;
96: }
97: ($isZipFile) ? $aListRows["extractFolder"] = '<label class="ZipExtract">' . i18n("extractTo") . '</label>' : '';
98:
99:
100: if (!cApiDbfs::isDbfs($_REQUEST["path"])) {
101: unset($aListRows['protected']);
102: unset($aListRows['timecontrol']);
103: }
104:
105:
106: $_cecIterator = $_cecRegistry->getIterator("Contenido.Upl_edit.Rows");
107: if ($_cecIterator->count() > 0) {
108: while ($chainEntry = $_cecIterator->next()) {
109: $newRowList = $chainEntry->execute($aListRows);
110: if (is_array($newRowList)) {
111: $aListRows = $newRowList;
112: }
113: }
114: }
115:
116: $iIdupl = $upload->get("idupl");
117: $sSql = "SELECT * FROM " . $cfg['tab']['upl_meta'] . "
118: WHERE idupl = " . cSecurity::toInteger($iIdupl) . "
119: AND idlang = " . cSecurity::toInteger($lang) . "
120: LIMIT 0, 1";
121: $db->query($sSql);
122:
123: if ($db->numRows() > 0) {
124: $db->nextRecord();
125: }
126:
127:
128: foreach ($aListRows as $sListRow => $sTitle) {
129: $sCell = "";
130: switch ($sListRow) {
131: case "filename":
132: $sCell = $_REQUEST["file"];
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($_REQUEST['file'], '.', TRUE));
145: $box->setClass('ZipExtract');
146: $sCell = $box;
147: $checkbox = new cHTMLCheckbox('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 ($db->f('medianame')) {
167: $medianame = cSecurity::unFilter($db->f('medianame'));
168: } else {
169: $medianame = $properties->getValue("upload", $qpath . $_REQUEST["file"], "file", "medianame");
170: }
171:
172: $mnedit = new cHTMLTextbox("medianame", $medianame, 60);
173: $sCell = $mnedit->render();
174: break;
175:
176: case "description":
177: if ($db->f('description')) {
178: $description = cSecurity::unFilter($db->f('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 ($db->f('keywords')) {
189: $keywords = cSecurity::unFilter($db->f('keywords'));
190: } else {
191: $keywords = $properties->getValue("upload", $qpath . $_REQUEST["file"], "file", "keywords");
192: }
193:
194: $kwedit = new cHTMLTextarea("keywords", $keywords);
195: $sCell = $kwedit->render();
196: break;
197:
198: case "medianotes":
199: if ($db->f('internal_notice')) {
200: $medianotes = cSecurity::unFilter($db->f('internal_notice'));
201: } else {
202: $medianotes = $properties->getValue("upload", $qpath . $_REQUEST["file"], "file", "medianotes");
203: }
204:
205: $moedit = new cHTMLTextarea("medianotes", $medianotes);
206: $sCell = $moedit->render();
207: break;
208:
209: case "copyright":
210: if ($db->f('copyright')) {
211: $copyright = cSecurity::unFilter($db->f('copyright'));
212: } else {
213: $copyright = $properties->getValue("upload", $qpath . $_REQUEST["file"], "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 . $_REQUEST["file"], "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 . $_REQUEST["file"], "file", "timemgmt");
230: $sStartDate = $properties->getValue("upload", $qpath . $_REQUEST["file"], "file", "datestart");
231: $sEndDate = $properties->getValue("upload", $qpath . $_REQUEST["file"], "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="' . $sess->url(cRegistry::getFrontendUrl() . "dbfs.php?file=" . $qpath . $_REQUEST["file"]) . '"><img class="bordered" src="' . uplGetThumbnail($qpath . $_REQUEST["file"], 350) . '"></a>';
252: } else {
253: $sCell = '<a target="_blank" href="' . $cfgClient[$client]["upl"]["htmlpath"] . $qpath . $_REQUEST["file"] . '"><img class="bordered" src="' . uplGetThumbnail($qpath . $_REQUEST["file"], 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, $_REQUEST["file"], $sListRow);
275: }
276: }
277: $sCell = implode("", $contents);
278: }
279: $form->add($sTitle, $sCell);
280: }
281:
282: $sScript = "";
283: if (cApiDbfs::isDbfs($_REQUEST["path"])) {
284: $sScript = '
285:
286: <script type="text/javascript">
287: var startcal = new calendar1(document.properties.elements["datestart"]);
288: startcal.year_scroll = true;
289: startcal.time_comp = true;
290: var endcal = new calendar1(document.properties.elements["dateend"]);
291: endcal.year_scroll = true;
292: endcal.time_comp = true;
293:
294: </script>
295:
296: ';
297: }
298:
299: if ($bDirectoryIsWritable == false) {
300: $pager->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]["upl"]["path"] . $path . ')');
301: }
302:
303: $page->set("s", "FORM", $form->render() . $sScript);
304: } else {
305: $page->displayCriticalError(sprintf(i18n("Could not load file %s"), $_REQUEST["file"]));
306: }
307:
308: $page->render();
309:
310: function isArchive($fileName) {
311:
312: if (substr(strrchr($fileName, '.'), 1) === 'zip') {
313: return true;
314: } else {
315: return false;
316: }
317: }
318: