From 264e1e82b23f622e9a79f7834cfcbfb536eac4f6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 15 Feb 2013 12:55:16 -0500 Subject: Digibug up and vanished. Move the module to contrib for now. This will leave the module active in any existing installs that had it active, but that shouldn't cause any negative impact. Fixes #2002. --- modules/digibug/config/digibug.php | 29 ------ modules/digibug/controllers/admin_digibug.php | 27 ----- modules/digibug/controllers/digibug.php | 121 ---------------------- modules/digibug/helpers/digibug_event.php | 52 ---------- modules/digibug/helpers/digibug_installer.php | 51 --------- modules/digibug/helpers/digibug_theme.php | 24 ----- modules/digibug/images/digibug_logo.png | Bin 17296 -> 0 bytes modules/digibug/js/digibug.js | 43 -------- modules/digibug/models/digibug_proxy.php | 22 ---- modules/digibug/module.info | 7 -- modules/digibug/tests/Digibug_Controller_Test.php | 74 ------------- modules/digibug/views/admin_digibug.html.php | 20 ---- modules/digibug/views/digibug_form.html.php | 13 --- 13 files changed, 483 deletions(-) delete mode 100644 modules/digibug/config/digibug.php delete mode 100644 modules/digibug/controllers/admin_digibug.php delete mode 100644 modules/digibug/controllers/digibug.php delete mode 100644 modules/digibug/helpers/digibug_event.php delete mode 100644 modules/digibug/helpers/digibug_installer.php delete mode 100644 modules/digibug/helpers/digibug_theme.php delete mode 100644 modules/digibug/images/digibug_logo.png delete mode 100644 modules/digibug/js/digibug.js delete mode 100644 modules/digibug/models/digibug_proxy.php delete mode 100644 modules/digibug/module.info delete mode 100644 modules/digibug/tests/Digibug_Controller_Test.php delete mode 100644 modules/digibug/views/admin_digibug.html.php delete mode 100644 modules/digibug/views/digibug_form.html.php (limited to 'modules') diff --git a/modules/digibug/config/digibug.php b/modules/digibug/config/digibug.php deleted file mode 100644 index 9412ca96..00000000 --- a/modules/digibug/config/digibug.php +++ /dev/null @@ -1,29 +0,0 @@ - email address that appears as the from address - * line-length => word wrap length (PHP documentations suggest no larger tha 70 characters - * reply-to => what goes into the reply to header - */ -$config["ranges"] = array( - "Digibug1" => array("low" => "65.249.152.0", "high" => "65.249.159.255"), - "Digibug2" => array("low" => "208.122.55.0", "high" => "208.122.55.255") -); diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php deleted file mode 100644 index 50f6f832..00000000 --- a/modules/digibug/controllers/admin_digibug.php +++ /dev/null @@ -1,27 +0,0 @@ -page_title = t("Digibug"); - $v->content = new View("admin_digibug.html"); - print $v; - } -} \ No newline at end of file diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php deleted file mode 100644 index 19199188..00000000 --- a/modules/digibug/controllers/digibug.php +++ /dev/null @@ -1,121 +0,0 @@ -file_url(true); - $thumb_url = $item->thumb_url(true); - } else { - $proxy = ORM::factory("digibug_proxy"); - $proxy->uuid = random::hash(); - $proxy->item_id = $item->id; - $proxy->save(); - $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid/$item->id"); - $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid/$item->id"); - } - - $v = new View("digibug_form.html"); - $v->order_params = array( - "digibug_api_version" => "100", - "company_id" => module::get_var("digibug", "company_id"), - "event_id" => module::get_var("digibug", "event_id"), - "cmd" => "addimg", - "partner_code" => "69", - "return_url" => url::abs_site("digibug/close_window"), - "num_images" => "1", - "image_1" => $full_url, - "thumb_1" => $thumb_url, - "image_height_1" => $item->height, - "image_width_1" => $item->width, - "thumb_height_1" => $item->thumb_height, - "thumb_width_1" => $item->thumb_width, - "title_1" => html::purify($item->title)); - - print $v; - } - - public function print_proxy($type, $uuid) { - // If its a request for the full size then make sure we are coming from an - // authorized address - if ($type == "full") { - $remote_addr = ip2long(Input::instance()->server("REMOTE_ADDR")); - if ($remote_addr === false) { - throw new Kohana_404_Exception(); - } - $config = Kohana::config("digibug"); - - $authorized = false; - foreach ($config["ranges"] as $ip_range) { - $low = ip2long($ip_range["low"]); - $high = ip2long($ip_range["high"]); - $authorized = $low !== false && $high !== false && - $low <= $remote_addr && $remote_addr <= $high; - if ($authorized) { - break; - } - } - if (!$authorized) { - throw new Kohana_404_Exception(); - } - } - - $proxy = ORM::factory("digibug_proxy")->where("uuid", "=", $uuid)->find(); - if (!$proxy->loaded() || !$proxy->item->loaded()) { - throw new Kohana_404_Exception(); - } - - $file = $type == "full" ? $proxy->item->file_path() : $proxy->item->thumb_path(); - if (!file_exists($file)) { - throw new Kohana_404_Exception(); - } - - // We don't need to save the session for this request - Session::instance()->abort_save(); - - if (!TEST_MODE) { - // Dump out the image - header("Content-Type: {$proxy->item->mime_type}"); - Kohana::close_buffers(false); - $fd = fopen($file, "rb"); - fpassthru($fd); - fclose($fd); - } - - $this->_clean_expired(); - } - - public function close_window() { - print ""; - } - - private function _clean_expired() { - db::build() - ->delete("digibug_proxies") - ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 90 DAY)")) - ->limit(20) - ->execute(); - } -} \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php deleted file mode 100644 index eaebc87b..00000000 --- a/modules/digibug/helpers/digibug_event.php +++ /dev/null @@ -1,52 +0,0 @@ -get("settings_menu") - ->append(Menu::factory("link") - ->id("digibug_menu") - ->label(t("Digibug")) - ->url(url::site("admin/digibug"))); - } - - static function site_menu($menu, $theme) { - $item = $theme->item(); - if ($item && $item->type == "photo") { - $menu->get("options_menu") - ->append(Menu::factory("link") - ->id("digibug") - ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) - ->css_id("g-print-digibug-link") - ->css_class("g-print-digibug-link ui-icon-print")); - } - } - - static function context_menu($menu, $theme, $item) { - if ($item->type == "photo") { - $menu->get("options_menu") - ->append(Menu::factory("link") - ->id("digibug") - ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) - ->css_class("g-print-digibug-link ui-icon-print")); - } - } -} diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php deleted file mode 100644 index be88b5ec..00000000 --- a/modules/digibug/helpers/digibug_installer.php +++ /dev/null @@ -1,51 +0,0 @@ -query("CREATE TABLE {digibug_proxies} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `uuid` char(32) NOT NULL, - `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp, - `item_id` int(9) NOT NULL, - PRIMARY KEY (`id`)) - DEFAULT CHARSET=utf8;"); - - module::set_var("digibug", "company_id", "3153"); - module::set_var("digibug", "event_id", "8491"); - } - - static function upgrade($version) { - if ($version == 1) { - module::clear_var("digibug", "default_company_id"); - module::clear_var("digibug", "default_event_id"); - module::clear_var("digibug", "basic_default_company_id"); - module::clear_var("digibug", "basic_event_id"); - module::set_var("digibug", "company_id", "3153"); - module::set_var("digibug", "event_id", "8491"); - module::set_version("digibug", $version = 2); - } - } - - static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {digibug_proxies}"); - module::delete("digibug"); - } -} diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php deleted file mode 100644 index e3795c3b..00000000 --- a/modules/digibug/helpers/digibug_theme.php +++ /dev/null @@ -1,24 +0,0 @@ -script("digibug.js"); - } -} diff --git a/modules/digibug/images/digibug_logo.png b/modules/digibug/images/digibug_logo.png deleted file mode 100644 index 5eac2c7d..00000000 Binary files a/modules/digibug/images/digibug_logo.png and /dev/null differ diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js deleted file mode 100644 index 46ddac52..00000000 --- a/modules/digibug/js/digibug.js +++ /dev/null @@ -1,43 +0,0 @@ -$(document).ready(function() { - $(".g-print-digibug-link").click(function(e) { - e.preventDefault(); - return digibug_popup(e.currentTarget.href, { width: 800, height: 600 } ); - }); -}); - -function digibug_popup(url, options) { - options = $.extend({ - /* default options */ - width: '800', - height: '600', - target: 'dbPopWin', - scrollbars: 'yes', - resizable: 'no', - menuBar: 'no', - addressBar: 'yes' - }, options); - - // center the window by default. - if (!options.winY) { - options.winY = screen.height / 2 - options.height / 2; - }; - if (!options.winX) { - options.winX = screen.width / 2 - options.width / 2; - }; - - open( - url, - options['target'], - 'width= ' + options.width + - ',height=' + options.height + - ',top=' + options.winY + - ',left=' + options.winX + - ',scrollbars=' + options.scrollbars + - ',resizable=' + options.resizable + - ',menubar=' + options.menuBar + - ',location=' + options.addressBar - ); - - return false; - -} diff --git a/modules/digibug/models/digibug_proxy.php b/modules/digibug/models/digibug_proxy.php deleted file mode 100644 index 18c77d49..00000000 --- a/modules/digibug/models/digibug_proxy.php +++ /dev/null @@ -1,22 +0,0 @@ -_server = $_SERVER; - } - - public function teardown() { - $_SERVER = $this->_server; - } - - private function _get_proxy() { - $album = test::random_album(); - $photo = test::random_photo($album); - - access::deny(identity::everybody(), "view_full", $album); - access::deny(identity::registered_users(), "view_full", $album); - - $proxy = ORM::factory("digibug_proxy"); - $proxy->uuid = random::hash(); - $proxy->item_id = $photo->id; - return $proxy->save(); - } - - public function digibug_request_thumb_test() { - $proxy = $this->_get_proxy(); - - $controller = new Digibug_Controller(); - $controller->print_proxy("thumb", $proxy->uuid); - } - - public function digibug_request_full_malicious_ip_test() { - $_SERVER["REMOTE_ADDR"] = "123.123.123.123"; - try { - $controller = new Digibug_Controller(); - $controller->print_proxy("full", $this->_get_proxy()->uuid); - $this->assert_true(false, "Should have failed with an 404 exception"); - } catch (Kohana_404_Exception $e) { - // expected behavior - } - } - - public function digibug_request_full_authorized_ip_test() { - $config = Kohana::config("digibug"); - $this->assert_true(!empty($config), "The Digibug config is empty"); - - $ranges = array_values($config["ranges"]); - $low = ip2long($ranges[0]["low"]); - $high = ip2long($ranges[0]["high"]); - - $_SERVER["REMOTE_ADDR"] = long2ip(rand($low, $high)); - $controller = new Digibug_Controller(); - $controller->print_proxy("full", $this->_get_proxy()->uuid); - } -} diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php deleted file mode 100644 index d673b116..00000000 --- a/modules/digibug/views/admin_digibug.html.php +++ /dev/null @@ -1,20 +0,0 @@ - -
- " alt="Digibug logo" class="g-right"/> -

-
-

- -

-
    -
  • - -
  • -
-

- register with Digibug and enter your Digibug id in the Advanced Settings page you can make money off of your photos!", - array("signup_url" => "http://www.digibug.com/signup.php", - "advanced_settings_url" => html::mark_clean(url::site("admin/advanced_settings")))) ?> -

-
-
diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php deleted file mode 100644 index af5a88b4..00000000 --- a/modules/digibug/views/digibug_form.html.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - - $value): ?> - - - - - - -- cgit v1.2.3