Exemplo n.º 1
0
 private function set_login_cookie($name, $pass)
 {
     global $config;
     $addr = get_session_ip($config);
     $hash = md5(strtolower($name) . $pass);
     set_prefixed_cookie("user", $name, time() + 60 * 60 * 24 * 365, '/');
     set_prefixed_cookie("session", md5($hash . $addr), time() + 60 * 60 * 24 * $config->get_int('login_memory'), '/');
 }
Exemplo n.º 2
0
    function display_page(Page $page)
    {
        global $config;
        $theme_name = $config->get_string('theme', 'default');
        $data_href = get_base_href();
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $main_block_html = "";
        $sub_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $block->get_html(true);
                    break;
                case "main":
                    $main_block_html .= $block->get_html(false);
                    break;
                case "subheading":
                    $sub_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>";
        if (empty($page->subheading)) {
            $subheading = "";
        } else {
            $subheading = "<div id='subtitle'>{$page->subheading}</div>";
        }
        if ($page->left_enabled) {
            $left = "<nav>{$left_block_html}</nav>";
            $withleft = "withleft";
        } else {
            $left = "";
            $withleft = "";
        }
        $flash = get_prefixed_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
{$header_html}
\t\t<script src='{$data_href}/themes/{$theme_name}/script.js' type='text/javascript'></script>
\t</head>

\t<body>
\t\t<header>
\t\t\t<h1>{$page->heading}</h1>
\t\t\t{$subheading}
\t\t\t{$sub_block_html}
\t\t</header>
\t\t{$left}
\t\t<article class="{$withleft}">
\t\t\t{$flash_html}
\t\t\t{$main_block_html}
\t\t</article>
\t\t<footer>
\t\t\t<hr>
\t\t\tImages &copy; their respective owners,
\t\t\t<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
\t\t\t<a href="http://www.shishnet.org/">Shish</a> &amp;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.
\t\t\t<br>Futaba theme based on 4chan's layout and CSS :3
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</footer>
\t</body>
</html>
EOD;
    }
