Example #1
0
function plugin_redirect_iframe_convert()
{
    global $vars, $script;
    $qm = get_qm();
    $page = isset($vars['page']) ? $vars['page'] : '';
    $args = func_get_args();
    $url = strip_autolink(array_pop($args));
    if ($url == '') {
        $url = $script . '?' . rawurlencode($page);
    } else {
        $url = is_url($url) ? $url : $script . '?' . rawurlencode($url);
    }
    $editable = ss_admin_check();
    if ($editable) {
        return $qm->replace('plg_redirect_iframe.ntc_admin', $url);
    } else {
        return <<<EOD
<span id="redirect_iframe_msg"><p style="color:gray"><a href="{$url}" target="new">{$qm->m['plg_redirect_iframe']['link']}</a></p></span>
<script type="text/javascript">
<!--
if(parent != self){
parent.location.href="{$url}";
}
else{
var element = document.getElementById("redirect_iframe_msg");
element.innerHTML = "";
}

//-->
</script>
EOD;
    }
}
Example #2
0
function plugin_redirect_convert()
{
    global $vars, $script;
    $qm = get_qm();
    $qt = get_qt();
    //キャッシュしない
    $qt->enable_cache = false;
    $page = isset($vars['page']) ? $vars['page'] : '';
    $args = func_get_args();
    $url = strip_autolink(array_shift($args));
    $status = array_shift($args);
    $status_codes = array('301' => 'HTTP/1.1 301 Moved Permanently');
    if (isset($status_codes[$status])) {
        $headers[] = $status_codes[$status];
    }
    if ($url == '') {
        $url = $script . '?FrontPage';
    } else {
        $url = is_url($url) ? $url : $script . '?' . rawurlencode($url);
    }
    $editable = ss_admin_check();
    //自分自身にリダイレクトして、ループする場合は警告する
    if ($url === $script . '?' . rawurlencode($page)) {
        return $qm->m['plg_redirect']['err_self_ref'];
    }
    if ($editable) {
        return $qm->replace('plg_redirect.ntc_admin', $url);
    } else {
        $headers[] = 'Location: ' . $url;
        foreach ($headers as $header) {
            header($header);
        }
        exit;
    }
}
Example #3
0
function plugin_chpassword_inline()
{
    global $script, $vars;
    global $auth_users;
    $qm = get_qm();
    $args = func_get_args();
    $text = strip_autolink(array_pop($args));
    // Already htmlspecialchars(text)
    list($dispflg) = array_pad($args, 1, 'false');
    $_page = isset($vars['page']) ? $vars['page'] : '';
    $url = $script . '?plugin=qhmsetting&mode=form&phase=';
    if ($text == '') {
        $text = $qm->m['plg_chpassword']['label'];
    }
    $is_login = false;
    if (isset($_SESSION['usr']) && array_key_exists($_SESSION['usr'], $auth_users)) {
        if (ss_admin_check()) {
            // 管理者
            $url .= 'admin';
        } else {
            $url .= 'user2';
        }
        $is_login = true;
    } else {
        // ログイン
        $url = $script . '?cmd=qhmauth';
    }
    $ret = '';
    if ($dispflg == 'true' || $dispflg == 'false' && $is_login) {
        $ret = '<a href="' . $url . '" >' . $text . '</a>';
    }
    return $ret;
}
Example #4
0
/**
 *   QBlog Achives Plugin
 *   -------------------------------------------
 *   ./plugin/qblog_archives.inc.php
 *
 *   Copyright (c) 2012 hokuken
 *   http://hokuken.com/
 *
 *   created  : 12/07/27
 *   modified :
 *
 *   Description
 *   
 *   
 *   Usage :
 *   
 */
