예제 #1
0
function plugin_touchgraph_ref()
{
    foreach (auth::get_existpages() as $page) {
        if (check_non_list($page)) {
            continue;
        }
        $file = CACHE_DIR . encode($page) . '.ref';
        if (file_exists($file)) {
            echo $page;
            foreach (file($file) as $line) {
                list($name) = explode("\t", $line);
                if (check_non_list($name)) {
                    continue;
                }
                echo ' ', $name;
            }
            echo "\n";
        }
    }
}
예제 #2
0
function plugin_related_action()
{
    global $vars, $script, $defaultpage, $whatsnew;
    $_page = isset($vars['page']) ? $vars['page'] : '';
    if ($_page == '') {
        $_page = $defaultpage;
    }
    // Get related from cache
    $data = links_get_related_db($_page);
    if (!empty($data)) {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            if ($page == $whatsnew || check_non_list($page)) {
                unset($data[$page]);
            }
        }
    }
    // Result
    // kazuwaya
    $r_word = rawurlencode($_page);
    $s_word = htmlspecialchars($_page);
    $msg = 'Backlinks for: ' . $s_word;
    $retval = '<p><a href="' . $script . '?' . $r_word . '">' . 'Return to ' . $s_word . '</a></p>' . "\n";
    if (empty($data)) {
        $retval .= '<ul><li>No related pages found.</li></ul>' . "\n";
    } else {
        // Show count($data)?
        ksort($data);
        $retval .= '<ul>' . "\n";
        foreach ($data as $page => $time) {
            $r_page = rawurlencode($page);
            $s_page = htmlspecialchars($page);
            $passage = get_passage($time);
            $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page . '</a> ' . $passage . '</li>' . "\n";
        }
        $retval .= '</ul>' . "\n";
    }
    return array('msg' => $msg, 'body' => $retval);
}
예제 #3
0
파일: related.inc.php 프로젝트: big2men/qhm
function plugin_related_action()
{
    global $vars, $script, $defaultpage, $whatsnew;
    $qm = get_qm();
    $_page = isset($vars['page']) ? $vars['page'] : '';
    if ($_page == '') {
        $_page = $defaultpage;
    }
    // Get related from cache
    $data = links_get_related_db($_page);
    if (!empty($data)) {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            if ($page == $whatsnew || check_non_list($page)) {
                unset($data[$page]);
            }
        }
    }
    // Result
    $r_word = rawurlencode($_page);
    $s_word = get_page_title($_page);
    $msg = $qm->replace('plg_related.title', $s_word);
    $retval = '<a href="' . $script . '?' . $r_word . '">' . $qm->replace('plg_related.link_back', $s_word) . '</a><br />' . "\n";
    if (empty($data)) {
        $retval .= '<ul><li>' . $qm->m['plg_related']['notfound'] . '</li></ul>' . "\n";
    } else {
        ksort($data);
        $retval .= '<ul>' . "\n";
        foreach ($data as $page => $time) {
            $r_page = rawurlencode($page);
            $s_page = get_page_title($page);
            $passage = get_passage($time);
            $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page . '</a> ' . $passage . '</li>' . "\n";
        }
        $retval .= '</ul>' . "\n";
    }
    return array('msg' => $msg, 'body' => $retval);
}
예제 #4
0
function plugin_related_action()
{
    global $vars, $defaultpage;
    $_page = isset($vars['page']) ? $vars['page'] : '';
    if ($_page == '') {
        $_page = $defaultpage;
    }
    // Get related from cache
    $data = links_get_related_db($_page);
    if (!empty($data)) {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            if (is_cantedit($page) || check_non_list($page)) {
                unset($data[$page]);
            }
        }
    }
    // Result
    $s_word = htmlspecialchars($_page);
    $msg = 'Backlinks for: ' . $s_word;
    $retval = '<a href="' . get_page_uri($_page) . '">' . 'Return to ' . $s_word . '</a><br />' . "\n";
    if (empty($data)) {
        $retval .= '<ul><li>No related pages found.</li></ul>' . "\n";
    } else {
        // Show count($data)?
        ksort($data, SORT_STRING);
        $retval .= '<ul>' . "\n";
        foreach ($data as $page => $time) {
            $s_page = htmlspecialchars($page);
            $passage = get_passage($time);
            $retval .= ' <li><a href="' . get_page_uri($page) . '">' . $s_page . '</a> ' . $passage . '</li>' . "\n";
        }
        $retval .= '</ul>' . "\n";
    }
    return array('msg' => $msg, 'body' => $retval);
}
예제 #5
0
function make_related($page, $tag = '')
{
    global $script, $vars, $rule_related_str, $related_str;
    global $_ul_left_margin, $_ul_margin, $_list_pad_str;
    $links = links_get_related($page);
    if ($tag) {
        ksort($links);
    } else {
        arsort($links);
    }
    $_links = array();
    foreach ($links as $page => $lastmod) {
        if (check_non_list($page)) {
            continue;
        }
        $r_page = rawurlencode($page);
        $s_page = htmlsc($page);
        $passage = get_passage($lastmod);
        $_links[] = $tag ? '<a href="' . $script . '?' . $r_page . '" title="' . $s_page . ' ' . $passage . '">' . $s_page . '</a>' : '<a href="' . $script . '?' . $r_page . '">' . $s_page . '</a>' . $passage;
    }
    if (empty($_links)) {
        return '';
    }
    // Nothing
    if ($tag == 'p') {
        // From the line-head
        $margin = $_ul_left_margin + $_ul_margin;
        $style = sprintf($_list_pad_str, 1, $margin, $margin);
        $retval = "\n" . '<ul' . $style . '>' . "\n" . '<li>' . join($rule_related_str, $_links) . '</li>' . "\n" . '</ul>' . "\n";
    } else {
        if ($tag) {
            $retval = join($rule_related_str, $_links);
        } else {
            $retval = join($related_str, $_links);
        }
    }
    return $retval;
}
예제 #6
0
function put_lastmodified()
{
    global $maxshow, $whatsnew, $autolink, $autobasealias;
    // if (PKWK_READONLY) return; // Do nothing
    if (auth::check_role('readonly')) {
        return;
    }
    // Do nothing
    // Get WHOLE page list
    $pages = get_existpages();
    // Check ALL filetime
    $recent_pages = array();
    foreach ($pages as $page) {
        if ($page != $whatsnew && !check_non_list($page)) {
            $recent_pages[$page] = get_filetime($page);
        }
    }
    // Sort decending order of last-modification date
    arsort($recent_pages, SORT_NUMERIC);
    // Cut unused lines
    // BugTrack2/179: array_splice() will break integer keys in hashtable
    $count = $maxshow + PKWK_MAXSHOW_ALLOWANCE;
    $_recent = array();
    foreach ($recent_pages as $key => $value) {
        unset($recent_pages[$key]);
        $_recent[$key] = $value;
        if (--$count < 1) {
            break;
        }
    }
    $recent_pages =& $_recent;
    // Re-create PKWK_MAXSHOW_CACHE
    $file = CACHE_DIR . PKWK_MAXSHOW_CACHE;
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message('Cannot open' . 'CACHE_DIR/' . PKWK_MAXSHOW_CACHE);
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    $last = ignore_user_abort(1);
    ftruncate($fp, 0);
    rewind($fp);
    foreach ($recent_pages as $page => $time) {
        fputs($fp, $time . "\t" . $page . "\n");
    }
    ignore_user_abort($last);
    @flock($fp, LOCK_UN);
    @fclose($fp);
    // Create RecentChanges
    $file = get_filename($whatsnew);
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message('Cannot open ' . htmlspecialchars($whatsnew));
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    $last = ignore_user_abort(1);
    ftruncate($fp, 0);
    rewind($fp);
    foreach (array_keys($recent_pages) as $page) {
        $time = $recent_pages[$page];
        // $s_lastmod = htmlspecialchars(format_date($time));
        $s_lastmod = '&epoch(' . $time . ');';
        $s_page = htmlspecialchars($page);
        fputs($fp, '-' . $s_lastmod . ' - [[' . $s_page . ']]' . "\n");
    }
    fputs($fp, '#norelated' . "\n");
    // :)
    ignore_user_abort($last);
    @flock($fp, LOCK_UN);
    @fclose($fp);
    // For AutoLink
    if ($autolink) {
        autolink_pattern_write(CACHE_DIR . PKWK_AUTOLINK_REGEX_CACHE, get_autolink_pattern($pages, $autolink));
    }
    // AutoBaseAlias
    if ($autobasealias) {
        autobasealias_write(CACHE_DIR . PKWK_AUTOBASEALIAS_CACHE, $pages);
    }
}
예제 #7
0
function plugin_popular_convert()
{
    global $vars, $whatsnew;
    global $_popular_plugin_frame, $_popular_plugin_today_frame;
    $max = PLUGIN_POPULAR_DEFAULT;
    $except = '';
    $array = func_get_args();
    $today = FALSE;
    switch (func_num_args()) {
        case 3:
            if ($array[2]) {
                $today = get_date('Y/m/d');
            }
        case 2:
            $except = $array[1];
        case 1:
            $max = $array[0];
    }
    $counters = array();
    foreach (get_existpages(COUNTER_DIR, '.count') as $file => $page) {
        if ($except != '' && ereg($except, $page) || $page == $whatsnew || check_non_list($page) || !is_page($page)) {
            continue;
        }
        $array = file(COUNTER_DIR . $file);
        $count = rtrim($array[0]);
        $date = rtrim($array[1]);
        $today_count = rtrim($array[2]);
        if ($today) {
            // $pageが数値に見える(たとえばencode('BBS')=424253)とき、
            // array_splice()によってキー値が変更されてしまうのを防ぐ
            // ため、キーに '_' を連結する
            if ($today == $date) {
                $counters['_' . $page] = $today_count;
            }
        } else {
            $counters['_' . $page] = $count;
        }
    }
    asort($counters, SORT_NUMERIC);
    // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
    $counters = array_reverse($counters, TRUE);
    // with array_splice()
    $counters = array_splice($counters, 0, $max);
    $items = '';
    if (!empty($counters)) {
        $items = '<ul class="popular_list">' . "\n";
        foreach ($counters as $page => $count) {
            $page = substr($page, 1);
            $s_page = htmlsc($page);
            if ($page == $vars['page']) {
                // No need to link itself, notifies where you just read
                $pg_passage = get_pg_passage($page, FALSE);
                $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '<span class="counter">(' . $count . ')</span></span></li>' . "\n";
            } else {
                $items .= ' <li>' . make_pagelink($page, $s_page . '<span class="counter">(' . $count . ')</span>') . '</li>' . "\n";
            }
        }
        $items .= '</ul>' . "\n";
    }
    return sprintf($today ? $_popular_plugin_today_frame : $_popular_plugin_frame, count($counters), $items);
}
예제 #8
0
function make_related($page, $tag = '')
{
    global $vars, $rule_related_str, $related_str;
    global $_ul_left_margin, $_ul_margin, $_list_pad_str;
    $links = links_get_related($page);
    if ($tag) {
        ksort($links, SORT_STRING);
        // Page name, alphabetical order
    } else {
        arsort($links, SORT_NUMERIC);
        // Last modified date, newer
    }
    $_links = array();
    foreach ($links as $page => $lastmod) {
        if (check_non_list($page)) {
            continue;
        }
        $s_page = htmlspecialchars($page);
        $passage = get_passage($lastmod);
        $_links[] = $tag ? '<a href="' . get_page_uri($page) . '" title="' . $s_page . ' ' . $passage . '">' . $s_page . '</a>' : '<a href="' . get_page_uri($page) . '">' . $s_page . '</a>' . $passage;
    }
    if (empty($_links)) {
        return '';
    }
    // Nothing
    if ($tag == 'p') {
        // From the line-head
        $margin = $_ul_left_margin + $_ul_margin;
        $style = sprintf($_list_pad_str, 1, $margin, $margin);
        $retval = "\n" . '<ul' . $style . '>' . "\n" . '<li>' . join($rule_related_str, $_links) . '</li>' . "\n" . '</ul>' . "\n";
    } else {
        if ($tag) {
            $retval = join($rule_related_str, $_links);
        } else {
            $retval = join($related_str, $_links);
        }
    }
    return $retval;
}
예제 #9
0
function plugin_dav_maketree0()
{
    global $whatsnew, $attach_link;
    $root = array();
    $pagelist = auth::get_existpages();
    foreach ($pagelist as $page) {
        if (check_non_list($page)) {
            continue;
        }
        if ($page == $whatsnew) {
            continue;
        }
        if (PLUGIN_DAV_SHOWONLYEDITABLE && !is_editable($page)) {
            continue;
        }
        $root[$page] = array();
    }
    // FIXME
    // 認証時は、この制限を回避するようにする。
    // 現状は、添付ファイル非表示の場合は抑止
    if (!$attach_link) {
        return $root;
    }
    $attaches =& new AttachPages('');
    foreach ($attaches->pages as $key => $val) {
        if (check_non_list($key)) {
            continue;
        }
        if (!check_readable($key, false, false)) {
            continue;
        }
        if (PLUGIN_DAV_SHOWONLYEDITABLE && !is_editable($key)) {
            continue;
        }
        if (!isset($root[$key])) {
            $root[$key] = array();
        }
        if (is_array($root[$key])) {
            foreach ($val->files as $file => $arr) {
                if (isset($arr[0])) {
                    $root[$key][$file] = $arr[0];
                }
            }
        }
    }
    return $root;
}
예제 #10
0
function plugin_guiedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
{
    global $vars;
    global $load_template_func, $whatsnew;
    global $_button;
    global $notimeupdate;
    global $head_tags, $javascript;
    global $guiedit_use_fck;
    // Newly generate $digest or not
    if ($digest === FALSE) {
        $digest = md5(get_source($page, TRUE, TRUE));
    }
    $s_id = isset($vars['id']) ? htmlspecialchars($vars['id']) : '';
    if (!$guiedit_use_fck) {
        $body = edit_form($page, $postdata, $digest, $b_template);
        $pattern = "/(<input\\s+type=\"hidden\"\\s+name=\"cmd\"\\s+value=\")edit(\"\\s*\\/?>)/";
        $replace = "\$1guiedit\$2\n" . '  <input type="hidden" name="id"     value="' . $s_id . '" />' . '  <input type="hidden" name="text"     value="1" />';
        $body = preg_replace($pattern, $replace, $body);
        return $body;
    }
    require_once GUIEDIT_LIB_PATH . 'guiedit.ini.php';
    //	フォームの値の設定
    $s_digest = htmlspecialchars($digest);
    $s_page = htmlspecialchars($page);
    $s_original = htmlspecialchars($vars['original']);
    $s_ticket = md5(MUTIME);
    if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) {
        // BugTrack/95 fix Problem: browser RSS request with session
        $_SESSION[$s_ticket] = md5(get_ticket() . $digest);
        $_SESSION['origin' . $s_ticket] = md5(get_ticket() . str_replace("\r", '', $s_original));
    }
    // テンプレート
    $template = '';
    if ($load_template_func) {
        global $guiedit_non_list;
        $pages = array();
        foreach (get_existpages() as $_page) {
            if ($_page == $whatsnew || check_non_list($_page)) {
                continue;
            }
            foreach ($guiedit_non_list as $key) {
                $pos = strpos($_page . '/', $key . '/');
                if ($pos !== FALSE && $pos == 0) {
                    continue 2;
                }
            }
            $_s_page = htmlspecialchars($_page);
            $pages[$_page] = '   <option value="' . $_s_page . '">' . $_s_page . '</option>';
        }
        ksort($pages);
        $s_pages = join("\n", $pages);
        $template = <<<EOD
  <select name="template_page" onchange="Template()">
   <option value="">-- {$_button['template']} --</option>
{$s_pages}
  </select>
  <br />
EOD;
    }
    // チェックボックス「タイムスタンプを変更しない」
    $add_notimestamp = '';
    if ($notimeupdate != 0) {
        $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : '';
        // if ($notimeupdate == 2) {
        if ($notimeupdate == 2 && auth::check_role('role_adm_contents')) {
            $add_notimestamp = '   ' . '<input type="password" name="pass" size="12" />' . "\n";
        }
        $add_notimestamp = '<input type="checkbox" name="notimestamp" ' . 'id="_edit_form_notimestamp" value="true"' . $checked_time . ' />' . "\n" . '   ' . '<label for="_edit_form_notimestamp"><span class="small">' . $_button['notchangetimestamp'] . '</span></label>' . "\n" . $add_notimestamp . '&nbsp;';
    }
    //	フォーム
    $body = <<<EOD

