Пример #1
0
function make_item($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $mkname = $GLOBALS['__POST']["mkname"];
    $mktype = $GLOBALS['__POST']["mktype"];
    $mkname = basename(stripslashes($mkname));
    if ($mkname == "") {
        show_error($GLOBALS["error_msg"]["miscnoname"]);
    }
    $new = get_abs_item($dir, $mkname);
    if (@file_exists($new)) {
        show_error($mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
    }
    if ($mktype != "file") {
        $ok = @mkdir($new, 0777);
        $err = $GLOBALS["error_msg"]["createdir"];
    } else {
        $ok = @touch($new);
        $err = $GLOBALS["error_msg"]["createfile"];
    }
    if ($ok === false) {
        show_error($err);
    }
    header("Location: " . make_link("list", $dir, NULL));
}
Пример #2
0
 protected function comment_to_html($comment, $trim = false)
 {
     $inner_id = $this->inner_id;
     // because custom themes can't add params, because PHP
     global $user;
     $tfe = new TextFormattingEvent($comment->comment);
     send_event($tfe);
     //$i_uid = int_escape($comment->owner_id);
     $h_name = html_escape($comment->owner_name);
     //$h_poster_ip = html_escape($comment->poster_ip);
     $h_comment = $trim ? substr($tfe->stripped, 0, 50) . "..." : $tfe->formatted;
     $i_comment_id = int_escape($comment->comment_id);
     $i_image_id = int_escape($comment->image_id);
     $stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50));
     $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
     $h_userlink = "<a href='" . make_link("user/{$h_name}") . "'>{$h_name}</a>";
     $h_date = $comment->posted;
     $h_del = $user->can("delete_comment") ? ' - <a onclick="return confirm(\'Delete comment by ' . $h_name . ':\\n' . $stripped_nonl . '\');" ' . 'href="' . make_link('comment/delete/' . $i_comment_id . '/' . $i_image_id) . '">Del</a>' : '';
     $h_reply = "[<a href='" . make_link("post/view/{$i_image_id}") . "'>Reply</a>]";
     if ($inner_id == 0) {
         return "<div class='comment' style='margin-top: 8px;'>{$h_userlink}{$h_del} {$h_date} No.{$i_comment_id} {$h_reply}<p>{$h_comment}</p></div>";
     } else {
         return "<table><tr><td nowrap class='doubledash'>&gt;&gt;</td><td>" . "<div class='reply'>{$h_userlink}{$h_del} {$h_date} No.{$i_comment_id} {$h_reply}<p>{$h_comment}</p></div>" . "</td></tr></table>";
     }
 }
Пример #3
0
 public function get_voter_html(Image $image)
 {
     $i_image_id = int_escape($image->id);
     $i_score = int_escape($image->numeric_score);
     $html = "\n\t\t\tCurrent Score: {$i_score}\n\n\t\t\t<p><form action='" . make_link("numeric_score_vote") . "' method='POST'>\n\t\t\t<input type='hidden' name='image_id' value='{$i_image_id}'>\n\t\t\t<input type='hidden' name='vote' value='up'>\n\t\t\t<input type='submit' value='Vote Up'>\n\t\t\t</form>\n\n\t\t\t<form action='" . make_link("numeric_score_vote") . "' method='POST'>\n\t\t\t<input type='hidden' name='image_id' value='{$i_image_id}'>\n\t\t\t<input type='hidden' name='vote' value='null'>\n\t\t\t<input type='submit' value='Remove Vote'>\n\t\t\t</form>\n\n\t\t\t<form action='" . make_link("numeric_score_vote") . "' method='POST'>\n\t\t\t<input type='hidden' name='image_id' value='{$i_image_id}'>\n\t\t\t<input type='hidden' name='vote' value='down'>\n\t\t\t<input type='submit' value='Vote Down'>\n\t\t\t</form>\n\t\t";
     return $html;
 }
