GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — projectsend/thumbnails-regenerate.php at develop · mhpcc/projectsend Expand file tree/ Copy paththumbnails-regenerate.phpMore file actions 258 lines (234 loc) · 14 KB / Copy paththumbnails-regenerate.phpFile metadata and controls258 lines (234 loc) · 14 KB 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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 <?php /** * Regenerate thumbnails for uploaded images */ require_once 'bootstrap.php'; check_access_enhanced(['edit_settings']); $page_title = __('Regenerate Thumbnails', 'cftp_admin'); $page_id = 'thumbnails_regenerate'; $active_nav = 'tools'; include_once ADMIN_VIEWS_DIR . DS . 'header.php'; global $flash; // Define convertible image formats $image_formats = ['png', 'jpg', 'jpeg', 'gif']; // Get statistics for all convertible images $all_images_stats = count_uploaded_files($image_formats); // Get statistics per format - use the by_format data from the all_images_stats for efficiency // But also ensure we have a count for each format even if it's 0 $format_stats = []; foreach ($image_formats as $format) { $format_stats[$format] = isset($all_images_stats['by_format'][$format]) ? $all_images_stats['by_format'][$format] : 0; } // Get date range for uploaded files global $dbh; $date_range_query = "SELECT MIN(DATE(timestamp)) as min_date, MAX(DATE(timestamp)) as max_date FROM " . TABLE_FILES . " WHERE 1=1"; $date_range_sql = $dbh->prepare($date_range_query); $date_range_sql->execute(); $date_range = $date_range_sql->fetch(PDO::FETCH_ASSOC); // Handle date filter from GET parameters $filter_start_date = isset($_GET['start_date']) ? htmlspecialchars($_GET['start_date'], ENT_QUOTES, 'UTF-8') : null; $filter_end_date = isset($_GET['end_date']) ? htmlspecialchars($_GET['end_date'], ENT_QUOTES, 'UTF-8') : null; // Re-calculate statistics with filtered dates if provided if ($filter_start_date || $filter_end_date) { $all_images_stats = count_uploaded_files($image_formats, $filter_start_date, $filter_end_date); // Update per-format stats with filtered data $format_stats = []; foreach ($image_formats as $format) { $format_stats[$format] = isset($all_images_stats['by_format'][$format]) ? $all_images_stats['by_format'][$format] : 0; } } if ($_POST) { // TODO: AJAX processing will be implemented later } ?> <!-- Filter Results Info --> <?php if ($date_range['min_date'] && $date_range['max_date']): ?> <div class="row"> <div class="col-12"> <div class="alert alert-info"> <i class="fa fa-info-circle"></i> <?php if ($filter_start_date || $filter_end_date) { $message = __('Current filter shows files', 'cftp_admin'); if ($filter_start_date && $filter_end_date) { $message .= ' ' . sprintf(__('uploaded between %s and %s', 'cftp_admin'), date('F j, Y', strtotime($filter_start_date)), date('F j, Y', strtotime($filter_end_date))); } elseif ($filter_start_date) { $message .= ' ' . sprintf(__('uploaded from %s onwards', 'cftp_admin'), date('F j, Y', strtotime($filter_start_date))); } elseif ($filter_end_date) { $message .= ' ' . sprintf(__('uploaded until %s', 'cftp_admin'), date('F j, Y', strtotime($filter_end_date))); } echo $message; } else { echo sprintf(__('Showing all files uploaded between %s and %s', 'cftp_admin'), date('F j, Y', strtotime($date_range['min_date'])), date('F j, Y', strtotime($date_range['max_date']))); } ?> </div> </div> </div> <?php endif; ?> <!-- Date Range Filter Section --> <div class="row"> <div class="col-12"> <div class="ps-card"> <div class="ps-card-body"> <h5><?php _e('Date Range Filter', 'cftp_admin'); ?></h5> <form action="thumbnails-regenerate.php" method="get" id="date-filter-form"> <div class="row align-items-end"> <div class="col-md-4"> <label for="filter_start_date"><?php _e('Start Date', 'cftp_admin'); ?></label> <input type="date" name="start_date" id="filter_start_date" class="form-control" value="<?php echo $filter_start_date ?? ''; ?>" min="<?php echo $date_range['min_date'] ?? ''; ?>" max="<?php echo $date_range['max_date'] ?? ''; ?>"> <small class="form-text text-muted"><?php _e('Leave empty for all files from beginning', 'cftp_admin'); ?></small> </div> <div class="col-md-4"> <label for="filter_end_date"><?php _e('End Date', 'cftp_admin'); ?></label> <input type="date" name="end_date" id="filter_end_date" class="form-control" value="<?php echo $filter_end_date ?? ''; ?>" min="<?php echo $date_range['min_date'] ?? ''; ?>" max="<?php echo $date_range['max_date'] ?? ''; ?>"> <small class="form-text text-muted"><?php _e('Leave empty for all files until now', 'cftp_admin'); ?></small> </div> <div class="col-md-4"> <label> </label> <div> <button type="submit" class="btn btn-primary"> <i class="fa fa-filter"></i> <?php _e('Filter', 'cftp_admin'); ?> </button> <?php if ($filter_start_date || $filter_end_date): ?> <a href="thumbnails-regenerate.php" class="btn btn-secondary ms-2"> <i class="fa fa-times"></i> <?php _e('Clear', 'cftp_admin'); ?> </a> <?php endif; ?> </div> <small class="form-text text-muted"> </small> </div> </div> </form> </div> </div> </div> </div> <!-- Regeneration Options Section --> <div class="row mt-3"> <div class="col-12"> <div class="ps-card"> <div class="ps-card-body"> <h5><?php _e('Regeneration Options', 'cftp_admin'); ?></h5> <form action="thumbnails-regenerate.php" name="regenerate_thumbnails" method="post" enctype="multipart/form-data" class="form-horizontal" id="thumbnails-form"> <?php addCsrf(); ?> <!-- Hidden inputs to maintain date filter when regenerating --> <?php if ($filter_start_date): ?> <input type="hidden" name="filtered_start_date" value="<?php echo htmlspecialchars($filter_start_date); ?>"> <?php endif; ?> <?php if ($filter_end_date): ?> <input type="hidden" name="filtered_end_date" value="<?php echo htmlspecialchars($filter_end_date); ?>"> <?php endif; ?> <div class="form-group"> <div class="row"> <div class="col-md-6"> <h6><?php _e('Thumbnail Dimensions', 'cftp_admin'); ?></h6> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="thumbnail_width"><?php _e('Width (pixels)', 'cftp_admin'); ?></label> <input type="number" name="thumbnail_width" id="thumbnail_width" class="form-control" value="<?php echo get_option('thumbnails_width', false, 200); ?>" placeholder="200" min="50" max="1000" required> <small class="form-text text-muted"><?php _e('Recommended: 150-300px', 'cftp_admin'); ?></small> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="thumbnail_height"><?php _e('Height (pixels)', 'cftp_admin'); ?></label> <input type="number" name="thumbnail_height" id="thumbnail_height" class="form-control" value="<?php echo get_option('thumbnails_height', false, 200); ?>" placeholder="200" min="50" max="1000" required> <small class="form-text text-muted"><?php _e('Recommended: 150-300px', 'cftp_admin'); ?></small> </div> </div> </div> </div> <div class="col-md-6"> <h6><?php _e('Format Selection', 'cftp_admin'); ?></h6> <div class="fw-bold fs-5 mb-3" style="color: var(--main_color);"> <?php echo number_format($all_images_stats['total']); ?> <?php _e('total images', 'cftp_admin'); ?> </div> <div class="form-group"> <div class="d-flex flex-wrap gap-2"> <?php foreach ($image_formats as $format): $has_files = $format_stats[$format] > 0; $disabled = !$has_files ? 'disabled' : ''; $checked = $has_files ? 'checked' : ''; ?> <div class="format-selector <?php echo !$has_files ? 'format-disabled' : ''; ?>"> <input class="format-checkbox" type="checkbox" name="formats[]" id="format_<?php echo $format; ?>" value="<?php echo $format; ?>" <?php echo $checked; ?> <?php echo $disabled; ?>> <label class="format-label" for="format_<?php echo $format; ?>"> <div class="format-name"><?php echo strtoupper($format); ?></div> <div class="format-count"><?php echo number_format($format_stats[$format]); ?></div> </label> </div> <?php endforeach; ?> </div> </div> <small class="form-text text-muted"><?php _e('Select which image formats to process', 'cftp_admin'); ?></small> </div> </div> </div> </div> <div class="after_form_buttons"> <button type="button" name="submit" class="btn btn-wide btn-primary mb-5" id="regenerate-btn" <?php echo ($all_images_stats['total'] == 0) ? 'disabled' : ''; ?>> <i class="fa fa-refresh"></i> <?php _e('Start Thumbnail Regeneration', 'cftp_admin'); ?> </button> <?php if ($all_images_stats['total'] == 0): ?> <div class="alert alert-warning mt-3"> <i class="fa fa-info-circle"></i> <?php _e('No convertible images found. Upload some PNG, JPG, JPEG, or GIF files first.', 'cftp_admin'); ?> </div> <?php endif; ?> </div> </form> </div> </div> </div> </div> <?php include_once ADMIN_VIEWS_DIR . DS . 'footer.php'; |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |