示例#1
0
文件: link.php 项目: ruoL/fun-x
 public function update_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $name = $this->input->post('name', true);
     $link = $this->input->post('link', true);
     $info = $this->input->post('info', true);
     $sort = (int) $this->input->post('sort');
     $data['name'] = trim($name);
     $data['link'] = $link;
     $data['info'] = substring(format_content($info), 240);
     $data['sort'] = $sort > 255 ? 255 : $sort;
     if (!$data['name'] or !$data['link']) {
         JSON('error', '对不起,请填写必填字段!');
     }
     if (!is_url($data['link'])) {
         JSON('error', '请填写有效的网站 URL 地址!');
     }
     $lid = (int) $this->input->post('lid');
     $this->db->update('link', $data, array('lid' => $lid));
     if ($this->db->affected_rows()) {
         JSON('success', '恭喜,链接已更新成功!');
     } else {
         JSON('error', '对不起,链接没有更新名更新失败!');
     }
 }
function plugin_siteimage_convert()
{
    global $link_target;
    $args = func_get_args();
    $url = array_shift($args);
    if (!is_url($url)) {
        return '<p>Usage: #siteimage([url],[option(s),...]);</p>';
    }
    $options = array('nolink' => false, 'around' => false, 'left' => false, 'right' => false, 'center' => false);
    get_plugin_option($args, &$options);
    $style = 'width:128px;height:128px;margin:10px;';
    if ($options['around']) {
        if ($options['right']) {
            $style .= 'float:right;margin-right:5px;';
        } else {
            $style .= 'float:left;margin-left:5px;';
        }
    } else {
        if ($options['right']) {
            $style .= 'margin-right:10px;margin-left:auto;';
        } else {
            if ($options['center']) {
                $style .= 'margin-right:auto;margin-left:auto;';
            } else {
                $style .= 'margin-right:auto;margin-left:10px;';
            }
        }
    }
    //	$img = plugin_siteimage_make($url, $options['nolink'], $options['target']);
    $img = plugin_siteimage_make($url, $options['nolink']);
    return '<div style="' . $style . '">' . $img . "</div>\n";
}
示例#3
0
 function pass($post)
 {
     if (!is_array($post)) {
         return false;
     }
     if (!$post['catid']) {
         return $this->_(lang('message->pass_catid'));
     }
     if (strlen($post['title']) < 3) {
         return $this->_(lang('message->pass_title'));
     }
     if (!is_url($post['thumb'])) {
         return $this->_(lang('message->pass_thumb'));
     }
     if (!$post['password'] && $post['open'] == 2) {
         return $this->_(lang('photo->pass_password'));
     }
     if (!$post['question'] && $post['open'] == 1) {
         return $this->_(lang('photo->pass_question'));
     }
     if (!$post['answer'] && $post['open'] == 1) {
         return $this->_(lang('photo->pass_answer'));
     }
     if (DT_MAX_LEN && strlen($post['content']) > DT_MAX_LEN) {
         return $this->_(lang('message->pass_max'));
     }
     return true;
 }
示例#4
0
 /** @return array of VcardAddress objects */
 static function parse($data)
 {
     if (is_url($data)) {
         $http = new HttpClient($data);
         $data = $http->getBody();
         //FIXME check http client return code for 404
         if (strpos($data, 'BEGIN:VCARD') === false) {
             throw new \Exception('VcardReader->parse FAIL: cant parse vcard from ' . $http->getUrl());
             return false;
         }
     }
     $res = array();
     do {
         $m1 = 'BEGIN:VCARD';
         $m2 = 'END:VCARD';
         $p1 = strpos($data, $m1);
         $p2 = strpos($data, $m2);
         if ($p1 === false || $p2 === false) {
             break;
         }
         $part = substr($data, $p1, $p2 - $p1 + strlen($m2));
         $res[] = self::parseVcard($part);
         $data = substr($data, $p2 + strlen($m2));
     } while ($data);
     return $res;
 }
