コード例 #1
0
ファイル: post_getposts.php プロジェクト: sXule/BranchFeed
    } else {
        $group_id = $_GET['group_id'];
        $offset = $_GET['offset'];
        $amount = $_GET['amount'];
    }
    // Setup API
    if (!($db = new Connection())) {
        throw new Exception("Couldn't connect to database!");
    }
    if (!($loginSys = new LoginSystem($db))) {
        throw new Exception("Couldn't connect to login system!");
    }
    if (!($postSys = new PostSystem($db))) {
        throw new Exception("Couldn't connect to post system!");
    }
    if (!($groupSys = new GroupSystem($db))) {
        throw new Exception("Couldn't connect to group system!");
    }
    // Verify that user is member of group
    if (!$groupSys->is_member($group_id, $loginSys->user['id'])) {
        throw new Exception("User isn't a member of requested group!");
    }
    // Get Posts
    if (!($posts = $postSys->GetPosts($group_id, $offset, $amount))) {
        throw new Exception("Unable to retreive posts!");
    }
} catch (Exception $e) {
    $error_msg = $e->getMessage();
    $success = false;
}
echo json_encode(array('success' => $success, 'error_msg' => $error_msg, 'posts' => $posts));
コード例 #2
0
ファイル: home.php プロジェクト: sXule/BranchFeed
<html>
    <head>
        <meta http-equiv="refresh" content="0; url=/"/>
    </head>
    <body></body>
</html>

<?php 
    // Logged in
} else {
    // Get Associated groups
    $groups = $groupSys->GetUserGroups($loginSys->user['id']);
    // Get Group Members
    $members = $loginSys->GetUsers($groupSys->GetMembers($loginSys->group_id));
    // Get group posts
    $posts = $postSys->GetPosts($loginSys->group_id);
    ?>
<!doctype html>
<html>
    <head>
        <title>BranchFeed</title>
        
        <meta charset="utf-8"/>
        
        <link rel="stylesheet" type="text/css" href="css/home.css"/>
    </head>
    <body>
        
        <div id="wrapper">
            
            <div id="topPanel">