<div class="edit_form">
 <form id="edit_form" action="{$script}" method="post" style="margin-bottom:0px;">
{$template}
  <input type="hidden" name="cmd"    value="guiedit" />
  <input type="hidden" name="page"   value="{$s_page}" />
  <input type="hidden" name="digest" value="{$s_digest}" />
  <input type="hidden" name="ticket" value="{$s_ticket}" />
  <input type="hidden" name="id"     value="{$s_id}" />
  <textarea name="msg" rows="1" cols="1" style="display:none"></textarea>
  <div style="float:left;">
   <input type="submit" name="write"   value="{$_button['update']}" accesskey="s" onclick="Write()" />
   <input type="button" name="preview" value="{$_button['preview']}" accesskey="p" onclick="Preview()" />
   {$add_notimestamp}
  </div>
  <textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea>
 </form>
 <form action="{$script}" method="post" style="margin-top:0px;">
  <input type="hidden" name="cmd"    value="guiedit" />
  <input type="hidden" name="page"   value="{$s_page}" />
  <input type="submit" name="cancel" value="{$_button['cancel']}" accesskey="c" />
 </form>
</div>
<div id="preview_indicator" style="display:none"></div>
<div id="preview_area" style="display:none"></div>

EOD;
    //	JavaScript を有効にする
    $javascript = 1;
    $root = get_baseuri('abs');
    //	ヘッダの設定
    $head_tags[] = ' <link rel="stylesheet" type="text/css" href="' . GUIEDIT_LIB_PATH . 'guiedit.css" charset="UTF-8" />';
    $head_tags[] = ' <script type="text/javascript" src="' . GUIEDIT_FCK_PATH . 'fckeditor.js" charset="UTF-8"></script>';
    $head_tags[] = ' <script type="text/javascript" src="' . GUIEDIT_LIB_PATH . 'ajax.js" charset="UTF-8"></script>';
    $head_tags[] = ' <script type="text/javascript" src="' . GUIEDIT_LIB_PATH . 'guiedit.js" charset="UTF-8"></script>';
    $head_tags[] = ' <script type="text/javascript">';
    $head_tags[] = ' <!-- <![CDATA[';
    $head_tags[] = ' var SMILEY_PATH="' . $root . IMAGE_URI . "face/" . '";';
    $head_tags[] = ' var FCK_PATH="' . $root . GUIEDIT_FCK_PATH . '";';
    $head_tags[] = ' var GUIEDIT_PATH="' . $root . GUIEDIT_LIB_PATH . '";';
    $head_tags[] = ' //]]>-->';
    $head_tags[] = ' </script>';
    return $body;
}
예제 #11
0
파일: file.php 프로젝트: big2men/qhm
function put_lastmodified()
{
    global $maxshow, $whatsnew, $autolink;
    $qm = get_qm();
    if (PKWK_READONLY) {
        return;
    }
    // Do nothing
    // Get WHOLE page list
    $pages = get_existpages();
    // Check ALL filetime
    $recent_pages = array();
    foreach ($pages as $page) {
        if ($page != $whatsnew && !check_non_list($page)) {
            $recent_pages[$page] = get_filetime($page);
        }
    }
    // Sort decending order of last-modification date
    arsort($recent_pages, SORT_NUMERIC);
    // Cut unused lines
    // BugTrack2/179: array_splice() will break integer keys in hashtable
    $count = $maxshow + PKWK_MAXSHOW_ALLOWANCE;
    $_recent = array();
    foreach ($recent_pages as $key => $value) {
        unset($recent_pages[$key]);
        $_recent[$key] = $value;
        if (--$count < 1) {
            break;
        }
    }
    $recent_pages =& $_recent;
    // Re-create PKWK_MAXSHOW_CACHE
    $file = CACHE_DIR . PKWK_MAXSHOW_CACHE;
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message($qm->replace('fmt_err_open_cachedir', PKWK_MAXSHOW_CACHE));
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    ftruncate($fp, 0);
    rewind($fp);
    foreach ($recent_pages as $page => $time) {
        fputs($fp, $time . "\t" . $page . "\n");
    }
    flock($fp, LOCK_UN);
    fclose($fp);
    // Create RecentChanges
    $file = get_filename($whatsnew);
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message($qm->replace('file.err_cannot_open', h($whatsnew)));
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    ftruncate($fp, 0);
    rewind($fp);
    foreach (array_keys($recent_pages) as $page) {
        $time = $recent_pages[$page];
        $s_lastmod = htmlspecialchars(format_date($time));
        $s_page = htmlspecialchars($page);
        $pagetile = get_page_title($page);
        fputs($fp, '-' . $s_lastmod . ' - [[' . $pagetile . '>' . $s_page . ']]' . "\n");
    }
    fputs($fp, '#freeze' . "\n");
    fputs($fp, '#norelated' . "\n");
    fputs($fp, '#nofollow' . "\n");
    flock($fp, LOCK_UN);
    fclose($fp);
    // For AutoLink
    if ($autolink) {
        list($pattern, $pattern_a, $forceignorelist) = get_autolink_pattern($pages);
        $file = CACHE_DIR . PKWK_AUTOLINK_REGEX_CACHE;
        pkwk_touch_file($file);
        $fp = fopen($file, 'r+') or die_message($qm->replace('fmt_err_open_cachedir', PKWK_AUTOLINK_REGEX_CACHE));
        set_file_buffer($fp, 0);
        flock($fp, LOCK_EX);
        ftruncate($fp, 0);
        rewind($fp);
        fputs($fp, $pattern . "\n");
        fputs($fp, $pattern_a . "\n");
        fputs($fp, join("\t", $forceignorelist) . "\n");
        flock($fp, LOCK_UN);
        fclose($fp);
    }
}
예제 #12
0
 function toRender($page = '', $pattern = 0)
 {
     if ($page != '') {
         if (!isset($this->pages[$page])) {
             return '';
         } else {
             return $this->pages[$page]->toRender($pattern);
         }
     }
     $ret = '';
     $pages = array_keys($this->pages);
     sort($pages, SORT_STRING);
     foreach ($pages as $page) {
         if (check_non_list($page)) {
             continue;
         }
         $ret .= '<tr><td>' . $this->pages[$page]->toRender($pattern) . '</td></tr>' . "\n";
     }
     return "\n" . '<table>' . "\n" . $ret . '</table>' . "\n";
 }