示例#5
0
function plugin_conversion_inline()
{
    global $vars, $script;
    $qm = get_qm();
    $page = isset($vars['page']) ? $vars['page'] : '';
    $args = func_get_args();
    if (count($args) != 5) {
        return $qm->replace('fmt_err_iln', 'conversion', $qm->m['plg_conversion']['err_usage_iln']);
    }
    $text = array_pop($args);
    list($step, $group, $name, $url) = $args;
    if (!is_url($url)) {
        return $qm->replace('fmt_err_iln', 'conversion', $qm->m['plg_conversion']['err_url']);
    }
    $raw_url = $url;
    $step = rawurlencode($step);
    $group = rawurlencode($group);
    $name = rawurlencode($name);
    $url = rawurlencode($url);
    $dest = $script . '?cmd=conversion&mode=link&step=' . $step . '&group=' . $group . '&name=' . $name . '&url=' . $url;
    //edit auth check
    $editable = edit_auth($page, FALSE, FALSE);
    if ($editable) {
        return '<a href="' . $dest . '">' . $text . '</a><span style="font-size:11px;background-color:#fdd">←' . $qm->m['plg_conversion']['ntc_admin'] . '</span>';
    } else {
        return '<a href="' . $dest . '">' . $text . '</a>';
    }
}
示例#6
0
function plugin_redirect_iframe_convert()
{
    global $vars, $script;
    $qm = get_qm();
    $page = isset($vars['page']) ? $vars['page'] : '';
    $args = func_get_args();
    $url = strip_autolink(array_pop($args));
    if ($url == '') {
        $url = $script . '?' . rawurlencode($page);
    } else {
        $url = is_url($url) ? $url : $script . '?' . rawurlencode($url);
    }
    $editable = ss_admin_check();
    if ($editable) {
        return $qm->replace('plg_redirect_iframe.ntc_admin', $url);
    } else {
        return <<<EOD
<span id="redirect_iframe_msg"><p style="color:gray"><a href="{$url}" target="new">{$qm->m['plg_redirect_iframe']['link']}</a></p></span>
<script type="text/javascript">
<!--
if(parent != self){
parent.location.href="{$url}";
}
else{
var element = document.getElementById("redirect_iframe_msg");
element.innerHTML = "";
}

//-->
</script>
EOD;
    }
}
示例#7
0
function plugin_ga_link_inline()
{
    global $accesstag_moved;
    global $accesstag;
    global $vars;
    $qm = get_qm();
    $qt = get_qt();
    $page = isset($vars['page']) ? $vars['page'] : '';
    //parameter check
    $args = func_get_args();
    $num = func_num_args();
    if ($num != 2) {
        return $qm->replace('fmt_err_iln', 'ga_link', $qm->m['plg_ga_link']['err_usage']);
    }
    $text = strip_autolink(array_pop($args));
    //テキストデータ
    $url = array_pop($args);
    if (!is_url($url)) {
        $url = 'index.php?' . rawurlencode($url);
    }
    $acc_tag = '';
    //初めて呼び出される場合、accesstag情報を表示する
    if (!$accesstag_moved) {
        $accesstag_moved = TRUE;
        //accesstag_movedを設定
        $editable = edit_auth($page, FALSE, FALSE);
        if (!$editable) {
            $qt->setv('toolkit_upper', $accesstag);
        }
    }
    //Google Analytics用のjavascriptを先に読み込んでから、関数を呼び出す
    $ret = '<a href="index.php?cmd=ga_link&url=' . rawurlencode($url) . '" onClick="javascript:pageTracker._link(this.href);return false;">' . $text . '</a>';
    return $ret;
}
示例#8
0
/**
 * PukiWiki Plus! Anchor Plugin
 *
 * @copyright   Copyright &copy; 2008, Katsumi Saito <*****@*****.**>
 * @version     $Id: a.inc.php,v 0.2 2008/02/24 18:47:00 upk Exp $
 * @license     http://opensource.org/licenses/gpl-license.php GNU Public License (GPL2)
 *
 */
function plugin_a_inline()
{
    global $_symbol_innanchor, $_symbol_extanchor;
    list($href, $name, $opt) = func_get_args();
    $href = trim($href);
    if (empty($href)) {
        return;
    }
    $name = trim($name);
    if (empty($name)) {
        $name = $href;
    }
    $opt = trim($opt);
    if (!empty($opt)) {
        $opt = ' ' . $opt;
    }
    $is_url = is_url($href);
    if (!$is_url && !a_rel_check($href)) {
        return $href;
    }
    $is_ext = $is_url && !is_inside_uri($href);
    $symbol = $is_ext ? $_symbol_extanchor : $_symbol_innanchor;
    $r_href = PKWK_USE_REDIRECT && $is_ext ? get_cmd_uri('redirect', '', '', 'u=') . rawurlencode($href) : htmlspecialchars($href);
    if (!$is_url) {
        return '<a href="' . $r_href . '"' . $opt . '>' . $name . '</a>';
    } else {
        return '<a class="inn" href="' . $r_href . '" rel="nofollow"' . $opt . '>' . $name . str_replace('$1', $r_href, str_replace('$2', '_blank', $symbol)) . '</a>';
    }
}
 function convert()
 {
     if (func_num_args() == 0) {
         return '<p>$this->plugin(): no argument(s). </p>';
     }
     global $vars;
     $args = func_get_args();
     $url = array_shift($args);
     if (!is_url($url) && is_interwiki($url)) {
         list($interwiki, $page) = explode(':', $url, 2);
         $url = get_interwiki_url($interwiki, $page);
     }
     $page = $vars['page'];
     if (!(PKWK_READONLY > 0 or is_freeze($page) or $this->is_edit_auth($page))) {
         if (!$this->accept($url)) {
             return "<p>{$this->plugin}(): The specified url, {$url}, is not allowed, modify iframe.inc.php<br />" . "Or, restrict editing of current page using freeze or edit_auth or PKWK_READONLY.</p>";
         }
     }
     $url = htmlspecialchars($url);
     $options = array();
     foreach ($args as $arg) {
         list($key, $val) = array_pad(explode('=', $arg, 2), 2, TRUE);
         $options[$key] = htmlspecialchars($val);
     }
     $style = isset($options['style']) ? $options['style'] : NULL;
     if (preg_match("/MSIE (3|4|5|6|7)/", getenv("HTTP_USER_AGENT"))) {
         $style = isset($options['iestyle']) ? $options['iestyle'] : $style;
         return $this->show_iframe($url, $style);
     } else {
         return $this->show_object($url, $style);
     }
 }
