Ejemplo n.º 1
0
function plugin_unfreeze_action()
{
    global $vars, $function_freeze, $_unfreeze_msg;
    $page = isset($vars['page']) ? $vars['page'] : '';
    $wiki = Factory::Wiki($page);
    if (!$function_freeze || !$wiki->isEditable(false, true) || !$wiki->isValied($page)) {
        return array('msg' => $_unfreeze_msg['title_disabled'], 'body' => '<p class="alert alert-danger">You have no permission to unfreeze this page.</p>');
    }
    $pass = isset($vars['pass']) ? $vars['pass'] : NULL;
    $msg = '';
    $body = array();
    if (!$wiki->isFreezed()) {
        // Unfreezed already
        $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_unfreeze_msg['title_isunfreezed']);
        $body[] = '<p class="alert alert-info">' . $msg . '</p>';
    } else {
        if (!Auth::check_role('role_contents_admin') || $pass !== NULL && Auth::login($pass)) {
            // BugTrack2/255
            $wiki->checkReadable();
            // Unfreeze
            $postdata = $wiki->get();
            array_shift($postdata);
            $wiki->set($postdata);
            // Update
            if (PLUGIN_UNFREEZE_EDIT) {
                // BugTrack2/255
                $wiki->checkEditable(true);
                //			$vars['cmd'] = 'read'; // To show 'Freeze' link
                $vars['cmd'] = 'edit';
            } else {
                $vars['cmd'] = 'read';
            }
            $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_unfreeze_msg['title_unfreezed']);
            $body[] = !IS_AJAX ? '' : '<p class="alert alert-success">' . $msg . '</p>';
            $body[] = '<div class="pull-right"><a href="' . $wiki->uri() . '" class="btn btn-primary">OK</a></div>';
            Utility::redirect($wiki->uri());
            exit;
        } else {
            // Show unfreeze form
            $msg = $_unfreeze_msg['title_unfreeze'];
            $body[] = $pass === NULL ? '' : '<p class="alert alert-danger">' . $_unfreeze_msg['msg_invalidpass'] . '</p>' . "\n";
            $body[] = '<fieldset>';
            $body[] = '<legend>' . $_unfreeze_msg['msg_unfreezing'] . '</legend>';
            $body[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-freeze-form">';
            $body[] = '<input type="hidden"   name="cmd"  value="unfreeze" />';
            $body[] = '<input type="hidden"   name="page" value="' . Utility::htmlsc($page) . '" />';
            $body[] = '<input type="password" name="pass" size="12" class="form-control" />';
            $body[] = '<button type="submit" class="btn btn-primary" name="ok"><span class="fa fa-lock"></span>' . $_unfreeze_msg['btn_unfreeze'] . '</button>';
            $body[] = '</form>';
            $body[] = '</fieldset>';
        }
    }
    return array('msg' => $msg, 'body' => join("\n", $body));
}
Ejemplo n.º 2
0
function plugin_links_action()
{
    global $post, $vars, $foot_explain;
    global $_links_messages, $_string;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this');
    if (Auth::check_role('readonly')) {
        Utility::dieMessage($_string['error_prohibit']);
    }
    $msg = $_links_messages['title_update'];
    $admin_pass = empty($post['adminpass']) ? null : $post['adminpass'];
    if (isset($vars['execute']) && $vars['execute'] === 'true') {
        if (!Auth::check_role('role_contents_admin') || Auth::login($admin_pass)) {
            //	$force = (isset($post['force']) && $post['force'] === 'on') ? true : false;
            $links = new Relational('');
            $links->init();
            return array('msg' => $msg, 'body' => $_links_messages['msg_done']);
        } else {
            $msg = $_links_messages['msg_error'];
        }
    }
    $body = RendererFactory::factory(sprintf($_links_messages['msg_usage1']));
    $script = Router::get_script_uri();
    if (Auth::check_role('role_contents_admin')) {
        $body .= RendererFactory::factory(sprintf($_links_messages['msg_usage2']));
    }
    $body .= <<<EOD
<form method="post" action="{$script}" class="form-inline plugin-links-form">
\t<input type="hidden" name="cmd" value="links" />
\t<input type="hidden" name="execute" value="true" />
EOD;
    if (Auth::check_role('role_contents_admin')) {
        $body .= <<<EOD
\t<div class="form-group">
\t\t<label for="_p_links_adminpass" class="sr-only">{$_links_messages['msg_adminpass']}</label>
\t\t<input type="password" name="adminpass" id="_p_links_adminpass" class="form-control" size="20" value="" placeholder="{$_links_messages['msg_adminpass']}" />
\t</div>
EOD;
    }
    $body .= <<<EOD
\t<!--div class="checkbox">
\t\t<input type="checkbox" name="force" id="_c_force" />
\t\t<label for="_c_force">{$_links_messages['btn_force']}</label>
\t</div-->
\t<input type="submit" class="btn btn-primary" value="{$_links_messages['btn_submit']}" />
</form>
EOD;
    return array('msg' => $msg, 'body' => $body);
}
Ejemplo n.º 3
0
function plugin_freeze_action()
{
    global $vars, $function_freeze, $_freeze_msg;
    $page = isset($vars['page']) ? $vars['page'] : null;
    if (is_null($page)) {
        return array('msg' => 'Not Found', 'body' => 'Page not found');
    }
    $wiki = Factory::Wiki($page);
    if (!$function_freeze || !$wiki->isEditable(true) || !$wiki->has()) {
        return array('msg' => $_freeze_msg['title_disabled'], 'body' => '<p class="alert alert-danger">You have no permission to freeze this page.</p>');
    }
    $pass = isset($vars['pass']) ? $vars['pass'] : NULL;
    $msg = '';
    $body = array();
    if ($wiki->isFreezed()) {
        // Freezed already
        $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_freeze_msg['title_isfreezed']);
        $body[] = '<p class="alert alert-info">' . $msg . '</p>';
    } else {
        if (!Auth::check_role('role_contents_admin') || $pass !== NULL && Auth::login($pass)) {
            // Freeze
            $postdata = $wiki->get();
            array_unshift($postdata, "#freeze");
            //凍結をページに付加
            $wiki->set($postdata, true);
            // Update
            //$wiki->is_freezed();
            $vars['cmd'] = 'read';
            $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_freeze_msg['title_freezed']);
            $body[] = !IS_AJAX ? '' : '<p class="alert alert-success">' . $msg . '</p><div class="pull-right"><a href="' . $wiki->uri() . '" class="btn btn-primary">OK</a></div>';
        } else {
            // Show a freeze form
            $msg = $_freeze_msg['title_freeze'];
            $body[] = $pass === NULL ? '' : '<p class="alert alert-warning">' . $_freeze_msg['msg_invalidpass'] . '</p>';
            $body[] = '<fieldset>';
            $body[] = '<legend>' . $_freeze_msg['msg_freezing'] . '</legend>';
            $body[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-freeze-form">';
            $body[] = '<input type="hidden"   name="cmd"  value="freeze" />';
            $body[] = '<input type="hidden"   name="page" value="' . Utility::htmlsc($page) . '" />';
            $body[] = '<input type="password" name="pass" size="12" class="form-control" />';
            $body[] = '<button type="submit" class="btn btn-primary" name="ok"><span class="fa fa-lock"></span>' . $_freeze_msg['btn_freeze'] . '</button>';
            $body[] = '</form>';
            $body[] = '</fieldset>';
        }
    }
    return array('msg' => $msg, 'body' => join("\n", $body));
}
Ejemplo n.º 4
0
/**
 * auth.php
 */