Пример #4
0
 public function display_aliases(Page $page, $aliases, $is_admin, $pageNumber, $totalPages)
 {
     if ($is_admin) {
         $action = "<th width='10%'>Action</th>";
         $add = "\n\t\t\t\t<tr>\n\t\t\t\t\t<form action='" . make_link("alias/add") . "' method='POST'>\n\t\t\t\t\t\t<td><input type='text' name='oldtag'></td>\n\t\t\t\t\t\t<td><input type='text' name='newtag'></td>\n\t\t\t\t\t\t<td><input type='submit' value='Add'></td>\n\t\t\t\t\t</form>\n\t\t\t\t</tr>\n\t\t\t";
     } else {
         $action = "";
         $add = "";
     }
     $h_aliases = "";
     $n = 0;
     foreach ($aliases as $old => $new) {
         $h_old = html_escape($old);
         $h_new = "<a href='" . make_link("post/list/" . url_escape($new) . "/1") . "'>" . html_escape($new) . "</a>";
         $oe = $n++ % 2 == 0 ? "even" : "odd";
         $h_aliases .= "<tr class='{$oe}'><td>{$h_old}</td><td>{$h_new}</td>";
         if ($is_admin) {
             $h_aliases .= "\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<form action='" . make_link("alias/remove") . "' method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='oldtag' value='{$h_old}'>\n\t\t\t\t\t\t\t<input type='submit' value='Remove'>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t</td>\n\t\t\t\t";
         }
         $h_aliases .= "</tr>";
     }
     $html = "\n\t\t\t<script>\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$(\"#aliases\").tablesorter();\n\t\t\t});\n\t\t\t</script>\n\t\t\t<table id='aliases' class='zebra'>\n\t\t\t\t<thead><tr><th>From</th><th>To</th>{$action}</tr></thead>\n\t\t\t\t<tbody>{$h_aliases}</tbody>\n\t\t\t\t<tfoot>{$add}</tfoot>\n\t\t\t</table>\n\t\t\t<p><a href='" . make_link("alias/export/aliases.csv") . "'>Download as CSV</a></p>\n\t\t";
     $bulk_html = "\n\t\t\t<form enctype='multipart/form-data' action='" . make_link("alias/import") . "' method='POST'>\n\t\t\t\t<input type='file' name='alias_file'>\n\t\t\t\t<input type='submit' value='Upload List'>\n\t\t\t</form>\n\t\t";
     $page->set_title("Alias List");
     $page->set_heading("Alias List");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Aliases", $html));
     if ($is_admin) {
         $page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
     }
     $this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
 }
Пример #5
0
 public function onPageRequest($event)
 {
     global $config, $page, $user;
     if ($event->page_matches("featured_image")) {
         if ($event->get_arg(0) == "set" && $user->check_auth_token()) {
             if ($user->is_admin() && isset($_POST['image_id'])) {
                 $id = int_escape($_POST['image_id']);
                 if ($id > 0) {
                     $config->set_int("featured_id", $id);
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("post/view/{$id}"));
                 }
             }
         }
         if ($event->get_arg(0) == "download") {
             $image = Image::by_id($config->get_int("featured_id"));
             if (!is_null($image)) {
                 $page->set_mode("data");
                 $page->set_type("image/jpeg");
                 $page->set_data(file_get_contents($image->get_image_filename()));
             }
         }
         if ($event->get_arg(0) == "view") {
             $image = Image::by_id($config->get_int("featured_id"));
             if (!is_null($image)) {
                 send_event(new DisplayingImageEvent($image, $page));
             }
         }
     }
 }