示例#10
0
 function parse($raw)
 {
     // TODO XmlReader should not handle HTTP protocol details
     if (is_url($raw)) {
         $url = $raw;
         $h = new HttpClient($url);
         //            $h->setCacheTime('30m');
         $raw = $h->getBody();
         //            d( $h->getResponseHeaders() );
         if ($h->getStatus() == 404) {
             // not found
             return false;
         }
         if ($h->getStatus() == 302) {
             $redir = $h->getResponseHeader('location');
             // echo "REDIRECT: ".$redir."\n";
             $h = new HttpClient($redir);
             //XXX: reuse previous client?
             $h->setCacheTime('30m');
             $url = $redir;
             $raw = $h->getBody();
         }
         // prepend XML header if nonexistent
         if (strpos($raw, '<?xml ') === false) {
             $raw = '<?xml version="1.0"?>' . $raw;
         }
     }
     if (!$this->xml($raw)) {
         if (isset($url)) {
             throw new \Exception("Failed to parse XML from " . $url);
         }
         throw new \Exception("Failed to parse XML");
     }
 }
function plugin_html2pdf_get_request_uri($init_uri = '')
{
    if ($init_uri == '') {
        // Set automatically
        $msg = 'get_request_uri() failed: Please set $script at INI_FILE manually';
        if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'][0] == '/') {
            $url = SERVER_PORT == 443 ? 'https://' : 'http://';
            // scheme
            $url .= SERVER_NAME;
            // host
            $url .= SERVER_PORT == 80 ? '' : ':' . SERVER_PORT;
            // port
            $url .= $_SERVER['REQUEST_URI'];
        } else {
            global $vars;
            $url = get_script_uri() . '?';
            $queries = array();
            $queries[] = $vars['cmd'] != '' ? 'cmd=' . rawurlencode($vars['cmd']) : '';
            $queries[] = $vars['page'] != '' ? 'page=' . rawurlencode($vars['page']) : '';
            $url .= implode('&', $queries);
        }
        if (!is_url($url, TRUE)) {
            die_message($msg);
        }
    } else {
        // Set manually
        if (!is_url($init_uri, TRUE)) {
            die_message('$url: Invalid URI');
        }
        $url = $init_uri;
    }
    return $url;
}
示例#12
0
/**
 *   Canonical URL modifier Plugin
 *   -------------------------------------------
 *   /haik-contents/plugin/canonical.inc.php
 *
 *   Copyright (c) 2014 hokuken
 *   http://hokuken.com/
 *
 *   created  : 14/12/10
 *   modified :
 *
 *   ページの canonical URL を任意のものに設定できる
 *
 *   Usage :
 *   #canonical(URL or pagename or path)
 *
 */
