Ejemplo n.º 1
0
function is_freeze($page, $clearcache = FALSE)
{
    global $function_freeze;
    static $is_freeze = array();
    if ($clearcache === TRUE) {
        $is_freeze = array();
    }
    if (isset($is_freeze[$page])) {
        return $is_freeze[$page];
    }
    if (!$function_freeze || !is_page($page)) {
        $is_freeze[$page] = FALSE;
        return FALSE;
    } else {
        $fp = fopen(get_filename($page), 'rb') or die('is_freeze(): fopen() failed: ' . htmlspecialchars($page));
        // flock($fp, LOCK_SH) or die('is_freeze(): flock() failed');
        @flock($fp, LOCK_SH);
        rewind($fp);
        $buffer = fgets($fp, 9);
        // flock($fp, LOCK_UN) or die('is_freeze(): flock() failed');
        @flock($fp, LOCK_UN);
        fclose($fp) or die('is_freeze(): fclose() failed: ' . htmlspecialchars($page));
        $is_freeze[$page] = $buffer != FALSE && rtrim($buffer, "\r\n") == '#freeze';
        return $is_freeze[$page];
    }
}
Ejemplo n.º 2
0
function plugin_ls_convert()
{
    global $vars;
    $with_title = FALSE;
    if (func_num_args()) {
        $args = func_get_args();
        $with_title = in_array('title', $args);
    }
    $prefix = $vars['page'] . '/';
    $page = isset($vars['page']) ? $vars['page'] : '';
    $pages = array();
    foreach (Auth::get_existpages() as $page) {
        if (strpos($page, $prefix) === 0) {
            $pages[] = $page;
        }
    }
    natcasesort($pages);
    $ls = array();
    foreach ($pages as $page) {
        $comment = '';
        if ($with_title) {
            $array = file_head(get_filename($page), 1);
            if ($array) {
                $comment = ' - ' . preg_replace(array('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/S', '/^(?:-+|\\*+)/'), array('$1$2', null), current($array));
            }
        }
        $ls[] = "-[[{$page}]] {$comment}";
    }
    return RendererFactory::factory($ls);
}
Ejemplo n.º 3
0
 /**
  * Check if the page timestamp is newer than the file timestamp
  *
  * PukiWiki API Extension
  *
  * @param string $page pagename
  * @param string $file filename
  * @param bool $ignore_notimestamp Ignore notimestamp edit and see the real time editted
  * @return boolean
  */
 function is_page_newer($page, $file, $ignore_notimestamp = TRUE)
 {
     $filestamp = file_exists($file) ? filemtime($file) : 0;
     if ($ignore_notimestamp) {
         // See the diff file. PukiWiki Trick.
         $pagestamp = is_page($page) ? filemtime(DIFF_DIR . encode($page) . '.txt') : 0;
     } else {
         $pagestamp = is_page($page) ? filemtime(get_filename($page)) : 0;
     }
     return $pagestamp > $filestamp;
 }