예제 #13
0
파일: popular.inc.php 프로젝트: big2men/qhm
function plugin_popular_convert()
{
    global $vars, $whatsnew;
    $qm = get_qm();
    $qt = get_qt();
    $max = PLUGIN_POPULAR_DEFAULT;
    $except = '';
    $array = func_get_args();
    //---- キャッシュのための処理を登録 -----
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    $today = FALSE;
    switch (func_num_args()) {
        case 3:
            if ($array[2]) {
                $today = get_date('Y/m/d');
            }
        case 2:
            $except = $array[1];
        case 1:
            $max = $array[0];
    }
    $counters = array();
    foreach (get_existpages(COUNTER_DIR, '.count') as $file => $page) {
        if ($except != '' && ereg($except, $page) || $page == $whatsnew || check_non_list($page) || !is_page($page)) {
            continue;
        }
        $array = array_pad(file(COUNTER_DIR . $file), 3, 0);
        $count = rtrim($array[0]);
        $date = rtrim($array[1]);
        $today_count = rtrim($array[2]);
        if ($today) {
            // $pageが数値に見える(たとえばencode('BBS')=424253)とき、
            // array_splice()によってキー値が変更されてしまうのを防ぐ
            // ため、キーに '_' を連結する
            if ($today == $date) {
                $counters['_' . $page] = $today_count;
            }
        } else {
            $counters['_' . $page] = $count;
        }
    }
    asort($counters, SORT_NUMERIC);
    // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
    $counters = array_reverse($counters, TRUE);
    // with array_splice()
    $counters = array_splice($counters, 0, $max);
    $items = '';
    if (!empty($counters)) {
        $items = '<ul class="popular_list">' . "\n";
        foreach ($counters as $page => $count) {
            $page = substr($page, 1);
            $s_page = htmlspecialchars($page);
            //customized by hokuken.com
            $s_page = get_page_title($page);
            if ($page == $vars['page']) {
                // No need to link itself, notifies where you just read
                $pg_passage = get_pg_passage($page, FALSE);
                $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '<span class="counter">(' . $count . ')</span></span></li>' . "\n";
            } else {
                $items .= ' <li>' . make_pagelink($page, $s_page . '<span class="counter">(' . $count . ')</span>') . '</li>' . "\n";
            }
        }
        $items .= '</ul>' . "\n";
    }
    $html = sprintf($today ? $qm->m['plg_popular']['today_frame'] : $qm->m['plg_popular']['frame'], count($counters), $items);
    return '<div class="qhm-plugin-popular">' . $html . '</div>';
}
예제 #14
0
 function toString($page = '', $flat = FALSE)
 {
     if ($page != '') {
         if (!isset($this->pages[$page])) {
             return '';
         } else {
             return $this->pages[$page]->toString($flat);
         }
     }
     $ret = '';
     $pages = array_keys($this->pages);
     sort($pages);
     foreach ($pages as $page) {
         if (check_non_list($page)) {
             continue;
         }
         $ret .= '<li>' . $this->pages[$page]->toString($flat) . '</li>' . "\n";
     }
     return "\n" . '<ul>' . "\n" . $ret . '</ul>' . "\n";
 }
