function plugin_navititle_inline()
{
    global $newtitle;
    global $page;
    $is_read = arg_check('read') && is_page($vars['page']);
    return '<h1 class="title">' . ($newtitle != '' && $is_read ? $newtitle : $page) . '</h1>';
}
function plugin_monobook_navigation($wikinote, $tabs, $background)
{
    global $vars, $plugin, $_monobook_navigation_messages;
    if (!exist_plugin('monobook_getlink')) {
        die('monobook_getlink plugin not found');
    }
    do_plugin_init('monobook_navigation');
    $main_tabs = '';
    if ($wikinote->is_effect()) {
        $main_tabs = str_replace(array('<ul class="wikinote">', '</ul>', "\n"), '', $wikinote->show_tabs(array(array('cmd' => 'main', 'label' => $_monobook_navigation_messages['article']), array('cmd' => 'note', 'label' => $_monobook_navigation_messages['discuss']))));
    }
    $sub_tabs = '';
    $selected_flag = FALSE;
    foreach ($tabs as $tab) {
        if ($tab === 'edit' && is_freeze($vars['page']) && !in_array('source', $tabs)) {
            $tab = 'source';
        }
        if ($tab === 'edit' && $plugin === 'paraedit') {
            $tab = 'paraedit';
        }
        if ($tab === 'edit' && exist_plugin('revert') && plugin_revert_getlink()) {
            $tab = 'revert';
        }
        list($link, $selected) = plugin_monobook_getlink($tab, $_monobook_navigation_messages, TRUE);
        if (!$link) {
            continue;
        }
        if ($selected) {
            $sub_tabs .= '<li class="selected">' . $link . '</li>';
            $selected_flag = TRUE;
        } else {
            $sub_tabs .= '<li>' . $link . '</li>';
        }
    }
    if (!$selected_flag) {
        $link = plugin_monobook_getlink('nowplugin', $_monobook_navigation_messages);
        if (!$main_tabs) {
            if ($link) {
                $sub_tabs = '<li class="selected" id="separate">' . $link . '</li>' . $sub_tabs;
            } else {
                $sub_tabs = '<li class="selected"><a href="' . get_script_uri() . strrchr($_SERVER['REQUEST_URI'], '?') . '">' . $_monobook_navigation_messages['undefined'] . '</a></li>';
            }
        } elseif ($main_tabs && !arg_check('read') && $link) {
            $sub_tabs = '<li class="selected">' . $link . '</li>' . $sub_tabs;
        }
    }
    return '<div id="navigator"><ul' . $background . '>' . $main_tabs . $sub_tabs . '</ul></div>' . "\n";
}
Esempio n. 3
0
/* enter送信防止 */
$(function(){
  $("input[type=text]").keydown(function(ev) {
    if ((ev.which && ev.which === 13) ||
        (ev.keyCode && ev.keyCode === 13)) {
      return false;
    } else {
      return true;
    }
  });
});

</script>

<?php 
if (arg_check('read') && exist_plugin_convert('menu')) {
    ?>
<script src="skin/snsCount.js?150804" id="snsCount" data-url=<?php 
    if ($vars["page"] == "FrontPage") {
        ?>
"http://pad.rtwiki.net/"<?php 
    } else {
        ?>
"<?php 
        echo $script . '?';
        echo rawurlencode($_page);
        ?>
"<?php 
    }
    ?>
></script>
Esempio n. 4
0
<?php 
}
?>
  <td class="ctable" valign="top">
   <?php 
if ($is_page and exist_plugin_convert('topicpath')) {
    echo do_plugin_convert('topicpath');
}
?>
   <div id="body"><?php 
echo $body;
?>
</div>
  </td>
<?php 
if (arg_check('read') && exist_plugin_convert('side') && do_plugin_convert('side') != '') {
    ?>
  <td class="rtable" valign="top"><div id="sidebar"><?php 
    echo do_plugin_convert('side');
    ?>
</div></td>
<?php 
}
?>
 </tr>
</table>
</div>

