<?php

include_once '../common/utilities.php';
$error_messages = array();
$title = 'Facebook album downloader';
$user = $fb->getUser();
$utilities = new Utilities();
if ($user) {
    $me = $fb->api('/me');
    $title = $me['name'] . ' : ' . $title;
    $userlist = $utilities->fql("SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())");
} else {
    $title = 'Login : '******'';
    $messages['info'][] = 'Please ' . $utilities->url($fb->getLoginUrl(), 'login') . ' to use this app';
}
include "../views/userlist.php";
<?php

include_once '../common/utilities.php';
$uid = $_SESSION['uid'] = $_GET['uid'];
$name = $_GET['name'];
$cols = 4;
$utilities = new Utilities();
$albums = $utilities->fql("SELECT aid, name, cover_pid FROM album WHERE owner = " . $uid);
$pids = array();
for ($i = 0; $i < count($albums); $i++) {
    $pids[] = '"' . $albums[$i]['cover_pid'] . '"';
}
$photos = $utilities->fql("SELECT pid, src FROM photo WHERE pid in (" . implode(',', $pids) . ")");
$coverImages = array();
for ($i = 0; $i < count($photos); $i++) {
    $coverImages[$photos[$i]['pid']] = $photos[$i]['src'];
}
$title = $name . "'s Albums";
include "../views/albumlist.php";
<?php

$aid = isset($_GET['aid']) ? $_GET['aid'] : '';
$name = isset($_GET['name']) ? $_GET['name'] : '';
include_once '../common/utilities.php';
if ($aid) {
    // user is requesting photos from album
    $fql = "SELECT src_small, src_big FROM photo where aid = '" . $aid . "'";
    $title = "Album photos : " . $name;
}
$utilities = new Utilities();
$photos = $utilities->fql($fql);
include '../views/photolist.php';