if ($uid) { $sql = "SELECT * from blocked_users where block_by=:uid and block_to=:user_id2"; $sth = $conn->prepare($sql); $sth->bindValue('uid', $uid); $sth->bindValue('user_id2', $user_id2); try { $sth->execute(); } catch (Exception $e) { } $result = $sth->fetchAll(); if ($result) { $success = '0'; $msg = "Already blocked this user"; } else { //removing match,favourites and conversation between current user and blocked user GeneralFunctions::RemoveMatch($uid, $user_id2); GeneralFunctions::RemoveFavorites($uid, $user_id2); GeneralFunctions::RemoveConversation($uid, $user_id2); $sql = "INSERT into blocked_users(id,block_by,block_to,created_on) VALUES(DEFAULT,:uid,:user_id2,NOW())"; $sth = $conn->prepare($sql); $sth->bindValue('uid', $uid); $sth->bindValue('user_id2', $user_id2); try { $sth->execute(); $success = '1'; $msg = "User BLocked"; } catch (Exception $e) { } } } else { $success = '0';
//checking whether the user is already matched $sql = "SELECT count(user_like.id) as like_count FROM `user_like` where liked_by IN (:user_id,:other_id) and liked_to IN (:user_id,:other_id) and user_like.status=1"; $sth = $conn->prepare($sql); $sth->bindValue('user_id', $user_id); $sth->bindValue('other_id', $other_id); try { $sth->execute(); } catch (Exception $e) { } $result = $sth->fetchAll(PDO::FETCH_ASSOC); $like_count = $result[0]['like_count']; if ($like_count == 2) { $match_status = 1; } else { $match_status = 0; } GeneralFunctions::RemoveMatch($user_id, $other_id) ? GeneralFunctions::RemoveMatch($user_id, $other_id) : []; $success = '1'; $msg = "Unmatched user"; } else { $success = '0'; $msg = "Token Expired"; } } // +-----------------------------------+ // + STEP 4: send json data + // +-----------------------------------+ /*if($success) echo json_encode(array('success'=>$success,'msg'=>$msg,'match'=>$match)); else*/ echo json_encode(array('success' => $success, 'msg' => $msg));