Пример #6
0
function do_styles($has_pipes = true, $uc = false, $start = 0, $end = 0, $sep = ' | ')
{
    global $styles, $image, $page, $style;
    $x = count($styles);
    for ($i = 0; $i < $x; ++$i) {
        if ($start) {
            echo $start;
        }
        if ($uc == false) {
            $echo_text = $styles[$i];
        } else {
            $echo_text = ucwords($styles[$i]);
        }
        if ($style != $styles[$i]) {
            echo make_link(array('page' => $page, 'image' => $image, 'style' => $styles[$i], 'text' => $echo_text));
        } else {
            echo $echo_text;
        }
        if ($has_pipes && $i < $x - 1) {
            echo $sep;
        }
        if ($end) {
            echo $end;
        }
    }
    return;
}
Пример #7
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Blocks");
     $sb->add_label("See <a href='" . make_link("ext_doc/blocks") . "'>the docs</a> for formatting");
     $sb->add_longtext_option("blocks_text");
     $event->panel->add_block($sb);
 }
Пример #8
0
/**
If no user is logged in, show the login option
*/
function show_login()
{
    if (login_ok()) {
        return;
    }
    echo '<small> - <a href="' . make_link("login", NULL) . '">' . $GLOBALS['messages']['btnlogin'] . "</a></small>";
}
Пример #9
0
 protected function build_navigation($page_number, $total_pages, $search_terms)
 {
     $h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
     $h_search_link = make_link();
     $h_search = "\n\t\t\t<p><form action='{$h_search_link}' method='GET'>\n\t\t\t\t<input name='search' type='text'\n\t\t\t\t\t\tvalue='{$h_search_string}' autocomplete='off' />\n\t\t\t\t<input type='hidden' name='q' value='/post/list'>\n\t\t\t\t<input type='submit' value='Find' style='display: none;' />\n\t\t\t</form>\n\t\t\t<div id='search_completions'></div>";
     return $h_search;
 }
Пример #10
0
 public function display_admin_block()
 {
     global $page, $config;
     $html = "" . "<b>Current Commit</b>: " . $config->get_string('commit_hash') . " | (" . $config->get_string('update_time') . ")" . "<br><b>Latest Commit</b>: <span id='updatecheck'>Loading...</span>" . "<br><a href='" . make_link('update/download') . "' id='updatelink'></a>";
     //TODO: Show warning before use.
     $page->add_block(new Block("Software Update", $html, "main", 75));
 }
Пример #11
0
 public function onUserBlockBuilding($event)
 {
     global $user;
     if ($user->is_admin()) {
         $event->add_link("Tips Editor", make_link("tips/list"));
     }
 }
Пример #12
0
 public function onUserBlockBuilding(UserBlockBuildingEvent $event)
 {
     global $user;
     if ($user->can("ban_image")) {
         $event->add_link("UnTags", make_link("untag/list/1"));
     }
 }
Пример #13
0
 public function display_image_banner(Page $page, Image $image)
 {
     global $config;
     $i_image = int_escape($image->id);
     $html = "\n\t\t\t<form action='" . make_link("image_report/add") . "' method='POST'>\n\t\t\t\t<input type='hidden' name='image_id' value='{$i_image}'>\n\t\t\t\t<input type='text' name='reason' value='Please enter a reason' onclick='this.value=\"\";'>\n\t\t\t\t<input type='submit' value='Report'>\n\t\t\t</form>\n\t\t";
     $page->add_block(new Block("Report Image", $html, "left"));
 }
Пример #14
0
 public function display_mass_tagger(Page $page, Event $event, $config)
 {
     $data_href = get_base_href();
     $body = "\n\t\t\t<form action='" . make_link("mass_tagger/tag") . "' method='POST'>\n\t\t\t\t<input id='mass_tagger_activate' type='button' onclick='activate_mass_tagger(\"{$data_href}\");' value='Activate'/>\n\t\t\t\t<div id='mass_tagger_controls' style='display: none;'>\n\t\t\t\t\tClick on images to mark them. Use the 'Index Options' in the Board Config to increase the amount of shown images.\n\t\t\t\t\t<br />\n\t\t\t\t\t<input type='hidden' name='ids' id='mass_tagger_ids' />\n\t\t\t\t\tSet instead of add? <input type='checkbox' name='setadd' value='set' />\n\t\t\t\t\t<label>Tags: <input type='text' name='tag' /></label>\n\n\t\t\t\t\t<input type='submit' value='Tag Marked Images' />\n\t\t\t\t</div>\n\t\t\t</form>\n\t\t";
     $block = new Block("Mass Tagger", $body, "left", 50);
     $page->add_block($block);
 }
