/** * API method * Returns a list of categories * @param mixed[] $params * @option int cat_id (optional) * @option bool recursive * @option bool public * @option bool tree_output * @option bool fullname */ function ws_categories_getList($params, &$service) { global $user, $conf; $where = array('1=1'); $join_type = 'INNER'; $join_user = $user['id']; if (!$params['recursive']) { if ($params['cat_id'] > 0) { $where[] = '( id_uppercat = ' . (int) $params['cat_id'] . ' OR id=' . (int) $params['cat_id'] . ' )'; } else { $where[] = 'id_uppercat IS NULL'; } } else { if ($params['cat_id'] > 0) { $where[] = 'uppercats ' . DB_REGEX_OPERATOR . ' \'(^|,)' . (int) $params['cat_id'] . '(,|$)\''; } } if ($params['public']) { $where[] = 'status = "public"'; $where[] = 'visible = "true"'; $join_user = $conf['guest_id']; } else { if (is_admin()) { // in this very specific case, we don't want to hide empty // categories. Function calculate_permissions will only return // categories that are either locked or private and not permitted // // calculate_permissions does not consider empty categories as forbidden $forbidden_categories = calculate_permissions($user['id'], $user['status']); $where[] = 'id NOT IN (' . $forbidden_categories . ')'; $join_type = 'LEFT'; } } $query = ' SELECT id, name, comment, permalink, uppercats, global_rank, id_uppercat, nb_images, count_images AS total_nb_images, representative_picture_id, user_representative_picture_id, count_images, count_categories, date_last, max_date_last, count_categories AS nb_categories FROM ' . CATEGORIES_TABLE . ' ' . $join_type . ' JOIN ' . USER_CACHE_CATEGORIES_TABLE . ' ON id=cat_id AND user_id=' . $join_user . ' WHERE ' . implode("\n AND ", $where) . ' ;'; $result = pwg_query($query); // management of the album thumbnail -- starts here $image_ids = array(); $categories = array(); $user_representative_updates_for = array(); // management of the album thumbnail -- stops here $cats = array(); while ($row = pwg_db_fetch_assoc($result)) { $row['url'] = make_index_url(array('category' => $row)); foreach (array('id', 'nb_images', 'total_nb_images', 'nb_categories') as $key) { $row[$key] = (int) $row[$key]; } if ($params['fullname']) { $row['name'] = strip_tags(get_cat_display_name_cache($row['uppercats'], null)); } else { $row['name'] = strip_tags(trigger_change('render_category_name', $row['name'], 'ws_categories_getList')); } $row['comment'] = strip_tags(trigger_change('render_category_description', $row['comment'], 'ws_categories_getList')); // management of the album thumbnail -- starts here // // on branch 2.3, the algorithm is duplicated from // include/category_cats, but we should use a common code for Piwigo 2.4 // // warning : if the API method is called with $params['public'], the // album thumbnail may be not accurate. The thumbnail can be viewed by // the connected user, but maybe not by the guest. Changing the // filtering method would be too complicated for now. We will simply // avoid to persist the user_representative_picture_id in the database // if $params['public'] if (!empty($row['user_representative_picture_id'])) { $image_id = $row['user_representative_picture_id']; } else { if (!empty($row['representative_picture_id'])) { // if a representative picture is set, it has priority $image_id = $row['representative_picture_id']; } else { if ($conf['allow_random_representative']) { // searching a random representant among elements in sub-categories $image_id = get_random_image_in_category($row); } else { // searching a random representant among representant of sub-categories if ($row['count_categories'] > 0 and $row['count_images'] > 0) { $query = ' SELECT representative_picture_id FROM ' . CATEGORIES_TABLE . ' INNER JOIN ' . USER_CACHE_CATEGORIES_TABLE . ' ON id=cat_id AND user_id=' . $user['id'] . ' WHERE uppercats LIKE \'' . $row['uppercats'] . ',%\' AND representative_picture_id IS NOT NULL ' . get_sql_condition_FandF(array('visible_categories' => 'id'), "\n AND") . ' ORDER BY ' . DB_RANDOM_FUNCTION . '() LIMIT 1 ;'; $subresult = pwg_query($query); if (pwg_db_num_rows($subresult) > 0) { list($image_id) = pwg_db_fetch_row($subresult); } } } } } if (isset($image_id)) { if ($conf['representative_cache_on_subcats'] and $row['user_representative_picture_id'] != $image_id) { $user_representative_updates_for[$row['id']] = $image_id; } $row['representative_picture_id'] = $image_id; $image_ids[] = $image_id; $categories[] = $row; } unset($image_id); // management of the album thumbnail -- stops here $cats[] = $row; } usort($cats, 'global_rank_compare'); // management of the album thumbnail -- starts here if (count($categories) > 0) { $thumbnail_src_of = array(); $new_image_ids = array(); $query = ' SELECT id, path, representative_ext, level FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $image_ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { if ($row['level'] <= $user['level']) { $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row); } else { // problem: we must not display the thumbnail of a photo which has a // higher privacy level than user privacy level // // * what is the represented category? // * find a random photo matching user permissions // * register it at user_representative_picture_id // * set it as the representative_picture_id for the category foreach ($categories as &$category) { if ($row['id'] == $category['representative_picture_id']) { // searching a random representant among elements in sub-categories $image_id = get_random_image_in_category($category); if (isset($image_id) and !in_array($image_id, $image_ids)) { $new_image_ids[] = $image_id; } if ($conf['representative_cache_on_level']) { $user_representative_updates_for[$category['id']] = $image_id; } $category['representative_picture_id'] = $image_id; } } unset($category); } } if (count($new_image_ids) > 0) { $query = ' SELECT id, path, representative_ext FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $new_image_ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row); } } } // compared to code in include/category_cats, we only persist the new // user_representative if we have used $user['id'] and not the guest id, // or else the real guest may see thumbnail that he should not if (!$params['public'] and count($user_representative_updates_for)) { $updates = array(); foreach ($user_representative_updates_for as $cat_id => $image_id) { $updates[] = array('user_id' => $user['id'], 'cat_id' => $cat_id, 'user_representative_picture_id' => $image_id); } mass_updates(USER_CACHE_CATEGORIES_TABLE, array('primary' => array('user_id', 'cat_id'), 'update' => array('user_representative_picture_id')), $updates); } foreach ($cats as &$cat) { foreach ($categories as $category) { if ($category['id'] == $cat['id'] and isset($category['representative_picture_id'])) { $cat['tn_url'] = $thumbnail_src_of[$category['representative_picture_id']]; } } // we don't want them in the output unset($cat['user_representative_picture_id'], $cat['count_images'], $cat['count_categories']); } unset($cat); // management of the album thumbnail -- stops here if ($params['tree_output']) { return categories_flatlist_to_tree($cats); } return array('categories' => new PwgNamedArray($cats, 'category', ws_std_get_category_xml_attributes())); }
function pfemail_check_accounts() { global $conf, $user; conf_update_param('pfemail_last_check', date('Y-m-d H:i:s')); require_once PFEMAIL_PATH . 'include/ImapMailbox.php'; $image_ids = array(); $query = ' SELECT * FROM ' . PFEMAIL_MAILBOXES_TABLE . ' ;'; $accounts = query2array($query); foreach ($accounts as $account) { $mailbox = new ImapMailbox($account['path'], $account['login'], $account['password'], $conf['upload_dir'] . '/buffer', 'utf-8'); $mails = array(); // Get some mail $mailsIds = $mailbox->searchMailBox('UNSEEN'); if (!$mailsIds) { continue; // check next email account } $mailId = reset($mailsIds); $mail = $mailbox->getMail($mailId); $attachments = $mail->getAttachments(); include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'; foreach ($attachments as $attachment) { $extension = strtolower(get_extension($attachment->{'name'})); if (!in_array($extension, $conf['picture_ext'])) { // the file has been downloaded, we have to remove it now unlink($attachment->{'filePath'}); continue; } $moderate = get_boolean($account['moderated']); $image_id = add_uploaded_file($attachment->{'filePath'}, stripslashes($attachment->{'name'}), array($account['category_id']), $moderate ? 16 : 0, null); // the photo is added by nobody (using the current user may make the // photo editable by her with Admin Tools...) single_update(IMAGES_TABLE, array('added_by' => null, 'name' => pfemail_clean_email_subject($mail->subject)), array('id' => $image_id)); $state = 'auto_validated'; if ($moderate) { $state = 'moderation_pending'; } list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); single_insert(PFEMAIL_PENDINGS_TABLE, array('image_id' => $image_id, 'state' => $state, 'added_on' => $dbnow, 'from_name' => $mail->fromName, 'from_address' => $mail->fromAddress, 'subject' => $mail->subject)); $image_ids[] = $image_id; } } if (count($image_ids) > 0) { include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; invalidate_user_cache(); // let's notify administrators $query = ' SELECT id FROM ' . GROUPS_TABLE . ' ;'; $group_ids = query2array($query, null, 'id'); if (count($group_ids) > 0) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $thumb_urls = array(); // force $conf['derivative_url_style'] to 2 (script) to make sure we // will use i.php?/upload and not _data/i/upload because you don't // know when the cache will be flushed $previous_derivative_url_style = $conf['derivative_url_style']; $conf['derivative_url_style'] = 2; $query = ' SELECT id, path FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $image_ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $thumb = DerivativeImage::thumb_url(array('id' => $row['id'], 'path' => $row['path'])); $thumb_urls[] = $thumb; } // restore configuration setting $conf['derivative_url_style'] = $previous_derivative_url_style; $thumbs_html_string = ''; foreach ($thumb_urls as $thumb_url) { if (!empty($thumbs_html_string)) { $thumbs_html_string .= ' '; } $thumbs_html_string .= '<img src="' . $thumb_url . '">'; } $content = $thumbs_html_string; // how many photos pending? $pendings = pfemail_get_pending_ids(); if (count($pendings) > 0) { $content .= '<br><br>'; $content .= '<a href="' . get_absolute_root_url() . 'admin.php?page=plugin-photo_from_email-pendings' . '">'; $content .= l10n('%d photos pending for validation', count($pendings)); $content .= '</a>'; } $real_user_id = $user['id']; $user['id'] = $conf['guest_id']; $subject = l10n('%d photos added by email', count($thumb_urls)); foreach ($group_ids as $group_id) { pwg_mail_group($group_id, array('subject' => '[' . $conf['gallery_title'] . '] ' . $subject, 'mail_title' => $conf['gallery_title'], 'mail_subtitle' => $subject, 'content' => $content, 'content_format' => 'text/html')); } } // restore current user $user['id'] = $real_user_id; } }
state, from_name, from_address, subject FROM ' . IMAGES_TABLE . ' JOIN ' . PFEMAIL_PENDINGS_TABLE . ' ON id = image_id WHERE image_id IN (' . implode(',', $pending_ids) . ') ORDER BY image_id DESC LIMIT ' . $page['start'] . ', ' . $page['nb_pendings_per_page'] . ' ;'; $result = pwg_query($query); $rows = array(); $image_ids = array(); while ($row = pwg_db_fetch_assoc($result)) { array_push($rows, $row); array_push($image_ids, $row['id']); } $template->assign(array('F_ACTION' => $admin_base_url)); foreach ($rows as $row) { $thumb = DerivativeImage::thumb_url(array('id' => $row['image_id'], 'path' => $row['path'])); $template->append('photos', array('U_EDIT' => get_root_url() . 'admin.php?page=plugin-showcase_admin-photo&image_id=' . $row['image_id'], 'ID' => $row['image_id'], 'TN_SRC' => $thumb, 'WEBSIZE_SRC' => $row['path'], 'ADDED_BY' => $row['author'], 'ADDED_ON' => format_date($row['date_available'], true), 'NAME' => $row['name'], 'FILE' => $row['file'], 'DATE_CREATION' => empty($row['date_creation']) ? l10n('N/A') : format_date($row['date_creation']), 'DESCRIPTION' => $row['comment'], 'FROM' => @$row['from_name'] . ' <' . $row['from_address'] . '>')); } // +-----------------------------------------------------------------------+ // | navigation bar | // +-----------------------------------------------------------------------+ $template->assign('navbar', create_navigation_bar(get_root_url() . 'admin.php' . get_query_string_diff(array('start', 'action', 'showcase_id')), count($pending_ids), $page['start'], $page['nb_pendings_per_page'])); // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
function ws_images_addRemote($params, &$service) { global $conf; if (!is_admin()) { return new PwgError(401, 'Access denied'); } load_language('plugin.lang', URLUPLOADER_PATH); $params = array_map('trim', $params); $allowed_extensions = array('jpg', 'jpeg', 'png', 'gif'); $allowed_mimes = array('image/jpeg', 'image/png', 'image/gif'); // check empty url if (empty($params['file_url'])) { return new PwgError(WS_ERR_INVALID_PARAM, l10n('File URL is empty')); } // check remote url if (!url_is_remote($params['file_url'])) { return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file URL')); } // check file extension if (!in_array(strtolower(get_extension($params['file_url'])), $allowed_extensions)) { return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file type')); } // download file include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; $temp_filename = $conf['data_location'] . basename($params['file_url']); $file = fopen($temp_filename, 'w+'); $result = fetchRemote($params['file_url'], $file); fclose($file); // download failed ? if (!$result) { @unlink($temp_filename); return new PwgError(WS_ERR_INVALID_PARAM, l10n('Unable to download file')); } // check mime-type if (!in_array(get_mime($temp_filename, $allowed_mimes[0]), $allowed_mimes)) { @unlink($temp_filename); return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file type')); } // add photo include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'; $image_id = add_uploaded_file($temp_filename, basename($temp_filename), array($params['category']), $params['level']); $updates = array(); if (!empty($params['name'])) { $updates['name'] = $params['name']; } if ($params['url_in_comment'] == 'true') { $url = parse_url($params['file_url']); $url = $url['scheme'] . '://' . $url['host']; $updates['comment'] = '<a href="' . $url . '">' . $url . '</a>'; } single_update(IMAGES_TABLE, $updates, array('id' => $image_id)); // return infos $query = ' SELECT id, name, permalink FROM ' . CATEGORIES_TABLE . ' WHERE id = ' . $params['category'] . ' ;'; $category = pwg_db_fetch_assoc(pwg_query($query)); $url_params = array('image_id' => $image_id, 'section' => 'categories', 'category' => $category); $query = ' SELECT id, path, name FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $image_infos = pwg_db_fetch_assoc(pwg_query($query)); $query = ' SELECT COUNT(*) AS nb_photos FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE category_id = ' . $params['category'] . ' ;'; $category_infos = pwg_db_fetch_assoc(pwg_query($query)); $category_name = get_cat_display_name_from_id($params['category'], null); return array('image_id' => $image_id, 'url' => make_picture_url($url_params), 'src' => DerivativeImage::thumb_url($image_infos), 'name' => $image_infos['name'], 'category' => array('id' => $params['category'], 'nb_photos' => $category_infos['nb_photos'], 'label' => $category_name)); }
$template->assign('U_SYNC', $base_url . 'site_update&site=1&cat_id=' . $category['id']); } } // representant management if ($category['has_images'] or !empty($category['representative_picture_id'])) { $tpl_representant = array(); // picture to display : the identified representant or the generic random // representant ? if (!empty($category['representative_picture_id'])) { $query = ' SELECT id,representative_ext,path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $category['representative_picture_id'] . ' ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); $src = DerivativeImage::thumb_url($row); $url = get_root_url() . 'admin.php?page=photo-' . $category['representative_picture_id']; $tpl_representant['picture'] = array('SRC' => $src, 'URL' => $url); } // can the admin choose to set a new random representant ? $tpl_representant['ALLOW_SET_RANDOM'] = $category['has_images'] ? true : false; // can the admin delete the current representant ? if ($category['has_images'] and $conf['allow_random_representative'] or !$category['has_images'] and !empty($category['representative_picture_id'])) { $tpl_representant['ALLOW_DELETE'] = true; } $template->assign('representant', $tpl_representant); } if ($category['is_virtual']) { $template->assign('parent_category', empty($category['id_uppercat']) ? array() : array($category['id_uppercat'])); } trigger_notify('loc_end_cat_modify');
$image_title = '(' . $line['image_id'] . ')'; if (isset($image_infos[$line['image_id']]['label'])) { $image_title .= ' ' . trigger_change('render_element_description', $image_infos[$line['image_id']]['label']); } else { $image_title .= ' unknown filename'; } $image_string = ''; switch ($thumbnail_display) { case 'no_display_thumbnail': $image_string = '<a href="' . $picture_url . '">' . $image_title . '</a>'; break; case 'display_thumbnail_classic': $image_string = '<a class="thumbnail" href="' . $picture_url . '">' . '<span><img src="' . DerivativeImage::thumb_url($element) . '" alt="' . $image_title . '" title="' . $image_title . '">' . '</span></a>'; break; case 'display_thumbnail_hoverbox': $image_string = '<a class="over" href="' . $picture_url . '">' . '<span><img src="' . DerivativeImage::thumb_url($element) . '" alt="' . $image_title . '" title="' . $image_title . '">' . '</span>' . $image_title . '</a>'; break; } } $template->append('search_results', array('DATE' => $line['date'], 'TIME' => $line['time'], 'USER' => $user_string, 'IP' => $line['IP'], 'IMAGE' => $image_string, 'TYPE' => $line['image_type'], 'SECTION' => $line['section'], 'CATEGORY' => isset($line['category_id']) ? isset($name_of_category[$line['category_id']]) ? $name_of_category[$line['category_id']] : 'deleted ' . $line['category_id'] : '', 'TAGS' => $tags_string)); } $summary['nb_guests'] = 0; if (count(array_keys($summary['guests_IP'])) > 0) { $summary['nb_guests'] = count(array_keys($summary['guests_IP'])); // we delete the "guest" from the $username_of hash so that it is // avoided in next steps unset($username_of[$conf['guest_id']]); } $summary['nb_members'] = count($username_of); $member_strings = array(); foreach ($username_of as $user_id => $user_name) {
/** */ function get_category_representant_properties($image_id) { $query = ' SELECT id,representative_ext,path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); $src = DerivativeImage::thumb_url($row); $url = get_root_url() . 'admin.php?page=photo-' . $image_id; return array('src' => $src, 'url' => $url); }
if (file_exists($file)) { array_push($videos, array('src' => embellish_url(get_gallery_home_url() . $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "." . $file_ext), 'ext' => vjs_get_mimetype_from_ext($file_ext))); } } //print_r($videos); /* Try to find WebVTT */ $file = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . ".vtt"; file_exists($file) ? $subtitle = embellish_url(get_gallery_home_url() . $file) : ($subtitle = null); /* Thumbnail videojs plugin */ $filematch = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "-th_*"; $matches = glob($filematch); $thumbnails = array(); $sort = array(); // A list of sort columns and their data to pass to array_multisort if (is_array($matches) and !empty($matches)) { foreach ($matches as $filename) { $ext = explode("-th_", $filename); $second = explode(".", $ext[1]); // ./galleries/videos/pwg_representative/trailer_480p-th_0.jpg //echo "$filename second " . $second[0]. "\n"; $thumbnails[] = array('second' => $second[0], 'source' => embellish_url(get_gallery_home_url() . $filename)); $sort['second'][$second[0]] = $second[0]; } } //print_r($thumbnails); // Sort thumbnails by second !empty($sort['second']) and array_multisort($sort['second'], SORT_ASC, $thumbnails); $infos = array_merge(array('Poster' => $poster), array('Videos source' => count($videos)), array('videos' => $videos), array('Thumbnails' => count($thumbnails)), array('thumbnails' => $thumbnails), array('Subtitle' => $subtitle)); //print_r($infos); $template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'SYNC_URL' => $sync_url, 'DELETE_URL' => $delete_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'EXIF' => $exif, 'INFOS' => $infos)); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
/** * Returns html description about recently published elements grouped by post date. * @todo clean up HTML output, currently messy and invalid ! * * @param array $date_detail returned value of get_recent_post_dates() * @return string */ function get_html_description_recent_post_date($date_detail, $auth_key = null) { global $conf; $add_url_params = array(); if (isset($auth_key)) { $add_url_params['auth'] = $auth_key; } $description = '<ul>'; $description .= '<li>' . l10n_dec('%d new photo', '%d new photos', $date_detail['nb_elements']) . ' (' . '<a href="' . add_url_params(make_index_url(array('section' => 'recent_pics')), $add_url_params) . '">' . l10n('Recent photos') . '</a>' . ')' . '</li><br>'; foreach ($date_detail['elements'] as $element) { $tn_src = DerivativeImage::thumb_url($element); $description .= '<a href="' . add_url_params(make_picture_url(array('image_id' => $element['id'], 'image_file' => $element['file'])), $add_url_params) . '"><img src="' . $tn_src . '"></a>'; } $description .= '...<br>'; $description .= '<li>' . l10n_dec('%d album updated', '%d albums updated', $date_detail['nb_cats']) . '</li>'; $description .= '<ul>'; foreach ($date_detail['categories'] as $cat) { $description .= '<li>' . get_cat_display_name_cache($cat['uppercats'], '', false, null, $auth_key) . ' (' . l10n_dec('%d new photo', '%d new photos', $cat['img_count']) . ')' . '</li>'; } $description .= '</ul>'; $description .= '</ul>'; return $description; }
} $local_conf = array(); $local_conf['contextmenu'] = 'false'; $local_conf['control'] = true; $local_conf['img_popup'] = false; $local_conf['popup'] = 2; $local_conf['center_lat'] = $lat; $local_conf['center_lng'] = $lon; $local_conf['zoom'] = $zoom; $local_conf['editor'] = true; $pathurl = get_absolute_root_url() . "i.php?" . $picture['pathurl']; $js_data = array(array($lat, $lon, null, $pathurl, null, null, null, null)); $js = osm_get_js($conf, $local_conf, $js_data); // Fetch the template. global $prefixeTable; // Easy access define('osm_place_table', $prefixeTable . 'osm_places'); // Save location, eg Place $query = ' SELECT id, name, latitude, longitude FROM ' . osm_place_table . ' ;'; $result = pwg_query($query); // JS for the template while ($row = pwg_db_fetch_assoc($result)) { $list_of_places[$row['id']] = [$row['name'], $row['latitude'], $row['longitude']]; $available_places[$row['id']] = $row['name']; } $jsplaces = "\nvar arr_places = " . json_encode($list_of_places) . ";\n"; $template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'OSM_PATH' => embellish_url(get_absolute_root_url() . OSM_PATH), 'OSM_JS' => $js, 'LAT' => $lat, 'LON' => $lon, 'AVAILABLE_PLACES' => $available_places, 'LIST_PLACES' => $jsplaces)); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
/** * API method * Adds a image (simple way) * @param mixed[] $params * @option int[] category * @option string name (optional) * @option string author (optional) * @option string comment (optional) * @option int level * @option string|string[] tags * @option int image_id (optional) */ function ws_images_upload($params, $service) { global $conf; if (get_pwg_token() != $params['pwg_token']) { return new PwgError(403, 'Invalid security token'); } // usleep(100000); // if (!isset($_FILES['image'])) // { // return new PwgError(405, 'The image (file) is missing'); // } // file_put_contents('/tmp/plupload.log', "[".date('c')."] ".__FUNCTION__."\n\n", FILE_APPEND); // file_put_contents('/tmp/plupload.log', '$_FILES = '.var_export($_FILES, true)."\n", FILE_APPEND); // file_put_contents('/tmp/plupload.log', '$_POST = '.var_export($_POST, true)."\n", FILE_APPEND); $upload_dir = $conf['upload_dir'] . '/buffer'; // create the upload directory tree if not exists if (!mkgetdir($upload_dir, MKGETDIR_DEFAULT & ~MKGETDIR_DIE_ON_ERROR)) { return new PwgError(500, 'error during buffer directory creation'); } // Get a file name if (isset($_REQUEST["name"])) { $fileName = $_REQUEST["name"]; } elseif (!empty($_FILES)) { $fileName = $_FILES["file"]["name"]; } else { $fileName = uniqid("file_"); } $filePath = $upload_dir . DIRECTORY_SEPARATOR . $fileName; // Chunking might be enabled $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; // file_put_contents('/tmp/plupload.log', "[".date('c')."] ".__FUNCTION__.', '.$fileName.' '.($chunk+1).'/'.$chunks."\n", FILE_APPEND); // Open temp file if (!($out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb"))) { die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); } if (!empty($_FILES)) { if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) { die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); } // Read binary input stream and append it to temp file if (!($in = @fopen($_FILES["file"]["tmp_name"], "rb"))) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); } } else { if (!($in = @fopen("php://input", "rb"))) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); } } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($out); @fclose($in); // Check if file has been uploaded if (!$chunks || $chunk == $chunks - 1) { // Strip the temp .part suffix off rename("{$filePath}.part", $filePath); include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'; $image_id = add_uploaded_file($filePath, stripslashes($params['name']), $params['category'], $params['level'], null); $query = ' SELECT id, name, representative_ext, path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $image_infos = pwg_db_fetch_assoc(pwg_query($query)); $query = ' SELECT COUNT(*) AS nb_photos FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE category_id = ' . $params['category'][0] . ' ;'; $category_infos = pwg_db_fetch_assoc(pwg_query($query)); $category_name = get_cat_display_name_from_id($params['category'][0], null); return array('image_id' => $image_id, 'src' => DerivativeImage::thumb_url($image_infos), 'name' => $image_infos['name'], 'category' => array('id' => $params['category'][0], 'nb_photos' => $category_infos['nb_photos'], 'label' => $category_name)); } }
function add_uploaded_file($source_filepath, $original_filename = null, $categories = null, $level = null, $image_id = null, $original_md5sum = null) { // 1) move uploaded file to upload/2010/01/22/20100122003814-449ada00.jpg // // 2) keep/resize original // // 3) register in database // TODO // * check md5sum (already exists?) global $conf, $user; if (isset($original_md5sum)) { $md5sum = $original_md5sum; } else { $md5sum = md5_file($source_filepath); } $file_path = null; $is_tiff = false; if (isset($image_id)) { // this photo already exists, we update it $query = ' SELECT path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $file_path = $row['path']; } if (!isset($file_path)) { die('[' . __FUNCTION__ . '] this photo does not exist in the database'); } // delete all physical files related to the photo (thumbnail, web site, HD) delete_element_files(array($image_id)); } else { // this photo is new // current date list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); list($year, $month, $day) = preg_split('/[^\\d]/', $dbnow, 4); // upload directory hierarchy $upload_dir = sprintf(PHPWG_ROOT_PATH . $conf['upload_dir'] . '/%s/%s/%s', $year, $month, $day); // compute file path $date_string = preg_replace('/[^\\d]/', '', $dbnow); $random_string = substr($md5sum, 0, 8); $filename_wo_ext = $date_string . '-' . $random_string; $file_path = $upload_dir . '/' . $filename_wo_ext . '.'; list($width, $height, $type) = getimagesize($source_filepath); if (IMAGETYPE_PNG == $type) { $file_path .= 'png'; } elseif (IMAGETYPE_GIF == $type) { $file_path .= 'gif'; } elseif (IMAGETYPE_TIFF_MM == $type or IMAGETYPE_TIFF_II == $type) { $is_tiff = true; $file_path .= 'tif'; } elseif (IMAGETYPE_JPEG == $type) { $file_path .= 'jpg'; } elseif (isset($conf['upload_form_all_types']) and $conf['upload_form_all_types']) { $original_extension = strtolower(get_extension($original_filename)); if (in_array($original_extension, $conf['file_ext'])) { $file_path .= $original_extension; } else { die('unexpected file type'); } } else { die('forbidden file type'); } prepare_directory($upload_dir); } if (is_uploaded_file($source_filepath)) { move_uploaded_file($source_filepath, $file_path); } else { rename($source_filepath, $file_path); } @chmod($file_path, 0644); if ($is_tiff and pwg_image::get_library() == 'ext_imagick') { // move the uploaded file to pwg_representative sub-directory $representative_file_path = dirname($file_path) . '/pwg_representative/'; $representative_file_path .= get_filename_wo_extension(basename($file_path)) . '.'; $representative_ext = $conf['tiff_representative_ext']; $representative_file_path .= $representative_ext; prepare_directory(dirname($representative_file_path)); $exec = $conf['ext_imagick_dir'] . 'convert'; if ('jpg' == $conf['tiff_representative_ext']) { $exec .= ' -quality 98'; } $exec .= ' "' . realpath($file_path) . '"'; $dest = pathinfo($representative_file_path); $exec .= ' "' . realpath($dest['dirname']) . '/' . $dest['basename'] . '"'; $exec .= ' 2>&1'; @exec($exec, $returnarray); // sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg // (thumbnail). I don't know how to avoid it. $representative_file_abspath = realpath($dest['dirname']) . '/' . $dest['basename']; if (!file_exists($representative_file_abspath)) { $first_file_abspath = preg_replace('/\\.' . $representative_ext . '$/', '-0.' . $representative_ext, $representative_file_abspath); if (file_exists($first_file_abspath)) { rename($first_file_abspath, $representative_file_abspath); } } } // // generate pwg_representative in case of video // $ffmpeg_video_exts = array('wmv', 'mov', 'mkv', 'mp4', 'mpg', 'flv', 'asf', 'xvid', 'divx', 'mpeg', 'avi', 'rm'); if (isset($original_extension) and in_array($original_extension, $ffmpeg_video_exts)) { $representative_file_path = dirname($file_path) . '/pwg_representative/'; $representative_file_path .= get_filename_wo_extension(basename($file_path)) . '.'; $representative_ext = 'jpg'; $representative_file_path .= $representative_ext; prepare_directory(dirname($representative_file_path)); $second = 1; $ffmpeg = $conf['ffmpeg_dir'] . 'ffmpeg'; $ffmpeg .= ' -i "' . $file_path . '"'; $ffmpeg .= ' -an -ss ' . $second; $ffmpeg .= ' -t 1 -r 1 -y -vcodec mjpeg -f mjpeg'; $ffmpeg .= ' "' . $representative_file_path . '"'; // file_put_contents('/tmp/ffmpeg.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.$ffmpeg."\n", FILE_APPEND); @exec($ffmpeg); if (!file_exists($representative_file_path)) { $representative_ext = null; } } if (isset($original_extension) and 'pdf' == $original_extension and pwg_image::get_library() == 'ext_imagick') { $representative_file_path = dirname($file_path) . '/pwg_representative/'; $representative_file_path .= get_filename_wo_extension(basename($file_path)) . '.'; $representative_ext = 'jpg'; $representative_file_path .= $representative_ext; prepare_directory(dirname($representative_file_path)); $exec = $conf['ext_imagick_dir'] . 'convert'; $exec .= ' -quality 98'; $exec .= ' "' . realpath($file_path) . '"[0]'; $dest = pathinfo($representative_file_path); $exec .= ' "' . realpath($dest['dirname']) . '/' . $dest['basename'] . '"'; $exec .= ' 2>&1'; @exec($exec, $returnarray); } if (pwg_image::get_library() != 'gd') { if ($conf['original_resize']) { $need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']); if ($need_resize) { $img = new pwg_image($file_path); $img->pwg_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight'], $conf['original_resize_quality'], $conf['upload_form_automatic_rotation'], false); $img->destroy(); } } } // we need to save the rotation angle in the database to compute // width/height of "multisizes" $rotation_angle = pwg_image::get_rotation_angle($file_path); $rotation = pwg_image::get_rotation_code_from_angle($rotation_angle); $file_infos = pwg_image_infos($file_path); if (isset($image_id)) { $update = array('file' => pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)), 'filesize' => $file_infos['filesize'], 'width' => $file_infos['width'], 'height' => $file_infos['height'], 'md5sum' => $md5sum, 'added_by' => $user['id'], 'rotation' => $rotation); if (isset($level)) { $update['level'] = $level; } single_update(IMAGES_TABLE, $update, array('id' => $image_id)); } else { // database registration $file = pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)); $insert = array('file' => $file, 'name' => get_name_from_file($file), 'date_available' => $dbnow, 'path' => preg_replace('#^' . preg_quote(PHPWG_ROOT_PATH) . '#', '', $file_path), 'filesize' => $file_infos['filesize'], 'width' => $file_infos['width'], 'height' => $file_infos['height'], 'md5sum' => $md5sum, 'added_by' => $user['id'], 'rotation' => $rotation); if (isset($level)) { $insert['level'] = $level; } if (isset($representative_ext)) { $insert['representative_ext'] = $representative_ext; } single_insert(IMAGES_TABLE, $insert); $image_id = pwg_db_insert_id(IMAGES_TABLE); } if (isset($categories) and count($categories) > 0) { associate_images_to_categories(array($image_id), $categories); } // update metadata from the uploaded file (exif/iptc) if ($conf['use_exif'] and !function_exists('read_exif_data')) { $conf['use_exif'] = false; } sync_metadata(array($image_id)); invalidate_user_cache(); // cache thumbnail $query = ' SELECT id, path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $image_infos = pwg_db_fetch_assoc(pwg_query($query)); set_make_full_url(); // in case we are on uploadify.php, we have to replace the false path $thumb_url = preg_replace('#admin/include/i#', 'i', DerivativeImage::thumb_url($image_infos)); unset_make_full_url(); fetchRemote($thumb_url, $dest); return $image_id; }
i.path, i.file, i.representative_ext, i.rating_score, r.element_id ORDER BY ' . $available_order_by[$order_by_index][1] . ' LIMIT ' . $elements_per_page . ' OFFSET ' . $start . ' ;'; $images = array(); $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $images[] = $row; } $template->assign('images', array()); foreach ($images as $image) { $thumbnail_src = DerivativeImage::thumb_url($image); $image_url = get_root_url() . 'admin.php?page=photo-' . $image['id']; $query = 'SELECT * FROM ' . RATE_TABLE . ' AS r WHERE r.element_id=' . $image['id'] . ' ORDER BY date DESC;'; $result = pwg_query($query); $nb_rates = pwg_db_num_rows($result); $tpl_image = array('id' => $image['id'], 'U_THUMB' => $thumbnail_src, 'U_URL' => $image_url, 'SCORE_RATE' => $image['score'], 'AVG_RATE' => $image['avg_rates'], 'SUM_RATE' => $image['sum_rates'], 'NB_RATES' => (int) $image['nb_rates'], 'NB_RATES_TOTAL' => (int) $nb_rates, 'FILE' => $image['file'], 'rates' => array()); while ($row = pwg_db_fetch_assoc($result)) { if (isset($users[$row['user_id']])) { $user_rate = $users[$row['user_id']]; } else { $user_rate = '? ' . $row['user_id']; } if (strlen($row['anonymous_id']) > 0) {
function ws_pshare_share_create($params, &$service) { global $conf, $user; if (!pshare_is_active()) { return new PwgError(401, "permission denied"); } $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = ' . $params['image_id'] . ' ;'; $images = query2array($query); if (count($images) == 0) { return new PwgError(404, "image not found"); } $image = $images[0]; if (!pshare_is_photo_visible($params['image_id'])) { return new PwgError(401, "permissions denied"); } if (!email_check_format($params['email'])) { return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid email address')); } // TODO check the expires_in is in the defined list $query = ' SELECT NOW(), ADDDATE(NOW(), INTERVAL ' . $params['expires_in'] . ' DAY) ;'; list($now, $expire) = pwg_db_fetch_row(pwg_query($query)); $key_uuid = pshare_get_key(); single_insert(PSHARE_KEYS_TABLE, array('uuid' => $key_uuid, 'user_id' => $user['id'], 'image_id' => $params['image_id'], 'sent_to' => $params['email'], 'created_on' => $now, 'duration' => $params['expires_in'], 'expire_on' => $expire)); $query = ' SELECT * FROM ' . PSHARE_KEYS_TABLE . ' WHERE uuid = \'' . $key_uuid . '\' ;'; $shares = query2array($query); if (count($shares) == 0) { return new PwgError(500, "share not created"); } $share = $shares[0]; // // Send the email // include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; // force $conf['derivative_url_style'] to 2 (script) to make sure we // will use i.php?/upload and not _data/i/upload because you don't // know when the cache will be flushed $previous_derivative_url_style = $conf['derivative_url_style']; $conf['derivative_url_style'] = 2; $thumb_url = DerivativeImage::thumb_url(array('id' => $image['id'], 'path' => $image['path'])); // restore configuration setting $conf['derivative_url_style'] = $previous_derivative_url_style; $link = get_absolute_root_url() . 'index.php?/pshare/' . $share['uuid']; $content = '<p style="text-align:center">'; $content .= l10n('%s has shared a photo with you', $user['username']); $content .= '<br><br><a href="' . $link . '"><img src="' . $thumb_url . '"></a>'; $content .= '<br><br><a href="' . $link . '">' . l10n('clic to view') . '</a>'; $content .= '</p>'; $subject = l10n('Photo shared'); pwg_mail($params['email'], array('subject' => '[' . $conf['gallery_title'] . '] ' . $subject, 'mail_title' => $conf['gallery_title'], 'mail_subtitle' => $subject, 'content' => $content, 'content_format' => 'text/html')); return array('message' => l10n('Email sent to %s', $share['sent_to'])); }
/* Update the database - No action done on the video */ $rotation_code = pwg_image::get_rotation_code_from_angle($_POST['angle']); $query = "UPDATE " . IMAGES_TABLE . " SET rotation='" . $rotation_code . "', `date_metadata_update`=CURDATE() WHERE `id`=" . $_GET['image_id'] . ";"; pwg_query($query); /* Retrieve direct information about picture */ $query = "SELECT id,path,representative_ext FROM " . IMAGES_TABLE . " WHERE " . SQL_VIDEOS . " AND id = " . $_GET['image_id'] . ";"; $row = pwg_db_fetch_assoc(pwg_query($query)); /* Delete previous derivatives */ delete_element_derivatives($row); array_push($page['infos'], l10n('The photo was updated')); } // +-----------------------------------------------------------------------+ // | Tabs | // +-----------------------------------------------------------------------+ $tabsheet = new tabsheet(); $tabsheet->set_id('photo'); $tabsheet->select('rotate'); $tabsheet->assign(); // +-----------------------------------------------------------------------+ // | template init | // +-----------------------------------------------------------------------+ $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin_rotate.tpl')); // Retrieve direct information about picture $query = "SELECT * FROM " . IMAGES_TABLE . " WHERE " . SQL_VIDEOS . " AND id = " . $_GET['image_id'] . ";"; $row = pwg_db_fetch_assoc(pwg_query($query)); $angles = array(array('value' => 270, 'name' => l10n('90° right')), array('value' => 90, 'name' => l10n('90° left')), array('value' => 180, 'name' => l10n('180°'))); $template->assign(array('F_ACTION' => $self_url, 'TN_SRC' => DerivativeImage::thumb_url($row), 'TITLE' => render_element_name($row), 'angles' => $angles, 'angle_selected' => pwg_image::get_rotation_angle_from_code($row['rotation']), 'library' => pwg_image::get_library(), 'PWG_TOKEN' => get_pwg_token())); // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
function add_uploaded_file($source_filepath, $original_filename = null, $categories = null, $level = null, $image_id = null, $original_md5sum = null) { // 1) move uploaded file to upload/2010/01/22/20100122003814-449ada00.jpg // // 2) keep/resize original // // 3) register in database // TODO // * check md5sum (already exists?) global $conf, $user; if (isset($original_md5sum)) { $md5sum = $original_md5sum; } else { $md5sum = md5_file($source_filepath); } $file_path = null; $is_tiff = false; if (isset($image_id)) { // this photo already exists, we update it $query = ' SELECT path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $file_path = $row['path']; } if (!isset($file_path)) { die('[' . __FUNCTION__ . '] this photo does not exist in the database'); } // delete all physical files related to the photo (thumbnail, web site, HD) delete_element_files(array($image_id)); } else { // this photo is new // current date list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); list($year, $month, $day) = preg_split('/[^\\d]/', $dbnow, 4); // upload directory hierarchy $upload_dir = sprintf(PHPWG_ROOT_PATH . $conf['upload_dir'] . '/%s/%s/%s', $year, $month, $day); // compute file path $date_string = preg_replace('/[^\\d]/', '', $dbnow); $random_string = substr($md5sum, 0, 8); $filename_wo_ext = $date_string . '-' . $random_string; $file_path = $upload_dir . '/' . $filename_wo_ext . '.'; list($width, $height, $type) = getimagesize($source_filepath); if (IMAGETYPE_PNG == $type) { $file_path .= 'png'; } elseif (IMAGETYPE_GIF == $type) { $file_path .= 'gif'; } elseif (IMAGETYPE_TIFF_MM == $type or IMAGETYPE_TIFF_II == $type) { $is_tiff = true; $file_path .= 'tif'; } elseif (IMAGETYPE_JPEG == $type) { $file_path .= 'jpg'; } elseif (isset($conf['upload_form_all_types']) and $conf['upload_form_all_types']) { $original_extension = strtolower(get_extension($original_filename)); if (in_array($original_extension, $conf['file_ext'])) { $file_path .= $original_extension; } else { die('unexpected file type'); } } else { die('forbidden file type'); } prepare_directory($upload_dir); } if (is_uploaded_file($source_filepath)) { move_uploaded_file($source_filepath, $file_path); } else { rename($source_filepath, $file_path); } @chmod($file_path, 0644); // handle the uploaded file type by potentially making a // pwg_representative file. $representative_ext = trigger_change('upload_file', null, $file_path); global $logger; $logger->info("Handling " . (string) $file_path . " got " . (string) $representative_ext); // If it is set to either true (the file didn't need a // representative generated) or false (the generation of the // representative failed), set it to null because we have no // representative file. if (is_bool($representative_ext)) { $representative_ext = null; } if (pwg_image::get_library() != 'gd') { if ($conf['original_resize']) { $need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']); if ($need_resize) { $img = new pwg_image($file_path); $img->pwg_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight'], $conf['original_resize_quality'], $conf['upload_form_automatic_rotation'], false); $img->destroy(); } } } // we need to save the rotation angle in the database to compute // width/height of "multisizes" $rotation_angle = pwg_image::get_rotation_angle($file_path); $rotation = pwg_image::get_rotation_code_from_angle($rotation_angle); $file_infos = pwg_image_infos($file_path); if (isset($image_id)) { $update = array('file' => pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)), 'filesize' => $file_infos['filesize'], 'width' => $file_infos['width'], 'height' => $file_infos['height'], 'md5sum' => $md5sum, 'added_by' => $user['id'], 'rotation' => $rotation); if (isset($level)) { $update['level'] = $level; } single_update(IMAGES_TABLE, $update, array('id' => $image_id)); } else { // database registration $file = pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)); $insert = array('file' => $file, 'name' => get_name_from_file($file), 'date_available' => $dbnow, 'path' => preg_replace('#^' . preg_quote(PHPWG_ROOT_PATH) . '#', '', $file_path), 'filesize' => $file_infos['filesize'], 'width' => $file_infos['width'], 'height' => $file_infos['height'], 'md5sum' => $md5sum, 'added_by' => $user['id'], 'rotation' => $rotation); if (isset($level)) { $insert['level'] = $level; } if (isset($representative_ext)) { $insert['representative_ext'] = $representative_ext; } single_insert(IMAGES_TABLE, $insert); $image_id = pwg_db_insert_id(IMAGES_TABLE); } if (isset($categories) and count($categories) > 0) { associate_images_to_categories(array($image_id), $categories); } // update metadata from the uploaded file (exif/iptc) if ($conf['use_exif'] and !function_exists('read_exif_data')) { $conf['use_exif'] = false; } sync_metadata(array($image_id)); invalidate_user_cache(); // cache thumbnail $query = ' SELECT id, path FROM ' . IMAGES_TABLE . ' WHERE id = ' . $image_id . ' ;'; $image_infos = pwg_db_fetch_assoc(pwg_query($query)); set_make_full_url(); // in case we are on uploadify.php, we have to replace the false path $thumb_url = preg_replace('#admin/include/i#', 'i', DerivativeImage::thumb_url($image_infos)); unset_make_full_url(); fetchRemote($thumb_url, $dest); return $image_id; }