/** * Deletes all files (on disk) related to given image ids. * * @param int[] $ids * @return 0|int[] image ids where files were successfully deleted */ function delete_element_files($ids) { global $conf; if (count($ids) == 0) { return 0; } $new_ids = array(); $query = ' SELECT id, path, representative_ext FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { if (url_is_remote($row['path'])) { continue; } $files = array(); $files[] = get_element_path($row); if (!empty($row['representative_ext'])) { $files[] = original_to_representative($files[0], $row['representative_ext']); } $ok = true; if (!isset($conf['never_delete_originals'])) { foreach ($files as $path) { if (is_file($path) and !unlink($path)) { $ok = false; trigger_error('"' . $path . '" cannot be removed', E_USER_WARNING); break; } } } if ($ok) { delete_element_derivatives($row); $new_ids[] = $row['id']; } else { break; } } return $new_ids; }
} } else { $page['errors'][] = l10n('You need to confirm deletion'); } } else { if ('metadata' == $action) { sync_metadata($collection); $page['infos'][] = l10n('Metadata synchronized from file'); } else { if ('delete_derivatives' == $action && !empty($_POST['del_derivatives_type'])) { $query = 'SELECT path,representative_ext FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $collection) . ')'; $result = pwg_query($query); while ($info = pwg_db_fetch_assoc($result)) { foreach ($_POST['del_derivatives_type'] as $type) { delete_element_derivatives($info, $type); } } } else { if ('generate_derivatives' == $action) { if ($_POST['regenerateSuccess'] != '0') { $page['infos'][] = l10n('%s photos have been regenerated', $_POST['regenerateSuccess']); } if ($_POST['regenerateError'] != '0') { $page['warnings'][] = l10n('%s photos can not be regenerated', $_POST['regenerateError']); } } } } } }
} else { $coi = fraction_to_char($_POST['l']) . fraction_to_char($_POST['t']) . fraction_to_char($_POST['r']) . fraction_to_char($_POST['b']); $query .= ' SET coi=\'' . $coi . '\''; } $query .= ' WHERE id=' . $_GET['image_id']; pwg_query($query); } $query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id=' . $_GET['image_id']; $row = pwg_db_fetch_assoc(pwg_query($query)); if (isset($_POST['submit'])) { foreach (ImageStdParams::get_defined_type_map() as $params) { if ($params->sizing->max_crop != 0) { delete_element_derivatives($row, $params->type); } } delete_element_derivatives($row, IMG_CUSTOM); $uid = '&b=' . time(); $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true; if ($conf['derivative_url_style'] == 1) { $conf['derivative_url_style'] = 0; //auto } } else { $uid = ''; } $tpl_var = array('TITLE' => render_element_name($row), 'ALT' => $row['file'], 'U_IMG' => DerivativeImage::url(IMG_LARGE, $row)); if (!empty($row['coi'])) { $tpl_var['coi'] = array('l' => char_to_fraction($row['coi'][0]), 't' => char_to_fraction($row['coi'][1]), 'r' => char_to_fraction($row['coi'][2]), 'b' => char_to_fraction($row['coi'][3])); } foreach (ImageStdParams::get_defined_type_map() as $params) { if ($params->sizing->max_crop != 0) {
$admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $_GET['image_id']; $self_url = get_root_url() . 'admin.php?page=plugin&section=piwigo-videojs/admin/admin_rotate.php&image_id=' . $_GET['image_id']; if (isset($_POST['videojs_rotate']) and isset($_POST['angle'])) { check_pwg_token(); if (!empty($_POST['angle']) and strlen($_POST['angle']) != 0 and !is_numeric($_POST['angle'])) { die('Invalid data!'); } /* 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'] . ";";