function import_flickr_url($url, $more = array()) { list($type, $uid) = import_flickr_url_type($url); # photosets if ($type == "set") { $rows = import_flickr_photoset($uid, $more); return array('ok' => 1, 'data' => $rows); } # groups if ($type == "group") { $group_id = $uid; if (!preg_match("!\\@N\\d+\$!", $group_id)) { $group_id = flickr_lookup_group_id_by_url($url); } if (!$group_id) { return array('ok' => 0, 'error' => 'Invalid group ID'); } $rows = import_flickr_group_pool($group_id, $more); return array('ok' => 1, 'data' => $rows); } # individual users if ($type == "user") { $user_id = $uid; if (!preg_match("!\\@N\\d+\$!", $user_id)) { $user_id = flickr_lookup_user_id_by_url($url); } if (!$user_id) { return array('ok' => 0, 'error' => 'Invalid user ID'); } $rows = import_flickr_user($user_id, $more); return array('ok' => 1, 'data' => $rows); } # for example: # http://api.flickr.com/services/feeds/geo/?id=35034348999@N01&lang=en-us if ($type == "feed") { $more = array('assume_mime_type' => 'application/rss+xml'); $upload = import_fetch_uri($url, $more); if ($upload['ok']) { $upload = import_process_file($upload); } return $upload; } # yahoo says no return array('ok' => 0, 'error' => 'Failed to parse URL'); }
function import_import_file(&$user, &$file, $more = array()) { if (!import_is_valid_mimetype($file, $more)) { return array('error' => 'invalid_mimetype', 'ok' => 0); } # Parse the file $process_rsp = import_process_file($file); if (!$process_rsp['ok']) { return $process_rsp; } # # store the data # $fingerprint = md5_file($file['path']); $label = $more['label'] ? $more['label'] : $process_rsp['label']; $import_more = array('return_dots' => $more['return_dots'], 'dots_index_on' => $more['dots_index_on'], 'label' => $label, 'mark_all_private' => $more['mark_all_private'], 'mime_type' => $file['type'], 'fingerprint' => $fingerprint, 'simplified' => $process_rsp['simplified'] ? 1 : 0); $import_rsp = import_process_data($user, $process_rsp['data'], $import_more); if (!$import_rsp['ok']) { return $import_rsp; } # # Hello new thing # $cache_key = "sheets_lookup_fingerprint_{$fingerprint}"; cache_unset($cache_key); # # store the actual file? # if ($GLOBALS['cfg']['enable_feature_import_archive']) { loadlib("archive"); $archive_rsp = archive_store_file($file, $import_rsp['sheet']); # throw an error if archiving fails? } # # happy happy # return $import_rsp; }
if (!$upload['ok']) { $GLOBALS['error']['upload_by_url_error'] = 1; $GLOBALS['error']['details'] = $upload['error']; $GLOBALS['smarty']->display('page_upload3.txt'); exit; } # # Okay, now process the file # if ($is_flickr) { // not entirely sure about this, there are many flickr cases (seanc | 07072011) $upload = import_preprocess_address_fields($upload); $pre_process = $upload; } else { $more = array('dots_index_on' => $dots_index_on); $pre_process = import_process_file($upload, $more); } # dumper($pre_process); # convert any errors from a bag of arrays in to a hash # where the key maps to record number (assuming the count # starts at 1. if (count($pre_process['errors'])) { $_errors = array(); foreach ($pre_process['errors'] as $e) { $_errors[$e['record']] = $e; } $pre_process['errors'] = $_errors; } $GLOBALS['smarty']->assign_by_ref("pre_process", $pre_process); $GLOBALS['smarty']->assign('step', 'process'); } else {
} if ($ok) { $more = array(); if ($mime_type) { $more['assume_mime_type'] = $mime_type; } if (!import_is_valid_mimetype($_FILES['upload'], $more)) { $GLOBALS['error']['invalid_mimetype'] = 1; } else { $_FILES['upload']['path'] = $_FILES['upload']['tmp_name']; $fingerprint = md5_file($_FILES['upload']['path']); $GLOBALS['smarty']->assign("fingerprint", $fingerprint); $sheets = sheets_lookup_by_fingerprint($fingerprint, $GLOBALS['cfg']['user']['id']); $GLOBALS['smarty']->assign_by_ref("sheets", $sheets); $more = array('dots_index_on' => $dots_index_on); $pre_process = import_process_file($_FILES['upload'], $more); # convert any errors from a bag of arrays in to a hash # where the key maps to record number (assuming the count # starts at 1. if (count($pre_process['errors'])) { $_errors = array(); foreach ($pre_process['errors'] as $e) { $_errors[$e['record']] = $e; } $pre_process['errors'] = $_errors; } $GLOBALS['smarty']->assign_by_ref("pre_process", $pre_process); # store the file somewhere in a pending bin? } } } else {