function plugin_qblog_archives_convert()
{
    global $vars, $script, $qblog_close;
    //閉鎖中は何も表示しない
    if ($qblog_close && !ss_admin_check()) {
        return '';
    }
    //---- キャッシュのための処理を登録 -----
    $qt = get_qt();
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    $archives_file = CACHEQBLOG_DIR . 'qblog_archives.dat';
    if (file_exists($archives_file)) {
        $archives_list = file_get_contents($archives_file);
    } else {
        $archives_list = array();
    }
    $list = '';
    $list .= '<ul class="qblog_archives">';
    foreach (explode("\n", $archives_list) as $line) {
        if (rtrim($line) != '') {
            list($year, $month, $num) = explode(",", rtrim($line));
            $archives_url = $script . '?QBlog&amp;mode=archives&amp;date=' . rawurlencode($year . $month);
            $list .= '<li><a href="' . $archives_url . '">' . $year . '年' . $month . '月 (' . $num . ')' . '</a></li>';
        }
    }
    $list .= '</ul>';
    return $list;
}
Example #5
0
function plugin_qblog_recent_convert()
{
    global $vars, $script, $qblog_page_re, $qblog_close;
    //閉鎖中は何も表示しない
    if ($qblog_close && !ss_admin_check()) {
        return '';
    }
    //---- キャッシュのための処理を登録 -----
    $qt = get_qt();
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    $display_num = PLUGIN_QBLOG_RECENT_DEFAULT_NUM;
    if (func_num_args()) {
        $args = func_get_args();
        $display_num = $args[0];
    }
    $recent_file = CACHEQBLOG_DIR . 'qblog_recent.dat';
    if (file_exists($recent_file)) {
        $recent_list = explode("\n", file_get_contents($recent_file));
    } else {
        $recent_list = array();
    }
    //件数を抜く
    $size = array_shift($recent_list);
    $list = '';
    $list .= '<ul class="qblog_recent">';
    foreach ($recent_list as $i => $line) {
        if ($i >= $display_num) {
            break;
        }
        if (rtrim($line) != '') {
            $pagename = rtrim($line);
            $title = get_page_title($pagename);
            if ($pagename == $title) {
                if (preg_match($qblog_page_re, $pagename, $mts)) {
                    $blog_date = "{$mts[1]}年{$mts[2]}月{$mts[3]}日";
                    $title = " No.{$mts[4]}";
                }
            }
            //! 表示方法 要検討
            $list .= '<li><a href="' . $script . '?' . rawurldecode($pagename) . '">' . $blog_date . $title . '</a></li>';
        }
    }
    $list .= '</ul>';
    if (!is_bootstrap_skin()) {
        $include_bs = '
<link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" />
<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>';
        $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs);
    }
    //qblog.css を読み込む
    $head = '
    <link rel="stylesheet" href="plugin/qblog/qblog.css" />';
    $qt->appendv_once('qblog_beforescript', 'beforescript', $head);
    return $list;
}
Example #6
0
function plugin_qblog_category_convert()
{
    global $vars, $script;
    global $qblog_default_cat, $qblog_close;
    //閉鎖中は何も表示しない
    if ($qblog_close && !ss_admin_check()) {
        return '';
    }
    //---- キャッシュのための処理を登録 -----
    $qt = get_qt();
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    $display_number = TRUE;
    $display_zero = FALSE;
    if (func_num_args()) {
        $args = func_get_args();
        foreach ($args as $arg) {
            if ($arg == 'numoff') {
                $display_number = FALSE;
            }
            if ($arg == 'displayall') {
                $display_zero = TRUE;
            }
        }
    }
    $catlist_file = CACHEQBLOG_DIR . 'qblog_categories.dat';
    if (file_exists($catlist_file)) {
        $cat_list = explode("\n", file_get_contents($catlist_file));
    } else {
        $cat_list = array();
    }
    $li = $first_li = '';
    foreach ($cat_list as $line) {
        if (rtrim($line) != '') {
            list($cat, $num) = explode("\t", rtrim($line));
            if (!$display_zero && $num == 0) {
                continue;
            }
            $cat_link = $script . '?QBlog&mode=category&catname=' . rawurlencode($cat);
            $number_str = $display_number ? ' (' . $num . ')' : '';
            if (trim($cat) == $qblog_default_cat) {
                $first_li .= '<li><a href="' . $cat_link . '">' . $cat . $number_str . '</a></li>';
            } else {
                $li .= '<li><a href="' . $cat_link . '">' . $cat . $number_str . '</a></li>';
            }
        }
    }
    $list = <<<EOD
<ul class="qblog_categories">
{$first_li}
{$li}
</ul>
EOD;
    return $list;
}
Example #7
0
function plugin_filelist_action()
{
    global $script, $vars;
    // check editable
    if (!ss_admin_check()) {
        $vars['cmd'] = 'list';
    }
    return do_plugin_action('list');
}
Example #8
0
function plugin_dump2_action()
{
    global $style_name, $script;
    $qm = get_qm();
    $style_name = '..';
    $back_url = '<p><a href="' . $script . '">' . $qm->m['frontpage'] . '</a> &gt; <a href="' . $script . '?cmd=qhmsetting">' . $qm->m['preferences'] . '</a> &gt; here</p>';
    $editable = ss_admin_check();
    if (!$editable) {
        return array('msg' => $qm->m['plg_dump']['title'], 'body' => $qm->m['fmt_err_page_only_for_admin']);
    }
    global $vars;
    if (PKWK_READONLY) {
        die_message($qm->m['fmt_err_pkwk_readonly']);
    }
    $pass = isset($_POST['pass']) ? $_POST['pass'] : NULL;
    $act = isset($vars['act']) ? $vars['act'] : NULL;
    $body = '';
    if ($pass !== NULL) {
        if (!pkwk_login($pass)) {
            $body = "<p><strong>{$qm->m['fmt_msg_invalidpass']}</strong></p>\n";
        } else {
            switch ($act) {
                case PLUGIN_DUMP_DUMP:
                    $body = plugin_dump2_download();
                    break;
                case PLUGIN_DUMP_RESTORE:
                    $retcode = plugin_dump2_upload();
                    $msg = $retcode['code'] ? $qm->m['plg_dump']['restore_success'] : $qm->m['plg_dump']['restore_failed'];
                    $body .= $retcode['msg'];
                    return array('msg' => $msg, 'body' => $back_url . $body);
                    break;
                case PLUGIN_DUMP_FULL:
                    $body = plugin_dump2_download_full();
                    break;
            }
        }
    }
    // 入力フォームを表示
    $body .= plugin_dump2_disp_form();
    $msg = '';
    if (PLUGIN_DUMP_ALLOW_RESTORE) {
        $msg = $qm->m['plg_dump']['title_bk_rstr'];
    } else {
        $msg = $qm->m['plg_dump']['title_bk'];
    }
    return array('msg' => $msg, 'body' => $back_url . $body);
}
function plugin_qblog_recent_comments_convert()
{
    global $script, $qblog_date_format, $qblog_close;
    //閉鎖中は何も表示しない
    if ($qblog_close && !ss_admin_check()) {
        return '';
    }
    //---- キャッシュのための処理を登録 -----
    $qt = get_qt();
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    $args = func_get_args();
    $nodate = in_array('nodate', $args);
    $datafile = CACHEQBLOG_DIR . 'qblog_recent_comments.dat';
    $comment_page_lines = explode("\n", file_get_contents($datafile));
    $comment_pages = array();
    foreach ($comment_page_lines as $line) {
        if (trim($line) === '') {
            continue;
        }
        list($time, $pagename) = explode("\t", $line);
        if (is_page($pagename)) {
            $comment_pages[$pagename] = $time;
        }
    }
    //calc num show
    $num = func_num_args() > 0 ? min(func_get_arg(0), PLUGIN_QBLOG_RECENT_COMMENTS_DEFAULT_NUM) : PLUGIN_QBLOG_RECENT_COMMENTS_DEFAULT_NUM;
    $num = min(count($comment_pages), $num);
    $html_str = '<ul class="qblog_recent_comments">';
    $cnt = 0;
    foreach ($comment_pages as $pagename => $time) {
        if ($cnt == PLUGIN_QBLOG_RECENT_COMMENTS_DEFAULT_NUM) {
            break;
        }
        $page_title = get_page_title($pagename);
        $page_title = ($nodate ? '' : date('m.d', $time) . ' ') . $page_title;
        $html_str .= '<li><a href="' . $script . '?' . rawurlencode($pagename) . '">' . h($page_title) . '</a></li>' . "\n";
        $cnt++;
    }
    $html_str .= '</ul>';
    return $html_str;
}
Example #10
0
function plugin_source_action()
{
    global $vars, $script;
    if (PKWK_SAFE_MODE) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    $vars['refer'] = $page;
    $editable = ss_admin_check();
    if (!$editable) {
        header("Location: {$script}");
        exit;
    }
    $qm = get_qm();
    if (!is_page($page) || !check_readable($page, false, false)) {
        return array('msg' => $qm->m['plg_source']['title_notfound'], 'body' => $qm->m['plg_source']['err_notfound']);
    }
    return array('msg' => $qm->m['plg_source']['title'], 'body' => '<pre id="source">' . htmlspecialchars(join('', get_source($page))) . '</pre>');
}
Example #11
0
function plugin_system_updater_action()
{
    global $script, $vars, $style_name;
    if (!ss_admin_check()) {
        redirect($script, 'この機能には、管理者のみアクセス可能です。');
    }
    if (($errmsg = plugin_system_updater_check()) !== '') {
        redirect($script, $errmsg);
    }
    plugin_system_updater_assets();
    $mode = isset($vars['mode']) ? $vars['mode'] : 'update';
    switch ($mode) {
        case 'confirm':
            return plugin_system_updater_action_confirm();
        case 'complete':
            return plugin_system_updater_action_complete();
        default:
            return plugin_system_updater_action_upload();
    }
}
Example #12
0
function plugin_skin_customizer_action()
{
    global $vars, $script;
    if (!ss_admin_check()) {
        redirect($script, '管理者のみアクセスできます。');
        exit;
    }
    $skin_name = $_SESSION['temp_design'];
    $custom_file = CACHE_DIR . 'custom_skin.' . $skin_name . '.dat';
    if (isset($vars['phase']) && $vars['phase'] == 'file_upload') {
        require PLUGIN_DIR . 'skin_customizer/SkinCustomizer_UploadHandler.php';
        $param_name = isset($vars['param_name']) ? $vars['param_name'] : 'files';
        $options = array('upload_dir' => CACHE_DIR, 'upload_url' => CACHE_DIR, 'param_name' => $param_name, 'image_versions' => array('' => array('auto_orient' => true)), 'skin_name' => $skin_name);
        $upload_handler = new SkinCustomizer_UploadHandler($options);
        exit;
    } else {
        if (isset($vars['save'])) {
            $skin_config = read_skin_config($_SESSION['temp_design']);
            $data = array();
            foreach ($skin_config['custom_options'] as $key => $row) {
                if (isset($vars[$key])) {
                    if ($row['type'] === 'if') {
                        $vars[$key] = intval($vars[$key]) === 1 ? true : false;
                    }
                    $data[$key] = $vars[$key];
                }
            }
            // data write
            $data = serialize($data);
            file_put_contents($custom_file, $data, LOCK_EX);
        } else {
            if (isset($vars['reset'])) {
                $files = glob(CACHE_DIR . 'custom_skin.' . $skin_name . '*');
                foreach ($files as $file) {
                    unlink($file);
                }
            }
        }
    }
    redirect($script);
}
Example #13
0
function plugin_qblog_list_convert()
{
    global $vars, $qblog_date_format, $show_passage;
    global $qblog_page_prefix, $qblog_defaultpage, $qblog_page_format, $qblog_close;
    global $style_name;
    //閉鎖中は何も表示しない
    if ($qblog_close && !ss_admin_check()) {
        return '';
    }
    static $exec_count = 1;
    $qm = get_qm();
    $qt = get_qt();
    $qt->setv('jquery_include', TRUE);
    $list_type = PLUGIN_QBLOG_LIST_TYPE;
    $recent_posts = PLUGIN_QBLOG_LIST_DEFAULT_POSTS;
    if (func_num_args()) {
        $args = func_get_args();
        if (count($args) > 2) {
            return '#qblog_list([line or table], [number])';
        }
        foreach ($args as $arg) {
            if (is_numeric($arg)) {
                $recent_posts = (int) $arg;
            }
            if ($arg == 'line') {
                $list_type = $arg;
            }
        }
    }
    //表示モード
    //recent, archives, category
    $mode = isset($vars['mode']) ? $vars['mode'] : 'recent';
    //表示ページ:ページネーション
    //表示ページは必ず 1以上の整数
    $page_num = isset($vars['p']) ? (int) $vars['p'] : 1;
    $page_num = $page_num <= 0 ? 1 : $page_num;
    // !前処理
    if (!is_bootstrap_skin()) {
        $include_bs = '
<link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" />
<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>';
        $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs);
    }
    //qblog.css を読み込む
    $head = '
