From ca9b69cfd7835b840273c82ccea2ecc07dc40685 Mon Sep 17 00:00:00 2001 From: floridave Date: Tue, 10 May 2011 14:47:22 -0600 Subject: [PATCH] new module: addthis was not on GIT before --- 3.0/modules/addthis/config/addthis.php | 29 +++++ 3.0/modules/addthis/controllers/addthis.php | 123 ++++++++++++++++++ .../addthis/controllers/admin_addthis.php | 26 ++++ 3.0/modules/addthis/css/addthis_menu.css | 3 + 3.0/modules/addthis/helpers/addthis_event.php | 48 +++++++ .../addthis/helpers/addthis_installer.php | 45 +++++++ 3.0/modules/addthis/helpers/addthis_theme.php | 29 +++++ 3.0/modules/addthis/images/addthis_logo.png | Bin 0 -> 5435 bytes 3.0/modules/addthis/models/addthis_proxy.php | 22 ++++ 3.0/modules/addthis/module.info | 3 + .../addthis/views/admin_addthis.html.php | 22 ++++ 11 files changed, 350 insertions(+) create mode 100644 3.0/modules/addthis/config/addthis.php create mode 100644 3.0/modules/addthis/controllers/addthis.php create mode 100644 3.0/modules/addthis/controllers/admin_addthis.php create mode 100644 3.0/modules/addthis/css/addthis_menu.css create mode 100644 3.0/modules/addthis/helpers/addthis_event.php create mode 100644 3.0/modules/addthis/helpers/addthis_installer.php create mode 100644 3.0/modules/addthis/helpers/addthis_theme.php create mode 100644 3.0/modules/addthis/images/addthis_logo.png create mode 100644 3.0/modules/addthis/models/addthis_proxy.php create mode 100644 3.0/modules/addthis/module.info create mode 100644 3.0/modules/addthis/views/admin_addthis.html.php diff --git a/3.0/modules/addthis/config/addthis.php b/3.0/modules/addthis/config/addthis.php new file mode 100644 index 00000000..04e314c9 --- /dev/null +++ b/3.0/modules/addthis/config/addthis.php @@ -0,0 +1,29 @@ + 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( + "Addthis1" => array("low" => "65.249.152.0", "high" => "65.249.159.255"), + "Addthis2" => array("low" => "208.122.55.0", "high" => "208.122.55.255") +); diff --git a/3.0/modules/addthis/controllers/addthis.php b/3.0/modules/addthis/controllers/addthis.php new file mode 100644 index 00000000..6e55a17b --- /dev/null +++ b/3.0/modules/addthis/controllers/addthis.php @@ -0,0 +1,123 @@ +file_url(true); + $thumb_url = $item->thumb_url(true); + } else { + $proxy = ORM::factory("addthis_proxy"); + $proxy->uuid = md5(rand()); + $proxy->item_id = $item->id; + $proxy->save(); + $full_url = url::abs_site("addthis/print_proxy/full/$proxy->uuid"); + $thumb_url = url::abs_site("addthis/print_proxy/thumb/$proxy->uuid"); + } + + $v = new View("addthis_form.html"); + $v->order_parms = array( + "addthis_api_version" => "100", + "company_id" => module::get_var("addthis", "company_id"), + "event_id" => module::get_var("addthis", "event_id"), + "cmd" => "addimg", + "partner_code" => "69", + "return_url" => url::abs_site("addthis/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, $id) { + // If its a request for the full size then make sure we are coming from an + // authorized address + if ($type == "full") { + $remote_addr = ip2long($this->input->server("REMOTE_ADDR")); + if ($remote_addr === false) { + Kohana::show_404(); + } + $config = Kohana::config("addthis"); + + $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) { + Kohana::show_404(); + } + } + + $proxy = ORM::factory("addthis_proxy", array("uuid" => $id)); + if (!$proxy->loaded || !$proxy->item->loaded) { + Kohana::show_404(); + } + + $file = $type == "full" ? $proxy->item->file_path() : $proxy->item->thumb_path(); + if (!file_exists($file)) { + kohana::show_404(); + } + + // We don't need to save the session for this request + Session::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); + + // If the request was for the image and not the thumb, then delete the proxy. + if ($type == "full") { + $proxy->delete(); + } + } + + $this->_clean_expired(); + } + + public function close_window() { + print ""; + } + + private function _clean_expired() { + Database::instance()->query( + "DELETE FROM {addthis_proxies} " . + "WHERE request_date <= (CURDATE() - INTERVAL 10 DAY) " . + "LIMIT 20"); + } +} \ No newline at end of file diff --git a/3.0/modules/addthis/controllers/admin_addthis.php b/3.0/modules/addthis/controllers/admin_addthis.php new file mode 100644 index 00000000..9c537b00 --- /dev/null +++ b/3.0/modules/addthis/controllers/admin_addthis.php @@ -0,0 +1,26 @@ +content = new View("admin_addthis.html"); + print $v; + } +} \ No newline at end of file diff --git a/3.0/modules/addthis/css/addthis_menu.css b/3.0/modules/addthis/css/addthis_menu.css new file mode 100644 index 00000000..b1deae01 --- /dev/null +++ b/3.0/modules/addthis/css/addthis_menu.css @@ -0,0 +1,3 @@ +#g-view-menu #g-addthis-link { + background-image: url('../images/addthis_logo.png'); +} diff --git a/3.0/modules/addthis/helpers/addthis_event.php b/3.0/modules/addthis/helpers/addthis_event.php new file mode 100644 index 00000000..c0415564 --- /dev/null +++ b/3.0/modules/addthis/helpers/addthis_event.php @@ -0,0 +1,48 @@ +get("settings_menu") + ->append(Menu::factory("link") + ->id("addthis_menu") + ->label(t("AddThis")) + ->url(url::site("admin/addthis"))); + } + + static function photo_menu($menu, $theme) { + $item = $theme->item(); + $menu->append(Menu::factory("link") + ->id("addthis") + ->label(t("Bookmark and Share: $item->title")) + ->url("") + ->css_id("g-addthis-link") + ->css_class("addthis_button")); + } + + static function album_menu($menu, $theme) { + $item = $theme->item(); + $menu->append(Menu::factory("link") + ->id("addthis") + ->label(t("Bookmark and Share: $item->title")) + ->url("") + ->css_id("g-addthis-link") + ->css_class("addthis_button")); + } +} diff --git a/3.0/modules/addthis/helpers/addthis_installer.php b/3.0/modules/addthis/helpers/addthis_installer.php new file mode 100644 index 00000000..ac401eb6 --- /dev/null +++ b/3.0/modules/addthis/helpers/addthis_installer.php @@ -0,0 +1,45 @@ +query("CREATE TABLE {addthis_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("addthis", "username", ""); + module::set_version("addthis", 1); + } + + static function upgrade($version) { + if ($version == 1) { + module::set_version("addthis", $version = 1); + } + } + + static function uninstall() { + Database::instance()->query("DROP TABLE IF EXISTS {addthis_proxies}"); + module::delete("addthis"); + } +} diff --git a/3.0/modules/addthis/helpers/addthis_theme.php b/3.0/modules/addthis/helpers/addthis_theme.php new file mode 100644 index 00000000..7308954e --- /dev/null +++ b/3.0/modules/addthis/helpers/addthis_theme.php @@ -0,0 +1,29 @@ +css("addthis_menu.css"); + return "\n" . + ""; + } +} diff --git a/3.0/modules/addthis/images/addthis_logo.png b/3.0/modules/addthis/images/addthis_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..39372a0c254b06107868c1ba96ff76d2c8c68833 GIT binary patch literal 5435 zcmXArc|6qL_s8F}7;Bc4JxijjgDFeYP+9s=mQ)mtB$Mic>{~M<2}MY=dXPB^l4@P06%Y^ zyEg$K>{srKP-o|#QgNi#(1_Px^q@|Urdry8k;t@bme(_7J&wRcQAcZ43ZN2}XR;64 zICK-fIvl!mrdE8Pa}EC?fg}1dmd@IKR-;d54S)tOS{n zfv|<7e3smZF?+czk?I(<3J@TQ9s~`*?vhnArY2HAyno3Cx`+Z5df(&J3I3~g^2HSe|~77_yqCf8H^pl` z+TSJNprM3*g3{i(gERBM9~(i;z2BF$|9A;^X9S$JB~1rP?&S+Q@IrU;`>$*Z+MHLB zKOEWxsB2~QW52nNIDO0dr~pV&*scaMzeX%A8;-tjcz5(D%79bm00vY2{`oy&86it= z!iradPu8m0BXWSpV8ZQs>JyzRA;ORj@M)6e`OO$0yeai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&9tTI!bQ8)3Ukx8 z`>dYNo$a4Hg`8kj7{U(&Uh>C7<(I1~(cv>Ev<{aJvOuM&H#Z4CbcUVemUflUgO(5P zyDK2wo0=nLhs5%U(ND~*5bsVsmq-L*U70^@>`xpVlU8mA(1Bh@8nE1H-i!*IwLE{O J>XgTW{{ueQ(2@WE literal 0 HcmV?d00001 diff --git a/3.0/modules/addthis/models/addthis_proxy.php b/3.0/modules/addthis/models/addthis_proxy.php new file mode 100644 index 00000000..dd7ff120 --- /dev/null +++ b/3.0/modules/addthis/models/addthis_proxy.php @@ -0,0 +1,22 @@ + +
+ " alt="Add This logo" class="g-right"/> +

+
+

+ +AddThis uses services to provide an intelligent, optimized sharing menu that is designed to offer the right options at the right time and maximize distribution of your content - everywhere.") ?> +

+
    +
  • + +
  • +
+

+ register with Add This and enter your addthis username in the Advanced Settings page you can get Analytics. Example data below.", + array("signup_url" => "http://www.addthis.com/register", + "advanced_settings_url" => html::mark_clean(url::site("admin/advanced_settings")))) ?> +

+
+
+