Пример #15
0
 public function display_image(Page $page, Image $image)
 {
     $ilink = make_link("get_svg/{$image->id}/{$image->id}.svg");
     //		$ilink = $image->get_image_link();
     $html = "\n\t\t\t<object data='{$ilink}' type='image/svg+xml' width='{$image->width}' height='{$image->height}'>\n\t\t\t    <embed src='{$ilink}' type='image/svg+xml' width='{$image->width}' height='{$image->height}' />\n\t\t\t</object>\n\t\t";
     $page->add_block(new Block("Image", $html, "main", 0));
 }
Пример #16
0
 /**
  * @param int $page_number
  * @param int $total_pages
  * @param string[] $search_terms
  * @return string
  */
 protected function build_navigation($page_number, $total_pages, $search_terms)
 {
     $h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
     $h_search_link = make_link();
     $h_search = "\n\t\t\t<p><form action='{$h_search_link}' method='GET'>\n\t\t\t\t<input name='search' type='text' value='{$h_search_string}' class='autocomplete_tags' placeholder=''  style='width:75%'/>\n\t\t\t\t<input type='submit' value='Go' style='width:20%'>\n\t\t\t\t<input type='hidden' name='q' value='/post/list'>\n\t\t\t</form>\n\t\t\t<div id='search_completions'></div>";
     return $h_search;
 }
Пример #17
0
 private function build_stats(Image $image)
 {
     $h_owner = html_escape($image->get_owner()->name);
     $h_ownerlink = "<a href='" . make_link("user/{$h_owner}") . "'>{$h_owner}</a>";
     $h_ip = html_escape($image->owner_ip);
     $h_date = autodate($image->posted);
     $h_filesize = to_shorthand_int($image->filesize);
     global $user;
     if ($user->can("view_ip")) {
         $h_ownerlink .= " ({$h_ip})";
     }
     $html = "\n\t\tId: {$image->id}\n\t\t<br>Posted: {$h_date} by {$h_ownerlink}\n\t\t<br>Size: {$image->width}x{$image->height}\n\t\t<br>Filesize: {$h_filesize}\n\t\t";
     if (!is_null($image->source)) {
         $h_source = html_escape($image->source);
         if (substr($image->source, 0, 7) != "http://" && substr($image->source, 0, 8) != "https://") {
             $h_source = "http://" . $h_source;
         }
         $html .= "<br>Source: <a href='{$h_source}'>link</a>";
     }
     if (class_exists("Ratings")) {
         if ($image->rating == null || $image->rating == "u") {
             $image->rating = "u";
         }
         $h_rating = Ratings::rating_to_human($image->rating);
         $html .= "<br>Rating: {$h_rating}";
     }
     return $html;
 }