<link rel="stylesheet" href="plugin/qblog/qblog.css" />';
    $qt->appendv_once('qblog_beforescript', 'beforescript', $head);
    //---- キャッシュのための処理を登録 -----
    $qt->enable_cache = FALSE;
    //------------------------------------
    if (!file_exists(PLUGIN_QBLOG_LIST_CACHE)) {
        return $qm->m['plg_recent']['err_file_notfound'] . '<br />';
    }
    $script = get_script_uri();
    $date = $items = '';
    //h2.title 前に挿入するHTML
    $pre_title_html = '';
    // !新規記事追加リンクを表示
    // デフォルトブログページが編集できるユーザー
    $editable = FALSE;
    if (check_editable($qblog_defaultpage, FALSE, FALSE) === TRUE) {
        $editable = TRUE;
        $search_replace = array('YYYY' => date('Y'), 'MM' => date('m'), 'DD' => date('d'));
        $newpage = str_replace(array_keys($search_replace), array_values($search_replace), $qblog_page_format);
        $number_holder_pos = strpos($newpage, '#');
        if ($number_holder_pos !== FALSE) {
            $filename_prefix = encode(substr($newpage, 0, $number_holder_pos));
            $files = glob(DATA_DIR . $filename_prefix . '*');
            $pattern = '/^(' . str_replace('#', '(\\d+)', preg_quote($newpage)) . ')$/';
            $max = 1;
            foreach ($files as $file) {
                $pagename = decode(basename($file, '.txt'));
                if (preg_match($pattern, $pagename, $mts)) {
                    $max = max($mts[2], $max);
                }
            }
            $newpage = str_replace('#', $max + 1, $newpage);
        }
        $addpostlink = $script . '?cmd=qblog&mode=addpost';
        $pre_title_html .= '<a href="' . h($addpostlink) . '" class="badge badge-info" style="color:#fff"><i class="icon-white icon-edit" style="vertical-align:text-bottom;"></i> 記事の追加</a> ';
    }
    // !モードによって、読み込むキャッシュを替える
    $pages = array();
    $start = ($page_num - 1) * $recent_posts;
    $addquery = '';
    switch ($mode) {
        case 'archives':
            $date = $vars['date'];
            $addquery = '&mode=archives&date=' . rawurlencode($date);
            if (preg_match('/^(\\d{4})(\\d{2})$/', $date, $mts)) {
                $year = $mts[1];
                $month = $mts[2];
            } else {
                $year = date('Y');
                $month = date('m');
            }
            $date = $year . $month;
            $files = glob(DATA_DIR . encode($qblog_page_prefix . $date) . '*');
            foreach ($files as $file) {
                $pages[] = decode(basename($file, '.txt'));
            }
            $count_pages = count($pages);
            natsort($pages);
            $pages = array_reverse($pages);
            $pages = array_slice($pages, $start, $recent_posts);
            $subtitle = "{$year}年{$month}月";
            $pre_title_html .= '<span class="badge">' . h($subtitle) . '</span> ';
            break;
        case 'category':
            $cat = isset($vars['catname']) ? $vars['catname'] : $qblog_default_cat;
            $addquery = '&mode=category&catname=' . rawurlencode($cat);
            $pages = explode("\n", trim(file_get_contents(CACHEQBLOG_DIR . encode($cat) . '.qbc.dat')));
            $count_pages = count($pages);
            $pages = array_slice($pages, $start, $recent_posts);
            $pre_title_html .= '<span class="badge">カテゴリ:' . h($cat) . '</span> ';
            break;
        default:
            //recent mode
            // Get latest N changes
            $count_pages = (int) array_pop(file_head(PLUGIN_QBLOG_LIST_CACHE, 1));
            $lines = file_slice(PLUGIN_QBLOG_LIST_CACHE, $start + 1, $recent_posts);
            foreach ($lines as $line) {
                $pages[] = rtrim($line);
            }
    }
    //! 記事毎のデータをまとめる
    $posts = array();
    foreach ($pages as $i => $page) {
        //キャッシュファイルを読み込む
        $data = get_qblog_post_data($page);
        if ($data === FALSE) {
            continue;
        }
        $r_page = rawurlencode($page);
        if (is_file(SWFU_IMAGE_DIR . $data['image'])) {
            $data['image'] = SWFU_IMAGE_DIR . $data['image'];
        }
        if (trim($data['image']) === '') {
            $data['image'] = PLUGIN_DIR . 'qblog/qblog_thumbnail.png';
        }
        if (trim($data['image']) === '') {
            $data['image'] = PLUGIN_DIR . 'qblog/qblog_thumbnail.png';
        }
        $posts[$i] = array('page' => $page, 'title' => $data['title'], 'abstract' => $data['abstract'], 'image' => $data['image'], 'category' => $data['category'], 'url' => $script . '?' . $r_page . $addquery, 'date' => get_qblog_date($qblog_date_format, $page));
    }
    // !ページネーションリンクを足す
    $paginates = array();
    if ($count_pages > $recent_posts) {
        if ($page_num > 1) {
            $paginates[PLUGIN_QBLOG_LIST_PAGINATE_LAST_NAV] = $script . '?' . $qblog_defaultpage . '&p=1' . $addquery;
        }
        $paginate_length = ceil($count_pages / $recent_posts);
        if (PLUGIN_QBLOG_LIST_PAGINATE_NUM < $paginate_length) {
        }
        $range = (int) floor(PLUGIN_QBLOG_LIST_PAGINATE_NUM / 2);
        $start = (int) max(1, $page_num - $range);
        $end = (int) min($paginate_length + 1, $start + PLUGIN_QBLOG_LIST_PAGINATE_NUM);
        // 最初<<< 1 | 2 | 3 | 4 | 5 >>>最後
        // 最初<<< 5 | 6 | 7 | 8 | 9 >>>最後
        for ($i = $start; $i < $end; $i++) {
            $paginates[$i] = $script . '?' . $qblog_defaultpage . '&p=' . $i . $addquery;
            if ($page_num == $i) {
                $paginates[$i] = '';
            }
        }
        if ($page_num < $paginate_length) {
            $paginates[PLUGIN_QBLOG_LIST_PAGINATE_FIRST_NAV] = $script . '?' . $qblog_defaultpage . '&p=' . $paginate_length . $addquery;
        }
    }
    $template_name = 'qblog_list_template.html';
    if (file_exists(SKIN_DIR . $style_name . '/' . $template_name)) {
        $template_path = SKIN_DIR . $style_name . '/' . $template_name;
    } else {
        $template_path = PLUGIN_DIR . 'qblog/list_template.html';
    }
    //! テンプレートを読み込む
    ob_start();
    include $template_path;
    $items .= ob_get_clean();
    //! h2.title にbadge を挿入
    if ($list_type === 'table') {
        $qt->prependv('this_right_title', $pre_title_html);
    }
    return '<div id="qblog">' . $items . '</div>';
}
Example #14
0
function plugin_list_get_commands($page)
{
    $retarr = array('read' => array('format' => '%s?%s', 'label' => '表示'), 'edit' => array('format' => '%s?cmd=edit&page=%s', 'label' => '編集'), 'diff' => array('format' => '%s?cmd=diff&page=%s', 'label' => '差分'), 'backup' => array('format' => '%s?cmd=backup&page=%s', 'label' => 'バックアップ'), 'rename' => array('format' => '%s?cmd=rename&refer=%s', 'label' => '名前変更'), 'delete' => array('format' => '%s?cmd=delete&page=%s', 'label' => '削除'), 'map' => array('format' => '%s?cmd=map&refer=%s', 'label' => 'マップ'), 'template' => array('format' => '%s?cmd=template&refer=%s', 'label' => '複製'));
    if (PKWK_READONLY) {
        return array('read' => $retarr['read']);
    }
    if (!ss_admin_check()) {
        unset($retarr['diff'], $retarr['backup'], $retarr['rename'], $retarr['map'], $retarr['template']);
        if (!check_editable($page, FALSE, FALSE)) {
            unset($retarr['edit']);
        }
    }
    return $retarr;
}
Example #15
0
<?php

