private function getHeaders($url) { loadNitroLib('browser'); $browser = new Browser($url); try { $browser->fetch("HEAD"); $headers = $browser->getHeaders(); } catch (Exception $e) { if (NITRO_DEBUG_MODE) { $this->log->write('[NitroBrowser]: ' . $e->getMessage()); } return false; } return $headers; }
<?php if (isNitroEnabled() && (getNitroPersistence('Smush.Method') && getNitroPersistence('Smush.Method') == 'local') && getNitroPersistence('Smush.OnDemand')) { if (!empty($new_image) && file_exists(DIR_IMAGE . $new_image)) { loadNitroLib('NitroSmush/NitroSmush'); $smusher = new NitroSmush(); global $registry; $log = $registry->get('log'); try { $filename = DIR_IMAGE . $new_image; $res = $smusher->smush($filename); if (!empty($res['errors']) && NITRO_DEBUG_MODE == 1) { $log->write("[NitroSmush: {$filename}] => " . var_export($res, true)); } } catch (Exception $e) { set_time_limit(30); } } }
public function smush_get_progress() { session_write_close(); loadNitroLib('iprogress'); $progress = new iProgress('smush_web', 200); $smush_progress = array('processed_images_count' => $progress->getProgress(), 'already_smushed_images_count' => $progress->getData('already_smushed'), 'total_images' => $progress->getMax(), 'b_saved' => $progress->getData('b_saved'), 'last_smush_timestamp' => $progress->getData('last_smush_timestamp'), 'is_process_active' => $progress->getData('is_process_active'), 'messages' => $progress->clearMessages()); echo json_encode($smush_progress); exit; }