Пример #18
0
 /**
  * Show a page of aliases.
  *
  * Note: $can_manage = whether things like "add new alias" should be shown
  *
  * @param array $aliases An array of ($old_tag => $new_tag)
  * @param int $pageNumber
  * @param int $totalPages
  */
 public function display_aliases($aliases, $pageNumber, $totalPages)
 {
     global $page, $user;
     $can_manage = $user->can("manage_alias_list");
     if ($can_manage) {
         $h_action = "<th width='10%'>Action</th>";
         $h_add = "\n\t\t\t\t<tr>\n\t\t\t\t\t" . make_form(make_link("alias/add")) . "\n\t\t\t\t\t\t<td><input type='text' name='oldtag'></td>\n\t\t\t\t\t\t<td><input type='text' name='newtag'></td>\n\t\t\t\t\t\t<td><input type='submit' value='Add'></td>\n\t\t\t\t\t</form>\n\t\t\t\t</tr>\n\t\t\t";
     } else {
         $h_action = "";
         $h_add = "";
     }
     $h_aliases = "";
     foreach ($aliases as $old => $new) {
         $h_old = html_escape($old);
         $h_new = "<a href='" . make_link("post/list/" . url_escape($new) . "/1") . "'>" . html_escape($new) . "</a>";
         $h_aliases .= "<tr><td>{$h_old}</td><td>{$h_new}</td>";
         if ($can_manage) {
             $h_aliases .= "\n\t\t\t\t\t<td>\n\t\t\t\t\t\t" . make_form(make_link("alias/remove")) . "\n\t\t\t\t\t\t\t<input type='hidden' name='oldtag' value='{$h_old}'>\n\t\t\t\t\t\t\t<input type='submit' value='Remove'>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t</td>\n\t\t\t\t";
         }
         $h_aliases .= "</tr>";
     }
     $html = "\n\t\t\t<table id='aliases' class='sortable zebra'>\n\t\t\t\t<thead><tr><th>From</th><th>To</th>{$h_action}</tr></thead>\n\t\t\t\t<tbody>{$h_aliases}</tbody>\n\t\t\t\t<tfoot>{$h_add}</tfoot>\n\t\t\t</table>\n\t\t\t<p><a href='" . make_link("alias/export/aliases.csv") . "'>Download as CSV</a></p>\n\t\t";
     $bulk_html = "\n\t\t\t" . make_form(make_link("alias/import"), 'post', true) . "\n\t\t\t\t<input type='file' name='alias_file'>\n\t\t\t\t<input type='submit' value='Upload List'>\n\t\t\t</form>\n\t\t";
     $page->set_title("Alias List");
     $page->set_heading("Alias List");
     $page->add_block(new NavBlock());
     $page->add_block(new Block("Aliases", $html));
     if ($can_manage) {
         $page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
     }
     $this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
 }
Пример #19
0
 public function onPageRequest(PageRequestEvent $event)
 {
     global $config, $user, $page;
     if ($user->is_admin() && isset($_GET['sha'])) {
         if ($event->page_matches("update/download")) {
             $ok = $this->download_shimmie();
             $page->set_mode("redirect");
             if ($ok) {
                 $page->set_redirect(make_link("update/update", "sha=" . $_GET['sha']));
             } else {
                 $page->set_redirect(make_link("admin"));
             }
             //TODO: Show error?
         } elseif ($event->page_matches("update/update")) {
             $ok = $this->update_shimmie();
             $page->set_mode("redirect");
             if ($ok) {
                 $page->set_redirect(make_link("admin"));
             } else {
                 $page->set_redirect(make_link("admin"));
             }
             //TODO: Show error?
         }
     }
 }
Пример #20
0
 public function onUserBlockBuilding(UserBlockBuildingEvent $event)
 {
     global $user;
     if ($user->can("view_sysinfo")) {
         $event->add_link("System Info", make_link("system_info"));
     }
 }
Пример #21
0
 public function onUserBlockBuilding($event)
 {
     global $user;
     if ($user->is_admin()) {
         $event->add_link("Event Log", make_link("log/view"));
     }
 }
Пример #22
0
 private function data(Image $image)
 {
     global $config;
     $text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format"));
     $text_link = trim($text_link) == "" ? null : $text_link;
     // null blank setting so the url gets filled in on the text links.
     return array('thumb_src' => make_http($image->get_thumb_link()), 'image_src' => make_http($image->get_image_link()), 'post_link' => make_http(make_link("post/view/{$image->id}")), 'text_link' => $text_link);
 }
Пример #23
0
 public function onInitExt(InitExtEvent $event)
 {
     global $config;
     $config->set_default_string("mail_sub", $config->get_string("site_title") . " - ");
     $config->set_default_string("mail_img", make_http("ext/mail/banner.png"));
     $config->set_default_string("mail_style", make_http("ext/mail/mail.css"));
     $config->set_default_string("mail_fot", "<a href='" . make_http(make_link()) . "'>" . $config->get_string("site_title") . "</a>");
 }