Ejemplo n.º 4
0
function is_page($page,$reload=FALSE)
{
	global $InterWikiName;
	static $is_page = array();
	
	if ($reload or !array_key_exists($page,$is_page))
	{
		$is_page[$page] = file_exists(get_filename($page));
	}
	
	return $is_page[$page];
}
Ejemplo n.º 5
0
function plugin_list_array($pages)
{
    $qm = get_qm();
    $symbol = ' ';
    $other = 'zz';
    $list = array();
    $cnd = 0;
    //並び替える
    foreach ($pages as $file => $page) {
        $pgdata = array();
        $pgdata['urlencoded'] = rawurlencode($page);
        $pgdata['sanitized'] = htmlspecialchars($page, ENT_QUOTES);
        $pgdata['passage'] = get_pg_passage($page, FALSE);
        $pgdata['mtime'] = date('Y年m月d日 H時i分s秒', filemtime(get_filename($page)));
        $pgdata['title'] = get_page_title($page);
        $pgdata['title'] = $pgdata['title'] == $pgdata['sanitized'] ? '' : '(' . $pgdata['title'] . ')';
        $pgdata['filename'] = htmlspecialchars($file);
        $head = preg_match('/^([A-Za-z])/', $page, $matches) ? $matches[1] : (preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other);
        $list[$head][$page] = $pgdata;
        $cnt++;
    }
    ksort($list);
    $tmparr = isset($list[$symbol]) ? $list[$symbol] : null;
    unset($list[$symbol]);
    $list[$symbol] = $tmparr;
    $retlist = array();
    foreach ($list as $head => $pages) {
        if (is_null($pages)) {
            continue;
        }
        ksort($pages);
        if ($head === $symbol) {
            $head = $qm->m['func']['list_symbol'];
        } else {
            if ($head === $other) {
                $head = $qm->m['func']['list_other'];
            }
        }
        $retlist[$head] = $pages;
    }
    return $retlist;
}
Ejemplo n.º 6
0
function get_function_files($dir)
{
    global $FUNCTIONS;
    if ($dh = @opendir($dir . "/functions")) {
        while (($file = readdir($dh)) !== FALSE) {
            if (ereg("\\.xml\$", $file)) {
                $FUNCTIONS[] = strtolower(str_replace(array(".xml", "-"), array("", "_"), $file));
            }
        }
        closedir($dh);
    } else {
        $dh = @opendir($dir . "/");
        if ($ch === FALSE) {
            die("Unable to find phpdoc XML files in {$dir} folder\n");
        }
        while (($file = readdir($dh)) !== FALSE) {
            if (!ereg("\\.xml\$", $file)) {
                continue;
            }
            $class = get_filename($file);
            if (!is_dir($dir . "/" . $class . "/")) {
                continue;
            }
            $cdh = @opendir($dir . "/" . $class . "/");
            if ($cdh === FALSE) {
                continue;
            }
            while (($method = readdir($cdh)) !== FALSE) {
                if (!ereg("\\.xml\$", $method)) {
                    continue;
                }
                $FUNCTIONS[] = strtolower($class . "::" . get_filename($method));
            }
        }
    }
}
Ejemplo n.º 7
0
<?php 
require "counter.php";
require_once "language.inc.php";
$LinkMenu["default"]["filename"] = "main.php";
$LinkMenu["default"]["title"] = get_string($WelcomeText);
$LinkMenu["default"]["datename"] = "xml/news.xml";
$LinkMenu["screenshots"]["filename"] = "screenshots.php";
$LinkMenu["screenshots"]["title"] = get_string($ScreenshotsText);
$LinkMenu["screenshots"]["datename"] = "xml/screenshots.xml";
$LinkMenu["downloads"]["filename"] = "downloads.php";
$LinkMenu["downloads"]["title"] = get_string($DownloadsText);
$LinkMenu["downloads"]["datename"] = "downloads.php";
$LinkMenu["faq"]["filename"] = "faq.php";
$LinkMenu["faq"]["title"] = get_string($FAQText);
$LinkMenu["faq"]["datename"] = get_filename("xml/faq.xml");
$LinkMenu["links"]["filename"] = "links.php";
$LinkMenu["links"]["title"] = get_string($LinksText);
$LinkMenu["links"]["datename"] = "links.php";
$LinkMenu["contact"]["filename"] = "contact.php";
$LinkMenu["contact"]["title"] = get_string($ContactText);
$LinkMenu["contact"]["datename"] = "contact.php";
/*
  $LinkMenu["gallery"]["filename"]="gallery.php";
  $LinkMenu["gallery"]["title"]=get_string($GalleryText);
  $LinkMenu["gallery"]["datename"]="gallery.php";

  $LinkMenu["gallery_add_user"]["filename"]="gallery_add_user.php";
  $LinkMenu["gallery_add_user"]["title"]=get_string($GalleryText);
  $LinkMenu["gallery_add_user"]["datename"]="gallery.php";
*/
Ejemplo n.º 8
0
function plugin_ajaxtree_write_after()
{
    global $vars;
    plugin_ajaxtree_init();
    if ($vars['plugin'] == 'rename') {
        plugin_ajaxtree_reset_cache();
        return;
    }
    $current = $vars['page'];
    if (PLUGIN_AJAXTREE_CHECK_MTIME) {
        $file = get_filename($current);
        if (filemtime($file) > filemtime(DATA_DIR)) {
            return;
        }
    }
    if (PLUGIN_AJAXTREE_COUNT_DESCENDANTS) {
        $ancestors = plugin_ajaxtree_get_ancestors($current);
        $ancestors[] = '/';
    } else {
        $pos = strrpos($current, '/');
        $parent = $pos ? substr($current, 0, $pos) : '/';
        if (PLUGIN_AJAXTREE_HIDE_TOPLEVEL_LEAVES && strpos($parent, '/') === false) {
            $ancestors = array($parent, '/');
        } else {
            $ancestors = array($parent);
        }
    }
    foreach ($ancestors as $ancestor) {
        plugin_ajaxtree_update_cache($ancestor);
    }
}
Ejemplo n.º 9
0
function plugin_convert_haik_set_meta()
{
    $pages = get_existpages();
    foreach ($pages as $page) {
        $data = array();
        $title = '';
        $pagefile = get_filename($page);
        $metafile = 'haik-contents/meta/' . encode($page) . '.php';
        include $metafile;
        foreach ($meta as $key => $val) {
            switch ($key) {
                case 'title':
                    $title = 'TITLE:' . $val;
                    break;
                case 'description':
                case 'keywords':
                    $data[$key] = '#' . $key . '(' . $val . ')';
                    break;
                case 'user_head':
                    $data[$key] = "#beforescript{{\n{$val}\n}}\n";
                    break;
            }
        }
        switch ($meta['close']) {
            case 'closed':
                $data[$key] = "#close";
                break;
            case 'password':
                $data[$key] = "#secret({$meta['password']})";
                break;
            case 'redirect':
                $status = $meta['redirect_status'] == '301' ? ',301' : '';
                $data[$key] = "#redirect({$meta['redirect']}{$status})";
                break;
        }
        array_unshift($data, $title);
        $src = join("\n", $data) . "\n\n";
        $src .= get_source($page, TRUE, TRUE);
        file_put_contents($pagefile, $src, LOCK_EX);
        plugin_convert_haik_write_log("[{$page}]ページ情報の移行をしました");
    }
    return true;
}
Ejemplo n.º 10
0
        $design->footer(1);
    }
}
#anzeigen
$design->header();
$tpl = new tpl('selfbp', 1);
$akl = '';
if (isset($_REQUEST['akl'])) {
    $akl = $_REQUEST['akl'];
}
#löschen
if (isset($_REQUEST['del'])) {
    $del = $_REQUEST['del'];
    $a = substr($del, 0, 1);
    $e = substr($del, 1);
    if ($e != 'neu') {
        unlink('include/contents/selfbp/self' . $a . '/' . $e);
    }
}
$text = get_text($akl);
$properties = get_properties($text);
if (!isset($properties['wysiwyg'])) {
    $properties['wysiwyg'] = 1;
}
$text = edit_text($text, false);
#$text = rteSafe($text);
$filename = get_filename($akl);
$akl = get_akl($akl);
$view = get_view($properties['view']);
$tpl->set_ar_out(array('akl' => $akl, 'text' => $text, 'filename' => $filename, 'exfilename' => $filename, 'wysiwyg' => $properties['wysiwyg'], 'title' => $properties['title'], 'hmenu' => $properties['hmenu'], 'view' => $view, 'viewoptions' => $properties['viewoptions'], 'wysiwyg_editor' => $properties['wysiwyg'] == 1 ? '<script type="text/javascript">buttonPath = "include/images/icons/editor/"; imageBrowse = "admin.php?selfbp-imagebrowser"; makeWhizzyWig("bbwy", "all");</script>' : ''), 0);
$design->footer();
Ejemplo n.º 11
0
function plugin_search2_do_search($word, $type = 'AND', $non_format = FALSE, $base = '')
{
    global $script, $whatsnew, $non_list, $search_non_list, $foot_explain;
    global $search_auth, $show_passage, $username, $vars;
    $qm = get_qm();
    $retval = array();
    $b_type = $type == 'AND';
    // AND:TRUE OR:FALSE
    mb_language('Japanese');
    $word = mb_convert_encoding($word, SOURCE_ENCODING, "UTF-8,EUC-JP,SJIS,ASCII,JIS");
    $word = mb_ereg_replace(" ", " ", $word);
    $keys = get_search_words(preg_split('/\\s+/', $word, -1, PREG_SPLIT_NO_EMPTY));
    foreach ($keys as $key => $value) {
        $keys[$key] = '/' . $value . '/S';
    }
    $pages = get_existpages();
    // Avoid
    if ($base != '') {
        $pages = preg_grep('/^' . preg_quote($base, '/') . '/S', $pages);
    }
    if (!$search_non_list) {
        $pages = array_diff($pages, preg_grep('/' . $non_list . '/S', $pages));
    }
    $pages = array_flip($pages);
    unset($pages[$whatsnew]);
    $count = count($pages);
    // Search for page contents
    global $ignore_plugin, $strip_plugin, $strip_plugin_inline;
    $titles = array();
    $head10s = array();
    // 一時的に認証を外す
    $user_name = null;
    if (isset($_SESSION['usr'])) {
        $user_name = $_SESSION['usr'];
        unset($_SESSION['usr']);
    }
    foreach (array_keys($pages) as $page) {
        $vars['page'] = $page;
        $b_match = FALSE;
        // Search auth for page contents
        if (!check_readable($page, false, false, TRUE)) {
            unset($pages[$page]);
            continue;
        }
        $lines = get_source($page, TRUE, FALSE);
        //--- 検索専用のデータの作成、更新 ---
        $srh_fname = CACHE_DIR . encode($page) . '_search.txt';
        if (!file_exists($srh_fname) || filemtime($srh_fname) < filemtime(get_filename($page))) {
            $p_title = $page;
            $p_heads = '';
            foreach ($lines as $k => $l) {
                if (preg_match($ignore_plugin, $l)) {
                    // 省く
                    $lines = array();
                    break;
                }
                if (preg_match($strip_plugin, $l, $ms)) {
                    // 省く
                    unset($lines[$k]);
                }
                if (preg_match('/^TITLE:(.*)/', $l, $ms)) {
                    $p_title = trim($ms[1]);
                    if ($p_title !== $page) {
                        $p_title = $p_title . ' ' . $page;
                    }
                    unset($lines[$k]);
                }
                if (preg_match('/^(?:!|(\\*){1,3})(.*)\\[#\\w+\\]\\s?/', $l, $ms)) {
                    $p_heads .= trim($ms[2]) . ' ';
                    unset($lines[$k]);
                }
            }
            $lines = preg_replace($strip_plugin_inline, '', $lines);
            // 省く
            $html = convert_html($lines);
            $html = preg_replace('/<(script|style)[^>]*>.*?<\\/\\1>/i', '', $html);
            $html = preg_replace('/<img\\b[^>]*alt="(.*?)"[^>]*>/i', '\\1', $html);
            $p_body = trim(strip_tags($html));
            foreach ($foot_explain as $id => $note) {
                $p_body .= "\n" . strip_tags($note);
            }
            $foot_explain = array();
            $p_body = count($lines) > 0 ? $p_title . "\n" . $p_heads . "\n" . $p_body : '';
            file_put_contents($srh_fname, $p_body);
        } else {
            $fp = fopen($srh_fname, "r");
            flock($fp, LOCK_SH);
            $lines = file($srh_fname);
            flock($fp, LOCK_UN);
            fclose($fp);
            $p_title = trim($lines[0]);
            unset($lines[0]);
            $p_heads = trim($lines[1]);
            unset($lines[1]);
            $p_body = implode('', $lines);
        }
        //////////////////////////////////////////////
        //
        //  検索スタート!
        //
        ///////////////////////////////////////////////
        $match_title = 0;
        $match_heads = 0;
        $match_body = 0;
        //--- ページタイトル検索 ---
        $point = 0;
        $ok = false;
        if (!$non_format) {
            foreach ($keys as $key) {
                $b_match = preg_match($key, $p_title);
                if (!$b_match) {
                    $ok = false;
                    break;
                } else {
                    $ok = true;
                    $point += 15;
                }
            }
            if ($ok) {
                $match_title = $point;
            }
        }
        //--- ヘッダー検索 ---
        $point = 0;
        $ok = false;
        foreach ($keys as $key) {
            $b_match = preg_match_all($key, $p_title, $ms);
            if (!$b_match) {
                $ok = false;
                break;
            } else {
                $ok = true;
                $point += 10;
            }
        }
        if ($ok) {
            $match_heads = $point;
        }
        //--- コンテンツ検索 ---
        foreach ($keys as $key) {
            $b_match = preg_match_all($key, $p_body, $ms);
            if (!$b_match) {
                $ok = false;
                break;
            } else {
                $ok = true;
                $point += count($ms[0]);
            }
        }
        if ($ok) {
            $match_body = $point;
        }
        //検索結果
        $total = $match_title + $match_heads + $match_body;
        if ($total == 0) {
            unset($pages[$page]);
            // Miss
        } else {
            $pages[$page] = $total;
            $titles[$page] = $p_title;
            $head10s[$page] = mb_substr($p_body, 0, 60 * 3);
        }
    }
    if ($user_name !== null) {
        $_SESSION['usr'] = $user_name;
    }
    $vars['page'] = '';
    //注釈の削除
    $foot_explain = array();
    if ($non_format) {
        return array_keys($pages);
    }
    $r_word = rawurlencode($word);
    $s_word = h($word);
    if (empty($pages)) {
        return str_replace('$1', $s_word, '$1 を含むページは見つかりませんでした。');
    }
    arsort($pages);
    $retval = '<div class="container-fluid"><div class="list-group">' . "\n";
    foreach ($pages as $page => $v) {
        $title = $titles[$page];
        if ($title !== $page) {
            $rpos = strrpos($title, $page);
            if ($rpos !== FALSE) {
                $title = trim(substr($title, 0, $rpos));
            }
            $title = $title . ' - ' . $page;
        }
        $r_page = rawurlencode($page);
        $tmp_li = '  <div class="list-group-item" style="border-style:none;"><a class="list-group-item-heading" href="' . $script . '?cmd=read&amp;page=' . $r_page . '&amp;word=' . $r_word . '" style="font-weight:bold;">' . h($title) . '</a><p class="list-group-item-text text-muted" style="margin: 5px 0;">' . $head10s[$page] . '</p></div>' . "\n";
        $retval .= $tmp_li;
    }
    $retval .= '</div><p>' . "\n";
    $retval .= str_replace('$1', $s_word, str_replace('$2', count($pages), str_replace('$3', $count, $b_type ? '$1 のすべてを含むページは <strong>$3</strong> ページ中、 <strong>$2</strong> ページ見つかりました。' : '$1 のいずれかを含むページは <strong>$3</strong> ページ中、 <strong>$2</strong> ページ見つかりました。')));
    $retval .= '</p></div>';
    return $retval;
}
Ejemplo n.º 12
0
<?php

