PageRenderTime 64ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/e107_plugins/forum/forum_post.php

https://github.com/e107/e107
PHP | 710 lines | 626 code | 51 blank | 33 comment | 118 complexity | e1cd626421973ead98d5670305fc0190 MD5 | raw file
  1. <?php
  2. /*
  3. + ----------------------------------------------------------------------------+
  4. | e107 website system
  5. |
  6. | Copyright (C) 2001-2002 Steve Dunstan (jalist@e107.org)
  7. | Copyright (C) 2008-2010 e107 Inc (e107.org)
  8. |
  9. |
  10. | Released under the terms and conditions of the
  11. | GNU General Public License (http://gnu.org).
  12. |
  13. | $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.7/e107_plugins/forum/forum_post.php $
  14. | $Revision: 12631 $
  15. | $Id: forum_post.php 12631 2012-04-12 19:30:41Z e107steved $
  16. | $Author: e107steved $
  17. +----------------------------------------------------------------------------+
  18. */
  19. // Experimental e-token
  20. if(isset($_POST['userlogin']) && !isset($_POST['e-token']))
  21. {
  22. // set e-token so it can be processed by class2
  23. $_POST['e-token'] = '';
  24. }
  25. require_once("../../class2.php");
  26. if (!isset($pref['plug_installed']['forum']))
  27. {
  28. header('Location: '.e_BASE.'index.php');
  29. exit;
  30. }
  31. $e_wysiwyg = "post";
  32. include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_post.php');
  33. if (IsSet($_POST['fjsubmit'])) {
  34. header("location:".e_BASE.$PLUGINS_DIRECTORY."forum/forum_viewforum.php?".$_POST['forumjump']);
  35. exit;
  36. }
  37. require_once(e_PLUGIN.'forum/forum_class.php');
  38. $forum = new e107forum;
  39. if (!e_QUERY) {
  40. header("Location:".e_PLUGIN."forum/forum.php");
  41. exit;
  42. } else {
  43. $tmp = explode(".", e_QUERY);
  44. $action = preg_replace('#\W#', '', $tmp[0]);
  45. $id = intval($tmp[1]);
  46. $from = intval($tmp[2]);
  47. }
  48. // check if user can post to this forum ...
  49. if ($action == 'rp')
  50. {
  51. // reply to thread
  52. $thread_info = $forum->thread_get($id, 'last', 11);
  53. if (!is_array($thread_info) || !count($thread_info))
  54. {
  55. $forum_info = FALSE; // Someone fed us a dud forum id - should exist if replying
  56. }
  57. elseif ($thread_info['head']['thread_active'] == 0)
  58. { // Locked thread - posting not allowed
  59. $forum_info = FALSE;
  60. }
  61. else
  62. {
  63. $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
  64. }
  65. }
  66. elseif ($action == 'nt')
  67. {
  68. // New thread
  69. $forum_info = $forum->forum_get($id);
  70. }
  71. elseif ($action == 'quote' || $action == 'edit')
  72. {
  73. $thread_info = $forum->thread_get_postinfo($id, TRUE);
  74. $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
  75. if($action == 'quote')
  76. {
  77. $id = $thread_info['head']['thread_id'];
  78. }
  79. }
  80. if (($forum_info === FALSE) || !check_class($forum_info['forum_postclass']) || !check_class($forum_info['parent_postclass']))
  81. {
  82. require_once(HEADERF);
  83. $ns->tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
  84. require_once(FOOTERF);
  85. exit;
  86. }
  87. define("MODERATOR", check_class($forum_info['forum_moderators']));
  88. //require_once(e_HANDLER.'forum_include.php');
  89. require_once(e_PLUGIN."forum/forum_post_shortcodes.php");
  90. require_once(e_PLUGIN."forum/forum_shortcodes.php");
  91. require_once(e_HANDLER."ren_help.php");
  92. $gen = new convert;
  93. $fp = new floodprotect;
  94. global $tp, $e_event;
  95. if ($sql->db_Select("tmp", "*", "tmp_ip='$ip' ")) {
  96. $row = $sql->db_Fetch();
  97. $tmp = explode("^", $row['tmp_info']);
  98. $action = $tmp[0];
  99. $anonname = $tmp[1];
  100. $subject = $tmp[2];
  101. $post = $tmp[3];
  102. $sql->db_Delete("tmp", "tmp_ip='$ip' ");
  103. }
  104. //Check to see if user had post rights
  105. if (!check_class($forum_info['forum_postclass']))
  106. {
  107. require_once(HEADERF);
  108. $text .= "<div style='text-align:center'>".LAN_399."</div>";
  109. $ns->tablerender(LAN_20, $text);
  110. require_once(FOOTERF);
  111. exit;
  112. }
  113. //if thread is not active and not new thread, show warning
  114. if ($action != "nt" && !$thread_info['head']['thread_active'] && !MODERATOR)
  115. {
  116. require_once(HEADERF);
  117. $ns->tablerender(LAN_20, "<div style='text-align:center'>".LAN_397."</div>");
  118. require_once(FOOTERF);
  119. exit;
  120. }
  121. $forum_info['forum_name'] = $tp -> toHTML($forum_info['forum_name'], TRUE);
  122. define("e_PAGETITLE", LAN_01." / ".$forum_info['forum_name']." / ".($action == "rp" ? LAN_02.$forum_info['thread_name'] : LAN_03));
  123. // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  124. if (is_readable(e_ADMIN.'filetypes.php')) {
  125. $a_filetypes = trim(file_get_contents(e_ADMIN.'filetypes.php'));
  126. $a_filetypes = explode(',', $a_filetypes);
  127. foreach ($a_filetypes as $ftype) {
  128. $sa_filetypes[] = '.'.trim(str_replace('.', '', $ftype));
  129. }
  130. $allowed_filetypes = implode(' | ', $sa_filetypes);
  131. }
  132. if (isset($_POST['submitpoll']))
  133. {
  134. require_once(e_PLUGIN."poll/poll_class.php");
  135. $poll = new poll;
  136. require_once(HEADERF);
  137. if (!$FORUMPOST)
  138. {
  139. if (file_exists(THEME."forum_posted_template.php"))
  140. {
  141. require_once(THEME."forum_posted_template.php");
  142. }
  143. else
  144. {
  145. require_once(e_PLUGIN."forum/templates/forum_posted_template.php");
  146. }
  147. }
  148. echo $FORUMPOLLPOSTED;
  149. require_once(FOOTERF);
  150. exit;
  151. }
  152. if (isset($_POST['fpreview']))
  153. {
  154. process_upload();
  155. require_once(HEADERF);
  156. if (USER)
  157. {
  158. $poster = USERNAME;
  159. }
  160. else
  161. {
  162. $poster = ($_POST['anonname']) ? $_POST['anonname'] : LAN_311;
  163. }
  164. $postdate = $gen->convert_date(time(), "forum");
  165. $tsubject = $tp->post_toHTML($_POST['subject'], true);
  166. $tpost = $tp->post_toHTML($_POST['post'], true);
  167. if ($_POST['poll_title'] != "" && $pref['forum_poll'])
  168. {
  169. require_once(e_PLUGIN."poll/poll_class.php");
  170. $poll = new poll;
  171. $poll->render_poll($_POST, "forum", "notvoted");
  172. }
  173. if (!$FORUM_PREVIEW)
  174. {
  175. if (file_exists(THEME."forum_preview_template.php"))
  176. {
  177. require_once(THEME."forum_preview_template.php");
  178. }
  179. else
  180. {
  181. require_once(e_PLUGIN."forum/templates/forum_preview_template.php");
  182. }
  183. }
  184. $text = $FORUM_PREVIEW;
  185. if ($poll_text)
  186. {
  187. $ns->tablerender($_POST['poll_title'], $poll_text);
  188. }
  189. $ns->tablerender(LAN_323, $text);
  190. $anonname = $tp->post_toHTML($_POST['anonname'], FALSE);
  191. $post = $tp->post_toForm($_POST['post']);
  192. $subject = $tp->post_toHTML($_POST['subject'], false);
  193. if ($action == "edit")
  194. {
  195. if ($_POST['subject'])
  196. {
  197. $action = "edit";
  198. }
  199. else
  200. {
  201. $action = "reply";
  202. }
  203. $eaction = TRUE;
  204. }
  205. else if($action == "quote")
  206. {
  207. $action = "reply";
  208. $eaction = FALSE;
  209. }
  210. }
  211. if (isset($_POST['newthread']) || isset($_POST['reply']))
  212. {
  213. $poster = array();
  214. if ((isset($_POST['newthread']) && trim($_POST['subject']) == "") || trim($_POST['post']) == "")
  215. {
  216. message_handler("ALERT", 5);
  217. }
  218. else
  219. {
  220. if ($fp->flood("forum_t", "thread_datestamp") == FALSE && !ADMIN)
  221. {
  222. echo "<script type='text/javascript'>document.location.href='".e_BASE."index.php'</script>\n";
  223. }
  224. if (USER)
  225. {
  226. $poster['post_userid'] = USERID;
  227. $poster['post_user_name'] = USERNAME;
  228. }
  229. else
  230. {
  231. $poster = getuser($_POST['anonname']);
  232. if ($poster == -1)
  233. {
  234. require_once(HEADERF);
  235. $ns->tablerender(LAN_20, LAN_310);
  236. if (isset($_POST['reply']))
  237. {
  238. $tmpdata = "reply.".$tp -> toDB($_POST['anonname']).".".$tp -> toDB($_POST['subject']).".".$tp -> toDB($_POST['post']);
  239. }
  240. else
  241. {
  242. $tmpdata = "newthread^".$tp -> toDB($_POST['anonname'])."^".$tp -> toDB($_POST['subject'])."^".$tp -> toDB($_POST['post']);
  243. }
  244. $sql->db_Insert("tmp", "'$ip', '".time()."', '$tmpdata' ");
  245. loginf();
  246. require_once(FOOTERF);
  247. exit;
  248. }
  249. }
  250. process_upload();
  251. $post = $tp->toDB($_POST['post']);
  252. $subject = $tp->toDB($_POST['subject']);
  253. $email_notify = ($_POST['email_notify'] ? 99 : 1);
  254. if ($_POST['poll_title'] != "" && $_POST['poll_option'][0] != "" && $_POST['poll_option'][1] != "")
  255. {
  256. $subject = "[".LAN_402."] ".$subject;
  257. }
  258. $threadtype = (MODERATOR ? intval($_POST['threadtype']) : 0);
  259. if (isset($_POST['reply']))
  260. {
  261. $parent = $id;
  262. $forum_id = $thread_info['head']['thread_forum_id'];
  263. }
  264. else
  265. {
  266. $parent = 0;
  267. $forum_id = $id;
  268. }
  269. $iid = $forum->thread_insert($subject, $post, $forum_id, $parent, $poster, $email_notify, $threadtype, $forum_info['forum_sub']);
  270. //fire event forumthreadcreate
  271. if (isset($_POST['newthread']))
  272. {
  273. $edata_fo = array("subject" => $subject, "post" => $post, "poster" => $poster, "forum_name" => $forum_info['forum_name']);
  274. $e_event -> trigger("forumthreadcreate", $edata_fo);
  275. }
  276. // fire event 'forumpostcreate
  277. if (isset($_POST['reply']))
  278. {
  279. $edata_fo = array("post" => $post, "poster" => $poster, "forum_name" => $forum_info['forum_name']);
  280. $e_event -> trigger("forumpostcreate", $edata_fo);
  281. }
  282. if($iid === -1)
  283. {
  284. require_once(HEADERF);
  285. $ns->tablerender("", LAN_FORUM_2);
  286. require_once(FOOTERF);
  287. exit;
  288. }
  289. if (isset($_POST['reply'])) {
  290. $reply = $iid;
  291. $iid = $parent;
  292. }
  293. if ($_POST['poll_title'] != "" && $_POST['poll_option'][0] != "" && $_POST['poll_option'][1] != "" && isset($_POST['newthread'])) {
  294. require_once(e_PLUGIN."poll/poll_class.php");
  295. $_POST['iid'] = $iid;
  296. $poll = new poll;
  297. $poll -> submit_poll(2);
  298. }
  299. $e107cache->clear("newforumposts");
  300. if ($pref['forum_redirect'])
  301. {
  302. redirect(e_PLUGIN."forum/forum_viewtopic.php?{$iid}.last");
  303. }
  304. else
  305. {
  306. require_once(HEADERF);
  307. if (!$FORUMPOST)
  308. {
  309. if (file_exists(THEME."forum_posted_template.php"))
  310. {
  311. require_once(THEME."forum_posted_template.php");
  312. }
  313. else
  314. {
  315. require_once(e_PLUGIN."forum/templates/forum_posted_template.php");
  316. }
  317. }
  318. echo (isset($_POST['newthread']) ? $FORUMTHREADPOSTED : $FORUMREPLYPOSTED);
  319. require_once(FOOTERF);
  320. exit;
  321. }
  322. }
  323. }
  324. require_once(HEADERF);
  325. if (isset($_POST['update_thread']))
  326. {
  327. if (!$_POST['subject'] || !$_POST['post'])
  328. {
  329. $error = "<div style='text-align:center'>".LAN_27."</div>";
  330. }
  331. else
  332. {
  333. if (!isAuthor())
  334. {
  335. $ns->tablerender(LAN_95, "<div style='text-align:center'>".LAN_96."</div>");
  336. require_once(FOOTERF);
  337. exit;
  338. }
  339. $newvals['thread_edit_datestamp'] = time();
  340. $newvals['thread_thread'] = $_POST['post'];
  341. $newvals['thread_name'] = $_POST['subject'];
  342. $newvals['thread_active'] = (isset($_POST['email_notify'])) ? '99' : '1'; // Always set in case it's changed
  343. if (isset($_POST['threadtype']) && MODERATOR)
  344. {
  345. $newvals['thread_s'] = $_POST['threadtype'];
  346. }
  347. $forum->thread_update($id, $newvals);
  348. $e107cache->clear("newforumposts");
  349. $url = e_PLUGIN."forum/forum_viewtopic.php?{$thread_info['head']['thread_id']}.0";
  350. echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
  351. }
  352. }
  353. if (isset($_POST['update_reply']))
  354. {
  355. if (!$_POST['post'])
  356. {
  357. $error = "<div style='text-align:center'>".LAN_27."</div>";
  358. }
  359. else
  360. {
  361. if (!isAuthor())
  362. {
  363. $ns->tablerender(LAN_95, "<div style='text-align:center'>".LAN_96."</div>");
  364. require_once(FOOTERF);
  365. exit;
  366. }
  367. $url = e_PLUGIN."forum/forum_viewtopic.php?{$id}.post";
  368. echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
  369. $newvals['thread_edit_datestamp'] = time();
  370. $newvals['thread_thread'] = $_POST['post'];
  371. $forum->thread_update($id, $newvals);
  372. $e107cache->clear("newforumposts");
  373. $url = e_PLUGIN."forum/forum_viewtopic.php?{$id}.post";
  374. echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
  375. }
  376. }
  377. if ($error)
  378. {
  379. $ns->tablerender(LAN_20, $error);
  380. }
  381. if ($action == 'edit' || $action == 'quote')
  382. {
  383. if ($action == "edit")
  384. {
  385. if (!isAuthor())
  386. {
  387. $ns->tablerender(LAN_95, "<div style='text-align:center'>".LAN_96."</div>");
  388. require_once(FOOTERF);
  389. exit;
  390. }
  391. }
  392. if(!is_array($thread_info[0]))
  393. {
  394. $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_96."</div>");
  395. require_once(FOOTERF);
  396. exit;
  397. }
  398. $thread_info[0]['user_name'] = $forum->thread_user($thread_info[0]);
  399. if (!isset($_POST['fpreview']))
  400. {
  401. $subject = $thread_info['0']['thread_name'];
  402. $post = $tp->toForm($thread_info[0]['thread_thread']);
  403. }
  404. $post = preg_replace("/&lt;span class=&#39;smallblacktext&#39;.*\span\>/", "", $post);
  405. if ($action == 'quote')
  406. {
  407. $post = preg_replace("#\[hide].*?\[/hide]#s", "", $post);
  408. $tmp = explode(chr(1), $thread_info[0]['user_name']);
  409. $timeStamp = time();
  410. $post = "[quote{$timeStamp}={$tmp[0]}]\n".$post."\n[/quote{$timeStamp}]\n";
  411. $eaction = FALSE;
  412. $action = 'reply';
  413. }
  414. else
  415. {
  416. $eaction = TRUE;
  417. if ($thread_info['0']['thread_parent'])
  418. {
  419. $action = "reply";
  420. }
  421. else
  422. {
  423. $action = "nt";
  424. $sact = "canc"; // added to override the bugtracker query below
  425. }
  426. }
  427. }
  428. // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  429. //Load forumpost template
  430. if (!$FORUMPOST)
  431. {
  432. if (is_readable(THEME."forum_post_template.php"))
  433. {
  434. include_once(THEME."forum_post_template.php");
  435. }
  436. else
  437. {
  438. include_once(e_PLUGIN."forum/templates/forum_post_template.php");
  439. }
  440. }
  441. /* check post access (bugtracker #1424) */
  442. if($action == "rp" && !$sql -> db_Select("forum_t", "*", "thread_id='{$id}'"))
  443. {
  444. $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
  445. require_once(FOOTERF);
  446. exit;
  447. }
  448. elseif($action == "nt")
  449. {
  450. if (!$sact && !$sql -> db_Select("forum", "*", "forum_id='{$id}'"))
  451. {
  452. $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
  453. require_once(FOOTERF);
  454. exit;
  455. }
  456. }
  457. else
  458. {
  459. // DB access should pass - after all, the thread should exist
  460. $sql->db_Select_gen("SELECT t.*, p.forum_postclass FROM #forum_t AS t
  461. LEFT JOIN #forum AS p ON t.thread_forum_id=p.forum_id WHERE thread_id='{$id}'");
  462. $fpr = $sql -> db_Fetch();
  463. if(!check_class($fpr['forum_postclass']))
  464. {
  465. $ns -> tablerender(LAN_20, "<div style='text-align:center'>".LAN_399."</div>");
  466. require_once(FOOTERF);
  467. exit;
  468. }
  469. }
  470. if($action == 'rp')
  471. {
  472. $FORUMPOST = $FORUMPOST_REPLY;
  473. }
  474. $text = $tp->parseTemplate($FORUMPOST, FALSE, $forum_post_shortcodes);
  475. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  476. if ($pref['forum_enclose'])
  477. {
  478. $ns->tablerender($pref['forum_title'], $text);
  479. }
  480. else
  481. {
  482. echo $text;
  483. }
  484. function isAuthor()
  485. {
  486. global $thread_info;
  487. $tmp = explode(".", $thread_info[0]['thread_user'], 2);
  488. return ($tmp[0] == USERID || MODERATOR);
  489. }
  490. function getuser($name)
  491. {
  492. global $tp, $sql, $e107;
  493. $ret = array();
  494. $ip = $e107->getip();
  495. $name = str_replace("'", "", $name);
  496. if (!$name)
  497. {
  498. // anonymous guest
  499. // $name = "0.".LAN_311.chr(1).$ip;
  500. $ret['post_userid'] = "0";
  501. $ret['post_user_name'] = LAN_311;
  502. return $ret;
  503. }
  504. else
  505. {
  506. if ($sql->db_Select("user", "user_id, user_ip", "user_name='".$tp -> toDB($name)."'"))
  507. {
  508. $row = $sql->db_Fetch();
  509. if ($row['user_ip'] == $ip)
  510. {
  511. $ret['post_userid'] = $row['user_id'];
  512. $ret['post_user_name'] = $name;
  513. }
  514. else
  515. {
  516. return -1;
  517. }
  518. }
  519. else
  520. {
  521. // $name = "0.".substr($tp->toDB($name), 0, 20).chr(1).$ip;
  522. $ret['post_userid'] = "0";
  523. $ret['post_user_name'] = $tp->toDB($name);
  524. }
  525. }
  526. return $ret;
  527. }
  528. function loginf() {
  529. $text .= "<div style='text-align:center'>
  530. <form method='post' action='".e_SELF."?".e_QUERY."'><p>
  531. ".LAN_16."<br />
  532. <input class='tbox' type='text' name='username' size='15' value='' maxlength='20' />\n
  533. <br />
  534. ".LAN_17."
  535. <br />
  536. <input class='tbox' type='password' name='userpass' size='15' value='' maxlength='20' />\n
  537. <br />
  538. <input class='button' type='submit' name='userlogin' value='".LAN_10."' />\n
  539. <br />
  540. <input type='checkbox' name='autologin' value='1' /> ".LAN_11."
  541. <input type='hidden' name='e-token' value='".e_TOKEN."' /><br /><br />
  542. [ <a href='".e_SIGNUP."'>".LAN_174."</a> ]<br />[ <a href='".e_BASE."fpw.php'>".LAN_212."</a> ]
  543. </p>
  544. </form>
  545. </div>";
  546. $ns = new e107table;
  547. $ns->tablerender(LAN_175, $text);
  548. }
  549. function forumjump()
  550. {
  551. global $forum;
  552. $jumpList = $forum->forum_get_allowed();
  553. $text = "<form method='post' action='".e_SELF."'><p>".LAN_401.": <select name='forumjump' class='tbox'>";
  554. foreach($jumpList as $key => $val)
  555. {
  556. $text .= "\n<option value='".$key."'>".$val."</option>";
  557. }
  558. $text .= "</select> <input class='button' type='submit' name='fjsubmit' value='".LAN_387."' /></p></form>";
  559. return $text;
  560. }
  561. function redirect($url)
  562. {
  563. echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
  564. }
  565. function process_upload()
  566. {
  567. global $pref, $forum_info, $thread_info, $admin_log;
  568. if(isset($thread_info['head']['thread_id']))
  569. {
  570. $tid = $thread_info['head']['thread_id'];
  571. }
  572. else
  573. {
  574. $tid = 0;
  575. }
  576. if (isset($_FILES['file_userfile']['error']))
  577. {
  578. require_once(e_HANDLER."upload_handler.php");
  579. if ($uploaded = file_upload('/'.e_FILE."public/", "attachment", "FT{$tid}_"))
  580. {
  581. foreach($uploaded as $upload)
  582. {
  583. if ($upload['error'] == 0)
  584. {
  585. $fpath = "{e_FILE}public/";
  586. if(strstr($upload['type'], "image"))
  587. {
  588. if(isset($pref['forum_maxwidth']) && $pref['forum_maxwidth'] > 0)
  589. {
  590. require_once(e_HANDLER."resize_handler.php");
  591. $orig_file = $upload['name'];
  592. $p = strrpos($orig_file,'.');
  593. $new_file = substr($orig_file, 0 , $p)."_".substr($orig_file, $p);
  594. if(resize_image(e_FILE.'public/'.$orig_file, e_FILE.'public/'.$new_file, $pref['forum_maxwidth']))
  595. {
  596. if($pref['forum_linkimg'])
  597. {
  598. $parms = image_getsize(e_FILE.'public/'.$new_file);
  599. $_POST['post'] .= "[br][link=".$fpath.$orig_file."][img{$parms}]".$fpath.$new_file."[/img][/link][br]";
  600. //show resized, link to fullsize
  601. }
  602. else
  603. {
  604. @unlink(e_FILE.'public/'.$orig_file);
  605. //show resized
  606. $parms = image_getsize(e_FILE.'public/'.$new_file);
  607. $_POST['post'] .= "[br][img{$parms}]".$fpath.$new_file."[/img][br]";
  608. }
  609. }
  610. else
  611. { //resize failed, show original
  612. $parms = image_getsize(e_FILE.'public/'.$upload['name']);
  613. $_POST['post'] .= "[br][img{$parms}]".$fpath.$upload['name']."[/img]";
  614. }
  615. }
  616. else
  617. { //resizing disabled, show original
  618. $parms = image_getsize(e_FILE.'public/'.$upload['name']);
  619. //resizing disabled, show original
  620. $_POST['post'] .= "[br]<div class='spacer'>[img{$parms}]".$fpath.$upload['name']."[/img]</div>\n";
  621. }
  622. }
  623. else
  624. {
  625. //upload was not an image, link to file
  626. $_POST['post'] .= "[br][file=".$fpath.$upload['name']."]".(isset($upload['rawname']) ? $upload['rawname'] : $upload['name'])."[/file]";
  627. }
  628. }
  629. else
  630. { // Error in uploaded file
  631. echo "Error in uploaded file: ".(isset($upload['rawname']) ? $upload['rawname'] : $upload['name'])."<br />";
  632. }
  633. }
  634. }
  635. }
  636. }
  637. function image_getsize($fname)
  638. {
  639. if($imginfo = getimagesize($fname))
  640. {
  641. return ":width={$imginfo[0]}&height={$imginfo[1]}";
  642. }
  643. else
  644. {
  645. return "";
  646. }
  647. }
  648. require_once(FOOTERF);
  649. ?>