Exemplo n.º 3
0
    /**
     * turns the Page into HTML
     */
    public function display_page(Page $page)
    {
        global $config;
        $theme_name = $config->get_string('theme', 'material');
        $site_name = $config->get_string('title');
        $data_href = get_base_href();
        $main_page = $config->get_string('main_page');
        $contact_link = $config->get_string('contact_link');
        $site_link = make_link();
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $main_block_html = "";
        $head_block_html = "";
        $sub_block_html = "";
        $drawer_block_html = "";
        //use exampled in user.theme.php & view.theme.php
        $toolbar_block_html = "";
        // not used at this point
        $subtoolbar_block_html = "";
        // use exampled in user.theme.php
        $navigation = "";
        $h_search = "\n      <div class='mdl-textfield mdl-js-textfield mdl-textfield--expandable\n                  mdl-textfield--floating-label mdl-textfield--align-right'>\n        <form action='" . make_link() . "' method='GET'>\n          <label class='mdl-button mdl-js-button mdl-button--icon'\n                 for='waterfall-exp'>\n            <i class='material-icons'>search</i>\n          </label>\n          <div class='mdl-textfield__expandable-holder'>\n            <input id='waterfall-exp' class='autocomplete_tags mdl-textfield__input' name='search' type='text' placeholder='Search' value='' />\n            <input type='hidden' name='q' value='/post/list'>\n            <input type='submit' value='Find' style='display: none;' />\n          </div>\n        </form>\n      </div>\n    ";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "toolbar":
                    $toolbar_block_html .= $this->get_html($block, "toolbar");
                    break;
                case "subtoolbar":
                    $subtoolbar_block_html .= $this->get_html($block, "subtoolbar");
                    break;
                case "left":
                    if ($block->header == "Navigation") {
                        $subtoolbar_block_html = $this->rework_navigation($block);
                        break;
                    }
                    // $left_block_html .= $block->get_html(true);
                    $left_block_html .= $this->get_html($block, "full", true, "left-blocks nav-card mdl-cell--4-col-tablet");
                    break;
                case "head":
                    $head_block_html .= $this->get_html($block, "third", true, "nav-card head-blocks");
                    break;
                case "drawer":
                    $drawer_block_html .= $this->get_html($block, "full", true, "nav-card drawer-blocks");
                    break;
                case "main":
                    // $main_block_html .= $block->get_html(false);
                    $main_block_html .= $this->get_html($block, "main", true, "");
                    break;
                case "subheading":
                    // $sub_block_html .= $block->body; // $this->block_to_html($block, true);
                    $sub_block_html .= $this->get_html($block, "third", true, "nav-card");
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>";
        /*$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
        
        		$wrapper = "";
        		if(strlen($page->heading) > 100) {
        			$wrapper = ' style="height: 3em; overflow: auto;"';
        		}
        		*/
        $flash = get_prefixed_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
\t\t<title>{$page->title}</title>
    <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en">
    <link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons"  rel="stylesheet">
    <link rel="stylesheet" href="{$data_href}/themes/{$theme_name}/material.min.css?v1.0.5"  rel="stylesheet">
    {$header_html}
\t\t<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/material.min.js?v1.0.5"></script>
\t\t<script type="text/javascript" src="{$data_href}/themes/{$theme_name}/script0.js?v1"></script>
    <!-- having conflicts this ensures the screens will not remain hidden \\while the layout is adjusted -->
\t</head>

\t<body>

    <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
      <header class="mdl-layout__header mdl-layout__header--waterfall">
        <!-- Top row, always visible -->
        <div class="mdl-layout__header-row ">
          <!-- Title -->
          <span class="mdl-layout-title">
            <a class="mdl-logo" href="{$site_link}">{$site_name}</a>
          </span>
          <div class="mdl-layout-spacer"></div>
          {$h_search}
          {$toolbar_block_html}
          <button id="menu-left-col-menu"
                  class="mdl-button mdl-js-button mdl-button--icon">
            <i class="material-icons">more_vert</i>
          </button>
        </div>
        <!-- Bottom row, not visible on scroll -->
        <div class="mdl-layout__header-row">
          <div class="mdl-layout-spacer"></div>
          <!-- Navigation -->
          {$subtoolbar_block_html}
        </div>
      </header>
      <div class="mdl-layout__drawer">
        <span class="mdl-layout-title">Drawer</span>
          <div class="mdl-grid">
            {$drawer_block_html}
          </div>
        <nav class="mdl-navigation">
          <a class="mdl-navigation__link" href="http://code.shishnet.org/shimmie2/">Shimmie  &copy;</a>
        </nav>
      </div>
      <main class="mdl-layout__content">
        <div class="mdl-grid">
          <div class="mdl-cell mdl-cell--12-col mdl-grid ">
            {$head_block_html}
            {$sub_block_html}
          </div>
        </div>
        <div id="main-grid" class="mdl-grid">
          <div id="left-block" class="mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-color--grey-200">
            <script>
              document.getElementById("left-block").style.display="none";
            </script>
            <div id="left-blk-content" class="mdl-cell mdl-cell--12-col mdl-grid">
              <!-- Start Left Block -->
              {$left_block_html}
            </div>
          </div>
          <div id="main-block" class="mdl-cell mdl-shadow--2dp mdl-cell--8-col mdl-cell--8-col-tablet mdl-color--grey-200 mdl-grid">
              <script>
                document.getElementById("main-block").style.display="none";
              </script>
              <!-- Start art Block -->
              <article class="mdl-cell mdl-cell--12-col mdl-cell--top">
              {$flash_html}
              {$main_block_html}
              </article>
          </div>
        </div>
          <footer class="mdl-mini-footer">
              {$debug}
              {$contact}
          </footer>
      </main>
    </div>

    <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
        for="menu-left-col-menu">
      <li id="layout-top" class="mdl-menu__item">Layout Top</li>
      <li id="layout-right" class="mdl-menu__item">Layout Right</li>
      <li id="layout-bottom" class="mdl-menu__item">Layout Bottom</li>
      <li id="layout-left" class="mdl-menu__item">Layout Left</li>
    </ul>
\t</body>
</html>
EOD;
    }