function plugin_canonical_convert()
{
    global $script, $vars;
    // Deny the call at layout pages
    if (isset($vars['page_alt'])) {
        return;
    }
    $qt = get_qt();
    if (func_num_args() === 0) {
        return;
    }
    $target = func_get_arg(0);
    // URL
    if (is_url($target)) {
        $canonical_url = $target;
    } else {
        if (is_page($target)) {
            $canonical_url = $script . '?' . rawurlencode($target);
        } else {
            $base_dir = dirname($script . 'dummy');
            $canonical_url = $base_dir . '/' . $target;
        }
    }
    $qt->setv('canonical_url', $canonical_url);
    return plugin_canonical_show_info();
}
示例#13
0
function plugin_ganatracker2_inline()
{
    global $accesstag_moved;
    global $accesstag;
    global $vars;
    $qm = get_qm();
    $page = isset($vars['page']) ? $vars['page'] : '';
    //parameter check
    $args = func_get_args();
    $num = func_num_args();
    if ($num != 3) {
        return $qm->replace('fmt_err_iln', 'ganatracker2', $qm->m['plg_ganatracker2']['err_usage_iln']);
    }
    $text = strip_autolink(array_pop($args));
    //テキストデータ
    $tname = array_pop($args);
    $url = array_pop($args);
    if (!is_url($url)) {
        $url = 'index.php?' . rawurlencode($url);
    }
    $acc_tag = '';
    //初めて呼び出される場合、accesstag情報を表示する
    if (!$accesstag_moved) {
        $acc_tag = $accesstag;
        $accesstag_moved = 1;
        //accesstag_movedを設定
    }
    $ret = $acc_tag . '<a href="' . $url . '" onClick="javascript:pageTracker._trackPageview(\'' . $tname . '\');">' . $text . '</a>';
    $editable = edit_auth($page, FALSE, FALSE);
    if ($editable) {
        return '<div style="border:2px dashed #f00;background-color:#fee;margin:1em">' . $ret . '<br />' . $qm->replace('plg_ganatracker2.ntc_admin', $tname) . '</div>';
    } else {
        return $ret;
    }
}
示例#14
0
function fetch_blacklist()
{
    global $config, $g;
    $url = $config['installedpackages']['dansguardianblacklist']['config'][0]['url'];
    if (is_url($url)) {
        conf_mount_rw();
        print "file download start..";
        unlink_if_exists("/usr/local/etc/dansguardian/lists/blacklist.tgz");
        exec("/usr/bin/fetch -o /usr/local/etc/dansguardian/lists/blacklist.tgz " . escapeshellarg($url));
        chdir("/usr/local/etc/dansguardian/lists");
        if (is_dir("blacklists.old")) {
            exec('rm -rf /usr/local/etc/dansguardian/lists/blacklists.old');
        }
        rename("blacklists", "blacklists.old");
        exec('/usr/bin/tar -xvzf /usr/local/etc/dansguardian/lists/blacklist.tgz 2>&1', $output, $return);
        if (preg_match("/x\\W+(\\w+)/", $output[0], $matches)) {
            if ($matches[1] != "blacklists") {
                rename("./" . $matches[1], "blacklists");
            }
            read_lists();
        } else {
            file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated", "");
        }
    } else {
        file_notice("Dansguardian - Blacklist url is invalid.", "");
    }
}
示例#15
0
function get_video_object($article)
{
    $video = new StdClass();
    $video->file = '';
    $video->image = '';
    $video->provider = '';
    $params = array();
    if (is_url($article->video_attachment)) {
        if (is_youtube_video($video->file = $article->video_attachment)) {
            $video->image = extract_youtube_image($video->file);
            $video->provider = 'youtube';
            $params[] = 'provider=youtube';
        }
    } else {
        $video->file = VIVVO_STATIC_URL . $article->video_attachment;
    }
    if (!$video->image and $article->image) {
        $video->image = VIVVO_STATIC_URL . "thumbnail.php?file={$article->image}&size=article_large";
    }
    if ($video->image) {
        $params[] = 'image=' . flashvars_encode($video->image);
    }
    $params[] = 'file=' . flashvars_encode($video->file);
    $params[] = 'logo.hide=true';
    $video->flashvars = implode('&', $params);
    return $video;
}
示例#16
0
function plugin_img_convert()
{
    if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI) {
        return '#img(): PKWK_DISABLE_INLINE_IMAGE_FROM_URI prohibits this' . '<br>' . "\n";
    }
    $args = func_get_args();
    // Check the 2nd argument first, for compatibility
    $arg = isset($args[1]) ? strtoupper($args[1]) : '';
    if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
        $align = 'left';
    } elseif ($arg == 'R' || $arg == 'RIGHT') {
        $align = 'right';
    } else {
        // Stop word-wrapping only (Ugly but compatible)
        // Short usage: #img(,clear)
        return PLUGIN_IMG_CLEAR;
    }
    $url = isset($args[0]) ? $args[0] : '';
    if (!is_url($url) || !preg_match('/\\.(jpe?g|gif|png)$/i', $url)) {
        return PLUGIN_IMG_USAGE;
    }
    $arg = isset($args[2]) ? strtoupper($args[2]) : '';
    $clear = $arg == 'C' || $arg == 'CLEAR' ? PLUGIN_IMG_CLEAR : '';
    return <<<EOD
<div style="float:{$align};padding:.5em 1.5em .5em 1.5em">
 <img src="{$url}" alt="" />