//---------------------------------------
// セールスレター型特有の設定
// lib/html.php に読み込まれることを想定
//
//-------------------------------------------------
//
// 外部リンクを別ウインドウで開くためのjavascriptの読み込み
//-------------------------------------------------
if (exist_plugin('external_link')) {
    plugin_external_link_js($nowindow, $reg_exp_host);
}
//when admin call Bootstrap and jquery
if ($qt->getv('editable') || ss_admin_check()) {
    $qt->setv('jquery_include', true);
    $qt->setv('bootstrap_script', '<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>');
    $qt->setv('bootstrap_style', '<link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" />');
}
// Javascript 読み込み
$include_js = '
<script src="js/qhm.js"></script>';
$qt->appendv_once('include_qhm_js', 'beforescript', $include_js);
//------------------------------------------------------
//
//  killerpage2 css settings
//
//------------------------------------------------------
//shadeborder
$sb_beforescript = '
<!--[if lte IE 8]>
Example #16
0
function plugin_dump_action()
{
    global $style_name, $script;
    $qm = get_qm();
    $qt = get_qt();
    $include_bs = '
<link rel="stylesheet" href="skin/bootstrap/css/bootstrap.min.css" />
<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>';
    $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs);
    $head = '
<link rel="stylesheet" href="skin/hokukenstyle/qhm.css" />
<style type="text/css">
body {background-color: #E7E7E7;}
</style>';
    $qt->appendv('beforescript', $head);
    $style_name = '..';
    $back_url = '<p><a href="' . $script . '">' . $qm->m['frontpage'] . '</a> &gt; <a href="' . $script . '?cmd=qhmsetting">' . $qm->m['preferences'] . '</a> &gt; ' . $qm->m['here'] . '</p>';
    $editable = ss_admin_check();
    if (!$editable) {
        return array('msg' => $qm->m['plg_dump']['title'], 'body' => $qm->m['fmt_err_page_only_for_admin']);
    }
    global $vars;
    if (PKWK_READONLY) {
        die_message($qm->m['fmt_err_pkwk_readonly']);
    }
    $pass = isset($_POST['pass']) ? $_POST['pass'] : NULL;
    $act = isset($vars['act']) ? $vars['act'] : NULL;
    $body = '';
    if ($pass !== NULL) {
        if (!pkwk_login($pass)) {
            $body = "<p class=\"alert alert-danger\">{$qm->m['fmt_err_invalidpass']}</strong></p>\n";
        } else {
            switch ($act) {
                case PLUGIN_DUMP_DUMP:
                    $body = plugin_dump_download();
                    break;
                case PLUGIN_DUMP_RESTORE:
                    $retcode = plugin_dump_upload();
                    $msg = $retcode['code'] ? $qm->m['plg_dump']['restore_success'] : $qm->m['plg_dump']['restore_failed'];
                    $body .= $retcode['msg'];
                    return array('msg' => $msg, 'body' => $back_url . $body);
                    break;
                case PLUGIN_DUMP_FULL:
                    $body = plugin_dump_download_full();
                    break;
            }
        }
    }
    // 入力フォームを表示
    $body .= plugin_dump_disp_form();
    $msg = '';
    if (PLUGIN_DUMP_ALLOW_RESTORE) {
        $msg = $qm->m['plg_dump']['title_bk_rstr'];
    } else {
        $msg = $qm->m['plg_dump']['title_bk'];
    }
    return array('msg' => $msg, 'body' => $back_url . $body);
}
Example #17
0
}
// CSSの生成
$default_css = '
<link rel="stylesheet" media="screen" href="' . SKIN_DIR . $style_name . '/main.css' . $reflesh . '">
';
if (file_exists(SKIN_DIR . $style_name . '/main_print.css')) {
    $default_css .= '<link rel="stylesheet" media="print" href="' . SKIN_DIR . $style_name . '/main_print.css">
';
}
$qt->setv('default_css', $bootstrap_css . $default_css);
$qt->setv('style_name', $style_name);
$qt->setv('style_path', SKIN_DIR . $style_name . '/');
if (file_exists('favicon.ico')) {
    $qt->appendv('default_css', '<link rel="shortcut icon" href="favicon.ico"  type="image/x-icon" />');
}
if (($qt->getv('editable') || ss_admin_check()) && !$is_setting) {
    //Bootstrap
    $include_bs = '
<link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" />
<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>';
    if ($is_bootstrap_skin) {
        $include_bs = '';
    }
    $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs);
}
// Javascript 読み込み
$include_js = '
<script src="js/qhm.min.js"></script>';
$qt->appendv_once('include_qhm_js', 'beforescript', $include_js);
// 自分自身へのリンクを削除する
// ※ おかしな設定の共用SSLにも対応する
Example #18
0
function plugin_convert_haik_action()
{
    global $vars, $script;
    if (!ss_admin_check()) {
        redirect($script, '管理者以外利用できません。');
    }
    if (!file_exists('haik-contents') or !is_dir('haik-contents')) {
        redirect($script, 'この機能はご利用いただけません。');
    }
    //確認画面
    if (!isset($vars['adminpass']) or !pkwk_login($vars['adminpass'])) {
        $msg = 'haik データ移行';
        $info = plugin_convert_haik_get_info();
        $warning = plugin_convert_haik_get_warning();
        $danger = '';
        if (isset($vars['adminpass'])) {
            $danger = <<<EOD
<div class="alert alert-danger">
  管理者パスワードが正しくありません。
</div>
EOD;
        }
        $body = <<<EOD
<h2>{$msg}</h2>
<p>
  haik のデータを QHM で動作するように変換します。<br>
  実行すると、<strong>現在のデータに対して</strong>上書きされます。
  よろしければ、<strong>開始</strong>ボタンを押して実行してください。
</p>
{$warning}
{$danger}
<form action="{$script}?cmd=convert_haik" method="post" class="form-inline">
  <div class="form-group">
    <label>管理者パスワード</label>
    <input type="password" name="adminpass" class="form-control">
  </div>
  <button type="submit" class="qhm-btn qhm-btn-primary">開始</button>
</form>
<hr>
<h3>移行情報</h3>
{$info}
EOD;
        return array('msg' => $msg, 'body' => $body);
    }
    // タイムスタンプを記録する
    plugin_convert_haik_write_log(date('Y-m-d H:i:s') . ' haik からのデータ移行開始' . "\n");
    //1.haik-contents/config/haik.ini.php を適宜 qhm.ini.php へ移植
    plugin_convert_haik_move_inifile();
    //2.haik-contents/upload/* を swfu/d/ へ移動し、ファイルチェックを行う
    plugin_convert_haik_move_uploadfile();
    //3.haik-contents/wiki/*.txt を wiki/ へコピーする
    plugin_convert_haik_move_wiki();
    //4.haik と qhm で名前が異なるプラグインを変換する
    plugin_convert_haik_replace_plugin();
    //5.haik-contents/meta/*.php を解釈して書式をソースへ追加する
    plugin_convert_haik_set_meta();
    plugin_convert_haik_write_log('');
    $log_text = file_get_contents(CACHE_DIR . 'convert_haik.log');
    $url = dirname($script . "dummy") . '/swfu/check.php';
    $body = <<<EOD
<h2>移行が完了しました</h2>
<p>
  <a href="{$script}" class="qhm-btn qhm-btn-info">トップへ戻る</a>
</p>

<div class="alert alert-warning">
  haik と QHM で対応するプラグインが無い場合、変換が行われていないため、手動での削除、修正をお願いいたします。
  <pre>* download プラグイン
* mc_form プラグイン
* form プラグイン
* goo_gl プラグイン
* scrollup プラグイン</pre>
</div>

<div class="alert alert-warning">
  icon プラグインは IcoMoon から <a href="http://getbootstrap.com/components/#glyphicons" title="Bootstrap glyphicons" target="_blank">glyphicon</a>, <a href="http://fortawesome.github.io/Font-Awesome/cheatsheet/" title="FontAwesome Cheatsheat" target="_blank">font-awesome</a> に変更されました。<br>
  指定したアイコン名によっては表示されなくなる場合があります。
</div>

<hr>

<h3>移行ログ</h3>

<div style="height:300px;overflow-y:scroll">
  <pre>{$log_text}</pre>
</div>

EOD;
    $body .= '<iframe src="' . $url . '" width="0" height="0"></iframe>';
    return array('msg' => 'complete', 'body' => $body);
}
Example #19
0
/**
 *   QHM Check Login Plugin
 *   -------------------------------------------
 *   check_login.inc.php
 *   
 *   Copyright (c) 2010 hokuken
 *   http://hokuken.com/
 *   
 *   created  : 2010-12-15
 *   modified :
 *   
 *   Description
 *   
 *   Usage :
 *   
 */