Exemplo n.º 4
0
/**
 * Set (or extend) a flash-message cookie.
 *
 * This can optionally be done at the same time as saving a log message with log_*()
 *
 * Generally one should flash a message in onPageRequest and log a message wherever
 * the action actually takes place (eg onWhateverElse) - but much of the time, actions
 * are taken from within onPageRequest...
 *
 * @param string $text
 * @param string $type
 */
function flash_message($text, $type = "info")
{
    $current = get_prefixed_cookie("flash_message");
    if ($current) {
        $text = $current . "\n" . $text;
    }
    # the message should be viewed pretty much immediately,
    # so 60s timeout should be more than enough
    set_prefixed_cookie("flash_message", $text, time() + 60, "/");
}
Exemplo n.º 5
0
    /**
     * turns the Page into HTML
     */
    public function display_page(Page $page)
    {
        global $config;
        //$theme_name = $config->get_string('theme', 'default');
        $site_name = $config->get_string('title');
        $data_href = get_base_href();
        $main_page = $config->get_string('main_page');
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $main_block_html = "";
        $head_block_html = "";
        $sub_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $block->get_html(true);
                    break;
                case "head":
                    $head_block_html .= "<td width='250'><small>" . $block->get_html(false) . "</small></td>";
                    break;
                case "main":
                    $main_block_html .= $block->get_html(false);
                    break;
                case "subheading":
                    $sub_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>";
        /*$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
        
        		$wrapper = "";
        		if(strlen($page->heading) > 100) {
        			$wrapper = ' style="height: 3em; overflow: auto;"';
        		}
        		*/
        $flash = get_prefixed_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
{$header_html}
\t</head>

\t<body>
\t\t<header>
\t\t\t<table id="header" class="bgtop" width="100%" height="113px">
\t\t\t\t<tr>
\t\t\t\t\t<td><center>
\t\t\t\t\t\t<h1><a href="{$data_href}/{$main_page}">{$site_name}</a></h1>
\t\t\t\t\t\t<p>[Navigation links go here]
\t\t\t\t\t</center></td>
\t\t\t\t\t{$head_block_html}
\t\t\t\t</tr>
\t\t\t</table>
\t\t\t{$sub_block_html}
\t\t</header>
\t\t<nav>
\t\t\t{$left_block_html}
\t\t</nav>
\t\t<article>
\t\t\t{$flash_html}
\t\t\t{$main_block_html}
\t\t</article>
\t\t<footer>
\t\t\tImages &copy; their respective owners,
\t\t\t<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
\t\t\t<a href="http://www.shishnet.org/">Shish</a> &amp;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</footer>
\t</body>
</html>
EOD;
    }