예제 #15
0
function plugin_mceedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
{
    global $script, $vars, $rows, $cols, $hr, $function_freeze;
    global $whatsnew, $load_template_func;
    global $notimeupdate;
    global $_button, $_string;
    global $ajax;
    // Newly generate $digest or not
    if ($digest === FALSE) {
        $digest = md5(join('', get_source($page)));
    }
    // TinyMCE
    $lines = explode("\n", $postdata);
    if (preg_match('/^\\*{1,3}/m', $lines[0]) !== 0) {
        $before = array_shift($lines);
    }
    $postdata = implode("\n", $lines);
    $postdata = trim($postdata);
    if (preg_match('/\\A#html{{[\\r\\n](.*)[\\r\\n]}}\\Z/m', $postdata, $matches) === 0) {
        return "<p>The format of text data has to be<br />#html{{<br />}}<br /> or <br />**One headline<br />#html{{<br />}}<br />(This is for paragraph editing). </p>";
    }
    $postdata = $matches[1];
    $refer = $template = $addtag = $add_top = $add_ajax = '';
    $checked_top = isset($vars['add_top']) ? ' checked="checked"' : '';
    $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : '';
    if (isset($vars['add'])) {
        $addtag = '<input type="hidden" name="add" value="true" />';
        $add_top = '<input type="checkbox" name="add_top" value="true"' . $checked_top . ' /><span class="small">' . $_button['addtop'] . '</span>';
    }
    if ($load_template_func && $b_template) {
        $pages = array();
        foreach (get_existpages() as $_page) {
            if ($_page == $whatsnew || check_non_list($_page)) {
                continue;
            }
            $s_page = htmlspecialchars($_page);
            $pages[$_page] = '   <option value="' . $s_page . '">' . $s_page . '</option>';
        }
        ksort($pages);
        $s_pages = join("\n", $pages);
        $template = <<<EOD
  <select name="template_page">
   <option value="">-- {$_button['template']} --</option>
{$s_pages}
  </select>
  <input type="submit" name="template" value="{$_button['load']}" accesskey="r" />
  <br />
EOD;
        if (isset($vars['refer']) && $vars['refer'] != '') {
            $refer = '[[' . strip_bracket($vars['refer']) . ']]' . "\n\n";
        }
    }
    $r_page = rawurlencode($page);
    $s_page = htmlspecialchars($page);
    $s_digest = htmlspecialchars($digest);
    $s_postdata = htmlspecialchars($refer . $postdata);
    $s_original = isset($vars['original']) ? htmlspecialchars($vars['original']) : $s_postdata;
    $s_id = isset($vars['id']) ? htmlspecialchars($vars['id']) : '';
    $b_preview = isset($vars['preview']);
    // TRUE when preview
    $btn_preview = $b_preview ? $_button['repreview'] : $_button['preview'];
    if ($ajax) {
        $add_ajax = '<input type="button" name="add_ajax" value="' . $btn_preview . '" accesskey="p" onclick="pukiwiki_apx(this.form.page.value)" />';
    }
    $add_notimestamp = '';
    if ($notimeupdate != 0) {
        // enable 'do not change timestamp'
        $add_notimestamp = <<<EOD
  <input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true"{$checked_time} />
  <label for="_edit_form_notimestamp"><span class="small">{$_button['notchangetimestamp']}</span></label>
EOD;
        if ($notimeupdate == 2 && auth::check_role('role_adm_contents')) {
            // enable only administrator
            $add_notimestamp .= <<<EOD
  <input type="password" name="pass" size="12" />
EOD;
        }
        $add_notimestamp .= '&nbsp;';
    }
    $refpage = htmlspecialchars($vars['refpage']);
    $add_assistant = edit_form_assistant();
    $body = <<<EOD
<div id="realview_outer"><div id="realview"></div><br /></div>
<form action="{$script}" method="post">
 <div class="edit_form" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()">
{$template}
  {$addtag}
  <input type="hidden" name="cmd"    value="mceedit" />
  <input type="hidden" name="page"   value="{$s_page}" />
  <input type="hidden" name="digest" value="{$s_digest}" />
  <input type="hidden" name="id"     value="{$s_id}" />
  <input type="hidden" name="before" value="{$before}" />
  <textarea class="mceEditor" id="msg" name="msg" rows="{$rows}" cols="{$cols}" onselect="pukiwiki_apv(this.form.page.value,this)" onfocus="pukiwiki_apv(this.form.page.value,this)" onkeyup="pukiwiki_apv(this.form.page.value,this)" onmouseup="pukiwiki_apv(this.form.page.value,this)">{$s_postdata}</textarea>
  <br />
  {$add_assistant}
  <br />
  <input type="submit" name="write"   value="{$_button['update']}" accesskey="s" />
  {$add_top}
  {$add_ajax}
  {$add_notimestamp}
  <input type="submit" name="cancel"  value="{$_button['cancel']}" accesskey="c" />
  <textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea>
 </div>
</form>
EOD;
    //  <input type="submit" name="preview" value="$btn_preview" accesskey="p" />
    //	if (isset($vars['help'])) {
    //		$body .= $hr . catrule();
    //	} else {
    //		$body .= '<ul><li><a href="' .
    //			$script . '?cmd=edit&amp;help=true&amp;page=' . $r_page .
    //			'">' . $_string['help'] . '</a></li></ul>';
    //	}
    if ($ajax) {
        global $head_tags;
        $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/msxml.js"></script>';
        //		$head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/textloader.js"></script>';
        $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/realedit.js"></script>';
        $head_tags[] = ' <script language="javascript" type="text/javascript" src="' . SKIN_URI . 'tiny_mce/tiny_mce.js"></script>';
        //TinyMCE
        $head_tags[] = ' <script language="javascript" type="text/javascript">
tinyMCE.init({
	mode : "specific_textareas", 
	editor_selector : "mceEditor"
});
</script>';
        //TinyMCE
    }
    return $body;
}
예제 #16
0
function plugin_guiedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
{
    global $vars;
    global $load_template_func, $whatsnew;
    global $_button;
    global $notimeupdate;
    global $js_tags, $link_tags, $js_blocks;
    global $guiedit_use_fck;
    $script = get_script_uri();
    // Newly generate $digest or not
    if ($digest === FALSE) {
        $digest = md5(get_source($page, TRUE, TRUE));
    }
    $s_id = isset($vars['id']) ? Utility::htmlsc($vars['id']) : '';
    if (!$guiedit_use_fck) {
        $body = edit_form($page, $postdata, $digest, $b_template);
        $pattern = "/(<input\\s+type=\"hidden\"\\s+name=\"cmd\"\\s+value=\")edit(\"\\s*\\/?>)/";
        $replace = "\$1guiedit\$2\n" . '  <input type="hidden" name="id"     value="' . $s_id . '" />' . '  <input type="hidden" name="text"     value="1" />';
        $body = preg_replace($pattern, $replace, $body);
        return $body;
    }
    //	require_once(GUIEDIT_CONF_PATH . 'guiedit.ini.php');
    //	フォームの値の設定
    $s_digest = Utility::htmlsc($digest);
    $s_page = Utility::htmlsc($page);
    $s_original = Utility::htmlsc($vars['original']);
    $s_ticket = md5(MUTIME);
    if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) {
        // BugTrack/95 fix Problem: browser RSS request with session
        $_SESSION[$s_ticket] = md5(get_ticket() . $digest);
        $_SESSION['origin' . $s_ticket] = md5(get_ticket() . str_replace("\r", '', $s_original));
    }
    // テンプレート
    $template = '';
    if ($load_template_func) {
        global $guiedit_non_list;
        $pages = array();
        foreach (get_existpages() as $_page) {
            if ($_page == $whatsnew || check_non_list($_page)) {
                continue;
            }
            foreach ($guiedit_non_list as $key) {
                $pos = strpos($_page . '/', $key . '/');
                if ($pos !== FALSE && $pos == 0) {
                    continue 2;
                }
            }
            $_s_page = Utility::htmlsc($_page);
            $pages[$_page] = '		<option value="' . $_s_page . '">' . $_s_page . '</option>';
        }
        ksort($pages);
        $s_pages = join("\n", $pages);
        $template = <<<EOD
<select name="template_page">
\t<option value="">-- {$_button['template']} --</option>
{$s_pages}
</select>
<br />
EOD;
    }
    // チェックボックス「タイムスタンプを変更しない」
    $add_notimestamp = '';
    if ($notimeupdate != 0) {
        $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : '';
        // if ($notimeupdate == 2) {
        if ($notimeupdate == 2 && Auth::check_role('role_contents_admin')) {
            $add_notimestamp = '   ' . '<input type="password" name="pass" size="12" />' . "\n";
        }
        $add_notimestamp = '<input type="checkbox" name="notimestamp" ' . 'id="_edit_form_notimestamp" value="true"' . $checked_time . ' />' . "\n" . '   ' . '<label for="_edit_form_notimestamp"><span class="small">' . $_button['notchangetimestamp'] . '</span></label>' . "\n" . $add_notimestamp . '&nbsp;';
    }
    //	フォーム
    $body = <<<EOD
