Example #1
0
function LogWrite($file, $msg, $path = false)
{
    $file_name = ($path !== false ? $patch : '') . LOGDIR . "/" . $file;
    if (!($f = @fopen($file_name, "a"))) {
        throw new Exception("can't open " . $file_name);
    }
    fwrite($f, CTime() . " - " . $msg . "\n");
    fclose($f);
}
Example #2
0
 /**
  * Send mail to user and store the cookie in the db
  * wikiurl?action=ConfirmEmail&id=bla
  */
 function sendEmailConfirmation($email, $userid)
 {
     $id = rand_ascii_readable(16);
     $wikidb = $GLOBALS['request']->getDbh();
     $data = $wikidb->get('ConfirmEmail');
     while (!empty($data[$id])) {
         // id collision
         $id = rand_ascii_readable(16);
     }
     $subject = _("E-Mail address confirmation");
     $ip = $request->get('REMOTE_HOST');
     $expire_date = time() + 7 * 86400;
     $content = fmt("Someone, probably you from IP address %s, has registered an\naccount \"%s\" with this e-mail address on %s.\n\nTo confirm that this account really does belong to you and activate\ne-mail features on %s, open this link in your browser:\n\n%s\n\nIf this is *not* you, don't follow the link. This confirmation code\nwill expire at %s.", $ip, $userid, WIKI_NAME, WIKI_NAME, WikiURL(HOME_PAGE, array('action' => 'ConfirmEmail', 'id' => $id), true), CTime($expire_date));
     $this->sendMail($subject, $content, "", true);
     $data[$id] = array('email' => $email, 'userid' => $userid, 'expire' => $expire_date);
     $wikidb->set('ConfirmEmail', $data);
     return '';
 }