include_once $_SERVER['DOCUMENT_ROOT'] . "/common/lib/common.php";
$db = new DbMySqli();
$name = addslashes($_POST['name']);
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
//첨부파일 업로드
if (is_uploaded_file($_FILES["filename"]["tmp_name"])) {
    $filename = $_FILES["filename"]["name"];
    $filesize = $_FILES["filename"]["size"];
    $origin_filename = $filename;
    $ext = strtolower(get_ext($filename));
    new_check_ext($ext);
    //금지파일 체크
    $filename = get_filename($filepath1, $ext);
    move_uploaded_file($_FILES["filename"]["tmp_name"], get_real_filepath($filepath1) . "/" . $filename);
} else {
    $filesize = 0;
}
$userip = $_SERVER['REMOTE_ADDR'];
$sql = "select ifnull(max(idx), 0) + 1 from tbl_qna";
$result = $db->query($sql);
$rows = mysqli_fetch_row($result);
$f_idx = $rows[0];
$table = "tbl_qna";
$idx_field = "idx";
$db['f_idx'] = $f_idx;
$db['thread'] = "a";
$db['name'] = $name;
$db['title'] = $title;
Ejemplo n.º 13
0
    }
    mysql_free_result($result);
    return $since_dt;
}
function create_from_obj($param, $fromid)
{
    $graph_url = 'https://graph.facebook.com/fql?access_token=' . $param->token . '&q=' . urlencode('select first_name, last_name from user where uid=') . $fromid;
    $fb = get_graphapi_data($graph_url);
    $user = $fb->data;
    $from = new stdclass();
    $from->name = $user[0]->first_name . ' ' . $user[0]->last_name;
    $from->id = $fromid;
    return $from;
}
/////////////////////////////////////////////////////////////////////////////////////////////
$updater_file = get_filename($_SERVER["PHP_SELF"]);
$fbid = empty($argv[1]) ? $_GET['fbid'] : $argv[1];
$token = empty($argv[2]) ? $_GET['token'] : $argv[2];
//$fbid = '1216568374';
//$token = 'CAAEtGOhTURQBAMSC2vYBAvOwjdR5nZCeOI1w3V6pMpwA6YeUBXE7Keli9vsd0eqz0r82IZA76o4a7xaOqTumI3rVCSKCJVyHLkQNiIZC5mAwSrP2cx5ceOIiZAUhyogfHzrTTYWZBbuZBccjk8ZC1F566lo5bG91jpKD0PMcIa1tyC2MNQYQsfJs5aDgZABZAO64ZD';
if (empty($fbid) or empty($token)) {
    logme('no fbid or token in cookie');
    die('no fbid or token in cookie');
}
$graph_url = "https://graph.facebook.com/{$fbid}/";
$execution_time['totalstart'] = get_time();
$execution_time['start'] = get_time();
$param->fbid = $fbid;
$param->token = $token;
$param->graph_url = $graph_url;
$param->limit = 25;
Ejemplo n.º 14
0
function plugin_pcomment_insert()
{
    global $vars, $now, $_title_updated, $_no_name, $_pcmt_messages;
    $refer = isset($vars['refer']) ? $vars['refer'] : '';
    $page = isset($vars['page']) ? $vars['page'] : '';
    $page = get_fullname($page, $refer);
    if (!is_pagename($page)) {
        return array('msg' => 'Invalid page name', 'body' => 'Cannot add comment', 'collided' => TRUE);
    }
    check_editable($page, true, true);
    $ret = array('msg' => $_title_updated, 'collided' => FALSE);
    $msg = str_replace('$msg', rtrim($vars['msg']), PLUGIN_PCOMMENT_FORMAT_MSG);
    $name = !isset($vars['name']) || $vars['name'] == '' ? $_no_name : $vars['name'];
    $name = $name == '' ? '' : str_replace('$name', $name, PLUGIN_PCOMMENT_FORMAT_NAME);
    $date = !isset($vars['nodate']) || $vars['nodate'] != '1' ? str_replace('$now', $now, PLUGIN_PCOMMENT_FORMAT_NOW) : '';
    if ($date != '' || $name != '') {
        $msg = str_replace("" . 'MSG' . "", $msg, PLUGIN_PCOMMENT_FORMAT_STRING);
        $msg = str_replace("" . 'NAME' . "", $name, $msg);
        $msg = str_replace("" . 'DATE' . "", $date, $msg);
    }
    $reply_hash = isset($vars['reply']) ? $vars['reply'] : '';
    if ($reply_hash || !is_page($page)) {
        $msg = preg_replace('/^\\-+/', '', $msg);
    }
    $msg = rtrim($msg);
    if (!is_page($page)) {
        $postdata = '[[' . htmlsc(strip_bracket($refer)) . ']]' . "\n\n" . '-' . $msg . "\n";
    } else {
        $postdata = get_source($page);
        $count = count($postdata);
        $digest = isset($vars['digest']) ? $vars['digest'] : '';
        if (md5(join('', $postdata)) != $digest) {
            $ret['msg'] = $_pcmt_messages['title_collided'];
            $ret['body'] = $_pcmt_messages['msg_collided'];
        }
        $start_position = 0;
        while ($start_position < $count) {
            if (preg_match('/^\\-/', $postdata[$start_position])) {
                break;
            }
            ++$start_position;
        }
        $end_position = $start_position;
        $dir = isset($vars['dir']) ? $vars['dir'] : '';
        // Find the comment to reply
        $level = 1;
        $b_reply = FALSE;
        if ($reply_hash != '') {
            while ($end_position < $count) {
                $matches = array();
                if (preg_match('/^(\\-{1,2})(?!\\-)(.*)$/', $postdata[$end_position++], $matches) && md5($matches[2]) == $reply_hash) {
                    $b_reply = TRUE;
                    $level = strlen($matches[1]) + 1;
                    while ($end_position < $count) {
                        if (preg_match('/^(\\-{1,3})(?!\\-)/', $postdata[$end_position], $matches) && strlen($matches[1]) < $level) {
                            break;
                        }
                        ++$end_position;
                    }
                    break;
                }
            }
        }
        if ($b_reply == FALSE) {
            $end_position = $dir == '0' ? $start_position : $count;
        }
        // Insert new comment
        array_splice($postdata, $end_position, 0, str_repeat('-', $level) . $msg . "\n");
        if (PLUGIN_PCOMMENT_AUTO_LOG) {
            $_count = isset($vars['count']) ? $vars['count'] : '';
            plugin_pcomment_auto_log($page, $dir, $_count, $postdata);
        }
        $postdata = join('', $postdata);
    }
    page_write($page, $postdata, PLUGIN_PCOMMENT_TIMESTAMP);
    if (PLUGIN_PCOMMENT_TIMESTAMP) {
        if ($refer != '') {
            pkwk_touch_file(get_filename($refer));
        }
        put_lastmodified();
    }
    return $ret;
}
Ejemplo n.º 15
0
function plugin_dav_action()
{
    global $scriptname, $zslash, $log_ua;
    if (!exist_plugin('attach')) {
        plugin_dav_error_exit(500, 'attach plugin not found.');
    }
    $scriptname = SCRIPT_NAME;
    // 区切り文字の全角
    $zslash = mb_convert_kana('/', 'A', SOURCE_ENCODING);
    header('Expires: Sat,  1 Jan 2000 00:00:00 GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', false);
    header('Pragma: no-cache');
    $req_headers = apache_request_headers();
    $path_info = empty($_SERVER['PATH_INFO']) ? '' : $_SERVER['PATH_INFO'];
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'OPTIONS':
            header('DAV: 1');
            // OPTIONS,PROPFIND,GET,HEAD,PUT,DELETE,MOVE,COPY
            header('Allow: OPTIONS,PROPFIND,GET,PUT,MOVE,COPY');
            header('MS-Author-Via: DAV');
            break;
        case 'PROPFIND':
            // 添付する際にパスワードまたは、管理者のみの場合は、認証を要求
            if (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) {
                // PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'admin password' : 'password';
                if (!isset($req_headers['Authorization'])) {
                    plugin_dav_error_exit(401);
                }
                //$user = auth::check_auth_pw(); // 認証済かのチェック
                //if (empty($user)) plugin_dav_error_exit(401); // 未認証なら認証を要求
            }
            if (empty($path_info)) {
                plugin_dav_error_exit(301, NULL, plugin_dav_myurl1() . '/');
            }
            $tree = plugin_dav_maketree($path_info);
            if (!isset($tree)) {
                plugin_dav_error_exit(404);
            }
            $ret = plugin_dav_makemultistat($tree, $_SERVER['REQUEST_URI'], $req_headers['Depth']);
            if (!isset($ret)) {
                plugin_dav_error_exit(301, NULL, plugin_dav_myurl() . '/');
            }
            header('HTTP/1.1 207 Multi-Status');
            header('Content-Type: text/xml');
            echo $ret->saveXML();
            exit;
        case 'GET':
        case 'HEAD':
            // 通常のファイル参照時は、このメソッドでアクセスされる
            $obj =& plugin_dav_getfileobj($path_info);
            if ($obj != NULL && $obj->exist) {
                $obj->open();
            } else {
                if ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($path_info) && strpos($log_ua, 'MSIE') > 0) {
                    plugin_dav_officious_message();
                    exit;
                } else {
                    plugin_dav_error_exit(404);
                }
            }
            break;
        case 'PUT':
            $pass = NULL;
            if (auth::check_role('readonly')) {
                plugin_dav_error_exit(403, 'PKWK_READONLY prohibits editing');
            }
            // 添付する際にパスワードまたは、管理者のみの場合は、認証を要求
            if (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) {
                if (isset($req_headers['Authorization'])) {
                    $pass = plugin_dav_getbasicpass($req_headers['Authorization']);
                }
                //  else
                // PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'admin password' : 'password';
                //    plugin_dav_error_exit(401);
            }
            if (PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY && $pass !== TRUE && ($pass === NULL || !pkwk_login($pass))) {
                plugin_dav_error_exit(401);
            }
            // 'admin only.'
            $obj =& plugin_dav_getfileobj($path_info, false);
            if (!isset($obj)) {
                plugin_dav_error_exit(403, 'no page');
            }
            if ($obj->exist) {
                unlink($tmpfilename);
                plugin_dav_error_exit(403, 'already exist.');
            }
            $size = intval($req_headers['Content-Length']);
            // Windows 7のクライアントは、まず0バイト書いて、
            // それをLOCKしてから、上書きしにくる。
            // しかし、Pukiwikiは基本上書き禁止。
            // そこで0バイトの時は無視する。
            if ($size > 0) {
                if ($size > PLUGIN_ATTACH_MAX_FILESIZE) {
                    plugin_dav_error_exit(403, 'file size error');
                }
                $tmpfilename = tempnam('/tmp', 'dav');
                $fp = fopen($tmpfilename, 'wb');
                $size = 0;
                $putdata = fopen('php://input', 'rb');
                while ($data = fread($putdata, 1024)) {
                    $size += strlen($data);
                    fwrite($fp, $data);
                }
                fclose($putdata);
                fclose($fp);
                if (copy($tmpfilename, $obj->filename)) {
                    chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE);
                }
                if (is_page($obj->page)) {
                    touch(get_filename($obj->page));
                }
                $obj->getstatus();
                $obj->status['pass'] = $pass !== TRUE && $pass !== NULL ? md5($pass) : '';
                $obj->putstatus();
                unlink($tmpfilename);
            }
            break;
        case 'DELETE':
            // FIXME
            // フォルダーは消せないくせに、消せたように処理してしまう。
            //
            $pass = NULL;
            if (auth::check_role('readonly')) {
                plugin_dav_error_exit(403, 'PKWK_READONLY prohibits editing');
            }
            // 添付する際にパスワードまたは、管理者のみの場合は、認証を要求
            if (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) {
                if (isset($req_headers['Authorization'])) {
                    $pass = plugin_dav_getbasicpass($req_headers['Authorization']);
                }
                //  else
                // PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'admin password' : 'password';
                //    plugin_dav_error_exit(401);
            }
            if (PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY && $pass !== TRUE && ($pass === NULL || !pkwk_login($pass))) {
                plugin_dav_error_exit(401);
            }
            // 'admin only.'
            $obj =& plugin_dav_getfileobj($path_info, false);
            if (!isset($obj)) {
                plugin_dav_error_exit(403);
            }
            if ($obj->getstatus() == FALSE) {
                plugin_dav_error_exit(404);
            }
            $obj->delete($pass);
            if (file_exists($obj->filename)) {
                plugin_dav_error_exit(406, "can't delete this file");
            }
            break;
        case 'MOVE':
        case 'COPY':
            // 添付ファイルのコピーと移動のみ
            // 同じページ内での添付ファイルの移動もわざわざ消して書いている
            // ページのコピーや移動は未実装
            $pass = NULL;
            if (auth::check_role('readonly')) {
                plugin_dav_error_exit(403, 'PKWK_READONLY prohibits editing');
            }
            // 添付する際にパスワードまたは、管理者のみの場合は、認証を要求
            if (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) {
                if (isset($req_headers['Authorization'])) {
                    $pass = plugin_dav_getbasicpass($req_headers['Authorization']);
                }
                //  else
                // PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'admin password' : 'password';
                //    plugin_dav_error_exit(401);
            }
            if (PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY && $pass !== TRUE && ($pass === NULL || !pkwk_login($pass))) {
                plugin_dav_error_exit(401);
            }
            // 'admin only.'
            // FROM (PATH_INFO)
            if ($_SERVER['REQUEST_METHOD'] == 'MOVE') {
                $obj1 =& plugin_dav_getfileobj($path_info, false);
            } else {
                $obj1 =& plugin_dav_getfileobj($path_info, true);
                // readonly
            }
            if (!isset($obj1)) {
                plugin_dav_error_exit(403, 'no src page.');
            }
            if ($obj1->getstatus() == FALSE) {
                plugin_dav_error_exit(404);
            }
            // TO (Destination)
            $destname = $req_headers['Destination'];
            if (strpos($destname, plugin_dav_myurl0()) === 0) {
                $destname = substr($destname, strlen(plugin_dav_myurl0()));
            }
            if (strpos($destname, $scriptname) === 0) {
                $destname = urldecode(substr($destname, strlen($scriptname)));
            } else {
                plugin_dav_error_exit(403, 'not dav directory.');
            }
            $obj2 =& plugin_dav_getfileobj($destname, false);
            if (!isset($obj2)) {
                plugin_dav_error_exit(403, 'no dst page.');
            }
            if ($obj2->exist) {
                plugin_dav_error_exit(403, 'already exist');
            }
            if (copy($obj1->filename, $obj2->filename)) {
                chmod($obj2->filename, PLUGIN_ATTACH_FILE_MODE);
            } else {
                plugin_dav_error_exit(406, "can't copy it");
            }
            // COPY
            if (is_page($obj2->page)) {
                touch(get_filename($obj2->page));
            }
            $obj2->getstatus();
            $obj2->status['pass'] = $pass !== TRUE && $pass !== NULL ? md5($pass) : '';
            $obj2->putstatus();
            // MOVE(DELETE)
            if ($_SERVER['REQUEST_METHOD'] == 'MOVE') {
                $obj1->delete($pass);
                if (file_exists($obj1->filename)) {
                    plugin_dav_error_exit(406, "can't delete this file");
                }
            }
            break;
            /*
            case 'MKCOL':
            	// ページは作成可能
            	// セキュリティは未検証
            	// Windowsクライアントを考えると、
            	// ページのリネームを考えないと無意味
            
            	if (auth::check_role('readonly')) plugin_dav_error_exit(403, 'PKWK_READONLY prohibits editing');
            
            	// 添付する際にパスワードまたは、管理者のみの場合は、認証を要求
            	if (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) {
            		if(isset($req_headers['Authorization']))
            			$pass = plugin_dav_getbasicpass($req_headers['Authorization']);
            		//  else
            		// PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'admin password' : 'password';
            		//    plugin_dav_error_exit(401);
            	}
            	$path = $path_info;
            	if(!isset($path)) plugin_dav_error_exit(403);
            	// $path = mb_convert_encoding($path, SOURCE_ENCODING, 'UTF-8');
            
            	if(preg_match('/^\/(.+)\/$/', $path, $matches) != 1)
            		plugin_dav_error_exit(403);
            
            	$page = str_replace($zslash, '/', $matches[1]);
            	if(is_page($page)) plugin_dav_error_exit(403);
            
            	// ここの辺りにもう一つチェックが必要かも
            	page_write($page, "dav.php"); // write initial string to the page.
            	break;
            */
        /*
        case 'MKCOL':
        	// ページは作成可能
        	// セキュリティは未検証
        	// Windowsクライアントを考えると、
        	// ページのリネームを考えないと無意味
        
        	if (auth::check_role('readonly')) plugin_dav_error_exit(403, 'PKWK_READONLY prohibits editing');
        
        	// 添付する際にパスワードまたは、管理者のみの場合は、認証を要求
        	if (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) {
        		if(isset($req_headers['Authorization']))
        			$pass = plugin_dav_getbasicpass($req_headers['Authorization']);
        		//  else
        		// PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'admin password' : 'password';
        		//    plugin_dav_error_exit(401);
        	}
        	$path = $path_info;
        	if(!isset($path)) plugin_dav_error_exit(403);
        	// $path = mb_convert_encoding($path, SOURCE_ENCODING, 'UTF-8');
        
        	if(preg_match('/^\/(.+)\/$/', $path, $matches) != 1)
        		plugin_dav_error_exit(403);
        
        	$page = str_replace($zslash, '/', $matches[1]);
        	if(is_page($page)) plugin_dav_error_exit(403);
        
        	// ここの辺りにもう一つチェックが必要かも
        	page_write($page, "dav.php"); // write initial string to the page.
        	break;
        */
        case 'PROPPATCH':
            // ダミールーチン: Windows 7のクライアントは、PROPPATCHが
            //                   失敗するとファイルを消しに来るため仕方なく。
            //
            header('HTTP/1.1 207 Multi-Status');
            header('Content-Type: text/xml');
            $doc = plugin_dav_proppatch_dummy_response($_SERVER['REQUEST_URI']);
            echo $doc->saveXML();
            exit;
        case 'MKCOL':
        case 'LOCK':
        case 'UNLOCK':
        case 'POST':
            plugin_dav_error_exit(501);
            // Method not Implemented
            break;
        default:
            plugin_dav_error_exit(405);
            // Method not Allowed
    }
}
Ejemplo n.º 16
0
 /**
  * Check if the page timestamp is newer than the file timestamp
  *
  * PukiWiki API Extension
  *
  * @access public
  * @static
  * @param string $page pagename
  * @param string $file filename
  * @param bool $ignore_notimestamp see true editted time
  * @return boolean
  * @version $Id: v 1.1 2008-07-16 11:14:46 sonots $
  */
 function is_page_newer($page, $file, $ignore_notimestamp = false)
 {
     $filestamp = file_exists($file) ? filemtime($file) : 0;
     $pagestamp = 0;
     if ($ignore_notimestamp) {
         // See the diff file. PukiWiki Trick.
         $difffile = DIFF_DIR . encode($page) . '.txt';
         if (file_exists($difffile)) {
             $pagestamp = filemtime($difffile);
         }
     }
     if ($pagestamp === 0) {
         if (is_page($page)) {
             $pagestamp = filemtime(get_filename($page));
         }
     }
     return $pagestamp > $filestamp;
 }
