<?php
/*
########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Free Content / Management System #
# / #
# #
# #
# Copyright 2005-2006 by webspell.org #
# #
# visit webSPELL.org, webspell.info to get webSPELL for free #
# - Script runs under the GNU GENERAL PUBLIC LICENSE #
# - It's NOT allowed to remove this copyright-tag #
# -- http://www.fsf.org/licensing/licenses/gpl.html #
# #
# Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), #
# Far Development by Development Team - webspell.org #
# #
# visit webspell.org #
# #
########################################################################
*/
if(!$userID) echo 'Musisz być zalogowany aby przeglądać swój profil!<br><br>
• <a href="index.php?site=register">Rejestracja</a><br>
• <a href="index.php?site=login">Logowanie</a>';
else {
eval ("\$title_myprofile = \"".gettemplate("title_myprofile")."\";");
echo $title_myprofile;
if($_POST['submit']) {
$nickname = substr(trim($_POST['nickname']), 0, 30);
$mail = $_POST['mail'];
$usernamenew = substr(trim($_POST['usernamenew']), 0, 30);
$usertext = $_POST['usertext'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$b_day = $_POST['b_day'];
$b_month = $_POST['b_month'];
$b_year = $_POST['b_year'];
$sex = $_POST['sex'];
$flag = $_POST['flag'];
$town = $_POST['town'];
$icq = $_POST['icq'];
$about = $_POST['messageabout'];
$clantag = $_POST['clantag'];
$clanname = $_POST['clanname'];
$clanhp = $_POST['clanhp'];
$clanirc = $_POST['clanirc'];
$clanhistory = $_POST['clanhistory'];
$cpu = $_POST['cpu'];
$mainboard = $_POST['mainboard'];
$monitor = $_POST['monitor'];
$ram = $_POST['ram'];
$graphiccard = $_POST['graphiccard'];
$soundcard = $_POST['soundcard'];
$connection = $_POST['connection'];
$keyboard = $_POST['keyboard'];
$mouse = $_POST['mouse'];
$mousepad = $_POST['mousepad'];
$newsletter = $_POST['newsletter'];
$homepage = $_POST['homepage'];
$pm_mail = $_POST['pm_mail'];
$avatar = $_FILES['avatar'];
$userpic = $_FILES['userpic'];
$id = $userID;
if($_POST['userID'] OR $_GET['userID'] OR $userID=="") die('Nie zalogowany.');
$editname=false;
$ergebnis=safe_query("SELECT * FROM ".PREFIX."user WHERE userID='$id' ");
$ds=mysql_fetch_array($ergebnis);
if($usernamenew != $ds[username]) {
$ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE username = '".$usernamenew."' ");
$num = mysql_num_rows($ergebnis);
if($num) {
$error="Wybrana nazwa użytkownika jest w użyciu!";
die('<b>Błąd: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
}
$editname=true;
}
if($_POST['delavatar']) {
$filepath = "./images/avatars/";
if(file_exists($filepath.$id.'.jpg')) @unlink($filepath.$id.'.jpg');
if(file_exists($filepath.$id.'.gif')) @unlink($filepath.$id.'.gif');
safe_query("UPDATE ".PREFIX."user SET avatar='' WHERE userID='$id' ");
}
if($_POST['deluserpic']) {
$filepath = "./images/userpics/";
if(file_exists($filepath.$id.'.jpg')) @unlink($filepath.$id.'.jpg');
if(file_exists($filepath.$id.'.gif')) @unlink($filepath.$id.'.gif');
safe_query("UPDATE ".PREFIX."user SET userpic='' WHERE userID='$id' ");
}
//avatar
$filepath = "./images/avatars/";
if ($avatar['name'] != "" OR ($_POST['avatar_url'] != "" AND $_POST['avatar_url'] != "http://")) {
if($avatar['name'] != "") {
move_uploaded_file($avatar[tmp_name], $filepath.$avatar[name].".tmp");
} else {
$avatar[name] = strrchr($_POST['avatar_url'],"/");
if(!copy($_POST['avatar_url'],$filepath.$avatar[name].".tmp")) {
$error = "Nie można skopiować pliku z serwera";
die('Błąd: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
}
}
@chmod($filepath.$avatar[name].".tmp", 0755);
$info = getimagesize($filepath.$avatar[name].".tmp");
if($info[0] < 91 && $info[1] < 91) {
if($info[2] == 2) {
$pic=$id.'.jpg';
if(file_exists($filepath.$pic)) @unlink($filepath.$pic);
if(file_exists($filepath.$id.'.gif')) @unlink($filepath.$id.'.gif');
rename($filepath.$avatar[name].".tmp", $filepath.$pic);
safe_query("UPDATE ".PREFIX."user SET avatar='$pic' WHERE userID='$id' ");
}
elseif($info[2] == 1) {
$pic=$id.'.gif';
if(file_exists($filepath.$pic)) @unlink($filepath.$pic);
if(file_exists($filepath.$id.'.jpg')) @unlink($filepath.$id.'.jpg');
rename($filepath.$avatar[name].".tmp", $filepath.$pic);
safe_query("UPDATE ".PREFIX."user SET avatar='$pic' WHERE userID='$id' ");
}
else {
if(unlink($filepath.$avatar[name].".tmp")) {
$error = "Niedozwolony format grafiki (dozwolone: gif lub jpg)";
die('Błąd: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
} else {
$error = "Wgrywanie zakończone niepowodzeniem";
die('Błąd: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
}
}
}
else {
@unlink($filepath.$avatar[name].".tmp");
$error = "Obrazek jest większy niż dozwolone 90/90px";
die('Błąd: '.$error.'<br><br><input type="button" class="button" onClick="javascript:history.back()" value="Wróć">');
}
}