function __construct() { parent::__construct("feed"); /* Set feed ID and self link. */ $this->id(html::specialchars(url::abs_current())); $this->link()->rel("self")->href(url::abs_current()); }
public function __call($function, $args) { $input = Input::instance(); $request = new stdClass(); switch ($method = strtolower($input->server("REQUEST_METHOD"))) { case "get": $request->params = (object) $input->get(); break; case "post": $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); } break; } $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method)); $request->access_token = $input->server("HTTP_X_GALLERY_REQUEST_KEY"); $request->url = url::abs_current(true); rest::set_active_user($request->access_token); $handler_class = "{$function}_rest"; $handler_method = $request->method; if (!method_exists($handler_class, $handler_method)) { throw new Rest_Exception("Bad Request", 400); } try { rest::reply(call_user_func(array($handler_class, $handler_method), $request)); } catch (ORM_Validation_Exception $e) { foreach ($e->validation->errors() as $key => $value) { $msgs[] = "{$key}: {$value}"; } throw new Rest_Exception("Bad Request: " . join(", ", $msgs), 400); } }
static function head($theme) { if ($theme->item()) { $item = $theme->item(); $image_url = $item->thumb_url(true); $page_url = url::abs_current(true); return "<meta property=\"og:image\" content=\"{$image_url}\"/>\n\t\t <meta property=\"og:title\" content=\"{$item->title}\"/>\n\t\t <meta property=\"og:type\" content=\"article\"/>\n\t\t <meta property=\"og:url\" content=\"{$page_url}\"/>"; } }
private static function _prompt_for_reauth($controller_name, $args) { if (request::method() == "get") { // Avoid anti-phishing protection by passing the url as session variable. Session::instance()->set("continue_url", url::abs_current(true)); } // Save the is_ajax value as we lose it, if set, when we redirect Session::instance()->set("is_ajax_request", request::is_ajax()); url::redirect("reauthenticate"); }
public function __call($function, $args) { try { $input = Input::instance(); $request = new stdClass(); switch ($method = strtolower($input->server("REQUEST_METHOD"))) { case "get": $request->params = (object) $input->get(); break; default: $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); system::delete_later($request->file); } break; } if (isset($request->params->entity)) { $request->params->entity = json_decode($request->params->entity); } if (isset($request->params->members)) { $request->params->members = json_decode($request->params->members); } $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method)); $request->access_key = $input->server("HTTP_X_GALLERY_REQUEST_KEY"); if (empty($request->access_key) && !empty($request->params->access_key)) { $request->access_key = $request->params->access_key; } $request->url = url::abs_current(true); if ($suffix = Kohana::config('core.url_suffix')) { $request->url = substr($request->url, 0, strlen($request->url) - strlen($suffix)); } rest::set_active_user($request->access_key); $handler_class = "{$function}_rest"; $handler_method = $request->method; if (!class_exists($handler_class) || !method_exists($handler_class, $handler_method)) { throw new Rest_Exception("Bad Request", 400); } $response = call_user_func(array($handler_class, $handler_method), $request); if ($handler_method == "post") { // post methods must return a response containing a URI. header("HTTP/1.1 201 Created"); header("Location: {$response['url']}"); } rest::reply($response); } catch (ORM_Validation_Exception $e) { // Note: this is totally insufficient because it doesn't take into account localization. We // either need to map the result values to localized strings in the application code, or every // client needs its own l10n string set. throw new Rest_Exception("Bad Request", 400, $e->validation->errors()); } catch (Kohana_404_Exception $e) { throw new Rest_Exception("Not Found", 404); } }
/** * Add a log entry. * * @param string $category an arbitrary category we can use to filter log messages * @param string $message a detailed log message * @param integer $severity INFO, WARNING or ERROR * @param string $html an html snippet presented alongside the log message to aid the admin */ private static function _add($category, $message, $html, $severity) { $log = ORM::factory("log"); $log->category = $category; $log->message = $message; $log->severity = $severity; $log->html = $html; $log->url = substr(url::abs_current(true), 0, 255); $log->referer = request::referrer(null); $log->timestamp = time(); $log->user_id = identity::active_user()->id; $log->save(); }
static function head($theme) { $impageonly = module::get_var("social_share", "general_impage_only"); $showblock = !$impageonly || ($impageonly && $theme->page_subtype == "photo" || $theme->page_subtype == "movie"); if ($showblock && $theme->item()) { $item = $theme->item(); $url = $item->thumb_url(true); $appId = module::get_var("social_share", "facebook_like_appId"); $adminId = module::get_var("social_share", "facebook_like_adminId"); $site_name = module::get_var("social_share", "facebook_like_site_name"); $selfURL = url::abs_current(true); return "\t<meta property=\"og:image\" content=\"{$url}\"/>\n <meta property=\"og:title\" content=\"{$item->title}\"/>\n <meta property=\"og:type\" content=\"article\"/>\n <meta property=\"og:url\" content=\"{$selfURL}\"/>\n <meta property=\"og:site_name\" content=\"{$site_name}\"/>\n <meta property=\"fb:app_id\" content=\"{$appId}\"/>\n <meta property=\"fb:admins\" content=\"{$adminId}\"/>"; } }
/** * Add a log entry. * * @param string $category an arbitrary category we can use to filter log messages * @param string $message a detailed log message * @param integer $severity INFO, WARNING or ERROR * @param string $html an html snippet presented alongside the log message to aid the admin */ private static function _add($category, $message, $html, $severity) { $log = ORM::factory("log"); $log->category = $category; $log->message = $message; $log->severity = $severity; $log->html = $html; $log->url = url::abs_current(true); $log->referer = request::referrer(null); $log->timestamp = time(); if (module::is_installed("user")) { $log->user_id = user::active()->id; } $log->save(); }
/** * If the gallery is only available to registered users and the user is not logged in, present * the login page. */ static function private_gallery() { if (identity::active_user()->guest && !access::user_can(identity::guest(), "view", item::root()) && php_sapi_name() != "cli") { try { $class = new ReflectionClass(ucfirst(Router::$controller) . '_Controller'); $allowed = $class->getConstant("ALLOW_PRIVATE_GALLERY") === true; } catch (ReflectionClass $e) { $allowed = false; } if (!$allowed) { if (Router::$controller == "admin") { // At this point we're in the admin theme and it doesn't have a themed login page, so // we can't just swap in the login controller and have it work. So redirect back to the // root item where we'll run this code again with the site theme. url::redirect(item::root()->abs_url()); } else { Session::instance()->set("continue_url", url::abs_current()); Router::$controller = "login"; Router::$controller_path = MODPATH . "gallery/controllers/login.php"; Router::$method = "html"; } } } }
static function user_menu($menu, $theme) { if ($theme->page_subtype != "login") { $user = identity::active_user(); if ($user->guest) { $menu->append(Menu::factory("dialog")->id("user_menu_login")->css_id("g-login-link")->url(url::site("login/ajax"))->label(t("Login"))); } else { $csrf = access::csrf_token(); $menu->append(Menu::factory("link")->id("user_menu_edit_profile")->css_id("g-user-profile-link")->view("login_current_user.html")->url(user_profile::url($user->id))->label($user->display_name())); $menu->append(Menu::factory("link")->id("user_menu_logout")->css_id("g-logout-link")->url(url::site("logout?csrf={$csrf}&continue=" . urlencode(url::abs_current())))->label(t("Logout"))); } } }
<?php defined("SYSPATH") or die("No direct script access."); $appId = module::get_var("social_share", "facebook_like_appId"); $selfURL = url::abs_current(true); $codeType = module::get_var("social_share", "facebook_like_code_type"); $layout = module::get_var("social_share", "facebook_like_layout", "standard"); $action = module::get_var("social_share", "facebook_like_action", "like"); if (module::get_var("social_share", "facebook_like_show_faces")) { $show_faces = "true"; $hite = 65; } else { $show_faces = "false"; $hite = 35; } if (module::get_var("social_share", "facebook_like_send")) { $send = "true"; } else { $send = "false"; } ?> <div class="g-social_share-facebook_like"> <?php if ($codeType == 'iframe') { ?> <iframe src="http://www.facebook.com/plugins/like.php?app_id=<?php echo $appId; ?> &href=<?php echo $selfURL;
<?php defined("SYSPATH") or die("No direct script access."); $tag_array = array(); $item = $theme->item; // Set up the tags that describe the current page. $tag_array[] = array("og:site_name", str_replace("\"", """, str_replace("\"", """, item::root()->title))); $tag_array[] = array("og:url", url::abs_current(true)); $tag_array[] = array("og:title", str_replace("\"", """, $item->title)); // Set albums and photos to type = article, movies to type = video for embeding. if ($item->is_album() || $item->is_photo()) { $tag_array[] = array("og:type", "article"); } elseif ($item->is_movie()) { $tag_array[] = array("og:type", "video"); } // Use the thumb url for the page image. $tag_array[] = array("og:image", $item->thumb_url(true)); // If there's a description, display it. if ($item->description != "") { $tag_array[] = array("og:description", html::purify($item->description)); } // If the item is a photo, then we already have the mime type in the database, so display that. // Otherwise, attempt to auto-detect mime type using getimagesize(). if ($item->is_photo()) { $tag_array[] = array("og:image:type", $item->mime_type); $tag_array[] = array("og:image:width", $item->thumb_width); $tag_array[] = array("og:image:height", $item->thumb_height); } elseif ($item->is_album()) { $size = getimagesize($item->thumb_path()); if ($size) { $tag_array[] = array("og:image:type", $size['mime']);
(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=<?php echo module::get_var("facebook_comment", "appId"); ?> "; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <fb:comments href="<?php if (isset($url)) { print $url; } else { print url::abs_current(); } ?> " num_posts="5" width="478" colorscheme="dark"> </fb:comments> </div> <script> if (typeof(FB) != 'undefined') { FB.XFBML.parse(document.getElementById('g-dialog')); } setTimeout(function () { $("#g-dialog").removeClass("g-loading-small"); }, 10); </script>
static function user_menu($menu, $theme) { if ($theme->page_subtype != "login") { $user = identity::active_user(); if ($user->guest) { $menu->append(Menu::factory("dialog")->id("user_menu_login")->css_id("g-login-link")->url(url::site("login/ajax"))->label(t("Login"))); } else { $csrf = access::csrf_token(); $menu->append(Menu::factory("link")->id("user_menu_edit_profile")->css_id("g-user-profile-link")->view("login_current_user.html")->url(user_profile::url($user->id))->label($user->display_name())); if (Router::$controller == "admin") { $continue_url = url::abs_site(""); } else { if ($item = $theme->item()) { if (access::user_can(identity::guest(), "view", $theme->item)) { $continue_url = $item->abs_url(); } else { $continue_url = item::root()->abs_url(); } } else { $continue_url = url::abs_current(); } } $menu->append(Menu::factory("link")->id("user_menu_logout")->css_id("g-logout-link")->url(url::site("logout?csrf={$csrf}&continue_url=" . urlencode($continue_url)))->label(t("Logout"))); } } }