YaWK  24.1
Yet another WebKit
accept-friend.php
Go to the documentation of this file.
1 <?php
2 include '../../system/classes/db.php';
3 include '../../system/classes/sys.php';
4 include '../../system/classes/user.php';
5 include '../../system/classes/alert.php';
6 include '../../system/classes/settings.php';
7 /* set database object */
8 if (!isset($db))
9 { // create new db object
10  $db = new \YAWK\db();
11 }
12 // prepare vars
13 $uid = $_POST['uid'];
14 $requestUsername = $_POST['requestUsername'];
15 $sessionUID = $_POST['sessionUID'];
16 $sessionUsername = \YAWK\user::getUserNameFromID($db, $sessionUID);
17 // SET friendship status to confirmed
19 if ($sql = $db->query("UPDATE {friends} SET confirmed = '1', confirmDate = '".$now."'
20  WHERE confirmed='0' AND friendB = '".$uid."' AND friendA = '".$sessionUID."'
21  OR confirmed = '0' AND friendA = '".$uid."' AND friendB = '".$sessionUID."'"))
22 { // success
23  echo "friendship confirmed";
24 }
25 else
26 { // q failed
27  echo \YAWK\alert::draw("warning","Warning!", "Could not confirm friendship status. Please try again.",'',4200);
28 }
29 // NOTIFY + SYSLOG ENTRY
30 // \YAWK\sys::setNotification($db, 3, "$sessionUsername accepted your friendship request.", $sessionUID, $uid, 0, 0);
31 \YAWK\sys::setNotification($db, 3, 0, $sessionUID, $uid, 0, 0,0);
32 \YAWK\sys::setSyslog($db, 17, 0, "$sessionUsername is now friend with $requestUsername", $uid, $sessionUID, 0, 0);
$sessionUsername
$requestUsername
$sessionUID
if(!isset($db)) $uid
$now
static now()
returns the current datetime
Definition: sys.php:1492
$sql
Definition: message-new.php:32