Skip to content

Commit

Permalink
initial (public) commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Nov 9, 2011
0 parents commit 61077be
Show file tree
Hide file tree
Showing 214 changed files with 19,715 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*~
45 changes: 45 additions & 0 deletions README.md
@@ -0,0 +1,45 @@
parallel-flickr
==

parallel-flickr is **not** a replacement for Flickr.

**THIS PROBABLY HAS BUGS (OR AT LEAST STUPID MISTAKES) BUT GENERALLY SEEMS TO WORK** It also needs to be documented.

To do:
--

* write files to S3 (see also: [flamework-aws](https://github.com/straup/flamework-aws))

* API hooks (see also: [flamework-api](https://github.com/straup/flamework-api))

* account deletion

* sync/update contacts

* cron jobs for backups

* display metadata

* permission checks for geo (currently not displayed)

* search (solr?)

* duplicate key errors fetching faves

* better layout, tested in more than just Firefox

To note:
--

* password reminders are disabled, only because I don't have a mail server set up

See also:
--

* [flamework](https://github.com/straup/flamework)

* [flamework-flickrapp](https://github.com/straup/flamework-flickrapp)

* [flamework-api](https://github.com/straup/flamework-api)

* [flamework-invitecodes](https://github.com/straup/flamework-invitecodes)
1 change: 1 addition & 0 deletions apache/.gitignore
@@ -0,0 +1 @@
*.conf
35 changes: 35 additions & 0 deletions apache/parallel-flickr.conf.example
@@ -0,0 +1,35 @@
<VirtualHost *:80>
# ServerName example.com
# ServerAdmin webmaster@localhost

DocumentRoot /usr/local/parallel-flickr/www

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory /usr/local/parallel-flickr/www>
Options FollowSymLinks Indexes
# AllowOverride FileInfo Limit
AllowOverride All
Order allow,deny
allow from all
</Directory>

Alias /static/ /usr/local/parallel-flickr-static/

<Directory /usr/local/parallel-flickr-static/>
Options None
AllowOverride None
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
17 changes: 17 additions & 0 deletions bin/backup_faves.php
@@ -0,0 +1,17 @@
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");

set_time_limit(0);

#

include("include/init.php");
loadlib("flickr_backups");

foreach (flickr_backups_users() as $user){
$rsp = flickr_backups_get_faves($user);
}

?>
18 changes: 18 additions & 0 deletions bin/backup_photos.php
@@ -0,0 +1,18 @@
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");

set_time_limit(0);

#

include("include/init.php");
loadlib("flickr_backups");

foreach (flickr_backups_users() as $user){
$rsp = flickr_backups_get_photos($user);
dumper($rsp);
}

?>
17 changes: 17 additions & 0 deletions bin/generate_secret.php
@@ -0,0 +1,17 @@
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");

set_time_limit(0);

#

include("include/init.php");
loadlib("random");

$length = 32;

echo random_string($length) . "\n";
exit();
?>
128 changes: 128 additions & 0 deletions bin/get_contacts.php
@@ -0,0 +1,128 @@
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");

#

include("include/init.php");

loadlib("flickr_api");
loadlib("flickr_users");
loadlib("flickr_contacts");

loadlib("random");

$nsid = '35034348999@N01';

$flickr_user = flickr_users_get_by_nsid($nsid);
$user = users_get_by_id($flickr_user['user_id']);

# purge and restore

$cluster_id = $user['cluster_id'];
$enc_id = AddSlashes($user['id']);

$sql = "DELETE FROM FlickrContacts WHERE user_id='{$enc_id}'";
$rsp = db_write_users($cluster_id, $sql);

# re-fetch

$method = 'flickr.contacts.getList';

$args = array(
'auth_token' => $flickr_user['auth_token'],
'per_page' => 100,
'page' => 1,
);

$pages = null;

while ((! isset($pages)) || ($pages >= $args['page'])){

$rsp = flickr_api_call($method, $args);

if (! $rsp){
exit();
}

if (! isset($pages)){
$pages = $rsp['rsp']['contacts']['pages'];
}

$contacts = $rsp['rsp']['contacts']['contact'];

if (! is_array($contacts)){
exit;
}

foreach ($contacts as $contact){

$contact_nsid = $contact['nsid'];
$contact_username = $contact['username'];

#

$flickr_contact = flickr_users_get_by_nsid($contact_nsid);

if (! $flickr_contact){

$password = random_string(32);

$user_contact = users_create_user(array(
"username" => $contact_username,
"email" => "{$contact_username}@donotsend-flickr.com",
"password" => $password,
));

$flickr_contact = flickr_users_create_user(array(
'user_id' => $user_contact['id'],
'nsid' => $contact_nsid,
# note the lack of an auth_token
));
}

#

$friend = $contact['friend'];
$family = $contact['family'];

# TODO: put me in a function...

$map = flickr_contacts_relationship_map('string keys');
$rel = 0;

if (($family) && ($friend)){
$rel = $map['frfa'];
}

else if ($family){
$rel = $map['family'];
}

else if ($friend){
$rel = $map['friend'];
}

else {
$rel = $map['contact'];
}

# echo "{$contact_username} ({$flickr_contact['user_id']}) fr:{$friend} fa:{$family} rel:{$rel}\n";

#

$insert = array(
'user_id' => $user['id'],
'contact_id' => $flickr_contact['user_id'],
'rel' => $rel,
);

$contact = flickr_contacts_add_contact($insert);
}

$args['page'] += 1;
}

exit();
?>
17 changes: 17 additions & 0 deletions bin/update_faves.php
@@ -0,0 +1,17 @@
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");

set_time_limit(0);

#

include("include/init.php");
loadlib("flickr_faves_import");

$nsid = '35034348999@N01';
$rsp = flickr_faves_import_faves($nsid, 3);

exit();
?>
3 changes: 3 additions & 0 deletions schema/.htaccess
@@ -0,0 +1,3 @@
Order Allow,Deny
Allow from none
Deny from all
3 changes: 3 additions & 0 deletions schema/SETUP.md
@@ -0,0 +1,3 @@
CREATE DATABASE flickr;
CREATE USER 'flickr'@'localhost' IDENTIFIED BY '***';
GRANT SELECT,INSERT,UPDATE, DELETE ON flickr.* TO 'flickr'@'localhost' IDENTIFIED BY '***';
63 changes: 63 additions & 0 deletions schema/db_main.schema
@@ -0,0 +1,63 @@
DROP TABLE IF EXISTS `Users`;

CREATE TABLE `Users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`deleted` int(10) unsigned NOT NULL,
`created` int(10) unsigned NOT NULL,
`password` char(64) DEFAULT NULL,
`conf_code` char(24) DEFAULT NULL,
`confirmed` int(10) unsigned NOT NULL,
`cluster_id` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `by_email` (`email`),
UNIQUE KEY `by_username` (`username`,`deleted`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `UsersPasswordReset`;

CREATE TABLE `UsersPasswordReset` (
`user_id` int(10) unsigned NOT NULL,
`reset_code` char(32) DEFAULT NULL,
`created` int(10) unsigned NOT NULL,
UNIQUE KEY `by_code` (`reset_code`),
KEY `by_user` (`user_id`),
KEY `by_timestamp` (`created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `FlickrUsers`;

CREATE TABLE `FlickrUsers` (
`user_id` int(11) UNSIGNED NOT NULL,
`nsid` varchar(20) NOT NULL,
`path_alias` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`auth_token` char(34) NOT NULL,
`oauth_token` char(34) NOT NULL,
`oauth_secret` char(34) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `by_nsid` (`nsid`),
KEY `by_path_alias` (`path_alias`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `FlickrPhotosLookup`;

CREATE TABLE `FlickrPhotosLookup` (
`photo_id` BIGINT(20) UNSIGNED NOT NULL,
`user_id` INT(11) UNSIGNED NOT NULL,
PRIMARY KEY (`photo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `FlickrBackups`;

CREATE TABLE `FlickrBackups` (
`user_id` int(11) unsigned NOT NULL,
`type_id` tinyint(3) unsigned NOT NULL,
`date_created` int(11) unsigned NOT NULL,
`date_firstupdate` int(11) unsigned NOT NULL,
`date_lastupdate` int(11) unsigned NOT NULL,
`disabled` tinyint(3) unsigned NOT NULL,
`details` tinytext NOT NULL,
UNIQUE KEY `by_user` (`user_id`,`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18 changes: 18 additions & 0 deletions schema/db_tickets.schema
@@ -0,0 +1,18 @@
DROP TABLE IF EXISTS `Tickets32`;

CREATE TABLE `Tickets32` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`stub` char(1) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `stub` (`stub`)
) ENGINE=MyISAM;

DROP TABLE IF EXISTS `Tickets64`;

CREATE TABLE `Tickets64` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`stub` char(1) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `stub` (`stub`)
) ENGINE=MyISAM;

0 comments on commit 61077be

Please sign in to comment.