</div>{$clear}
EOD;
}
function object_alter_render_late($args)
{
    $elem = $args['elem'];
    $html =& $args['html'];
    $obj = $args['obj'];
    if (!elem_has_class($args['elem'], 'object')) {
        return false;
    }
    if (!$args['edit']) {
        // add links only for viewing
        if (!empty($obj['object-link'])) {
            $link = $obj['object-link'];
            // resolve any aliases
            $link = resolve_aliases($link, $obj['name']);
            if (!is_url($link) && substr($link, 0, 1) != '#') {
                // add base url for relative links that are not directed towards anchors
                if (SHORT_URLS) {
                    $link = base_url() . urlencode($link);
                } else {
                    $link = base_url() . '?' . urlencode($link);
                }
            }
            // <a> can include block elements in html5
            if (substr($html, -1) == "\n") {
                $html = substr($html, 0, -1);
            }
            $html = '<a href="' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '">' . "\n\t" . str_replace("\n", "\n\t", $html) . "\n" . '</a>' . "\n";
            return true;
        }
    }
    return false;
}
示例#18
0
function plugin_read_url_inline()
{
    $qt = get_qt();
    //---- キャッシュのための処理を登録 -----
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    global $vars;
    $qm = get_qm();
    $page = $vars['page'];
    $args = func_get_args();
    $num = func_num_args();
    if ($num > 0) {
        $url = $args[0];
    }
    $from_en = "auto";
    if (isset($args[1]) && $args[1] != '') {
        $from_en = h($args[1]);
    }
    if (is_url($url)) {
        $_data = null;
        if ($_http = fopen($url, "r")) {
            while (!feof($_http)) {
                $_data .= fgets($_http, 1024);
            }
            fclose($_http);
        }
        return mb_convert_encoding($_data, SOURCE_ENCODING, $from_en);
    } else {
        return "<p>" . $qm->replace('plg_read_url.err_invalid_url', $url) . "</p>";
    }
}
示例#19
0
文件: img.inc.php 项目: big2men/qhm
function plugin_img_convert()
{
    $qm = get_qm();
    if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI) {
        return $qm->replace('fmt_err_deny_uri_img', '#img');
    }
    $args = func_get_args();
    // Check the 2nd argument first, for compatibility
    $arg = isset($args[1]) ? strtoupper($args[1]) : '';
    if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
        $align = 'left';
    } else {
        if ($arg == 'R' || $arg == 'RIGHT') {
            $align = 'right';
        } else {
            // Stop word-wrapping only (Ugly but compatible)
            // Short usage: #img(,clear)
            return PLUGIN_IMG_CLEAR;
        }
    }
    $url = isset($args[0]) ? $args[0] : '';
    if (!is_url($url) || !preg_match('/\\.(jpe?g|gif|png)$/i', $url)) {
        return $qm->replace('fmt_err_cvt', 'img', $qm->m['plg_img']['err_usage']);
    }
    $arg = isset($args[2]) ? strtoupper($args[2]) : '';
    $clear = $arg == 'C' || $arg == 'CLEAR' ? PLUGIN_IMG_CLEAR : '';
    return <<<EOD
<div style="float:{$align};padding:.5em 1.5em .5em 1.5em">
 <img src="{$url}" alt="" />
</div>{$clear}
EOD;
}
示例#20
0
function plugin_redirect_convert()
{
    global $vars, $script;
    $qm = get_qm();
    $qt = get_qt();
    //キャッシュしない
    $qt->enable_cache = false;
    $page = isset($vars['page']) ? $vars['page'] : '';
    $args = func_get_args();
    $url = strip_autolink(array_shift($args));
    $status = array_shift($args);
    $status_codes = array('301' => 'HTTP/1.1 301 Moved Permanently');
    if (isset($status_codes[$status])) {
        $headers[] = $status_codes[$status];
    }
    if ($url == '') {
        $url = $script . '?FrontPage';
    } else {
        $url = is_url($url) ? $url : $script . '?' . rawurlencode($url);
    }
    $editable = ss_admin_check();
    //自分自身にリダイレクトして、ループする場合は警告する
    if ($url === $script . '?' . rawurlencode($page)) {
        return $qm->m['plg_redirect']['err_self_ref'];
    }
    if ($editable) {
        return $qm->replace('plg_redirect.ntc_admin', $url);
    } else {
        $headers[] = 'Location: ' . $url;
        foreach ($headers as $header) {
            header($header);
        }
        exit;
    }
}
示例#21
0
 function check()
 {
     $this->filter();
     $err = array();
     if (count($this->post_arr) == 0) {
         return array('信息未改变');
     }
     if (isset($this->post_arr['sitename'])) {
         if ($this->post_arr['sitename'] == '') {
             array_push($err, "站点名不能为空");
         }
     }
     if (isset($this->post_arr['siteurl'])) {
         if (!is_url($this->post_arr['siteurl'])) {
             array_push($err, "站点名不能为空");
         }
         while (substr($this->post_arr['siteurl'], -1, 1) == '/') {
             $this->post_arr['siteurl'] = substr($this->post_arr['siteurl'], 0, -1);
         }
     }
     if (isset($this->post_arr['cookie_time'])) {
         if (!(is_numeric($this->post_arr['cookie_time']) && $this->post_arr['cookie_time'] == round($this->post_arr['cookie_time']))) {
             array_push($err, "Cookies时间设置有误");
         }
     }
     if (isset($this->post_arr['cookie_key'])) {
         if ($this->post_arr['cookie_key'] == '') {
             array_push($err, "Cookies key有误");
         }
     }
     if (count($err) == 0) {
         $this->status = TRUE;
     }
     return $err;
 }