Example #3
0
 function _generate()
 {
     global $WikiTheme, $request;
     $toolbar = "document.writeln(\"<div class=\\\"edit-toolbar\\\" id=\\\"toolbar\\\">\");\n";
     if (ENABLE_EDIT_TOOLBAR) {
         $username = $request->_user->UserName();
         if (FUSIONFORGE or DISABLE_MARKUP_WIKIWORD or !isWikiWord($username)) {
             $username = '******' . $username . ']]';
         }
         $signature = " ––" . $username . " " . CTime();
         $toolarray = array(array("image" => "ed_format_bold.png", "open" => "**", "close" => "**", "sample" => _("Bold text"), "title" => _("Bold text [alt-b]")), array("image" => "ed_format_italic.png", "open" => "//", "close" => "//", "sample" => _("Italic text"), "title" => _("Italic text [alt-i]")), array("image" => "ed_format_strike.png", "open" => "<s>", "close" => "</s>", "sample" => _("Strike-through text"), "title" => _("Strike")), array("image" => "ed_format_color.png", "open" => "%color=green% ", "close" => " %%", "sample" => _("Color text"), "title" => _("Color")), array("image" => "ed_pagelink.png", "open" => "[[", "close" => "]]", "sample" => _("PageName|optional label"), "title" => _("Link to page")), array("image" => "ed_link.png", "open" => "[[", "close" => "]]", "sample" => _("http://www.example.com|optional label"), "title" => _("External link (remember http:// prefix)")), array("image" => "ed_headline.png", "open" => "\\n== ", "close" => " ==\\n", "sample" => _("Headline text"), "title" => _("Level 1 headline")), array("image" => "ed_nowiki.png", "open" => "\\<verbatim\\>\\n", "close" => "\\n\\</verbatim\\>", "sample" => _("Insert non-formatted text here"), "title" => _("Ignore wiki formatting")), array("image" => "ed_sig.png", "open" => $signature, "close" => "", "sample" => "", "title" => _("Your signature")), array("image" => "ed_hr.png", "open" => "\\n----\\n", "close" => "", "sample" => "", "title" => _("Horizontal line")), array("image" => "ed_table.png", "open" => "\\n{| class=\"bordered\"\\n|+ This is the table caption\\n|= This is the table summary\\n|-\\n! Header A !! Header B !! Header C\\n|-\\n| Cell A1 || Cell B1 || Cell C1\\n|-\\n| Cell A2 || Cell B2 || Cell C2\\n|-\\n| Cell A3 || Cell B3 || Cell C3\\n|}\\n", "close" => "", "sample" => "", "title" => _("Sample table")), array("image" => "ed_enumlist.png", "open" => "\\n# Item 1\\n# Item 2\\n# Item 3\\n", "close" => "", "sample" => "", "title" => _("Enumeration")), array("image" => "ed_list.png", "open" => "\\n* Item 1\\n* Item 2\\n* Item 3\\n", "close" => "", "sample" => "", "title" => _("List")), array("image" => "ed_toc.png", "open" => "<<CreateToc with_toclink||=1>>\\n", "close" => "", "sample" => "", "title" => _("Table of Contents")), array("image" => "ed_redirect.png", "open" => "<<RedirectTo page=\"", "close" => "\">>", "sample" => _("Page Name"), "title" => _("Redirect")), array("image" => "ed_templateplugin.png", "open" => "{{", "close" => "}}", "sample" => _("Template Name"), "title" => _("Template")));
         $btn = new SubmitImageButton(_("Save"), "edit[save]", 'toolbar', $WikiTheme->getImageURL("ed_save.png"));
         $btn->addTooltip(_("Save"));
         $btn->setAccesskey("s");
         $toolbar .= 'document.writeln("' . addslashes($btn->asXml()) . '");' . "\n";
         // preview not supported yet on Wikiblog
         if (empty($WikiTheme->_headers_printed)) {
             $btn = new SubmitImageButton(_("Preview"), "edit[preview]", 'toolbar', $WikiTheme->getImageURL("ed_preview.png"));
             $btn->addTooltip(_("Preview"));
             $btn->setAccesskey("p");
             $toolbar .= 'document.writeln("' . addslashes($btn->asXml()) . '");' . "\n";
         }
         foreach ($toolarray as $tool) {
             global $WikiTheme;
             $image = $WikiTheme->getImageURL($tool["image"]);
             $open = $tool["open"];
             $close = $tool["close"];
             $sample = addslashes($tool["sample"]);
             // Note that we use the title both for the ALT tag and the TITLE tag of the image.
             // Older browsers show a "speedtip" type message only for ALT.
             // Ideally these should be different, realistically they
             // probably don't need to be.
             $tool = $WikiTheme->fixAccesskey($tool);
             $title = addslashes($tool["title"]);
             $toolbar .= "addTagButton('{$image}','{$title}','{$open}','{$close}','{$sample}');\n";
         }
         /* Fails with Chrome */
         if (!isBrowserSafari()) {
             $toolbar .= "addInfobox('" . addslashes(_("Click a button to get an example text")) . "');\n";
         }
     }
     if (JS_SEARCHREPLACE) {
         $undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
         //$redo_btn = $WikiTheme->getImageURL("ed_redo.png");
         $sr_btn = $WikiTheme->getImageURL("ed_replace.png");
         //TODO: generalize the UNDO button and fix it for Search & Replace
         $sr_html = HTML(HTML::img(array('class' => "toolbar", 'id' => "sr_undo", 'src' => $undo_d_btn, 'title' => _("Undo Search & Replace"), 'alt' => _("Undo Search & Replace"), 'onclick' => "do_undo()")), HTML::img(array('class' => "toolbar", 'src' => $sr_btn, 'alt' => _("Search & Replace"), 'title' => _("Search & Replace"), 'onclick' => "replace()")));
     } else {
         $sr_html = '';
     }
     //TODO: Delegate this to run-time with showing an hidden input at the right, and do
     // a seperate moacdropdown and xmlrpc:titleSearch.
     // Button to generate categories, display in extra window as popup and insert
     $sr_html = HTML($sr_html, $this->categoriesPulldown());
     // Button to generate plugins, display in extra window as popup and insert
     $sr_html = HTML($sr_html, $this->pluginPulldown());
     // Button to generate pagenames, display in extra window as popup and insert
     if (TOOLBAR_PAGELINK_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->pagesPulldown(TOOLBAR_PAGELINK_PULLDOWN));
     }
     // Button to insert from an template, display pagename in extra window as popup and insert
     if (TOOLBAR_TEMPLATE_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->templatePulldown(TOOLBAR_TEMPLATE_PULLDOWN));
     }
     // Button to add images, display in extra window as popup and insert
     if (TOOLBAR_IMAGE_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->imagePulldown(TOOLBAR_IMAGE_PULLDOWN));
     }
     // don't use document.write for replace, otherwise self.opener is not defined.
     $toolbar_end = "document.writeln(\"</div>\");";
     if ($sr_html) {
         return HTML(Javascript($toolbar), "\n", $sr_html, "\n", Javascript($toolbar_end));
     } else {
         return HTML(Javascript($toolbar . $toolbar_end));
     }
 }
