public function action_add_blocked($block = null)
 {
     if (empty($block) === true) {
         $block = $_POST['blocked'];
     } else {
         $block = str_replace('-', '.', $block);
     }
     $blacklist_item = Model_Blacklist::query()->where('expression', $block)->get_one();
     if (empty($blacklist_item) === true) {
         $blacklist_item = Model_Blacklist::forge(array('expression' => $block));
         $blacklist_item->save();
         if (Input::is_ajax() === true) {
             echo $blacklist_item->id;
         }
     } else {
         if (Input::is_ajax() === true) {
             print_r(Format::forge(array('error' => 'Already Exists'))->to_json());
         } else {
             Session::set('error', $block . ' is already in the blacklist!');
         }
     }
     if (Input::is_ajax() === true) {
         die;
     }
     Response::Redirect_Back();
 }
 public static function img_from_url($url_object, $device = "desktop")
 {
     $api_key = \Settings::get('google_pagespeed_insights_api_key');
     if (empty($api_key) === false) {
         if (empty($url_object) === false && is_object($url_object)) {
             if (empty($url_object->cached_preview) === true) {
                 $image = false;
                 if ($url_object->url != null && $api_key != null) {
                     if ($device != "desktop") {
                         $device = "mobile";
                     }
                     $data = @json_decode(file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=" . urlencode($url_object->url) . "&strategy=" . $device . "&screenshot=true&fields=responseCode%2Cscreenshot&key=" . $api_key));
                     if (@$data->responseCode == 200) {
                         $image = 'data:image/png;base64,' . str_replace(array("-", "_"), array("+", "/"), $data->screenshot->data);
                         $url_object->cached_preview = $image;
                         $url_object->save();
                         if (Input::is_ajax()) {
                             echo $image;
                             die;
                         } else {
                             return $image;
                         }
                     }
                 }
             } else {
                 if (\Input::is_ajax()) {
                     echo $url_object->cached_preview;
                     die;
                 } else {
                     return $url_object->cached_preview;
                 }
             }
         } else {
             if (\Input::is_ajax()) {
                 echo 'Invalid input, this is not a url object!';
                 die;
             } else {
                 \Session::set('error', 'Invalid input, this is not a url object!');
             }
         }
     } else {
         if (\Input::is_ajax()) {
             echo "error : No Google PageSpeed Insights API Key has been set please vist : https://code.google.com/apis/console to get a key!";
             die;
         } else {
             \Session::set('error', 'No Google PageSpeed Insights API Key has been set please vist : https://code.google.com/apis/console to get a key!');
             \Response::Redirect_Back();
         }
     }
 }