示例#22
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)));
            }
        }
    }
}
示例#23
0
文件: back.inc.php 项目: big2men/qhm
function plugin_back_convert()
{
    global $script;
    $qm = get_qm();
    if (func_num_args() > 4) {
        return $qm->replace('fmt_err_cvt', 'back', $qm->m['err_usage']);
    }
    list($word, $align, $hr, $href) = array_pad(func_get_args(), 4, '');
    $word = trim($word);
    $word = $word == '' ? $qm->m['plg_back']['back_word'] : htmlspecialchars($word);
    $align = strtolower(trim($align));
    switch ($align) {
        case '':
            $align = 'center';
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'center':
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'left':
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'right':
            break;
        default:
            return $qm->replace('fmt_err_cvt', 'back', $qm->m['err_usage']);
    }
    $hr = trim($hr) != '0' ? '<hr class="full_hr" />' . "\n" : '';
    $link = TRUE;
    $href = trim($href);
    if ($href != '') {
        if (PLUGIN_BACK_ALLOW_PAGELINK) {
            if (is_url($href)) {
                $href = rawurlencode($href);
            } else {
                $array = anchor_explode($href);
                $array[0] = rawurlencode($array[0]);
                $array[1] = $array[1] != '' ? '#' . rawurlencode($array[1]) : '';
                $href = $script . '?' . $array[0] . $array[1];
                $link = is_page($array[0]);
            }
        } else {
            $href = rawurlencode($href);
        }
    } else {
        if (!PLUGIN_BACK_ALLOW_JAVASCRIPT) {
            return $qm->replace('fmt_err_cvt', 'back', $qm->m['err_usage']) . ': ' . $qm->m['plg_back']['usage_hint'];
        }
        $href = 'javascript:history.go(-1)';
    }
    if ($link) {
        // Normal link
        return $hr . '<div style="text-align:' . $align . '">' . '[ <a href="' . $href . '">' . $word . '</a> ]</div>' . "\n";
    } else {
        // Dangling link
        return $hr . '<div style="text-align:' . $align . '">' . '[ <span class="noexists">' . $word . '<a href="' . $href . '">?</a></span> ]</div>' . "\n";
    }
}
示例#24
0
 function set($post)
 {
     global $MOD, $DT_TIME, $DT_IP, $AREA, $_username, $_userid;
     is_url($post['thumb']) or $post['thumb'] = '';
     is_url($post['thumb1']) or $post['thumb1'] = '';
     is_url($post['thumb2']) or $post['thumb2'] = '';
     $post['filepath'] = isset($post['filepath']) && is_filepath($post['filepath']) ? file_vname($post['filepath']) : '';
     $post['editor'] = $_username;
     $post['islink'] = isset($post['islink']) ? 1 : 0;
     $post['addtime'] = isset($post['addtime']) && $post['addtime'] ? strtotime($post['addtime']) : $DT_TIME;
     $post['adddate'] = timetodate($post['addtime'], 3);
     $post['edittime'] = $DT_TIME;
     $post['editdate'] = timetodate($post['edittime'], 3);
     $post['totime'] = $post['totime'] ? strtotime($post['totime'] . ' 23:59:59') : 0;
     $post['fee'] = dround($post['fee']);
     $post['content'] = stripslashes($post['content']);
     $post['content'] = save_local($post['content']);
     if ($MOD['clear_link']) {
         $post['content'] = clear_link($post['content']);
     }
     if ($MOD['save_remotepic']) {
         $post['content'] = save_remote($post['content']);
     }
     if ($MOD['introduce_length']) {
         $post['introduce'] = addslashes(get_intro($post['content'], $MOD['introduce_length']));
     }
     if ($this->itemid) {
         $new = $post['content'];
         if ($post['thumb']) {
             $new .= '<img src="' . $post['thumb'] . '"/>';
         }
         if ($post['thumb1']) {
             $new .= '<img src="' . $post['thumb1'] . '"/>';
         }
         if ($post['thumb2']) {
             $new .= '<img src="' . $post['thumb2'] . '"/>';
         }
         $r = $this->get_one();
         $old = $r['content'];
         if ($r['thumb']) {
             $old .= '<img src="' . $r['thumb'] . '"/>';
         }
         if ($r['thumb1']) {
             $old .= '<img src="' . $r['thumb1'] . '"/>';
         }
         if ($r['thumb2']) {
             $old .= '<img src="' . $r['thumb2'] . '"/>';
         }
         delete_diff($new, $old);
     } else {
         $post['ip'] = $DT_IP;
     }
     $content = $post['content'];
     unset($post['content']);
     $post = dhtmlspecialchars($post);
     $post['content'] = addslashes(dsafe($content));
     return array_map("trim", $post);
 }