function plugin_check_login_action()
{
    global $vars, $script, $auth_users;
    $qt = get_qt();
    //Ajax
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
        $mode = isset($vars['mode']) ? $vars['mode'] : 'check';
        $res = array('status' => 0, 'message' => '', 'data' => null);
        //チェック
        if ($mode == 'check') {
            // login OK
            if (isset($_SESSION['usr']) && array_key_exists($_SESSION['usr'], $auth_users)) {
                $res['status'] = 1;
                $res['message'] = 'login';
            } else {
                $res['status'] = 0;
                $res['message'] = 'logout';
            }
        } else {
            if ($mode == 'auth') {
                $username = isset($vars['username']) ? $vars['username'] : '';
                $password = isset($vars['password']) ? $vars['password'] : '';
                //OK
                if (isset($auth_users[$username]) && $auth_users[$username] == pkwk_hash_compute($password)) {
                    $_SESSION['usr'] = $username;
                    if (ss_admin_check()) {
                        $d = dir(CACHEQHM_DIR);
                        while (false !== ($entry = $d->read())) {
                            if ($entry != '.' && $entry != '..') {
                                $entry = CACHEQHM_DIR . $entry;
                                if (file_exists($entry)) {
                                    // cacheqhmディレクトリにある3日前の一時ファイルを削除
                                    if (mktime(date("H"), date("i"), date("s"), date("n"), date("j") - 3, date("Y")) > time(fileatime($entry))) {
                                        unlink($entry);
                                    }
                                }
                            }
                        }
                        $d->close();
                    }
                    $res['status'] = 1;
                    $res['message'] = 'Login Success';
                } else {
                    $res['status'] = 2;
                    $res['message'] = 'Invalid Username or Password';
                }
            } else {
                if ($mode == 'destroy') {
                    ss_auth_logout();
                    $res['status'] = 0;
                    $res['message'] = 'logout';
                } else {
                    $res['status'] = 2;
                    $res['message'] = 'request error';
                    $res['data'] = $vars;
                }
            }
        }
        header("Content-Type: application/json; charset=UTF-8");
        $json = json_encode($res);
        echo $json;
        exit;
    } else {
        $to = $script . '?cmd=qhmauth';
        header("Location: {$to}");
        exit;
    }
}
Example #20
0
/**
 *   QBlog Setting Plugin
 *   -------------------------------------------
 *   ./plugin/qblog.inc.php
 *
 *   Copyright (c) 2012 hokuken
 *   http://hokuken.com/
 *
 *   created  : 12/07/31
 *   modified :
 *
 *   Description
 *
 *   Usage :
 *
 */
function plugin_qblog_action()
{
    global $vars, $script, $style_name;
    global $qblog_defaultpage, $qblog_default_cat, $qblog_date_format, $qblog_page_prefix;
    global $qblog_social_widget, $qblog_social_html, $qblog_social_wiki, $qblog_title;
    global $qblog_enable_comment, $qblog_close, $qblog_enable_ping, $qblog_ping;
    global $qblog_comment_notice, $admin_email;
    $qt = get_qt();
    $style_name = '..';
    $vars['disable_toolmenu'] = TRUE;
    $qt->setv('no_menus', TRUE);
    //メニューやナビ等をconvertしない
    $include_bs = '
<link rel="stylesheet" href="skin/bootstrap/css/bootstrap.min.css" />
<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>';
    $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs);
    $beforescript = '
