1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
check_status(ACCESS_ADMINISTRATOR);
// +-----------------------------------------------------------------------+
// | Load configuration |
// +-----------------------------------------------------------------------+
$upload_form_config = get_upload_form_config();
$form_values = array();
foreach ($upload_form_config as $param_shortname => $param)
{
$param_name = 'upload_form_'.$param_shortname;
$form_values[$param_shortname] = $conf[$param_name];
}
// +-----------------------------------------------------------------------+
// | search pictures without thumbnails |
// +-----------------------------------------------------------------------+
$wo_thumbnails = array();
// what is the directory to search in ?
$query = '
SELECT galleries_url FROM '.SITES_TABLE.'
WHERE galleries_url NOT LIKE \'http://%\'
;';
$result = pwg_query($query);
while ( $row=pwg_db_fetch_assoc($result) )
{
$basedir = preg_replace('#/*$#', '', $row['galleries_url']);
$fs = get_fs($basedir);
// because isset is one hundred time faster than in_array
$fs['thumbnails'] = array_flip($fs['thumbnails']);
foreach ($fs['elements'] as $path)
{
// only pictures need thumbnails
if (in_array(get_extension($path), $conf['picture_ext']))
{
$dirname = dirname($path);
$filename = basename($path);
// only files matching the authorized filename pattern can be considered
// as "without thumbnail"
if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
{
continue;
}
// searching the element
$filename_wo_ext = get_filename_wo_extension($filename);
$tn_ext = '';
$base_test = $dirname.'/'.$conf['dir_thumbnail'].'/';
$base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.';
foreach ($conf['picture_ext'] as $ext)
{
if (isset($fs['thumbnails'][$base_test.$ext]))
{
$tn_ext = $ext;
break;
}
}
if (empty($tn_ext))
{
array_push($wo_thumbnails, $path);
}
}
} // next element
} // next site id
// +-----------------------------------------------------------------------+
// | form & pictures without thumbnails display |
// +-----------------------------------------------------------------------+
$template->set_filenames( array('thumbnail'=>'thumbnail.tpl') );
if (count($wo_thumbnails) > 0)
{
foreach ($wo_thumbnails as $path)
{
list($width, $height) = getimagesize($path);
$size = floor(filesize($path) / 1024).' KB';
$template->append(
'remainings',
array(
'PATH'=>$path,
'FILESIZE_IMG'=>$size,
'WIDTH_IMG'=>$width,
'HEIGHT_IMG'=>$height,
)
);
}
}
foreach (array_keys($upload_form_config) as $field)
{
if (is_bool($upload_form_config[$field]['default']))
{
$form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
}
}
$template->assign(
array(
'F_ACTION' => get_root_url().'admin.php?page=thumbnail',
'values' => $form_values,
'TOTAL_NB_REMAINING' => count($wo_thumbnails),
'U_HELP' => get_root_url().'admin/popuphelp.php?page=thumbnail',
)
);
$template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail');
?>
|