echo get_user_tweets($user); } elseif ($func == 'toggle_favorite') { $panel_id = $_REQUEST['panel']; $tw_user = $_SESSION['panels'][$panel_id]->user; $tw_pass = $_SESSION['panels'][$panel_id]->pass; $fav_id = $_REQUEST['tweet_id']; $fav = $_REQUEST['favorite']; header("Content-type: text/javascript"); echo toggle_favorite($tw_user, $tw_pass, $fav_id, $fav); } elseif ($func == 'follow_user') { $panel_id = $_REQUEST['panel']; $tw_user = $_SESSION['panels'][$panel_id]->user; $tw_pass = $_SESSION['panels'][$panel_id]->pass; $to_follow = $_REQUEST['user']; header("Content-type: text/javascript"); echo follow_user($tw_user, $tw_pass, $to_follow); } elseif ($func == 'unfollow_user') { $panel_id = $_REQUEST['panel']; $tw_user = $_SESSION['panels'][$panel_id]->user; $tw_pass = $_SESSION['panels'][$panel_id]->pass; $to_follow = $_REQUEST['user']; header("Content-type: text/javascript"); echo unfollow_user($tw_user, $tw_pass, $to_follow); } elseif ($func == 'get_session_panels') { if (!isset($_SESSION['user_info']['panel_order'])) { $_SESSION['user_info']['panel_order'] = ""; } $panel_order = $_SESSION['user_info']['panel_order']; $panels = array(); if ($panel_order != "") { }
} function like_post($post_id) { global $conn; $sql = "update posts set likes = likes + 1 where id = {$post_id}"; $result = mysqli_query($conn, $sql); } function dislike_post($post_id) { global $conn; $sql = "update posts set dislikes = dislikes +1 where id = {$post_id}"; $result = mysqli_query($conn, $sql); } switch ($do) { case "follow": follow_user($_SESSION['userid'], $id); $msg = "You have followed a user!"; break; case "unfollow": unfollow_user($_SESSION['userid'], $id); $msg = "You have unfollowed a user!"; break; case "like": like_post($id); $msg = "You have liked a post!"; break; case "dislike": dislike_post($id); $msg = "You have disliked a post!"; break; case "delete":
function user_follow($uid, $followee_id) { global $db; $user_follows = $db->array_load_with_two_identifier('USER_FOLLOW', 'User_ID', $uid, 'Followee_ID', $followee_id); sort($user_follows); $count = count($user_follows); if ($count == 0) { unfollow_user($uid, $followee_id); follow_user($uid, $followee_id); } elseif ($count == 1) { unfollow_user($uid, $followee_id); } }
<?php require 'init.php'; $user_id = $_GET['id']; if (!get_username_by_user_id($user_id)) { display_not_found_page(); } $followers = get_followers($user_id); $page_url = APP_URL . '/user.php?id=' . $user_id; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['follow'])) { follow_user($user_id, get_current_user_id()); redirect($page_url); } else { if (isset($_POST['unfollow'])) { unfollow_user($user_id, get_current_user_id()); redirect($page_url); } } } $follower_count = get_follower_count($user_id); ?> <!DOCTYPE html> <head> <meta charset="utf-8"> <title>Tubogram</title> <?php echo js_and_css(); ?> </head>
if (!empty($token) && !empty($users_id2)) { $users_id1 = getUsersId($token); if (!empty($users_id1)) { $sql = "SELECT id FROM `follow` WHERE users_id1=:users_id1 AND users_id2=:users_id2"; $stmt = $conn->prepare($sql); $stmt->bindParam(':users_id1', $users_id1); $stmt->bindParam(':users_id2', $users_id2); try { $stmt->execute(); } catch (PDOException $e) { echo $e->getMessage(); } $id = $stmt->FetchAll(PDO::FETCH_ASSOC); if (empty($id)) { if ($users_id1 != $users_id2) { $follow_id = follow_user($users_id1, $users_id2); if (!empty($follow_id)) { $success = "1"; $msg = "Successfully followed!"; $sql1 = "SELECT U.id, U.name AS username, CONCAT( '{$path}', profile_pic )AS profile_pic, U.apn_id \n\t\t\t\t\t\t FROM `follow` AS F\n\t\t\t\t\t\t JOIN users AS U ON F.users_id2 = U.id\n\t\t\t\t\t\t WHERE F.id =:follow_id"; $sth1 = $conn->prepare($sql1); $sth1->bindValue(":follow_id", $follow_id); try { $sth1->execute(); } catch (Exception $e) { } $result1 = $sth1->fetchAll(PDO::FETCH_ASSOC); $apnid = $result1[0]['apn_id']; $sql2 = "SELECT U.id as uid, U.name AS username, CONCAT( '{$path}', profile_pic )AS profile_pic\n\t\t\t\t\t\t FROM `follow` AS F\n\t\t\t\t\t\t JOIN users AS U ON F.users_id1 = U.id\n\t\t\t\t\t\t WHERE F.id =:follow_id"; $sth2 = $conn->prepare($sql2); $sth2->bindValue(":follow_id", $follow_id);