<?php
$logged = mysql_query("SELECT * from members WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[pass]'");
$user = $logged['user'];
$result = mysql_query("SELECT * FROM members WHERE user='$user'");
$row = mysql_fetch_assoc($result);
?>
<?
$result = mysql_query("SELECT * FROM members WHERE user = '$user'");
$row = mysql_fetch_assoc($result);
$sql = "SELECT * FROM members WHERE user='$user'";
$result = mysql_query($sql);
$raw = mysql_fetch_assoc($result);
if ($user) {
switch ($_GET['change']) {
default:
echo "<div class='table'><center>
<a href='edit_profile.php?change=avatar'>смяна на аватар</a> |
<a href='edit_profile.php?change=profile'>потребителски профил</a> |
<a href='edit_profile.php?change=password'>смяна на парола</a>
</center></div>";
break;
case "avatar" :
?>
<center>
<a href='edit_profile.php?change=avatar'>смяна на аватар</a> |
<a href='edit_profile.php?change=profile'>потребителски профил</a> |
<a href='edit_profile.php?change=password'>смяна на парола</a>
</center>
<form method="post" enctype='multipart/form-data'><br />
<span style="font:12px arial; text-align:right;"><b>Избери файл от компютъра ..</b></span><br />
<table><tr><td style="font-size: 11px;" width="15%">
<input type="file" name="avatar" size="50" />
<input class='button' type='submit' name='changeavatar' value='Смени аватара' /> <br/>
<?
if($_POST['changeavatar']) {
$avatar = $_FILES['avatar'];
$tmp_name = $_FILES['avatar']['tmp_name'];
$name = $_FILES['avatar']['name'];
$format = end(explode(".", $name));
if($format != "png" && $format != "gif" && $format != "jpeg" && $format != "jpg") {
echo "<br /><br />Позволени формати: <font color='red'>PNG, GIF, JPEG</font> <br />";
}
else {
$runq = mysql_query("SELECT * FROM members WHERE user='$user'");
$row = mysql_fetch_assoc($runq);
$location = "templates/avatars/$name.$format";
move_uploaded_file($tmp_name, $location);
$avatar = $location;
$run_q = mysql_query("UPDATE `members` set avatar='$avatar' WHERE user='$user'");
header("Location: edit_profile.php?change=avatar");
}
}
echo "</td><td class='table' style='width:100px; height:100px;'><img style='width:100px; height:100px;' src='$raw[avatar]'/><br />
</td></tr></table></form>";
break;
case "profile":
?>
<center>
<a href='edit_profile.php?change=avatar'>смяна на аватар</a> |
<a href='edit_profile.php?change=profile'>потребителски профил</a> |
<a href='edit_profile.php?change=password'>смяна на парола</a>
</center>
<form method='post' name='inputform'>
<table width="100%">
<tr>
<td width="30%" style="font:12px arial; text-align:right;"><b>Име</b> </td>
<td><input type='text' class='input' name='name' value='<? echo"$raw[name]"; ?>' onclick="this.value=''" size='25' /></td>
</tr>
<tr>
<td width="30%" style="font:12px arial; text-align:right;"><b>Емайл</b> </td>
<td><?
if($raw['viewmail'] != 1) {
echo "<span style='font:13px arial; text-align:right;'><b>$raw[email]</b></span>";
} elseif($raw['viewmail'] == 1) {
echo "<span style='font:13px arial; text-align:right;'><i><b>[скрито по желание]</b></i></span>";
}
?></td>
</tr>
<tr>
<td><input type='checkbox' name='viewmail' value='1' style='float:right' /></td>
<td><span style='font:13px tahoma'>Скрий моя <b>емайл</b> в профила</span></td>
</tr>
<tr>
<td width="30%" style="font:12px arial; text-align:right;"><b>Населено място</b> </td>
<td><input type='text' class='input' name='city' value='<? echo"$raw[city]"; ?>' onclick="this.value=''" size='25' /></td>
</tr>
<tr>
<td width="30%" style="font:12px arial; text-align:right;"><b>Скайп</b> </td>
<td><input type='text' class='input' name='skype' value='<? echo"$raw[skype]"; ?>' onclick="this.value=''" size='25' /></td>
</tr>
<tr>
<td width="30%" style="font:12px arial; text-align:right;"><b>Пол;</b> </td>
<td><select name='gender'><option value='1'>Момче</option><option value='2'>Момиче</option></select></td>
</tr>
<tr>
<td colspan="2">
<input type='image' src='emoticons/emote.png' class='bbcodes' onclick="return overlay(this, 'bbcode_smileys_list_message', 'bottomleft');" title='Smileys' />
<img src='emoticons/smile.gif' onclick="insertText('message', ':)', 'inputform');" />
<img src='emoticons/tong.gif' onclick="insertText('message', ':P', 'inputform');" />
<img src='emoticons/bigsmile.gif' onclick="insertText('message', ':D', 'inputform');" />
<img src='emoticons/kiss.gif' onclick="insertText('message', ':*', 'inputform');" />
<img src='emoticons/crying.gif' onclick="insertText('message', ';(', 'inputform');" />
<img src='emoticons/wink.gif' onclick="insertText('message', ';)', 'inputform');" />
<img src='emoticons/hi.gif' onclick="insertText('message', '(wave)', 'inputform');" />
<img src='emoticons/nod.gif' onclick="insertText('message', '(nod)', 'inputform');" />
<img src='emoticons/finger.gif' onclick="insertText('message', '(finger)', 'inputform');" />
<img src='emoticons/mooning.gif' onclick="insertText('message', '(mooning)', 'inputform');" />
<img src='emoticons/wondering.gif' onclick="insertText('message', '(wondering)', 'inputform');" />
<img src='emoticons/yes.gif' onclick="insertText('message', '(yes)', 'inputform');" />
<img src='emoticons/no.gif' onclick="insertText('message', '(no)', 'inputform');" />
<img src='emoticons/party.gif' onclick="insertText('message', '(party)', 'inputform');" />
<input type='image' src='templates/img/bbimg/b.png' class='bbcodes' onclick="addText('message','[b]','[/b]','inputform');return false;" title='Удебелява избрания текст' />
<input type='image' src='templates/img/bbimg/i.png' class='bbcodes' onclick="addText('message','[i]','[/i]','inputform');return false;" title='Прави текста наклонен' />
<input type='image' src='templates/img/bbimg/u.png' class='bbcodes' onclick="addText('message','[u]','[/u]','inputform');return false;" title='Прави избрания текст подчертан' />
<input type='image' src='templates/img/bbimg/url.png' class='bbcodes' onclick="addText('message','[url]','[/url]','inputform');return false;" title='Прави URL кликване' />
<input type='image' src='templates/img/bbimg/img.png' class='bbcodes' onclick="addText('message','[img]','[/img]','inputform');return false;" title='Показва изображение от определена страница' />
<input type='image' src='templates/img/bbimg/code.png' class='bbcodes' onclick="addText('message','[code]','[/code]','inputform');return false;" title='Показва текста като код' />
<input type='image' src='templates/img/bbimg/quote.png' class='bbcodes' onclick="addText('message','[quote]','[/quote]','inputform');return false;" title='Цитат' />
<a onclick="document.getElementById('chat').value=entobg(document.getElementById('chat').value);">
<img style="float: right; margin-top: 7px;" src="templates/img/icons/bg.png" title="Смени езика на БГ" /></a>
<hr style="border: 1px solid #d7d7d7;" /><br/>
<textarea style="width: 100%; height: 150px; margin-top: -15px; border: none;" id="chat" name="message"></textarea>
</td>
</tr>
<tr><td colspan="2"><input type='submit' name='submit' class='button' value='Запази промените' /></td>
</tr>
</table>
<?
if ($_POST['submit']) {
$user = htmlspecialchars($_POST['user']);
$skype = htmlspecialchars($_POST['skype']);
$mail = $_POST['mail'];
$zaqvka = "UPDATE members SET skype='$skype', mail='$mail' WHERE user='$user'";
$sql = mysql_query($zaqvka);
echo "<br/>Успешно променихте профила си.";
@header("Location: ".$_SERVER['HTTP_REFERER']."");
}
echo "</form>";
break;
case "pass":
?>
<center>
<a href='settings.php?change=avatar'>смяна на аватар</a> |
<a href='settings.php?change=profile'>потребителски профил</a> |
<a href='settings.php?change=password'>смяна на парола</a>
</center>
<form method='post' action=''>
<table width="100%">
<tr>
<td width="30%" style="font:12px arial; text-align:right;"><b>Нова парола</b> </td>
<td><input type='pass' class='input' name='pass' size='25' /></td></tr>
<tr><td width="30%" style="font:12px arial; text-align:right;"><b>Повтори нова парола</b> </td>
<td><input type='pass' class='input' name='pass2' size='25' /></td>
</tr>
<tr><td colspan="2"><input type='submit' name='changepassword' class='button' value='Смени паролата' /></td>
</tr>
</table>
<?
$pass = htmlspecialchars($_POST['pass']);
$pass2 = htmlspecialchars($_POST['pass2']);
if($_POST['changepassword']) {
if ($pass != $pass2) {
echo "<div style='color:red'>Паролите не съвпадат</div>";
}
elseif($pass == NULL || $pass2 == NULL) {
echo '<span style="color:red"> Попълни празните полето</span>';
}
else {
$sql = "UPDATE `members` set pass='".md5($pass)."' WHERE user='$user'";
$result = mysql_query($sql);
echo "<br/>Успешно сменихте вашата парола";
header("Location: ".$_SERVER['HTTP_REFERER']."");
}
}
echo "</form>";
break;
}
}
else {
@header("Location: index.php");
}
?>