コード例 #1
0
 public function add($userId, $reason = "")
 {
     $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
     $currentTime = time();
     $ip_addr = helper::ip_addr();
     $u_agent = helper::u_agent();
     $stmt = $this->db->prepare("INSERT INTO profile_blacklist (blockedByUserId, blockedUserId, reason, createAt, ip_addr, u_agent) value (:blockedByUserId, :blockedUserId, :reason, :createAt, :ip_addr, :u_agent)");
     $stmt->bindParam(":blockedByUserId", $this->requestFrom, PDO::PARAM_INT);
     $stmt->bindParam(":blockedUserId", $userId, PDO::PARAM_INT);
     $stmt->bindParam(":reason", $reason, PDO::PARAM_STR);
     $stmt->bindParam(":createAt", $currentTime, PDO::PARAM_INT);
     $stmt->bindParam(":ip_addr", $ip_addr, PDO::PARAM_STR);
     $stmt->bindParam(":u_agent", $u_agent, PDO::PARAM_STR);
     if ($stmt->execute()) {
         $result = array("error" => false, "error_code" => ERROR_SUCCESS);
         $my_profile = new profile($this->db, $this->requestFrom);
         if ($my_profile->is_friend_exists($userId)) {
             $friends = new friends($this->db, $this->requestFrom);
             $friends->remove($userId);
             unset($friends);
         } else {
             if ($my_profile->is_follower_exists($userId)) {
                 // Unfollow
                 $my_profile->addFollower($userId);
             }
             $profile = new profile($this->db, $userId);
             if ($profile->is_follower_exists($this->requestFrom)) {
                 $profile->addFollower($this->requestFrom);
             }
             unset($profile);
         }
         unset($my_profile);
     }
     return $result;
 }
コード例 #2
0
 public function accept($friendId)
 {
     $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
     $my_profile = new profile($this->db, $this->profileId);
     if ($my_profile->is_follower_exists($friendId)) {
         $currentTime = time();
         $stmt = $this->db->prepare("INSERT INTO friends (friend, friendTo, createAt) value (:friend, :friendTo, :createAt)");
         $stmt->bindParam(":friend", $friendId, PDO::PARAM_INT);
         $stmt->bindParam(":friendTo", $this->profileId, PDO::PARAM_INT);
         $stmt->bindParam(":createAt", $currentTime, PDO::PARAM_INT);
         if ($stmt->execute()) {
             $result = array("error" => false, "error_code" => ERROR_SUCCESS, "itemId" => $this->db->lastInsertId());
             $stmt2 = $this->db->prepare("INSERT INTO friends (friend, friendTo, createAt) value (:friend, :friendTo, :createAt)");
             $stmt2->bindParam(":friend", $this->profileId, PDO::PARAM_INT);
             $stmt2->bindParam(":friendTo", $friendId, PDO::PARAM_INT);
             $stmt2->bindParam(":createAt", $currentTime, PDO::PARAM_INT);
             $stmt2->execute();
             $stmt3 = $this->db->prepare("DELETE FROM profile_followers WHERE follower = (:follower) AND follow_to = (:follow_to)");
             $stmt3->bindParam(":follower", $friendId, PDO::PARAM_INT);
             $stmt3->bindParam(":follow_to", $this->profileId, PDO::PARAM_INT);
             $stmt3->execute();
             $stmt4 = $this->db->prepare("DELETE FROM profile_followers WHERE follower = (:follower) AND follow_to = (:follow_to)");
             $stmt4->bindParam(":follower", $this->profileId, PDO::PARAM_INT);
             $stmt4->bindParam(":follow_to", $friendId, PDO::PARAM_INT);
             $stmt4->execute();
             $stmt5 = $this->db->prepare("DELETE FROM notifications WHERE notifyToId = (:notifyToId) AND notifyFromId = (:notifyFromId) AND notifyType = 1");
             $stmt5->bindParam(":notifyToId", $this->profileId, PDO::PARAM_INT);
             $stmt5->bindParam(":notifyFromId", $friendId, PDO::PARAM_INT);
             $stmt5->execute();
             $stmt5 = $this->db->prepare("DELETE FROM notifications WHERE notifyToId = (:notifyToId) AND notifyFromId = (:notifyFromId) AND notifyType = 1");
             $stmt5->bindParam(":notifyToId", $friendId, PDO::PARAM_INT);
             $stmt5->bindParam(":notifyFromId", $this->profileId, PDO::PARAM_INT);
             $stmt5->execute();
             $account = new account($this->db, $this->profileId);
             $account->updateCounters();
             unset($account);
             $account = new account($this->db, $friendId);
             $account->updateCounters();
             if ($account->getAllowFollowersGCM() == ENABLE_FOLLOWERS_GCM) {
                 $gcm = new gcm($this->db, $friendId);
                 $gcm->setData(GCM_FRIEND_REQUEST_ACCEPTED, "Friend Request accepted", 0);
                 $gcm->send();
             }
             unset($account);
         }
     }
     unset($my_profile);
     return $result;
 }