Exemplo n.º 6
0
    public function display_page($page)
    {
        global $config, $user;
        $theme_name = $config->get_string('theme');
        //$base_href = $config->get_string('base_href');
        $data_href = get_base_href();
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $left_block_html = "";
        $user_block_html = "";
        $main_block_html = "";
        $sub_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $block->get_html(true);
                    break;
                case "user":
                    $user_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    break;
                case "subheading":
                    $sub_block_html .= $block->body;
                    // $this->block_to_html($block, true);
                    break;
                case "main":
                    if ($block->header == "Images") {
                        $block->header = "&nbsp;";
                    }
                    $main_block_html .= $block->get_html(false);
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>";
        if (empty($this->subheading)) {
            $subheading = "";
        } else {
            $subheading = "<div id='subtitle'>{$this->subheading}</div>";
        }
        $site_name = $config->get_string('title');
        // bzchan: change from normal default to get title for top of page
        $main_page = $config->get_string('main_page');
        // bzchan: change from normal default to get main page for top of page
        // bzchan: CUSTOM LINKS are prepared here, change these to whatever you like
        $custom_links = "";
        if ($user->is_anonymous()) {
            $custom_links .= $this->navlinks(make_link('user_admin/login'), "My Account", array("user", "user_admin", "setup", "admin"));
        } else {
            $custom_links .= $this->navlinks(make_link('user'), "My Account", array("user", "user_admin", "setup", "admin"));
        }
        $custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post"));
        $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment"));
        $custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags"));
        if (class_exists("Pools")) {
            $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", array("pool"));
        }
        $custom_links .= $this->navlinks(make_link('upload'), "Upload", array("upload"));
        if (class_exists("Wiki")) {
            $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki"));
            $custom_links .= $this->navlinks(make_link('wiki/more'), "More &raquo;", array("wiki/more"));
        }
        $custom_sublinks = "";
        // hack
        $username = url_escape($user->name);
        // hack
        $qp = explode("/", ltrim(@$_GET["q"], "/"));
        // php sucks
        switch ($qp[0]) {
            default:
                $custom_sublinks .= $user_block_html;
                break;
            case "":
                # FIXME: this assumes that the front page is
                # post/list; in 99% of case it will either be
                # post/list or home, and in the latter case
                # the subnav links aren't shown, but it would
                # be nice to be correct
            # FIXME: this assumes that the front page is
            # post/list; in 99% of case it will either be
            # post/list or home, and in the latter case
            # the subnav links aren't shown, but it would
            # be nice to be correct
            case "post":
            case "upload":
                if (class_exists("NumericScore")) {
                    $custom_sublinks .= "<li><b>Popular by </b><a href='" . make_link('popular_by_day') . "'>Day</a>/<a href='" . make_link('popular_by_month') . "'>Month</a>/<a href='" . make_link('popular_by_year') . "'>Year</a></li>";
                }
                $custom_sublinks .= "<li><a href='" . make_link('post/list') . "'>All</a></li>";
                if (class_exists("Favorites")) {
                    $custom_sublinks .= "<li><a href='" . make_link("post/list/favorited_by={$username}/1") . "'>My Favorites</a></li>";
                }
                if (class_exists("RSS_Images")) {
                    $custom_sublinks .= "<li><a href='" . make_link('rss/images') . "'>Feed</a></li>";
                }
                if (class_exists("RandomImage")) {
                    $custom_sublinks .= "<li><a href='" . make_link("random_image/view") . "'>Random Image</a></li>";
                }
                if (class_exists("Wiki")) {
                    $custom_sublinks .= "<li><a href='" . make_link("wiki/posts") . "'>Help</a></li>";
                } else {
                    $custom_sublinks .= "<li><a href='" . make_link("ext_doc/index") . "'>Help</a></li>";
                }
                break;
            case "comment":
                $custom_sublinks .= "<li><a href='" . make_link('comment/list') . "'>All</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/comment") . "'>Help</a></li>";
                break;
            case "pool":
                $custom_sublinks .= "<li><a href='" . make_link('pool/list') . "'>List</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("pool/new") . "'>Create</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("pool/updated") . "'>Changes</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/pools") . "'>Help</a></li>";
                break;
            case "wiki":
                $custom_sublinks .= "<li><a href='" . make_link('wiki') . "'>Index</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("wiki/rules") . "'>Rules</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/wiki") . "'>Help</a></li>";
                break;
            case "tags":
            case "alias":
                $custom_sublinks .= "<li><a href='" . make_link('tags/map') . "'>Map</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('tags/alphabetic') . "'>Alphabetic</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('tags/popularity') . "'>Popularity</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('tags/categories') . "'>Categories</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link('alias/list') . "'>Aliases</a></li>";
                $custom_sublinks .= "<li><a href='" . make_link("ext_doc/tag_edit") . "'>Help</a></li>";
                break;
        }
        // bzchan: failed attempt to add heading after title_link (failure was it looked bad)
        //if($this->heading==$site_name)$this->heading = '';
        //$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
        // bzchan: prepare main title link
        $title_link = "<h1 id='site-title'><a href='" . make_link($main_page) . "'>{$site_name}</a></h1>";
        if ($page->left_enabled) {
            $left = "<nav>{$left_block_html}</nav>";
            $withleft = "withleft";
        } else {
            $left = "";
            $withleft = "noleft";
        }
        $flash = get_prefixed_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
{$header_html}
\t\t<script src='{$data_href}/themes/{$theme_name}/script.js' type='text/javascript'></script>
\t</head>

