예제 #1
0
파일: ajax.php 프로젝트: jnpdx/combotweet
    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 != "") {
    }
    header("Content-type: text/javascript");
    $json_panels = array();
    foreach ($_SESSION['panels'] as $key => $p) {
        /*
        if ($p->panel_type == 'search') {
        	
        	display_search_panel($p);
예제 #2
0
파일: user.php 프로젝트: afalina/Tubogram
<?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>
예제 #3
0
    $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":
        delete_post($id);
        $msg = "You have deleted that post!";
        break;
}
예제 #4
0
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);
    }
}