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; }
<?php /*! * 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'] : ''; $friendId = isset($_POST['friendId']) ? $_POST['friendId'] : 0; $friendId = helper::clearInt($friendId); $result = array("error" => true, "error_code" => ERROR_UNKNOWN); $auth = new auth($dbo); if (!$auth->authorize($accountId, $accessToken)) { api::printError(ERROR_ACCESS_TOKEN, "Error authorization."); } $friends = new friends($dbo, $accountId); $friends->setRequestFrom($accountId); $result = $friends->remove($friendId); echo json_encode($result); exit; }