= 7) {
// jika permintaan ke nick, kita mendapatkan datanya.
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$user = mysql_fetch_assoc($req);
if ($user['rights'] > $datauser['rights']) {
// jika anda tidak mempunyai cukup hak, kita mendapatkan kesalahan
echo display_error('Anda tidak dapat mengedit profil ini');
require_once ('../incfiles/end.php');
exit;
}
}
else {
echo display_error('Profil dengan nick ini tidak ada !');
require_once ('../incfiles/end.php');
exit;
}
}
else {
$id = false;
$user = $datauser;
}
if ($id && $rights >= 7 && $act == 'reset') {
// Reset
mysql_query("UPDATE `users` SET `set_user` = '', `set_forum` = '', `set_chat` = '' WHERE `id` = '" . $user['id'] . "'");
echo '';
require_once ('../incfiles/end.php');
exit;
}
echo '';
if (isset($_GET['delavatar'])) {
// Hapus avatar
@unlink('../files/avatar/' . $user['id'] . '.png');
echo '';
} elseif (isset($_GET['delphoto'])) {
// Hapus avatar
@unlink('../files/photo/' . $user['id'] . '.jpg');
@unlink('../files/photo/' . $user['id'] . '_small.jpg');
echo '';
} elseif (isset($_POST['submit'])) {
$error = array();
// Data nick
$user['imname'] = isset($_POST['imname']) ? check(mb_substr($_POST['imname'], 0, 25)) : '';
$user['live'] = isset($_POST['live']) ? check(mb_substr($_POST['live'], 0, 50)) : '';
$user['dayb'] = isset($_POST['dayb']) ? intval($_POST['dayb']) : 0;
$user['monthb'] = isset($_POST['monthb']) ? intval($_POST['monthb']) : 0;
$user['yearofbirth'] = isset($_POST['yearofbirth']) ? intval($_POST['yearofbirth']) : 0;
$user['about'] = isset($_POST['about']) ? check(mb_substr($_POST['about'], 0, 500)) : '';
$user['mibile'] = isset($_POST['mibile']) ? check(mb_substr($_POST['mibile'], 0, 40)) : '';
$user['mail'] = isset($_POST['mail']) ? check(mb_substr($_POST['mail'], 0, 40)) : '';
$user['mailvis'] = isset($_POST['mailvis']) ? 1 : 0;
$user['icq'] = isset($_POST['icq']) ? intval($_POST['icq']) : 0;
$user['skype'] = isset($_POST['skype']) ? check(mb_substr($_POST['skype'], 0, 40)) : '';
$user['jabber'] = isset($_POST['jabber']) ? check(mb_substr($_POST['jabber'], 0, 40)) : '';
$user['www'] = isset($_POST['www']) ? check(mb_substr($_POST['www'], 0, 40)) : '';
// Data nick (untuk administrator)
$user['name'] = isset($_POST['name']) ? check(mb_substr($_POST['name'], 0, 20)) : $user['name'];
$user['status'] = isset($_POST['status']) ? check(mb_substr($_POST['status'], 0, 50)) : '';
$user['immunity'] = isset($_POST['immunity']) ? 1 : 0;
$user['karma_off'] = isset($_POST['karma_off']) ? 1 : 0;
$user['sex'] = isset($_POST['sex']) && $_POST['sex'] == 'm' ? 'm' : 'zh';
$user['rights'] = isset($_POST['rights']) ? abs(intval($_POST['rights'])) : 0;
// Cek Buat yang diperlukan
if ($user['id'] == $user_id)
$user['rights'] = $datauser['rights'];
if ($rights >= 7) {
if (mb_strlen($user['name']) < 2)
$error[] = 'Panjang minimal nick - 2 karakter';
$lat_nick = rus_lat(mb_strtolower($user['name']));
if (preg_match("/[^1-9a-z\-\@\*\(\)\?\!\~\_\=\[\]]+/", $lat_nick))
$error[] = 'Nick menganduk karakter yang tidak valid !! ';
}
if ($user['dayb'] || $user['monthb'] || $user['yearofbirth']) {
if ($user['dayb'] < 1 || $user['dayb'] > 31 || $user['monthb'] < 1 || $user['monthb'] > 12)
$error[] = 'Format Tanggal lahir tidak benar';
}
if ($user['icq'] && ($user['icq'] < 10000 || $user['icq'] > 999999999))
$error[] = 'Number ICQ Harus terdiri setidaknya 5 digit dan maksimal 10 digit';
if (!$error) {
mysql_query("UPDATE `users` SET
`imname` = '" . $user['imname'] . "',
`live` = '" . $user['live'] . "',
`dayb` = '" . $user['dayb'] . "',
`monthb` = '" . $user['monthb'] . "',
`yearofbirth` = '" . $user['yearofbirth'] . "',
`about` = '" . $user['about'] . "',
`mibile` = '" . $user['mibile'] . "',
`mail` = '" . $user['mail'] . "',
`mailvis` = '" . $user['mailvis'] . "',
`icq` = '" . $user['icq'] . "',
`skype` = '" . $user['skype'] . "',
`jabber` = '" . $user['jabber'] . "',
`www` = '" . $user['www'] . "'
WHERE `id` = '" . $user['id'] . "' LIMIT 1");
if ($rights >= 7) {
mysql_query("UPDATE `users` SET
`name` = '" . $user['name'] . "',
`status` = '" . $user['status'] . "',
`immunity` = '" . $user['immunity'] . "',
`karma_off` = '" . $user['karma_off'] . "',
`sex` = '" . $user['sex'] . "',
`rights` = '" . $user['rights'] . "'
WHERE `id` = '" . $user['id'] . "' LIMIT 1");
}
echo '';
}
else {
echo display_error($error);
}
}
echo '';
echo '';
require_once ('../incfiles/end.php');
?>