示例#25
0
function plugin_back_convert()
{
    global $_msg_back_word, $script;
    if (func_num_args() > 4) {
        return PLUGIN_BACK_USAGE;
    }
    list($word, $align, $hr, $href) = array_pad(func_get_args(), 4, '');
    $word = trim($word);
    $word = $word == '' ? $_msg_back_word : htmlsc($word);
    $align = strtolower(trim($align));
    switch ($align) {
        case '':
            $align = 'center';
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'center':
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'left':
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'right':
            break;
        default:
            return PLUGIN_BACK_USAGE;
    }
    $hr = trim($hr) != '0' ? '<hr class="full_hr" />' . "\n" : '';
    $link = true;
    $href = trim($href);
    if ($href != '') {
        if (PLUGIN_BACK_ALLOW_PAGELINK) {
            if (is_url($href)) {
                $href = rawurlencode($href);
            } else {
                $array = anchor_explode($href);
                $array[0] = rawurlencode($array[0]);
                $array[1] = $array[1] != '' ? '#' . rawurlencode($array[1]) : '';
                $href = $script . '?' . $array[0] . $array[1];
                $link = is_page($array[0]);
            }
        } else {
            $href = rawurlencode($href);
        }
    } else {
        if (!PLUGIN_BACK_ALLOW_JAVASCRIPT) {
            return PLUGIN_BACK_USAGE . ': Set a page name or an URI';
        }
        $href = 'javascript:history.go(-1)';
    }
    if ($link) {
        // Normal link
        return $hr . '<div style="text-align:' . $align . '">' . '[ <a href="' . $href . '">' . $word . '</a> ]</div>' . "\n";
    } else {
        // Dangling link
        return $hr . '<div style="text-align:' . $align . '">' . '[ <span class="noexists">' . $word . '<a href="' . $href . '">?</a></span> ]</div>' . "\n";
    }
}
function fetch_blacklist($log_notice = true, $install_process = false)
{
    global $config, $g;
    if (is_array($config['installedpackages']['dansguardianblacklist']) && is_array($config['installedpackages']['dansguardianblacklist']['config'])) {
        $url = $config['installedpackages']['dansguardianblacklist']['config'][0]['url'];
        $uw = "Found a previouns install, checking Blacklist config...";
    } else {
        $uw = "Found a clean install, reading default access lists...";
    }
    conf_mount_rw();
    if ($install_process == true) {
        update_output_window($uw);
    }
    if (isset($url) && is_url($url)) {
        if ($log_notice == true) {
            print "file download start..";
            unlink_if_exists("/usr/local/pkg/blacklist.tgz");
            exec("/usr/bin/fetch -o /usr/local/pkg/blacklist.tgz " . escapeshellarg($url), $output, $return);
        } else {
            #install process
            if (file_exists("/usr/local/pkg/blacklist.tgz")) {
                update_output_window("Found previous blacklist database, skipping download...");
                $return = 0;
            } else {
                update_output_window("Fetching blacklist");
                download_file_with_progress_bar($url, "/usr/local/pkg/blacklist.tgz");
                if (file_exists("/usr/local/pkg/blacklist.tgz")) {
                    $return = 0;
                }
            }
        }
        if ($return == 0) {
            chdir(DANSGUARDIAN_DIR . "/etc/dansguardian/lists");
            if (is_dir("blacklists.old")) {
                exec('rm -rf ' . DANSGUARDIAN_DIR . '/etc/dansguardian/lists/blacklists.old');
            }
            rename("blacklists", "blacklists.old");
            exec('/usr/bin/tar -xvzf /usr/local/pkg/blacklist.tgz 2>&1', $output, $return);
            if (preg_match("/x\\W+(\\w+)/", $output[1], $matches)) {
                if ($matches[1] != "blacklists") {
                    rename("./" . $matches[1], "blacklists");
                }
                read_lists($log_notice);
            } else {
                file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated", "");
            }
        } else {
            file_notice("Dansguardian - Could not fetch blacklists from url", "");
        }
    } else {
        if ($install_process == true) {
            read_lists(false, $uw);
        } elseif (!empty($url)) {
            file_notice("Dansguardian - Blacklist url is invalid.", "");
        }
    }
}
示例#27
0
function plugin_showrss_convert()
{
    static $_xml;
    if (!isset($_xml)) {
        $_xml = extension_loaded('xml');
    }
    if (!$_xml) {
        return '#showrss: xml extension is not found<br />' . "\n";
    }
    $num = func_num_args();
    if ($num == 0) {
        return PLUGIN_SHOWRSS_USAGE . '<br />' . "\n";
    }
    $argv = func_get_args();
    $timestamp = FALSE;
    $cachehour = 0;
    $template = $uri = '';
    switch ($num) {
        case 4:
            $timestamp = trim($argv[3]) == '1';
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 3:
            $cachehour = trim($argv[2]);
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 2:
            $template = strtolower(trim($argv[1]));
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 1:
            $uri = trim($argv[0]);
    }
    $class = $template == '' || $template == 'default' ? 'ShowRSS_html' : 'ShowRSS_html_' . $template;
    if (!is_numeric($cachehour)) {
        return '#showrss: Cache-lifetime seems not numeric: ' . htmlspecialchars($cachehour) . '<br />' . "\n";
    }
    if (!class_exists($class)) {
        return '#showrss: Template not found: ' . htmlspecialchars($template) . '<br />' . "\n";
    }
    if (!is_url($uri)) {
        return '#showrss: Seems not URI: ' . htmlspecialchars($uri) . '<br />' . "\n";
    }
    if (!is_requestable($uri)) {
        return '#showrss: Prohibit fetching RSS from my server<br />' . "\n";
    }
    list($rss, $time) = plugin_showrss_get_rss($uri, $cachehour);
    if ($rss === FALSE) {
        return '#showrss: Failed fetching RSS from the server<br />' . "\n";
    }
    if ($timestamp > 0) {
        $time = '<p style="font-size:10px; font-weight:bold">Last-Modified:' . get_date('Y/m/d H:i:s', $time) . '</p>';
    }
    $obj = new $class($rss);
    return $obj->toString($time);
}
示例#28
0
 function uploadSubmit($p)
 {
     if (!is_url($p['url'])) {
         $error = ErrorHandler::getInstance();
         $error->add('Not an url');
         return false;
     }
     $eventId = TaskQueue::addTask(TASK_FETCH, $p['url']);
     echo '<div class="okay">URL to process has been enqueued.</div><br/>';
     echo ahref('queue/show/' . $eventId, 'Click here') . ' to perform further actions on this file.';
 }
