Example #1
0
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     $db = $this->factory->getDatabase(DSN);
     $res = $db->query('replace into friends (UID,FRIEND) values (%s, (select UID from user where USERNAME="******"))', $request->getValue('user')->UID, $request->getValue('friend'));
     header('Location: /sniff/main', 302);
     die;
 }
Example #2
0
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     if ($request->getValue('user')) {
         header('Location: /sniff/main', 302);
         die;
     }
     return new sniffStaticView(__DIR__ . '/../pages/homepage.xhtml');
 }
Example #3
0
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     $db = $this->factory->getDatabase(DSN);
     $res = $db->query('select * from user where UID in (select FRIEND from friends where UID="%s")', $request->getValue('user')->UID);
     $friends = array();
     while ($tmp = $res->fetch_object()) {
         $friends[] = $tmp;
     }
     $response->FRIENDS = $friends;
     return new sniffStaticView(__DIR__ . '/../pages/main.xhtml');
 }
Example #4
0
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     $db = $this->factory->getDatabase(DSN);
     if ($request->getValue('login')) {
         $res = $db->query('select * from user where USERNAME="******"', $request->getValue('login'));
         $response->profile = $res->fetch_object();
     } else {
         $response->profile = $request->getValue('user');
     }
     return new sniffStaticView(__DIR__ . $this->viewFile);
 }
Example #5
0
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     $db = $this->factory->getDatabase(DSN);
     $res = $db->query('insert into user (USERNAME,PASSWD,EMAIL,NAME) values ("%s","%s","%s","%s")', $request->getValue('username'), $request->getValue('passwd'), $request->getValue('email'), $request->getValue('name'));
     $msg = 'Welcome ' . $request->getValue('name') . "\n";
     $msg .= 'Your Login: '******'username') . "\n";
     $msg .= 'Your Password: '******'passwd') . "\n";
     $msg .= "\n\nEnjoy your stay!";
     mail($request->getValue('email'), 'welcome to SNIFF', $msg, 'From: housekeeping@sniff.mobile');
     header('Location: /sniff/home?message=Welcome,%20please%20login!', 302);
     die;
 }
Example #6
0
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     $db = $this->factory->getDatabase(DSN);
     if ($request->getValue('sniffUser')) {
         $_SESSION['user'] = unserialize($request->getValue('sniffUser'));
     } else {
         $res = $db->query('select * from user where username="******" and passwd="%s"', $request->getValue('username'), $request->getValue('passwd'));
         if ($res->num_rows != 1) {
             return new sniffStaticView(__DIR__ . '/../pages/loginfailed.xhtml');
         }
         $_SESSION['user'] = $res->fetch_object();
         setcookie('sniffUser', serialize($_SESSION['user']), time() + 60 * 60 * 24 * 31, '/');
     }
     header('Location: /sniff/main', 302);
     die;
 }
 public function execute(sniffRequest $request, sniffResponse $response)
 {
     $db = $this->factory->getDatabase(DSN);
     if (isset($_FILES['PICTURE'])) {
         $picture = basename($_FILES['PICTURE']['name']);
         $path = __DIR__ . '/../pictures/' . $request->getValue('user')->UID;
         if (!file_exists($path)) {
             mkdir($path);
         }
         move_uploaded_file($_FILES['PICTURE']['tmp_name'], $path . '/' . $picture);
         $res = $db->query('update user set PICTURE="%s" where UID=%s', $picture, $request->getValue('UID'));
     }
     $res = $db->query('update user set NAME="%s", EMAIL="%s", DESCR="%s" where UID=%s', $request->getValue('NAME'), $request->getValue('EMAIL'), $request->getValue('DESCR'), $request->getValue('UID'));
     $res = $db->query('select * from user where UID=%s', $request->getValue('user')->UID);
     $_SESSION['user'] = $res->fetch_object();
     header('Location: /sniff/main?message=Saved%20successfully', 302);
     die;
 }