Example #4
0
 private function SystemTemplate($file)
 {
     if (!ereg("/", $file)) {
         $file = $this->path . "/" . $file;
     }
     if (!($f = @fopen($file, "r"))) {
         throw new TemplateExcept("не могу открыть шаблон " . $file);
     }
     $content = fread($f, filesize($file));
     fclose($f);
     $template_arr = preg_split("/\\[\\[([^\\]]*)\\]\\]/", $content, -1, PREG_SPLIT_DELIM_CAPTURE);
     foreach ($template_arr as $k => $v) {
         if ($k % 2 == 0) {
             echo $v;
             continue;
         }
         switch ($v) {
             case "system_info":
                 echo $this->system_info;
                 break;
             case "custom_header":
                 echo $this->custom_header;
                 break;
             case "topic":
                 echo $this->menu->topic;
                 break;
             case "title":
                 echo TITLE;
                 if (strlen($this->menu->topic) > 0) {
                     echo " :: " . $this->menu->topic;
                 }
                 break;
             case "ip":
                 echo $_SESSION[S_ID]["ip_login"];
                 break;
             case "current_time":
                 echo CTime(time());
                 break;
             case "login_time":
                 echo CTime($_SESSION[S_ID]["time_login"]);
                 break;
             case "menu":
                 echo $this->menu->Show();
                 break;
             case "full_name":
                 echo $this->sys_user->full_name == ' ' ? $this->sys_user->login : $this->sys_user->full_name . " (" . $this->sys_user->login . ")";
                 break;
             case "login":
                 echo $this->sys_user->login;
                 break;
             default:
                 echo $v;
         }
     }
 }
Example #5
0
 function _approval_form(&$request, $args, $moderation, $pass = '******')
 {
     $header = HTML::h3(_("Please approve or reject this request:"));
     $loader = new WikiPluginLoader();
     $BackendInfo = $loader->getPlugin("_BackendInfo");
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $content = $table;
     $diff = '';
     if ($moderation['args']['action'] == 'edit') {
         $pagename = $moderation['args']['pagename'];
         $p = $request->_dbi->getPage($pagename);
         $rev = $p->getCurrentRevision(true);
         $curr_content = $rev->getPackedContent();
         $new_content = $moderation['args']['edit']['content'];
         include_once "lib/difflib.php";
         $diff2 = new Diff($curr_content, $new_content);
         $fmt = new UnifiedDiffFormatter();
         $diff = $pagename . " Current Version " . Iso8601DateTime($p->get('mtime')) . "\n";
         $diff .= $pagename . " Edited Version " . Iso8601DateTime($moderation['timestamp']) . "\n";
         $diff .= $fmt->format($diff2);
     }
     $content->pushContent($BackendInfo->_showhash("Request", array('User' => $moderation['userid'], 'When' => CTime($moderation['timestamp']), 'Pagename' => $pagename, 'Action' => $moderation['args']['action'], 'Diff' => HTML::pre($diff))));
     $content_dbg = $table;
     $myargs = $args;
     $BackendInfo->_fixupData($myargs);
     $content_dbg->pushContent($BackendInfo->_showhash("raw request args", $myargs));
     $BackendInfo->_fixupData($moderation);
     $content_dbg->pushContent($BackendInfo->_showhash("raw moderation data", $moderation));
     $reason = HTML::div(_("Reason: "), HTML::textarea(array('name' => 'reason')));
     $approve = Button('submit:ModeratedPage[approve]', _("Approve"), $pass == 'approve' ? 'wikiadmin' : 'button');
     $reject = Button('submit:ModeratedPage[reject]', _("Reject"), $pass == 'reject' ? 'wikiadmin' : 'button');
     $args['action'] = _("ModeratedPage");
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $content, HTML::p(""), $content_dbg, $reason, ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($args), $pass == 'approve' ? HTML::p($approve, $reject) : HTML::p($reject, $approve));
 }