Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.51 KB | None | 0 0
  1. {php}
  2. $name=$this->_tpl_vars['user']['username'];
  3. $ally=$this->_tpl_vars['user']['ally'];
  4. $id=$_GET[id];
  5. $mode=$_GET['modf'];
  6. if($mode==""){$mode="none";}
  7. include('../include/config.php');
  8. $host=$config['db_host'];
  9. $username=$config['db_user'];
  10. $password=$config['db_pw'];
  11. $db_name="lan"; // Database name
  12. $tbl_name="forum_question"; // Table name
  13.  
  14. // Connect to server and select databse.
  15. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  16. mysql_select_db("$db_name")or die("cannot select DB");
  17.  
  18. $sql="SELECT * FROM $tbl_name WHERE forumid=$id AND allyid=$ally ORDER BY id DESC";
  19. // OREDER BY id DESC is order result by descending
  20. $result=mysql_query($sql);
  21.  
  22. $sqlt="SELECT * FROM `forums` WHERE `allyid`='$ally'";
  23. $sqls="SELECT * FROM `forums` WHERE `allyid`='$ally' AND `id`='$id'";
  24. $r=mysql_query($sqls);$rt=mysql_query($sqlt);
  25. $rr=mysql_fetch_array($r);
  26. {/php}
  27.  
  28. {literal}
  29. <script type="text/javascript">
  30. <!--
  31. function toggle_visibility(id) {
  32. var e = document.getElementById(id);
  33. if(e.style.display == 'block')
  34. e.style.display = 'none';
  35. else
  36. e.style.display = 'block';
  37. }
  38. //-->
  39. </script>
  40. {/literal}
  41. <head>
  42. {literal}
  43. <script src="script.js" type="text/javascript"></script>
  44. <script src="mootools.js" type="text/javascript"></script>
  45.  
  46. <script>
  47. function addCode(emoticon)
  48. {
  49. document.new_thread.message.value=document.new_thread.message.value+emoticon;
  50. document.new_thread.message.focus();
  51. return;
  52. }
  53. </script>
  54. {/literal}
  55. </head>
  56. <link rel="stylesheet" type="text/css" href="stamm.css" />
  57. <table class="vis" width="800">
  58. <tr><th colspan="3">Forumul Tribului</th></tr>
  59. <tr><td>
  60. <table align=left>
  61. <tr>
  62. {php}
  63. while ($rrt=mysql_fetch_array($rt)){
  64. {/php}
  65. <td class="selected" style="border:1px solid #804000;" height=25>{php} if($rrt[id]==$id){echo "<b>".$rrt[titlu]."</b>";}else{{/php}<b><a href="forum.php?id={php} echo $rrt[id]{/php}">{php} echo $rrt[titlu];}{/php}</a></b></td>
  66. <td height=25 wight=10></td>
  67. {php}
  68. }
  69. {/php}
  70. </tr></table>
  71. </td></tr>
  72. {php} if($mode=='none'){
  73. {/php}
  74. <tr><td>
  75. <h2>{php} echo $rr[titlu];{/php}</h2>
  76. <br />
  77. <a href="forum.php?id={php} echo $rr[id]{/php}&mode=newt"><img style="border:1px;" src="graphic/forum_new.png" /></a>
  78. <table class="vis" width="800">
  79. <tr>
  80. <th>Subiecte</th>
  81. <th>Autor</th>
  82. <th>R&#259;spunsuri</th>
  83. </tr>
  84. {php}
  85. while($rows=mysql_fetch_array($result)){
  86. {/php}
  87. <tr>
  88. <td width=350><a href="forum.php?id={php} echo $rr['id']; {/php}&mode=view_topic&vid={php} echo $rows['id']; {/php}">{php} echo $rows['topic']; {/php}</a></td>
  89. <td width=150 align=center><div align="center" style="font-size: 8pt;"><a href="#" target="_blank">{php} echo $rows['name']; {/php}</a><br />in data de {php} echo $rows['datetime']; {/php}</div></td>
  90. <td width=150 align=center>{php} echo $rows['reply']; {/php}</td>
  91. </tr>
  92. {php}
  93. }
  94. mysql_close();
  95. {/php}
  96. <div align=center><a href="forum.php?id={php} echo $rr['id']; {/php}&mode=admin">Administreaz&#259; forumul</a></div>
  97. <tr>
  98. <th colspan=4>
  99. &nbsp;</th>
  100. </tr>
  101. {php}
  102. } elseif($mode=='newt') {
  103. {/php}
  104. <table class="vis" width="800">
  105. <tr><td colspan="2"><h2>Deschiderea unei teme noi</h2></td></tr>
  106. <form action="forum.php?id={php} echo $rr[id];{/php}&mode=newt" method="post" name="new_thread">
  107. <tr>
  108. <td>Titlu:</td>
  109. <td><input name="subject" type="text" size="64" value="" tabindex="1" /></td>
  110. </tr>
  111. <td>Text:</td>
  112. <td>
  113. <div style="position: relative">
  114. <a title="&#206;ngro&#351;at" href="javascript: addCode('[b][/b]')">
  115. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat 0px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  116. </a>
  117. <a title="Cursiv" href="javascript: addCode('[i][/i]')">
  118. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -20px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  119. </a>
  120. <a title="Subliniat" href="javascript: addCode('[u][/u]')">
  121. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -40px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  122. </a>
  123. <a title="T&#259;iat" href="javascript: addCode('[s][/s]')" onclick="insertBBcode('message', '[s]', '[/s]');">
  124. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -60px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  125. </a>
  126. <a title="Citat" href="javascript: addCode('[quote=Autor][/quote]')" onclick="insertBBcode('message', '[quote=Autor]', '[/quote]');">
  127. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -140px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  128. </a>
  129. <a title="Adres&#259;" href="javascript: addCode('[url][/url]')" onclick="insertBBcode('message', '[url]', '[/url]');">
  130. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -160px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  131. </a>
  132. <a title="Spoiler" href="javascript: addCode('[spoiler][/spoiler]')" onclick="insertBBcode('message', '[spoiler]', '[/spoiler]');">
  133. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -260px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  134. </a>
  135. <a title="Juc&#259;tor" href="javascript: addCode('[player][/player]')" onclick="insertBBcode('message', '[player]', '[/player]');">
  136. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -80px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  137. </a>
  138. <a title="Trib" href="javascript: addCode('[ally][/ally]')" onclick="insertBBcode('message', '[ally]', '[/ally]');">
  139. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -100px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  140. </a>
  141. <a title="Coordonate" href="javascript: addCode('[village][/village]')" onclick="insertBBcode('message', '[village]', '[/village]');">
  142. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -120px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  143. </a>
  144. <a title="M&#259;rimea textului" href="javascript:nothing()" onclick="javascript:toggle_visibility('bb_sizes');">
  145. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -220px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  146. </a>
  147. <a title="Imagine" href="javascript: addCode('[img][/img]')" onclick="insertBBcode('message', '[img]', '[/img]');">
  148. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -180px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  149. </a>
  150.  
  151.  
  152. <table id="bb_sizes" style="display: none; clear:both;">
  153. <tr>
  154. <td>
  155. <a href="javascript: addCode('[size=4][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Foarte mic</a><br />
  156. <a href="javascript: addCode('[size=7][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Mic</a><br />
  157. <a href="javascript: addCode('[size=9][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Normal</a><br />
  158. <a href="javascript: addCode('[size=12][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Mare</a><br />
  159. <a href="javascript: addCode('[size=20][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Foarte mare</a><br />
  160. </td>
  161. </tr>
  162. </table>
  163. </div>
  164. <textarea name="message" id="message" cols="80" rows="12" tabindex="2"></textarea></td>
  165. </tr>
  166. <tr>
  167. <td colspan="2"><input type="submit" value="Expediere" name="send"></td>
  168. </tr>
  169. </form>
  170. </table>
  171. {php}
  172. if (isset($_POST[send])){
  173. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  174. mysql_select_db("$db_name")or die("cannot select DB");
  175. $topic=$_POST['subject'];
  176. $detail=$_POST['message'];
  177. $datetime=date("d/m/y h:i:s");
  178. $tbl_name="forum_question";
  179. $sql="INSERT INTO $tbl_name(topic, detail, name, datetime, forumid, allyid)VALUES('$topic', '$detail', '$name', '$datetime', '$rr[id]', '$ally')";
  180. $result=mysql_query($sql);
  181. if($result){
  182. echo "<meta http-equiv='refresh' content='0; url=forum.php?id=".$rr[id]."'>";
  183. }
  184. else {
  185. echo "ERROR";
  186. }
  187. mysql_close();
  188. }
  189. }elseif($mode=='view_topic'){
  190. {/php}
  191. {php}
  192. $vid=$_GET[vid];
  193. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  194. mysql_select_db("$db_name")or die("cannot select DB");
  195. $sql="SELECT * FROM $tbl_name WHERE id='$vid'";
  196. $result=mysql_query($sql);
  197. $rows=mysql_fetch_array($result);
  198. {/php}
  199. <tr><td><h2>{php} echo $rows[topic];{/php}</h2></td></tr>
  200. <tr><th><a href="" target="_blank" style="font-size:9pt;">{php} echo $rows['name']; {/php}</a> in data de {php} echo $rows['datetime']; {/php} [<a href="">Citat</a>]</th></tr>
  201. <tr><td>{php} echo $rows['detail']; {/php}</td></tr>
  202. {php}
  203. $tbl_name2="forum_answer"; // Switch to table "forum_answer"
  204.  
  205. $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$vid'";
  206. $result2=mysql_query($sql2);
  207. while($rows=mysql_fetch_array($result2)){
  208. {/php}
  209. <tr><th><a href="" target="_blank" style="font-size:9pt;">{php} echo $rows['a_name']; {/php}</a> in data de {php} echo $rows['a_datetime']; {/php} [<a href="">Citat</a>] {php} if($name==$rows[a_name]){echo "[<a href='forum.php?id=".$rr[id]."&mode=view_topic&vid=".$vid."&del=".$rows[id]."'>Sterge</a>]";}{/php}</th></tr>
  210. <tr><td>{php} echo $rows['a_answer']; {/php}</td></tr>
  211. {php}
  212. }
  213. {/php}
  214. <table width="100%"><tr>
  215. <td style="min-width: 150px">
  216. <a href="#" onclick="toggle_visibility('foo');" class="thread_button">
  217. <span class="thread_answer_open"></span>
  218. <span class="thread_answer">Raspunde</span>
  219. <span class="thread_answer_close"></span>
  220. </a> </td></tr>
  221. </table>
  222.  
  223. {php}
  224. $tbl_name2="forum_answer"; // Switch to table "forum_answer"
  225.  
  226. $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$vid'";
  227. $result2=mysql_query($sql2);
  228.  
  229. while($rows=mysql_fetch_array($result2)){
  230. {/php}
  231.  
  232. {php}
  233. }
  234.  
  235. $sql3="SELECT view FROM $tbl_name WHERE id='$vid'";
  236. $result3=mysql_query($sql3);
  237.  
  238. $rows=mysql_fetch_array($result3);
  239. $view=$rows['view'];
  240.  
  241. // if have no counter value set counter = 1
  242. if(empty($view)){
  243. $view=1;
  244. $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$vid'";
  245. $result4=mysql_query($sql4);
  246. }
  247.  
  248. // count more value
  249. $addview=$view+1;
  250. $sql5="update $tbl_name set view='$addview' WHERE id='$vid'";
  251. $result5=mysql_query($sql5);
  252. {/php}
  253. <div id="foo">
  254. <form name="new_thread" method="post" action="forum.php?id={php} echo $rr['id']; {/php}&mode=view_topic&vid={php} echo $vid; {/php}">
  255. <table class="vis">
  256. <tr><td>
  257. <div style="position: relative">
  258. <a title="&#206;ngro&#351;at" href="javascript: addCode('[b][/b]')">
  259. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat 0px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  260. </a>
  261. <a title="Cursiv" href="javascript: addCode('[i][/i]')">
  262. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -20px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  263. </a>
  264. <a title="Subliniat" href="javascript: addCode('[u][/u]')">
  265. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -40px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  266. </a>
  267. <a title="T&#259;iat" href="javascript: addCode('[s][/s]')" onclick="insertBBcode('message', '[s]', '[/s]');">
  268. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -60px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  269. </a>
  270. <a title="Citat" href="javascript: addCode('[quote=Autor][/quote]')" onclick="insertBBcode('message', '[quote=Autor]', '[/quote]');">
  271. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -140px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  272. </a>
  273. <a title="Adres&#259;" href="javascript: addCode('[url][/url]')" onclick="insertBBcode('message', '[url]', '[/url]');">
  274. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -160px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  275. </a>
  276. <a title="Spoiler" href="javascript: addCode('[spoiler][/spoiler]')" onclick="insertBBcode('message', '[spoiler]', '[/spoiler]');">
  277. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -260px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  278. </a>
  279. <a title="Juc&#259;tor" href="javascript: addCode('[player][/player]')" onclick="insertBBcode('message', '[player]', '[/player]');">
  280. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -80px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  281. </a>
  282. <a title="Trib" href="javascript: addCode('[ally][/ally]')" onclick="insertBBcode('message', '[ally]', '[/ally]');">
  283. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -100px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  284. </a>
  285. <a title="Coordonate" href="javascript: addCode('[village][/village]')" onclick="insertBBcode('message', '[village]', '[/village]');">
  286. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -120px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  287. </a>
  288. <a title="M&#259;rimea textului" href="javascript:nothing()" onclick="javascript:toggle_visibility('bb_sizes');">
  289. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -220px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  290. </a>
  291. <a title="Imagine" href="javascript: addCode('[img][/img]')" onclick="insertBBcode('message', '[img]', '[/img]');">
  292. <div style="float: left; background:url(graphic/bbcodes/bbcodes.png?1) no-repeat -180px 0px; padding-left: 0px; padding-bottom:0px; margin-right: 4px; width: 20px; height: 20px"></div>
  293. </a>
  294.  
  295.  
  296. <table id="bb_sizes" style="display: none; clear:both;">
  297. <tr>
  298. <td>
  299. <a href="javascript: addCode('[size=4][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Foarte mic</a><br />
  300. <a href="javascript: addCode('[size=7][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Mic</a><br />
  301. <a href="javascript: addCode('[size=9][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Normal</a><br />
  302. <a href="javascript: addCode('[size=12][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Mare</a><br />
  303. <a href="javascript: addCode('[size=20][/size]');javascript:toggle_visibility('bb_sizes');">&raquo; Foarte mare</a><br />
  304. </td>
  305. </tr>
  306. </table>
  307. </div>
  308. </td></tr>
  309. <tr><td><textarea name="message" cols="80" rows="12" id="a_answer"></textarea></td></tr>
  310. <tr>
  311. <td><input type="submit" name="Submit" value="Submit"></td>
  312. </tr>
  313. </table>
  314. </form>
  315. </div>
  316. {php}
  317. if(isset($_POST[Submit])){
  318. $tbl_name="forum_answer";
  319. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  320. mysql_select_db("$db_name")or die("cannot select DB");
  321. $sql="SELECT MAX(a_id) AS Maxa_id FROM $tbl_name WHERE question_id='$vid'";
  322. $result=mysql_query($sql);
  323. $rows=mysql_fetch_array($result);
  324. if ($rows) {
  325. $Max_id = $rows['Maxa_id']+1;
  326. }
  327. else {
  328. $Max_id = 1;
  329. }
  330. $a_name=$name;
  331. $a_answer=$_POST['message'];
  332. $datetime=date("d/m/y H:i:s"); // create date and time
  333. $sql2="INSERT INTO $tbl_name(question_id, a_id, a_name, a_answer, a_datetime)VALUES('$vid', '$Max_id', '$a_name', '$a_answer', '$datetime')";
  334. $result2=mysql_query($sql2);
  335.  
  336. if($result2){
  337. $tbl_name2="forum_question";
  338. $sql3="UPDATE $tbl_name2 SET reply='$Max_id' WHERE id='$vid'";
  339. $result3=mysql_query($sql3);
  340. echo "<meta http-equiv='refresh' content='0; url=forum.php?id=".$rr[id]."&mode=view_topic&vid=".$vid."'>";
  341. }
  342. else {
  343. echo "ERROR";
  344. }
  345. }
  346. if($_GET[del]!=0){
  347. mysql_query("DELETE FROM forum_answer WHERE id=$_GET[del]");
  348. echo "<meta http-equiv='refresh' content='0; url=forum.php?id=".$rr[id]."&mode=view_topic&vid=".$vid."'>";
  349. }
  350. }
  351. {/php}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement