View file modules/user/edit.php

File size: 4.12Kb
<?
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.pp.ua	  *
**********************************/
if(isset($user)) {
if(isset($_POST['save']) && $_GET['act']== 'save') {
$name = substr(input($_POST['name']), 0, 35);
$surname = substr(input($_POST['surname']), 0, 35);
$day = abs(intval($_POST['day']));
$month = abs(intval($_POST['month']));
$year = abs(intval($_POST['year']));
$device = substr(input($_POST['device']), 0, 65);
$icq = substr(abs(intval($_POST['icq'])), 0, 9);
$gender = abs(intval($_POST['gender']));
$city = substr(input($_POST['city']), 0, 65);
$country = substr(input($_POST['country']), 0, 55);
$site = substr(input($_POST['site']), 0, 40);
$about_me = substr(input($_POST['about_me']), 0, 1000);
$db->query("UPDATE `users` SET  `name` = '". $name."', `surname` = '". $surname."', `day` = '". $day."', `month` = '". $month."', `year` = '". $year."', `device` = '". $device."', `icq` = '". $icq."', `city` = '". $city."', `country` = '". $country."', `site` = '". $site."', `gender` = '". $gender."', `info` = '". $about_me."' WHERE `id` = '".$user['id'] ."'");
// print_r($db->errorInfo());
go('/user/edit/?act=edited');
	}
$locate = 'in_edit';
$title = $lang->word('edit_profile');
require_once(SYS.'/view/header.php');
if($_GET['act']=='edited') {$tpl->div('block', $lang->word('succ_save'));}
$tpl->div('title',  $lang->word('edit_profile'));
echo '<div class="post">
		<form action="?act=save" method="post">
		 <b>'. $lang->word('name') .'</b>: <br/>
		 <input type="text" name="name" value="'. $user['name'] .'" /><br/>
		 <b>'. $lang->word('surname') .'</b>: <br/>
		 <input type="text" name="surname" value="'. $user['surname'] .'" /><br/>
		 <b>'. $lang->word('birth') .'</b>: <br/>
		 <select name="day">
		 <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
		 for($d = 1; $d<=31; $d++) {
		 echo "<option value=\"". $d ."\" ".($user['day'] == $d ? 'selected=\"selected\"' : NULL).">". $d ."</option>\n";
		 }
		 echo '</select>
		 <select name="month">
		 <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
		 for($m = 1; $m<=12; $m++) {
		 echo "<option value=\"". $m ."\" ".($user['month'] == $m ? 'selected=\"selected\"' : NULL).">". $m ."</option>\n";
		 }
		 echo '</select>
		 <select name="year">
		 <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
		 for($y = 1960; $y<=(date('Y')-1); $y++) {
		 echo "<option value=\"". $y ."\" ".($user['year'] == $y ? 'selected=\"selected\"' : NULL).">". $y ."</option>\n";
		 }
		 echo '</select><br/>
		 <b>'. $lang->word('gender') .'</b>: <br/>
		 <select name="gender">
		 <option value="0" '.($user['gender'] == '0' ? 'selected="selected"' : NULL).'>'. $lang->word('unknown') .'</option>
		 <option value="1" '.($user['gender'] == '1' ? 'selected="selected"' : NULL).'>'. $lang->word('male') .'</option>
		 <option value="2" '.($user['gender'] == '2' ? 'selected="selected"' : NULL).'>'. $lang->word('female') .'</option>
		 </select><br/>
		 <b>'. $lang->word('device') .'</b>: <br/>
		 <input type="text" name="device" value="'. $user['device'] .'" /><br/>
		 <b>ICQ</b>: <br/>
		 <input type="text" name="icq" value="'. $user['icq'] .'" /><br/>
		 <b>'. $lang->word('city') .'</b>: <br/>
		 <input type="text" name="city" value="'. $user['city'] .'" /><br/>
		 <b>'. $lang->word('country') .'</b>: <br/>
		 <input type="text" name="country" value="'. $user['country'] .'" /><br/>
		 <b>'. $lang->word('site') .'</b>: <br/>
		 <input type="text" name="site" value="'. (empty($user['site']) ? 'http://' : $user['site']).'" /><br/>
		 <b>'. $lang->word('about_me') .'</b>: <br/>
		 <textarea rows="5" cols="30" name="about_me">'. $user['info'] .'</textarea><br/>
		 <input name="save" type="submit" value="'. $lang->word('save') .'" />
		 </form>
</div>
		 ';
$tpl->div('block', NAV.'<a href="/user/panel/">'.$lang->word('user_panel').'</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
} else { go('/'); }
?>