[13038] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | Piwigo - a PHP based photo gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | |
---|
| 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
| 23 | |
---|
| 24 | if(!defined("PHPWG_ROOT_PATH")) |
---|
| 25 | { |
---|
| 26 | die('Hacking attempt!'); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | // +-----------------------------------------------------------------------+ |
---|
| 30 | // | Check Access and exit when user status is not ok | |
---|
| 31 | // +-----------------------------------------------------------------------+ |
---|
| 32 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 33 | |
---|
| 34 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
| 35 | |
---|
| 36 | if (isset($_POST['submit'])) |
---|
| 37 | { |
---|
| 38 | $query = 'UPDATE '.IMAGES_TABLE; |
---|
| 39 | if (strlen($_POST['l'])==0) |
---|
| 40 | { |
---|
| 41 | $query .= ' SET coi=NULL'; |
---|
| 42 | } |
---|
| 43 | else |
---|
| 44 | { |
---|
| 45 | $coi = fraction_to_char($_POST['l']) |
---|
| 46 | .fraction_to_char($_POST['t']) |
---|
| 47 | .fraction_to_char($_POST['r']) |
---|
| 48 | .fraction_to_char($_POST['b']); |
---|
| 49 | $query .= ' SET coi=\''.$coi.'\''; |
---|
| 50 | } |
---|
| 51 | $query .= ' WHERE id='.$_GET['image_id']; |
---|
| 52 | pwg_query($query); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$_GET['image_id']; |
---|
| 56 | $row = pwg_db_fetch_assoc( pwg_query($query) ); |
---|
| 57 | |
---|
| 58 | if (isset($_POST['submit'])) |
---|
| 59 | { |
---|
[13052] | 60 | foreach(ImageStdParams::get_defined_type_map() as $params) |
---|
| 61 | { |
---|
| 62 | if ($params->sizing->max_crop != 0) |
---|
| 63 | { |
---|
| 64 | delete_element_derivatives($row, $params->type); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | delete_element_derivatives($row, IMG_CUSTOM); |
---|
| 68 | $uid = '&b='.time(); |
---|
| 69 | $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true; |
---|
| 70 | if ($conf['derivative_url_style']==1) |
---|
| 71 | { |
---|
| 72 | $conf['derivative_url_style']=0; //auto |
---|
| 73 | } |
---|
[13038] | 74 | } |
---|
[13052] | 75 | else |
---|
| 76 | { |
---|
| 77 | $uid = ''; |
---|
| 78 | } |
---|
[13038] | 79 | |
---|
| 80 | $tpl_var = array( |
---|
[13077] | 81 | 'TITLE' => render_element_name($row), |
---|
[13038] | 82 | 'ALT' => $row['file'], |
---|
| 83 | 'U_IMG' => DerivativeImage::url(IMG_LARGE, $row), |
---|
| 84 | ); |
---|
| 85 | |
---|
| 86 | if (!empty($row['coi'])) |
---|
| 87 | { |
---|
| 88 | $tpl_var['coi'] = array( |
---|
| 89 | 'l'=> char_to_fraction($row['coi'][0]), |
---|
| 90 | 't'=> char_to_fraction($row['coi'][1]), |
---|
| 91 | 'r'=> char_to_fraction($row['coi'][2]), |
---|
| 92 | 'b'=> char_to_fraction($row['coi'][3]), |
---|
| 93 | ); |
---|
| 94 | } |
---|
| 95 | |
---|
[13052] | 96 | foreach(ImageStdParams::get_defined_type_map() as $params) |
---|
[13038] | 97 | { |
---|
[13052] | 98 | if ($params->sizing->max_crop != 0) |
---|
| 99 | { |
---|
| 100 | $derivative = new DerivativeImage($params, new SrcImage($row) ); |
---|
| 101 | $template->append( 'cropped_derivatives', array( |
---|
| 102 | 'U_IMG' => $derivative->get_url().$uid, |
---|
| 103 | 'HTM_SIZE' => $derivative->get_size_htm(), |
---|
| 104 | ) ); |
---|
| 105 | } |
---|
[13038] | 106 | } |
---|
| 107 | |
---|
[13052] | 108 | |
---|
[13038] | 109 | $template->assign($tpl_var); |
---|
| 110 | $template->set_filename('picture_coi', 'picture_coi.tpl'); |
---|
| 111 | |
---|
| 112 | $template->assign_var_from_handle('ADMIN_CONTENT', 'picture_coi'); |
---|
| 113 | ?> |
---|