Здравейте,
Ето това ми е кода за чата
И реших да добавя function и стана така
Изникна проблем показва, че не съм логнат,а всъщност съм.
Използвам този логин : http://web-tourist.net/login/login/view.php?st=802
Ето това ми е кода за чата
PHP:
<script type="text/javascript">
</script>
<?
if ($logged[username]) {
echo "
<div align='center'>
<form action='' method='post'>
<br /><br />
<textarea name='fuckerbot2' id='styled' onkeydown='textCounter(this.form.styled, this.form.remLen,250);' onkeyup='textCounter(this.form.styled, this.form.remLen,250);' style='height:100px; max-height:100px; width:170px; max-width:170px' placeholder=\"Писането на кирилица е задължително\"></textarea><br />
<div style='padding-top:3px;'><span style='padding-top:3px'>Анти-бот:
<a href='#' onclick=\"document.getElementById('captcha').src = './data/img.php?' + Math.random(); return false\" style='vertical-align: top'><img id='captcha' src='./data/img.php' alt='captcha' /></a></span>
<input type='text' style='width: 45px' name='kod' /></div><br />
<input type='submit' name='submit45' class='button' value='Добави' /> <input class='button' type='button' onclick='toggle_visibility(\"bah\");' value='Емоции' />
</form>
<div style='display: none' id='bah'>
<a href=\"javascript:emoticon('(smile)')\"><img style='border: 0;' src='images/emoticons/smile.png' alt='усмивка' /></a>
<a href=\"javascript:emoticon('(angry)')\"><img style='border: 0;' src='images/emoticons/angry.png' alt='нервен' /></a>
<a href=\"javascript:emoticon('(grin)')\"><img style='border: 0;' src='images/emoticons/grin.png' alt='смях' /></a>
<a href=\"javascript:emoticon('(h)')\"><img style='border: 0;' src='images/emoticons/heart.png' alt='сърце' /></a>
<a href=\"javascript:emoticon('(sad)')\"><img style='border: 0;' src='images/emoticons/sad.png' alt='тъжен' /></a>
<a href=\"javascript:emoticon('(nocomment)')\"><img style='border: 0;' src='images/emoticons/nocom.png' alt='без коментар' /></a>
<a href=\"javascript:emoticon('(tongue)')\"><img style='border: 0;' src='images/emoticons/tongue.png' alt='плезене' /></a>
<a href=\"javascript:emoticon('(wink)')\"><img style='border: 0;' src='images/emoticons/wink.png' alt='намигване' /></a>
<a href=\"javascript:emoticon('(hi)')\"><img style='border: 0;' src='images/emoticons/hi.png' alt='здравейте' /></a>
<a href=\"javascript:emoticon('(bye)')\"><img style='border: 0;' src='images/emoticons/bye.png' alt='чао' /></a>
<a href=\"javascript:emoticon('(cry)')\"><img style='border: 0;' src='images/emoticons/crying2.png' alt='реве' /></a>
<a href=\"javascript:emoticon('(devil)')\"><img style='border: 0;' src='images/emoticons/devil.png' alt='дявол' /></a>
<a href=\"javascript:emoticon('(elated)')\"><img style='border: 0;' src='images/emoticons/elated.png' alt='удивен' /></a>
<a href=\"javascript:emoticon('(innocent)')\"><img style='border: 0;' src='images/emoticons/innocent.png' alt='ангелче' /></a>
<a href=\"javascript:emoticon('(worry)')\"><img style='border: 0;' src='images/emoticons/worried.png' alt='притеснен' /></a>
<a href=\"javascript:emoticon('(listen)')\"><img style='border: 0;' src='images/emoticons/listen.png' alt='слушам музика' /></a>
<a href=\"javascript:emoticon('(beer)')\"><img style='border: 0;' src='images/emoticons/beer.png' alt='биричка' /></a>
</div>
</div>
<br />";
}
else{
echo "<br />За да пишите тук трябва да имате влезнали<br /><br />";
} ?>
<?php
if (isset($_POST["submit45"])) {
if(!$logged[username]) {
header("Location:../index.php");
exit;
}
$date = date("Y-m-d");
if (!empty($_POST["fuckerbot2"])) $fuckerbot2 = mysql_real_escape_string($_POST["fuckerbot2"]);
else $errMsg = "<div class='msg_error'>Моля въведете съобщение!</div><br />";
$fuckerbot2 = str_replace("(smile)", "<img src=\"/images/emoticons/smile.png\" title=\"smile\" alt=\"smile emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(wink)", "<img src=\"/images/emoticons/wink.png\" title=\"wink\" alt=\"wink emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(sad)", "<img src=\"/images/emoticons/sad.png\" title=\"sad\" alt=\"sad emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(tongue)", "<img src=\"/images/emoticons/tongue.png\" title=\"tongue\" alt=\"tongue emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(grin)", "<img src=\"/images/emoticons/grin.png\" title=\"grin\" alt=\"grin emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(angry)", "<img src=\"/images/emoticons/angry.png\" title=\"angry\" alt=\"angry emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(h)", "<img src=\"/images/emoticons/heart.png\" title=\"heart\" alt=\"heart emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(nocomment)", "<img src=\"/images/emoticons/nocom.png\" title=\"no comment\" alt=\"no comment emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(hi)", "<img src=\"/images/emoticons/bye.png\" title=\"hi\" alt=\"hi emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(bye)", "<img src=\"/images/emoticons/hi.png\" title=\"bye\" alt=\"bye emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(cry)", "<img src=\"/images/emoticons/crying2.png\" title=\"cry\" alt=\"crying emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(devil)", "<img src=\"/images/emoticons/devil.png\" title=\"devil\" alt=\"devil emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(elated)", "<img src=\"/images/emoticons/elated.png\" title=\"elated\" alt=\"elated emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(innocent)", "<img src=\"/images/emoticons/innocent.png\" title=\"innocent\" alt=\"innocent emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(worry)", "<img src=\"/images/emoticons/worried.png\" title=\"worry\" alt=\"worried emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(listen)", "<img src=\"/images/emoticons/listen.png\" title=\"listen\" alt=\"listen emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(beer)", "<img src=\"/images/emoticons/beer.png\" title=\"beer\" alt=\"beer emoticon\" />", $fuckerbot2);
$fuckerbot2 = preg_replace('~((http://)[^ ]+)~', '<a href="$1" title="препратка">линк</a>', $fuckerbot2);
$kod = htmlspecialchars($_POST[kod]);
if($kod!=$_COOKIE[imgcodepage])
$errMsg = "<div class='msg_error'>Не сте въвели правилно кода!</div><br />";
if (empty($errMsg))
{
$insert = mysql_query("INSERT INTO chatbox(nick, message, date) VALUES('$logged[username]', '$fuckerbot2', '$date')")or die(mysql_error());
echo '<div class=\'msg_suc\'> Съобщението е добавено!</div><br>';
} else echo $errMsg;
}
?>
<?
$query="SELECT id,nick,message,date FROM chatbox ORDER BY id DESC limit 10";
$result=mysql_query($query);
while ($row=@mysql_fetch_row($result)) {
$profile1 = mysql_query("SELECT * from users where username = '$row[1]'");
$profile1 = mysql_fetch_array($profile1);
echo"<div class='chatbox' style=' text-shadow: 1px 0px #fff; font: 11px verdana; color: #333;><a href='user.php?id=$profile1[id]'>";
if($profile1['level'] == 1)
{
echo "<img src='./images/user_icon.png'";
}
elseif($profile1['level'] == 2)
{
echo "<img src='./images/admin_icon.png'";
}
echo "border='0' title='' align='top' width='13px' height='13px'/></a> <a href='user.php?id=$profile1[id]' class='profile_link' style='font-size: 12px; font-family: verdana;color: #555;' title=''>$row[1]</a><br />
<span style='color: gray; font: 10px verdana;'>$row[3]</span>
<br />$row[2]</div>";
}
?>
И реших да добавя function и стана така
PHP:
<script type="text/javascript">
</script>
<?
function chatbox() {
if ($logged[username]) {
echo "
<div align='center'>
<form action='' method='post'>
<br /><br />
<textarea name='fuckerbot2' id='styled' onkeydown='textCounter(this.form.styled, this.form.remLen,250);' onkeyup='textCounter(this.form.styled, this.form.remLen,250);' style='height:100px; max-height:100px; width:170px; max-width:170px' placeholder=\"Писането на кирилица е задължително\"></textarea><br />
<div style='padding-top:3px;'><span style='padding-top:3px'>Анти-бот:
<a href='#' onclick=\"document.getElementById('captcha').src = './data/img.php?' + Math.random(); return false\" style='vertical-align: top'><img id='captcha' src='./data/img.php' alt='captcha' /></a></span>
<input type='text' style='width: 45px' name='kod' /></div><br />
<input type='submit' name='submit45' class='button' value='Добави' /> <input class='button' type='button' onclick='toggle_visibility(\"bah\");' value='Емоции' />
</form>
<div style='display: none' id='bah'>
<a href=\"javascript:emoticon('(smile)')\"><img style='border: 0;' src='images/emoticons/smile.png' alt='усмивка' /></a>
<a href=\"javascript:emoticon('(angry)')\"><img style='border: 0;' src='images/emoticons/angry.png' alt='нервен' /></a>
<a href=\"javascript:emoticon('(grin)')\"><img style='border: 0;' src='images/emoticons/grin.png' alt='смях' /></a>
<a href=\"javascript:emoticon('(h)')\"><img style='border: 0;' src='images/emoticons/heart.png' alt='сърце' /></a>
<a href=\"javascript:emoticon('(sad)')\"><img style='border: 0;' src='images/emoticons/sad.png' alt='тъжен' /></a>
<a href=\"javascript:emoticon('(nocomment)')\"><img style='border: 0;' src='images/emoticons/nocom.png' alt='без коментар' /></a>
<a href=\"javascript:emoticon('(tongue)')\"><img style='border: 0;' src='images/emoticons/tongue.png' alt='плезене' /></a>
<a href=\"javascript:emoticon('(wink)')\"><img style='border: 0;' src='images/emoticons/wink.png' alt='намигване' /></a>
<a href=\"javascript:emoticon('(hi)')\"><img style='border: 0;' src='images/emoticons/hi.png' alt='здравейте' /></a>
<a href=\"javascript:emoticon('(bye)')\"><img style='border: 0;' src='images/emoticons/bye.png' alt='чао' /></a>
<a href=\"javascript:emoticon('(cry)')\"><img style='border: 0;' src='images/emoticons/crying2.png' alt='реве' /></a>
<a href=\"javascript:emoticon('(devil)')\"><img style='border: 0;' src='images/emoticons/devil.png' alt='дявол' /></a>
<a href=\"javascript:emoticon('(elated)')\"><img style='border: 0;' src='images/emoticons/elated.png' alt='удивен' /></a>
<a href=\"javascript:emoticon('(innocent)')\"><img style='border: 0;' src='images/emoticons/innocent.png' alt='ангелче' /></a>
<a href=\"javascript:emoticon('(worry)')\"><img style='border: 0;' src='images/emoticons/worried.png' alt='притеснен' /></a>
<a href=\"javascript:emoticon('(listen)')\"><img style='border: 0;' src='images/emoticons/listen.png' alt='слушам музика' /></a>
<a href=\"javascript:emoticon('(beer)')\"><img style='border: 0;' src='images/emoticons/beer.png' alt='биричка' /></a>
</div>
</div>
<br />";
}
else{
echo "<br />За да пишите тук трябва да имате влезнали<br /><br />";
} ?>
<?php
if (isset($_POST["submit45"])) {
if(!$logged[username]) {
header("Location:../index.php");
exit;
}
$date = date("Y-m-d");
if (!empty($_POST["fuckerbot2"])) $fuckerbot2 = mysql_real_escape_string($_POST["fuckerbot2"]);
else $errMsg = "<div class='msg_error'>Моля въведете съобщение!</div><br />";
$fuckerbot2 = str_replace("(smile)", "<img src=\"/images/emoticons/smile.png\" title=\"smile\" alt=\"smile emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(wink)", "<img src=\"/images/emoticons/wink.png\" title=\"wink\" alt=\"wink emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(sad)", "<img src=\"/images/emoticons/sad.png\" title=\"sad\" alt=\"sad emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(tongue)", "<img src=\"/images/emoticons/tongue.png\" title=\"tongue\" alt=\"tongue emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(grin)", "<img src=\"/images/emoticons/grin.png\" title=\"grin\" alt=\"grin emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(angry)", "<img src=\"/images/emoticons/angry.png\" title=\"angry\" alt=\"angry emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(h)", "<img src=\"/images/emoticons/heart.png\" title=\"heart\" alt=\"heart emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(nocomment)", "<img src=\"/images/emoticons/nocom.png\" title=\"no comment\" alt=\"no comment emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(hi)", "<img src=\"/images/emoticons/bye.png\" title=\"hi\" alt=\"hi emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(bye)", "<img src=\"/images/emoticons/hi.png\" title=\"bye\" alt=\"bye emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(cry)", "<img src=\"/images/emoticons/crying2.png\" title=\"cry\" alt=\"crying emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(devil)", "<img src=\"/images/emoticons/devil.png\" title=\"devil\" alt=\"devil emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(elated)", "<img src=\"/images/emoticons/elated.png\" title=\"elated\" alt=\"elated emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(innocent)", "<img src=\"/images/emoticons/innocent.png\" title=\"innocent\" alt=\"innocent emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(worry)", "<img src=\"/images/emoticons/worried.png\" title=\"worry\" alt=\"worried emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(listen)", "<img src=\"/images/emoticons/listen.png\" title=\"listen\" alt=\"listen emoticon\" />", $fuckerbot2);
$fuckerbot2 = str_replace("(beer)", "<img src=\"/images/emoticons/beer.png\" title=\"beer\" alt=\"beer emoticon\" />", $fuckerbot2);
$fuckerbot2 = preg_replace('~((http://)[^ ]+)~', '<a href="$1" title="препратка">линк</a>', $fuckerbot2);
$kod = htmlspecialchars($_POST[kod]);
if($kod!=$_COOKIE[imgcodepage])
$errMsg = "<div class='msg_error'>Не сте въвели правилно кода!</div><br />";
if (empty($errMsg))
{
$insert = mysql_query("INSERT INTO chatbox(nick, message, date) VALUES('$logged[username]', '$fuckerbot2', '$date')")or die(mysql_error());
echo '<div class=\'msg_suc\'> Съобщението е добавено!</div><br>';
} else echo $errMsg;
}
?>
<?
$query="SELECT id,nick,message,date FROM chatbox ORDER BY id DESC limit 10";
$result=mysql_query($query);
while ($row=@mysql_fetch_row($result)) {
$profile1 = mysql_query("SELECT * from users where username = '$row[1]'");
$profile1 = mysql_fetch_array($profile1);
echo"<div class='chatbox' style=' text-shadow: 1px 0px #fff; font: 11px verdana; color: #333;><a href='user.php?id=$profile1[id]'>";
if($profile1['level'] == 1)
{
echo "<img src='./images/user_icon.png'";
}
elseif($profile1['level'] == 2)
{
echo "<img src='./images/admin_icon.png'";
}
echo "border='0' title='' align='top' width='13px' height='13px'/></a> <a href='user.php?id=$profile1[id]' class='profile_link' style='font-size: 12px; font-family: verdana;color: #555;' title=''>$row[1]</a><br />
<span style='color: gray; font: 10px verdana;'>$row[3]</span>
<br />$row[2]</div>";
}
}
?>
Изникна проблем показва, че не съм логнат,а всъщност съм.
Използвам този логин : http://web-tourist.net/login/login/view.php?st=802