<div id="guiedit">
\t<form id="guiedit_form" action="{$script}" method="post" style="margin-bottom:0px;">
\t{$template}
\t\t<input type="hidden" name="cmd"    value="guiedit" />
\t\t<input type="hidden" name="page"   value="{$s_page}" />
\t\t<input type="hidden" name="digest" value="{$s_digest}" />
\t\t<input type="hidden" name="ticket" value="{$s_ticket}" />
\t\t<input type="hidden" name="id"     value="{$s_id}" />
\t\t<textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea>
\t\t<textarea name="msg" id="editor"></textarea>
\t\t<div class="pull-left">
\t\t<button type="submit" name="write"   accesskey="s" class="btn btn-primary">{$_button['update']}</button>
\t\t<button type="button" name="preview" accesskey="p" class="btn btn-secondary">{$_button['preview']}</button>
\t\t{$add_notimestamp}
\t\t</div>
\t</form>
\t<form action="{$script}" method="post">
\t\t<input type="hidden" name="cmd"    value="guiedit" />
\t\t<input type="hidden" name="page"   value="{$s_page}" />
\t\t<input type="submit" name="cancel" value="{$_button['cancel']}" class="btn btn-warning" accesskey="c" />
\t</form>
</div>
EOD;
    $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/ckeditor/ckeditor.js', 'defer' => 'defer');
    $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/ckeditor/adapters/jquery.js', 'defer' => 'defer');
    $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/plugin/guiedit/guiedit.js', 'defer' => 'defer');
    return $body;
}
예제 #17
0
function plugin_popular_convert()
{
    global $vars;
    //	global $_popular_plugin_frame, $_popular_plugin_today_frame;
    static $localtime;
    $_popular_plugin_frame_s = _('popular(%d)');
    $_popular_plugin_today_frame_s = _('today\'s(%d)');
    $_popular_plugin_yesterday_frame_s = _('yesterday\'s(%d)');
    $_popular_plugin_recent_frame_s = _('recent\'s(%d)');
    $_popular_plugin_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_frame_s);
    $_popular_plugin_today_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_today_frame_s);
    $_popular_plugin_yesterday_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_yesterday_frame_s);
    $_popular_plugin_recent_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_recent_frame_s);
    $view = 'total';
    $max = PLUGIN_POPULAR_DEFAULT;
    $except = '';
    if (!isset($localtime)) {
        list($zone, $zonetime) = set_timezone(DEFAULT_LANG);
        $localtime = UTIME + $zonetime;
    }
    $today = gmdate('Y/m/d', $localtime);
    // $yesterday = gmdate('Y/m/d', strtotime('yesterday', $localtime));
    $yesterday = gmdate('Y/m/d', gmmktime(0, 0, 0, gmdate('m', $localtime), gmdate('d', $localtime) - 1, gmdate('Y', $localtime)));
    $array = func_get_args();
    switch (func_num_args()) {
        case 3:
            switch ($array[2]) {
                case 'today':
                case 'true':
                    $view = 'today';
                    break;
                case 'yesterday':
                    $view = 'yesterday';
                    break;
                case 'recent':
                    $view = 'recent';
                    break;
                case 'total':
                case 'false':
                default:
                    $view = 'total';
                    break;
            }
        case 2:
            $except = $array[1];
        case 1:
            $max = $array[0];
    }
    $counters = array();
    foreach (auth::get_existpages(COUNTER_DIR, '.count') as $file => $page) {
        if ($except != '' && ereg($except, $page) || is_cantedit($page) || check_non_list($page) || !is_page($page)) {
            continue;
        }
        $array = file(COUNTER_DIR . $file);
        $count = rtrim($array[0]);
        $date = rtrim($array[1]);
        $today_count = rtrim($array[2]);
        $yesterday_count = rtrim($array[3]);
        $counters['_' . $page] = 0;
        if ($view == 'today' or $view == 'recent') {
            // $pageが数値に見える(たとえばencode('BBS')=424253)とき、
            // array_splice()によってキー値が変更されてしまうのを防ぐ
            // ため、キーに '_' を連結する
            if ($today == $date) {
                $counters['_' . $page] = $today_count;
            }
        }
        if ($view == 'yesterday' or $view == 'recent') {
            if ($today == $date) {
                $counters['_' . $page] += $yesterday_count;
            } elseif ($yesterday == $date) {
                $counters['_' . $page] += $today_count;
            }
        }
        if ($view == 'total') {
            $counters['_' . $page] = $count;
        }
        if ($counters['_' . $page] == 0) {
            unset($counters['_' . $page]);
        }
    }
    asort($counters, SORT_NUMERIC);
    // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
    $counters = array_reverse($counters, TRUE);
    // with array_splice()
    $counters = array_splice($counters, 0, $max);
    $items = '';
    if (!empty($counters)) {
        $items = '<ul class="popular_list">' . "\n";
        foreach ($counters as $page => $count) {
            $page = substr($page, 1);
            $s_page = htmlspecialchars($page);
            if ($page == $vars['page']) {
                // No need to link itself, notifies where you just read
                $pg_passage = get_pg_passage($page, FALSE);
                $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '<span class="counter">(' . $count . ')</span></span></li>' . "\n";
            } else {
                $items .= ' <li>' . make_pagelink($page, $s_page . '<span class="counter">(' . $count . ')</span>') . '</li>' . "\n";
            }
        }
        $items .= '</ul>' . "\n";
    }
    switch ($view) {
        case 'today':
            $frame = $_popular_plugin_today_frame;
            break;
        case 'yesterday':
            $frame = $_popular_plugin_yesterday_frame;
            break;
        case 'recent':
            $frame = $_popular_plugin_recent_frame;
            break;
        case 'total':
        default:
            $frame = $_popular_plugin_frame;
            break;
    }
    return sprintf($frame, count($counters), $items);
}