dropbox_submit.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. <?php // $Id: dropbox_submit.php,v 1.27 2005/05/17 08:02:03 renehaentjens Exp $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006 Dokeos S.A.
  6. Copyright (c) 2006 Ghent University (UGent)
  7. Copyright (c) various contributors
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. */
  19. /*
  20. * ========================================
  21. * PREVENT RESUBMITING
  22. * ========================================
  23. * This part checks if the $dropbox_unid var has the same ID
  24. * as the session var $dropbox_uniqueid that was registered as a session
  25. * var before.
  26. * The resubmit prevention only works with GET requests, because it gives some annoying
  27. * behaviours with POST requests.
  28. */
  29. /*
  30. if (isset($_POST["dropbox_unid"])) {
  31. $dropbox_unid = $_POST["dropbox_unid"];
  32. } elseif (isset($_GET["dropbox_unid"]))
  33. {
  34. $dropbox_unid = $_GET["dropbox_unid"];
  35. } else {
  36. die(dropbox_lang("badFormData")." (code 400)");
  37. }
  38. if (isset($_SESSION["dropbox_uniqueid"]) && isset($_GET["dropbox_unid"]) && $dropbox_unid == $_SESSION["dropbox_uniqueid"]) {
  39. //resubmit : go to index.php
  40. // only prevent resending of data for GETS, not POSTS because this gives annoying results
  41. if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on") {
  42. $mypath = "https";
  43. } else {
  44. $mypath = "http";
  45. }
  46. $mypath=$mypath."://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php";
  47. echo 'hier';
  48. header("Location: $mypath");
  49. }
  50. $dropbox_uniqueid = $dropbox_unid;
  51. api_session_register("dropbox_uniqueid");
  52. */
  53. /**
  54. * ========================================
  55. * FORM SUBMIT
  56. * ========================================
  57. * - VALIDATE POSTED DATA
  58. * - UPLOAD NEW FILE
  59. */
  60. if ( isset( $_POST["submitWork"]))
  61. {
  62. if (file_exists(api_get_include_path() . "/fileUploadLib.inc.php")) {
  63. require_once(api_get_include_path() . "/fileUploadLib.inc.php");
  64. } else {
  65. require_once(api_get_library_path() . "/fileUpload.lib.php");
  66. }
  67. $error = FALSE;
  68. $errormsg = '';
  69. /**
  70. * --------------------------------------
  71. *      FORM SUBMIT : VALIDATE POSTED DATA
  72. * --------------------------------------
  73. */
  74. // the author or description field is empty
  75. if ( !isset( $_POST['authors']) || !isset( $_POST['description']))
  76. {
  77. $error = TRUE;
  78. $errormsg = dropbox_lang("badFormData");
  79. }
  80. elseif ( !isset( $_POST['recipients']) || count( $_POST['recipients']) <= 0)
  81. {
  82. $error = TRUE;
  83. $errormsg = dropbox_lang("noUserSelected");
  84. }
  85. else
  86. {
  87. $thisIsAMailing = FALSE; // RH: Mailing selected as destination
  88. $thisIsJustUpload = FALSE; // RH
  89. foreach( $_POST['recipients'] as $rec)
  90. {
  91. if ( $rec == 'mailing')
  92. {
  93. $thisIsAMailing = TRUE;
  94. }
  95. elseif ( $rec == 'upload')
  96. {
  97. $thisIsJustUpload = TRUE;
  98. }
  99. elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_') ) ))
  100. {
  101. echo '401';
  102. die( dropbox_lang("badFormData")." (code 401)");
  103. }
  104. elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0)
  105. {
  106. echo '402';
  107. die( dropbox_lang("badFormData")." (code 402)");
  108. }
  109. }
  110. // we are doing a mailing but an additional recipient is selected
  111. if ( $thisIsAMailing && ( count($_POST['recipients']) != 1))
  112. {
  113. $error = TRUE;
  114. $errormsg = dropbox_lang("mailingSelectNoOther");
  115. }
  116. // we are doing a just upload but an additional recipient is selected.
  117. elseif ( $thisIsJustUpload && ( count($_POST['recipients']) != 1))
  118. {
  119. $error = TRUE;
  120. $errormsg = dropbox_lang("mailingJustUploadNoOther");
  121. }
  122. elseif ( empty( $_FILES['file']['name']))
  123. {
  124. $error = TRUE;
  125. $errormsg = dropbox_lang("noFileSpecified");
  126. }
  127. }
  128. //check if $_POST['cb_overwrite'] is true or false
  129. $dropbox_overwrite = false;
  130. if ( isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']==true)
  131. {
  132. $dropbox_overwrite = true;
  133. }
  134. /**
  135. * --------------------------------------
  136. *     FORM SUBMIT : UPLOAD NEW FILE
  137. * --------------------------------------
  138. */
  139. if ( !$error)
  140. {
  141. $dropbox_filename = $_FILES['file']['name'];
  142. $dropbox_filesize = $_FILES['file']['size'];
  143. $dropbox_filetype = $_FILES['file']['type'];
  144. $dropbox_filetmpname = $_FILES['file']['tmp_name'];
  145. if ( $dropbox_filesize <= 0 || $dropbox_filesize > dropbox_cnf("maxFilesize"))
  146. {
  147. $errormsg = dropbox_lang("tooBig");
  148. $error = TRUE;
  149. }elseif ( !is_uploaded_file( $dropbox_filetmpname)) // check user fraud : no clean error msg.
  150. {
  151. die ( dropbox_lang("badFormData")." (code 403)");
  152. }
  153. if ( !$error)
  154. {
  155. // Try to add an extension to the file if it hasn't got one
  156. $dropbox_filename = add_ext_on_mime( $dropbox_filename,$dropbox_filetype);
  157. // Replace dangerous characters
  158. $dropbox_filename = replace_dangerous_char( $dropbox_filename);
  159. // Transform any .php file in .phps fo security
  160. $dropbox_filename = php2phps ( $dropbox_filename);
  161. // set title
  162. $dropbox_title = $dropbox_filename;
  163. // set author
  164. if ( $_POST['authors'] == '')
  165. {
  166. $_POST['authors'] = getUserNameFromId( $_uid);
  167. }
  168. if ( $dropbox_overwrite) // RH: Mailing: adapted
  169. {
  170. $dropbox_person = new Dropbox_Person( $_uid, $is_courseAdmin, $is_courseTutor);
  171. foreach($dropbox_person->sentWork as $w)
  172. {
  173. if ($w->title == $dropbox_filename)
  174. {
  175. if ( ($w->recipients[0]['id'] > dropbox_cnf("mailingIdBase")) xor $thisIsAMailing)
  176. {
  177. $error = TRUE;
  178. $errormsg = dropbox_lang("mailingNonMailingError");
  179. }
  180. if ( ($w->recipients[0]['id'] == $_uid) xor $thisIsJustUpload)
  181. {
  182. $error = TRUE;
  183. $errormsg = dropbox_lang("mailingJustUploadNoOther");
  184. }
  185. $dropbox_filename = $w->filename; $found = true;
  186. break;
  187. }
  188. }
  189. }
  190. else // rename file to login_filename_uniqueId format
  191. {
  192. $dropbox_filename = getLoginFromId( $_uid) . "_" . $dropbox_filename . "_".uniqid('');
  193. }
  194. if ( ( ! is_dir( dropbox_cnf("sysPath"))))
  195. {
  196. //The dropbox subdir doesn't exist yet so make it and create the .htaccess file
  197. mkdir( dropbox_cnf("sysPath"), 0700) or die ( dropbox_lang("errorCreatingDir")." (code 404)");
  198. $fp = fopen( dropbox_cnf("sysPath")."/.htaccess", "w") or die (dropbox_lang("errorCreatingDir")." (code 405)");
  199. fwrite($fp, "AuthName AllowLocalAccess
  200. AuthType Basic
  201. order deny,allow
  202. deny from all
  203. php_flag zlib.output_compression off") or die (dropbox_lang("errorCreatingDir")." (code 406)");
  204. }
  205. if ( $error) {}
  206. elseif ( $thisIsAMailing) // RH: $newWorkRecipients is integer - see class
  207. {
  208. if ( preg_match( dropbox_cnf("mailingZipRegexp"), $dropbox_title))
  209. {
  210. $newWorkRecipients = dropbox_cnf("mailingIdBase");
  211. }
  212. else
  213. {
  214. $error = TRUE;
  215. $errormsg = $dropbox_title . ": " . dropbox_lang("mailingWrongZipfile");
  216. }
  217. }
  218. elseif ( $thisIsJustUpload) // RH: $newWorkRecipients is empty array
  219. {
  220. $newWorkRecipients = array();
  221. }
  222. else
  223. { // creating the array that contains all the users who will receive the file
  224. $newWorkRecipients = array();
  225. foreach ($_POST["recipients"] as $rec)
  226. {
  227. if (strpos($rec, 'user_') === 0) {
  228. $newWorkRecipients[] = substr($rec, strlen('user_') );
  229. }
  230. elseif (strpos($rec, 'group_') === 0 )
  231. {
  232. $userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_') ));
  233. foreach ($userList as $usr)
  234. {
  235. if (! in_array($usr['user_id'], $newWorkRecipients) && $usr['user_id'] != $_uid)
  236. {
  237. $newWorkRecipients[] = $usr['user_id'];
  238. }
  239. }
  240. }
  241. }
  242. }
  243. //After uploading the file, create the db entries
  244. if ( !$error)
  245. {
  246. @move_uploaded_file( $dropbox_filetmpname, dropbox_cnf("sysPath") . '/' . $dropbox_filename)
  247. or die( dropbox_lang("uploadError")." (code 407)");
  248. new Dropbox_SentWork( $_uid, $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients);
  249. }
  250. }
  251. } //end if(!$error)
  252. /**
  253. * ========================================
  254. * SUBMIT FORM RESULTMESSAGE
  255. * ========================================
  256. */
  257. if ( !$error)
  258. {
  259. $return_message=get_lang('FileUploadSucces');
  260. }
  261. else
  262. {
  263. $return_message=$errormsg;
  264. }
  265. } // end if ( isset( $_POST["submitWork"]))
  266. /**
  267. * ========================================
  268. * // RH: EXAMINE OR SEND MAILING (NEW)
  269. * ========================================
  270. */
  271. if ( isset( $_GET['mailingIndex'])) // examine or send
  272. {
  273. $dropbox_person = new Dropbox_Person( $_uid, $is_courseAdmin, $is_courseTutor);
  274. if ( isset($_SESSION["sentOrder"]))
  275. {
  276. $dropbox_person->orderSentWork ($_SESSION["sentOrder"]);
  277. }
  278. $i = $_GET['mailingIndex']; $mailing_item = $dropbox_person->sentWork[$i];
  279. $mailing_title = $mailing_item->title;
  280. $mailing_file = dropbox_cnf("sysPath") . '/' . $mailing_item->filename;
  281. $errormsg = '<b>' . $mailing_item->recipients[0]['name'] . ' ('
  282. . "<a href='dropbox_download.php?origin=$origin&id=".urlencode($mailing_item->id)."'>"
  283. . htmlspecialchars($mailing_title) . '</a>):</b><br><br>';
  284. if ( preg_match( dropbox_cnf("mailingZipRegexp"), $mailing_title, $nameParts))
  285. {
  286. $var = strtoupper($nameParts[2]); // the variable part of the name
  287. $course_user = Database::get_main_table(MAIN_COURSE_USER_TABLE);
  288. $sel = "SELECT u.user_id, u.lastname, u.firstname, cu.status
  289. FROM `".$mainDbName."`.`user` u
  290. LEFT JOIN $course_user cu
  291. ON cu.user_id = u.user_id AND cu.course_code = '".$_course['sysCode']."'";
  292. $sel .= " WHERE u.".dropbox_cnf("mailingWhere".$var)." = '";
  293. function getUser($thisRecip)
  294. {
  295. // string result = error message, array result = [user_id, lastname, firstname]
  296. global $var, $sel; unset($students);
  297. $result = api_sql_query($sel . $thisRecip . "'",__FILE__,__LINE__);
  298. while ( ($res = mysql_fetch_array($result))) {$students[] = $res;}
  299. mysql_free_result($result);
  300. if (count($students) == 1)
  301. {
  302. return($students[0]);
  303. }
  304. elseif (count($students) > 1)
  305. {
  306. return ' <'.dropbox_lang("mailingFileRecipDup", "noDLTT").$var."= $thisRecip>";
  307. }
  308. else
  309. {
  310. return ' <'.dropbox_lang("mailingFileRecipNotFound", "noDLTT").$var."= $thisRecip>";
  311. }
  312. }
  313. $preFix = $nameParts[1]; $postFix = $nameParts[3];
  314. $preLen = strlen($preFix); $postLen = strlen($postFix);
  315. function findRecipient($thisFile)
  316. {
  317. // string result = error message, array result = [user_id, lastname, firstname, status]
  318. global $nameParts, $preFix, $preLen, $postFix, $postLen;
  319. if ( preg_match(dropbox_cnf("mailingFileRegexp"), $thisFile, $matches))
  320. {
  321. $thisName = $matches[1];
  322. if ( substr($thisName, 0, $preLen) == $preFix)
  323. {
  324. if ( $postLen == 0 || substr($thisName, -$postLen) == $postFix)
  325. {
  326. $thisRecip = substr($thisName, $preLen, strlen($thisName) - $preLen - $postLen);
  327. if ( $thisRecip) return getUser($thisRecip);
  328. return ' <'.dropbox_lang("mailingFileNoRecip", "noDLTT").'>';
  329. }
  330. else
  331. {
  332. return ' <'.dropbox_lang("mailingFileNoPostfix", "noDLTT").$postFix.'>';
  333. }
  334. }
  335. else
  336. {
  337. return ' <'.dropbox_lang("mailingFileNoPrefix", "noDLTT").$preFix.'>';
  338. }
  339. }
  340. else
  341. {
  342. return ' <'.dropbox_lang("mailingFileFunny", "noDLTT").'>';
  343. }
  344. }
  345. if (file_exists(api_get_include_path() . "/pclzip/pclzip.lib.php")) {
  346. require(api_get_include_path() . "/pclzip/pclzip.lib.php");
  347. } else {
  348. require(api_get_library_path() . "/pclzip/pclzip.lib.php");
  349. }
  350. $zipFile = new pclZip($mailing_file); $goodFiles = array();
  351. $zipContent = $zipFile->listContent(); $ucaseFiles = array();
  352. if ( $zipContent)
  353. {
  354. foreach( $zipFile->listContent() as $thisContent)
  355. {
  356. $thisFile = substr(strrchr('/' . $thisContent['filename'], '/'), 1);
  357. $thisFileUcase = strtoupper($thisFile);
  358. if ( preg_match("~.(php.*|phtml)$~i", $thisFile) )
  359. {
  360. $error = TRUE; $errormsg .= $thisFile . ': ' . dropbox_lang("mailingZipPhp");
  361. break;
  362. }
  363. elseif ( !$thisContent['folder'])
  364. {
  365. if ( $ucaseFiles[$thisFileUcase])
  366. {
  367. $error = TRUE; $errormsg .= $thisFile . ': ' . dropbox_lang("mailingZipDups");
  368. break;
  369. }
  370. else
  371. {
  372. $goodFiles[$thisFile] = findRecipient($thisFile);
  373. $ucaseFiles[$thisFileUcase] = "yep";
  374. }
  375. }
  376. }
  377. }
  378. else
  379. {
  380. $error = TRUE; $errormsg .= dropbox_lang("mailingZipEmptyOrCorrupt");
  381. }
  382. if ( !$error)
  383. {
  384. $students = array(); // collect all recipients in this course
  385. foreach( $goodFiles as $thisFile => $thisRecip)
  386. {
  387. $errormsg .= htmlspecialchars($thisFile) . ': ';
  388. if ( is_string($thisRecip)) // see findRecipient
  389. {
  390. $errormsg .= '<font color="#FF0000">'
  391. . htmlspecialchars($thisRecip) . '</font><br>';
  392. }
  393. else
  394. {
  395. if ( isset( $_GET['mailingSend']))
  396. {
  397. $errormsg .= dropbox_lang("mailingFileSentTo");
  398. }
  399. else
  400. {
  401. $errormsg .= dropbox_lang("mailingFileIsFor");
  402. }
  403. $errormsg .= htmlspecialchars($thisRecip[1].' '.$thisRecip[2]);
  404. if ( is_null($thisRecip[3]))
  405. {
  406. $errormsg .= dropbox_lang("mailingFileNotRegistered");
  407. }
  408. else
  409. {
  410. $students[] = $thisRecip[0];
  411. }
  412. $errormsg .= '<br>';
  413. }
  414. }
  415. // find student course members not among the recipients
  416. $course_user = Database::get_main_table(MAIN_COURSE_USER_TABLE);
  417. $sql = "SELECT u.lastname, u.firstname
  418. FROM $course_user cu
  419. LEFT JOIN `".$mainDbName."`.`user` u
  420. ON cu.user_id = u.user_id AND cu.course_code = '".$_course['sysCode']."'
  421. WHERE cu.status = 5
  422. AND u.user_id NOT IN ('" . implode("', '" , $students) . "')";
  423. $result = api_sql_query($sql,__FILE__,__LINE__);
  424. if ( mysql_num_rows($result) > 0)
  425. {
  426. $remainingUsers = '';
  427. while ( ($res = mysql_fetch_array($result)))
  428. {
  429. $remainingUsers .= ', ' . htmlspecialchars($res[0].' '.$res[1]);
  430. }
  431. $errormsg .= '<br>' . dropbox_lang("mailingNothingFor") . substr($remainingUsers, 1) . '.<br>';
  432. }
  433. if ( isset( $_GET['mailingSend']))
  434. {
  435. chdir(dropbox_cnf("sysPath"));
  436. $zipFile->extract(PCLZIP_OPT_REMOVE_ALL_PATH);
  437. $mailingPseudoId = dropbox_cnf("mailingIdBase") + $mailing_item->id;
  438. foreach( $goodFiles as $thisFile => $thisRecip)
  439. {
  440. if ( is_string($thisRecip)) // remove problem file
  441. {
  442. @unlink(dropbox_cnf("sysPath") . '/' . $thisFile);
  443. }
  444. else
  445. {
  446. $newName = getLoginFromId( $_uid) . "_" . $thisFile . "_" . uniqid('');
  447. if ( rename(dropbox_cnf("sysPath") . '/' . $thisFile, dropbox_cnf("sysPath") . '/' . $newName))
  448. new Dropbox_SentWork( $mailingPseudoId, $thisFile, $mailing_item->description, $mailing_item->author, $newName, $thisContent['size'], array($thisRecip[0]));
  449. }
  450. }
  451. $sendDT = addslashes(date("Y-m-d H:i:s",time()));
  452. // set filesize to zero on send, to avoid 2nd send (see index.php)
  453. $sql = "UPDATE `".dropbox_cnf("fileTbl")."`
  454. SET filesize = '0'
  455. , upload_date = '".$sendDT."', last_upload_date = '".$sendDT."'
  456. WHERE id='".addslashes($mailing_item->id)."'";
  457. $result =api_sql_query($sql,__FILE__,__LINE__);
  458. }
  459. elseif ( $mailing_item->filesize != 0)
  460. {
  461. $errormsg .= '<br>' . dropbox_lang("mailingNotYetSent") . '<br>';
  462. }
  463. }
  464. }
  465. else
  466. {
  467. $error = TRUE; $errormsg .= dropbox_lang("mailingWrongZipfile");
  468. }
  469. /**
  470. * ========================================
  471. * EXAMINE OR SEND MAILING RESULTMESSAGE
  472. * ========================================
  473. */
  474. if ( $error)
  475. {
  476. ?>
  477. <b><font color="#FF0000"><?php echo $errormsg?></font></b><br><br>
  478. <a href="index.php<?php echo "?origin=$origin"; ?>"><?php echo dropbox_lang("backList")?></a><br>
  479. <?php
  480. }
  481. else
  482. {
  483. ?>
  484. <?php echo $errormsg?><br><br>
  485. <a href="index.php<?php echo "?origin=$origin"; ?>"><?php echo dropbox_lang("backList")?></a><br>
  486. <?php
  487. }
  488. }
  489. /**
  490. * =============================================
  491. * DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK // RH: Feedback
  492. * =============================================
  493. * - DELETE ALL RECEIVED FILES
  494. * - DELETE 1 RECEIVED FILE
  495. * - DELETE ALL SENT FILES
  496. * - DELETE 1 SENT FILE
  497. * - EDIT FEEDBACK // RH: Feedback
  498. */
  499. if ( isset( $_GET['deleteReceived']) || isset( $_GET['deleteSent'])
  500. || isset( $_GET['showFeedback']) || isset( $_GET['editFeedback'])) // RH: Feedback
  501. {
  502. if ( $_GET['mailing']) // RH: Mailing
  503. {
  504. getUserOwningThisMailing($_GET['mailing'], $_uid, '408'); // RH or die
  505. $dropbox_person = new Dropbox_Person( $_GET['mailing'], $is_courseAdmin, $is_courseTutor);
  506. }
  507. else
  508. {
  509. $dropbox_person = new Dropbox_Person( $_uid, $is_courseAdmin, $is_courseTutor);
  510. }
  511. // RH: these two are needed, I think
  512. if ( isset($_SESSION["sentOrder"]))
  513. {
  514. $dropbox_person->orderSentWork ($_SESSION["sentOrder"]);
  515. }
  516. if ( isset($_SESSION["receivedOrder"]))
  517. {
  518. $dropbox_person->orderReceivedWork ($_SESSION["receivedOrder"]);
  519. }
  520. /*if (! $dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) {
  521. die(dropbox_lang("generalError")." (code 408)");
  522. }*/
  523. $tellUser = dropbox_lang("fileDeleted"); // RH: Feedback
  524. if ( isset( $_GET['deleteReceived']))
  525. {
  526. if ( $_GET["deleteReceived"] == "all")
  527. {
  528. $dropbox_person->deleteAllReceivedWork( );
  529. }elseif ( is_numeric( $_GET["deleteReceived"]))
  530. {
  531. $dropbox_person->deleteReceivedWork( $_GET['deleteReceived']);
  532. }
  533. else
  534. {
  535. die(dropbox_lang("generalError")." (code 409)");
  536. }
  537. }
  538. elseif ( isset( $_GET['deleteSent'])) // RH: Feedback
  539. {
  540. if ( $_GET["deleteSent"] == "all")
  541. {
  542. $dropbox_person->deleteAllSentWork( );
  543. }elseif ( is_numeric( $_GET["deleteSent"]))
  544. {
  545. $dropbox_person->deleteSentWork( $_GET['deleteSent']);
  546. }
  547. else
  548. {
  549. die(dropbox_lang("generalError")." (code 410)");
  550. }
  551. }
  552. elseif ( isset( $_GET['showFeedback'])) // RH: Feedback
  553. {
  554. $w = new Dropbox_SentWork($id = $_GET['showFeedback']);
  555. if ($w->uploader_id != $_uid)
  556. getUserOwningThisMailing($w->uploader_id, $_uid, '411'); // RH or die
  557. foreach( $w -> recipients as $r) if (($fb = $r["feedback"]))
  558. {
  559. $fbarray [$r["feedback_date"].$r["name"]]=
  560. $r["name"] . ' ' . dropbox_lang("sentOn", "noDLTT") .
  561. ' ' . $r["feedback_date"] . ":\n" . $fb;
  562. }
  563. if ($fbarray)
  564. {
  565. krsort($fbarray);
  566. echo '<textarea class="dropbox_feedbacks">',
  567. htmlspecialchars(implode("\n\n", $fbarray)), '</textarea>', "\n";
  568. }
  569. else
  570. {
  571. echo '<textarea class="dropbox_feedbacks">&nbsp;</textarea>', "\n";
  572. }
  573. $tellUser = dropbox_lang("showFeedback");
  574. }
  575. else // if ( isset( $_GET['editFeedback'])) // RH: Feedback
  576. {
  577. $id = $_GET['editFeedback']; $found = false;
  578. foreach($dropbox_person->receivedWork as $w) {
  579. if ($w->id == $id) {
  580. $found = true; break;
  581. }
  582. }
  583. if (! $found) die(dropbox_lang("generalError")." (code 415)");
  584. echo '<form method="post" action="index.php">', "\n",
  585. '<input type="hidden" name="feedbackid" value="',
  586. $id, '"/>', "\n",
  587. '<textarea name="feedbacktext" class="dropbox_feedbacks">',
  588. htmlspecialchars($w->feedback), '</textarea>', "<br>\n",
  589. '<input type="submit" name="feedbacksubmit" value="', dropbox_lang("ok", "noDLTT"), '"/>', "\n",
  590. '</form>', "\n";
  591. $tellUser = dropbox_lang("giveFeedback");
  592. }
  593. /**
  594. * ==============================================
  595. * RESULTMESSAGE FOR DELETE FILE OR EDIT FEEDBACK // RH: Feedback
  596. * ==============================================
  597. */
  598. $return_message=dropbox_lang("backList");
  599. }
  600. ?>