示例#29
0
function plugin_ajaxrss_output_url($url)
{
    if (!is_url($url, TRUE)) {
        return '';
    }
    $ret = http_request($url);
    if ($ret['rc'] != 200) {
        return '';
    }
    return $ret['data'];
}
示例#30
0
function plugin_back_convert()
{
    $_msg_back_word = T_('Back');
    if (func_num_args() > 4) {
        return PLUGIN_BACK_USAGE;
    }
    list($word, $align, $hr, $href) = array_pad(func_get_args(), 4, '');
    $word = trim($word);
    $word = $word == '' ? $_msg_back_word : htmlsc($word);
    $align = strtolower(trim($align));
    switch ($align) {
        case '':
            $align = 'center';
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'center':
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'left':
            /*FALLTHROUGH*/
        /*FALLTHROUGH*/
        case 'right':
            break;
        default:
            return PLUGIN_BACK_USAGE;
    }
    $hr = trim($hr) != '0' ? '<hr class="full_hr" />' . "\n" : '';
    $link = TRUE;
    $href = trim($href);
    if (!empty($href)) {
        if (Auth::check_role('safemode')) {
            if (is_url($href)) {
                $href = rawurlencode($href);
            } else {
                $wiki = Factory::Wiki($array[0]);
                $array = Utility::explodeAnchor($href);
                $array[1] = !empty($array[1]) ? '#' . rawurlencode($array[1]) : '';
                $href = $wiki->uri() . $array[1];
                $link = $wiki->has();
            }
        } else {
            $href = rawurlencode($href);
        }
    } else {
        $href = 'javascript:history.go(-1)';
    }
    if ($link) {
        // Normal link
        return $hr . '<div style="text-align:' . $align . '">' . '[ <a href="' . $href . '">' . $word . '</a> ]</div>' . "\n";
    } else {
        // Dangling link
        return $hr . '<div style="text-align:' . $align . '">' . '[ <span class="noexists">' . $word . '<a href="' . $href . '">?</a></span> ]</div>' . "\n";
    }
}