function friendsAction() { HackCheck(); if ($_REQUEST['json'] == 'y') { if ($_REQUEST['act']) { $act = explode("-", $_REQUEST['act']); if ($act[0] == "r") { $this->user->RemoveFriend(decode($act[1])); $r = array("af frnd", "Add as friend", "a-" . $act[1]); } if ($act[0] == "a") { $this->user->AddFan(decode($act[1])); $user = new UsersModel(decode($act[1])); $user = $user->Info(); $invitee = $this->view->user; $msg = "<strong>Hi " . $user['fname'] . " " . $user['lname'] . "</strong><br /><br />\r\n\t\t\t\t\t\t\t<a href=\"" . WWW_ROOT . "user/" . encode($invitee["id"]) . "/\">" . $invitee['fname'] . " " . $invitee['lname'] . "</a> wants to be your friend on pepool.com.<br />\r\n\t\t\t\t\t\t\tTo accept his request and view user profile go to the link below:<br />\r\n\t\t\t\t\t\t\t<a href=\"" . WWW_ROOT . "user/" . encode($invitee["id"]) . "/\">" . WWW_ROOT . "user/" . encode($invitee["id"]) . "</a>\r\n\t\t\t\t\t\t\t<br /><br />Thanks<br />Pepool.com"; sendmail($invitee["fname"] . " " . $invitee["lname"] . " wants to be your friend ", $msg, $user["email"], $user['fname'] . " " . $user['lname']); $r = array("wf frnd", "Friend request pending", ""); } if ($act[0] == "c") { $this->user->ConfirmFriend(decode($act[1])); $r = array("rf frnd", "Remove friend", "r-" . $act[1]); } } jencode($r); } $of = $this->getRequest()->getParam('of') ? decode($this->getRequest()->getParam('of')) : $this->session->user['id']; $user = new UsersModel($of); $userFriends = $user->GetFriends(); $user = $user->Info(); $prefix = $this->session->user['id'] == $of ? 'My' : ($user['gender'] == 'M' ? 'His' : 'Her'); if (count($userFriends["recivedRequest"]) > 0 && $of && $prefix == 'My') { $rU["recived-friend"]["title"] = "You have new friend request"; foreach ($userFriends["recivedRequest"] as $id => $v) { $rU["recived-friend"]["data"][] = array("uid" => encode($id), "username" => $v["username"], "image" => $v["image"], "addr" => timeDiff(strtotime($v["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => '')) . ", " . ($v["gender"] == "M" ? "Male" : "Female") . "<br />" . ($v["address"] ? $v["address"] . ", " : "") . ($v["city"] ? $v["city"] . ", " : "") . $v["state"]); } } if (count($userFriends["friends"]) > 0) { $rU["real-friend"]["title"] = $prefix . " real friends"; foreach ($userFriends["friends"] as $id => $v) { $rU["real-friend"]["data"][] = array("uid" => encode($id), "username" => $v["username"], "image" => $v["image"], "addr" => timeDiff(strtotime($v["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => '')) . ", " . ($v["gender"] == "M" ? "Male" : "Female") . "<br />" . ($v["address"] ? $v["address"] . ", " : "") . ($v["city"] ? $v["city"] . ", " : "") . $v["state"]); } } else { $rU["real-friend"]["title"] = "So sad, " . $prefix . " account of friends are empty"; } if (count($userFriends["sentRequest"]) > 0 && $of && $prefix == 'My') { $rU["sent-friend"]["title"] = "Pending friend request you send"; foreach ($userFriends["sentRequest"] as $id => $v) { $rU["sent-friend"]["data"][] = array("uid" => encode($id), "username" => $v["username"], "image" => $v["image"], "addr" => timeDiff(strtotime($v["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => '')) . ", " . ($v["gender"] == "M" ? "Male" : "Female") . "<br />" . ($v["address"] ? $v["address"] . ", " : "") . ($v["city"] ? $v["city"] . ", " : "") . $v["state"]); } } jencode($rU); die; }