<?php 
if ($notes) {
    ?>
Esempio n. 5
0
    ?>

 <?php 
    if ($rw) {
        ?>
	<?php 
        _navigator('new');
        ?>
 <?php 
    }
    ?>
   <?php 
    _navigator('list');
    ?>
 <?php 
    if (arg_check('list')) {
        ?>
   <?php 
        _navigator('filelist');
        ?>
 <?php 
    }
    ?>
   <?php 
    _navigator('search');
    ?>
   <?php 
    _navigator('recent');
    ?>
   <?php 
    _navigator('help');
Esempio n. 6
0
function plugin_toolbar_convert()
{
    global $do_backup, $trackback, $referer;
    global $function_freeze;
    global $vars;
    // $is_read = (arg_check('read') && is_page($vars['page']));
    $is_read = is_page($vars['page']);
    $is_readonly = auth::check_role('readonly');
    $is_safemode = auth::check_role('safemode');
    $is_createpage = auth::is_check_role(PKWK_CREATE_PAGE);
    $num = func_num_args();
    $args = $num ? func_get_args() : array();
    $body = '';
    while (!empty($args)) {
        $name = array_shift($args);
        switch ($name) {
            case 'freeze':
                if ($is_readonly) {
                    break;
                }
                if (!$is_read) {
                    break;
                }
                if ($function_freeze) {
                    if (!is_freeze($vars['page'])) {
                        $name = 'freeze';
                    } else {
                        $name = 'unfreeze';
                    }
                    if ($body != '') {
                        $body .= "\n";
                    }
                    $body .= _toolbar($name);
                }
                break;
            case 'upload':
                if ($is_readonly) {
                    break;
                }
                if (!$is_read) {
                    break;
                }
                if ($function_freeze && is_freeze($vars['page'])) {
                    break;
                }
                if ((bool) ini_get('file_uploads')) {
                    if ($body != '') {
                        $body .= "\n";
                    }
                    $body .= _toolbar($name);
                }
                break;
            case 'filelist':
                if (arg_check('list')) {
                    if ($body != '') {
                        $body .= "\n";
                    }
                    $body .= _toolbar($name);
                }
                break;
            case 'backup':
                if ($do_backup) {
                    if ($body != '') {
                        $body .= "\n";
                    }
                    $body .= _toolbar($name);
                }
                break;
            case 'trackback':
                if ($trackback) {
                    if ($body != '') {
                        $body .= "\n";
                    }
                    $tbcount = tb_count($vars['page']);
                    if ($tbcount > 0) {
                        $body .= _toolbar($name);
                    } else {
                        if (!$is_read) {
                            $body .= _toolbar($name);
                        }
                    }
                }
                break;
            case 'refer':
                if ($referer) {
                    if ($body != '') {
                        $body .= "\n";
                    }
                    $body .= _toolbar($name);
                }
                break;
            case 'rss':
            case 'mixirss':
                if ($body != '') {
                    $body .= "\n";
                }
                $body .= _toolbar($name);
                break;
            case '|':
                $body .= "\n&nbsp;\n";
                break;
            case 'diff':
                if (!$is_read) {
                    break;
                }
                if ($is_safemode) {
                    break;
                }
                if ($body != '') {
                    $body .= "\n";
                }
                $body .= _toolbar($name);
                break;
            case 'edit':
            case 'guiedit':
                if (!$is_read) {
                    break;
                }
                if ($is_readonly) {
                    break;
                }
                if ($function_freeze && is_freeze($vars['page'])) {
                    break;
                }
                if ($body != '') {
                    $body .= "\n";
                }
                $body .= _toolbar($name);
                break;
            case 'new':
            case 'newsub':
                if ($is_createpage) {
                    break;
                }
            case 'rename':
            case 'copy':
                if ($is_readonly) {
                    break;
                }
            case 'reload':
            case 'print':
            case 'full':
                if (!$is_read) {
                    break;
                }
            default:
                if ($body != '') {
                    $body .= "\n";
                }
                $body .= _toolbar($name);
                break;
        }
    }
    return '<div id="toolbar">' . $body . '</div>';
}
Esempio n. 7
0
function catbody($title, $page, $body)
{
    global $script, $vars, $arg, $defaultpage, $whatsnew, $help_page, $hr;
    global $attach_link, $related_link, $cantedit, $function_freeze;
    global $search_word_color, $_msg_word, $foot_explain, $note_hr, $head_tags;
    global $trackback, $trackback_javascript, $referer, $javascript;
    global $nofollow;
    global $_LANG, $_LINK, $_IMAGE;
    global $pkwk_dtd;
    // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional...
    global $page_title;
    // Title of this site
    global $do_backup;
    // Do backup or not
    global $modifier;
    // Site administrator's  web page
    global $modifierlink;
    // Site administrator's name
    if (!file_exists(SKIN_FILE) || !is_readable(SKIN_FILE)) {
        die_message('SKIN_FILE is not found');
    }
    $_LINK = $_IMAGE = array();
    // Add JavaScript header when ...
    if ($trackback && $trackback_javascript) {
        $javascript = 1;
    }
    // Set something If you want
    if (!PKWK_ALLOW_JAVASCRIPT) {
        unset($javascript);
    }
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $r_page = rawurlencode($_page);
    // Set $_LINK for skin
    $_LINK['add'] = "{$script}?cmd=add&amp;page={$r_page}";
    $_LINK['backup'] = "{$script}?cmd=backup&amp;page={$r_page}";
    $_LINK['copy'] = "{$script}?plugin=template&amp;refer={$r_page}";
    $_LINK['diff'] = "{$script}?cmd=diff&amp;page={$r_page}";
    $_LINK['edit'] = "{$script}?cmd=edit&amp;page={$r_page}";
    $_LINK['filelist'] = "{$script}?cmd=filelist";
    $_LINK['freeze'] = "{$script}?cmd=freeze&amp;page={$r_page}";
    $_LINK['help'] = "{$script}?" . rawurlencode($help_page);
    $_LINK['list'] = "{$script}?cmd=list";
    $_LINK['new'] = "{$script}?plugin=newpage&amp;refer={$r_page}";
    $_LINK['rdf'] = "{$script}?cmd=rss&amp;ver=1.0";
    $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew);
    $_LINK['refer'] = "{$script}?plugin=referer&amp;page={$r_page}";
    $_LINK['reload'] = "{$script}?{$r_page}";
    $_LINK['rename'] = "{$script}?plugin=rename&amp;refer={$r_page}";
    $_LINK['rss'] = "{$script}?cmd=rss";
    $_LINK['rss10'] = "{$script}?cmd=rss&amp;ver=1.0";
    // Same as 'rdf'
    $_LINK['rss20'] = "{$script}?cmd=rss&amp;ver=2.0";
    $_LINK['search'] = "{$script}?cmd=search";
    $_LINK['top'] = "{$script}?" . rawurlencode($defaultpage);
    if ($trackback) {
        $tb_id = tb_get_id($_page);
        $_LINK['trackback'] = "{$script}?plugin=tb&amp;__mode=view&amp;tb_id={$tb_id}";
    }
    $_LINK['unfreeze'] = "{$script}?cmd=unfreeze&amp;page={$r_page}";
    $_LINK['upload'] = "{$script}?plugin=attach&amp;pcmd=upload&amp;page={$r_page}";
    // Compat: Skins for 1.4.4 and before
    $link_add =& $_LINK['add'];
    $link_new =& $_LINK['new'];
    // New!
    $link_edit =& $_LINK['edit'];
    $link_diff =& $_LINK['diff'];
    $link_top =& $_LINK['top'];
    $link_list =& $_LINK['list'];
    $link_filelist =& $_LINK['filelist'];
    $link_search =& $_LINK['search'];
    $link_whatsnew =& $_LINK['recent'];
    $link_backup =& $_LINK['backup'];
    $link_help =& $_LINK['help'];
    $link_trackback =& $_LINK['trackback'];
    // New!
    $link_rdf =& $_LINK['rdf'];
    // New!
    $link_rss =& $_LINK['rss'];
    $link_rss10 =& $_LINK['rss10'];
    // New!
    $link_rss20 =& $_LINK['rss20'];
    // New!
    $link_freeze =& $_LINK['freeze'];
    $link_unfreeze =& $_LINK['unfreeze'];
    $link_upload =& $_LINK['upload'];
    $link_template =& $_LINK['copy'];
    $link_refer =& $_LINK['refer'];
    // New!
    $link_rename =& $_LINK['rename'];
    // Init flags
    $is_page = is_pagename($_page) && !arg_check('backup') && $_page != $whatsnew;
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    // Last modification date (string) of the page
    $lastmodified = $is_read ? format_date(get_filetime($_page)) . ' ' . get_pg_passage($_page, FALSE) : '';
    // List of attached files to the page
    $attaches = $attach_link && $is_read && exist_plugin_action('attach') ? attach_filelist() : '';
    // List of related pages
    $related = $related_link && $is_read ? make_related($_page) : '';
    // List of footnotes
    ksort($foot_explain, SORT_NUMERIC);
    $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : '';
    // Tags will be inserted into <head></head>
    $head_tag = !empty($head_tags) ? join("\n", $head_tags) . "\n" : '';
    // 1.3.x compat
    // Last modification date (UNIX timestamp) of the page
    $fmt = $is_read ? get_filetime($_page) + LOCALZONE : 0;
    // Search words
    if ($search_word_color && isset($vars['word'])) {
        $body = '<div class="small">' . $_msg_word . htmlsc($vars['word']) . '</div>' . $hr . "\n" . $body;
        // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
        // with array_splice(), array_flip()
        $words = preg_split('/\\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY);
        $words = array_splice($words, 0, 10);
        // Max: 10 words
        $words = array_flip($words);
        $keys = array();
        foreach ($words as $word => $id) {
            $keys[$word] = strlen($word);
        }
        arsort($keys, SORT_NUMERIC);
        $keys = get_search_words(array_keys($keys), TRUE);
        $id = 0;
        foreach ($keys as $key => $pattern) {
            $s_key = htmlsc($key);
            $pattern = '/' . '<textarea[^>]*>.*?<\\/textarea>' . '|' . '<[^>]*>' . '|' . '&[^;]+;' . '|' . '(' . $pattern . ')' . '/sS';
            $decorate_Nth_word = create_function('$matches', 'return (isset($matches[1])) ? ' . '\'<strong class="word' . $id . '">\' . $matches[1] . \'</strong>\' : ' . '$matches[0];');
            $body = preg_replace_callback($pattern, $decorate_Nth_word, $body);
            $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes);
            ++$id;
        }
    }
    $longtaketime = getmicrotime() - MUTIME;
    $taketime = sprintf('%01.03f', $longtaketime);
    require SKIN_FILE;
}
Esempio n. 8
0
     if (isset($tools['qbloglink'])) {
         unset($tools['qbloglink']);
     }
 }
 // レイアウトページの時の管理ウィンドウの制御
 if ($no_toolmenu) {
     if (!is_bootstrap_skin()) {
         $tools = array('editlink' => $tools['editlink'], 'reflink' => $tools['reflink'], 'pagelink' => $tools['pagelink']);
     }
     unset($tools['pagelink']['sub']['sharelink']);
     unset($tools['pagelink']['sub']['renamelink']);
     unset($tools['pagelink']['sub']['dellink']);
     unset($tools['pagelink']['sub']['copylink']);
     unset($tools['pagelink']['sub']['maplink']);
     unset($tools['pagelink']['sub']['tinyurllink']);
     if (arg_check('backup') or arg_check('diff')) {
         $tools['reflink']['visible'] = FALSE;
     }
 }
 $tools_str = '<ul class="toolbar_menu">';
 foreach ($tools as $lv1key => $lv1) {
     // main menu
     $style = $lv1['style'] != '' ? $lv1['style'] : '';
     // visible
     if ($lv1['visible']) {
         // link
         if ($lv1['link'] != '') {
             $class = isset($lv1['class']) && $lv1['class'] != '' ? ' class="' . $lv1['class'] . '"' : '';
             $target = $lv1key == 'helplink' ? ' target="help"' : '';
             $tools_str .= '<li style="background-image:none;' . $style . '"' . $class . '><a href="' . $lv1['link'] . '"' . $target . ' id="' . $lv1key . '">' . $lv1['name'] . '</a>';
         } else {
Esempio n. 9
0
function plugin_navibar2_keyword($name)
{
    global $_LINK;
    global $do_backup, $trackback, $referer;
    global $function_freeze;
    global $vars;
    if ($_LINK['reload'] == '') {
        return array();
    }
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    switch ($name) {
        case 'freeze':
            if ($is_read && $function_freeze) {
                if (!$is_freeze) {
                    $name = 'freeze';
                    return _navigator2($name);
                }
            }
            break;
        case 'unfreeze':
            if ($is_read && $function_freeze) {
                if ($is_freeze) {
                    $name = 'unfreeze';
                    return _navigator2($name);
                }
            }
            break;
        case 'upload':
            if ($is_read && (bool) ini_get('file_uploads')) {
                return _navigator2($name);
            }
            break;
        case 'filelist':
            if (arg_check('list')) {
                return _navigator2($name);
            }
            break;
        case 'backup':
            if ($do_backup) {
                return _navigator2($name);
            }
            break;
        case 'brokenlink':
        case 'template':
        case 'source':
            if (!empty($_page)) {
                return _navigator2($name);
            }
            break;
        case 'trackback':
            if ($trackback) {
                $tbcount = tb_count($_page);
                if ($tbcount > 0) {
                    return _navigator2($name, 'Trackback(' . $tbcount . ')');
                } else {
                    if ($is_read) {
                        return array('text' => 'no Trackback');
                    } else {
                        if ($vars['cmd'] == 'list') {
                            return _navigator2($name, 'Trackback list');
                        }
                    }
                }
            }
            break;
        case 'refer':
        case 'skeylist':
        case 'linklist':
            if ($referer) {
                if (!isset($refcount)) {
                    $refcount = ref_count($vars['page']);
                }
                if ($refcount > 0) {
                    return _navigator2($name);
                }
            }
            break;
        case 'log_login':
            if (log_exist('login', $vars['page'])) {
                return _navigator2($name);
            }
            break;
        case 'log_check':
            if (log_exist('check', $vars['page'])) {
                return _navigator2($name);
            }
            break;
        case 'log_browse':
            if (log_exist('browse', $vars['page'])) {
                return _navigator2($name);
            }
            break;
        case 'log_update':
            if (log_exist('update', $vars['page'])) {
                return _navigator2($name);
            }
            break;
        case 'log_down':
            if (log_exist('download', $vars['page'])) {
                return _navigator2($name);
            }
            break;
            // case 'new':
        // case 'new':
        case 'newsub':
        case 'edit':
        case 'guiedit':
        case 'diff':
            if (!$is_read) {
                break;
            }
        default:
            return _navigator2($name);
    }
    return array();
}
Esempio n. 10
0
function catbody($title, $page, $body)
{
    global $script;
    // MUST BE SKIN.FILE. Do not delete line.
    global $vars, $arg, $defaultpage, $whatsnew, $help_page, $hr;
    global $attach_link, $related_link, $function_freeze;
    global $search_word_color, $foot_explain, $note_hr, $head_tags, $foot_tags;
    global $trackback, $referer, $javascript;
    global $newtitle, $newbase, $language, $use_local_time;
    // Plus! skin extension
    global $nofollow;
    global $_LANG, $_LINK, $_IMAGE;
    global $pkwk_dtd;
    // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional...
    global $page_title;
    // Title of this site
    global $do_backup;
    // Do backup or not
    global $modifier;
    // Site administrator's  web page
    global $modifierlink;
    // Site administrator's name
    global $skin_file, $menubar, $sidebar;
    global $_string;
    if (!defined('SKIN_FILE') || !file_exists(SKIN_FILE) || !is_readable(SKIN_FILE)) {
        if (!file_exists($skin_file) || !is_readable($skin_file)) {
            die_message(SKIN_FILE . '(skin file) is not found.');
        } else {
            define('SKIN_FILE', $skin_file);
        }
    }
    $_LINK = $_IMAGE = array();
    // Add JavaScript header when ...
    if (!PKWK_ALLOW_JAVASCRIPT) {
        unset($javascript);
    }
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $r_page = rawurlencode($_page);
    // Set $_LINK for skin
    $_LINK['add'] = get_cmd_uri('add', $_page);
    $_LINK['backup'] = get_cmd_uri('backup', $_page);
    $_LINK['brokenlink'] = get_cmd_uri('brokenlink', $_page);
    $_LINK['copy'] = get_cmd_uri('template', '', '', 'refer=' . $r_page);
    $_LINK['diff'] = get_cmd_uri('diff', $_page);
    $_LINK['edit'] = get_cmd_uri('edit', $_page);
    $_LINK['guiedit'] = get_cmd_uri('guiedit', $_page);
    $_LINK['filelist'] = get_cmd_uri('filelist');
    $_LINK['freeze'] = get_cmd_uri('freeze', $_page);
    $_LINK['help'] = get_cmd_uri('help');
    $_LINK['linklist'] = get_cmd_uri('linklist', $_page);
    $_LINK['list'] = get_cmd_uri('list');
    $_LINK['log_login'] = get_cmd_uri('logview', '', '', 'kind=login');
    $_LINK['log_browse'] = get_cmd_uri('logview', $_page, '', 'kind=browse');
    $_LINK['log_update'] = get_cmd_uri('logview', $_page);
    $_LINK['log_down'] = get_cmd_uri('logview', $_page, '', 'kind=download');
    $_LINK['log_check'] = get_cmd_uri('logview', $_page, '', 'kind=check');
    $_LINK['menu'] = get_page_uri($menubar);
    $_LINK['new'] = get_cmd_uri('newpage', '', '', 'refer=' . $r_page);
    $_LINK['newsub'] = get_cmd_uri('newpage_subdir', '', '', 'directory=' . $r_page);
    $_LINK['print'] = get_cmd_uri('print', $_page);
    $_LINK['full'] = get_cmd_uri('print', $_page) . '&amp;nohead&amp;nofoot';
    $_LINK['read'] = get_page_uri($_page);
    $_LINK['recent'] = get_page_uri($whatsnew);
    $_LINK['refer'] = get_cmd_uri('referer', $_page);
    $_LINK['reload'] = get_page_absuri($_page);
    // 本当は、get_script_uri でいいけど、絶対パスでないと、スキンに影響が出る
    $_LINK['reload_rel'] = get_page_uri($_page);
    $_LINK['rename'] = get_cmd_uri('rename', '', '', 'refer=' . $r_page);
    $_LINK['skeylist'] = get_cmd_uri('skeylist', $_page);
    $_LINK['search'] = get_cmd_uri('search');
    $_LINK['side'] = get_page_uri($sidebar);
    $_LINK['source'] = get_cmd_uri('source', $_page);
    $_LINK['template'] = get_cmd_uri('template', '', '', 'refer=' . $r_page);
    $_LINK['top'] = get_page_uri($defaultpage);
    if ($trackback) {
        $tb_id = tb_get_id($_page);
        $_LINK['trackback'] = get_cmd_uri('tb', '', '', '__mode=view&tb_id=' . $tb_id);
    }
    $_LINK['unfreeze'] = get_cmd_uri('unfreeze', $_page);
    $_LINK['upload'] = get_cmd_uri('attach', $_page, '', 'pcmd=upload');
    // link rel="alternate" にも利用するため absuri にしておく
    $_LINK['rdf'] = get_cmd_absuri('rss', '', 'ver=1.0');
    $_LINK['rss'] = get_cmd_absuri('rss');
    $_LINK['rss10'] = get_cmd_absuri('rss', '', 'ver=1.0');
    // Same as 'rdf'
    $_LINK['rss20'] = get_cmd_absuri('rss', '', 'ver=2.0');
    $_LINK['mixirss'] = get_cmd_absuri('mixirss');
    // Same as 'rdf' for mixi
    // Compat: Skins for 1.4.4 and before
    $link_add =& $_LINK['add'];
    $link_backup =& $_LINK['backup'];
    $link_brokenlink =& $_LINK['brokenlink'];
    $link_template =& $_LINK['copy'];
    $link_diff =& $_LINK['diff'];
    $link_edit =& $_LINK['edit'];
    $link_guiedit =& $_LINK['guiedit'];
    $link_filelist =& $_LINK['filelist'];
    $link_freeze =& $_LINK['freeze'];
    $link_help =& $_LINK['help'];
    $link_linklist =& $_LINK['linklist'];
    $link_list =& $_LINK['list'];
    $link_log_login =& $_LINK['log_login'];
    $link_log_browse =& $_LINK['log_browse'];
    $link_log_update =& $_LINK['log_update'];
    $link_log_down =& $_LINK['log_down'];
    $link_log_check =& $_LINK['log_check'];
    $link_menu =& $_LINK['menu'];
    $link_new =& $_LINK['new'];
    $link_newsub =& $_LINK['newsub'];
    $link_print =& $_LINK['print'];
    $link_full =& $_LINK['full'];
    $link_read =& $_LINK['read'];
    $link_whatsnew =& $_LINK['recent'];
    $link_refer =& $_LINK['refer'];
    $link_reload =& $_LINK['reload'];
    $link_reload_rel =& $_LINK['reload_rel'];
    $link_rename =& $_LINK['rename'];
    $link_skeylist =& $_LINK['skeylist'];
    $link_search =& $_LINK['search'];
    $link_side =& $_LINK['side'];
    $link_source =& $_LINK['source'];
    $link_top =& $_LINK['top'];
    if ($trackback) {
        $link_trackback =& $_LINK['trackback'];
    }
    $link_unfreeze =& $_LINK['unfreeze'];
    $link_upload =& $_LINK['upload'];
    //
    $link_rdf =& $_LINK['rdf'];
    $link_rss =& $_LINK['rss'];
    $link_rss10 =& $_LINK['rss10'];
    $link_rss20 =& $_LINK['rss20'];
    $link_mixirss =& $_LINK['mixirss'];
    // Init flags
    $is_page = is_pagename($_page) && !arg_check('backup') && !is_cantedit($_page);
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    // Last modification date (string) of the page
    $lastmodified = $is_read ? get_date('D, d M Y H:i:s T', get_filetime($_page)) . ' ' . get_pg_passage($_page, FALSE) : '';
    // List of attached files to the page
    $attaches = '';
    if ($attach_link && $is_read && exist_plugin_action('attach')) {
        if (do_plugin_init('attach') !== FALSE) {
            $attaches = attach_filelist();
        }
    }
    // List of related pages
    $related = $related_link && $is_read ? make_related($_page) : '';
    // List of footnotes
    ksort($foot_explain, SORT_NUMERIC);
    $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : '';
    // Tags will be inserted into <head></head>
    $head_tag = !empty($head_tags) ? join("\n", $head_tags) . "\n" : '';
    $foot_tag = !empty($foot_tags) ? join("\n", $foot_tags) . "\n" : '';
    // 1.3.x compat
    // Last modification date (UNIX timestamp) of the page
    $fmt = $is_read ? get_filetime($_page) : 0;
    // Search words
    if ($search_word_color && isset($vars['word'])) {
        $body = '<div class="small">' . $_string['word'] . htmlspecialchars($vars['word']) . '</div>' . $hr . "\n" . $body;
        // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
        $words = preg_split('/\\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY);
        $words = array_splice($words, 0, 10);
        // Max: 10 words
        $words = array_flip($words);
        $keys = array();
        foreach ($words as $word => $id) {
            $keys[$word] = strlen($word);
        }
        arsort($keys, SORT_NUMERIC);
        $keys = get_search_words(array_keys($keys), TRUE);
        $id = 0;
        foreach ($keys as $key => $pattern) {
            $s_key = htmlspecialchars($key);
            $pattern = '/' . '<textarea[^>]*>.*?<\\/textarea>' . '|' . '<[^>]*>' . '|' . '&[^;]+;' . '|' . '(' . $pattern . ')' . '/sS';
            $decorate_Nth_word = create_function('$matches', 'return (isset($matches[1])) ? ' . '\'<strong class="word' . $id . '">\' . $matches[1] . \'</strong>\' : ' . '$matches[0];');
            $body = preg_replace_callback($pattern, $decorate_Nth_word, $body);
            $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes);
            ++$id;
        }
    }
    // Compat: 'HTML convert time' without time about MenuBar and skin
    $taketime = elapsedtime();
    require SKIN_FILE;
}
Esempio n. 11
0
function plugin_navibar_convert()
{
    global $_LINK;
    global $do_backup, $trackback, $referer;
    global $function_freeze;
    global $vars;
    if ($_LINK['reload'] == '') {
        return '#navibar: plugin called from wikipage. skipped.';
    }
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    $num = func_num_args();
    $args = $num ? func_get_args() : array();
    $body = '';
    $line = '';
    while (!empty($args)) {
        $name = array_shift($args);
        switch ($name) {
            case 'freeze':
                if ($is_read && $function_freeze) {
                    if (!$is_freeze) {
                        $name = 'freeze';
                        if ($body != '' && $oldname != '|') {
                            $body .= ' | ';
                        }
                        $body .= _navigator($name);
                    }
                }
                break;
            case 'unfreeze':
                if ($is_read && $function_freeze) {
                    if ($is_freeze) {
                        $name = 'unfreeze';
                        if ($body != '' && $oldname != '|') {
                            $body .= ' | ';
                        }
                        $body .= _navigator($name);
                    }
                }
                break;
            case 'upload':
                if ($is_read && (bool) ini_get('file_uploads')) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'filelist':
                if (arg_check('list')) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'backup':
                if ($do_backup) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'brokenlink':
            case 'template':
            case 'source':
                if (!empty($_page)) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'trackback':
                if ($trackback) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $tbcount = tb_count($_page);
                    if ($tbcount > 0) {
                        $body .= _navigator($name, 'Trackback(' . $tbcount . ')');
                    } else {
                        if ($is_read) {
                            $body .= 'no Trackback';
                        } else {
                            if (isset($vars['cmd']) && $vars['cmd'] == 'list') {
                                $body .= _navigator($name, 'Trackback list');
                            }
                        }
                    }
                }
                break;
            case 'refer':
            case 'skeylist':
            case 'linklist':
                if ($referer) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'log_login':
                if (log_exist('login', $vars['page'])) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'log_check':
                if (log_exist('check', $vars['page'])) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'log_browse':
                if ($body != '' && $oldname != '|') {
                    $body .= ' | ';
                }
                $body .= _navigator($name);
                //			if (log_exist('browse',$vars['page'])) {
                //				return _navigator($name);
                //			}
                break;
            case 'log_update':
                if (log_exist('update', $vars['page'])) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case 'log_down':
                if (log_exist('download', $vars['page'])) {
                    if ($body != '' && $oldname != '|') {
                        $body .= ' | ';
                    }
                    $body .= _navigator($name);
                }
                break;
            case '|':
                if (trim($body) != '') {
                    $line .= '[ ' . $body . ' ]' . "\n\n";
                    $body = '';
                }
                break;
                // case 'new':
            // case 'new':
            case 'newsub':
            case 'edit':
            case 'guiedit':
            case 'diff':
                if (!$is_read) {
                    break;
                }
            default:
                if ($body != '' && $oldname != '|') {
                    $body .= ' | ';
                }
                $body .= _navigator($name);
                break;
        }
        $oldname = $name;
        $body .= ' ';
    }
    if (trim($body) != '') {
        $line .= '[ ' . $body . ' ]' . "\n\n";
        $body = '';
    }
    return '<div id="navigator">' . $line . '</div>';
}
Esempio n. 12
0
File: html.php Progetto: big2men/qhm
function catbody($title, $page, $body)
{
    global $script, $script_ssl, $vars, $arg, $defaultpage, $whatsnew, $help_page, $hr;
    global $attach_link, $related_link, $cantedit, $function_freeze;
    global $search_word_color, $_msg_word, $foot_explain, $note_hr, $head_tags;
    global $trackback, $trackback_javascript, $referer, $javascript;
    global $nofollow, $non_list;
    global $_LANG, $_LINK, $_IMAGE;
    global $pkwk_dtd;
    // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional...
    global $page_title;
    // Title of this site
    global $do_backup;
    // Do backup or not
    global $modifier;
    // Site administrator's  web page
    global $modifierlink;
    // Site administrator's name
    global $owneraddr;
    // Site owner address
    global $ownertel;
    // Site owner tel
    global $headcopy;
    // Site headcopy
    global $menuadmin;
    // Menu Administrate Page
    global $style_type, $style_name, $logo_image, $logo_header;
    global $keywords, $description, $accesstag, $ga_tracking_id, $killer_fg, $killer_bg, $noindex, $accesstag_moved;
    //for skin by hokuken
    global $qhm_adminmenu;
    // Site administration menu 20 JUN 2007
    global $custom_meta;
    // Insert meta tag for specific meta tag
    global $adcode;
    // AD code (exp. Google Adwords, Analytics ... )  25 JLY 2007 by hokuken.com
    global $nowindow;
    // Disable including external_link.js
    global $killer_page2;
    // for Killer page Design 2
    global $no_qhm_licence;
    // qhm licence
    global $include_skin_file_path;
    //orignal skin setting
    global $qhm_access_key;
    global $reg_exp_host;
    global $unload_confirm, $check_login;
    global $enable_wp_theme, $enable_wp_theme_name, $wp_add_css;
    //WordPress用のテーマ
    global $mobile_redirect, $googlemaps_apikey;
    global $other_plugins, $other_plugin_categories;
    global $default_script, $init_scripts;
    global $enable_smart_style, $smart_name;
    // smart phone
    global $is_update;
    global $enable_fitvids;
    // body部分以外は、元々の$script を使う(通常のリンク設定)を使う
    // 結果、$body内は、script_sslを使ったリンクになるが、ナビ、メニューなどは、元の$scriptを必ず使う
    $script = $init_scripts['normal'];
    $script_ssl = $init_scripts['ssl'];
    if (!file_exists(SKIN_FILE) || !is_readable(SKIN_FILE)) {
        die_message('SKIN_FILE is not found');
    }
    $_LINK = $_IMAGE = array();
    // Add JavaScript header when ...
    if ($trackback && $trackback_javascript) {
        $javascript = 1;
    }
    // Set something If you want
    if (!PKWK_ALLOW_JAVASCRIPT) {
        unset($javascript);
    }
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $r_page = rawurlencode($_page);
    //QHM Template
    $qt = get_qt();
    if (!$qt->set_page) {
        $qt->set_page($_page);
    }
    //QHM Messages
    $qm = get_qm();
    // Set $_LINK for skin
    $_LINK['add'] = "{$script}?cmd=add&amp;page={$r_page}";
    $_LINK['backup'] = "{$script}?cmd=backup&amp;page={$r_page}";
    $_LINK['copy'] = "{$script}?plugin=template&amp;refer={$r_page}";
    $_LINK['diff'] = "{$script}?cmd=diff&amp;page={$r_page}";
    $_LINK['edit'] = "{$script}?cmd=edit&amp;page={$r_page}";
    $_LINK['filelist'] = "{$script}?cmd=filelist";
    $_LINK['freeze'] = "{$script}?cmd=freeze&amp;page={$r_page}";
    $_LINK['help'] = "{$script}?" . rawurlencode($help_page);
    $_LINK['list'] = "{$script}?cmd=list";
    $_LINK['new'] = "{$script}?plugin=newpage&amp;refer={$r_page}";
    $_LINK['rdf'] = "{$script}?cmd=rss&amp;ver=1.0";
    $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew);
    $_LINK['refer'] = "{$script}?plugin=referer&amp;page={$r_page}";
    $_LINK['reload'] = "{$script}?{$r_page}";
    $_LINK['rename'] = "{$script}?plugin=rename&amp;refer={$r_page}";
    $_LINK['delete'] = "{$script}?plugin=delete&amp;page={$r_page}";
    $_LINK['rss'] = "{$script}?cmd=rss";
    $_LINK['rss10'] = "{$script}?cmd=rss&amp;ver=1.0";
    // Same as 'rdf'
    $_LINK['rss20'] = "{$script}?cmd=rss&amp;ver=2.0";
    $_LINK['search'] = "{$script}?cmd=search";
    $_LINK['top'] = dirname($script . 'dummy.php') . '/';
    if ($trackback) {
        $tb_id = tb_get_id($_page);
        $_LINK['trackback'] = "{$script}?plugin=tb&amp;__mode=view&amp;tb_id={$tb_id}";
    }
    $_LINK['unfreeze'] = "{$script}?cmd=unfreeze&amp;page={$r_page}";
    $_LINK['upload'] = "{$script}?plugin=attach&amp;pcmd=upload&amp;page={$r_page}";
    $_LINK['menuadmin'] = "{$script}?" . rawurlencode($menuadmin);
    //Hokuken.com original
    $_LINK['qhm_adminmenu'] = qhm_get_script_path() . "?cmd=qhmauth";
    $_LINK['qhm_logout'] = "{$script}?cmd=qhmlogout";
    $_LINK['qhm_setting'] = "{$script}?cmd=qhmsetting";
    $_LINK['edit_menu'] = "{$script}?cmd=edit&amp;page=MenuBar";
    $_LINK['edit_menu2'] = "{$script}?cmd=edit&amp;page=MenuBar2";
    $_LINK['edit_navi'] = "{$script}?cmd=edit&amp;page=SiteNavigator";
    $_LINK['edit_navi2'] = "{$script}?cmd=edit&amp;page=SiteNavigator2";
    $_LINK['edit_header'] = "{$script}?cmd=edit&amp;page=SiteHeader";
    $_LINK['yetlist'] = "{$script}?cmd=yetlist";
    // Compat: Skins for 1.4.4 and before
    $link_add =& $_LINK['add'];
    $link_new =& $_LINK['new'];
    // New!
    $link_edit =& $_LINK['edit'];
    $link_diff =& $_LINK['diff'];
    $link_top =& $_LINK['top'];
    $link_list =& $_LINK['list'];
    $link_filelist =& $_LINK['filelist'];
    $link_search =& $_LINK['search'];
    $link_whatsnew =& $_LINK['recent'];
    $link_backup =& $_LINK['backup'];
    $link_help =& $_LINK['help'];
    $link_trackback =& $_LINK['trackback'];
    // New!
    $link_rdf =& $_LINK['rdf'];
    // New!
    $link_rss =& $_LINK['rss'];
    $link_rss10 =& $_LINK['rss10'];
    // New!
    $link_rss20 =& $_LINK['rss20'];
    // New!
    $link_freeze =& $_LINK['freeze'];
    $link_unfreeze =& $_LINK['unfreeze'];
    $link_upload =& $_LINK['upload'];
    $link_template =& $_LINK['copy'];
    $link_refer =& $_LINK['refer'];
    // New!
    $link_rename =& $_LINK['rename'];
    $link_delete =& $_LINK['delete'];
    $link_menuadmin =& $_LINK['menuadmin'];
    //Hokuken.com original
    $link_copy =& $_LINK['copy'];
    $link_qhm_adminmenu =& $_LINK['qhm_adminmenu'];
    //Hokuken.com original
    $link_qhm_logout =& $_LINK['qhm_logout'];
    //Hokuken.com original
    $link_qhm_setting =& $_LINK['qhm_setting'];
    //Hokuken.com original
    $link_edit_menu =& $_LINK['edit_menu'];
    //Hokuken.com original
    $link_edit_menu2 =& $_LINK['edit_menu2'];
    $link_edit_navi =& $_LINK['edit_navi'];
    //Hokuken.com original
    $link_edit_navi2 =& $_LINK['edit_navi2'];
    //Hokuken.com original
    $link_edit_header =& $_LINK['edit_header'];
    //Hokuken.com original
    $link_yetlist =& $_LINK['yetlist'];
    //Hokuken.com original
    // Init flags
    $is_page = is_pagename($_page) && $_page != $whatsnew;
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    // Last modification date (string) of the page
    $lastmodified = $is_read ? format_date(get_filetime($_page)) . ' ' . get_pg_passage($_page, FALSE) : '';
    // List of attached files to the page
    $attaches = $attach_link && $is_read && exist_plugin_action('attach') ? attach_filelist() : '';
    // List of related pages
    $related = $related_link && $is_read ? make_related($_page) : '';
    // List of footnotes
    ksort($foot_explain, SORT_NUMERIC);
    $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : '';
    // Tags will be inserted into <head></head>
    $head_tag = !empty($head_tags) ? join("\n", $head_tags) . "\n" : '';
    // 1.3.x compat
    // Last modification date (UNIX timestamp) of the page
    $fmt = $is_read ? get_filetime($_page) + LOCALZONE : 0;
    // Search words
    if ($search_word_color && isset($vars['word'])) {
        $body = '<div class="small">' . $_msg_word . htmlspecialchars($vars['word']) . '</div>' . $hr . "\n" . $body;
        // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
        // with array_splice(), array_flip()
        $words = preg_split('/\\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY);
        $words = array_splice($words, 0, 10);
        // Max: 10 words
        $words = array_flip($words);
        $keys = array();
        foreach ($words as $word => $id) {
            $keys[$word] = strlen($word);
        }
        arsort($keys, SORT_NUMERIC);
        $keys = get_search_words(array_keys($keys), TRUE);
        $id = 0;
        foreach ($keys as $key => $pattern) {
            $s_key = htmlspecialchars($key);
            $pattern = '/' . '<textarea[^>]*>.*?<\\/textarea>' . '|' . '<[^>]*>' . '|' . '&[^;]+;' . '|' . '(' . $pattern . ')' . '/sS';
            $decorate_Nth_word = create_function('$matches', 'return (isset($matches[1])) ? ' . '\'<strong class="word' . $id . '">\' . $matches[1] . \'</strong>\' : ' . '$matches[0];');
            $body = preg_replace_callback($pattern, $decorate_Nth_word, $body);
            $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes);
            ++$id;
        }
    }
    //-----------------------------------------------------------------------
    //
    // customized by hokuken for QHM (2009/1/28)
    //
    //-----------------------------------------------------------------------
    //----------------- 携帯の場合の処理 --------------------------------------
    if (preg_match('/keitai.skin.php$/', SKIN_FILE)) {
        require LIB_DIR . 'qhm_init.php';
        require LIB_DIR . 'qhm_init_main.php';
        require SKIN_FILE;
        return;
    }
    //------------------- IF UA is mobile, end here -----------------------
    //---------- KILLERPAGE: でもKILLERPAGE2:に統合 いつか消したい --------------
    if ($killer_fg != '') {
        //load common setting and output header
        require LIB_DIR . 'qhm_init.php';
        $killer_page2['fg'] = $killer_fg;
        $killer_page2['bg'] = $killer_bg;
        $killer_page2['width'] = 700;
        $killer_page2['padding'] = 60;
        $killer_page2['bg_body'] = '#fff';
        $killer_page2['fg_body'] = '#000';
        require LIB_DIR . 'qhm_init_killer.php';
        $longtaketime = getmicrotime() - MUTIME;
        $taketime = sprintf('%01.03f', $longtaketime);
        $qt->setv('taketime', $taketime);
    }
    //--------------------------- いつか消したい end here ----------------
    ///////////////////////////////////////////////////////////////////
    //
    // Main
    //
    //common setting
    require LIB_DIR . 'qhm_init.php';
    $qt->enable_cache = $qt->getv('editable') ? false : $qt->enable_cache;
    $qt->set_encode($shiftjis || $eucjp ? true : false);
    if ($shiftjis) {
        $output_encode = 'Shift_JIS';
    } else {
        if ($eucjp) {
            $output_encode = 'EUC-JP';
        } else {
            $output_encode = CONTENT_CHARSET;
        }
    }
    define('WORDPRESS_CHARSET', $output_encode);
    //output common header (available change encode)
    $qt->setv('meta_content_type', qhm_output_dtd($pkwk_dtd, CONTENT_CHARSET, $output_encode));
    //------- KILLERPAGE2: セールスレター型デザイン -------------------
    if (isset($killer_page2['fg']) != '') {
        require LIB_DIR . 'qhm_init_killer.php';
        //JQuery Include
        $jquery_script = '';
        $jquery_cookie_script = '';
        if ($qt->getv('jquery_include')) {
            $jquery_script = '<script type="text/javascript" src="js/jquery.js"></script>';
            $jquery_cookie_script = '<script type="text/javascript" src="js/jquery.cookie.js"></script>';
        }
        $bootstrap_style = $bootstrap_script = '';
        if ($qt->getv('bootstrap_script')) {
            $bootstrap_style = $qt->getv('bootstrap_style');
            $bootstrap_script = $qt->getv('bootstrap_script');
        }
        $qt->setv('jquery_script', $bootstrap_style . $jquery_script . $bootstrap_script);
        $qt->setv('jquery_cookie_script', $jquery_cookie_script);
        $longtaketime = getmicrotime() - MUTIME;
        $taketime = sprintf('%01.03f', $longtaketime);
        $qt->setv('taketime', $taketime);
        $qt->read('skin/killerpage2/pukiwiki.skin.php');
        return;
    }
    //-------------------------------------------------------------
    // ---- include main design skin file ----
    if (isset($_SESSION['temp_skin']) && strlen($_SESSION['temp_skin']) > 0) {
        $style_type = $_SESSION['temp_style_type'];
    }
    //pluginでデザインが指定されている場合
    if ($include_skin_file_path != '') {
        $style_name = $include_skin_file_path;
    }
    require LIB_DIR . 'qhm_init_main.php';
    // meta:GENERATOR
    $generator_tag = '<meta name="GENERATOR" content="Quick Homepage Maker; version=' . QHM_VERSION . '; haik=' . (is_bootstrap_skin() ? 'true' : 'false') . '" />' . "\n";
    $qt->prependv_once('generator_tag', 'beforescript', $generator_tag);
    //-------------------------------------------------
    // ogp タグを挿入
    //-------------------------------------------------
    if (exist_plugin('ogp')) {
        plugin_ogp_set_template($body);
    }
    //独自のテンプレートファイルをチェック
    $skin_file = SKIN_DIR . "{$style_name}/pukiwiki.skin.php";
    if ($qt->getv('layout_name')) {
        $layout_file = $qt->getv('layout_name') . '.skin.php';
        $layout_path = SKIN_DIR . "{$style_name}/{$layout_file}";
        if (file_exists($layout_path)) {
            $skin_file = $layout_path;
        }
    } else {
        $layout_prefix = 'content';
        if ($_page === $defaultpage) {
            $layout_prefix = 'default';
        } else {
            if (is_qblog()) {
                $layout_prefix = 'article';
            }
        }
        $layout_name = isset($style_config["{$layout_prefix}_layout"]) ? $style_config["{$layout_prefix}_layout"] : "";
        $layout_path = SKIN_DIR . "{$style_name}/{$layout_name}.skin.php";
        if (file_exists($layout_path)) {
            $skin_file = $layout_path;
        }
    }
    if (!file_exists($skin_file)) {
        $skin_file = SKIN_FILE;
        //デフォルトの位置
    }
    // Read design config for customize
    $style_config = read_skin_config($style_name);
    $skin_custom_vars = get_skin_custom_vars($style_name);
    $custom_css = make_custom_css($style_name);
    $qt->prependv('beforescript', $custom_css);
    if (isset($style_config['bootstrap']) && $style_config['bootstrap'] !== false) {
        $qt->setv('jquery_include', true);
    }
    // Default Eyecatch
    if (isset($skin_custom_vars['default_eyecatch']) && $skin_custom_vars['default_eyecatch'] && $qt->getv('main_visual') === '' && exist_plugin('eyecatch')) {
        $bg_image = $color = '';
        if (isset($skin_custom_vars['eyecatch_bgimage'])) {
            $bg_image = $skin_custom_vars['eyecatch_bgimage'];
            $bg_image = is_url($bg_image, TRUE, TRUE) || file_exists(get_file_path($bg_image)) ? $bg_image : '';
        }
        if (isset($skin_custom_vars['enable_eyecatch_bgimage']) && !$skin_custom_vars['enable_eyecatch_bgimage']) {
            $bg_image = '';
        }
        if (isset($skin_custom_vars['eyecatch_color'])) {
            $color = 'color=' . $skin_custom_vars['eyecatch_color'];
        }
        if (is_qblog()) {
            $title_copy = $qblog_title;
        } else {
            if (isset($skin_custom_vars['eyecatch_title_type']) && trim($skin_custom_vars['eyecatch_title_type']) == 'site') {
                $title_copy = $page_title;
            } else {
                if ($_page === $defaultpage) {
                    $title_copy = $page_title;
                } else {
                    $title_copy = get_page_title($_page);
                }
            }
        }
        $content = <<<EOD
! {$title_copy}
EOD;
        plugin_eyecatch_convert($bg_image, $color, '__default', $content);
    }
    if ($qt->getv('no_eyecatch')) {
        $qt->setv('main_visual', "<!-- no eyecatch -->");
    }
    // Determine emptiness of eyecatch
    $qt->setv('eyecatch_is_empty', $qt->getv('no_eyecatch') || $qt->getv('main_visual') === '');
    if (isset($skin_custom_vars['palette_color']) && trim($skin_custom_vars['palette_color'])) {
        $qt->setv('palette_color', trim($skin_custom_vars['palette_color']));
        $qt->setv('palette_color_class', 'haik-palette-' . trim($skin_custom_vars['palette_color']));
    }
    //JQuery Include
    $jquery_script = '';
    $jquery_cookie_script = '';
    if ($qt->getv('jquery_include')) {
        $jquery_script = '<script type="text/javascript" src="js/jquery.js"></script>';
        $jquery_cookie_script = '<script type="text/javascript" src="js/jquery.cookie.js"></script>';
    }
    if ($qt->getv('bootstrap_script')) {
        $bootstrap_script = $qt->getv('bootstrap_script');
    }
    $qt->setv('jquery_script', $jquery_script . $bootstrap_script);
    $qt->setv('jquery_cookie_script', $jquery_cookie_script);
    $longtaketime = getmicrotime() - MUTIME;
    $taketime = sprintf('%01.03f', $longtaketime);
    $qt->setv('taketime', $taketime);
    //UniversalAnalytics Tracking Code
    if ($code = $qt->getv('ga_universal_analytics')) {
        $qt->appendv('beforescript', $code);
    }
    //------------------------------------------------------------------
    // WordPressデザイン
    if ($enable_wp_theme && ($vars['cmd'] != 'qhmsetting' && $vars['plugin'] != 'qhmsetting')) {
        define('TEMPLATEPATH', 'skin/wordpress/' . $enable_wp_theme_name);
        include LIB_DIR . 'wp_adapter.php';
        wp_load_functions();
        $skin_file = get_wp_skin_file();
    }
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    // 	プレビュー用のskinファイルを表示
    $tmpfilename = '';
    if (isset($_SESSION['temp_skin']) && strlen($_SESSION['temp_skin']) > 0) {
        $tmpfilename = $skin_file = tempnam(realpath(CACHEQHM_DIR), 'qhmdesign');
        file_put_contents($skin_file, $_SESSION['temp_skin']);
        $qt->setv('default_css', $bootstrap_css . $_SESSION['temp_css']);
        $qt->setv('style_path', $_SESSION['temp_style_path']);
    }
    //-------------------------------------------------------------------
    //skinファイルを読み込んで、表示
    $qt->read($skin_file, $_page);
    // 一時ファイルの削除
    if (file_exists($tmpfilename) && strpos(basename($tmpfilename), 'qhmdesign') === 0) {
        unlink($tmpfilename);
    }
}
Esempio n. 13
0
function plugin_toolbar_convert()
{
    global $_LINK;
    global $do_backup, $trackback, $referer;
    global $function_freeze;
    global $vars;
    global $whatsnew, $whatsdeleted;
    //	if ($_LINK['reload'] == '') {
    //		return '#navibar: plugin called from wikipage. skipped.';
    //	}
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    $num = func_num_args();
    $args = $num ? func_get_args() : array();
    $ret[] = '<ul role="toolbar">';
    while (!empty($args)) {
        $name = array_shift($args);
        switch ($name) {
            case 'freeze':
            case 'unfreeze':
                if ($is_read && $function_freeze) {
                    if ($is_freeze) {
                        $name = 'unfreeze';
                    } else {
                        $name = 'freeze';
                    }
                    $ret[] = _toolbar($name);
                }
                break;
            case 'upload':
                if ($is_read && (bool) ini_get('file_uploads') && !$is_freeze && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'list':
                if ($vars['cmd'] !== 'list') {
                    $ret[] = _toolbar($name);
                } else {
                    $ret[] = _toolbar('filelist');
                }
                break;
            case 'backup':
                if ($do_backup) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'brokenlink':
            case 'template':
            case 'source':
                if (!empty($_page)) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'trackback':
                if ($trackback) {
                    if (!empty($_page) && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                        $ret[] = _toolbar($name, 'Trackback(' . tb_count($_page) . ')');
                    } else {
                        //		$ret[] = _toolbar($name, 'Trackback list');
                    }
                }
                break;
            case 'referer':
            case 'skeylist':
            case 'linklist':
                if ($referer && !empty($_page)) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'log_login':
                if (!empty($_page) && log_exist('login', $vars['page'])) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'log_check':
                if (!empty($_page) && log_exist('check', $vars['page'])) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'log':
            case 'log_browse':
                if (!empty($_page)) {
                    $ret[] = _toolbar($name);
                }
                //			if (log_exist('browse',$vars['page'])) {
                //				return _toolbar($name);
                //			}
                break;
            case 'log_update':
                if (!empty($_page) && log_exist('update', $vars['page'])) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'log_down':
                if (!empty($_page) && log_exist('download', $vars['page'])) {
                    $ret[] = _toolbar($name);
                }
                break;
            case '|':
                if (end($ret) !== '<ul>') {
                    $ret[] = '</ul>';
                    $ret[] = "\n";
                    $ret[] = '<ul role="toolbar">';
                }
                break;
                // case 'new':
            // case 'new':
            case 'newsub':
            case 'edit':
            case 'guiedit':
                if (!empty($_page) && $is_read && $function_freeze && !$is_freeze && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                    $ret[] = _toolbar($name);
                }
                break;
            case 'diff':
            case 'reload':
            case 'copy':
                if (!$is_read || empty($_page)) {
                    break;
                }
            default:
                $ret[] = _toolbar($name);
                break;
        }
    }
    if (end($ret) === '<ul>') {
        array_pop($ret);
        array_pop($ret);
    } else {
        $ret[] = '</ul>';
    }
    $body = "\n" . join('', $ret) . "\n";
    return '<nav class="toolbar">' . $body . '</nav>' . "\n";
}
Esempio n. 14
0
function catbody($title,$page,$body)
{
	global $script,$vars,$arg,$defaultpage,$whatsnew,$help_page,$hr;
	global $related_link,$cantedit,$function_freeze,$search_word_color,$_msg_word;
	global $foot_explain,$note_hr,$head_tags;
	
	global $html_transitional; // FALSE:XHTML1.1 TRUE:XHTML1.0 Transitional
	global $page_title;        // ホームページのタイトル
	global $do_backup;         // バックアップを行うかどうか
	global $modifier;          // 編集者のホームページ
	global $modifierlink;      // 編集者の名前

	$_page = $vars['page'];
	$r_page = rawurlencode($_page);
	
	$link_add      = "$script?cmd=add&amp;page=$r_page";
	$link_edit     = "$script?cmd=edit&amp;page=$r_page";
	$link_diff     = "$script?cmd=diff&amp;page=$r_page";
	$link_top      = "$script?".rawurlencode($defaultpage);
	$link_list     = "$script?cmd=list";
	$link_filelist = "$script?cmd=filelist";
	$link_search   = "$script?cmd=search";
	$link_whatsnew = "$script?".rawurlencode($whatsnew);
	$link_backup   = "$script?cmd=backup&amp;page=$r_page";
	$link_help     = "$script?".rawurlencode($help_page);
	$link_rss      = "$script?cmd=rss10";
	$link_freeze   = "$script?cmd=freeze&amp;page=$r_page";
	$link_unfreeze = "$script?cmd=unfreeze&amp;page=$r_page";
	$link_upload   = "$script?plugin=attach&amp;pcmd=upload&amp;page=$r_page";
	$link_template = "$script?plugin=template&amp;refer=$r_page";
	$link_rename   = "$script?plugin=rename&amp;refer=$r_page";
	
	// ページの表示時TRUE(バックアップの表示、RecentChangesの表示を除く)
	$is_page = (is_pagename($_page) and !arg_check('backup') and $_page != $whatsnew);
	
	// ページの読み出し時TRUE
	$is_read = (arg_check('read') and is_page($_page));
	
	// ページが凍結されているときTRUE
	$is_freeze = is_freeze($_page);
	
	// ページの最終更新時刻(文字列)
	$lastmodified = $is_read ?
		get_date('D, d M Y H:i:s T',get_filetime($_page)).' '.get_pg_passage($_page,FALSE) : '';
	
	// 関連するページのリスト
	$related = ($is_read and $related_link) ? make_related($_page) : '';
	
	// 添付ファイルのリスト
	$attaches = ($is_read and exist_plugin_action('attach')) ? attach_filelist() : '';
	
	// 注釈のリスト
	ksort($foot_explain,SORT_NUMERIC);
	$notes = count($foot_explain) ? $note_hr.join("\n",$foot_explain) : '';
	
	// <head>内に追加するタグ
	$head_tag = count($head_tags) ? join("\n",$head_tags)."\n" : '';
	
	// 1.3.x compat
	// ページの最終更新時刻(UNIX timestamp)
	$fmt = $is_read ? get_filetime($_page) + LOCALZONE : 0;

	//単語検索
	if ($search_word_color and array_key_exists('word',$vars))
	{
		$body = '<div class="small">'.$_msg_word.htmlspecialchars($vars['word'])."</div>$hr\n$body";
		$words = array_flip(array_splice(preg_split('/\s+/',$vars['word'],-1,PREG_SPLIT_NO_EMPTY),0,10));
		$keys = array();
		foreach ($words as $word=>$id)
		{
			$keys[$word] = strlen($word);
		}
		arsort($keys,SORT_NUMERIC);
		$keys = get_search_words(array_keys($keys),TRUE);
		$id = 0;
		foreach ($keys as $key=>$pattern)
		{
			$s_key = htmlspecialchars($key);
			$pattern = "/(<[^>]*>)|($pattern)/";
			$callback = create_function(
				'$arr',
				'return $arr[1] ? $arr[1] : "<strong class=\"word'.$id++.'\">{$arr[2]}</strong>";'
			);
			$body = preg_replace_callback($pattern,$callback,$body);
			$notes = preg_replace_callback($pattern,$callback,$notes);
		}
	}
	
	$longtaketime = getmicrotime() - MUTIME;
	$taketime = sprintf('%01.03f',$longtaketime);
	
	if (!file_exists(SKIN_FILE)||!is_readable(SKIN_FILE))
	{
		die_message(SKIN_FILE.'(skin file) is not found.');
	}
	require(SKIN_FILE);
}
Esempio n. 15
0
    ?>
					</ul>
				</nav>
<?php 
}
?>
			</header>

			<main role="main" data-role="content" data-theme="c">
				<?php 
echo $this->body;
?>
			</main>

<?php 
if (arg_check('read')) {
    ?>
	<?php 
    if (!empty($this->menubar)) {
        ?>
			<aside data-role="panel" id="menubar" data-theme="b" data-content-theme="d" data-position="left" data-display="reveal">
				<?php 
        echo $this->menubar;
        ?>
			</aside>
	<?php 
    }
    ?>
	<?php 
    if (!empty($this->sidebar)) {
        ?>
Esempio n. 16
0
function plugin_suckerfish_keyword($name)
{
    global $do_backup, $trackback, $referer;
    global $function_freeze;
    global $vars;
    // $is_read = (arg_check('read') && is_page($vars['page']));
    $is_read = isset($vars['page']) && is_page($vars['page']);
    $is_readonly = Auth::check_role('readonly');
    $is_safemode = Auth::check_role('safemode');
    $is_createpage = Auth::is_check_role(PKWK_CREATE_PAGE);
    $num = func_num_args();
    $args = $num ? func_get_args() : array();
    switch ($name) {
        case 'freeze':
            if ($is_readonly) {
                break;
            }
            if (!$is_read) {
                break;
            }
            if ($function_freeze) {
                if (!is_freeze($vars['page'])) {
                    $name = 'freeze';
                } else {
                    $name = 'unfreeze';
                }
                return _suckerfish($name);
            }
            break;
        case 'upload':
            if ($is_readonly) {
                break;
            }
            if (!$is_read) {
                break;
            }
            if ($function_freeze && is_freeze($vars['page'])) {
                break;
            }
            if ((bool) ini_get('file_uploads')) {
                return _suckerfish($name);
            }
            break;
        case 'filelist':
            if (arg_check('list')) {
                return _suckerfish($name);
            }
            break;
        case 'backup':
            if ($do_backup) {
                return _suckerfish($name);
            }
            break;
        case 'referer':
            if ($referer) {
                return _suckerfish($name);
            }
            break;
        case 'rss':
        case 'mixirss':
            return _suckerfish($name);
            break;
        case 'diff':
            if (!$is_read) {
                break;
            }
            if ($is_safemode) {
                break;
            }
            return _suckerfish($name);
            break;
        case 'edit':
        case 'guiedit':
            if (!$is_read) {
                break;
            }
            if ($is_readonly) {
                break;
            }
            if ($function_freeze && is_freeze($vars['page'])) {
                break;
            }
            return _suckerfish($name);
            break;
        case 'new':
        case 'newsub':
            if ($is_createpage) {
                break;
            }
        case 'rename':
        case 'copy':
            if ($is_readonly) {
                break;
            }
        case 'reload':
        case 'print':
        case 'full':
            if (!$is_read) {
                break;
            }
        default:
            return _suckerfish($name);
            break;
    }
    return array();
}
Esempio n. 17
0
function plugin_navibar_convert()
{
    global $do_backup, $trackback, $referer;
    global $function_freeze;
    global $vars;
    global $whatsnew, $whatsdeleted;
    /*
    	if ($_LINK['reload'] == '') {
    		return '<p class="message_box ui-state-error ui-corner-all">#navibar: plugin called from wikipage. skipped.</p>';
    	}
    */
    $_page = isset($vars['page']) ? $vars['page'] : null;
    $is_read = arg_check('read') && is_page($_page);
    $is_freeze = is_freeze($_page);
    $is_readonly = Auth::check_role('readonly') || PKWK_READONLY == Auth::ROLE_AUTH && Auth::get_role_level() > Auth::ROLE_AUTH ? true : false;
    $cmd = isset($vars['cmd']) ? $vars['cmd'] : null;
    $num = func_num_args();
    $args = $num ? func_get_args() : array();
    if (IS_MOBILE) {
        $ret[] = '<ul data-role="listview">';
    } else {
        $ret[] = '<ul>';
    }
    while (!empty($args)) {
        $name = array_shift($args);
        switch ($name) {
            case 'freeze':
            case 'unfreeze':
                if ($is_read && $function_freeze && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                    if ($is_freeze) {
                        $name = 'unfreeze';
                    } else {
                        $name = 'freeze';
                    }
                    $ret[] = _navibar($name);
                }
                break;
            case 'list':
                if ($cmd !== 'list') {
                    $ret[] = _navibar($name);
                } else {
                    $ret[] = _navibar('filelist');
                }
                break;
            case 'backup':
                if ($do_backup) {
                    $ret[] = _navibar($name);
                }
                break;
            case 'brokenlink':
            case 'template':
            case 'source':
            case 'diff':
            case 'reload':
            case 'copy':
                if ($is_read || !empty($_page) && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                    $ret[] = _navibar($name);
                }
                break;
            case 'trackback':
                if ($trackback) {
                    if (!empty($_page) && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                        $ret[] = _navibar($name, 'Trackback(' . tb_count($_page) . ')');
                    } else {
                        //		$ret[] = _navibar($name, 'Trackback list');
                    }
                }
                break;
            case 'referer':
            case 'skeylist':
            case 'linklist':
                if ($referer && !empty($_page)) {
                    $ret[] = _navibar($name);
                }
                break;
            case 'log':
                if (!empty($_page)) {
                    $ret[] = _navibar($name);
                }
            case '|':
                if (end($ret) !== '<ul>') {
                    $ret[] = '</ul>';
                    $ret[] = "\n";
                    $ret[] = !IS_MOBILE ? '<ul>' : '<ul data-role="listview">';
                }
                break;
            case 'attach':
            case 'upload':
                if ($is_read && (bool) ini_get('file_uploads') && !$is_freeze && !($_page == $whatsnew || $_page == $whatsdeleted) && !$is_readonly) {
                    $ret[] = _navibar($name);
                }
                break;
            case 'new':
            case 'newsub':
            case 'edit':
            case 'guiedit':
                if (!empty($_page) && $is_read && $function_freeze && !$is_freeze && !($_page == $whatsnew || $_page == $whatsdeleted) && !$is_readonly) {
                    $ret[] = _navibar($name);
                }
                break;
            case 'login':
                $auth_key = Auth::get_user_info();
                if (empty($auth_key['key'])) {
                    $ret[] = _navibar($name);
                }
                break;
            default:
                $ret[] = _navibar($name);
                break;
        }
    }
    if (end($ret) === '<ul>') {
        array_pop($ret);
        array_pop($ret);
    } else {
        $ret[] = '</ul>';
    }
    $body = "\n" . join('', $ret) . "\n";
    if (IS_MOBILE) {
        return $body;
    } else {
        return '<nav class="navibar">' . $body . '</nav>' . "\n";
    }
}
Esempio n. 18
0
function pass2($file, $namespace, $ast, $current_scope, $parent_node = null, $current_class = null, $current_function = null, $parent_scope = null) : string
{
    global $classes, $functions, $namespace_map, $scope, $tainted_by, $quick_mode;
    static $next_node = 1;
    $vars = [];
    $parent_kind = null;
    if ($parent_node instanceof \ast\Node) {
        $parent_kind = $parent_node->kind;
    }
    if ($ast instanceof \ast\Node) {
        // Infinite Recursion check
        if (empty($ast->id)) {
            $ast->id = $next_node++;
        }
        if (!empty($parent_node)) {
            if (empty($ast->visited_from[$parent_node->id])) {
                $ast->visited_from[$parent_node->id] = 1;
            } else {
                return $namespace;
            }
        }
        switch ($ast->kind) {
            case \ast\AST_NAMESPACE:
                $namespace = (string) $ast->children[0] . '\\';
                break;
            case \ast\AST_USE_TRAIT:
                // We load up the trais in AST_CLASS, this part is just for pretty error messages
                foreach ($ast->children[0]->children as $trait) {
                    $name = $trait->children[0];
                    $lname = strtolower($name);
                    if (!empty($namespace_map[T_CLASS][$file][$lname])) {
                        $name = $namespace_map[T_CLASS][$file][$lname];
                    } else {
                        if ($trait->flags & \ast\flags\NAME_NOT_FQ) {
                            $name = $namespace . $name;
                        }
                    }
                    if (empty($classes[strtolower($name)])) {
                        Log::err(Log::EUNDEF, "Undeclared trait {$trait->children[0]}", $file, $ast->lineno);
                    }
                }
                break;
            case \ast\AST_CLASS:
                $lname = strtolower($namespace . $ast->name);
                if (empty($classes[$lname])) {
                    dump_scope($scope);
                    Log::err(Log::EFATAL, "Can't find class {$namespace}{$ast->name} - aborting", $file, $ast->lineno);
                }
                $current_class = $classes[$lname];
                $traits = $classes[$lname]['traits'];
                // Copy the trait over into this class
                foreach ($traits as $trait) {
                    if (empty($classes[$trait])) {
                        continue;
                    }
                    // TODO: Implement the various trait aliasing mechanisms here
                    $classes[$lname]['properties'] = array_merge($classes[$lname]['properties'], $classes[$trait]['properties']);
                    $classes[$lname]['constants'] = array_merge($classes[$lname]['constants'], $classes[$trait]['constants']);
                    $classes[$lname]['methods'] = array_merge($classes[$lname]['methods'], $classes[$trait]['methods']);
                    // Need the scope as well
                    foreach ($classes[$trait]['methods'] as $k => $method) {
                        if (empty($scope["{$classes[$trait]['name']}::{$method['name']}"])) {
                            continue;
                        }
                        $cs = $namespace . $ast->name . '::' . $method['name'];
                        if (!array_key_exists($cs, $scope)) {
                            $scope[$cs] = [];
                        }
                        if (!array_key_exists('vars', $scope[$cs])) {
                            $scope[$cs]['vars'] = [];
                        }
                        $scope[$cs] = $scope["{$classes[$trait]['name']}::{$method['name']}"];
                        // And finally re-map $this to point to this class
                        $scope[$cs]['vars']['this']['type'] = $namespace . $ast->name;
                    }
                }
                break;
            case \ast\AST_FUNC_DECL:
                if (empty($functions[strtolower($namespace . $ast->name)])) {
                    Log::err(Log::EFATAL, "Can't find function {$namespace}{$ast->name} - aborting", $file, $ast->lineno);
                }
                $current_function = $functions[strtolower($namespace . $ast->name)];
                $parent_scope = $current_scope;
                $current_scope = $namespace . $ast->name;
                break;
            case \ast\AST_CLOSURE:
                $closure_name = '{closure ' . $ast->id . '}';
                $functions[$closure_name] = node_func($file, false, $ast, $closure_name, '');
                $current_function = $closure_name;
                $parent_scope = $current_scope;
                $current_scope = $closure_name;
                if (!empty($scope[$parent_scope]['vars']['this'])) {
                    // TODO: check for a static closure
                    add_var_scope($current_scope, 'this', $scope[$parent_scope]['vars']['this']['type']);
                }
                if (!empty($ast->children[1]) && $ast->children[1]->kind == \ast\AST_CLOSURE_USES) {
                    $uses = $ast->children[1];
                    foreach ($uses->children as $use) {
                        if ($use->kind != \ast\AST_CLOSURE_VAR) {
                            Log::err(Log::EVAR, "You can only have variables in a closure use() clause", $file, $ast->lineno);
                        } else {
                            $name = var_name($use->children[0]);
                            if ($use->flags & \ast\flags\PARAM_REF) {
                                if (empty($parent_scope) || empty($scope[$parent_scope]['vars']) || empty($scope[$parent_scope]['vars'][$name])) {
                                    add_var_scope($parent_scope, $name, '');
                                }
                                $scope[$current_scope]['vars'][$name] =& $scope[$parent_scope]['vars'][$name];
                            } else {
                                if (empty($parent_scope) || empty($scope[$parent_scope]['vars']) || empty($scope[$parent_scope]['vars'][$name])) {
                                    Log::err(Log::EVAR, "Variable \${$name} is not defined", $file, $ast->lineno);
                                } else {
                                    $scope[$current_scope]['vars'][$name] = $scope[$parent_scope]['vars'][$name];
                                }
                            }
                        }
                    }
                }
                break;
            case \ast\AST_METHOD:
                if (empty($current_class['methods'][strtolower($ast->name)])) {
                    Log::err(Log::EFATAL, "Can't find method {$current_class['name']}:{$ast->name} - aborting", $file, $ast->lineno);
                }
                $current_function = $current_class['methods'][strtolower($ast->name)];
                $parent_scope = $current_scope;
                $current_scope = $current_class['name'] . '::' . $ast->name;
                break;
            case \ast\AST_USE:
                // TODO: Figure out a clean way to map namespaces
                break;
            case \ast\AST_FOREACH:
                // Not doing depth-first here, because we need to declare the vars for the body of the loop
                if ($ast->children[2] instanceof \ast\Node && $ast->children[2]->kind == \ast\AST_LIST) {
                    Log::err(Log::EFATAL, "Can't use list() as a key element - aborting", $file, $ast->lineno);
                }
                if ($ast->children[1]->kind == \ast\AST_LIST) {
                    add_var_scope($current_scope, var_name($ast->children[1]->children[0]), '', true);
                    add_var_scope($current_scope, var_name($ast->children[1]->children[1]), '', true);
                } else {
                    // value
                    add_var_scope($current_scope, var_name($ast->children[1]), '', true);
                    // key
                    if (!empty($ast->children[2])) {
                        add_var_scope($current_scope, var_name($ast->children[2]), '', true);
                    }
                }
                break;
            case \ast\AST_CATCH:
                $obj = var_name($ast->children[0]);
                $name = var_name($ast->children[1]);
                if (!empty($name)) {
                    add_var_scope($current_scope, $name, $obj, true);
                }
                break;
        }
        // Depth-First for everything else
        foreach ($ast->children as $child) {
            $namespace = pass2($file, $namespace, $child, $current_scope, $ast, $current_class, $current_function, $parent_scope);
        }
        switch ($ast->kind) {
            case \ast\AST_ASSIGN:
            case \ast\AST_ASSIGN_REF:
                var_assign($file, $namespace, $ast, $current_scope, $current_class, $vars);
                foreach ($vars as $k => $v) {
                    if (empty($v)) {
                        $v = ['type' => '', 'tainted' => false, 'tainted_by' => ''];
                    }
                    if (empty($v['type'])) {
                        $v['type'] = '';
                    }
                    if (strpos($k, '::') === false) {
                        $cs = $current_scope;
                    } else {
                        $cs = 'global';
                    }
                    // Put static properties in the global scope TODO: revisit
                    // Check if we are assigning something to $GLOBALS[key]
                    if ($k == 'GLOBALS' && $ast->children[0]->kind == \ast\AST_DIM) {
                        $temp = $ast;
                        $depth = 0;
                        while ($temp->children[0]->kind == \ast\AST_DIM) {
                            $depth++;
                            $temp = $temp->children[0];
                        }
                        // If the index is a simple scalar, set it in the global scope
                        if (!empty($temp->children[1]) && !$temp->children[1] instanceof \ast\Node) {
                            $cs = 'global';
                            $k = $temp->children[1];
                            if ($depth == 1) {
                                $taint = false;
                                $tainted_by = '';
                                $v['type'] = node_type($file, $namespace, $ast->children[1], $current_scope, $current_class, $taint);
                                $v['tainted'] = $taint;
                                $v['tainted_by'] = $tainted_by;
                            } else {
                                // This is a $GLOBALS['a']['b'] type of assignment
                                // TODO: track array content types
                                $v['type'] = 'array';
                                $v['tainted'] = false;
                                $v['tainted_by'] = '';
                            }
                        }
                    }
                    if ($k == 'GLOBALS') {
                        break;
                    }
                    add_var_scope($cs, $k, $v['type']);
                    $scope[$cs]['vars'][$k]['tainted'] = $v['tainted'];
                    $scope[$cs]['vars'][$k]['tainted_by'] = $v['tainted_by'];
                }
                break;
            case \ast\AST_LIST:
                // TODO: Very simplistic here - we can be smarter
                foreach ($ast->children as $c) {
                    $name = var_name($c);
                    if (!empty($name)) {
                        add_var_scope($current_scope, $name, '');
                    }
                }
                break;
            case \ast\AST_GLOBAL:
                if (!array_key_exists($current_scope, $scope)) {
                    $scope[$current_scope] = [];
                }
                if (!array_key_exists('vars', $scope[$current_scope])) {
                    $scope[$current_scope]['vars'] = [];
                }
                $name = var_name($ast);
                if ($name === false) {
                    break;
                }
                if (!array_key_exists($name, $scope['global']['vars'])) {
                    add_var_scope('global', $name, '');
                }
                $scope[$current_scope]['vars'][$name] =& $scope['global']['vars'][$name];
                break;
            case \ast\AST_FOREACH:
                // check the array, the key,value part was checked on in the non-DPS part above
                $type = node_type($file, $namespace, $ast->children[0], $current_scope, $current_class);
                if (type_scalar($type)) {
                    Log::err(Log::ETYPE, "{$type} passed to foreach instead of array", $file, $ast->lineno);
                }
                break;
            case \ast\AST_STATIC:
                $name = var_name($ast);
                $type = node_type($file, $namespace, $ast->children[1], $current_scope, $current_class, $taint);
                add_var_scope($current_scope, $name, $type);
                $scope[$current_scope]['vars'][$name]['tainted'] = $taint;
                $scope[$current_scope]['vars'][$name]['tainted_by'] = $tainted_by;
                break;
            case \ast\AST_PRINT:
            case \ast\AST_ECHO:
                $taint = false;
                $tainted_by = '';
                $type = node_type($file, $namespace, $ast->children[0], $current_scope, $current_class, $taint);
                if ($type == 'array') {
                    Log::err(Log::ETYPE, "array to string conversion", $file, $ast->lineno);
                }
                if ($taint) {
                    if (empty($tainted_by)) {
                        Log::err(Log::ETAINT, "possibly tainted output.", $file, $ast->lineno);
                    } else {
                        Log::err(Log::ETAINT, "possibly tainted output. Data tainted at {$tainted_by}", $file, $ast->lineno);
                    }
                }
                break;
            case \ast\AST_VAR:
                if ($parent_kind == \ast\AST_STMT_LIST) {
                    Log::err(Log::ENOOP, "no-op variable", $file, $ast->lineno);
                }
                break;
            case \ast\AST_ARRAY:
                if ($parent_kind == \ast\AST_STMT_LIST) {
                    Log::err(Log::ENOOP, "no-op array", $file, $ast->lineno);
                }
                break;
            case \ast\AST_CONST:
                if ($parent_kind == \ast\AST_STMT_LIST) {
                    Log::err(Log::ENOOP, "no-op constant", $file, $ast->lineno);
                }
                break;
            case \ast\AST_CLOSURE:
                if ($parent_kind == \ast\AST_STMT_LIST) {
                    Log::err(Log::ENOOP, "no-op closure", $file, $ast->lineno);
                }
                break;
            case \ast\AST_RETURN:
                // Check if there is a return type on the current function
                if (!empty($current_function['oret'])) {
                    $ret = $ast->children[0];
                    if ($ret instanceof \ast\Node) {
                        if ($ast->children[0]->kind == \ast\AST_ARRAY) {
                            $ret_type = 'array';
                        } else {
                            $ret_type = node_type($file, $namespace, $ret, $current_scope, $current_class);
                        }
                    } else {
                        $ret_type = type_map(gettype($ret));
                        // This is distinct from returning actual NULL which doesn't hit this else since it is an AST_CONST node
                        if ($ret_type == 'NULL') {
                            $ret_type = 'void';
                        }
                    }
                    $check_type = $current_function['oret'];
                    if (strpos("|{$check_type}|", '|self|') !== false) {
                        $check_type = preg_replace("/\\bself\\b/", $current_class['name'], $check_type);
                    }
                    if (strpos("|{$check_type}|", '|static|') !== false) {
                        $check_type = preg_replace("/\\bstatic\\b/", $current_class['name'], $check_type);
                    }
                    if (strpos("|{$check_type}|", '|\\$this|') !== false) {
                        $check_type = preg_replace("/\\b\$this\\b/", $current_class['name'], $check_type);
                    }
                    if (!type_check($ret_type, $check_type, $namespace)) {
                        Log::err(Log::ETYPE, "return {$ret_type} but {$current_function['name']}() is declared to return {$current_function['oret']}", $file, $ast->lineno);
                    }
                } else {
                    $type = node_type($file, $namespace, $ast->children[0], $current_scope, $current_class);
                    if (!empty($functions[$current_scope]['oret'])) {
                        // The function has a return type declared
                        if (!type_check($type, $functions[$current_scope]['oret'], $namespace)) {
                            Log::err(Log::ETYPE, "return {$type} but {$functions[$current_scope]['name']}() is declared to return {$functions[$current_scope]['oret']}", $file, $ast->lineno);
                        }
                    } else {
                        if (strpos($current_scope, '::') !== false) {
                            list($class_name, $method_name) = explode('::', $current_scope, 2);
                            $idx = find_method_class($class_name, $method_name);
                            if ($idx) {
                                $classes[$idx]['methods'][strtolower($method_name)]['ret'] = $type;
                            }
                        } else {
                            if (!empty($functions[$current_scope]['ret'])) {
                                foreach (explode('|', $type) as $t) {
                                    if (!empty($t) && strpos($functions[$current_scope]['ret'], $t) === false) {
                                        $functions[$current_scope]['ret'] = $functions[$current_scope]['ret'] . '|' . $type;
                                    }
                                }
                                $functions[$current_scope]['ret'] = trim($functions[$current_scope]['ret'], '|');
                            } else {
                                if ($current_scope != 'global') {
                                    $functions[$current_scope]['ret'] = $type;
                                }
                            }
                        }
                    }
                }
                break;
            case \ast\AST_CLASS_CONST_DECL:
            case \ast\AST_PROP_DECL:
                // TODO
                break;
            case \ast\AST_CALL:
                $found = false;
                $call = $ast->children[0];
                if ($call->kind == \ast\AST_NAME) {
                    $func_name = $call->children[0];
                    $found = null;
                    if ($call->flags & \ast\flags\NAME_NOT_FQ) {
                        if (!empty($namespace_map[T_FUNCTION][$file][strtolower($namespace . $func_name)])) {
                            $cs = $namespace_map[T_FUNCTION][$file][strtolower($namespace . $func_name)];
                            $found = $functions[strtolower($cs)];
                        } else {
                            if (!empty($namespace_map[T_FUNCTION][$file][strtolower($func_name)])) {
                                $cs = $namespace_map[T_FUNCTION][$file][strtolower($func_name)];
                                $found = $functions[strtolower($cs)];
                            } else {
                                if (!empty($functions[strtolower($namespace . $func_name)])) {
                                    $cs = $namespace . $func_name;
                                    $found = $functions[strtolower($cs)];
                                } else {
                                    if (!empty($functions[strtolower($func_name)])) {
                                        $cs = $func_name;
                                        $found = $functions[strtolower($func_name)];
                                    }
                                }
                            }
                        }
                    } else {
                        if (!empty($functions[strtolower($func_name)])) {
                            $cs = $func_name;
                            $found = $functions[strtolower($func_name)];
                        }
                    }
                    if (!$found) {
                        Log::err(Log::EUNDEF, "call to undefined function {$func_name}()", $file, $ast->lineno);
                    } else {
                        // Ok, the function exists, but are we calling it correctly?
                        if ($found instanceof ReflectionType) {
                            echo "oops at {$file}:{$ast->lineno}\n";
                        }
                        // DEBUG
                        arg_check($file, $namespace, $ast, $func_name, $found, $current_scope, $current_class);
                        if ($found['file'] != 'internal') {
                            // re-check the function's ast with these args
                            if (!$quick_mode) {
                                pass2($found['file'], $found['namespace'], $found['ast'], $found['scope'], $ast, $current_class, $found, $parent_scope);
                            }
                        } else {
                            if (!$found['avail']) {
                                if (!$found) {
                                    Log::err(Log::EAVAIL, "function {$func_name}() is not compiled into this version of PHP", $file, $ast->lineno);
                                }
                            }
                        }
                    }
                } else {
                    if ($call->kind == \ast\AST_VAR) {
                        $name = var_name($call);
                        if ($name instanceof \ast\Node) {
                            // $$var() - Ugh..
                            // TODO - something brilliant here
                        } else {
                            // $var() - hopefully a closure, otherwise we don't know
                            if (array_key_exists($name, $scope[$current_scope]['vars'])) {
                                if (($pos = strpos($scope[$current_scope]['vars'][$name]['type'], '{closure ')) !== false) {
                                    $closure_id = (int) substr($scope[$current_scope]['vars'][$name]['type'], $pos + 9);
                                    $func_name = '{closure ' . $closure_id . '}';
                                    $found = $functions[$func_name];
                                    arg_check($file, $namespace, $ast, $func_name, $found, $current_scope, $current_class);
                                    if (!$quick_mode) {
                                        pass2($found['file'], $found['namespace'], $found['ast'], $found['scope'], $ast, $current_class, $found, $parent_scope);
                                    }
                                }
                            }
                        }
                    }
                }
                break;
            case \ast\AST_NEW:
                $class_name = find_class_name($file, $ast, $namespace, $current_class, $current_scope);
                if ($class_name) {
                    $method_name = '__construct';
                    // No type checking for PHP4-style constructors
                    $method = find_method($class_name, $method_name);
                    if ($method) {
                        // Found a constructor
                        arg_check($file, $namespace, $ast, $method_name, $method, $current_scope, $current_class, $class_name);
                        if ($method['file'] != 'internal') {
                            // re-check the function's ast with these args
                            if (!$quick_mode) {
                                pass2($method['file'], $method['namespace'], $method['ast'], $method['scope'], $ast, $classes[strtolower($class_name)], $method, $parent_scope);
                            }
                        }
                    }
                }
                break;
            case \ast\AST_STATIC_CALL:
                $static_call_ok = false;
                $class_name = find_class_name($file, $ast, $namespace, $current_class, $current_scope, $static_call_ok);
                if ($class_name) {
                    // The class is declared, but does it have the method?
                    $method_name = $ast->children[1];
                    $method = find_method($class_name, $method_name);
                    if (is_array($method) && array_key_exists('avail', $method) && !$method['avail']) {
                        Log::err(Log::EAVAIL, "method {$class_name}::{$method_name}() is not compiled into this version of PHP", $file, $ast->lineno);
                    }
                    if ($method === false) {
                        Log::err(Log::EUNDEF, "static call to undeclared method {$class_name}::{$method_name}()", $file, $ast->lineno);
                    } else {
                        if ($method != 'dynamic') {
                            // Was it declared static?
                            if (!($method['flags'] & \ast\flags\MODIFIER_STATIC)) {
                                if (!$static_call_ok) {
                                    Log::err(Log::ESTATIC, "static call to non-static method {$class_name}::{$method_name}() defined at {$method['file']}:{$method['lineno']}", $file, $ast->lineno);
                                }
                            }
                            arg_check($file, $namespace, $ast, $method_name, $method, $current_scope, $current_class, $class_name);
                            if ($method['file'] != 'internal') {
                                // re-check the function's ast with these args
                                if (!$quick_mode) {
                                    pass2($method['file'], $method['namespace'], $method['ast'], $method['scope'], $ast, $classes[strtolower($class_name)], $method, $parent_scope);
                                }
                            }
                        }
                    }
                }
                break;
            case \ast\AST_METHOD_CALL:
                $class_name = find_class_name($file, $ast, $namespace, $current_class, $current_scope);
                if ($class_name) {
                    $method_name = $ast->children[1];
                    $method = find_method($class_name, $method_name);
                    if ($method === false) {
                        Log::err(Log::EUNDEF, "call to undeclared method {$class_name}->{$method_name}()", $file, $ast->lineno);
                    } else {
                        if ($method != 'dynamic') {
                            if (array_key_exists('avail', $method) && !$method['avail']) {
                                Log::err(Log::EAVAIL, "method {$class_name}::{$method_name}() is not compiled into this version of PHP", $file, $ast->lineno);
                            }
                            arg_check($file, $namespace, $ast, $method_name, $method, $current_scope, $current_class, $class_name);
                            if ($method['file'] != 'internal') {
                                // re-check the function's ast with these args
                                if (!$quick_mode) {
                                    pass2($method['file'], $method['namespace'], $method['ast'], $method['scope'], $ast, $classes[strtolower($class_name)], $method, $parent_scope);
                                }
                            }
                        }
                    }
                }
                break;
        }
    } else {
        if ($parent_kind == \ast\AST_STMT_LIST) {
            if ($ast !== null) {
                Log::err(Log::ENOOP, "(line number not accurate) dangling expression: " . var_export($ast, true), $file, $parent_node->lineno);
            }
        }
    }
    return $namespace;
}
Esempio n. 19
0
						<?php 
    echo $this->notes;
    ?>
					</aside>
<!--  End Note -->
<?php 
}
?>
					<?php 
echo $this->conf['adarea']['footer'] ? '<hr /><div id="footer_ad" class="noprint">' . $this->conf['adarea']['footer'] . '</div>' : '';
?>
<!-- * end Main Content * -->
				</div>

<?php 
if (arg_check('read') && !empty($this->menubar)) {
    ?>
<!-- * MenuBar * -->
				<aside id="sidebar" class="noprint clearfix"  role="navigation">
					<?php 
    echo $this->menubar;
    ?>
				</aside>
<!-- * End MenuBar * -->
				<?php 
    echo !empty($this->lastmodified) ? '<div id="lastmodified">Last-modified: ' . $this->lastmodified . '</div>' . "\n" : '';
} else {
    echo '<hr />';
}
?>
				<address role="contactinfo">Founded by <a href="<?php