Ejemplo n.º 17
0
function show_attachment_link($attachment)
{
    $name = get_filename($attachment->name);
    $name = htmlentities($name);
    $path = htmlentities($attachment->path);
    echo "<a href=\"{$path}\" target=\"_blank\" class=\"attachment\">{$name}</a>\n";
}
Ejemplo n.º 18
0
if ($temp) {
    if ($die) {
        $die .= "\n";
    }
    // A breath
    $die .= 'Define(s) not found: (Maybe the old *.ini.php?)' . "\n" . $temp;
}
if ($die) {
    die_message(nl2br("\n\n" . $die));
}
unset($die, $temp);
/////////////////////////////////////////////////
// 必須のページが存在しなければ、空のファイルを作成する
foreach (array($defaultpage, $whatsnew, $interwiki) as $page) {
    if (!is_page($page)) {
        touch(get_filename($page));
    }
}
/////////////////////////////////////////////////
// 外部からくる変数のチェック
// Prohibit $_GET attack
foreach (array('msg', 'pass') as $key) {
    if (isset($_GET[$key])) {
        die_message('Sorry, already reserved: ' . $key . '=');
    }
}
// Expire risk
unset($HTTP_GET_VARS, $HTTP_POST_VARS);
//, 'SERVER', 'ENV', 'SESSION', ...
unset($_REQUEST);
// Considered harmful
Ejemplo n.º 19
0
function put_lastmodified()
{
    global $maxshow, $whatsnew, $autolink, $autobasealias;
    // if (PKWK_READONLY) return; // Do nothing
    if (auth::check_role('readonly')) {
        return;
    }
    // Do nothing
    // Get WHOLE page list
    $pages = get_existpages();
    // Check ALL filetime
    $recent_pages = array();
    foreach ($pages as $page) {
        if ($page != $whatsnew && !check_non_list($page)) {
            $recent_pages[$page] = get_filetime($page);
        }
    }
    // Sort decending order of last-modification date
    arsort($recent_pages, SORT_NUMERIC);
    // Cut unused lines
    // BugTrack2/179: array_splice() will break integer keys in hashtable
    $count = $maxshow + PKWK_MAXSHOW_ALLOWANCE;
    $_recent = array();
    foreach ($recent_pages as $key => $value) {
        unset($recent_pages[$key]);
        $_recent[$key] = $value;
        if (--$count < 1) {
            break;
        }
    }
    $recent_pages =& $_recent;
    // Re-create PKWK_MAXSHOW_CACHE
    $file = CACHE_DIR . PKWK_MAXSHOW_CACHE;
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message('Cannot open' . 'CACHE_DIR/' . PKWK_MAXSHOW_CACHE);
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    $last = ignore_user_abort(1);
    ftruncate($fp, 0);
    rewind($fp);
    foreach ($recent_pages as $page => $time) {
        fputs($fp, $time . "\t" . $page . "\n");
    }
    ignore_user_abort($last);
    @flock($fp, LOCK_UN);
    @fclose($fp);
    // Create RecentChanges
    $file = get_filename($whatsnew);
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message('Cannot open ' . htmlspecialchars($whatsnew));
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    $last = ignore_user_abort(1);
    ftruncate($fp, 0);
    rewind($fp);
    foreach (array_keys($recent_pages) as $page) {
        $time = $recent_pages[$page];
        // $s_lastmod = htmlspecialchars(format_date($time));
        $s_lastmod = '&epoch(' . $time . ');';
        $s_page = htmlspecialchars($page);
        fputs($fp, '-' . $s_lastmod . ' - [[' . $s_page . ']]' . "\n");
    }
    fputs($fp, '#norelated' . "\n");
    // :)
    ignore_user_abort($last);
    @flock($fp, LOCK_UN);
    @fclose($fp);
    // For AutoLink
    if ($autolink) {
        autolink_pattern_write(CACHE_DIR . PKWK_AUTOLINK_REGEX_CACHE, get_autolink_pattern($pages, $autolink));
    }
    // AutoBaseAlias
    if ($autobasealias) {
        autobasealias_write(CACHE_DIR . PKWK_AUTOBASEALIAS_CACHE, $pages);
    }
}
Ejemplo n.º 20
0
 function delete($pass)
 {
     global $_attach_messages, $notify, $notify_subject;
     if ($this->status['freeze']) {
         return attach_info('msg_isfreeze');
     }
     if (!pkwk_login($pass)) {
         if (PLUGIN_ATTACH_DELETE_ADMIN_ONLY || $this->age) {
             return attach_info('err_adminpass');
         } else {
             if (PLUGIN_ATTACH_PASSWORD_REQUIRE && md5($pass) != $this->status['pass']) {
                 return attach_info('err_password');
             }
         }
     }
     // バックアップ
     if ($this->age || PLUGIN_ATTACH_DELETE_ADMIN_ONLY && PLUGIN_ATTACH_DELETE_ADMIN_NOBACKUP) {
         @unlink($this->filename);
     } else {
         do {
             $age = ++$this->status['age'];
         } while (file_exists($this->basename . '.' . $age));
         if (!rename($this->basename, $this->basename . '.' . $age)) {
             // 削除失敗 why?
             return array('msg' => $_attach_messages['err_delete']);
         }
         $this->status['count'][$age] = $this->status['count'][0];
         $this->status['count'][0] = 0;
         $this->putstatus();
     }
     if (is_page($this->page)) {
         touch(get_filename($this->page));
     }
     if ($notify) {
         $footer['ACTION'] = 'File deleted';
         $footer['FILENAME'] =& $this->file;
         $footer['PAGE'] =& $this->page;
         $footer['URI'] = get_script_uri() . '?' . rawurlencode($this->page);
         $footer['USER_AGENT'] = TRUE;
         $footer['REMOTE_ADDR'] = TRUE;
         pkwk_mail_notify($notify_subject, "\n", $footer) or die('pkwk_mail_notify(): Failed');
     }
     return array('msg' => $_attach_messages['msg_deleted']);
 }