Пример #24
0
 protected function build_options($duser)
 {
     global $database;
     global $config;
     $html = "";
     $html .= "\n\t\t<form action='" . make_link("user_admin/change_pass") . "' method='POST'>\n\t\t\t<input type='hidden' name='name' value='{$duser->name}'>\n\t\t\t<input type='hidden' name='id' value='{$duser->id}'>\n\t\t\t<table style='width: 300px;'>\n\t\t\t\t<tr><td colspan='2'>Change Password</td></tr>\n\t\t\t\t<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>\n\t\t\t\t<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>\n\t\t\t\t<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>\n\t\t\t</table>\n\t\t</form>\n\t\t";
     return $html;
 }
Пример #25
0
function make_links($array)
{
    $output = "<ul>";
    foreach ($array as $key => $value) {
        $output .= "<li>" . make_link($value) . "</li>";
    }
    return $output . "</ul>";
}
Пример #26
0
 public function build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text)
 {
     $main_links_html = empty($main_links) ? "" : "<div class='space' id='links'>{$main_links}</div>";
     $message_html = empty($main_text) ? "" : "<div class='space' id='message'>{$main_text}</div>";
     $counter_html = empty($counter_text) ? "" : "<div class='space' id='counter'>{$counter_text}</div>";
     $search_html = "\n\t\t\t<div class='space' id='search'>\n\t\t\t\t<form action='" . make_link("post/list") . "' method='GET'>\n\t\t\t\t<input id='search_input' name='search' size='30' type='text' value='' autocomplete='off' />\n\t\t\t\t<input type='hidden' name='q' value='/post/list'>\n\t\t\t\t<input type='submit' value='Search'/>\n\t\t\t\t</form>\n\t\t\t</div>\n\t\t";
     return "\n\t\t<div id='front-page'>\n\t\t\t<h1><a style='text-decoration: none;' href='" . make_link() . "'><span>{$sitename}</span></a></h1>\n\t\t\t{$main_links_html}\n\t\t\t{$search_html}\n\t\t\t{$message_html}\n\t\t\t{$counter_html}\n\t\t\t<div class='space' id='foot'>\n\t\t\t\t<small><small>\n\t\t\t\t<a href='mailto:{$contact_link}'>Contact</a> &ndash; Serving {$num_comma} posts &ndash;\n\t\t\t\tRunning <a href='http://code.shishnet.org/shimmie2/'>Shimmie</a>\n\t\t\t\t</small></small>\n\t\t\t</div>\n\t\t</div>";
 }
Пример #27
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_edit")) {
         if ($event->get_arg(0) == "replace") {
             if ($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
                 $search = $_POST['search'];
                 $replace = $_POST['replace'];
                 $this->mass_tag_edit($search, $replace);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof ImageInfoSetEvent) {
         if ($this->can_tag()) {
             send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
             if ($this->can_source()) {
                 send_event(new SourceSetEvent($event->image, $_POST['tag_edit__source']));
             }
         } else {
             $this->theme->display_error($page, "Error", "Anonymous tag editing is disabled");
         }
     }
     if ($event instanceof TagSetEvent) {
         $event->image->set_tags($event->tags);
     }
     if ($event instanceof SourceSetEvent) {
         $event->image->set_source($event->source);
     }
     if ($event instanceof ImageDeletionEvent) {
         $event->image->delete_tags_from_image();
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_mass_editor($page);
     }
     // When an alias is added, oldtag becomes inaccessable
     if ($event instanceof AddAliasEvent) {
         $this->mass_tag_edit($event->oldtag, $event->newtag);
     }
     if ($event instanceof ImageInfoBoxBuildingEvent) {
         if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_tag_editor_html($event->image), 40);
         }
         if ($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_source_editor_html($event->image), 41);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Editing");
         $sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
         $sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
         $event->panel->add_block($sb);
     }
 }