\t<body>
\t\t<header>
\t\t\t{$title_link}
\t\t\t<ul id="navbar" class="flat-list">
\t\t\t\t{$custom_links}
\t\t\t</ul>
\t\t\t<ul id="subnavbar" class="flat-list">
\t\t\t\t{$custom_sublinks}
\t\t\t</ul>
\t\t</header>
\t\t{$subheading}
\t\t{$sub_block_html}
\t\t{$left}
\t\t<article class="{$withleft}">
\t\t\t{$flash_html}
\t\t\t{$main_block_html}
\t\t</article>
\t\t<footer><em>
\t\t\tImages &copy; their respective owners,
\t\t\t<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
\t\t\t<a href="http://www.shishnet.org/">Shish</a> &amp;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.
\t\t\t{$debug}
\t\t\t{$contact}
        </em></footer>
\t</body>
</html>
EOD;
    }
Exemplo n.º 7
0
    /**
     * turns the Page into HTML.
     *
     * @param Page $page
     */
    public function display_page(Page $page)
    {
        global $config, $user;
        $theme_name = $config->get_string('theme', 'lite');
        $site_name = $config->get_string('title');
        $data_href = get_base_href();
        $contact_link = $config->get_string('contact_link');
        $header_html = "";
        ksort($page->html_headers);
        foreach ($page->html_headers as $line) {
            $header_html .= "\t\t{$line}\n";
        }
        $menu = "<div class='menu'>\n\t\t\t<script type='text/javascript' src='{$data_href}/themes/{$theme_name}/wz_tooltip.js'></script>\n\t\t\t<a href='" . make_link() . "' onmouseover='Tip(&#39;Home&#39;, BGCOLOR, &#39;#C3D2E0&#39;, FADEIN, 100)' onmouseout='UnTip()'><img src='{$data_href}/favicon.ico' style='position: relative; top: 3px;'></a>\n\t\t\t<b>{$site_name}</b> ";
        // Custom links: These appear on the menu.
        $custom_links = "";
        if ($user->is_anonymous()) {
            $custom_links .= $this->navlinks(make_link('user_admin/login'), "Account", array("user", "user_admin", "setup", "admin", "profile"));
        } else {
            $custom_links .= $this->navlinks(make_link('user'), "Account", array("user", "setup", "user_admin", "admin", "profile"));
        }
        $custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post", "view"));
        $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment"));
        $custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags"));
        if (class_exists("Pools")) {
            $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", array("pool"));
        }
        $custom_links .= $this->navlinks(make_link('upload'), "Upload", array("upload"));
        if (class_exists("Wiki")) {
            $custom_links .= $this->navlinks(make_link('wiki/rules'), "Rules", array("wiki/rules"));
            $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki"));
        }
        $menu .= "{$custom_links}</div>";
        $left_block_html = "";
        $main_block_html = "";
        $sub_block_html = "";
        $user_block_html = "";
        foreach ($page->blocks as $block) {
            switch ($block->section) {
                case "left":
                    $left_block_html .= $this->block_to_html($block, true, "left");
                    break;
                case "main":
                    $main_block_html .= $this->block_to_html($block, false, "main");
                    break;
                case "user":
                    $user_block_html .= $block->body;
                    break;
                case "subheading":
                    $sub_block_html .= $this->block_to_html($block, false, "main");
                    break;
                default:
                    print "<p>error: {$block->header} using an unknown section ({$block->section})";
                    break;
            }
        }
        $custom_sublinks = "<div class='sbar'>";
        // hack
        $username = url_escape($user->name);
        // hack
        $qp = explode("/", ltrim(@$_GET["q"], "/"));
        $cs = "";
        // php sucks
        switch ($qp[0]) {
            default:
                $cs = $user_block_html;
                break;
            case "":
                # FIXME: this assumes that the front page is
                # post/list; in 99% of case it will either be
                # post/list or home, and in the latter case
                # the subnav links aren't shown, but it would
                # be nice to be correct
            # FIXME: this assumes that the front page is
            # post/list; in 99% of case it will either be
            # post/list or home, and in the latter case
            # the subnav links aren't shown, but it would
            # be nice to be correct
            case "post":
                if (class_exists("NumericScore")) {
                    $cs .= "<b>Popular by </b><a href='" . make_link('popular_by_day') . "'>Day</a><b>/</b><a href='" . make_link('popular_by_month') . "'>Month</a><b>/</b><a href='" . make_link('popular_by_year') . "'>Year</a> ";
                }
                $cs .= "<a class='tab' href='" . make_link('post/list') . "'>All</a>";
                if (class_exists("Favorites")) {
                    $cs .= "<a class='tab' href='" . make_link("post/list/favorited_by={$username}/1") . "'>My Favorites</a>";
                }
                if (class_exists("RSS_Images")) {
                    $cs .= "<a class='tab' href='" . make_link('rss/images') . "'>Feed</a>";
                }
                if (class_exists("Random_Image")) {
                    $cs .= "<a class='tab' href='" . make_link("random_image/view") . "'>Random Image</a>";
                }
                if (class_exists("Wiki")) {
                    $cs .= "<a class='tab' href='" . make_link("wiki/posts") . "'>Help</a>";
                } else {
                    $cs .= "<a class='tab' href='" . make_link("ext_doc/index") . "'>Help</a>";
                }
                break;
            case "comment":
                $cs .= "<a class='tab' href='" . make_link('comment/list') . "'>All</a>";
                $cs .= "<a class='tab' href='" . make_link('rss/comments') . "'>Feed</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/comment") . "'>Help</a>";
                break;
            case "pool":
                $cs .= "<a class='tab' href='" . make_link('pool/list') . "'>List</a>";
                $cs .= "<a class='tab' href='" . make_link("pool/new") . "'>Create</a>";
                $cs .= "<a class='tab' href='" . make_link("pool/updated") . "'>Changes</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/pools") . "'>Help</a>";
                break;
            case "wiki":
                $cs .= "<a class='tab' href='" . make_link('wiki') . "'>Index</a>";
                $cs .= "<a class='tab' href='" . make_link("wiki/rules") . "'>Rules</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/wiki") . "'>Help</a>";
                break;
            case "tags":
            case "alias":
                $cs .= "<a class='tab' href='" . make_link('tags/map') . "'>Map</a>";
                $cs .= "<a class='tab' href='" . make_link('tags/alphabetic') . "'>Alphabetic</a>";
                $cs .= "<a class='tab' href='" . make_link('tags/popularity') . "'>Popularity</a>";
                $cs .= "<a class='tab' href='" . make_link('tags/categories') . "'>Categories</a>";
                $cs .= "<a class='tab' href='" . make_link('alias/list') . "'>Aliases</a>";
                $cs .= "<a class='tab' href='" . make_link("ext_doc/tag_edit") . "'>Help</a>";
                break;
            case "upload":
                if (class_exists("Wiki")) {
                    $cs .= "<a class='tab' href='" . make_link("wiki/upload_guidelines") . "'>Guidelines</a>";
                }
                break;
            case "random":
                $cs .= "<a class='tab' href='" . make_link('random/view') . "'>Shuffle</a>";
                $cs .= "<a class='tab' href='" . make_link('random/download') . "'>Download</a>";
                break;
            case "featured":
                $cs .= "<a class='tab' href='" . make_link('featured/download') . "'>Download</a>";
                break;
        }
        if ($cs == "") {
            $custom_sublinks = "";
        } else {
            $custom_sublinks .= "{$cs}</div>";
        }
        $debug = get_debug_info();
        $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>";
        //$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
        /*$wrapper = "";
        		if(strlen($page->heading) > 100) {
        			$wrapper = ' style="height: 3em; overflow: auto;"';
        		}*/
        if ($page->left_enabled == false) {
            $left_block_html = "";
            $main_block_html = "<article id='body_noleft'>{$main_block_html}</article>";
        } else {
            $left_block_html = "<nav>{$left_block_html}</nav>";
            $main_block_html = "<article>{$main_block_html}</article>";
        }
        $flash = get_prefixed_cookie("flash_message");
        $flash_html = "";
        if ($flash) {
            $flash_html = "<b id='flash'>" . nl2br(html_escape($flash)) . " <a href='#' onclick=\"\$('#flash').hide(); return false;\">[X]</a></b>";
            set_prefixed_cookie("flash_message", "", -1, "/");
        }
        print <<<EOD
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
\t<head>
\t\t<title>{$page->title}</title>
\t\t{$header_html}
\t</head>

