<?php

require 'include/init.php';
if (!global_check_login()) {
    global_redirect('index.php');
}
$topics = array("contacts_photos" => "Contacts' Photos", "contacts_faves" => "Contacts' Faves", "photos_of_contacts" => "Photos of my Contacts", "photos_of_me" => "Photos of Me", "my_photos" => "My Photos", "my_faves" => "My Faves", "geo" => "Geo", "commons" => "Commons", "tags" => "Tags");
$user_nsid = $cfg['account']['auth']['user']['nsid'];
$token = $cfg['account']['auth']['token']['_content'];
$flickr = new Flickr($cfg['flickr_key'], $cfg['flickr_secret']);
// What does Flickr say we are subscribed to?
$subscriptions = $flickr->call_method('flickr.push.getSubscriptions', array('auth_token' => $token), 1);
$live_subscriptions = array();
$active_subscriptions = array();
// Figure out what we are currently subscribed to so we'll know what we need to add from the passed-in form data
if (isset($subscriptions['subscriptions']['subscription'])) {
    foreach ($subscriptions['subscriptions']['subscription'] as $sub) {
        if (strpos($sub['callback'], $cfg['base_push_url']) === 0) {
            $pieces = explode('&', parse_url($sub['callback'], PHP_URL_QUERY));
            foreach ($pieces as $piece) {
                list($k, $v) = explode('=', $piece, 2);
                if ($k == 'sub') {
                    $live_subscriptions[$v] = 1;
                }
            }
        }
    }
}
$titles = array();
foreach ($_POST['streams'] as $topic) {
    switch ($topic) {
Example #2
0
<?php

require 'include/init.php';
# We don't know who they are. Make them log back in!
$flickr = new Flickr($GLOBALS['cfg']['flickr_key'], $GLOBALS['cfg']['flickr_secret']);
# Determine if user is logged in
$show_login = !global_check_login();
?>
<!doctype html>
<html>
    <head>
        <title>Conduit: An Experiment</title>
        <link type="text/css" rel="stylesheet" href="site.css">
    </head>
    <body>
        <h1>Conduit</h1>
<?php 
if ($show_login) {
    print 'This is Nolan Caudill\'s <a href="https://github.com/mncaudill/flickr-conduit">Flickr Conduit</a> adapted for Heroku (<a href="https://github.com/RandomEtc/flickr-conduit-front/">front</a>, <a href="https://github.com/RandomEtc/flickr-conduit-back/">back</a>). Flickr Pro account holders can log in <a href="login.php">here</a>.';
} else {
    print "<p>Logged in as {$GLOBALS['cfg']['account']['auth']['user']['username']}. <a href='{$GLOBALS['cfg']['logout']}'>Log out?</a></p>";
    ?>
        <form method='post' action='streams.php'>
            <input type="checkbox" name="streams[]" value="commons">Photos from the Flickr Commons<br>
            <input type="checkbox" name="streams[]" value="contacts_photos">Photos from your contacts<br>
            <input type="checkbox" name="streams[]" value="contacts_faves">Favorites from your contacts<br>
            <input type="checkbox" name="streams[]" value="photos_of_contacts">Photos of your contacts<br>
            <input type="checkbox" name="streams[]" value="photos_of_me">Photos of you<br>
            <input type="checkbox" name="streams[]" value="my_photos">Your photos<br>
            <input type="checkbox" name="streams[]" value="my_faves">Your favorites<br>