/** * Creates the options admin page and manages the update of options. * * This is the default Action * * @return void */ function indexAction() { if (post('action') == 'index') { $options = get_option('HerissonOptions'); $new_options = array(); foreach ($this->allowedoptions as $option) { $new_options[$option] = post($option); } $complete_options = array_merge($options, $new_options); if (!array_key_exists('privateKey', $complete_options)) { $encryption = Encryption::i()->generateKeyPairs(); $complete_options['publicKey'] = $encryption->public; $complete_options['privateKey'] = $encryption->private; Message::i()->addError("<b>Warning</b> : public/private keys have been regenerated"); } update_option('HerissonOptions', $complete_options); } // Check binaries paths $binaryTools = array('convert', 'wget', 'du', 'mv', 'uname'); sort($binaryTools); $this->view->binaries = array(); foreach ($binaryTools as $binary) { $this->view->binaries[$binary] = Shell::getPath($binary); } $this->view->platform = Shell::shellExec('uname', '-a'); $this->view->screenshots = WpHerissonScreenshotsTable::getAll(); $this->view->options = get_option('HerissonOptions'); }
/** * Create the screenshot of the webpage url * * Use the wkhtmltoimage tool to create the PNG image * If the screenshot has been created, create a thumbnail and calculate the new dir size. * * @param boolean $verbose wether this method should verbose messages * * @return void */ public function captureFromUrl($verbose) { if (!$this->id || $this->error || !$this->hash || $this->is_binary) { return false; } $options = get_option('HerissonOptions'); if (!$options['spiderOptionScreenshot']) { return false; } // return false if screenshot already exists if ($this->hasImage()) { return false; } $image = $this->getImage(); $screenshotTool = WpHerissonScreenshotsTable::get($options['screenshotTool']); call_user_func($screenshotTool->fonction, $this->url, $image); if (file_exists($image) && filesize($image)) { herisson_screenshots_thumb($image, $this->getThumb()); $this->content_image = $image; $this->calculateDirSize(); } else { $this->content_image = null; } $this->save(); }