<link rel="stylesheet" href="' . PLUGIN_DIR . 'qblog/qblog.css" />
<script type="text/javascript" src="js/jQuery.ajaxQueue.min.js"></script>';
    $qt->appendv('beforescript', $beforescript);
    // 管理者でない場合はブログトップへ移動する
    // 記事の追加のみ、編集権限を後でチェックする
    if ($vars['mode'] !== 'addpost' && !ss_admin_check()) {
        $url = $script . '?' . $qblog_defaultpage;
        header('Location: ' . $url);
        exit;
    }
    // モード毎の処理
    if (isset($vars['mode'])) {
        if ($vars['mode'] == 'delete') {
            plugin_qblog_delete_category();
        } else {
            if ($vars['mode'] === 'rebuild') {
                plugin_qblog_rebuild_posts();
            } else {
                if ($vars['mode'] === 'social_widget') {
                    plugin_qblog_save_social_widget();
                } else {
                    if ($vars['mode'] === 'move_confirm') {
                        $ret = plugin_qblog_move_from_ameba_confirm();
                        if ($ret) {
                            return $ret;
                        }
                    } else {
                        if ($vars['mode'] == 'move') {
                            plugin_qblog_move_from_ameba();
                        } else {
                            if ($vars['mode'] == 'move_from_eblog_confirm') {
                                $ret = plugin_qblog_move_from_eblog_confirm();
                                if ($ret !== FALSE) {
                                    return $ret;
                                }
                            } else {
                                if ($vars['mode'] == 'move_from_eblog') {
                                    plugin_qblog_move_from_eblog();
                                } else {
                                    if ($vars['mode'] == 'start') {
                                        plugin_qblog_start();
                                    } else {
                                        if ($vars['mode'] == 'addpost') {
                                            $newpage = qblog_get_newpage();
                                            if (check_editable($newpage, TRUE, FALSE)) {
                                                $newpage_url = $script . '?cmd=edit&page=' . $newpage;
                                                redirect($newpage_url);
                                            } else {
                                                $url = $script . '?' . $qblog_defaultpage;
                                                header('Location: ' . $url);
                                                exit;
                                            }
                                        } else {
                                            if ($vars['mode'] == 'edit_title') {
                                                plugin_qblog_edit_title();
                                            } else {
                                                if ($vars['mode'] == 'enable_comment') {
                                                    plugin_qblog_enable_comment();
                                                } else {
                                                    if ($vars['mode'] == 'close') {
                                                        plugin_qblog_close();
                                                    } else {
                                                        if ($vars['mode'] == 'rename_category') {
                                                            plugin_qblog_rename_category();
                                                        } else {
                                                            if ($vars['mode'] == 'update_ping') {
                                                                plugin_qblog_update_ping();
                                                            } else {
                                                                if ($vars['mode'] == 'comment_notice') {
                                                                    plugin_qblog_update_comment_notice();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // ! お知らせをセットする
    $qblog_info = '';
    if (isset($vars['phase'])) {
        switch ($vars['phase']) {
            case 'set_title':
                $qblog_info = '
<div class="qblog_info alert alert-success">
	<button class="close" data-dismiss="alert">×</button>
	<p>
		<b>ブログに名前を付けましょう!</b><br />
		<a href="#qblog_title" data-tab="move" id="go_qblog_title" class="btn">ブログタイトル設定</a>へ進んでください。
	</p>
</div>
';
                break;
            case 'edit_title':
                $qblog_info = '
<div class="qblog_info alert alert-success">
	<button class="close" data-dismiss="alert">×</button>
	<p>
		ブログタイトルを変更しました。
	</p>';
                if (!glob(DATA_DIR . encode($qblog_page_prefix) . '*')) {
                    $vars['hash'] = 'misc';
                    $qblog_info .= '
	<p>
		<b>アメブロをお持ちの方:</b><br />
		<a href="#qblog_move_ameba" data-tab="move" class="btn">アメブロからの引越し</a>に進んでください。
	</p>
	<p>
		<b>QHMプロの簡易ブログをご利用の方:</b><br />
		<a href="#qblog_move_eblog" data-tab="move" class="btn">簡易ブログからの引越し</a>に進んでください。
	</p>
	<p>
		<b>ブログを利用されていない方:</b><br />
		<a href="' . $script . '?cmd=qblog&mode=addpost" class="btn">さっそく、新しい記事を投稿しましょう!</a>
	</p>';
                }
                $qblog_info .= '
</div>
';
                break;
            case 'social_widget':
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	ソーシャルウィジェット設定を保存しました。
</div>
';
                break;
            case 'rebuild':
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	ブログの修復が完了しました。
</div>
';
                break;
            case 'delete_category':
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	カテゴリー:' . h($vars['category']) . ' を削除しました。
</div>
';
                break;
            case 'enable_comment':
                $commentmsg = $qblog_enable_comment ? '表示する' : '表示しない';
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	コメントの表示を「' . $commentmsg . '」にしました。
</div>
';
                break;
            case 'close':
                $msg = $qblog_close ? '閉鎖' : '公開';
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	ブログを「' . $msg . '」しました。
</div>
';
                break;
            case 'rename_category':
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	カテゴリー名を変更しました。
</div>
';
                break;
            case 'ping':
                $msg = $qblog_enable_ping ? '有効' : '無効';
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	Ping送信を「' . $msg . '」にしました。
</div>
';
                break;
            case 'comment_notice':
                $msg = $qblog_comment_notice ? '通知する' : '通知しない';
                $qblog_info = '
<div class="qblog_info alert alert-success">
<button class="close" data-dismiss="alert">×</button>
	コメントを「' . $msg . '」にしました。
</div>
';
                break;
            default:
        }
    } else {
        if ($qblog_close) {
            $qblog_info = '
<div class="qblog_info alert alert-danger">
<button class="close" data-dismiss="alert">×</button>
	ブログは<strong>閉鎖中</strong>です。<br />
	公開する場合、「その他」タブを開いて、ブログの閉鎖設定を変更してください。
</div>
';
        }
    }
    // エラーがあればエラーをセットする
    $qblog_error = '';
    if (isset($vars['qblog_error']) && $vars['qblog_error'] != '') {
        $qblog_error = $vars['qblog_error'];
    }
    //開くタブをセットする
    $hash = isset($vars['hash']) ? $vars['hash'] : '';
    // ブログの初期設定
    // ! ブログの記事が存在するかチェック
    $files = glob(DATA_DIR . encode($qblog_page_prefix) . '*');
    // ! アメブロからの引越を表示するかしないか
    $move_amebro = FALSE && count($files) == 0;
    // !カテゴリ一覧の取得
    $categories_file = CACHEQBLOG_DIR . 'qblog_categories.dat';
    $categories = array();
    if (file_exists($categories_file)) {
        $categorydata = explode("\n", file_get_contents($categories_file));
        foreach ($categorydata as $data) {
            if (strlen(trim($data)) > 0) {
                list($name, $num) = explode("\t", trim($data));
                $categories[$name] = array('name' => $name, 'num' => $num);
            }
        }
    }
    // !未承認コメントの一覧
    $pending_comments = unserialize(file_get_contents(CACHEQBLOG_DIR . 'qblog_pending_comments.dat'));
    $pending_comments = $pending_comments === FALSE ? array() : $pending_comments;
    foreach ($pending_comments as $i => $comment) {
        $pending_comments[$i]['post_title'] = mb_strimwidth(get_page_title($comment['page']), 0, 16, '...');
        $pending_comments[$i]['title'] = mb_strimwidth($comment['title'], 0, 16, '...');
        $pending_comments[$i]['name'] = mb_strimwidth($comment['name'], 0, 12, '...');
    }
    // !RSSのURL
    $rss_url = '';
    if (exist_plugin('rss')) {
        $rss_url = $script . '?cmd=rss&qblog_rss=1';
    }
    // !Ping
    if (trim($qblog_ping) === '') {
        $qblog_ping = plugin_qblog_get_default_ping();
    }
    //! テンプレートを読み込む
    $html = '';
    ob_start();
    include PLUGIN_DIR . 'qblog/qblog_index_template.html';
    $html .= ob_get_clean();
    return array('msg' => 'ブログ設定', 'body' => $html);
}
Example #21
0
        $retvars = array('msg' => $msg, 'body' => $msg);
        $base =& $defaultpage;
    }
}
$title = h(strip_bracket($base));
$page = make_search($base);
if (isset($retvars['msg']) && $retvars['msg'] != '') {
    $title = str_replace('$1', $title, $retvars['msg']);
    $page = str_replace('$1', $page, $retvars['msg']);
}
//------------------------------------------------------
// * サイト全体を閉鎖するオプションがOnの場合、
//  qhmloginへのアクセス以外、全部、「閉鎖中」を出す
// 2009 6/18 (by hokuken.com)
//------------------------------------------------------
if ($site_close_all && !ss_admin_check() && $vars['phase'] != 'sssavepath') {
    $_SESSION['usr'] = null;
    output_site_close_message($page_title, $script . '?cmd=qhmauth');
    exit;
}
//--
// 共用SSLの多くは、SSL通信なのに、SERVER変数が、http系になっていることがほとんど
// そこで、SSL通信の場合、$scriptは、https://.. にするために、$script_sslを使うようにする
// 独自SSLを導入している場合でも、対応できる ( lib/init.php で、$script_ssl を作っているので )
//  ※ なお、convert_htmlが終わった時点で、元に戻す(このelseブロックの最後を参照)
if (is_https()) {
    $scr_tmp = $script;
    $script = $script_ssl;
    $script_ssl = $scr_tmp;
}
if (isset($retvars['body']) && $retvars['body'] != '') {
Example #22
0
function ss_chkusr($title, $users)
{
    global $script;
    global $login_log;
    $qm = get_qm();
    // キャンセルなら、トップへリダイレクト
    if (isset($_POST['send']) && $_POST['send'] == $qm->m['ss_authform']['btn_cancel']) {
        //この比較は非推奨
        header('Location: ' . $script);
        exit;
    } else {
        if (isset($_POST['send']) && $_POST['send'] == $qm->m['ss_authform']['btn_login']) {
            $user = isset($_POST['username']) ? $_POST['username'] : '';
            $pass = isset($_POST['password']) ? $_POST['password'] : '';
            // User, Passwordをチェック
            $auth = array_key_exists($user, $users) && check_passwd($pass, $users[$user]);
            //認証OK、NGに応じた処理
            if ($auth) {
                $_SESSION['usr'] = $user;
                if (ss_admin_check()) {
                    $d = dir(CACHEQHM_DIR);
                    while (false !== ($entry = $d->read())) {
                        if ($entry != '.' && $entry != '..') {
                            $entry = CACHEQHM_DIR . $entry;
                            if (file_exists($entry)) {
                                // cacheqhmディレクトリにある3日前の一時ファイルを削除
                                if (mktime(date("H"), date("i"), date("s"), date("n"), date("j") - 3, date("Y")) > time(fileatime($entry))) {
                                    unlink($entry);
                                }
                            }
                        }
                    }
                    $d->close();
                }
                return TRUE;
            } else {
                // カウントして、3回以上試行したらエラーを出す
                $_SESSION['ct'] = $_SESSION['ct'] + 1;
                if ($_SESSION['ct'] > 3) {
                    $_SESSION['ct'] = 0;
                    return FALSE;
                }
                ss_msg($qm->m['ss_authform']['err_auth']);
                exit;
            }
        } else {
            ss_auth_loginform($title);
            exit;
        }
    }
}
Example #23
0
function plugin_qblog_comment_action()
{
    global $script, $vars, $now;
    global $qblog_date_format, $qblog_comment_check, $qblog_defaultpage;
    $qm = get_qm();
    //TODO: remove
    if (PKWK_READONLY) {
        die_message($qm->m['fmt_err_pkwk_readonly']);
    }
    if ($vars['mode'] === 'accept') {
        plugin_qblog_comment_accept();
    } else {
        if ($vars['mode'] === 'hide') {
            plugin_qblog_comment_hide();
        } else {
            if ($vars['mode'] === 'get_comment') {
                plugin_qblog_comment_get();
            }
        }
    }
    $page = $vars['refer'];
    if ($vars['msg'] == '') {
        return array('msg' => '', 'body' => '');
    }
    // Do nothing
    //QBlog ページ以外設置不可
    if (!is_qblog($page)) {
        return array('msg' => '', 'body' => '');
    }
    $comment_title = isset($vars['title']) ? $vars['title'] : '';
    $writer_name = isset($vars['name']) ? $vars['name'] : '';
    $editable = check_editable($qblog_defaultpage, FALSE, FALSE);
    //CSRF 対策
    if (md5(join('', get_source($vars['refer']))) != $vars['digest']) {
        redirect($script);
    }
    $error = FALSE;
    if (mb_strlen($comment_title) > PLUGIN_QBLOG_MAX_COMMENT_TITLE_LENGTH) {
        $vars['qblog_comment_title_error'] = 'タイトルは' . PLUGIN_QBLOG_MAX_COMMENT_TITLE_LENGTH . '文字以内で入力してください。';
        $error = TRUE;
    }
    if (mb_strlen($writer_name) > PLUGIN_QBLOG_MAX_COMMENT_NAME_LENGTH) {
        $vars['qblog_comment_name_error'] = 'お名前は' . PLUGIN_QBLOG_MAX_COMMENT_NAME_LENGTH . '文字以内で入力してください。';
        $error = TRUE;
    }
    if (!$editable && $vars['authcode_master'] !== $vars['authcode']) {
        $vars['qblog_comment_auth_error'] = '認証コードを入力してください。';
        $error = TRUE;
    }
    if ($error) {
        return array('msg' => '', 'body' => '');
    }
    //管理人コメントは承認待ちしない
    $is_admin = ss_admin_check();
    $qblog_comment_check = $is_admin ? 0 : $qblog_comment_check;
    $comment_data = array('msg' => $vars['msg'], 'title' => $comment_title, 'name' => $writer_name, 'admin' => $is_admin);
    $title = $qm->m['fmt_title_updated'];
    $body = '';
    qblog_add_comment($page, $comment_data);
    $wiki = 'コメントありがとうございました。
コメントは管理者による承認後に表示されます。

#beforescript{{
<style type="text/css">
body {
margin-top:60px;
font-size: 15px;
background-color: #fff;
}
h2.title {
display:none;
}
#body {
text-align: center;
}
#body h2 {
font-size: 24px;
margin-top: 20px;
}
</style>
}}
';
    redirect($page, $wiki, 5);
}
Example #24
0
            unset($tools['haiklink']);
        }
    } else {
        $addjs = '
<script type="text/javascript" src="js/haik_theme_utility.js"></script>
<script type="text/javascript" src="' . PLUGIN_DIR . 'skin_customizer/color_picker.js"></script>
';
        $qt->appendv('beforescript', $addjs);
        // Determine custom skin
        $style_config = read_skin_config($style_name);
        $skin_custom_vars = get_skin_custom_vars($style_name);
        if (!isset($style_config['custom_options']['header']) || !$skin_custom_vars['header']) {
            unset($tools['sitelink']['sub']['headerlink']);
        }
    }
    if (!ss_admin_check()) {
        if (isset($tools['reflink'])) {
            unset($tools['reflink']);
        }
        if (isset($tools['pagelink'])) {
            unset($tools['pagelink']);
        }
        if (isset($tools['sitelink'])) {
            unset($tools['sitelink']);
        }
        if (isset($tools['toollink'])) {
            unset($tools['toollink']);
        }
        if (isset($tools['configlink'])) {
            unset($tools['configlink']);
        }
Example #25
0
/**
 *   cols
 *   -------------------------------------------
 *   cols.inc.php
 *
 *   Copyright (c) 2013 hokuken
 *   http://hokuken.com/
 *
 *   created  : 13/01/10
 *   modified : 13/08/07
 *
 *   Description
 *
 *
 *   Usage :
 *
 */
function plugin_cols_convert()
{
    $qm = get_qm();
    $qt = get_qt();
    $args = func_get_args();
    $body = array_pop($args);
    $type = plugin_cols_type('get');
    $msg = '';
    $cols = array();
    $delim = "\r====\r";
    $row_class = '';
    $num = $args[0];
    $col_push_index = false;
    $col_push_num = 0;
    $col_pull_index = false;
    $col_pull_num = 0;
    // 段落オプションの正規表現パターン
    $regex = <<<EOR
\t\t/
\t\t\t\\A
\t\t\t\t(\\d+)                    # 1: col-sm-N
\t\t\t\t(?:\\+(\\d+))?             # 2: col-sm-offset-N
\t\t\t\t(r|l)?                   # 3: col-sm-push col-sm-pull
\t\t\t\t(                        # 4: col-X-N col-X-offset-N
\t\t\t\t\t(?:
\t\t\t\t\t\t@(?:xs|md|lg)
\t\t\t\t\t\t\\d+
\t\t\t\t\t\t(?:\\+\\d+)?
\t\t\t\t\t)*
\t\t\t\t)?
\t\t\t\t(                         # 5: custom class name
\t\t\t\t\t(?:\\.[a-zA-Z0-9_-]+)+
\t\t\t\t)?
\t\t\t\\z
\t\t/x
EOR;
    if (count($args) > 0) {
        $max = 12;
        $total = 0;
        for ($i = 0; $i < count($args); $i++) {
            $args[$i] = trim($args[$i]);
            if ($args[$i] === '') {
                continue;
            }
            if (!preg_match($regex, $args[$i], $mts)) {
                if (preg_match('/^class=(.+)$/', $args[$i], $mts)) {
                    $row_class = " " . trim($mts[1]);
                } else {
                    if (preg_match('/^(left|center|right)$/i', $args[$i], $mts)) {
                        $row_class = " text-" . trim($mts[1]);
                    } else {
                        $delim = "\r" . trim($args[$i]) . "\r";
                    }
                }
                continue;
            }
            $col_num = (int) $mts[1];
            $col_offset = isset($mts[2]) ? (int) $mts[2] : 0;
            $col_push = false;
            if ($col_push_index === false && $col_pull_index === false && isset($mts[3]) && $mts[3] == 'r') {
                $col_push_index = count($cols);
                $col_push = $col_push_num = $col_num;
            }
            $col_pull = false;
            if ($col_push_index === false && $col_pull_index === false && isset($mts[3]) && $mts[3] == 'l') {
                $col_pull_index = count($cols);
                $col_pull = $col_pull_num = $col_num;
            }
            # スクリーンサイズによる段組幅の切り替え設定
            # e.g. @xs6@md6+3@lg10
            $custom_cols = array();
            if (isset($mts[4]) && strlen($mts[4]) > 0) {
                foreach (explode('@', trim($mts[4], '@')) as $custom_col) {
                    $key = substr($custom_col, 0, 2);
                    list($span, $offset) = explode('+', substr($custom_col, 2));
                    $custom_cols[$key] = array('span' => $span, 'offset' => $offset ? $offset : 0);
                }
            }
            $col_class = isset($mts[5]) ? $mts[5] : '';
            $total += $col_num + $col_offset;
            $cols[] = array('span' => $col_num, 'offset' => $col_offset, 'push' => $col_push, 'pull' => $col_pull, 'custom' => $custom_cols, 'class' => $col_class);
        }
        if (ss_admin_check()) {
            if ($max < $total) {
                $msg = <<<EOD
<div class="alert alert-danger">
\t<button type="button" class="close" data-dismiss="alert">&times;</button>
\t<p>指定しているカラムの合計数が12を超えています。</p>
\t<p>※このメッセージは、管理者にのみ表示しています</p>
</div>
EOD;
            }
        }
    }
    if (count($cols) === 0) {
        $data = explode($delim, $body);
        $col_num = (int) (12 / count($data));
        for ($i = 0; $i < count($data); $i++) {
            $cols[] = array('span' => $col_num, 'offset' => 0, 'class' => NULL, 'push' => false, 'pull' => false);
        }
    }
    if ($col_push_index !== false) {
        $push_sum = 0;
        for ($i = count($cols) - 1; $i > $col_push_index; $i--) {
            $cols[$i]['pull'] = $col_push_num;
            $push_sum += $cols[$i]['span'];
        }
        $cols[$col_push_index]['push'] = $push_sum;
    }
    if ($col_pull_index !== false) {
        $pull_sum = 0;
        for ($i = 0; $i < $col_pull_index; $i++) {
            $cols[$i]['push'] = $col_pull_num;
            $pull_sum += $cols[$i]['span'];
        }
        $cols[$col_pull_index]['pull'] = $pull_sum;
    }
    $html = '<div class="row%s">';
    if ($type === 'thumbnails') {
        $html = '<div class="row">';
    }
    $html = sprintf($html, h($row_class));
    $data = array_pad(explode($delim, $body, count($cols)), count($cols), '');
    global $block_style, $block_class, $block_image;
    if (!isset($block_style)) {
        $block_style = '';
    }
    if (!isset($block_class)) {
        $block_class = '';
    }
    if (!isset($block_image)) {
        $block_image = '';
    }
    for ($i = 0; $i < count($cols); $i++) {
        $option = $cols[$i];
        $offset = $option['offset'] ? ' col-sm-offset-' . $option['offset'] : '';
        $col_class = $option['class'] ? str_replace('.', ' ', $option['class']) : '';
        $col_push = $option['push'] ? ' col-sm-push-' . $option['push'] : '';
        $col_pull = $option['pull'] ? ' col-sm-pull-' . $option['pull'] : '';
        $screen_class = '';
        foreach ($option['custom'] as $screen_size => $config) {
            $screen_class .= " col-{$screen_size}-{$config['span']}";
            if ($config['offset']) {
                $screen_class .= " col-{$screen_size}-offset-{$config['offset']}";
            }
        }
        $open_tag = '<div class="col-sm-' . $option['span'] . $offset . $col_push . $col_pull . $screen_class . $col_class . '%s" style="%s">';
        $close_tag = '</div>';
        if ($type === 'thumbnails') {
            $open_tag = '<div class="col-sm-' . $option['span'] . $offset . ' %s" style="%s"><div class="thumbnail">%s<div class="caption">';
            $close_tag = '</div></div></div>';
        }
        $str = '';
        if (isset($data[$i])) {
            $str = str_replace("\r", "\n", str_replace("\r\n", "\n", $data[$i]));
            $lines = explode("\n", $str);
            $str = convert_html($lines);
        }
        $html .= sprintf($open_tag, " " . h($block_class), h($block_style), $block_image);
        $html .= $str . $close_tag;
        $block_class = $block_style = $block_image = '';
    }
    if ($type === 'thumbnails') {
        $html .= '</div>';
    } else {
        $html .= '</div>';
    }
    return $msg . $html;
}
Example #26
0
/**
 *   QBlog display post-head plugin
 *   -------------------------------------------
 *   ./plugin/qblog_head.inc.php
 *   
 *   Copyright (c) 2012 hokuken
 *   http://hokuken.com/
 *   
 *   created  : 12/07/30
 *   modified :
 *   
 *   Description
 *   
 *   Usage :
 *   
 */
function plugin_qblog_head_convert()
{
    global $vars, $script, $defaultpage;
    global $qblog_date_format, $qblog_page_re, $qblog_defaultpage, $qblog_close, $qblog_default_cat;
    if (!is_qblog()) {
        return '';
    }
    $closed_msg = '';
    if ($qblog_close) {
        if (ss_admin_check()) {
            $closed_msg = '
<div class="alert" style="margin-top: 15px ;margin-bottom: 15px ;">
	<button class="close" data-dismiss="alert">×</button>
	<p>
		ブログは閉鎖されています。<br />
		管理者以外のアクセスはトップページへ転送されます。
	</p>
	<p>
		※ブログメニュー上のリストも管理者以外には表示されません。
	</p>
</div>
';
        } else {
            redirect($defaultpage);
        }
    }
    $qt = get_qt();
    //RSSフィードを出力
    if (exist_plugin('rss')) {
        $rssurl = $script . '?cmd=rss&qblog_rss=1';
        $qt->setv_once('rss_link', $rssurl);
    }
    if (!is_bootstrap_skin()) {
        $include_bs = '
<link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" />
<script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>';
        $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs);
    }
    //qblog.css を読み込む
    $head = '
<link rel="stylesheet" href="plugin/qblog/qblog.css' . '" />';
    $qt->appendv_once('qblog_beforescript', 'beforescript', $head);
    $page = $vars['page'];
    // ブログトップは<head>内の調整のみ
    if ($page === $qblog_defaultpage) {
        return $closed_msg;
    }
    //日付を取得
    $date = get_qblog_date($qblog_date_format, $page);
    $data = get_qblog_post_data($page);
    if ($vars['cmd'] == 'edit') {
        //新規ページ
        if (!$data) {
            $data['title'] = $page;
            $data['category'] = $qblog_default_cat;
        }
        $data['title'] = isset($vars['title']) && $vars['title'] ? $vars['title'] : $data['title'];
        $data['category'] = isset($vars['category']) && $vars['category'] ? $vars['category'] : $data['category'];
        if (isset($vars['qblog_date'])) {
            $date = $vars['qblog_date'];
            list($y, $m, $d) = array_pad(explode('-', $vars['qblog_date']), 3, '');
            if (checkdate($m, $d, $y)) {
                $time = mktime(0, 0, 0, $m, $d, $y);
                $date = date($qblog_date_format, $time);
            }
        }
    }
    $category_url = $script . '?' . $qblog_defaultpage . '&mode=category&catname=' . rawurlencode($data['category']);
    $addpostlink_html = '';
    if (ss_admin_check()) {
        $editpostlink = $script . '?cmd=edit&page=' . $page;
        $addpostlink = $script . '?cmd=qblog&mode=addpost';
        $addpostlink_html = '
<a href="' . h($editpostlink) . '" class="badge badge-important" style="color:#fff"><i class="icon-white icon-edit" style="vertical-align:text-bottom"></i> この記事を編集</a>
<a href="' . h($addpostlink) . '" class="badge badge-info" style="color:#fff"><i class="icon-white icon-plus" style="vertical-align:text-bottom"></i> 記事の追加</a>
';
    }
    $head = '
<style type="text/css">
#content h2.title{display:none;}
</style>
' . $closed_msg . '
<div class="title">
<span class="qblog_post_date">' . h($date) . '</span>
' . $addpostlink_html . '
<a href="' . h($category_url) . '" class="qblog_category badge">カテゴリ:' . h($data['category']) . '</a>
</div>
<h2>' . h($data['title']) . '</h2>
';
    if (trim($data['image']) !== '') {
        if (is_file(SWFU_IMAGE_DIR . $data['image'])) {
            $data['image'] = SWFU_IMAGE_DIR . $data['image'];
        }
        $head .= <<<EOH
EOH;
    }
    return $head;
}