function flickr_backups_for_user(&$user, $type_id = null) { $enc_user = AddSlashes($user['id']); $sql = "SELECT * FROM FlickrBackups WHERE user_id='{$enc_user}'"; if (isset($type_id)) { $enc_type = AddSlashes($type_id); $sql .= " AND type_id='{$enc_type}'"; } $rsp = db_fetch($sql); $backups = array(); $map = flickr_backups_type_map(); foreach ($rsp['rows'] as $row) { $type = $map[$row['type_id']]; $backups[$type] = $row; } return $backups; }
<?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"); $map = flickr_backups_type_map("string keys"); foreach (flickr_backups_users() as $user) { $backups = flickr_backups_for_user($user); foreach ($map as $label => $type_id) { if (isset($backups[$label])) { continue; } echo "backup", "register '{$user['username']}' for {$label} backups\n"; $rsp = flickr_backups_create($user, $type_id); } }
$backups = flickr_backups_for_user($GLOBALS['cfg']['user']); $registered = count($backups) ? 1 : 0; if (!$registered && !$GLOBALS['cfg']['backups_enable_registrations']) { error_disabled(); } if ($GLOBALS['cfg']['enable_feature_invite_codes']) { if (!$registered && !invite_codes_get_by_cookie()) { $cookie = login_get_cookie('invite'); if (!$cookie) { header("location: /invite/?redir=" . urlencode("account/flickr/backups")); exit; } } } features_ensure_enabled("backups"); $map = flickr_backups_type_map('string keys'); $GLOBALS['smarty']->assign_by_ref("map", $map); $crumb_key = 'backups'; $smarty->assign("crumb_key", $crumb_key); $crumb_ok = crumb_check($crumb_key); if ($crumb_ok) { if (post_str("setup")) { $created = array(); $details = array(); foreach ($map as $ignore => $type_id) { $rsp = flickr_backups_create($GLOBALS['cfg']['user'], $type_id); $created[$type_id] = $rsp['ok'] || $rsp['error_code'] == 1062 ? 1 : 0; $rsp['type_id'] = $type_id; $details[] = $rsp; } $GLOBALS['smarty']->assign_by_ref("created", $created);