コード例 #3
0
 public function get()
 {
     $result = array("error" => true, "error_code" => ERROR_ACCOUNT_ID);
     $stmt = $this->db->prepare("SELECT * FROM users WHERE id = (:id) LIMIT 1");
     $stmt->bindParam(":id", $this->id, PDO::PARAM_INT);
     if ($stmt->execute()) {
         if ($stmt->rowCount() > 0) {
             $row = $stmt->fetch();
             // test to my like
             $myLike = false;
             if ($this->requestFrom != 0) {
                 if ($this->is_like_exists($this->requestFrom)) {
                     $myLike = true;
                 }
             }
             // test to blocked
             $blocked = false;
             if ($this->requestFrom != 0) {
                 $blacklist = new blacklist($this->db);
                 $blacklist->setRequestFrom($this->requestFrom);
                 if ($blacklist->isExists($this->id)) {
                     $blocked = true;
                 }
                 unset($blacklist);
             }
             // test to follow
             $follow = false;
             if ($this->requestFrom != 0) {
                 if ($this->is_follower_exists($this->requestFrom)) {
                     $follow = true;
                 }
             }
             // test to friend
             $friend = false;
             if ($this->requestFrom != 0) {
                 if ($this->is_friend_exists($this->requestFrom)) {
                     $friend = true;
                 }
             }
             // test to my follower
             $follower = false;
             if ($this->requestFrom != 0) {
                 $myProfile = new profile($this->db, $this->requestFrom);
                 if ($myProfile->is_follower_exists($this->getId())) {
                     $follower = true;
                 }
                 unset($myProfile);
             }
             // is my profile exists in blacklist
             $inBlackList = false;
             if ($this->requestFrom != 0) {
                 $blacklist = new blacklist($this->db);
                 $blacklist->setRequestFrom($this->getId());
                 if ($blacklist->isExists($this->getRequestFrom())) {
                     $inBlackList = true;
                 }
                 unset($blacklist);
             }
             $online = false;
             $current_time = time();
             if ($row['last_authorize'] != 0 && $row['last_authorize'] > $current_time - 15 * 60) {
                 $online = true;
             }
             $time = new language($this->db);
             $result = array("error" => false, "error_code" => ERROR_SUCCESS, "id" => $row['id'], "ghost" => $row['ghost'], "vip" => $row['vip'], "rating" => $row['rating'], "state" => $row['state'], "sex" => $row['sex'], "year" => $row['bYear'], "month" => $row['bMonth'], "day" => $row['bDay'], "lat" => $row['lat'], "lng" => $row['lng'], "username" => $row['login'], "fullname" => htmlspecialchars_decode(stripslashes($row['fullname'])), "location" => stripcslashes($row['country']), "status" => stripcslashes($row['status']), "fb_page" => stripcslashes($row['fb_page']), "instagram_page" => stripcslashes($row['my_page']), "verify" => $row['verify'], "lowPhotoUrl" => $row['lowPhotoUrl'], "bigPhotoUrl" => $row['bigPhotoUrl'], "normalPhotoUrl" => $row['normalPhotoUrl'], "normalCoverUrl" => $row['normalCoverUrl'], "originCoverUrl" => $row['originCoverUrl'], "coverPosition" => $row['coverPosition'], "iStatus" => $row['iStatus'], "iPoliticalViews" => $row['iPoliticalViews'], "iWorldView" => $row['iWorldView'], "iPersonalPriority" => $row['iPersonalPriority'], "iImportantInOthers" => $row['iImportantInOthers'], "iSmokingViews" => $row['iSmokingViews'], "iAlcoholViews" => $row['iAlcoholViews'], "iLooking" => $row['iLooking'], "iInterested" => $row['iInterested'], "allowPhotosComments" => $row['allowPhotosComments'], "allowMessages" => $row['allowMessages'], "friendsCount" => $row['friends_count'], "photosCount" => $row['photos_count'], "likesCount" => $row['likes_count'], "giftsCount" => $row['gifts_count'], "follower" => $follower, "friend" => $friend, "inBlackList" => $inBlackList, "follow" => $follow, "blocked" => $blocked, "myLike" => $myLike, "createAt" => $row['regtime'], "createDate" => date("Y-m-d", $row['regtime']), "lastAuthorize" => $row['last_authorize'], "lastAuthorizeDate" => date("Y-m-d H:i:s", $row['last_authorize']), "lastAuthorizeTimeAgo" => $time->timeAgo($row['last_authorize']), "online" => $online);
         }
     }
     return $result;
 }