Ejemplo n.º 21
0
function plugin_ls2_1_timecmp($a, $b)
{
    $atime = filemtime(get_filename($a));
    $btime = filemtime(get_filename($b));
    if ($atime == $btime) {
        return 0;
    }
    return $atime < $btime ? 1 : -1;
}
Ejemplo n.º 22
0
function discover_font($default, $passed)
{
    $passed_fn = strtolower(get_filename($passed));
    $ret = $default;
    $fdir = str_replace('\\', '/', getcwd() . '/' . FONTS_DIR);
    $d = dir($fdir);
    while (false !== ($entry = $d->read())) {
        if ($passed_fn == strtolower(get_filename($entry))) {
            $ret = $entry;
        }
    }
    $d->close();
    $rp = realpath($fdir . '/' . $ret);
    return !$rp || false === strpos(str_replace('\\', '/', $rp), $fdir) ? $default : $ret;
}
Ejemplo n.º 23
0
/**
 * Adds Current Class to Navigation 
 *
 * add to page navigation like this: class="<?php currentnav(); ?>"
 *
 * @uses get_filename
 * @param string $currentpage
 * @return string
 */
function currentnav($currentpage)
{
    if (get_filename() == 'index.php' && $currentpage == 'home') {
        echo ' current ';
    } else {
        if (strstr($_SERVER['REQUEST_URI'], $currentpage)) {
            echo ' current ';
        }
    }
}
Ejemplo n.º 24
0
function showcert()
{
    global $user, $globals, $l, $theme, $softpanel, $error, $done, $key_list;
    echo '<table border="0" cellpadding="8" cellspacing="0" width="100%" class="sai_altrowstable">	
	<tr>
		<th align="center" width="70%">' . $l['cert_file'] . '</th>
		<th align="center"  >' . $l['option'] . '</th>
	</tr>
	<tr>';
    // Getting cert files
    $key_list = $softpanel->keyfiles();
    // Why required again ?
    $i = 1;
    foreach ($key_list as $key => $value) {
        $ext = get_extension($value);
        if ($ext == 'key') {
            $file = get_filename($value);
            echo '<tr class="' . ($i % 2 == 0 ? "sai_evenrowcolor" : "sai_oddrowcolor") . '" >
					<td>
						<span id="name' . $key . '">' . $file . '</span>							
					</td>
					<td>
					 	<img title="Delete" class="delete" id="did' . $key . '" src="' . $theme['images'] . 'remove.gif" style="cursor:pointer" /> &nbsp;<img title="Show" class="edit" id="eid' . $file . '" src="' . $theme['images'] . 'editdetail.gif" style="cursor:pointer"  /> 
					 </td>';
            $i++;
        }
    }
    echo '</tr>
	</table><br /></br>
	<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
	
		$(document).ready(function(){
			// For deleting record
			$(".delete").click(function() {
				message_box.delete_message ("Warning", "' . $l['record_del_conf'] . '", $(this).attr("id").substr(3));
			});
			
			// For creating DNS
			$(".edit").click(function(){
				var did = $(this).attr("id").substr(3);
				$.ajax({
					type: "POST",
					url: window.location+"&ajaxdetail=1&detail_record="+did,
					
					// Checking for error
					success: function(data){
						$("#detailrectab")
							.html(data)
							.slideDown("slide", "", 5000);
					},
					error: function() {
						message_box.show_message("Error", "' . $l['connect_error'] . '", 1);
					}
				});
													
			});
		});	
			
	// ]]></script>';
}
Ejemplo n.º 25
0
function plugin_tracker_action()
{
    global $post, $vars, $now;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $config_name = array_key_exists('_config', $post) ? $post['_config'] : '';
    $config = new Config('plugin/tracker/' . $config_name);
    if (!$config->read()) {
        return "<p>config file '" . htmlsc($config_name) . "' not found.</p>";
    }
    $config->config_name = $config_name;
    $source = $config->page . '/page';
    $refer = array_key_exists('_refer', $post) ? $post['_refer'] : $post['_base'];
    if (!is_pagename($refer)) {
        return array('msg' => 'cannot write', 'body' => 'page name (' . htmlsc($refer) . ') is not valid.');
    }
    if (!is_page($source)) {
        return array('msg' => 'cannot write', 'body' => 'page template (' . htmlsc($source) . ') is not exist.');
    }
    // ページ名を決定
    $base = $post['_base'];
    $num = 0;
    $name = array_key_exists('_name', $post) ? $post['_name'] : '';
    if (array_key_exists('_page', $post)) {
        $page = $real = $post['_page'];
    } else {
        $real = is_pagename($name) ? $name : ++$num;
        $page = get_fullname('./' . $real, $base);
    }
    if (!is_pagename($page)) {
        $page = $base;
    }
    while (is_page($page)) {
        $real = ++$num;
        $page = "{$base}/{$real}";
    }
    // ページデータを生成
    $postdata = plugin_tracker_get_source($source);
    // 規定のデータ
    $_post = array_merge($post, $_FILES);
    $_post['_date'] = $now;
    $_post['_page'] = $page;
    $_post['_name'] = $name;
    $_post['_real'] = $real;
    // $_post['_refer'] = $_post['refer'];
    $fields = plugin_tracker_get_fields($page, $refer, $config);
    // Creating an empty page, before attaching files
    touch(get_filename($page));
    foreach (array_keys($fields) as $key) {
        $value = array_key_exists($key, $_post) ? $fields[$key]->format_value($_post[$key]) : '';
        foreach (array_keys($postdata) as $num) {
            if (trim($postdata[$num]) == '') {
                continue;
            }
            $postdata[$num] = str_replace("[{$key}]", ($postdata[$num][0] == '|' or $postdata[$num][0] == ':') ? str_replace('|', '&#x7c;', $value) : $value, $postdata[$num]);
        }
    }
    // Writing page data, without touch
    page_write($page, join('', $postdata));
    $r_page = rawurlencode($page);
    pkwk_headers_sent();
    header('Location: ' . get_script_uri() . '?' . $r_page);
    exit;
}
Ejemplo n.º 26
0
function plugin_tracker_action()
{
    global $post, $vars, $now;
    //	if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (auth::check_role('readonly')) {
        die_message(_('PKWK_READONLY prohibits editing'));
    }
    if (auth::is_check_role(PKWK_CREATE_PAGE)) {
        die_message(_('PKWK_CREATE_PAGE prohibits editing'));
    }
    $base = isset($post['_base']) ? $post['_base'] : '';
    $refer = isset($post['_refer']) ? $post['_refer'] : '';
    $createProxy = isset($post['_createProxy']) ? $post['_createProxy'] : '';
    // $page name to add will be decided here
    $num = 0;
    $name = isset($post['_name']) ? $post['_name'] : '';
    if (isset($post['_page'])) {
        $real = $page = $post['_page'];
    } else {
        $real = is_pagename($name) ? $name : ++$num;
        $page = get_fullname('./' . $real, $base);
    }
    if (!is_pagename($page)) {
        $page = $base;
    }
    while (is_page($page)) {
        $real = ++$num;
        $page = $base . '/' . $real;
    }
    $config = isset($post['_config']) ? $post['_config'] : '';
    $createProxy = isset($post['_createProxy']) ? $post['_createProxy'] : '';
    // Petit SPAM Check (Client(Browser)-Server Ticket Check)
    $spam = FALSE;
    if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) {
        $s_tracker = md5(get_ticket() . $config_name);
        error_log("\$s_tracker: " . $s_tracker);
        error_log("\$_SESSION['tracker']: " . $_SESSION['tracker']);
        //		if ($_SESSION['tracker'] != $s_tracker) {
        //			$spam = TRUE;
        //		}
    } else {
        if (isset($post['encode_hint']) && $post['encode_hint'] != '') {
            if (PKWK_ENCODING_HINT != $post['encode_hint']) {
                $spam = TRUE;
            }
        } else {
            if (PKWK_ENCODING_HINT != '') {
                $spam = TRUE;
            }
        }
        if (is_spampost(array('body'), PLUGIN_TRACKER_REJECT_SPAMCOUNT)) {
            $spam = TRUE;
        }
    }
    if ($spam) {
        honeypot_write();
        return array('msg' => 'cannot write', 'body' => '<p>prohibits editing</p>');
    }
    // TODO: Why here
    // Default
    $_post = array_merge($post, $_FILES);
    $_post['_date'] = $now;
    $_post['_page'] = $page;
    $_post['_name'] = $name;
    $_post['_real'] = $real;
    // $_post['_refer'] = $_post['refer'];
    // TODO: Why here => See BugTrack/662
    // Creating an empty page, before attaching files
    pkwk_touch_file(get_filename($page));
    $from = $to = array();
    $tracker_form =& new Tracker_form();
    if (!$tracker_form->init($base, $refer, $config)) {
        return array('msg' => 'Cannot write', 'body' => htmlspecialchars($tracker_form->error));
    }
    // Load $template
    $template_page = $tracker_form->config->page . '/' . PLUGIN_TRACKER_DEFAULT_PAGE;
    $template = plugin_tracker_get_source($template_page);
    if ($template === FALSE || empty($template)) {
        return array('msg' => 'Cannot write', 'body' => 'Page template (' . htmlspecialchars($template_page) . ') not found');
    }
    if (!$tracker_form->initFields(plugin_tracker_field_pickup(implode('', $template)))) {
        return array('msg' => 'Cannot write', 'body' => htmlspecialchars($tracker_form->error));
    }
    $fields = $tracker_form->fields;
    unset($tracker_form);
    foreach (array_keys($fields) as $field) {
        $from[] = '[' . $field . ']';
        $to[] = isset($_post[$field]) ? $fields[$field]->format_value($_post[$field]) : '';
        unset($fields[$field]);
    }
    // Repalace every [$field]s (found inside $template) to real values
    $subject = $escape = array();
    foreach (array_keys($template) as $linenum) {
        if (trim($template[$linenum]) == '') {
            continue;
        }
        // Escape some TextFormattingRules
        $letter = $template[$linenum][0];
        if ($letter == '|' || $letter == ':') {
            $escape['|'][$linenum] = $template[$linenum];
        } else {
            if ($letter == ',') {
                $escape[','][$linenum] = $template[$linenum];
            } else {
                // TODO: Escape "\n" except multiline-allowed fields
                $subject[$linenum] = $template[$linenum];
            }
        }
    }
    foreach (str_replace($from, $to, $subject) as $linenum => $line) {
        $template[$linenum] = $line;
    }
    if ($escape) {
        // Escape for some TextFormattingRules
        foreach (array_keys($escape) as $hint) {
            $to_e = plugin_tracker_escape($to, $hint);
            foreach (str_replace($from, $to_e, $escape[$hint]) as $linenum => $line) {
                $template[$linenum] = $line;
            }
        }
        unset($to_e);
    }
    unset($from, $to);
    // Write $template, without touch
    page_write($page, join('', $template));
    // Create proxy page
    if ($createProxy && ($proxyPage = isset($_post[$createProxy]) ? $_post[$createProxy] : '')) {
        page_write($proxyPage, '#include(' . $page . ',notitle)');
    }
    pkwk_headers_sent();
    header('Location: ' . get_page_location_uri($page));
    exit;
}
Ejemplo n.º 27
0
                }
            }
        }
        $pass = $paths[$expected[chr(65 + $ku)][$kp + 1] - 1] . get_filename($ku, $kp);
        @unlink($pass);
        print_r($pass . ' => pass.png' . "\n");
        if ($create) {
            symlink(get_path_image($kp, 'pass.png'), $pass);
        }
    }
}
if ($create) {
    echo ' -->';
} else {
    die('Bye! <em>(or <a href="test_rewriterule.php">run the tests</a> again)</em>');
}
// display the matrix to see the status in one glance
echo '<table>';
foreach ($urls as $ku => $url) {
    echo '<tr>';
    foreach ($paths as $kp => $path) {
        $filename = get_filename($ku, $kp);
        echo '<td>';
        echo '<img src="' . $url . $filename . '" />';
        echo '</td>';
    }
    echo '</tr>';
}
echo '</table>';
// Allow one to clean up the file system
echo '<p>Are you done? Please <a href="test_rewriterule.php?clean=1">clean up</a> before leaving.</p>';
Ejemplo n.º 28
0
 function restore_time()
 {
     $this->cachefile = CACHE_DIR . "remakepage.dat";
     if (($lines = file($this->cachefile)) === FALSE) {
         return "<p><b>timestamp cache file, {$this->cachefile}, does not exist or not readable. </b></p>";
     }
     $oldpages = array();
     $failedpages = array();
     foreach ($lines as $line) {
         $line = rtrim($line);
         list($page, $time) = csv_explode(',', $line);
         $oldpages[] = $page;
         if (is_page($page) && pkwk_touch_file(get_filename($page), $time) === false) {
             $failedpages[] = $page;
         }
     }
     put_lastmodified();
     $body = '<p>';
     $body .= '<b>Restored timestamps.</b><br />';
     $nonexists = array_diff($oldpages, get_existpages());
     if (!empty($nonexists)) {
         $body .= "<b>Following pages do not exist in current wiki,</b><br />\n";
         $body .= implode("<br />\n", $nonexists) . "<br />";
     }
     if (!empty($failedpages)) {
         $body .= "<b>Failed to restore timestamp of </b><br />\n";
         $body .= implode("<br />\n", $failedpages) . "<br />";
         $body .= "<b>Skipped.</b><br />";
     }
     $body .= '</p>';
     return $body;
 }
