当前位置: 首页>>代码示例>>PHP>>正文


PHP do_invalid函数代码示例

本文整理汇总了PHP中do_invalid函数的典型用法代码示例。如果您正苦于以下问题:PHP do_invalid函数的具体用法?PHP do_invalid怎么用?PHP do_invalid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了do_invalid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_filter

function do_filter($formatter, $options)
{
    if (!$options['filter']) {
        do_invalid($formatter, $options);
        return;
    }
    $body = $formatter->page->get_raw_body($options);
    $filters = preg_split("/(\\||,)/", $options['filter']);
    if ($options['raw']) {
        $formatter->send_header('Content-Type: text/plain');
    } else {
        $formatter->send_header('', $options);
    }
    foreach ($filters as $ft) {
        $body = $formatter->filter_repl(trim($ft), $body, $options);
    }
    if ($options['raw']) {
        print $body;
        return;
    }
    $formatter->send_title('', '', $options);
    print '<pre>' . $body . '</pre>';
    $formatter->send_footer("", $options);
    return;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:25,代码来源:filter.php

示例2: do_vote

function do_vote($formatter, $options)
{
    global $DBInfo;
    if ($options['id'] == 'Anonymous') {
        if (!isset($options['msg'])) {
            $options['msg'] = '';
        }
        $options['msg'] .= "\n" . _("Please Login or make your ID on this Wiki ;)");
        do_invalid($formatter, $options);
        return;
    }
    if (!$options['ticket'] and !$options['vote']) {
        return '<html><h1>Error</h1></html>';
    }
    $body = $formatter->page->get_raw_body();
    $lines = explode("\n", $body);
    $count = count($lines);
    for ($i = 0; $i < $count; $i++) {
        if ($test = preg_match_all("/\\[\\[Vote\\(([^\\]]+)\\)\\]\\]/", $lines[$i], $tickets)) {
            foreach ($tickets[1] as $ticket) {
                $tic = preg_replace($formatter->baserule, $formatter->baserepl, $ticket);
                if (md5($tic) == $options['ticket']) {
                    $save = $ticket;
                    $items = explode(",", $tic);
                    $rawitems = explode(",", $ticket);
                    for ($k = 0; $k < sizeof($items); $k++) {
                        preg_match("/(^.+)\\s+(\\d+)\$/", $items[$k], $match);
                        preg_match("/(^.+)\\s+(\\d+)\$/", $rawitems[$k], $rawmatch);
                        $votes[$rawmatch[1]] = (int) $match[2];
                        if (md5($match[1]) == $options['vote']) {
                            $votes[$rawmatch[1]]++;
                            $voted = 1;
                        }
                    }
                    if ($voted) {
                        while (list($item, $count) = each($votes)) {
                            $args .= "{$item} {$count},";
                        }
                        $args = substr($args, 0, -1);
                        $lines[$i] = str_replace("[[Vote({$save})]]", "[[Vote({$args})]]", $lines[$i]);
                        break;
                    }
                }
            }
        }
    }
    if ($voted) {
        $formatter->page->write(join("\n", $lines));
        $DBInfo->savePage($formatter->page, "Vote", $options);
        $options[msg] = _("Voted successfully");
    }
    $formatter->send_header("", $options);
    $formatter->send_title("", "", $options);
    $formatter->send_page();
    $formatter->send_footer("", $options);
    return;
}
开发者ID:NessunKim,项目名称:MW_Skins,代码行数:57,代码来源:Vote.php

示例3: do_format

function do_format($formatter, $options)
{
    $mimes = array('text/plain' => 'html', 'text/xml' => 'text_xml');
    $mimetype = $options['mimetype'];
    $proc = !empty($options['proc']) ? $options['proc'] : '';
    if (!$mimetype) {
        $mimetype = 'text/plain';
    }
    $pi = $formatter->page->get_instructions($dummy);
    if (!$formatter->wordrule) {
        $formatter->set_wordrule($pi);
    }
    if ($pi['#format'] == 'xsltproc') {
        $options['title'] = _("It is a XML format !");
        do_invalid($formatter, $options);
        return;
    }
    if (!$formatter->page->exists()) {
        do_invalid($formatter, $options);
        return;
    } else {
        if (empty($proc) and array_key_exists($mimetype, $mimes)) {
            header("Content-type: " . $mimetype);
            print $formatter->processor_repl($mimes[$mimetype], $formatter->page->get_raw_body(), $options);
        } else {
            if (!empty($proc)) {
                #if (getProcessor($processor)) {
                #  do_invalid($formatter,$options);
                #  return;
                #}
                #header("Content-type: ".$mimetype);
                header("Content-type: text/plain");
                print $formatter->processor_repl($proc, $formatter->page->get_raw_body(), $options);
            } else {
                $processor = str_replace("/.", "__", $mimetype);
                header("Content-type: text/plain");
                if (getProcessor($processor)) {
                    print $formatter->processor_repl($processor, $formatter->page->get_raw_body(), $options);
                } else {
                    do_invalid($formatter, $options);
                    return;
                }
            }
        }
    }
    return;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:47,代码来源:format.php

示例4: do_rcspurge

function do_rcspurge($formatter, $options)
{
    global $DBInfo;
    # XXX
    if (!$options['show'] and $DBInfo->security->is_protected("rcspurge", $options) and !$DBInfo->security->is_valid_password($options['passwd'], $options)) {
        $title = sprintf('Invalid password to purge "%s" !', $options['page']);
        $formatter->send_header("", $options);
        $formatter->send_title($title);
        $formatter->send_footer();
        return;
    }
    if (!preg_match("/^[\\d:;\\.]+\$/", $options['range'])) {
        $options['title'] = _("Invalid rcspurge range");
        do_invalid($formatter, $options);
        return;
    }
    $title = sprintf(_("RCS purge \"%s\""), $options['page']);
    $formatter->send_header("", $options);
    $formatter->send_title($title, "", $options);
    if ($options['range']) {
        $ranges = explode(';', $options['range']);
        foreach ($ranges as $range) {
            if (!trim($range)) {
                continue;
            }
            printf("<h3>range '%s' purged</h3>", $range);
            if ($options['show']) {
                print "<tt>rcs -o{$range} " . $options['page'] . "</tt><br />";
            } else {
                #print "<b>Not enabled now</b> <tt>rcs -o$range  data_dir/".$options[page]."</tt><br />";
                print "<tt>rcs -o{$range} " . $options['page'] . "</tt><br />";
                $fp = popen("rcs -o{$range} " . $formatter->page->filename . $formatter->NULL, 'r');
                pclose($fp);
            }
        }
    } else {
        printf("<h3>No version selected to purge '%s'</h3>", $options['page']);
    }
    $args['noaction'] = 1;
    $formatter->send_footer($args, $options);
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:41,代码来源:rcspurge.php

示例5: do_aclinfo

function do_aclinfo($formatter, $options)
{
    global $DBInfo;
    if ($DBInfo->security_class == 'acl') {
        list($allowed, $denied, $protected) = $DBInfo->security->get_acl('aclinfo', $options);
    } else {
        $options['msg'] = _("ACL is not enabled on this Wiki");
        do_invalid($formatter, $options);
        return;
    }
    $formatter->send_header('', $options);
    $formatter->send_title('', '', $options);
    print '<h2>' . _("Your ACL Info") . '</h2>';
    if (in_array($options['id'], $DBInfo->owners)) {
        print '<h4>' . _("You are wiki owner") . "</h4>\n";
    } else {
        if (in_array($options['id'], $DBInfo->wikimasters)) {
            print '<h4>' . _("You are wiki master") . "</h4>\n";
        } else {
            print '<h4>' . _("Allowed actions") . "</h4>\n";
            print '<ul>';
            foreach ($allowed as $k => $v) {
                print '<li>' . $k . ': (' . $v . ')</li>';
            }
            print '</ul>';
            print '<h4>' . _("Denied actions") . "</h4>\n";
            print '<ul>';
            foreach ($denied as $k => $v) {
                print '<li>' . $k . ': (' . $v . ')</li>';
            }
            print '</ul>';
            print '</pre>';
            print '<h4>' . _("Protected actions") . "</h4>\n";
            print '<ul><li>';
            print implode('</li><li>', $protected);
            print '</li></ul>';
        }
    }
    $formatter->send_footer('', $options);
    return;
}
开发者ID:NessunKim,项目名称:MW_Skins,代码行数:41,代码来源:aclinfo.php

示例6: do_post_jme

function do_post_jme($formatter, $options)
{
    global $DBInfo;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$DBInfo->security->writable($options)) {
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    }
    $draw_dir = str_replace("./", '', $DBInfo->upload_dir . '/JME');
    $pagename = $options['page'];
    !empty($options['value']) ? $name = $options['value'] : !empty($options['name']) ? $name = $options['name'] : null;
    if (empty($name)) {
        $name = time();
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST' and $options['mol']) {
        $dummy = explode('/', $name);
        $name = $dummy[count($dummy) - 1];
        $molname = $name . '.mol';
        $fp = fopen($draw_dir . '/' . $molname, 'w');
        if ($fp) {
            fwrite($fp, $options['mol']);
            fclose($fp);
        }
        $formatter->send_header('', $options);
        $formatter->send_title(_("Molecule successfully added"), '', $options);
        $formatter->send_footer('', $options);
        return;
    }
    $formatter->send_header('', $options);
    $formatter->send_title(_("Edit Molecule"), '', $options);
    $script = <<<SCRIPT
<script type="text/javascript">
/*<![CDATA[*/
function setMolFile(obj) {
    var mol = document.JME.molFile();
    obj.mol.value = mol;
}

function getGauFile(obj) {
    var mol = document.JME.molFile();
    var lines = mol.split("\\n");
    var i=0;
    var gau="%chk=\\n# ub3lyp/6-311g(d,p) OPT FREQ POP=full\\n\\n";
    gau += obj.name.value + "\\n\\n0 1\\n";

    while (i < lines.length) {
        var mat = lines[i].match(/^\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([A-Z]{1,2})\\s+.*/);
        if (mat != null) {
            gau += mat[4] + ' ' + mat[1] + ' ' + mat[2] + ' ' + mat[3] + "\\n";
        }
        i++;
    }

    obj.mol.value = gau + "\\n";
}
/*]]>*/
</script>
SCRIPT;
    $pubpath = $DBInfo->url_prefix . "/applets/JMEPlugin";
    print "<h2>" . _("Edit new molecule") . "</h2>\n";
    $name = _html_escape($name);
    print <<<FORM
{$script}
<form method="POST" action="">
<applet code="JME.class" name="JME" codebase="{$pubpath}" archive="JME.zip"
width="360" height="315">
<param name=" options"  value="multipart; autoez";>
You have to enable Java and JavaScritpt on your machine !
</applet><br />
<input type="hidden" name="action" value="jme" />
<input type="hidden" name="name" value="{$name}" />
<input type="submit" name="submit_button" value="Submit" onclick="setMolFile(this.form)" />
<input type="button" name="gau_button" value="Get Gaussian input" onclick="getGauFile(this.form)" />
<input type="button" value="Get Mol" onclick="setMolFile(this.form)" />
<input type="reset" value="reset" />
<div class="molecule">
<textarea cols="50" rows="20" name="mol" /></textarea></div>
</form>
FORM;
    $formatter->send_footer("", $options);
    return;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:81,代码来源:JME.php

示例7: do_OeKaki

function do_OeKaki($formatter, $options)
{
    global $DBInfo;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$DBInfo->security->writable($options)) {
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    }
    $oekaki_dir = $DBInfo->upload_dir . '/OeKaki';
    $pagename = $options['page'];
    $name = $options['value'];
    #  $fp=fopen('php://stderr','w');
    #  fputs($fp,"name=$name\n");
    #  fputs($fp,"page=$options[page]\n");
    #  if ($_SERVER['REQUEST_METHOD']=='POST') {
    #    $len = $_SERVER['CONTENT_LENGTH'];
    #    fputs($fp,"len=$len\n");
    #    fputs($fp,"method=POST\n");
    #  }
    if (!$name) {
        $name = time();
    }
    # XXX
    $pngname = 'OeKaki_' . _rawurlencode($name);
    $imgurl = "{$DBInfo->url_prefix}/{$oekaki_dir}/{$pngname}.png";
    $imgpath = "{$oekaki_dir}/{$pngname}.png";
    $dummy = 0;
    $backup_imgpath = $imgpath;
    while (file_exists($backup_imgpath)) {
        $dummy = $dummy + 1;
        $ufname = $pngname . "_" . $dummy;
        // rename file
        $upfilename = $ufname . ".png";
        $backup_imgpath = "{$oekaki_dir}/{$upfilename}";
    }
    if ($GLOBALS['HTTP_RAW_POST_DATA']) {
        if ($formatter->page->exists()) {
            $body = $formatter->page->get_raw_body();
        } else {
            $body = '';
        }
        if (!preg_match("/\n?\\[\\[OeKaki\\({$name}\\)\\]\\]\n?/i", $body)) {
            if (preg_match("/\n##Draw\n/i", $body)) {
                $body = preg_replace("/\n##Draw\n/", "\n##Draw\n[[OeKaki({$name})]]\n", $body);
            } else {
                $body .= "[[OeKaki({$name})]]\n";
            }
            $log = "Oekaki drawing added";
            $formatter->page->write($body);
            # XXX Oekaki post does not hav any information about user id.
            $DBInfo->savePage($formatter->page, $log, $options);
        }
        if ($backup_imgpath != $imgpath) {
            copy($imgpath, $backup_imgpath);
        }
        $raw = $GLOBALS['HTTP_RAW_POST_DATA'];
        $p = strpos($raw, "\r");
        if ($p < 0) {
            header("Content-type: text/plain");
            print "error\n\n";
        } else {
            $img = fopen($imgpath, 'w');
            if (is_resource($img)) {
                fwrite($img, substr($raw, $p + 2));
                fclose($img);
            }
        }
        header("Content-type: text/plain");
        print "ok\n\n";
        print $imgpath;
        return;
    }
    if ($options['size'] and preg_match("/(\\d{3})x(\\d{3})/", $options['size'], $match)) {
        $sizex = $match[1];
        $sizey = $match[2];
        if ($sizex < 100 or $sizex > 600) {
            $sizex = 300;
        }
        if ($sizey < 100 or $sizey > 600) {
            $sizey = 300;
        }
    } else {
        $sizex = 300;
        $sizey = 300;
    }
    $extra = "<param name='image_canvas' value='{$imgurl}'>";
    $formatter->send_header("", $options);
    $formatter->send_title(_("Create new picture"), "", $options);
    $prefix = $formatter->prefix;
    $now = time();
    $urlpgname = _rawurlencode($options['page']);
    $imgname = _rawurlencode($name);
    $url_exit = $formatter->link_url($urlpgname, "?ts={$now}");
    $url_save = $formatter->link_url($urlpgname, "----OeKaki----{$imgname}");
    $pubpath = $DBInfo->url_prefix . "/applets/OekakiPlugin";
    print "<h2>" . _("Edit Image") . "</h2>\n";
    print <<<APPLET
<applet code="pbbs.PaintBBS.class" archive="PaintBBS.jar"
 codebase="{$pubpath}"
 name="{$pngname}.png"
 width="400" height="400" align="center">
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:OeKaki.php

示例8: do_ticket

function do_ticket($formatter, $options)
{
    global $DBInfo;
    $word_length = 4;
    if (!empty($options['__seed'])) {
        // check seed
        // check referer
        $passwd = getTicket($options['__seed'], $_SERVER['REMOTE_ADDR'], $word_length);
    } else {
        $options['title'] = _("Invalid use of ticket");
        do_invalid($formatter, $options);
        return;
    }
    if (!empty($DBInfo->gdfontpath)) {
        putenv('GDFONTPATH=' . $DBInfo->gdfontpath);
    } else {
        // set default GDFONTPATH
        $old = getenv('GDFONTPATH');
        $path = $DBInfo->data_dir;
        if ($old) {
            $path = $old . ':' . $new;
        }
        putenv('GDFONTPATH=' . $path);
    }
    if (function_exists('ImageTtfText')) {
        while (!empty($DBInfo->ticket_font)) {
            if (is_numeric($DBInfo->ticket_font)) {
                break;
            }
            $FONT = $DBInfo->ticket_font;
            //$FONT="/home/foobar/data/PenguinAttack.ttf";
            if ($FONT[0] == '/' and !file_exists($FONT)) {
                $use_ttf = 0;
            } else {
                $FONT = $DBInfo->ticket_font;
                $use_ttf = 1;
            }
            break;
        }
    }
    if (!empty($use_ttf)) {
        $pointsize = !empty($DBInfo->ticket_font_size) ? $DBInfo->ticket_font_size : 16;
        $angle = 0;
        //$size = Imagettfbbox($pointsize, 0, $FONT, $passwd);
        // XXX segfault :(
        $margin = $pointsize / 2;
        $size = array(0, 0, 0, 20, 65);
        //$size=array(0,0,0,20,50);
        //$w=$size[4]+20; # margin=20 ?
        $w = $pointsize * $word_length + $margin;
        $h = $pointsize + $margin;
        if ($DBInfo->use_ticket & 23) {
            $h += $pointsize / 3;
        }
    } else {
        $FONT = 5;
        // giant
        if (!empty($DBInfo->ticket_gdfont)) {
            $FONT = $DBInfo->ticket_gdfont;
        }
        $w = imagefontwidth($FONT) * strlen($passwd) + 10;
        $h = imagefontheight($FONT);
        $pointsize = $h;
        $h += 10;
    }
    $im = ImageCreate($w, $h);
    $color = array();
    if (isset($DBInfo->captcha_bgcolor) and preg_match('/^#[0-9a-fA-F]$/', $DBInfo->captcha_bgcolor)) {
        $r = substr($DBInfo->captcha_bgcolor, 1, 2);
        $g = substr($DBInfo->captcha_bgcolor, 3, 2);
        $b = substr($DBInfo->captcha_bgcolor, 5, 2);
        $color[] = ImageColorAllocate($im, hexdec($r), hexdec($g), hexdec($b));
        // background
    } else {
        $color[] = ImageColorAllocate($im, 240, 240, 240);
        // default background
    }
    $color[] = ImageColorAllocate($im, 0, 0, 0);
    // black
    $color[] = ImageColorAllocate($im, 255, 255, 255);
    // white
    $pen = rand(3, 19);
    $pen1 = rand(3, 19);
    for ($i = 0; $i < 18; $i++) {
        $color[] = ImageColorAllocate($im, rand(100, 200), rand(100, 200), rand(100, 200));
    }
    if (!empty($use_ttf)) {
        $sx = $margin;
        $sy = $margin / 2 + $pointsize;
        ImageTtfText($im, $pointsize, $angle, $sx, $sy + 1, $color[$pen], $FONT, $passwd);
        ImageTtfText($im, $pointsize, $angle, $sx + 1, $sy, $color[$pen], $FONT, $passwd);
    } else {
        ImageString($im, $FONT, 5, 3, $passwd, $color[$pen]);
        ImageString($im, $FONT, 4, 4, $passwd, $color[$pen]);
    }
    $grad = '';
    if ($DBInfo->use_ticket & 8) {
        $grad = 1;
    }
    if ($DBInfo->use_ticket & 4) {
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:ticket.php

示例9: do_userform


//.........这里部分代码省略.........
                                                $title = _("too short password!");
                                            } else {
                                                if ($ret == -1) {
                                                    $title = _("mismatch password!");
                                                } else {
                                                    if ($ret == -2) {
                                                        $title = _("not acceptable character found in the password!");
                                                    }
                                                }
                                            }
                                        } else {
                                            if ($ret < 8 and empty($DBInfo->use_safelogin)) {
                                                $options['msg'] = _("Your password is too simple to use as a password !");
                                            }
                                            $udb = $DBInfo->udb;
                                            if ($options['email']) {
                                                if (preg_match('/^[a-z][a-z0-9_\\-\\.]+@[a-z][a-z0-9_\\-]+(\\.[a-z0-9_]+)+$/i', $options['email'])) {
                                                    if (($ret = verify_email($options['email'])) < 0) {
                                                        $options['email'] = '';
                                                        // reset email address
                                                        $ret = -$ret;
                                                        $options['msg'] .= '<br />' . 'ERROR Code: ' . $ret;
                                                        $options['msg'] .= '<br/>' . _("Can't verify E-mail address! Please check your email address.");
                                                    }
                                                } else {
                                                    $options['msg'] .= '<br/>' . _("Your email address is not valid");
                                                }
                                            }
                                            if ($udb->isNotUser($user)) {
                                                if (!empty($DBInfo->no_register)) {
                                                    $options['msg'] = _("Fail to register");
                                                    $options['err'] = _("You are not allowed to register on this wiki");
                                                    $options['err'] .= "\n" . _("Please contact WikiMasters");
                                                    do_invalid($formatter, $options);
                                                    return;
                                                }
                                                $title = sprintf(_("Successfully added as '%s'"), _html_escape($user->id));
                                                $options['id'] = $user->id;
                                                $ticket = md5(time() . $user->id . $options['email']);
                                                $user->info['eticket'] = $ticket . "." . $options['email'];
                                                if (!empty($DBInfo->use_safelogin)) {
                                                    $options['msg'] = sprintf(_("Successfully added as '%s'"), $user->id);
                                                    $options['msg'] .= '<br />' . _("Please check your mailbox");
                                                }
                                                $args = array();
                                                if ($options['email'] == $id or !empty($DBInfo->register_confirm_email)) {
                                                    $args = array('suspended' => 1);
                                                }
                                                if (!empty($DBInfo->register_confirm_admin)) {
                                                    $args = array('suspended' => 1);
                                                }
                                                if (!empty($DBInfo->register_confirm_admin)) {
                                                    if (!empty($options['msg'])) {
                                                        $options['msg'] .= '<br />';
                                                    }
                                                    $options['msg'] .= _("Your need to wait until your ID activated by admin");
                                                }
                                                // save join agreement
                                                if (!empty($DBInfo->use_agreement) and !empty($options['joinagreement'])) {
                                                    $user->info['join_agreement'] = 'agree';
                                                    if (!empty($DBInfo->agreement_version)) {
                                                        $user->info['join_agreement_version'] = $DBInfo->agreement_version;
                                                    }
                                                }
                                                if (empty($DBInfo->use_safelogin) && empty($args['suspended'])) {
                                                    $formatter->header($user->setCookie());
开发者ID:ahastudio,项目名称:moniwiki,代码行数:67,代码来源:userform.php

示例10: do_theme

function do_theme($formatter, $options = array())
{
    global $DBInfo;
    if (!empty($DBInfo->theme_css)) {
        $options['title'] = _("Theme disabled !");
        $options['msg'] = _("Please contact WikiMasters");
        do_invalid($formatter, $options);
        return _("Theme disabled !");
    }
    $theme = '';
    if (preg_match('/^[a-zA-Z0-9_-]+$/', $options['value'])) {
        $theme = $options['value'];
    } else {
        if (preg_match('/^[a-zA-Z0-9_-]+$/', $options['theme'])) {
            $theme = $options['theme'];
        }
    }
    $themes = macro_Theme($formatter, '', array('call' => 1));
    if (!in_array($theme, $themes)) {
        $title = _("Invalid Theme");
        $theme = null;
    } else {
        if ($options['id'] == 'Anonymous') {
            if ($theme == $_COOKIE['MONI_THEME']) {
                $theme = null;
            }
        } else {
            if ($theme == $DBInfo->user->info['theme']) {
                $theme = null;
            } else {
                if (empty($DBInfo->user->info['theme']) && $theme == $DBInfo->theme) {
                    $theme = null;
                }
            }
        }
    }
    if ($options['clear']) {
        if ($options['id'] == 'Anonymous') {
            #header("Set-Cookie: MONI_THEME=dummy; expires=Tuesday, 01-Jan-1999 12:00:00 GMT; Path=".get_scriptname());
            #header("Set-Cookie: MONI_CSS=dummy; expires=Tuesday, 01-Jan-1999 12:00:00 GMT; Path=".get_scriptname());
            setcookie('MONI_THEME', 'dummy', time() - 60 * 60 * 24 * 30, get_scriptname());
            setcookie('MONI_CSS', 'dummy', time() - 60 * 60 * 24 * 30, get_scriptname());
            $cleared = 1;
            //$options['css_url']='';
            //$options['theme']='';
        } else {
            # save profile
            $udb = $DBInfo->udb;
            $userinfo = $udb->getUser($options['id']);
            $userinfo->info['theme'] = "";
            $userinfo->info['css_url'] = "";
            $udb->saveUser($userinfo);
        }
        $msg = '<h2>' . _("Theme cleared.") . ' ' . sprintf(_("Goto %s"), $formatter->link_repl("UserPreferences")) . '</h2>';
    } else {
        if (!empty($theme)) {
            $themedir = $formatter->themedir;
            if (file_exists($themedir . "/header.php")) {
                # check
                $options['css_url'] = $formatter->themeurl . "/css/default.css";
                if ($options['save'] and $options['id'] == 'Anonymous') {
                    setcookie("MONI_THEME", $theme, time() + 60 * 60 * 24 * 30, get_scriptname());
                    setcookie("MONI_CSS", $options['css_url'], time() + 60 * 60 * 24 * 30, get_scriptname());
                    $title = _("Theme is changed");
                    $msg = "Goto " . $formatter->link_repl("UserPreferences");
                } else {
                    if ($options['save'] and $options['id'] != 'Anonymous') {
                        # save profile
                        $udb = $DBInfo->udb;
                        $userinfo = $udb->getUser($options['id']);
                        $userinfo->info['theme'] = $theme;
                        $userinfo->info['css_url'] = $options['css_url'];
                        $udb->saveUser($userinfo);
                        $msg = "Goto " . $formatter->link_repl("UserPreferences");
                    } else {
                        $title = "";
                        $want = _("Do you want to apply this theme ?");
                        $btn = _("OK");
                        $msg = <<<FORM
<form method='post'>
<input type='hidden' name='action' value='theme' />
<input type='hidden' name='theme' value="{$theme}" />
{$want} <input type='submit' name='save' value='{$btn}' /> &nbsp;
</form>

FORM;
                    }
                }
                $formatter->send_header("", $options);
                $formatter->send_title($title, "", $options);
                print $msg;
                $formatter->send_footer("", $options);
                return;
            }
        } else {
            $title = _("Please select a theme");
        }
    }
    $formatter->send_header("", $options);
    $formatter->send_title($title, '', $options);
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:theme.php

示例11: do_rating

function do_rating($formatter, $options)
{
    global $DBInfo;
    if (!$DBInfo->security->writable($options)) {
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    }
    if ($options['id'] == 'Anonymous') {
        $options['msg'] .= "\n" . _("Please Login or make your ID on this Wiki ;)");
        do_invalid($formatter, $options);
        return;
    }
    $formatter->send_header('', $options);
    $oraw = $formatter->page->get_raw_body();
    list($nth, $dum, $v) = explode(',', base64_decode($options['mid']), 3);
    $val = explode(',', $v);
    if (sizeof($val) >= 2) {
        $total = $val[0];
        $count = $val[1];
    } else {
        $total = $val[0];
    }
    if (isset($count)) {
        $count = max(1, $count);
    } else {
        $count = 1;
    }
    $value = $total / $count;
    // averaged value
    if ($total == 0 and $count == 1) {
        $count = 0;
    }
    $value = (!empty($value) and 0 < $value and 6 > $value) ? $value : 0;
    ++$count;
    $check = '[[' . $dum . '(' . $v . ')]]';
    $rating = $options['rating'] ? (int) $options['rating'] : 1;
    $rating = min(5, max(0, $rating));
    $total += $rating;
    // increase total rating
    if (is_numeric($nth)) {
        $raw = str_replace("\n", "", $oraw);
        $chunk = preg_split("/({{{.+}}})/U", $raw, -1, PREG_SPLIT_DELIM_CAPTURE);
        #print '<pre>';
        #print_r($chunk);
        #print '</pre>';
        $nc = '';
        $k = 1;
        $i = 1;
        foreach ($chunk as $c) {
            if ($k % 2) {
                $nc .= $c;
            } else {
                $nc .= "" . $i . "";
                $blocks[$i] = str_replace("", "\n", $c);
                ++$i;
            }
            $k++;
        }
        $nc = str_replace("", "\n", $nc);
        $chunk = preg_split('/((?!\\!)\\[\\[.+\\]\\])/U', $nc, -1, PREG_SPLIT_DELIM_CAPTURE);
        $nnc = '';
        $ii = 1;
        $matched = 0;
        for ($j = 0, $sz = sizeof($chunk); $j < $sz; ++$j) {
            if (($j + 1) % 2) {
                $nnc .= $chunk[$j];
            } else {
                if ($nth == $ii) {
                    $new = '[[Rating(' . $total . ',' . $count . ')]]';
                    if ($check != $chunk[$j]) {
                        break;
                    }
                    $nnc .= $new;
                    $matched = 1;
                } else {
                    $nnc .= $chunk[$j];
                }
                ++$ii;
            }
        }
        if (!empty($blocks)) {
            $formatter->_array_callback($blocks, true);
            $nnc = preg_replace_callback("/(\\d+)/", array(&$formatter, '_array_callback'), $nnc);
        }
    }
    if (empty($matched)) {
        if (!empty($DBInfo->use_rating)) {
            $dum = '';
            $pi = $formatter->page->get_instructions($dum);
            $old = !empty($pi['#rating']) ? $pi['#rating'] : '';
            $new = '#rating ' . $total . ',' . $count;
            if ($old) {
                list($ts, $cnt) = explode(',', $old);
                $raw = preg_replace('/^#rating\\s+.*$/m', $new, $oraw, 1);
            } else {
                if (!$formatter->pi) {
                    $raw = $new . "\n" . $oraw;
                } else {
                    $body = $oraw;
                    $head = '';
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:Rating.php

示例12: do_post_fixbacklinks

function do_post_fixbacklinks($formatter, $options = array())
{
    global $DBInfo;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$DBInfo->security->writable($options)) {
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    }
    $options['name'] = trim($options['name']);
    $new = $options['name'];
    if (!empty($DBInfo->use_namespace) and $new[0] == '~' and ($p = strpos($new, '/')) !== false) {
        // Namespace renaming ~foo/bar -> foo~bar
        $dummy = substr($new, 1, $p - 1);
        $dummy2 = substr($new, $p + 1);
        $options['name'] = $dummy . '~' . $dummy2;
    }
    if (isset($options['name'][0]) and $options['name']) {
        if ($DBInfo->hasPage($options['name'])) {
            $formatter->send_header('', $options);
            $new_encodedname = _rawurlencode($options['name']);
            $fixed = 0;
            $msg = '';
            $title = sprintf(_("backlinks of \"%s\" page are fixed !"), $options['page']);
            $comment = sprintf(_("Fixed \"%s\" to \"%s\""), $options['page'], $options['name']);
            if ($options['pagenames'] and is_array($options['pagenames'])) {
                $regex = preg_quote($options['page']);
                //$options['minor'] = 1; # disable log
                foreach ($options['pagenames'] as $page) {
                    $p = new WikiPage($page);
                    if (!$p->exists()) {
                        continue;
                    }
                    $f = new Formatter($p);
                    $body = $p->_get_raw_body();
                    $nbody = preg_replace("/{$regex}/m", $options['name'], $body);
                    // FIXME
                    if ($nbody !== false && $body != $nbody) {
                        $f->page->write($nbody);
                        if (!$options['show_only']) {
                            $DBInfo->savePage($f->page, $comment, $options);
                        }
                        $msg .= sprintf(_("'%s' is changed"), $f->link_tag(_rawurlencode($page), "?action=highlight&amp;value=" . $new_encodedname, _html_escape($page))) . "<br />";
                        $fixed++;
                    }
                }
            }
            if ($fixed == 0) {
                $title = _("No pages are fixed!");
            }
            $formatter->send_title($title, '', $options);
            if ($fixed > 0) {
                print $msg;
                print sprintf(_("'%s' links are successfully fixed as '%s'."), _html_escape($options['page']), $formatter->link_tag($new_encodedname, "?action=highlight&amp;value=" . $new_encodedname, _html_escape($options['name'])));
            }
            $formatter->send_footer('', $options);
            return;
        } else {
            $title = sprintf(_("Fail to fix backlinks of \"%s\" !"), $options['page']);
            $options['msg'] = sprintf(_("New pagename \"%s\" is not exists!"), $options['name']);
            $formatter->send_header('', $options);
            $formatter->send_title($title, '', $options);
            $formatter->send_footer('', $options);
            return;
        }
    }
    $title = sprintf(_("Fix backlinks of \"%s\" ?"), $options['page']);
    $formatter->send_header('', $options);
    $formatter->send_title($title, '', $options);
    $obtn = _("Old name:");
    $nbtn = _("New name:");
    $pgname = _html_escape($options['page']);
    print "<form method='post'>\n        <table border='0'>\n        <tr><td align='right'>{$obtn} </td><td><b>{$pgname}</b></td></tr>\n        <tr><td align='right'>{$nbtn} </td><td><input name='name' /></td></tr>\n";
    if (!empty($options['value']) and $options['value'] == 'check_backlinks') {
        $button = _("Fix backlinks");
        print "<tr><td colspan='2'>\n";
        print check_backlinks($formatter, $options);
        print "</td></tr>\n";
    } else {
        $button = _("Check backlinks");
    }
    if ($DBInfo->security->is_protected("fixbacklinks", $options)) {
        print "<tr><td align='right'>" . _("Password") . ": </td><td><input type='password' name='passwd' /> " . _("Only WikiMaster can fix backlinks of this page") . "</td></tr>\n";
    }
    if (!empty($options['value']) and $options['value'] == 'check_backlinks') {
        print "<tr><td colspan='2'><input type='checkbox' name='show_only' checked='checked' />" . _("show only") . "</td></tr>\n";
    }
    print "<tr><td></td><td><input type='submit' name='button_fixbacklinks' value='{$button}' />";
    print "<input type='hidden' name='value' value='check_backlinks' />";
    print "</td></tr>\n";
    print "\n        </table>\n        <input type='hidden' name='action' value='fixbacklinks' />\n        </form>";
    $formatter->send_footer('', $options);
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:91,代码来源:fixbacklinks.php

示例13: do_post_DeletePage

function do_post_DeletePage($formatter, $options)
{
    global $DBInfo;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$DBInfo->security->writable($options)) {
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    }
    $page = $DBInfo->getPage($options['page']);
    if (!$page->exists()) {
        $formatter->send_header('', $options);
        $title = _("Page not found.");
        $formatter->send_title($title, '', $options);
        $formatter->send_footer('', $options);
        return;
    }
    // check full permission to edit
    $full_permission = true;
    if (!empty($DBInfo->no_full_edit_permission) or $options['id'] == 'Anonymous' && !empty($DBInfo->anonymous_no_full_edit_permission)) {
        $full_permission = false;
    }
    // members always have full permission to edit
    if (in_array($options['id'], $DBInfo->members)) {
        $full_permission = true;
    }
    if (!$full_permission) {
        $formatter->send_header('', $options);
        $title = _("You do not have full permission to delete this page on this wiki.");
        $formatter->send_title($title, '', $options);
        $formatter->send_footer('', $options);
        return;
    }
    // get the site specific hash code
    $ticket = $page->mtime() . getTicket($DBInfo->user->id, $_SERVER['REMOTE_ADDR']);
    $hash = md5($ticket);
    if (isset($options['name'][0])) {
        $options['name'] = urldecode($options['name']);
    }
    $pagename = $formatter->page->urlname;
    if (isset($options['name'][0]) and $options['name'] == $options['page']) {
        $retval = array();
        $options['retval'] =& $retval;
        $ret = -1;
        // check hash
        if (empty($options['hash'])) {
            $ret = -2;
        } else {
            if ($hash == $options['hash']) {
                $ret = $DBInfo->deletePage($page, $options);
            } else {
                $ret = -3;
            }
        }
        if ($ret == -1) {
            if (!empty($options['retval']['msg'])) {
                $title = $options['retval']['msg'];
            } else {
                $title = sprintf(_("Fail to delete \"%s\""), _html_escape($page->name));
            }
        } else {
            if ($ret == -2) {
                $title = _("Empty hash code !");
            } else {
                if ($ret == -3) {
                    $title = _("Incorrect hash code !");
                } else {
                    $title = sprintf(_("\"%s\" is deleted !"), _html_escape($page->name));
                }
            }
        }
        $myrefresh = '';
        if (!empty($DBInfo->use_save_refresh)) {
            $sec = $DBInfo->use_save_refresh - 1;
            $lnk = $formatter->link_url($formatter->page->urlname, "?action=show");
            $myrefresh = 'Refresh: ' . $sec . '; url=' . qualifiedURL($lnk);
        }
        $formatter->send_header($myrefresh, $options);
        $formatter->send_title($title, "", $options);
        $formatter->send_footer('', $options);
        return;
    } else {
        if (isset($options['name'][0])) {
            #print $options['name'];
            $options['msg'] = _("Please delete this file manually.");
        }
    }
    $title = sprintf(_("Delete \"%s\" ?"), $page->name);
    $formatter->send_header("", $options);
    $formatter->send_title($title, "", $options);
    $btn = _("Summary");
    print "<form method='post'>\n{$btn}: <input name='comment' size='80' value='' /><br />\n";
    if (!empty($DBInfo->delete_history)) {
        print _("with revision history") . " <input type='checkbox' name='history' />\n";
    }
    print "\n<input type=\"hidden\" name=\"hash\" value=\"" . $hash . "\" />\n";
    $pwd = _("Password");
    $btn = _("Delete Page");
    $msg = _("Only WikiMaster can delete this page");
    if ($DBInfo->security->is_protected("DeletePage", $options)) {
        print "{$pwd}: <input type='password' name='passwd' size='20' value='' />\n{$msg}<br />\n";
    }
//.........这里部分代码省略.........
开发者ID:reviforks,项目名称:moniwiki,代码行数:101,代码来源:wikilib.php

示例14: do_sendping

function do_sendping($formatter, $options)
{
    global $DBInfo, $_release;
    if (!$formatter->page->exists()) {
        $options['msg'] = _("Error: Page Not found !");
        do_invalid($formatter, $options);
        return;
    }
    if (strtolower($DBInfo->charset) == 'utf-8') {
        $checked = 'checked="checked"';
    }
    if (!$options['trackback_url']) {
        $url = $formatter->link_url($formatter->page->urlname);
        $raw_body = $formatter->page->_get_raw_body();
        if ($options['value']) {
            $lines = explode("\n", $raw_body);
            $count = count($lines);
            # add comment
            for ($i = 0; $i < $count; $i++) {
                if (preg_match("/^({{{)?#!blog (.*)\$/", $lines[$i], $match)) {
                    if (md5($match[2]) == $options['value']) {
                        list($tag, $user, $date, $title) = explode(" ", $lines[$i], 4);
                        $found = 1;
                        if ($match[1]) {
                            $end_tag = '}}}';
                        }
                        break;
                    }
                }
            }
            if ($found) {
                # a blog page with multiple entries
                $i++;
                if ($end_tag) {
                    for (; $i < $count; $i++) {
                        if (preg_match("/^}}}\$/", $lines[$i])) {
                            break;
                        } else {
                            if (preg_match("/^----\$/", $lines[$i])) {
                                break;
                            }
                        }
                        $excerpt .= $lines[$i] . "\n";
                    }
                } else {
                    # a blog page with a single entry
                    list($dummy, $entry) = explode("\n", $raw_body, 2);
                    list($excerpt, $comments) = explode("\n----\n", $entry, 2);
                }
            } else {
                $options['msg'] = _("Error: No entry found!");
                do_invalid($formatter, $options);
                return;
            }
        } else {
            # a plain wiki page
            $excerpt = substr($raw_body, 0, 400);
            $title = $options['page'];
        }
        $COLS_MSIE = 80;
        $COLS_OTHER = 85;
        $cols = preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) ? $COLS_MSIE : $COLS_OTHER;
        $rows = $options['rows'] > 5 ? $options['rows'] : 8;
        $cols = $options['cols'] > 60 ? $options['cols'] : $cols;
        $formatter->send_header("", $options);
        $formatter->send_title(_("Send TrackBack ping"), "", $options);
        $msg1 = _("TrackBack Ping URL");
        print "<form method='post' action='{$url}'>\n";
        print "<b>{$msg1}</b>: <input name='trackback_url' size='60' maxlength='256' style='width:200' /><br />\n";
        if ($options['value']) {
            $options['value'] = _html_escape($options['value']);
            print "<input type='hidden' name='value' value=\"{$options['value']}\" />\n";
        }
        $msg2 = _("Title");
        $title = _html_escape($title);
        print "<b>{$msg2}</b>: <input name='title' value=\"{$title}\" size='70' maxlength='70' style='width:200' /><br />\n";
        if ($DBInfo->use_resizer > 1) {
            echo <<<JS
<script type="text/javascript" src="{$DBInfo->url_prefix}/local/textarea.js"></script>
JS;
        }
        print <<<FORM
<div class="resizable-textarea" style='position:relative'><!-- IE hack -->
<textarea class="wiki resizable" id="content" wrap="virtual" name="excerpt"
 rows="{$rows}" cols="{$cols}" class="wiki">{$excerpt}</textarea></div>
FORM;
        $mb_msg = _("mb encoded");
        $send_msg = _("Send ping");
        $reset = _("Reset");
        print <<<FORM2
<b>{$mb_msg}</b> <input type="checkbox" name="mbencode" {$checked} />&nbsp;
<input type="hidden" name="action" value="sendping" />
<span class="button"><input class="button" type="submit" value="{$send_msg}" /></span>&nbsp;
<span class="button"><input class="button" type="reset" value="{$reset}" /></span>&nbsp;
</form>
FORM2;
        $formatter->send_footer("", $options);
        return;
    }
    # send Trackback ping
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:sendping.php

示例15: do_comment

function do_comment($formatter, $options = array())
{
    global $DBInfo;
    if (!$DBInfo->security->writable($options)) {
        $formatter->preview = 1;
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    } else {
        if (!$DBInfo->hasPage($options['page'])) {
            $options['err'] = _("You are not allowed to add a comment.");
            $options['title'] = _("Page does not exists");
            return do_invalid($formatter, $options);
        }
    }
    if (!empty($options['usemeta'])) {
        $use_meta = 1;
    }
    $cols = get_textarea_cols();
    $rows = (!empty($options['rows']) and $options['rows'] > 5) ? $options['rows'] : 8;
    $cols = (!empty($options['cols']) and $options['cols'] > 60) ? $options['cols'] : $cols;
    $url = $formatter->link_url($formatter->page->urlname);
    $button_preview = !empty($options['button_preview']) ? $options['button_preview'] : 0;
    $use_any = 0;
    if (!empty($DBInfo->use_textbrowsers)) {
        if (is_string($DBInfo->use_textbrowsers)) {
            $use_any = preg_match('/' . $DBInfo->use_textbrowsers . '/', $_SERVER['HTTP_USER_AGENT']) ? 1 : 0;
        } else {
            $use_any = preg_match('/Lynx|w3m|links/', $_SERVER['HTTP_USER_AGENT']) ? 1 : 0;
        }
    }
    $ok_ticket = 0;
    if (empty($use_any) and !empty($DBInfo->use_ticket) and $options['id'] == 'Anonymous') {
        if ($options['__seed'] and $options['check']) {
            $mycheck = getTicket($options['__seed'], $_SERVER['REMOTE_ADDR'], 4);
            if ($mycheck == $options['check']) {
                $ok_ticket = 1;
            } else {
                $options['msg'] = _("Invalid ticket !");
                $button_preview = 1;
            }
        } else {
            if (!$button_preview) {
                $options['msg'] = _("You need a ticket !");
            }
            $button_preview = 1;
        }
    } else {
        $ok_ticket = 1;
    }
    if ($options['savetext']) {
        $savetext = _stripslashes($options['savetext']);
        $savetext = str_replace("\r", "", $savetext);
        $savetext = rtrim($savetext);
        #$savetext=str_replace("<","&lt;",$savetext);
    }
    if (!empty($savetext) and empty($button_preview) and !empty($DBInfo->spam_filter)) {
        $text = $savetext;
        $fts = preg_split('/(\\||,)/', $DBInfo->spam_filter);
        foreach ($fts as $ft) {
            $text = $formatter->filter_repl($ft, $text, $options);
        }
        if ($text != $savetext) {
            $button_preview = 1;
            $options['msg'] = _("Sorry, can not save page because some messages are blocked in this wiki.");
        }
    }
    if (!empty($button_preview) && !empty($options['savetext'])) {
        if (empty($options['action_mode']) or $options['action_mode'] != 'ajax') {
            $formatter->send_header("", $options);
            $formatter->send_title(_("Preview comment"), "", $options);
            $formatter->send_page($savetext . "\n----");
            $options['savetext'] = $savetext;
            print macro_Comment($formatter, '', $options);
            print $formatter->macro_repl('EditHints');
            $formatter->send_footer("", $options);
        }
        return false;
    } else {
        if (empty($savetext)) {
            if (empty($options['action_mode']) or $options['action_mode'] != 'ajax') {
                $formatter->send_header("", $options);
                $formatter->send_title(_("Add comment"), "", $options);
                print macro_Comment($formatter, '', $options);
                print $formatter->macro_repl('EditHints');
                $formatter->send_footer("", $options);
            }
            return false;
        }
    }
    $datestamp = $options['datestamp'];
    if ($formatter->page->mtime() > $datestamp) {
        $options['msg'] = '';
        if (empty($options['action_mode']) or $options['action_mode'] != 'ajax') {
            $formatter->send_header('', $options);
            $formatter->send_title(_("Error: Don't make a clone!"), '', $options);
            $formatter->send_footer('', $options);
        }
        return false;
    }
    $body = $formatter->page->get_raw_body();
//.........这里部分代码省略.........
开发者ID:NessunKim,项目名称:MW_Skins,代码行数:101,代码来源:Comment.php


注:本文中的do_invalid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。