[2] | 1 | <?php |
---|
[362] | 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 23 | |
---|
| 24 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[10570] | 25 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); |
---|
[1072] | 26 | |
---|
[10570] | 27 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 28 | |
---|
[1072] | 29 | // +-----------------------------------------------------------------------+ |
---|
[10570] | 30 | // | Load configuration | |
---|
[1072] | 31 | // +-----------------------------------------------------------------------+ |
---|
[10570] | 32 | $upload_form_config = get_upload_form_config(); |
---|
[2] | 33 | |
---|
[10570] | 34 | $form_values = array(); |
---|
[5957] | 35 | |
---|
[10570] | 36 | foreach ($upload_form_config as $param_shortname => $param) |
---|
[2428] | 37 | { |
---|
[10570] | 38 | $param_name = 'upload_form_'.$param_shortname; |
---|
| 39 | $form_values[$param_shortname] = $conf[$param_name]; |
---|
[2428] | 40 | } |
---|
| 41 | |
---|
[695] | 42 | // +-----------------------------------------------------------------------+ |
---|
| 43 | // | search pictures without thumbnails | |
---|
| 44 | // +-----------------------------------------------------------------------+ |
---|
| 45 | $wo_thumbnails = array(); |
---|
[393] | 46 | |
---|
[695] | 47 | // what is the directory to search in ? |
---|
| 48 | $query = ' |
---|
[1814] | 49 | SELECT galleries_url FROM '.SITES_TABLE.' |
---|
[6550] | 50 | WHERE galleries_url NOT LIKE \'http://%\' |
---|
[695] | 51 | ;'; |
---|
[1814] | 52 | $result = pwg_query($query); |
---|
[4325] | 53 | while ( $row=pwg_db_fetch_assoc($result) ) |
---|
[1814] | 54 | { |
---|
| 55 | $basedir = preg_replace('#/*$#', '', $row['galleries_url']); |
---|
| 56 | $fs = get_fs($basedir); |
---|
[695] | 57 | |
---|
[1814] | 58 | // because isset is one hundred time faster than in_array |
---|
| 59 | $fs['thumbnails'] = array_flip($fs['thumbnails']); |
---|
[695] | 60 | |
---|
[1814] | 61 | foreach ($fs['elements'] as $path) |
---|
[2] | 62 | { |
---|
[1814] | 63 | // only pictures need thumbnails |
---|
| 64 | if (in_array(get_extension($path), $conf['picture_ext'])) |
---|
[703] | 65 | { |
---|
[1814] | 66 | $dirname = dirname($path); |
---|
| 67 | $filename = basename($path); |
---|
| 68 | |
---|
| 69 | // only files matching the authorized filename pattern can be considered |
---|
| 70 | // as "without thumbnail" |
---|
| 71 | if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename)) |
---|
[695] | 72 | { |
---|
[1814] | 73 | continue; |
---|
[695] | 74 | } |
---|
[1814] | 75 | |
---|
| 76 | // searching the element |
---|
| 77 | $filename_wo_ext = get_filename_wo_extension($filename); |
---|
| 78 | $tn_ext = ''; |
---|
[3720] | 79 | $base_test = $dirname.'/'.$conf['dir_thumbnail'].'/'; |
---|
[1814] | 80 | $base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.'; |
---|
| 81 | foreach ($conf['picture_ext'] as $ext) |
---|
| 82 | { |
---|
| 83 | if (isset($fs['thumbnails'][$base_test.$ext])) |
---|
| 84 | { |
---|
| 85 | $tn_ext = $ext; |
---|
| 86 | break; |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | if (empty($tn_ext)) |
---|
| 91 | { |
---|
| 92 | array_push($wo_thumbnails, $path); |
---|
| 93 | } |
---|
[695] | 94 | } |
---|
[1814] | 95 | } // next element |
---|
| 96 | } // next site id |
---|
[695] | 97 | |
---|
| 98 | // +-----------------------------------------------------------------------+ |
---|
| 99 | // | form & pictures without thumbnails display | |
---|
| 100 | // +-----------------------------------------------------------------------+ |
---|
[10571] | 101 | $template->set_filenames( array('thumbnail'=>'thumbnail.tpl') ); |
---|
| 102 | |
---|
[10570] | 103 | if (count($wo_thumbnails) > 0) |
---|
[695] | 104 | { |
---|
[10570] | 105 | foreach ($wo_thumbnails as $path) |
---|
[2] | 106 | { |
---|
[695] | 107 | list($width, $height) = getimagesize($path); |
---|
| 108 | $size = floor(filesize($path) / 1024).' KB'; |
---|
| 109 | |
---|
[2250] | 110 | $template->append( |
---|
| 111 | 'remainings', |
---|
[665] | 112 | array( |
---|
[695] | 113 | 'PATH'=>$path, |
---|
| 114 | 'FILESIZE_IMG'=>$size, |
---|
| 115 | 'WIDTH_IMG'=>$width, |
---|
| 116 | 'HEIGHT_IMG'=>$height, |
---|
[10571] | 117 | ) |
---|
| 118 | ); |
---|
[665] | 119 | } |
---|
[2] | 120 | } |
---|
[2250] | 121 | |
---|
[10570] | 122 | foreach (array_keys($upload_form_config) as $field) |
---|
| 123 | { |
---|
| 124 | if (is_bool($upload_form_config[$field]['default'])) |
---|
| 125 | { |
---|
| 126 | $form_values[$field] = $form_values[$field] ? 'checked="checked"' : ''; |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | $template->assign( |
---|
| 131 | array( |
---|
| 132 | 'F_ACTION' => get_root_url().'admin.php?page=thumbnail', |
---|
| 133 | 'values' => $form_values, |
---|
| 134 | 'TOTAL_NB_REMAINING' => count($wo_thumbnails), |
---|
[10571] | 135 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=thumbnail', |
---|
[10570] | 136 | ) |
---|
| 137 | ); |
---|
| 138 | |
---|
[393] | 139 | $template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail'); |
---|
[362] | 140 | ?> |
---|