-
Notifications
You must be signed in to change notification settings - Fork 0
/
InsertUser.php
163 lines (135 loc) · 4.23 KB
/
InsertUser.php
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
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
require_once('DbOperation.php');
require_once('Uprofile.php');
require_once('User.php');
require_once('Uprofile.php');
require_once('Follower.php');
$mysqli = new mysqli('localhost','root','pass@123','Feelsyou');
$usertimestamp="";
$userid="";
$userfid="";
$usergid="";
$useripaddr="";
$userphonenumber="";
$id="";
$profile="";
$last_name="";
$first_name="";
$nickname="";
$email="";
$website="";
$status="";
$aboutme="";
$gender="";
$mypath="";
$result="";
if($_SERVER['REQUEST_METHOD']=='POST'){
$user=new User();
$db = new DbOperation();
$uprofile = new Uprofile();
$useripaddr = $_SERVER['REMOTE_ADDR'];
$usertimestamp = round(microtime(true) * 1000);
$id = $usertimestamp.$db->generateId();
$userid = $usertimestamp.$db->generateId();
if (isset($_POST["fid"])) {
$userfid = $_POST['fid'];
}
if (isset($_POST["gid"])) {
$usergid = $_POST['gid'];
}
if (isset($_POST["phonenumber"])) {
$userphonenumber = $_POST['phonenumber'];
}
if (isset($_POST["profile"])) {
$profile = $_POST['profile'];
}else{
$profile="http://feeltunes.com/ItFeelsYou/PostData/logo.jpg";
}
if (isset($_POST["last_name"])) {
$last_name = $_POST['last_name'];
}
if (isset($_POST["first_name"])) {
$first_name = $_POST['first_name'];
}
if (isset($_POST["nickname"])) {
$nickname = $_POST['nickname'];
}
if (isset($_POST["email"])) {
$email = $_POST['email'];
}
if (isset($_POST["website"])) {
$website = $_POST['website'];
}
if (isset($_POST["status"])) {
$status = $_POST['status'];
}
if (isset($_POST["aboutme"])) {
$aboutme = $_POST['aboutme'];
}
if (isset($_POST["gender"])) {
$gender= $_POST['gender'];
}
$result = $mysqli->query("SELECT * FROM user WHERE phonenumber = $userphonenumber");
//echo json_encode($result);
if($result->num_rows == 0) {
// row not found, do stuff...
echo json_encode($result);
$mysqli->close();
$mypath = "Users/".$usertimestamp;
if (!file_exists($mypath)) {
mkdir($mypath,0777, true);
// echo('Folder Created');
mkdir("Users/".$usertimestamp."/".$userid,0777,true);
}
else
{
// echo('Folders Not created ');
}
if(!$user->createUser($userid,$usertimestamp,$userphonenumber,$userfid,$usergid,$useripaddr))
{
$uprofile->createProfile($id,$userid,$usertimestamp,$profile,$userphonenumber,$last_name,$first_name,$nickname,$email,$website,$status,$aboutme,$gender);
}
//$myObj=array();
$myObj->userid = $userid;
$myObj->tp = $usertimestamp;
$myObj->profile ="http://feeltunes.com/ItFeelsYou/Users/".$usertimestamp."/".$userid."/".$usertimestamp.".jpg" ;
$myObj->nickname=$nickname;
$myJSON = json_encode($myObj);
echo $myJSON;
}
else
{
$result = $mysqli->query("SELECT * FROM user WHERE phonenumber = $userphonenumber");
$f=new Follower();
$up = new Uprofile();
$uid=$result->id;
$url = $up->getUProfile($uid);
$response = array();
while($sms = $url->fetch_assoc()){
$temp = array();
$temp['uid']=$sms['uid'];
$temp['timestamp']=$sms['timestamp'];
$temp['profile']="http://feeltunes.com/ItFeelsYou/".$sms['profile'];
$temp['phone']=$sms['phone'];
$temp['last_name']=$sms['last_name'];
$temp['first_name']=$sms['first_name'];
$temp['nickname']=$sms['nickname'];
$temp['email']=$sms['email'];
$temp['website']=$sms['website'];
$temp['status']=$sms['status'];
$temp['aboutme']=$sms['aboutme'];
$temp['gender']=$sms['gender'];
$followerc=array();
$followercount=$f->getFollowerCount($uid);
$followingc=array();
$followingcount=$f->getFollowingCount($uid);
//array_push($followerc,$followercount[0]);
//array_push($followingc,$followingcount[0]);
$temp['followerc']=$followercount[0];
$temp['followingc']=$followingcount[0];
array_push($response,$temp);
}
echo json_encode($response);
}
}
?>