\t<body>
\t\t<header>
\t\t\t{$menu}
\t\t\t{$custom_sublinks}
\t\t\t{$sub_block_html}
\t\t</header>
\t\t{$left_block_html}
\t\t{$flash_html}
\t\t{$main_block_html}
\t\t<footer>
\t\t\tImages &copy; their respective owners,
\t\t\t<a href="http://code.shishnet.org/shimmie2/">Shimmie</a> &copy;
\t\t\t<a href="http://www.shishnet.org/">Shish</a> &amp;
\t\t\t<a href="https://github.com/shish/shimmie2/graphs/contributors">The Team</a>
\t\t\t2007-2014,
\t\t\tbased on the Danbooru concept.<br />
\t\t\tLite Theme by <a href="http://seemslegit.com">Zach</a>
\t\t\t{$debug}
\t\t\t{$contact}
\t\t</footer>
\t</body>
</html>
EOD;
    }
Exemplo n.º 8
0
 private function comment_checks($image_id, User $user, $comment)
 {
     global $config;
     // basic sanity checks
     if (!$user->can("create_comment")) {
         throw new CommentPostingException("Anonymous posting has been disabled");
     } else {
         if (is_null(Image::by_id($image_id))) {
             throw new CommentPostingException("The image does not exist");
         } else {
             if (trim($comment) == "") {
                 throw new CommentPostingException("Comments need text...");
             } else {
                 if (strlen($comment) > 9000) {
                     throw new CommentPostingException("Comment too long~");
                 } else {
                     if (strlen($comment) / strlen(gzcompress($comment)) > 10) {
                         throw new CommentPostingException("Comment too repetitive~");
                     } else {
                         if ($user->is_anonymous() && !$this->hash_match()) {
                             set_prefixed_cookie("nocache", "Anonymous Commenter", time() + 60 * 60 * 24, "/");
                             throw new CommentPostingException("Comment submission form is out of date; refresh the " . "comment form to show you aren't a spammer~");
                         } else {
                             if ($this->is_comment_limit_hit()) {
                                 throw new CommentPostingException("You've posted several comments recently; wait a minute and try again...");
                             } else {
                                 if ($this->is_dupe($image_id, $comment)) {
                                     throw new CommentPostingException("Someone already made that comment on that image -- try and be more original?");
                                 } else {
                                     if ($config->get_bool('comment_captcha') && !captcha_check()) {
                                         throw new CommentPostingException("Error in captcha");
                                     } else {
                                         if ($user->is_anonymous() && $this->is_spam_akismet($comment)) {
                                             throw new CommentPostingException("Akismet thinks that your comment is spam. Try rewriting the comment, or logging in.");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }