コード例 #1
0
ファイル: follow_followers.php プロジェクト: TEJATJ/BITSQ
                    }
                    echo ');" style="padding:5px;text-decoration:none;margin-top:6px;">
				<span class="followuser-' . $userDetails->id . '">';
                    if (following($user_id, $userDetails->id)) {
                        echo 'Unfollow';
                    } else {
                        echo 'Follow';
                    }
                    echo '</span></a>
	<div>';
                    echo '<hr>';
                }
            }
            break;
        case "Followers":
            $a = followers_id($_SESSION['user_id']);
            $user_id = $_SESSION['user_id'];
            foreach ($a as $follower) {
                if (!empty(getUserDetails($follower->u_id))) {
                    $userDetails = getUserDetails($follower->u_id);
                    echo '<div style="margin-top:1px;"><img style="padding-right:5px;" src="' . BASE_URI . 'templates/avatars/' . $userDetails->avatar . '" width="50px" height="50px"><a href="topics.php?user='******'">' . $userDetails->name . '<span class="hidden-xs">, ' . $userDetails->about . '</a>
	<a href="#" id="follow-' . $userDetails->id . '" class="upvotes upvoteborder pull-right" onclick="follow(' . $userDetails->id . ',';
                    if (following($user_id, $userDetails->id)) {
                        echo "'unfollow'";
                    } else {
                        echo "'follow'";
                    }
                    echo ');" style="padding:5px;text-decoration:none;margin-top:6px;">
				<span class="followuser-' . $userDetails->id . '">';
                    if (following($user_id, $userDetails->id)) {
                        echo 'Unfollow';
コード例 #2
0
ファイル: create.php プロジェクト: TEJATJ/BITSQ
            $db = new Database();
            $db->query("INSERT INTO categories VALUES ('',:name,:description)");
            $db->bind(":name", strip_tags($_POST['newCat'], ''));
            $db->bind(":description", $b);
            $db->execute();
            $db->query("SELECT id FROM categories ORDER BY id DESC LIMIT 1");
            $result = $db->single();
            $data['category_id'] = $result->id;
        } else {
            $data['category_id'] = strip_tags($_POST['category'], '');
        }
        $data['user_id'] = $_SESSION['user_id'];
        $data['last_activity'] = date("Y-m-d H:i:s");
        $data['body'] = strip_tags($_POST['body'], '<iframe><br>');
        $required = array("title", "category_id");
        if (requiredFields($required, $data)) {
            if ($user->createTopic($data)) {
                add_notification($_SESSION['user_id'], "asked a question", getlastid('topics'), 0, followers_id($_SESSION['user_id']));
                echo '<div class="al alert alert-success" style="text-align:center">Successfully posted your query</div>
	 <script>reload();</script>';
            } else {
                echo '<div class="al alert alert-danger" style="text-align:center">Couldn\'t Upload. Please try after some time </div>';
            }
        } else {
            echo '<div class="al alert alert-warning" style="text-align:center">Please fill all the required fields</div>';
        }
    }
    echo $template;
} else {
    redirect("index.php");
}
コード例 #3
0
ファイル: topic.php プロジェクト: TEJATJ/BITSQ
require 'core/init.php';
$topic = new Topic();
$user = new User();
$template = new Template("templates/topic.php");
$topic_id = isset($_GET['topic']) ? $_GET['topic'] : null;
$template->topicSel = $topic->getTopicById($topic_id);
$template->replies = $topic->getRepliesBytopic($topic_id);
$template->title = $topic->getTopicById($topic_id)->title;
$template->totUsers = totUsers();
$template->totTopics = topicsCount("all");
if (isLoggedIn()) {
    $template->user_id = $_SESSION['user_id'];
    $template->username = $_SESSION['username'];
    $template->email = $_SESSION['email'];
    $template->last_activity = $_SESSION['last_activity'];
    $template->avatar = $_SESSION['avatar'];
    $template->details = $_SESSION['details'];
    if (!empty($_POST['reply']) && isset($_POST['reply']) && $_POST['reply'] != '<br>') {
        $data['topic_id'] = $_GET['topic'];
        $data['user_id'] = $_SESSION['user_id'];
        $data['body'] = $_POST['reply'];
        $redirect = "topic.php?topic=" . urlFormat($_GET['topic']);
        if ($user->reply($data)) {
            add_notification($_SESSION['user_id'], " added an answer to a topic ", $_GET['topic'], $_POST['newAns'], followers_id($_SESSION['user_id']));
        }
        redirect($redirect);
    }
} else {
    redirect("home.php");
}
echo $template;
コード例 #4
0
ファイル: upvote.php プロジェクト: TEJATJ/BITSQ
            if ($result->count == 0) {
                $db->query("INSERT INTO upvotes VALUES ('',:t_id,:r_id,:u_id,:v_f,'1',:date)");
            } else {
                $db->query("UPDATE upvotes SET vote='1',last_activity=:date WHERE u_id=:u_id AND t_id=:t_id AND r_id=:r_id AND v_for=:v_f");
            }
            $db->bind("u_id", $user_id);
            $db->bind("r_id", $r_id);
            $db->bind("t_id", $t_id);
            $db->bind("v_f", $s->user_id);
            $db->bind("date", date("Y-m-d H:i:s"));
            if ($db->execute()) {
                if ($r_id != 0) {
                    add_notification($user_id, "upvoted for an answer to the question", $t_id, $r_id, followers_id($user_id));
                } else {
                    if ($_id == 0) {
                        add_notification($user_id, "upvoted for a question", $t_id, $r_id, followers_id($user_id));
                    }
                }
            }
            break;
        case "downvote":
            $db->query("UPDATE upvotes SET vote='0',last_activity=:date WHERE u_id=:u_id AND t_id=:t_id AND r_id=:r_id");
            $db->bind("u_id", $user_id);
            $db->bind("r_id", $r_id);
            $db->bind("t_id", $t_id);
            $db->bind("date", date("Y-m-d H:i:s"));
            if ($db->execute()) {
            }
    }
} else {
    redirect("home.php");