Пример #28
0
function plugin_read_action()
{
    global $vars, $_title_invalidwn, $_msg_invalidiwn;
    $page = isset($vars['page']) ? $vars['page'] : '';
    if (is_page($page)) {
        // ページを表示
        check_readable($page, true, true);
        header_lastmod($page);
        return array('msg' => '', 'body' => '');
        // } else if (! PKWK_SAFE_MODE && is_interwiki($page)) {
    } else {
        if (!auth::check_role('safemode') && is_interwiki($page)) {
            return do_plugin_action('interwiki');
            // InterWikiNameを処理
        } else {
            if (is_pagename($page)) {
                $realpages = get_autoaliases($page);
                if (count($realpages) == 1) {
                    $realpage = $realpages[0];
                    if (is_page($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        header('Location: ' . get_page_location_uri($realpage));
                        return;
                    } elseif (is_url($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        header('Location: ' . $realpage);
                        return;
                    } elseif (is_interwiki($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        $vars['page'] = $realpage;
                        return do_plugin_action('interwiki');
                        // header('Location');
                    } else {
                        // 存在しない場合、直接編集フォームに飛ばす // To avoid infinite loop
                        header('Location: ' . get_location_uri('edit', $realpage));
                        return;
                    }
                } elseif (count($realpages) >= 2) {
                    $body = '<p>';
                    $body .= _('This pagename is an alias to') . '<br />';
                    $link = '';
                    foreach ($realpages as $realpage) {
                        $link .= '[[' . $realpage . '>' . $realpage . ']]&br;';
                    }
                    $body .= make_link($link);
                    $body .= '</p>';
                    return array('msg' => _('Redirect'), 'body' => $body);
                }
                $vars['cmd'] = 'edit';
                return do_plugin_action('edit');
                // 存在しないので、編集フォームを表示
            } else {
                // 無効なページ名
                return array('msg' => $_title_invalidwn, 'body' => str_replace('$1', htmlspecialchars($page), str_replace('$2', 'WikiName', $_msg_invalidiwn)));
            }
        }
    }
}
Пример #29
0
 public function get_user_editor_html(Image $image)
 {
     global $user;
     $h_owner = html_escape($image->get_owner()->name);
     $h_av = $image->get_owner()->get_avatar_html();
     $h_date = autodate($image->posted);
     $h_ip = $user->can("view_ip") ? " (" . show_ip($image->owner_ip, "Image posted {$image->posted}") . ")" : "";
     return "\n\t\t\t<tr>\n\t\t\t\t<th>Uploader</th>\n\t\t\t\t<td>\n\t\t" . ($user->can("edit_image_owner") ? "\n\t\t\t\t\t<span class='view'><a class='username' href='" . make_link("user/{$h_owner}") . "'>{$h_owner}</a>{$h_ip}, {$h_date}</span>\n\t\t\t\t\t<input class='edit' type='text' name='tag_edit__owner' value='{$h_owner}'>\n\t\t" : "\n\t\t\t\t\t<a class='username' href='" . make_link("user/{$h_owner}") . "'>{$h_owner}</a>{$h_ip}, {$h_date}\n\t\t") . "\n\t\t\t\t</td>\n\t\t\t\t<td width='80px' rowspan='4'>{$h_av}</td>\n\t\t\t</tr>\n\t\t";
 }
Пример #30
0
 /**
  * Adds functionality for post/list.
  *
  * @param PageRequestEvent $event
  */
 public function onPageRequest(PageRequestEvent $event)
 {
     if ($event->page_matches("post/list")) {
         $pageinfo = $this->get_list_pageinfo($event);
         $prev_url = make_http(make_link("post/list/" . $pageinfo["prev"]));
         $next_url = make_http(make_link("post/list/" . $pageinfo["next"]));
         $this->add_arrowkeys_code($prev_url, $next_url);
     }
 }