-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'uploadr' of github.com:straup/parallel-flickr into uploadr
- Loading branch information
Showing
7 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DROP TABLE IF EXISTS `InviteCodes`; | ||
|
||
CREATE TABLE `InviteCodes` ( | ||
`code` char(12) CHARACTER SET latin1 NOT NULL, | ||
`email` varchar(255) CHARACTER SET latin1 NOT NULL, | ||
`created` int(10) unsigned NOT NULL, | ||
`redeemed` int(10) unsigned NOT NULL, | ||
`user_id` int(11) unsigned NOT NULL, | ||
`sent` int(10) unsigned NOT NULL, | ||
`invited_by` int(11) unsigned NOT NULL, | ||
UNIQUE KEY `by_code` (`code`), | ||
KEY `by_email` (`email`), | ||
KEY `by_created` (`created`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
require('include/init.php'); | ||
loadlib('http'); | ||
loadlib("flickr_users"); | ||
loadlib("flickr_backups"); | ||
loadlib('flickr_photos_upload'); | ||
|
||
if (! $GLOBALS['cfg']['enable_feature_oauth_upload']) { | ||
error_disabled(); | ||
} | ||
|
||
if (! $GLOBALS['cfg']['enable_feature_uploads']){ | ||
error_disabled(); | ||
} | ||
|
||
$auth_url = $_SERVER['HTTP_X_AUTH_SERVICE_PROVIDER']; | ||
|
||
// Unless we validated which service is the auth provider, anyone | ||
// could send a valid user ID and post on behalf of known p-flickr | ||
// and twitter users. Also, there may be more providers but Twitter | ||
// is the big one. | ||
if (! preg_match("#^https://api.twitter.com/#", $auth_url)) { | ||
exit; | ||
} | ||
|
||
$headers = array('Authorization' => $_SERVER['HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION']); | ||
$res = http_get($auth_url, $headers); | ||
|
||
if (! $res['ok']) { | ||
exit; | ||
} | ||
|
||
$body = json_decode($res['body'], true); | ||
$twitter_id = $body['id']; | ||
|
||
// TODO: this should really be a page that user's can access through settings | ||
if (! isset($GLOBALS['cfg']['oauth_upload_user_mapping'][$twitter_id])) { | ||
exit; | ||
} | ||
|
||
$user = users_get_by_id($GLOBALS['cfg']['oauth_upload_user_mapping'][$twitter_id]); | ||
|
||
$is_registered = flickr_backups_is_registered_user($user); | ||
$can_upload = $is_registered; | ||
|
||
if ($can_upload){ | ||
$flickr_user = flickr_users_get_by_user_id($user['id']); | ||
$can_upload = flickr_users_has_token_perms($flickr_user, "write"); | ||
} | ||
|
||
if (! $can_upload) { | ||
exit; | ||
} | ||
|
||
$filepath = $_FILES['media']['tmp_name']; | ||
|
||
if (! $filepath) { | ||
exit; | ||
} | ||
|
||
// See that blank space? If a Twitter message starts with an '@' symbol, | ||
// that gets interpreted by curl as a *filepath*. Flickr strips that | ||
// blank space on save so this hack gets around that (nolan-20120929) | ||
$args = array( | ||
'title' => ' ' . $_POST['message'], | ||
); | ||
|
||
$res = flickr_photos_upload($user, $filepath, $args); | ||
|
||
if ($res['ok']) { | ||
print "<mediaurl>http://www.flickr.com/photos/{$flickr_user['nsid']}/{$res['photo_id']}/</mediaurl>"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters