public function getMod($slug)
 {
     $table_javascript = route('tdf_name', ['modmodpacks', '0', $slug]);
     $mod = Mod::where('slug', '=', $slug)->first();
     if (!$mod) {
         $redirect = new URLRedirect();
         $do_redirect = $redirect->getRedirect(Request::path());
         if ($do_redirect) {
             return Redirect::to($do_redirect->target, 301);
         }
         App::abort(404);
     }
     $can_edit = false;
     if (Auth::check()) {
         $maintainer = $mod->maintainers()->where('user_id', Auth::id())->first();
         if ($maintainer) {
             $can_edit = true;
         }
     }
     $authors = $mod->authors;
     $spotlights = $mod->youtubeVideos()->where('category_id', 2)->get();
     $tutorials = $mod->youtubeVideos()->where('category_id', 3)->get();
     $raw_links = ['website' => $mod->website, 'download_link' => $mod->download_link, 'donate_link' => $mod->donate_link, 'wiki_link' => $mod->wiki_link];
     $links = [];
     foreach ($raw_links as $index => $link) {
         if ($link != '') {
             $links["{$index}"] = $link;
         }
     }
     $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($mod->description));
     $mod_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html);
     $title = $mod->name . ' - Mod - ' . $this->site_name;
     $meta_description = $mod->deck;
     return View::make('mods.detail', ['table_javascript' => $table_javascript, 'mod' => $mod, 'mod_description' => $mod_description, 'links' => $links, 'authors' => $authors, 'title' => $title, 'meta_description' => $meta_description, 'sticky_tabs' => true, 'spotlights' => $spotlights, 'tutorials' => $tutorials, 'can_edit' => $can_edit]);
 }
 /**
  * Build the user interface to ask for membership
  * 
  */
 function buildInterface()
 {
     $user = $this->getUserManager()->getCurrentUser();
     if ($user->isAnonymous()) {
         $redirect = new URLRedirect();
         $redirect->redirectToLogin();
     } else {
         $this->buildPermissionDeniedInterface();
     }
 }
Example #3
0
 public function getContent(HTTPRequest $request)
 {
     $parse = $this->displayViewVcHeader($request);
     $headers = "";
     $body = "";
     //this is very important. default path must be /
     $path = "/";
     if ($request->getFromServer('PATH_INFO') != "") {
         $path = $request->getFromServer('PATH_INFO');
         // hack: path must always end with /
         if (strrpos($path, "/") != strlen($path) - 1) {
             $path .= "/";
         }
     }
     $command = 'HTTP_COOKIE=' . $this->escapeStringFromServer($request, 'HTTP_COOKIE') . ' ' . 'HTTP_USER_AGENT=' . $this->escapeStringFromServer($request, 'HTTP_USER_AGENT') . ' ' . 'REMOTE_ADDR=' . escapeshellarg(HTTPRequest::instance()->getIPAddress()) . ' ' . 'QUERY_STRING=' . $this->cleanQueryString($request) . ' ' . 'SERVER_SOFTWARE=' . $this->escapeStringFromServer($request, 'SERVER_SOFTWARE') . ' ' . 'SCRIPT_NAME=' . $this->escapeStringFromServer($request, 'SCRIPT_NAME') . ' ' . 'HTTP_ACCEPT_ENCODING=' . $this->escapeStringFromServer($request, 'HTTP_ACCEPT_ENCODING') . ' ' . 'HTTP_ACCEPT_LANGUAGE=' . $this->escapeStringFromServer($request, 'HTTP_ACCEPT_LANGUAGE') . ' ' . 'PATH_INFO=' . $this->setLocaleOnFileName($path) . ' ' . 'PATH=' . $this->escapeStringFromServer($request, 'PATH') . ' ' . 'HTTP_HOST=' . $this->escapeStringFromServer($request, 'HTTP_HOST') . ' ' . 'DOCUMENT_ROOT=' . $this->escapeStringFromServer($request, 'DOCUMENT_ROOT') . ' ' . 'CODENDI_LOCAL_INC=' . $this->escapeStringFromServer($request, 'CODENDI_LOCAL_INC') . ' ' . '/var/www/cgi-bin/viewvc.cgi 2>&1';
     $content = $this->setLocaleOnCommand($command);
     list($headers, $body) = http_split_header_body($content);
     $content_type_line = strtok($content, "\n\t\r\v");
     $viewvc_content_type = $this->getViewVcContentType($content_type_line, $path);
     $content = substr($content, strpos($content, $content_type_line));
     $location_line = strtok($content, "\n\t\r\v");
     $viewvc_location = $this->getViewVcLocationHeader($location_line);
     if ($viewvc_location) {
         $content = substr($content, strpos($content, $location_line));
     }
     if ($parse) {
         //parse the html doc that we get from viewvc.
         //remove the http header part as well as the html header and
         //html body tags
         $begin_body = stripos($content, "<body");
         $begin_doc = strpos($content, ">", $begin_body) + 1;
         $length = strpos($content, "</body>\n</html>") - $begin_doc;
         // Now insert references, and display
         return util_make_reference_links(substr($content, $begin_doc, $length), $request->get('group_id'));
     } else {
         if ($viewvc_location) {
             $redirect = new \URLRedirect();
             $redirect->makeReturnToUrl($request, $viewvc_location);
             // TODO: need to test this
             // header('Location: '.$viewvc_location);
             // exit(1);
         }
         header('Content-Type:' . $viewvc_content_type . '; charset=utf-8');
         return $body;
     }
 }
 /**
  * Check if anonymous is granted to access else redirect to login page
  *
  * @param Array $server
  *
  * @return void
  */
 public function verifyRequest($server)
 {
     $user = $this->getCurrentUser();
     if (!ForgeConfig::areAnonymousAllowed() && $user->isAnonymous() && !$this->isScriptAllowedForAnonymous($server) && !$this->getPermissionsOverriderManager()->doesOverriderAllowUserToAccessPlatform($user)) {
         $redirect = new URLRedirect();
         $this->urlChunks['script'] = $redirect->buildReturnToLogin($server);
     }
 }
 /**
  * Check if anonymous is granted to access else redirect to login page
  *
  * @param Array $server
  *
  * @return void
  */
 public function verifyRequest($server)
 {
     $user = $this->getCurrentUser();
     if ($this->doesPlatformRequireLogin() && $user->isAnonymous() && !$this->isScriptAllowedForAnonymous($server)) {
         $redirect = new URLRedirect();
         $this->urlChunks['script'] = $redirect->buildReturnToLogin($server);
     }
 }
Example #6
0
function util_return_to($url)
{
    $request = HTTPRequest::instance();
    $url_redirect = new URLRedirect();
    $GLOBALS['Response']->redirect($url_redirect->makeReturnToUrl($request, $url));
    exit;
}
 public function getModpack($version, $slug)
 {
     $mods_javascript = route('tdf_name', ['modpackmods', $version, $slug]);
     $friendly_version = $this->getVersion($version);
     $modpack = Modpack::where('slug', '=', $slug)->first();
     if (!$modpack) {
         $redirect = new URLRedirect();
         $do_redirect = $redirect->getRedirect(Request::path());
         if ($do_redirect) {
             return Redirect::to($do_redirect->target, 301);
         }
         App::abort(404);
     }
     $can_edit = false;
     $has_servers = false;
     if (Auth::check()) {
         $maintainer = $modpack->maintainers()->where('user_id', Auth::id())->first();
         if ($maintainer) {
             $can_edit = true;
         }
     }
     $launcher = $modpack->launcher;
     $creators = $modpack->creators;
     $creators_formatted = implode(', ', array_map(function ($creator) {
         return $creator['name'];
     }, $creators->toArray()));
     $pack_code = $modpack->code;
     $tags = $modpack->tags;
     $tags_formatted = implode(', ', array_map(function ($tag) {
         return link_to(action('SearchController@getModpackSearch') . '?tag=' . $tag['slug'], $tag['name'], ['title' => $tag['deck']]);
     }, $tags->toArray()));
     $server_count = $modpack->servers()->where('active', 1)->count();
     $twitch_streams = $modpack->twitchStreams()->orderBy('viewers', 'desc')->get();
     $lets_plays = $modpack->youtubeVideos()->where('category_id', 1)->get();
     if ($server_count > 0) {
         $has_servers = true;
     }
     $server_javascript = route('tdf', ['servers', 'all']) . '?modpack=' . $modpack->id;
     $raw_links = ['website' => $modpack->website, 'download_link' => $modpack->download_link, 'donate_link' => $modpack->donate_link, 'wiki_link' => $modpack->wiki_link];
     $links = [];
     foreach ($raw_links as $index => $link) {
         if (!empty($link)) {
             $links[] = ['type' => $index, 'link' => $link];
         }
     }
     $links_formatted = implode(' | ', array_map(function ($link) {
         if ($link['type'] == 'website') {
             return "<a href='{$link['link']}'><i class='fa fa-external-link'></i>Website</a>";
         }
         if ($link['type'] == 'download_link') {
             return "<a href='{$link['link']}'><i class='fa fa-download'></i>Download</a>";
         }
         if ($link['type'] == 'donate_link') {
             return "<a href='{$link['link']}'><i class='fa fa-dollar'></i>Donate</a>";
         }
         if ($link['type'] == 'wiki_link') {
             return "<a href='{$link['link']}'><i class='fa fa-book'></i>Wiki</a>";
         }
         return '';
     }, $links));
     $table_javascript = [$mods_javascript, $server_javascript];
     $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($modpack->description));
     $modpack_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html);
     $title = $modpack->name . ' - ' . $friendly_version . ' Modpack - ' . $this->site_name;
     $meta_description = $modpack->deck;
     return View::make('modpacks.detail', ['table_javascript' => $table_javascript, 'modpack' => $modpack, 'modpack_description' => $modpack_description, 'links' => $links, 'links_formatted' => $links_formatted, 'launcher' => $launcher, 'creators' => $creators, 'creators_formatted' => $creators_formatted, 'tags' => $tags, 'tags_formatted' => $tags_formatted, 'servers' => $has_servers, 'title' => $title, 'meta_description' => $meta_description, 'pack_code' => $pack_code, 'version' => $version, 'twitch_streams' => $twitch_streams, 'lets_plays' => $lets_plays, 'has_servers' => $has_servers, 'can_edit' => $can_edit, 'sticky_tabs' => true]);
 }