function pkwk_login($pass = '')
{
    return Auth::login($pass);
}
Ejemplo n.º 5
0
/**
 * function plugin_backup_rollback($page, $age)
 */
function plugin_backup_rollback($page, $age)
{
    global $vars;
    global $_backup_messages;
    $passvalid = isset($vars['pass']) ? Auth::login($vars['pass']) : FALSE;
    if ($passvalid) {
        $backup = Factory::Backup($page);
        $backups = $backup->get($age);
        if (empty($backups)) {
            return array(sprintf($_backup_messages['title_backup_rollback'], $age), 'body' => $_backup_messages['msg_nobackup']);
            // Do nothing
        }
        $wiki = Factory::Wiki($page);
        // バックアップからロールバック(タイムスタンプを更新しない状態で)
        $wiki->set($backups['data']);
        // ファイルの更新日時をバックアップの時点にする
        $wiki->touch($backups['time']);
        //put_lastmodified();
        return array('msg' => $_backup_messages['title_backup_rollbacked'], 'body' => str_replace('$1', make_pagelink($page) . '(No. ' . $age . ')', $_backup_messages['msg_backup_rollbacked']));
    } else {
        $script = Router::get_script_uri();
        $s_page = htmlsc($page);
        $body = <<<EOD
<fieldset>
\t<legend>{$_backup_messages['msg_backup_adminpass']}</legend>
\t<form action="{$script}" method="post" class="plugin-backup-rollback-form form-inline">
\t\t<input type="hidden" name="cmd" value="backup" />
\t\t<input type="hidden" name="action" value="rollback" />
\t\t<input type="hidden" name="age" value="{$age}" />
\t\t<input type="hidden" name="page" value="{$s_page}" />
\t\t<div class="form-group">
\t\t\t<input type="password" name="pass" size="12" class="form-control" />
\t\t</div>
\t\t<input type="submit" name="ok" value="{$_backup_messages['btn_rollback']}" class="btn btn-warning" />
\t</form>
</legend>
EOD;
        return array('msg' => sprintf($_backup_messages['title_backup_rollback'], $age), 'body' => $body);
    }
}
Ejemplo n.º 6
0
 /**
  * ファイルを凍結/解除
  * @param boolean $freeze
  * @param boolean
  */
 public function freeze($freeze, $pass)
 {
     if (Auth::check_role('role_contents_admin') && !Auth::login($pass)) {
         return attach_info('err_adminpass');
     }
     // TODO
     $this->status['freeze'] = $freeze;
     $this->update = true;
     return true;
 }