Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {php}
- $name=$this->_tpl_vars['user']['username'];
- $ally=$this->_tpl_vars['user']['ally'];
- $id=$_GET[id];
- $mode=$_GET['modf'];
- if($mode==""){$mode="none";}
- include('../include/config.php');
- $host=$config['db_host'];
- $username=$config['db_user'];
- $password=$config['db_pw'];
- $db_name="lan"; // Database name
- $tbl_name="forum_question"; // Table name
- // Connect to server and select databse.
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $sql="SELECT * FROM $tbl_name WHERE forumid=$id AND allyid=$ally ORDER BY id DESC";
- // OREDER BY id DESC is order result by descending
- $result=mysql_query($sql);
- $sqlt="SELECT * FROM `forums` WHERE `allyid`='$ally'";
- $sqls="SELECT * FROM `forums` WHERE `allyid`='$ally' AND `id`='$id'";
- $r=mysql_query($sqls);$rt=mysql_query($sqlt);
- $rr=mysql_fetch_array($r);
- {/php}
- {literal}
- <script type="text/javascript">
- <!--
- function toggle_visibility(id) {
- var e = document.getElementById(id);
- if(e.style.display == 'block')
- e.style.display = 'none';
- else
- e.style.display = 'block';
- }
- //-->
- </script>
- {/literal}
- <head>
- {literal}
- <script src="script.js" type="text/javascript"></script>
- <script src="mootools.js" type="text/javascript"></script>
- <script>
- function addCode(emoticon)
- {
- document.new_thread.message.value=document.new_thread.message.value+emoticon;
- document.new_thread.message.focus();
- return;
- }
- </script>
- {/literal}
- </head>
- <link rel="stylesheet" type="text/css" href="stamm.css" />
- <table class="vis" width="800">
- <tr><th colspan="3">Forumul Tribului</th></tr>
- <tr><td>
- <table align=left>
- <tr>
- {php}
- while ($rrt=mysql_fetch_array($rt)){
- {/php}
- <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>
- <td height=25 wight=10></td>
- {php}
- }
- {/php}
- </tr></table>
- </td></tr>
- {php} if($mode=='none'){
- {/php}
- <tr><td>
- <h2>{php} echo $rr[titlu];{/php}</h2>
- <br />
- <a href="forum.php?id={php} echo $rr[id]{/php}&mode=newt"><img style="border:1px;" src="graphic/forum_new.png" /></a>
- <table class="vis" width="800">
- <tr>
- <th>Subiecte</th>
- <th>Autor</th>
- <th>Răspunsuri</th>
- </tr>
- {php}
- while($rows=mysql_fetch_array($result)){
- {/php}
- <tr>
- <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>
- <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>
- <td width=150 align=center>{php} echo $rows['reply']; {/php}</td>
- </tr>
- {php}
- }
- mysql_close();
- {/php}
- <div align=center><a href="forum.php?id={php} echo $rr['id']; {/php}&mode=admin">Administrează forumul</a></div>
- <tr>
- <th colspan=4>
- </th>
- </tr>
- {php}
- } elseif($mode=='newt') {
- {/php}
- <table class="vis" width="800">
- <tr><td colspan="2"><h2>Deschiderea unei teme noi</h2></td></tr>
- <form action="forum.php?id={php} echo $rr[id];{/php}&mode=newt" method="post" name="new_thread">
- <tr>
- <td>Titlu:</td>
- <td><input name="subject" type="text" size="64" value="" tabindex="1" /></td>
- </tr>
- <td>Text:</td>
- <td>
- <div style="position: relative">
- <a title="Îngroşat" href="javascript: addCode('[b][/b]')">
- <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>
- </a>
- <a title="Cursiv" href="javascript: addCode('[i][/i]')">
- <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>
- </a>
- <a title="Subliniat" href="javascript: addCode('[u][/u]')">
- <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>
- </a>
- <a title="Tăiat" href="javascript: addCode('[s][/s]')" onclick="insertBBcode('message', '[s]', '[/s]');">
- <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>
- </a>
- <a title="Citat" href="javascript: addCode('[quote=Autor][/quote]')" onclick="insertBBcode('message', '[quote=Autor]', '[/quote]');">
- <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>
- </a>
- <a title="Adresă" href="javascript: addCode('[url][/url]')" onclick="insertBBcode('message', '[url]', '[/url]');">
- <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>
- </a>
- <a title="Spoiler" href="javascript: addCode('[spoiler][/spoiler]')" onclick="insertBBcode('message', '[spoiler]', '[/spoiler]');">
- <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>
- </a>
- <a title="Jucător" href="javascript: addCode('[player][/player]')" onclick="insertBBcode('message', '[player]', '[/player]');">
- <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>
- </a>
- <a title="Trib" href="javascript: addCode('[ally][/ally]')" onclick="insertBBcode('message', '[ally]', '[/ally]');">
- <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>
- </a>
- <a title="Coordonate" href="javascript: addCode('[village][/village]')" onclick="insertBBcode('message', '[village]', '[/village]');">
- <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>
- </a>
- <a title="Mărimea textului" href="javascript:nothing()" onclick="javascript:toggle_visibility('bb_sizes');">
- <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>
- </a>
- <a title="Imagine" href="javascript: addCode('[img][/img]')" onclick="insertBBcode('message', '[img]', '[/img]');">
- <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>
- </a>
- <table id="bb_sizes" style="display: none; clear:both;">
- <tr>
- <td>
- <a href="javascript: addCode('[size=4][/size]');javascript:toggle_visibility('bb_sizes');">» Foarte mic</a><br />
- <a href="javascript: addCode('[size=7][/size]');javascript:toggle_visibility('bb_sizes');">» Mic</a><br />
- <a href="javascript: addCode('[size=9][/size]');javascript:toggle_visibility('bb_sizes');">» Normal</a><br />
- <a href="javascript: addCode('[size=12][/size]');javascript:toggle_visibility('bb_sizes');">» Mare</a><br />
- <a href="javascript: addCode('[size=20][/size]');javascript:toggle_visibility('bb_sizes');">» Foarte mare</a><br />
- </td>
- </tr>
- </table>
- </div>
- <textarea name="message" id="message" cols="80" rows="12" tabindex="2"></textarea></td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" value="Expediere" name="send"></td>
- </tr>
- </form>
- </table>
- {php}
- if (isset($_POST[send])){
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $topic=$_POST['subject'];
- $detail=$_POST['message'];
- $datetime=date("d/m/y h:i:s");
- $tbl_name="forum_question";
- $sql="INSERT INTO $tbl_name(topic, detail, name, datetime, forumid, allyid)VALUES('$topic', '$detail', '$name', '$datetime', '$rr[id]', '$ally')";
- $result=mysql_query($sql);
- if($result){
- echo "<meta http-equiv='refresh' content='0; url=forum.php?id=".$rr[id]."'>";
- }
- else {
- echo "ERROR";
- }
- mysql_close();
- }
- }elseif($mode=='view_topic'){
- {/php}
- {php}
- $vid=$_GET[vid];
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $sql="SELECT * FROM $tbl_name WHERE id='$vid'";
- $result=mysql_query($sql);
- $rows=mysql_fetch_array($result);
- {/php}
- <tr><td><h2>{php} echo $rows[topic];{/php}</h2></td></tr>
- <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>
- <tr><td>{php} echo $rows['detail']; {/php}</td></tr>
- {php}
- $tbl_name2="forum_answer"; // Switch to table "forum_answer"
- $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$vid'";
- $result2=mysql_query($sql2);
- while($rows=mysql_fetch_array($result2)){
- {/php}
- <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>
- <tr><td>{php} echo $rows['a_answer']; {/php}</td></tr>
- {php}
- }
- {/php}
- <table width="100%"><tr>
- <td style="min-width: 150px">
- <a href="#" onclick="toggle_visibility('foo');" class="thread_button">
- <span class="thread_answer_open"></span>
- <span class="thread_answer">Raspunde</span>
- <span class="thread_answer_close"></span>
- </a> </td></tr>
- </table>
- {php}
- $tbl_name2="forum_answer"; // Switch to table "forum_answer"
- $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$vid'";
- $result2=mysql_query($sql2);
- while($rows=mysql_fetch_array($result2)){
- {/php}
- {php}
- }
- $sql3="SELECT view FROM $tbl_name WHERE id='$vid'";
- $result3=mysql_query($sql3);
- $rows=mysql_fetch_array($result3);
- $view=$rows['view'];
- // if have no counter value set counter = 1
- if(empty($view)){
- $view=1;
- $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$vid'";
- $result4=mysql_query($sql4);
- }
- // count more value
- $addview=$view+1;
- $sql5="update $tbl_name set view='$addview' WHERE id='$vid'";
- $result5=mysql_query($sql5);
- {/php}
- <div id="foo">
- <form name="new_thread" method="post" action="forum.php?id={php} echo $rr['id']; {/php}&mode=view_topic&vid={php} echo $vid; {/php}">
- <table class="vis">
- <tr><td>
- <div style="position: relative">
- <a title="Îngroşat" href="javascript: addCode('[b][/b]')">
- <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>
- </a>
- <a title="Cursiv" href="javascript: addCode('[i][/i]')">
- <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>
- </a>
- <a title="Subliniat" href="javascript: addCode('[u][/u]')">
- <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>
- </a>
- <a title="Tăiat" href="javascript: addCode('[s][/s]')" onclick="insertBBcode('message', '[s]', '[/s]');">
- <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>
- </a>
- <a title="Citat" href="javascript: addCode('[quote=Autor][/quote]')" onclick="insertBBcode('message', '[quote=Autor]', '[/quote]');">
- <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>
- </a>
- <a title="Adresă" href="javascript: addCode('[url][/url]')" onclick="insertBBcode('message', '[url]', '[/url]');">
- <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>
- </a>
- <a title="Spoiler" href="javascript: addCode('[spoiler][/spoiler]')" onclick="insertBBcode('message', '[spoiler]', '[/spoiler]');">
- <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>
- </a>
- <a title="Jucător" href="javascript: addCode('[player][/player]')" onclick="insertBBcode('message', '[player]', '[/player]');">
- <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>
- </a>
- <a title="Trib" href="javascript: addCode('[ally][/ally]')" onclick="insertBBcode('message', '[ally]', '[/ally]');">
- <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>
- </a>
- <a title="Coordonate" href="javascript: addCode('[village][/village]')" onclick="insertBBcode('message', '[village]', '[/village]');">
- <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>
- </a>
- <a title="Mărimea textului" href="javascript:nothing()" onclick="javascript:toggle_visibility('bb_sizes');">
- <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>
- </a>
- <a title="Imagine" href="javascript: addCode('[img][/img]')" onclick="insertBBcode('message', '[img]', '[/img]');">
- <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>
- </a>
- <table id="bb_sizes" style="display: none; clear:both;">
- <tr>
- <td>
- <a href="javascript: addCode('[size=4][/size]');javascript:toggle_visibility('bb_sizes');">» Foarte mic</a><br />
- <a href="javascript: addCode('[size=7][/size]');javascript:toggle_visibility('bb_sizes');">» Mic</a><br />
- <a href="javascript: addCode('[size=9][/size]');javascript:toggle_visibility('bb_sizes');">» Normal</a><br />
- <a href="javascript: addCode('[size=12][/size]');javascript:toggle_visibility('bb_sizes');">» Mare</a><br />
- <a href="javascript: addCode('[size=20][/size]');javascript:toggle_visibility('bb_sizes');">» Foarte mare</a><br />
- </td>
- </tr>
- </table>
- </div>
- </td></tr>
- <tr><td><textarea name="message" cols="80" rows="12" id="a_answer"></textarea></td></tr>
- <tr>
- <td><input type="submit" name="Submit" value="Submit"></td>
- </tr>
- </table>
- </form>
- </div>
- {php}
- if(isset($_POST[Submit])){
- $tbl_name="forum_answer";
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $sql="SELECT MAX(a_id) AS Maxa_id FROM $tbl_name WHERE question_id='$vid'";
- $result=mysql_query($sql);
- $rows=mysql_fetch_array($result);
- if ($rows) {
- $Max_id = $rows['Maxa_id']+1;
- }
- else {
- $Max_id = 1;
- }
- $a_name=$name;
- $a_answer=$_POST['message'];
- $datetime=date("d/m/y H:i:s"); // create date and time
- $sql2="INSERT INTO $tbl_name(question_id, a_id, a_name, a_answer, a_datetime)VALUES('$vid', '$Max_id', '$a_name', '$a_answer', '$datetime')";
- $result2=mysql_query($sql2);
- if($result2){
- $tbl_name2="forum_question";
- $sql3="UPDATE $tbl_name2 SET reply='$Max_id' WHERE id='$vid'";
- $result3=mysql_query($sql3);
- echo "<meta http-equiv='refresh' content='0; url=forum.php?id=".$rr[id]."&mode=view_topic&vid=".$vid."'>";
- }
- else {
- echo "ERROR";
- }
- }
- if($_GET[del]!=0){
- mysql_query("DELETE FROM forum_answer WHERE id=$_GET[del]");
- echo "<meta http-equiv='refresh' content='0; url=forum.php?id=".$rr[id]."&mode=view_topic&vid=".$vid."'>";
- }
- }
- {/php}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement