set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/thumbnailer_admin.tpl') ); // +-----------------------------------------------------------------------+ // | search pictures without thumbnails | // +-----------------------------------------------------------------------+ $wo_thumbnails = array(); $thumbnalized = 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=mysql_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.'/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_url = get_root_url().'admin.php?page=thumbnail'; $gd = !empty($_POST['gd']) ? $_POST['gd'] : 2; $width = !empty($_POST['width']) ? $_POST['width'] : $conf['tn_width']; $height = !empty($_POST['height']) ? $_POST['height'] : $conf['tn_height']; $n = !empty($_POST['n']) ? $_POST['n'] : 5; $template->assign( 'params', array( 'F_ACTION'=> $form_url, 'GD_SELECTED' => $gd, 'N_SELECTED' => $n, 'WIDTH_TN'=>$width, 'HEIGHT_TN'=>$height, )); $template->assign( 'TOTAL_NB_REMAINING', count($wo_thumbnails)); $template->assign( 'plugin', array( 'path' => AT_PATH )); foreach ($wo_thumbnails as $path) { list($width, $height) = getimagesize($path); $size = floor(filesize($path) / 1024).' KB'; $template->append( 'wo_thumbnails', array( 'PATH'=>$path, 'FILESIZE_IMG'=>$size, 'WIDTH_IMG'=>$width, 'HEIGHT_IMG'=>$height, )); } $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); ?>