Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public function reject($friendId)
 {
     $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
     $my_profile = new profile($this->db, $this->profileId);
     if ($my_profile->is_follower_exists($friendId)) {
         $my_profile->addFollower($friendId);
         $result = array("error" => false, "error_code" => ERROR_SUCCESS);
     }
     unset($my_profile);
     return $result;
 }
Ejemplo n.º 3
0
/*!
 * ifsoft.co.uk engine v1.0
 *
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php";
if (!empty($_POST)) {
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $profileId = isset($_POST['profileId']) ? $_POST['profileId'] : 0;
    $profileId = helper::clearInt($profileId);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $blacklist = new blacklist($dbo);
    $blacklist->setRequestFrom($profileId);
    if (!$blacklist->isExists($accountId)) {
        $profile = new profile($dbo, $profileId);
        $profile->setRequestFrom($accountId);
        $result = $profile->addFollower($accountId);
    }
    echo json_encode($result);
    exit;
}