-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathedit_user.php
More file actions
147 lines (138 loc) · 5.16 KB
/
edit_user.php
File metadata and controls
147 lines (138 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Silurus Classifieds Builder
*
*
* @author SnowHall - http://snowhall.com
* @website http://snowhall.com/silurus
* @email support@snowhall.com
*
* @version 2.0
* @date March 7, 2013
*
* Silurus is a professionally developed PHP Classifieds script that was built for you.
* Whether you are running classifieds for autos, motorcycles, bicycles, rv's, guns,
* horses, or general merchandise, our product is the right package for you.
* It has template system and no limit to usage with free for any changes.
*
* Copyright (c) 2009-2013
*/
include("./include_php/init.php");
if($_SESSION['memberID'] == 0) header("location: index.php");
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$err = array();
$add_on = '';
if($_POST['Email'] != $_POST['Email2'])
$err['Email2'] = 1;
/*if(trim($_POST['fname']) == '')
$err['fname'] = 1;
if(trim($_POST['lname']) == '')
$err['lname'] = 1;
if(trim($_POST['city']) == '')
$err['city'] = 1;*/
if(trim($_POST['Email']) == '')
$err['Email'] = 1;
/*if(trim($_POST['zip']) == '')
$err['Zip'] = 1; */
if($_POST['Password1'] != '' && $_POST['Password1'] != $_POST['Password2'])
$err['Password2'] = 1;
$us = mysql_numrows(mysql_query("select * from Profiles where ID<>".$_SESSION['memberID']." and Email='".mysql_escape_string($_POST['Email'])."'"));
if($us > 0 && $_POST['Email']!='')
{
$add_on = "<span style=\"font-size:14px;color:#880000\"><b>Error:</b> This E-mail already use</span><br />";
$err['Email'] = 1;
}
if(empty($err))
{
$collge = mysql_fetch_assoc(mysql_query("select * from City where Title = '".mysql_escape_string(trim($_POST['city']))."'"));
if(intval($collge['ID']) > 0)
$collgeid = intval($collge['ID']);
else
{
mysql_query("insert into City set Title='".mysql_escape_string(trim($_POST['city']))."'");
$collgeid = mysql_insert_id();
}
$Photo = '';
if( !$_FILES['Photo'] or empty( $_FILES['Photo'] ) )
$add_on .= report_err('File not uploaded');
else
{
if( $_FILES['Photo']['error'] != 0 )
$sActionText = 'File upload error<br>';
else
{
$aFileInfo = getimagesize( $_FILES['Photo']['tmp_name'] );
if( !$aFileInfo )
$sActionText = 'You uploaded not image file<br>';
else
{
$ext = false;
switch( $aFileInfo['mime'] )
{
case 'image/jpeg': $ext = 'jpg'; break;
case 'image/gif': $ext = 'gif'; break;
case 'image/png': $ext = 'png'; break;
}
if( !$ext )
$sActionText = 'You uploaded not JPEG, GIF or PNG file<br>';
else
{
$dir = "media/images/profile/".$_SESSION['memberID']."/";
if(!is_dir($dir)) mkdir($dir, 0755, true);
if(trim($_SESSION['memberINFO']['PrimPhoto'])!='' && trim($_SESSION['memberINFO']['PrimPhoto'])!='0')
$newFileName = $_SESSION['memberINFO']['PrimPhoto'];
else
$newFileName = time().'.'.$ext;
if( !move_uploaded_file( $_FILES['Photo']['tmp_name'], $dir.'photo_'.$newFileName ) )
$sActionText = 'Couldn\'t download file.';
else
{
imageResize( $dir.'photo_'.$newFileName, $dir.'thumb_'.$newFileName,200);
$Photo = "PrimPhoto='$newFileName',";
}
}
}
}
}
mysql_query("update `Profiles` SET
fname='".mysql_escape_string($_POST['fname'])."',
lname='".mysql_escape_string($_POST['lname'])."',
Email='".mysql_escape_string($_POST['Email'])."',
".($_POST['Password1'] != ''?"Password='".mysql_escape_string($_POST['Password1'])."',":"")."
zip='".mysql_escape_string($_POST['zip'])."',
city=".$collgeid.",
$Photo
LastModified=".time().",
intro='".mysql_escape_string($_POST['intro'])."',
note='".mysql_escape_string($_POST['note'])."',
altemail='".mysql_escape_string($_POST['altemail'])."',
phone='".mysql_escape_string($_POST['phone'])."',
cell='".mysql_escape_string($_POST['cell'])."',
aim='".mysql_escape_string($_POST['aim'])."',
skype='".mysql_escape_string($_POST['skype'])."',
phone_none='".intval($_POST['phone_none'])."',
cell_none='".intval($_POST['cell_none'])."',
aim_none='".intval($_POST['aim_none'])."',
altemail_none='".intval($_POST['altemail_none'])."',
skype_none='".intval($_POST['skype_none'])."'
where ID=".$_SESSION['memberID']);
$_SESSION['memberINFO'] = mysql_fetch_assoc(mysql_query("select * from Profiles where ID=".$_SESSION['memberID']));
header("location: profile.php"); die();
}
$smarty->assign("error", $err);
$smarty->assign("t_error", $add_on);
}
else
{
$_REQUEST = $_SESSION['memberINFO'];
$_REQUEST['Email2'] = $_REQUEST['Email'];
$city = mysql_fetch_assoc(mysql_query("select * from City where ID=".intval($_REQUEST['city'])));
$_REQUEST['city'] = $city['Title'];
}
addNavigation('profile.php','My Profile');
addNavigation('','Edit My Account Information');
$smarty->assign("site_title", 'Edit My Account Information'." :: ".$gConfig['site_title']);
$smarty->assign("HEADERTEXT", 'Edit My Account Information');
show_smarty_template('edit_user');
?>