Ejemplo n.º 29
0
<?php

require 'config.php';
function my_urlencode($string)
{
    return str_replace(' ', '%20', $string);
}
try {
    $ok = true;
    // Check if the URL is set
    if ($ok && isset($_GET["url"])) {
        // Get the URL and decode to remove any %20, etc
        $url = urldecode($_GET["url"]);
        // Hash the url
        $filename = get_filename($url);
    } else {
        // No URL set so error
        header('HTTP/1.0 400 Bad Request');
        echo "No URL was specified";
        $ok = false;
    }
    if ($ok) {
        if (file_exists($filename)) {
            // Send cached file
            $file = file_get_contents($filename, false, NULL, strlen($garbage));
        } else {
            // Load the image and save the file if valid image if found
            // Get the contents of the URL
            $file = file_get_contents(my_urlencode($url));
            // Check if it is an image
            $img = @imagecreatefromstring($file);
Ejemplo n.º 30
-1
function plans_theme()
{
    global $user, $globals, $l, $theme, $softpanel, $iscripts, $catwise, $error, $emailtemps, $plans, $done, $_users;
    softheader($l['<title>']);
    echo '<center class="sai_heading"><img src="' . $theme['images'] . 'admin/plans.gif" />&nbsp;&nbsp;' . $l['title'] . '</center>
<img src="' . $theme['images'] . 'hr.jpg" width="100%" height="1" alt="" /><br /><br /><br />';
    error_handle($error);
    echo '<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

function delconf(){
	return confirm("' . $l['del_conf'] . '");
};

function add_plan(){
 window.location.href = "' . $globals['ind'] . 'act=addplans";
}

// ]]></script>';
    if (!empty($done)) {
        echo '<div class="sai_notice"><img src="' . $theme['images'] . 'success.gif" /> &nbsp; ' . $l['done'] . '</div><br />';
    }
    if (empty($plans)) {
        echo '<div class="sai_notice"><img src="' . $theme['images'] . 'notice.gif" /> &nbsp; ' . $l['no_plan'] . '</div><br />';
    } else {
        echo '<table border="0" cellpadding="5" cellspacing="1" width="95%" class="sai_altrowstable" align="center">
<tr>
	<th>' . $l['planname'] . '</th>
	<th>' . $l['options'] . '&nbsp;<input type="checkbox" onclick="check(document.getElementsByName(\'insids[]\'), this);" /></th>
</tr>';
        $i = 1;
        // Sort the plans alphabetically
        ksort($plans);
        foreach ($plans as $k => $v) {
            // Show name
            $v['show_name'] = get_filename($v['name']);
            echo '<tr class="' . ($i % 2 == 0 ? "sai_evenrowcolor" : "sai_oddrowcolor") . '">		
	<td width="80%">' . $v['show_name'] . '</td>
	<td><a href="' . $globals['ind'] . 'act=editplans&plan=' . $v['show_name'] . '"><img src="' . $theme['images'] . 'admin/editemail.gif" title= ' . $l['edit_plan'] . '/></a>&nbsp;
	<a href="' . $globals['ind'] . 'act=plans&delete=' . $v['show_name'] . '" onclick="return delconf();" title=' . $l['del_plan'] . '><img src="' . $theme['images'] . 'admin/remove.gif" /></a>&nbsp;<input type="checkbox" name="insids[]" id="' . $v['show_name'] . '" value="' . $v['show_name'] . '">
	</td>
</tr>';
            $i++;
        }
        echo '</table>
<br />
<center><a href="' . $globals['ind'] . 'act=addplans" style="text-decoration: none" ><input type="submit" class="sai_graybluebut" value="' . $l['addplan'] . '"></a></center><br />';
    }
    echo '' . (empty($globals['lictype']) ? '<div class="notebox">' . $l['feature_not_available'] . '</div>' : '') . '<br />
	<p align="right">
		' . $l['with_selected'] . ': 
		<select name="multi_options" id="multi_options">
			<option name="todo" id="todo" value="0">---</option>
			<option name="todo" id="todo" value="mult_rem">' . $l['del_plan'] . '</option>
		</select>
		<input type="button" value="' . $l['go'] . '" onclick="show_confirm()" class="sai_graybluebut">
		<br />
	</p>
	<div id="rem_div"></div>
	
<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
insids = new Array();
removed = new Object();

function show_confirm(){
	
	insids = new Array();
	removed = new Object();
	
	if($_("multi_options").value != "mult_rem"){
		return false;
	}

	// Build the list of Installations to remove
	var field = document.getElementsByName(\'insids[]\');
		insids = new Array();
		var c = 0;
		for(i = 0; i < field.length; i++){
			if(field[i].checked == true){
				insids[c] = field[i].value;
				c++;
			}
		
	}
	//alert(insids);
	
	if(c == 0){
		alert("' . $l['no_sel_inst'] . '");
		return false;
	}
	
	var r = confirm("' . $l['del_insid'] . '");
	if(r != true){
		return false;
	}

	remove_by_id(insids[0], "", 0);
}

function remove_by_id(insid, re, oldinsid){

	removed[insid] = false;
	
	if(re.length > 0 && oldinsid > 0){
		if(re == "removed"){
			removed[insid] = true;
		}
	}
	
	nextinsid = 0;
	
	// Find the next INSTALLATION to remove
	for(i = 0; i < insids.length; i++){
		if(typeof(removed[insids[i]]) != "undefined"){
			continue;
		}
		nextinsid = insids[i];
		break;
	}

	// If there is something left to be removed
	if(insid != 0){
		try{	
			AJAX("' . $globals['index'] . 'act=plans&delete="+insid+"&ajax=1&random="+Math.random(), "remove_by_id(\'"+nextinsid+"\', re, \'"+insid+"\')");
			$_("rem_div").innerHTML = "<br /><br /><p align=\\"center\\"><img src=\\"' . $theme['images'] . 'ajax_remove.gif\\"> <br />' . $l['rem_backup_id'] . ' File: " +insid+ "<br /></p>";
			return true;
		}catch(e){
			return false;
		}
	}
	$_("rem_div").innerHTML = "";
	alert("' . $l['inst_remvd'] . '");
	location.reload(true);
	return true;
}


$(document).ready(function(){
	
	$(".sai_altrowstable tr").mouseover(function(){
		var old_class = $(this).attr("class");
		//alert(old_class);
		$(this).attr("class", "sai_tr_bgcolor");
		
		$(this).mouseout(function(){
			$(this).attr("class", old_class);
		});
	});
	
});

// ]]></script>';
    softfooter();
}