PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/bote.php

https://bitbucket.org/obsidian/selador
PHP | 850 lines | 655 code | 113 blank | 82 comment | 149 complexity | 869e4aa1bed377e63835622e7d04f521 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1
  1. <?php
  2. /* bote.php - Front-end for "Bote" page
  3. *
  4. * Copyright (C) 2006, 2007, 2008 Kevin Read, Simone Schaefer
  5. *
  6. * This file is part of Selador, a browser-based fantasy strategy game
  7. *
  8. * This program is distributed under the terms of the GNU Affero General Public License.
  9. *
  10. *
  11. * Selador is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * any later version.
  15. *
  16. * Selador is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with Selador. If not, see <http://www.gnu.org/licenses/>.
  23. **/
  24. // TODO: Hyprit has a nicely re-written but basic version of this. Bug him about it :)
  25. // This code is in working condition but old and hastily put together.
  26. require_once("php/base/world.inc.php");
  27. require_once("php/base.php");
  28. require_once("php/event.php");
  29. // Don't auto-reload any of these pages when a counter expires.
  30. $no_reload = 1;
  31. require_once("headers.php");
  32. $me->activevillage->update_stamp ();
  33. ?>
  34. <script src="http://code.jquery.com/jquery-latest.js"></script>
  35. <script type="text/javascript" src="/scripts/jquery.autocomplete.js"></script>
  36. <link rel="stylesheet" href="/styles/jquery.autocomplete.css" type="text/css" />
  37. <script type="text/javascript" src="/scripts/jquery.bgiframe.min.js"></script>
  38. <script type="text/javascript">
  39. <!--
  40. var allymsg = false;
  41. var data = null;
  42. function toggleAllyMsg ()
  43. {
  44. if (allymsg == true)
  45. allymsg = false;
  46. else
  47. allymsg = true;
  48. var more = document.getElementById("more");
  49. var img = document.getElementById("addimg");
  50. more.innerHTML = "";
  51. var rec = document.getElementById("recipient0");
  52. if (allymsg)
  53. {
  54. rec.value = "[Ally]";
  55. rec.setAttribute('readonly', false, 'true');
  56. rec.className = "disabled";
  57. var err = document.getElementById("errormsg");
  58. err.innerHTML ="";
  59. img.innerHTML = "<img src=\"styles/<?php echo $_SESSION['theme']?>/add_disabled.png\" onclick=\"addRec()\">";
  60. reccounter = 1;
  61. }
  62. else
  63. {
  64. rec.value = "";
  65. rec.removeAttribute("readonly");
  66. rec.className = "defaults";
  67. img.innerHTML = "<img src=\"styles/<?php echo $_SESSION['theme']?>/add.png\" onclick=\"addRec()\">";
  68. }
  69. }
  70. var reccounter = 1;
  71. function addRec ()
  72. {
  73. //alert("hurra");
  74. var elem = document.getElementById("more");
  75. if (!allymsg)
  76. {
  77. {
  78. var id = '#recipient'+reccounter;
  79. var ni = document.getElementById('more');
  80. var newdiv = document.createElement('div');
  81. var divIdName = 'more'+reccounter;
  82. newdiv.setAttribute('id',divIdName);
  83. var toBeAppended = "";
  84. if (reccounter >= 5)
  85. {
  86. var errormsg = document.getElementById("errormsg");
  87. errormsg.innerHTML = '<div id="errormsg"><span class="error">Du kannst h&ouml;chstens f&uuml;nf Empf&auml;nger eingeben.</span></div>';
  88. }
  89. else
  90. {
  91. toBeAppended = '<input type="text" size="20" name="recipient['+reccounter+']" id="recipient'+reccounter+'" value=""><br>';
  92. newdiv.innerHTML = toBeAppended;
  93. ni.appendChild(newdiv);
  94. $(id).autocomplete(data);
  95. reccounter++;
  96. }
  97. }
  98. /*else
  99. {
  100. elem.innerHTML = '<span class="error">Du kannst h&ouml;chstens f&uuml;nf Empf&auml;nger eingeben.</span>';
  101. }*/
  102. }
  103. else
  104. {
  105. elem.innerHTML = '<span class="error">Allianznachricht kann keine zusätzlichen Empfänger haben. </span>';
  106. }
  107. }
  108. <?php
  109. if ($_REQUEST['f'] == 2)
  110. {
  111. ?>
  112. $(document).ready(function() {
  113. <?php
  114. //javascript autocompletion
  115. //preload all bus stops from the database and fill in the js data array
  116. $query = 'select user from user order by user asc';
  117. if ($res = mysql_query($query)) {
  118. while ($row =mysql_fetch_array($res)) {
  119. if (isset($datastr))
  120. $datastr.=',';
  121. $datastr .= '"'.$row['user'].'"';
  122. }
  123. }
  124. ?>
  125. data = [<?php echo $datastr; ?>].sort();
  126. $('#recipient0').autocomplete(data);
  127. });
  128. // Break out of frames. This facilitates the search working as expected
  129. if (top.location.href != location.href) {
  130. top.location.href = location.href;
  131. }
  132. <?php
  133. }
  134. ?>
  135. function check_all ()
  136. {
  137. var formElem = document.getElementById ("msgdel");
  138. var allCheckElem = document.getElementById ("allchecker");
  139. var boxCounter = 0;
  140. var boxElem;
  141. while ((boxElem = formElem.elements[boxCounter]))
  142. {
  143. if (boxElem.type == "checkbox")
  144. boxElem.checked = allCheckElem.checked;
  145. boxCounter++;
  146. }
  147. }
  148. function show_melden (submitname)
  149. {
  150. var meldElem = document.getElementById ("meldarea");
  151. if (meldElem)
  152. {
  153. meldElem.innerHTML = '<p>Das freundliche Miteinander ist wichtig für den Spielspaß in Selador. Hier könnt ihr Beleidigungen, Diskriminierung und andere Tiefschläge melden. Auch Cheater, Skripter, Multis und Buguser können hier gemeldet werden.</p>Kurze Beschreibung des Problems:<br><textarea name="meldcont" rows="3" cols="80"></textarea><br><input type="submit" name="' + submitname + '" value="Melden" style="text-align: right;">';
  154. }
  155. }
  156. -->
  157. </script>
  158. <?php
  159. // We include basic design parts here
  160. require_once ("styles/php/base_design-".$_SESSION['theme'].".php");
  161. if (isset ($_REQUEST['f']))
  162. $folder = (int)$_REQUEST['f'];
  163. else
  164. $folder = 1;
  165. if (isset ($_REQUEST['p']))
  166. $page = max (0, (int)$_REQUEST['p']);
  167. else
  168. $page = 0;
  169. ?>
  170. <div id="contentbox">
  171. <div id="onecolumn">
  172. <?php
  173. // We should pass this on to the tutorial, if it is still going strong
  174. if (is_object ($tutorial))
  175. {
  176. if ($tutorial->active)
  177. $tutorial->is_in_messenger ($folder);
  178. }
  179. $msgs_per_page = 15;
  180. /* Check for delete or archive commands */
  181. if ((isset ($_REQUEST['msg_action'])) && ($_REQUEST['msg_action'] != "Antworten"))
  182. {
  183. if (isset ($_REQUEST['o']))
  184. if (($_REQUEST['o'] == 3) || ($_REQUEST['o'] == 5))
  185. {
  186. $delsender = true;
  187. }
  188. if (isset ($_REQUEST['id']))
  189. {
  190. $id = (int)$_REQUEST['id'];
  191. if ($_REQUEST['msg_action'] == 'Melden')
  192. {
  193. $query = "select A.body, A.sent, A.sender, B.user from messages A left join user B on (A.sender=B.uid) where A.id=".$id;
  194. if (!($res = mysql_query ($query)))
  195. {
  196. $err = "Die Nachricht konnte leider nicht gemeldet werden, da ein Fehler aufgetreten ist";
  197. log_err ("Error while crying about a message. Query: ".$query.", ".mysql_error ());
  198. }
  199. else
  200. {
  201. if (($row = mysql_fetch_array ($res)))
  202. {
  203. $meldung = "Nachricht vom ".$row['sent'].":\n".$row['body'];
  204. }
  205. else
  206. $meldung = "Nachricht konnte nicht gefunden werden!!";
  207. $meldung = "Spieler ".$me->user." hat folgende Nachricht von Spieler ".$row['user']." (".$row['sender'].") gepetzt. Link zur Nachricht ist http://".$_SERVER['SERVER_NAME']."/".$_SERVER['PHP_SELF']."?id=".$id."\n\n".$meldung;
  208. if (isset($_REQUEST['meldcont']))
  209. $meldcont = mysql_real_escape_string(strip_tags(trim($_REQUEST['meldcont'])));
  210. else
  211. $meldcont = "keine Beschreibung";
  212. $meldung.= "\n\nBeschreibung: ".$meldcont;
  213. $query = "insert into messages values (NULL, ".$me->uid.", ".$support_uid.", \"Meldung\", \"".$meldung."\", 0, now(), 0, \"".$me->user."\", 1)";
  214. if (!mysql_query ($query))
  215. {
  216. $err = "Die Nachricht konnte leider nicht gemeldet werden, da ein Fehler aufgetreten ist";
  217. log_err ("Error while crying about a message. Query: ".$query.", ".mysql_error ());
  218. }
  219. else
  220. {
  221. $query = "update user set msgs=msgs+1 where uid=".$support_uid;
  222. mysql_query ($query);
  223. }
  224. }
  225. }
  226. if ($_REQUEST['msg_action'] == 'Löschen')
  227. {
  228. unset ($query);
  229. if ($delsender)
  230. {
  231. $query = "update messages set snd_del=1, sent=sent where id=".$id." and sender=".$me->uid;
  232. $folder = $_REQUEST['o'];
  233. }
  234. else
  235. $folder = 1;
  236. if (!isset ($query))
  237. $query = "update messages set archived=2, sent=sent where id=".$id." and recip=".$me->uid;
  238. @mysql_query ($query);
  239. }
  240. if ($_REQUEST['msg_action'] == 'Archivieren')
  241. {
  242. $query = "update messages set archived=1, sent=sent where id=".$id." and recip=".$me->uid;
  243. @mysql_query ($query);
  244. }
  245. if ($_REQUEST['msg_action'] == 'Ungelesen')
  246. {
  247. $query = "update messages set msg_read=0, sent=sent where id=".$id." and recip=".$me->uid;
  248. @mysql_query ($query);
  249. $folder = $_REQUEST['o'];
  250. $query = "select count(id) from messages where archived=0 and msg_read=0 and recip=".$me->uid;
  251. $res = mysql_query ($query);
  252. $row = mysql_fetch_row ($res);
  253. $query = "update user set msgs=".$row[0]." where uid=".$me->uid;
  254. @mysql_query ($query);
  255. }
  256. }
  257. if (isset ($_REQUEST['ids']))
  258. {
  259. $ids = $_REQUEST['ids'];
  260. if ($_REQUEST['msg_action'] == 'Löschen')
  261. {
  262. if ($delsender) // FIXME EVIL SLOW do this with id in ()
  263. foreach ($ids as $this_id)
  264. {
  265. $query = "update messages set snd_del=1, sent=sent where id=".(int)$this_id." and sender=".$me->uid;
  266. @mysql_query ($query);
  267. }
  268. else
  269. foreach ($ids as $this_id)
  270. {
  271. $query = "update messages set archived=2, sent=sent where id=".(int)$this_id." and recip=".$me->uid;
  272. @mysql_query ($query);
  273. }
  274. }
  275. if ($_REQUEST['msg_action'] == 'Archivieren')
  276. {
  277. foreach ($ids as $this_id)
  278. {
  279. $query = "update messages set archived=1, sent=sent where id=".(int)$this_id." and (sender=".$me->uid." or recip=".$me->uid.")";
  280. @mysql_query ($query);
  281. }
  282. }
  283. $query = "select count(id) from messages where archived=0 and msg_read=0 and recip=".$me->uid;
  284. $res = mysql_query ($query);
  285. $row = mysql_fetch_row ($res);
  286. $query = "update user set msgs=".$row[0]." where uid=".$me->uid;
  287. @mysql_query ($query);
  288. }
  289. if (isset ($_REQUEST['o']))
  290. $folder = $_REQUEST['o'];
  291. else
  292. $folder = 1;
  293. }
  294. $no_go = false;
  295. /* First, check for outgoing message data */
  296. if (isset ($_REQUEST['msg_submit']))
  297. {
  298. if (isset ($_REQUEST['c']) && ($_REQUEST['c'] == $me->reload_counter))
  299. {
  300. $me->reload_counter++;
  301. $recipients = $_REQUEST['recipient'];
  302. $empfaenger = false;
  303. foreach ($recipients as $idx => $rec)
  304. {
  305. if (strlen($rec) > 3)
  306. {
  307. if ($rec != "[Ally]")
  308. $empfaenger = true;
  309. }
  310. }
  311. if (($empfaenger == true) && ($_POST['to_all_members'] == "ON"))
  312. {
  313. $no_go = true;
  314. echo "<span class=\"error\">Du hast einen Empf&auml;nger eingegeben und zus&auml;tzlich \"Allianz-Rundmail verschicken\" angew&auml;hlt. Es geht aber nur eins von beidem!</span>";
  315. }
  316. else
  317. {
  318. if ($empfaenger == true)
  319. {
  320. $counter = 0;
  321. foreach ($recipients as $idx => $rec)
  322. {
  323. if ($counter > 5)
  324. break;
  325. if (strlen (trim ($rec)) > 0)
  326. {
  327. $query = "select uid from user where user=\"".trim($rec)."\"";
  328. $res = mysql_query ($query);
  329. if ($row = mysql_fetch_row ($res))
  330. {
  331. $recuid[] = $row[0];
  332. $recipients[$idx] = mysql_real_escape_string (trim ($rec));
  333. }
  334. else
  335. {
  336. unset ($recipients[$idx]);
  337. echo "<span class=\"error\">Empfänger ".$rec." nicht gefunden :(</span>\n";
  338. $no_go = true;
  339. }
  340. }
  341. }
  342. if (!$no_go)
  343. {
  344. if (isset ($_REQUEST['subject']))
  345. {
  346. $subject = mysql_real_escape_string (trim (strip_tags ($_REQUEST['subject'])));
  347. if (strlen ($subject) < 1)
  348. $subject = "Kein Betreff";
  349. if (isset ($_REQUEST['body']))
  350. {
  351. if (stristr($_REQUEST['body'], "<" ))
  352. {
  353. echo "<b>Fehler: Die Nachricht enth&auml;t ung&uuml;ltige Zeichen (<).<br> </b>";
  354. $no_go = true;
  355. }
  356. $body = mysql_real_escape_string (trim (strip_tags ($_REQUEST['body'])));
  357. //echo $body;
  358. if (strlen ($body) < 3)
  359. {
  360. echo "<b>Nachricht leer?</b>\n";
  361. $no_go = true;
  362. }
  363. if ($me->sat_by)
  364. $body = "Diese Nachricht wurde von einem Sitter verfasst:\n".$body;
  365. }
  366. else
  367. {
  368. echo "<b>Nachrichtentext kaputt??</b>\n";
  369. $no_go = true;
  370. }
  371. }
  372. else
  373. {
  374. echo "<b>Betreff defekt???</b>\n";
  375. $no_go = true;
  376. }
  377. }
  378. }
  379. else
  380. {
  381. //allianzrundmail
  382. if ($_POST['to_all_members'] != "ON")
  383. {
  384. echo "<span class=\"error\">Empfänger eingeben</span>";
  385. $no_go = true;
  386. }
  387. else
  388. {
  389. if (!$me->aid)
  390. echo "<span class=\"error\">Es ist ein Fehler beim Versenden der Nachricht aufgetreten!</span>";
  391. else
  392. {
  393. if (strlen($_REQUEST['subject']) > 0)
  394. $subject = "[Ally]".mysql_real_escape_string(strip_tags($_REQUEST['subject']));
  395. else
  396. $subject = "[Ally]kein Betreff";
  397. $already_sent = true;
  398. $query_select = "select uid,user from user where aid=".$me->aid." and uid!=".$me->uid;
  399. if (!$res = mysql_query($query_select))
  400. echo "<span class=\"error\">Es ist ein Fehler beim Versenden der Nachricht aufgetreten!</span>";
  401. else
  402. {
  403. if ($me->sat_by)
  404. $_REQUEST['body'] = "Diese Nachricht wurde von einem Sitter verfasst:\n".$_REQUEST['body'];
  405. //$body = mysql_real_escape_string(trim(strip_tags($REQUEST['body'])));
  406. $query_anfang = "insert into messages (sender,recip,subject,body,msg_read,sent,archived,name,snd_del) values ";
  407. while ($row = mysql_fetch_array($res) )
  408. {
  409. if (isset($query_rundmail))
  410. $query_rundmail .= ",";
  411. $query_rundmail .= "(".$me->uid.",".$row['uid'].",'".$subject."','".mysql_real_escape_string(trim(strip_tags($_REQUEST['body'])))."',0,now(),0,'".mysql_real_escape_string($me->user)."',0)";
  412. }
  413. $query_ally = $query_anfang . $query_rundmail;
  414. if (!mysql_query($query_ally))
  415. {
  416. echo "<span class=\"error\">Es ist ein Datenbankfehler aufgetreten</span>";
  417. $me->log_err ("Cannot send ally mail. Query: ".$query_ally.", ".mysql_error ());
  418. }
  419. else
  420. {
  421. echo "<span class=\"success\">Erfolgreich verschickt</span>";
  422. $query = "update user set msgs=msgs+1 where aid=".$me->aid." and uid!=".$me->uid;
  423. if (!mysql_query ($query))
  424. $me->log_err ("Cannot update msgs after sending ally mail. Query: ".$query.", ".mysql_error ());
  425. }
  426. $folder=1;
  427. $already_sent = true;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. if (!$no_go)
  434. {
  435. if (!$already_sent)
  436. {
  437. foreach ($recuid as $idx => $this_recip)
  438. {
  439. $query = "insert into messages (sender, recip, name, subject, body) values (".$me->uid.", ".$this_recip.", \"".mysql_real_escape_string($me->user)."\", \"".$subject."\", \"".$body."\")";
  440. if (@mysql_query ($query))
  441. {
  442. $me->reload_counter++;
  443. $folder = 1;
  444. $query = "update user set msgs=msgs+1 where uid=".$this_recip;
  445. @mysql_query ($query);
  446. }
  447. else
  448. {
  449. echo "<b>Nachricht konnte nicht an alle gesendet werden :(</b>\n";
  450. $folder = 2;
  451. }
  452. }
  453. }
  454. else
  455. $folder = 1;
  456. }
  457. else
  458. $folder = 2;
  459. }
  460. else
  461. {
  462. $folder = 1;
  463. }
  464. }
  465. switch ($folder)
  466. {
  467. case 1:
  468. $query = "select count(id) from messages where archived=0 and recip=".$me->uid;
  469. $res = mysql_query ($query);
  470. $row = mysql_fetch_row ($res);
  471. $num_msgs = $row[0];
  472. $pages = (int)(($num_msgs-1) / $msgs_per_page);
  473. if ($page-1 > $pages)
  474. $page = $pages;
  475. // FIXME: Left joins here, or messages won't be displayed if user deletes himself!
  476. $query = "select A.id, A.sender, A.subject, date_format(A.sent, \"%d.%c.%Y - %H:%i\") as sent, A.msg_read, B.user, B.uid, B.aid, C.tag, A.name from messages A left join user B on (A.sender=B.uid) left join allies C on (B.aid=C.aid) where archived=0 and recip=".$me->uid." order by A.sent desc limit ".($page*$msgs_per_page).",".$msgs_per_page;
  477. $tablehead = "<th width=\"20\" class=\"bold\">&nbsp;</th><th class=\"bold\">Betreff</th><th class=\"bold\">Absender</th><th class=\"bold\">Ally</td><th class=\"bold\">Gesendet</th>\n";
  478. case 3:
  479. if (!isset ($pages))
  480. {
  481. $query = "select count(id) from messages where snd_del=0 and sender=".$me->uid;
  482. $res = mysql_query ($query);
  483. $row = mysql_fetch_row ($res);
  484. $num_msgs = $row[0];
  485. $pages = (int)(($num_msgs-1) / $msgs_per_page);
  486. if ($page-1 > $pages)
  487. $page = $pages;
  488. $query = "select A.id, A.recip, A.subject, date_format(A.sent, \"%d.%c.%Y - %H:%i\") as sent, A.msg_read, B.user, B.uid, B.aid, C.tag, A.name from messages A left join user B on (A.recip=B.uid) left join allies C on (B.aid=C.aid) where snd_del=0 and sender=".$me->uid." order by A.sent desc limit ".($page*$msgs_per_page).",".$msgs_per_page;
  489. $tablehead = "<th width=\"24px\">&nbsp;</th><th class=\"bold\">Betreff</th><th class=\"bold\">Empfänger</th><th class=\"bold\">Ally</th><th class=\"bold\">Gesendet</th>\n";
  490. }
  491. case 4:
  492. if (!isset ($pages))
  493. {
  494. $query = "select count(id) from messages where archived=1 and recip=".$me->uid;
  495. $res = mysql_query ($query);
  496. $row = mysql_fetch_row ($res);
  497. $num_msgs = $row[0];
  498. $pages = (int)(($num_msgs-1) / $msgs_per_page);
  499. if ($page-1 > $pages)
  500. $page = $pages;
  501. $query = "select A.id, A.sender, A.subject, date_format(A.sent, \"%d.%c.%Y - %H:%i\") as sent, A.msg_read, B.user, B.uid, B.aid, C.tag, A.name from messages A left join user B on (A.sender=B.uid) left join allies C on (B.aid=C.aid) where archived=1 and recip=".$me->uid." order by A.sent desc limit ".($page*$msgs_per_page).",".$msgs_per_page;
  502. $tablehead = "<th class=\"bold\" width=\"24px\">&nbsp;</th><th class=\"bold\" >Betreff</th><th class=\"bold\" >Absender</th><th class=\"bold\">Ally</th><th class=\"bold\">Gesendet</th>\n";
  503. }
  504. // case 5:
  505. /*if (!isset ($pages))
  506. {
  507. $query = "select count(id) from messages where archived=1 and snd_del=0 and sender=".$me->uid;
  508. $res = mysql_query ($query);
  509. $row = mysql_fetch_row ($res);
  510. $num_msgs = $row[0];
  511. $pages = (int)(($num_msgs-1) / $msgs_per_page);
  512. if ($page-1 > $pages)
  513. $page = $pages;
  514. $query = "select A.id, A.recip, A.subject, date_format(A.sent, \"%d.%c.%Y - %H:%i\") as sent, A.msg_read, B.user, B.uid, B.aid, C.tag from messages A left join user B on (A.recip=B.uid ) left join allies C on (B.aid=C.aid) where archived=1 and snd_del=0 and sender=".$me->uid." order by A.sent desc limit ".($page*$msgs_per_page).",".$msgs_per_page;
  515. $tablehead = "<th width=\"50%\">Betreff</th><th width=\"120\">Empfänger</th><th>Ally</th><th width=\"120\">Gesendet</th>\n";
  516. }*/
  517. echo "<form name=\"msgdel\" id=\"msgdel\" action=\"bote.php\" method=\"POST\"><table class=\"border\" ><tr >";
  518. echo "<th width=\"22\" class=\"bold\">&nbsp;</th>".$tablehead."</tr>";
  519. $res = mysql_query ($query);
  520. $counter = 0;
  521. while ($row = mysql_fetch_array ($res))
  522. {
  523. if ($counter % 2 == 0)
  524. $class = ' class="iterate"';
  525. else
  526. $class = '';
  527. $counter++;
  528. echo "<tr ".$class.">";
  529. echo "<td> ";
  530. if ($row['msg_read'] == 0)
  531. echo '<img src="styles/'.$_SESSION['theme'].'/new.png" >';;
  532. echo "</td>\n";
  533. echo "<td ><input class=\"eingabe\" type=\"checkbox\" name=\"ids[]\" value=\"".$row['id']."\"></td>";
  534. echo "<td ><a href=\"bote.php?o=".$folder."&f=6&id=".$row['id']."\" class=\"dark\">".stripslashes ($row['subject'])."</a></td>";
  535. if ($row['uid'])
  536. echo "<td ><a href=\"profile.php?u=".$row['uid']."\">".$row['user']."</a>";
  537. else
  538. {
  539. if ($folder == 1)
  540. echo "<td >".$row['name']."";
  541. else
  542. echo "<td>(gel&ouml;scht)";
  543. }
  544. /*</td>";
  545. else*/
  546. echo "</td>";
  547. //if ($folder==1)
  548. echo "<td><a href=\"allianz.php?a=".$row['aid']."\">".$row['tag']."</a></td>";
  549. // if ($folder==3)
  550. // echo "<td><a href=\"allianz.php?a=".$row[7]."\">".$row[8]."</a></td>";
  551. echo "<td >".$row[3]."</td></tr>\n";
  552. }
  553. echo "</table>\n";
  554. echo "<input type=\"hidden\" name=\"f\" value=\"".$folder."\">\n";
  555. echo "<input type=\"hidden\" name=\"o\" value=\"".$folder."\">\n";
  556. // echo "</div>\n";
  557. // Correctly format and paint arrows - they shouldn't be links if we cannot scroll in this direction
  558. echo "</div><div id=\"leiste-unten\">";
  559. echo "<input class=\"eingabe\" type=\"checkbox\" id=\"allchecker\" onClick=\"check_all();\">Alle markieren&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  560. if ($page == 0)
  561. echo "<img src=\"styles/".$_SESSION['theme']."/pfeil_lang_links_grau.png\" alt=\"Nach links bl&auml;ttern!\" title=\"Nach links bl&auml;ttern!\">\n";
  562. else
  563. echo "<a href=\"".$_SERVER['PHP_SELF']."?p=".($page-1)."&f=".$folder."\"><img src=\"styles/".$_SESSION['theme']."/pfeil_lang_links.png\" border=\"0\" alt=\"Nach links bl&auml;ttern!\" title=\"Nach links bl&auml;ttern!\"></a>\n";
  564. if ($page < $pages)
  565. echo "<a href=\"".$_SERVER['PHP_SELF']."?p=".($page+1)."&f=".$folder."\"><img src=\"styles/".$_SESSION['theme']."/pfeil_lang_rechts.png\" alt=\"Nach rechts bl&auml;ttern!\" title=\"Nach rechts bl&auml;ttern!\"></a>\n";
  566. else
  567. echo "<img src=\"styles/".$_SESSION['theme']."/pfeil_lang_rechts_grau.png\" alt=\"Nach rechts bl&auml;ttern!\" title=\"Nach rechts bl&auml;ttern!\">\n";
  568. echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Seite ".($page+1)." von ".($pages+1)."";
  569. echo "";
  570. if ($folder < 4) // Cannot archive already archived messages
  571. {
  572. echo "";
  573. }
  574. echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class=\"eingabe\" type=\"submit\" name=\"msg_action\" value=\"Löschen\">";
  575. if ((($folder == 6 ) && $row['recip'] == $me->uid) || ($folder == 1))
  576. echo "&nbsp;&nbsp;&nbsp;<input class=\"eingabe\" type=\"submit\" name=\"msg_action\" value=\"Archivieren\"></form>\n";
  577. break;
  578. case 2:
  579. if (isset ($_REQUEST['r']))
  580. $recipients[] = $_REQUEST['r'];
  581. if (isset ($_REQUEST['subject']))
  582. {
  583. //$sub_tmp = split_string($_REQUEST['subject'], 2);
  584. $sub_tmp_array = explode(":", $_REQUEST['subject']);
  585. if (substr($sub_tmp_array[0], 0, 6) == "[Ally]")
  586. {
  587. //mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
  588. $sub_tmp_array[0] = str_replace("[Ally]", "", $sub_tmp_array[0]);
  589. }
  590. if (substr($sub_tmp_array[0], 0, 2) == "Re") // we answer to an answer. so we have to upgrade the counter
  591. {
  592. $counter = (int)substr($sub_tmp_array[0], 3);
  593. $counter++;
  594. $subject = "Re^".$counter;
  595. foreach ($sub_tmp_array as $idx => $value)
  596. {
  597. //ignore the "Re:"-entry
  598. if ($idx != 0)
  599. {
  600. $subject = $subject.":".stripslashes($sub_tmp_array[$idx]);
  601. }
  602. }
  603. }
  604. else // that message is the origin message. so we create the new counter
  605. {
  606. $subject = stripslashes ("Re^1: ".$_REQUEST['subject']);
  607. }
  608. //$subject = stripslashes ("Re: ".$_REQUEST['subject']); // FIXME: Need more logic here
  609. }
  610. if (isset ($_REQUEST['body']))
  611. {
  612. if ($no_go)
  613. {
  614. $body = $_REQUEST['body']; // This is the case if something went wrong while trying to send a submitted message
  615. }
  616. else
  617. {
  618. if (($_REQUEST['o'] == 3) || ($_REQUEST['o'] == 5))
  619. $body = "\n\n___________________________________________\nAm ".$_REQUEST['olddate']." schrieb ".stripslashes ($me->user).":\n".stripslashes ($_REQUEST['body']);
  620. else
  621. $body = "\n\n___________________________________________\nAm ".$_REQUEST['olddate']." schrieb ".stripslashes ($_REQUEST['r']).":\n".stripslashes ($_REQUEST['body']);
  622. }
  623. }
  624. echo "<div><form name=\"msg\" action=\"bote.php\" method=\"POST\"><table class=\"border\">\n";
  625. echo "<tr><th class=\"bold\" colspan=\"2\">Empfänger</th></tr>";
  626. echo '<tr><td colspan="2"><span class="info">Du kannst mehrere Empfänger eingeben, indem du auf das Plus klickst.</span></td></tr>';
  627. echo "<tr><td colspan=\"2\"><input id=\"recipient0\" name=\"recipient[0]\" value=\"".$_REQUEST['r']."\" size=\"20\">";
  628. echo "<div id=\"addimg\"><img src=\"styles/".$_SESSION['theme']."/add.png\" onclick=\"addRec()\"></div><div id=\"more\"></div><div id=\"errormsg\"></div></td></tr>\n";
  629. if ($me->aid)
  630. {
  631. echo "<tr><td colspan=\"2\">oder <input type=\"checkbox\" name=\"to_all_members\" value=\"ON\" onclick=\"toggleAllyMsg()\">Allianz-Rundmail schreiben. ";
  632. echo '<span class="info">Du brauchst dann keinen Empf&auml;nger einzugeben.</span> </td></tr>';
  633. }
  634. echo '<tr><th class="bold" colspan="2">Nachricht</th></tr>';
  635. echo "<tr><td align=\"left\">Betreff:</td><td ><input class=\"eingabe\" maxlength=\"30\" name=\"subject\" size=\"30\" value=\"".$subject."\"></td><tr>\n";
  636. echo "<tr><td colspan=\"3\" style=\"position:absolute; height:10px; overflow:visible;\"></td></tr>\n";
  637. echo "<tr><td colspan=\"3\"><textarea name=\"body\" cols=\"80\" rows=\"13\">".$body."</textarea>\n";
  638. echo "<input class=\"eingabe\" type=\"submit\" name=\"msg_submit\" value=\"Absenden\"></td></tr>";
  639. echo "</table><input type=\"hidden\" name=\"f\" value=\"1\"><input type=\"hidden\" name=\"c\" value=\"".$me->reload_counter."\"></form>\n";
  640. break;
  641. case 6:
  642. if (isset ($_REQUEST['id']))
  643. {
  644. $id = $_REQUEST['id'];
  645. unset ($query);
  646. if (isset ($_REQUEST['o']))
  647. {
  648. if (($_REQUEST['o'] == 3) || ($_REQUEST['o'] == 5))
  649. {
  650. $query = "select A.*, date_format(A.sent, \"%d.%c.%Y um %H:%i\") as sent, B.user from messages A left join user B on (A.recip=B.uid) where A.id=".$id." and A.sender=".$me->uid;
  651. $title = "Empfänger";
  652. }
  653. }
  654. if (!isset ($query))
  655. {
  656. $query = "select A.*, date_format(A.sent, \"%d.%c.%Y um %H:%i\") as sent, B.user from messages A left join user B on (A.sender=B.uid) where A.id=".$id." and A.recip=".$me->uid;
  657. $title = "Absender";
  658. }
  659. $res = mysql_query ($query);
  660. if ($row = mysql_fetch_array ($res))
  661. {
  662. echo "<div><form name=\"message\" action=\"bote.php\" method=\"POST\">\n";
  663. echo "<table class=\"border\">\n";
  664. echo '<tr><th colspan="2" class="bold">'.stripslashes ($row['subject']).'';
  665. echo "<tr><td >".$title.":</td><td >";
  666. if ($row['user'])
  667. echo stripslashes ($row['user'])."</td></tr>\n";
  668. else
  669. echo stripslashes ($row['name'])."</td></tr>\n";
  670. // echo "<tr><td >Betreff:</td><td >".stripslashes ($row['subject'])."</td></tr>\n";
  671. echo "<tr><td >Gesendet am:</td><td>".stripslashes ($row['sent'])."</td></tr>\n";
  672. echo "<tr><td colspan=\"2\" style=\"position:absolute; height:5px; overflow:visible;\"></td></tr>\n";
  673. echo "<tr><td colspan=\"2\" align=\"left\"><textarea name=\"body\" cols=\"80\" rows=\"14\" readonly>".stripslashes ($row['body'])."</textarea></td></tr>\n";
  674. echo "<tr><td colspan=\"2\" style=\"position:absolute; height:5px; overflow:visible;\"></td></tr>\n";
  675. echo "<tr><td><input type=\"button\" onClick=\"show_melden ('msg_action');\" value=\"Melden\">&nbsp;<!--<small>Beleidigungen, Rassismus usw. melden--></small></td>\n";
  676. echo "<td align=\"right\"><input type=\"submit\" name=\"msg_action\" value=\"Löschen\">&nbsp;&nbsp;";
  677. echo "<input type=\"submit\" name=\"msg_action\" value=\"Ungelesen\">&nbsp;";
  678. if (($row['archived'] == 0) && ($row['recip'] == $me->uid))
  679. echo "<input type=\"submit\" name=\"msg_action\" value=\"Archivieren\">&nbsp;&nbsp;";
  680. echo "<input type=\"submit\" name=\"msg_action\" value=\"Antworten\"></td></tr>\n";
  681. echo "</table><input type=\"hidden\" name=\"f\" value=\"2\">\n";
  682. echo "<input type=\"hidden\" name=\"id\" value=\"".$id."\">";
  683. echo "<input type=\"hidden\" name=\"r\" value=\"".$row['user']."\">\n";
  684. echo "<input type=\"hidden\" name=\"subject\" value=\"".$row['subject']."\">\n";
  685. echo "<input type=\"hidden\" name=\"olddate\" value=\"".$row['sent']."\">\n";
  686. echo "<input type=\"hidden\" name=\"c\" value=\"".$me->reload_counter."\">\n";
  687. if (isset ($_REQUEST['o']))
  688. echo "<input type=\"hidden\" name=\"o\" value=\"".$_REQUEST['o']."\">\n";
  689. echo '<div id="meldarea"></div>';
  690. echo "</form></div>\n";
  691. if (($row['msg_read'] == 0) && ($title == "Absender"))
  692. {
  693. $query = "update messages set msg_read=1, sent=sent where id=".$id;
  694. if (!@mysql_query ($query))
  695. {
  696. echo "Konnte nicht als gelesen markieren! ".mysql_error();
  697. }
  698. if ($user_row[1] > 0)
  699. {
  700. $query = "update user set msgs=msgs-1 where uid=".$me->uid;
  701. if (!@mysql_query ($query))
  702. {
  703. echo "Konnte ungelesene Nachrichten nicht dekrementieren! ".mysql_error();
  704. }
  705. }
  706. }
  707. }
  708. else
  709. echo "<b>Nachricht existiert nicht!</b>\n";
  710. }
  711. break;
  712. case 7:
  713. /* echo "<table width=\"98%\"><tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  714. echo "<tr><th colspan=\"2\">Offene Quests</th></tr>";
  715. echo "<tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  716. echo "<tr><td>Quest 4 [draufklicklink] Name[/dkl]: </td><td>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td>";
  717. echo "<tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  718. echo "<tr><th colspan=\"2\">Abgeschlossene Quests</th></tr>";
  719. echo "<tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  720. echo "<tr><td>Quest 3 [draufklicklink]: </td><td>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td>";
  721. echo "<tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  722. echo "<tr><td>Quest 2 [draufklicklink]: </td><td>+ Lorem ipsum dolor sit amet, consectetur adipisici ....</td>";
  723. echo "<tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  724. echo "<tr><td>Quest 1 [draufklicklink]: </td><td>+ Lorem ipsum dolor sit amet, consectetur adipisici ....</td>";
  725. echo "<tr><td colspan=\"2\" height=\"1px\"><img src=\"styles/".$_SESSION['theme']."/line_thin.gif\" width=\"98%\" height=\"1px\"></td></tr>";
  726. echo "<table><tr><td></td><td></td>";*/
  727. break;
  728. }
  729. ?>
  730. </form>
  731. </div>
  732. </div>
  733. <?php
  734. require_once("footer.php");
  735. ?>