<?php if (OPTIONS::website('service_minify') == 1) { EVENTS::add_action("before_render", function () { if (!URL::routed()) { $r = URL::check('^extender/(.*).min.(css|js)$', true); if ($r !== false) { $path = FOLDER_BASE . "extender/" . $r[1] . "." . $r[2]; if (file_exists($path)) { // minify $minify = HELPERS::load("minify"); $minify->addSource($path); $minify->exec(); // redirect to the new file redirect(BASE_URL . $r[0]); } } } }); }
<?php if (OPTIONS::website('service_thumbs') == 1) { $r = URL::check('^content/[any]/[any]-thumb[num]x[num].[alpha]$', true); if ($r !== false) { $path = FOLDER_CONTENT . $r[1] . DS . $r[2] . "." . $r[5]; if (file_exists($path)) { $allowed_sizes = explode(",", OPTIONS::website("service_thumbs_allowed_sizes")); if (in_array($r[3] . "x" . $r[4], $allowed_sizes)) { // the new name of the image $new_name = FOLDER_CONTENT . $r[1] . DS . $r[2] . "-thumb" . $r[3] . "x" . $r[4] . "." . $r[5]; // load base image $img = HELPERS::load("images")->load($path); // resize, save and show $img->thumbnail($r[3], $r[4])->save($new_name)->output($new_name); // prevent execution die; } } } }