Exemplo n.º 1
0
/**
 * Make a link to cmd 
 *
 * @author     sonots
 * @license    http://www.gnu.org/licenses/gpl.html GPL v2
 * @version    $Id: cmd.inc.php,v 1.1 2007-06-10 11:14:46 sonots $
 * @package    plugin
 */
function plugin_cmd_inline()
{
    $args = func_get_args();
    if (count($args) < 2) {
        return 'cmd(): &amp;cmd(cmd,[page]){linkstr};';
    }
    $linkstr = array_pop($args);
    $cmd = array_shift($args);
    $page = empty($args) ? '' : array_shift($args);
    $linkstr = $linkstr === '' ? htmlspecialchars($cmd) : $linkstr;
    $href = plugin_cmd_getlink($cmd, $page);
    $href = is_null($href) ? get_script_uri() . '?cmd=' . rawurlencode($cmd) : $href;
    return '<a class="cmd" href="' . $href . '">' . $linkstr . '</a>';
}
Exemplo n.º 2
0
function plugin_cmd_link($name, $page)
{
    $is_readonly = Auth::check_role('readonly');
    $is_safemode = Auth::check_role('safemode');
    $is_createpage = Auth::is_check_role(PKWK_CREATE_PAGE);
    if (isset($page)) {
        $page = isset($vars['page']) ? $vars['page'] : '';
    }
    // $is_read = (arg_check('read') && is_page($_page));
    $is_read = is_page($page);
    $is_editable = is_editable($page);
    switch ($name) {
        case 'freeze':
        case 'unfreeze':
            if ($is_read && $function_freeze) {
                if ($is_freeze) {
                    $name = 'unfreeze';
                } else {
                    $name = 'freeze';
                }
                return plugin_cmd_getlink($name);
            }
            break;
        case 'upload':
            if ($is_read && (bool) ini_get('file_uploads') && !$is_freeze && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'list':
            if ($vars['cmd'] !== 'list') {
                return plugin_cmd_getlink($name);
            } else {
                if ((bool) ini_get('file_uploads')) {
                    return plugin_cmd_getlink('filelist');
                }
            }
            break;
        case 'backup':
            if ($do_backup) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'brokenlink':
        case 'template':
        case 'source':
            if (!empty($_page)) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'trackback':
            if ($trackback && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                $tbcount = tb_count($_page);
                if (isset($vars['cmd']) && $vars['cmd'] == 'list') {
                    return plugin_cmd_getlink($name, 'Trackback list');
                } else {
                    return plugin_cmd_getlink($name, 'Trackback(' . $tbcount . ')');
                }
            }
            break;
        case 'referer':
        case 'skeylist':
        case 'linklist':
            if ($referer) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'log_login':
            if (log_exist('login', $vars['page'])) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'log_check':
            if (log_exist('check', $vars['page'])) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'log_browse':
            return plugin_cmd_getlink($name);
            //			if (log_exist('browse',$vars['page'])) {
            //				return plugin_cmd_getlink($name);
            //			}
            break;
        case 'log_update':
            if (log_exist('update', $vars['page'])) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'log_down':
            if (log_exist('download', $vars['page'])) {
                return plugin_cmd_getlink($name);
            }
            break;
        case '|':
            return '</ul>' . "\n" . '<ul>';
            break;
            // case 'new':
        // case 'new':
        case 'newsub':
        case 'edit':
        case 'guiedit':
            if ($is_read && $function_freeze && !$is_freeze && !($_page == $whatsnew || $_page == $whatsdeleted)) {
                return plugin_cmd_getlink($name);
            }
            break;
        case 'full':
        case 'print':
        case 'diff':
        case 'reload':
        case 'copy':
            if (!$is_read) {
                break;
            }
        default:
            return plugin_cmd_getlink($name);
            break;
    }
}