Example #1
0
 function chownPages(&$dbi, &$request, $pages, $newowner)
 {
     $ul = HTML::ul();
     $count = 0;
     foreach ($pages as $name) {
         $page = $dbi->getPage($name);
         if ($owner = $page->getOwner() and $newowner != $owner) {
             if (!mayAccessPage('change', $name)) {
                 $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
             } else {
                 $page->set('owner', $newowner);
                 if ($page->get('owner') === $newowner) {
                     $ul->pushContent(HTML::li(fmt("Chown page '%s' to '%s'.", WikiLink($name), WikiLink($newowner))));
                     $count++;
                 } else {
                     $ul->pushContent(HTML::li(fmt("Couldn't chown page '%s' to '%s'.", WikiLink($name), $newowner)));
                 }
             }
         }
     }
     if ($count) {
         $dbi->touch();
         return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count)));
     } else {
         return HTML($ul, HTML::p(fmt("No pages changed.")));
     }
 }
Example #2
0
 function WikiDB_backend_dba($dbparams)
 {
     $directory = '/tmp';
     $prefix = 'wiki_';
     $dba_handler = 'gdbm';
     $timeout = 20;
     extract($dbparams);
     if ($directory) {
         $directory .= "/";
     }
     $dbfile = $directory . $prefix . 'pagedb' . '.' . $dba_handler;
     // FIXME: error checking.
     $db = new DbaDatabase($dbfile, false, $dba_handler);
     $db->set_timeout($timeout);
     // Workaround for BDB 4.1 bugs
     if (file_exists($dbfile)) {
         $mode = 'w';
     } else {
         $mode = 'c';
     }
     if (!$db->open($mode)) {
         trigger_error(sprintf(_("%s: Can't open dba database"), $dbfile), E_USER_ERROR);
         global $request;
         $request->finish(fmt("%s: Can't open dba database", $dbfile));
     }
     $this->WikiDB_backend_dbaBase($db);
 }
Example #3
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if (!defined('ENABLE_RAW_HTML') || !ENABLE_RAW_HTML) {
         return $this->disabled(_("Raw HTML is disabled in this wiki."));
     }
     if (!$basepage) {
         return $this->error("{$basepage} unset?");
     }
     $page = $request->getPage($basepage);
     if (ENABLE_RAW_HTML_LOCKEDONLY) {
         if (!$page->get('locked')) {
             return $this->disabled(fmt("%s is only allowed in locked pages.", _("Raw HTML")));
         }
     }
     if (ENABLE_RAW_HTML_SAFE) {
         // check for javascript handlers (on*) and style tags with external urls. no javascript urls.
         // See also http://simon.incutio.com/archive/2003/02/23/safeHtmlChecker
         // But we should allow not only code semantic meaning,  presentational markup also.
         // http://chxo.com/scripts/safe_html-test.php looks better
         $argstr = $this->safe_html($argstr);
         /*return $this->disabled(HTML(fmt("This %s plugin on %s is disabled because of unsafe HTML code. ",$this->getName(), $basepage),
                                       fmt("See PhpWiki:allowing%20safe%20HTML")
                                       ));
           */
     }
     return HTML::raw($argstr);
 }
Example #4
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return '';
     }
     $backend =& $dbi->_backend;
     $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $pagedata = $backend->get_pagedata($page);
     if (!$pagedata) {
         // FIXME: invalid HTML
         $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
     } else {
         $this->_fixupData($pagedata);
         $table->pushContent($this->_showhash("get_pagedata('{$page}')", $pagedata));
     }
     for ($version = $backend->get_latest_version($page); $version; $version = $backend->get_previous_version($page, $version)) {
         $vdata = $backend->get_versiondata($page, $version, true);
         $this->_fixupData($vdata);
         $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
     }
     $html->pushContent($table);
     return $html;
 }
Example #5
0
 function purgePages(&$request, $pages)
 {
     $result = HTML::div();
     $ul = HTML::ul();
     $dbi = $request->getDbh();
     $count = 0;
     foreach ($pages as $name) {
         $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name);
         if (mayAccessPage('purge', $name)) {
             $dbi->purgePage($name);
             $ul->pushContent(HTML::li(fmt("Purged page '%s' successfully.", $name)));
             $count++;
         } else {
             $ul->pushContent(HTML::li(fmt("Didn't purge page '%s'. Access denied.", $name)));
         }
     }
     if ($count) {
         $dbi->touch();
         $result->setAttr('class', 'feedback');
         if ($count == 1) {
             $result->pushContent(HTML::p("One page has been permanently purged:"));
         } else {
             $result->pushContent(HTML::p(fmt("%s pages have been permanently purged:", $count)));
         }
         $result->pushContent($ul);
         return $result;
     } else {
         $result->setAttr('class', 'error');
         $result->pushContent(HTML::p("No pages purged."));
         return $result;
     }
 }
Example #6
0
function PurgePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML::p(array('class' => 'error'), _("Sorry, this page does not exist."));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $purgeB = Button('submit:verify', _("Purge Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $fieldset = HTML::fieldset(HTML::p(fmt("You are about to purge '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'purge')), HTML::div(array('class' => 'toolbar'), $purgeB, $WikiTheme->getButtonSeparator(), $cancelB)));
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html = HTML($fieldset, HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::p(array('class' => 'error'), _("Someone has edited the page!")), HTML::p(fmt("Since you started the purge process, someone has saved a new version of %s.  Please check to make sure you still want to permanently purge the page from the database.", $pagelink)));
    } else {
        // Real purge.
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->purgePage($pagename);
        $dbi->touch();
        $html = HTML::div(array('class' => 'feedback'), fmt("Purged page '%s' successfully.", $pagename));
    }
    GeneratePage($html, _("Purge Page"));
}
Example #7
0
 function box($args = false, $request = false, $basepage = false)
 {
     if (!$request) {
         $request =& $GLOBALS['request'];
     }
     $stats = $this->getStats($request->_dbi, $request, 'summary');
     return $this->makeBox(_("Who is online"), HTML(HTML::Raw('· '), WikiLink(_("WhoIsOnline"), 'auto', fmt("%d online users", $stats['NUM_USERS']))));
 }
Example #8
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     // Any text that is returned will not be further transformed,
     // so use html where necessary.
     $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END);
     return $html;
 }
Example #9
0
function RemovePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML(HTML::h2(_("Already deleted")), HTML::p(_("Sorry, this page is not in the database.")));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $removeB = Button('submit:verify', _("Remove Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $html = HTML(HTML::h2(fmt("You are about to remove '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'remove')), HTML::div(array('class' => 'toolbar'), $removeB, $WikiTheme->getButtonSeparator(), $cancelB)), HTML::hr());
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html->pushContent(HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::h2(_("Someone has edited the page!")), HTML::p(fmt("Since you started the deletion process, someone has saved a new version of %s.  Please check to make sure you still want to permanently remove the page from the database.", $pagelink)));
    } else {
        // Codendi specific: remove the deleted wiki page from ProjectWantedPages
        $projectPageName = 'ProjectWantedPages';
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        require_once PHPWIKI_DIR . "/lib/loadsave.php";
        $pagehandle = $dbi->getPage($projectPageName);
        if ($pagehandle->exists()) {
            // don't replace default contents
            $current = $pagehandle->getCurrentRevision();
            $version = $current->getVersion();
            $text = $current->getPackedContent();
            $meta = $current->_data;
        }
        $text = str_replace("* [{$pagename}]", "", $text);
        $meta['summary'] = $GLOBALS['Language']->getText('wiki_lib_wikipagewrap', 'page_added', array($pagename));
        $meta['author'] = user_getname();
        $pagehandle->save($text, $version + 1, $meta);
        //Codendi specific: remove permissions for this page @codenditodo: may be transferable otherwhere.
        require_once 'common/wiki/lib/WikiPage.class.php';
        $wiki_page = new WikiPage(GROUP_ID, $_REQUEST['pagename']);
        $wiki_page->resetPermissions();
        // Real delete.
        //$pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->deletePage($pagename);
        $dbi->touch();
        $link = HTML::a(array('href' => 'javascript:history.go(-2)'), _("Back to the previous page."));
        $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)), HTML::div($link), HTML::hr());
    }
    GeneratePage($html, _("Remove Page"));
}
Example #10
0
 public function getHtmlFields()
 {
     $this->notifyUrl .= "&processor=jcc";
     $this->returnUrl .= "&processor=jcc";
     //Version
     $version = "1.0.0";
     //Merchant ID
     $merchantID = $this->merchantId;
     //Acquirer ID
     $acquirerID = $this->acquirerId;
     //The SSL secured URL of the merchant to which JCC will send the transaction result
     //This should be SSL enabled – note https:// NOT http://
     //Purchase Amount
     $purchaseAmt = fmt($this->amount);
     //Pad the purchase amount with 0's so that the total length is 13 characters, i.e. 20.50 will become 0000000020.50
     $purchaseAmt = str_pad($purchaseAmt, 13, "0", STR_PAD_LEFT);
     //Remove the dot (.) from the padded purchase amount(JCC will know from currency how many digits to	consider as decimal)
     //0000000020.50 will become 000000002050 (notice there is no dot)
     $formattedPurchaseAmt = substr($purchaseAmt, 0, 10) . substr($purchaseAmt, 11);
     //Euro currency ISO Code; see relevant appendix for ISO codes of other currencies
     $currency = 978;
     //The number of decimal points for transaction currency, i.e. in this example we indicate that Euro has 2 decimal points
     $currencyExp = 2;
     //Order number
     $orderID = $this->itemNumber;
     //Specify we want not only to authorize the amount but also capture at the same time. Alternative value	could be M (for capturing later)
     $captureFlag = "A";
     //Password
     $password = $this->password;
     //Form the plaintext string to encrypt by concatenating Password, Merchant ID, Acquirer ID, Order ID,Formatter Purchase Amount and Currency
     //This will give 1234abcd | 0011223344 | 402971 | TestOrder12345 | 000000002050 | 978 (spaces and |	introduced here for clarity)
     $toEncrypt = $password . $merchantID . $acquirerID . $orderID . $formattedPurchaseAmt . $currency;
     //Produce the hash using SHA1
     //This will give b14dcc7842a53f1ec7a621e77c106dfbe8283779
     $sha1Signature = sha1($toEncrypt);
     //Encode the signature using Base64 before transmitting to JCC
     //This will give sU3MeEKlPx7HpiHnfBBt++goN3k=
     $base64Sha1Signature = base64_encode(pack("H*", $sha1Signature));
     //The name of the hash algorithm use to create the signature; can be MD5 or SHA1; the latter is preffered and is what we used in this example
     $signatureMethod = "SHA1";
     $html = '';
     $html .= sprintf('<input type="hidden" name="Version" value="%s"/>', $version);
     $html .= sprintf('<input type="hidden" name="MerID" value="%s"/>', $merchantID);
     $html .= sprintf('<input type="hidden" name="AcqID" value="%s"/>', $acquirerID);
     $html .= sprintf('<input type="hidden" name="MerRespURL" value="%s"/>', $this->notifyUrl);
     $html .= sprintf('<input type="hidden" name="PurchaseAmt" value="%s"/>', $formattedPurchaseAmt);
     $html .= sprintf('<input type="hidden" name="PurchaseCurrency" value="%s"/>', $currency);
     $html .= sprintf('<input type="hidden" name="PurchaseCurrencyExponent" value="%s"/>', $currencyExp);
     $html .= sprintf('<input type="hidden" name="OrderID" value="%s"/>', $orderID);
     $html .= sprintf('<input type="hidden" name="CaptureFlag" value="%s"/>', $captureFlag);
     $html .= sprintf('<input type="hidden" name="Signature" value="%s"/>', $base64Sha1Signature);
     $html .= sprintf('<input type="hidden" name="SignatureMethod" value="%s"/>', $signatureMethod);
     //echo $html; exit;
     return $html;
 }
Example #11
0
 function checkname()
 {
     $name = isset($_POST['name']) ? $_POST['name'] : "";
     $name = fmt($name);
     $data = $this->find("user_name=" . $name, "users");
     if (!empty($data)) {
         echo "用户名已存在";
     } else {
         echo "OK";
     }
 }
Example #12
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return $this->error("page missing");
     }
     $backend =& $dbi->_backend;
     $this->chunk_split = true;
     $this->readonly_pagemeta = array();
     $this->hidden_pagemeta = array('_cached_html');
     $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $pagedata = $backend->get_pagedata($page);
     if (!$pagedata) {
         // FIXME: invalid HTML
         $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
     } else {
         $this->_fixupData($pagedata);
         $table->pushContent($this->_showhash("get_pagedata('{$page}')", $pagedata));
     }
     if (!$notallversions) {
         $version = $backend->get_latest_version($page);
         $vdata = $backend->get_versiondata($page, $version, true);
         $this->_fixupData($vdata);
         $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
     } else {
         for ($version = $backend->get_latest_version($page); $version; $version = $backend->get_previous_version($page, $version)) {
             $vdata = $backend->get_versiondata($page, $version, true);
             $this->_fixupData($vdata);
             $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
             $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
         }
     }
     $linkdata = $backend->get_links($page, false);
     if ($linkdata->count()) {
         $table->pushContent($this->_showhash("get_links('{$page}')", $linkdata->asArray()));
     }
     $relations = $backend->get_links($page, false, false, false, false, false, true);
     if ($relations->count()) {
         $table->pushContent($this->_showhash("get_relations('{$page}')", array()));
         while ($rel = $relations->next()) {
             $table->pushContent($this->_showhash(false, $rel));
         }
     }
     $linkdata = $backend->get_links($page, true);
     if ($linkdata->count()) {
         $table->pushContent($this->_showhash("get_backlinks('{$page}')", $linkdata->asArray()));
     }
     $html->pushContent($table);
     return $html;
 }
Example #13
0
 function showNotify(&$request, $messages, $page, $pagelist, $verified)
 {
     $isNecessary = !$this->contains($pagelist, $page);
     $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs(), false, array('verify')), $messages, HTML::p(_("Your current watchlist: "), $this->showWatchList($pagelist)));
     if ($isNecessary) {
         $form->pushContent(HTML::p(_("New watchlist: "), $this->showWatchList($this->addpagelist($page, $pagelist))), HTML::p(sprintf(_("Do you %s want to add this page \"%s\" to your WatchList?"), $verified ? _("really") : "", $page)), HTML::p(Button('submit:add', _("Yes")), HTML::Raw('&nbsp;'), Button('submit:cancel', _("Cancel"))));
     } else {
         $form->pushContent(HTML::p(fmt("The page %s is already watched!", $page)), HTML::p(Button('submit:edit', _("Edit")), HTML::Raw('&nbsp;'), Button('submit:cancel', _("Cancel"))));
     }
     $fieldset = HTML::fieldset(HTML::legend("Watch Page"), $form);
     return $fieldset;
 }
Example #14
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page) && empty($prefix) && empty($suffix)) {
         return '';
     }
     if ($prefix) {
         $suffix = false;
         $descrip = fmt("Page names with prefix '%s'", $prefix);
     } elseif ($suffix) {
         $descrip = fmt("Page names with suffix '%s'", $suffix);
     } elseif ($page) {
         $words = preg_split('/[\\s:-;.,]+/', SplitPagename($page));
         $words = preg_grep('/\\S/', $words);
         $prefix = reset($words);
         $suffix = end($words);
         $descrip = fmt("These pages share an initial or final title word with '%s'", WikiLink($page, 'auto'));
     }
     // Search for pages containing either the suffix or the prefix.
     $search = $match = array();
     if (!empty($prefix)) {
         $search[] = $this->_quote($prefix);
         $match[] = '^' . preg_quote($prefix, '/');
     }
     if (!empty($suffix)) {
         $search[] = $this->_quote($suffix);
         $match[] = preg_quote($suffix, '/') . '$';
     }
     if ($search) {
         $query = new TextSearchQuery(join(' OR ', $search));
     } else {
         $query = new NullTextSearchQuery();
     }
     // matches nothing
     $match_re = '/' . join('|', $match) . '/';
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption($descrip);
     }
     $pages = $dbi->titleSearch($query);
     while ($page = $pages->next()) {
         $name = $page->getName();
         if (!preg_match($match_re, $name)) {
             continue;
         }
         $pagelist->addPage($page);
     }
     return $pagelist;
 }
Example #15
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if ($args['basepage']) {
         $pagename = $args['basepage'];
     } else {
         $pagename = $request->getArg('pagename');
     }
     // FIXME: explodePageList from stdlib doesn't seem to work as
     // expected when there are no subpages. (see also
     // UnfoldSubPages plugin)
     $subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*');
     if (!$subpages) {
         return $this->error(_("The current page has no subpages defined."));
     }
     extract($args);
     $content = HTML();
     $subpages = array_reverse($subpages);
     if ($maxpages) {
         $subpages = array_slice($subpages, 0, $maxpages);
     }
     $descrip = fmt("SubPages of %s:", WikiLink($pagename, 'auto'));
     if ($info) {
         $info = explode(",", $info);
         if (in_array('count', $info)) {
             $args['types']['count'] = new _PageList_Column_ListSubpages_count('count', _("#"), 'center');
         }
     }
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption($descrip);
     }
     foreach ($subpages as $page) {
         // A page cannot include itself. Avoid doublettes.
         static $included_pages = array();
         if (in_array($page, $included_pages)) {
             $content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"), $page)));
             continue;
         }
         array_push($included_pages, $page);
         //if ($relative) {
         // TODO: add relative subpage name display to PageList class
         //}
         $pagelist->addPage($page);
         array_pop($included_pages);
     }
     $content->pushContent($pagelist);
     return $content;
 }
Example #16
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if ($Longitude === '') {
         return $this->error(fmt("%s parameter missing", "'Longitude'"));
     }
     if ($Latitude === '') {
         return $this->error(fmt("%s parameter missing", "'Latitude'"));
     }
     $maps = JavaScript('', array('src' => "http://maps.google.com/maps?file=api&v=1&key=" . GOOGLE_LICENSE_KEY));
     $id = GenerateId("googlemap");
     switch ($MapType) {
         case "Satellite":
             $type = "_SATELLITE_TYPE";
             break;
         case "Map":
             $type = "_MAP_TYPE";
             break;
         case "Hybrid":
             $type = "_HYBRID_TYPE";
             break;
         default:
             return $this->error(sprintf(_("invalid argument %s"), $MapType));
     }
     $div = HTML::div(array('id' => $id, 'style' => 'width: ' . $width . '; height: ' . $height));
     // TODO: Check for multiple markers or polygons
     if (!$InfoText) {
         $Marker = false;
     }
     // Create a marker whose info window displays the given text
     if ($Marker) {
         if ($InfoText) {
             include_once "lib/BlockParser.php";
             $page = $dbi->getPage($request->getArg('pagename'));
             $rev = $page->getCurrentRevision(false);
             $markup = $rev->get('markup');
             $markertext = TransformText($InfoText, $markup, $basepage);
         }
         $markerjs = JavaScript("\nfunction createMarker(point, text) {\n  var marker = new GMarker(point);\n  var html = text + \"<br><br><font size='-1'>[" . _("new&nbsp;window") . "]</font>\";\n  GEvent.addListener(marker, \"click\", function() {marker.openInfoWindowHtml(html);});\n  return marker;\n}");
     }
     $run = JavaScript("\nvar map = new GMap(document.getElementById('" . $id . "'));\n" . ($SmallMapControl ? "map.addControl(new GSmallMapControl());\n" : "map.addControl(new GLargeMapControl());\n") . "\nmap.addControl(new GMapTypeControl());\nmap.centerAndZoom(new GPoint(" . $Longitude . ", " . $Latitude . "), " . $ZoomFactor . ");\nmap.setMapType(" . $type . ");" . ($Marker ? "\nvar point = new GPoint(" . $Longitude . "," . $Latitude . ");\nvar marker = createMarker(point, '" . $markertext->asXml() . "'); map.addOverlay(marker);" : ""));
     if ($Marker) {
         return HTML($markerjs, $maps, $div, $run);
     } else {
         return HTML($maps, $div, $run);
     }
 }
Example #17
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $h = HTML();
     $this->_generatePageheader($info, $h);
     if (!REQUIRE_ADMIN || $request->_user->isadmin()) {
         $h->pushContent(HTML::h2(_("Plugins")));
         $table = HTML::table(array('class' => "pagelist"));
         $this->_generateColheadings($info, $table);
         $this->_generateTableBody($info, $dbi, $request, $table);
         $h->pushContent($table);
     } else {
         $h->pushContent(fmt("You must be an administrator to %s.", _("use this plugin")));
     }
     return $h;
 }
Example #18
0
 function chownPages(&$dbi, &$request, $pages, $newowner)
 {
     $result = HTML::div();
     $ul = HTML::ul();
     $count = 0;
     foreach ($pages as $name) {
         $page = $dbi->getPage($name);
         $current = $page->getCurrentRevision();
         if ($owner = $page->getOwner() and $newowner != $owner) {
             if (!mayAccessPage('change', $name)) {
                 $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
             } else {
                 $version = $current->getVersion();
                 $meta = $current->_data;
                 $text = $current->getPackedContent();
                 $meta['summary'] = "Change page owner from '" . $owner . "' to '" . $newowner . "'";
                 $meta['is_minor_edit'] = 1;
                 $meta['author'] = $request->_user->UserName();
                 unset($meta['mtime']);
                 // force new date
                 $page->set('owner', $newowner);
                 $page->save($text, $version + 1, $meta);
                 if ($page->get('owner') === $newowner) {
                     $ul->pushContent(HTML::li(fmt("Change owner of page '%s' to '%s'.", WikiLink($name), WikiLink($newowner))));
                     $count++;
                 } else {
                     $ul->pushContent(HTML::li(fmt("Could not change owner of page '%s' to '%s'.", WikiLink($name), $newowner)));
                 }
             }
         }
     }
     if ($count) {
         $dbi->touch();
         $result->setAttr('class', 'feedback');
         if ($count == 1) {
             $result->pushContent(HTML::p("One page has been permanently changed:"));
         } else {
             $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count)));
         }
         $result->pushContent($ul);
         return $result;
     } else {
         $result->setAttr('class', 'error');
         $result->pushContent(HTML::p("No pages changed."));
         return $result;
     }
 }
Example #19
0
 /**
  * Create a new query.
  *
  * @param $search_query string The query.  Syntax is as described above.
  * Note that an empty $search_query will match anything.
  * @param $case_exact boolean
  * @param $regex string one of 'auto', 'none', 'glob', 'posix', 'pcre', 'sql'
  * @see TextSearchQuery
  */
 function TextSearchQuery($search_query, $case_exact = false, $regex = 'auto')
 {
     if ($regex == 'none' or !$regex) {
         $this->_regex = 0;
     } elseif (defined("TSQ_REGEX_" . strtoupper($regex))) {
         $this->_regex = constant("TSQ_REGEX_" . strtoupper($regex));
     } else {
         trigger_error(fmt("Unsupported argument: %s=%s", 'regex', $regex));
         $this->_regex = 0;
     }
     $this->_case_exact = $case_exact;
     $parser = new TextSearchQuery_Parser();
     $this->_tree = $parser->parse($search_query, $case_exact, $this->_regex);
     $this->_optimize();
     // broken under certain circumstances: "word -word -word"
     $this->_stoplist = '(A|An|And|But|By|For|From|In|Is|It|Of|On|Or|The|To|With)';
 }
Example #20
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     $href = $args['href'];
     $page = $args['page'];
     if ($href) {
         // If URL is urlencoded, decode it.
         if (strpos('%', $href) !== false) {
             $href = urldecode($href);
         }
         $url = strip_tags($href);
         if ($url != $href) {
             // URL contains tags
             return $this->disabled(_("Illegal characters in external URL."));
         }
         $thispage = $request->getPage();
         if (!$thispage->get('locked')) {
             return $this->disabled(_("Redirect to an external URL is only allowed in locked pages."));
         }
     } else {
         if ($page) {
             $url = WikiURL($page, array('redirectfrom' => $request->getArg('pagename')), 'abs_path');
         } else {
             return $this->error(_("'href' or 'page' parameter missing."));
         }
     }
     if ($page == $request->getArg('pagename')) {
         return $this->error(fmt("Recursive redirect to self: '%s'", $url));
     }
     if ($request->getArg('action') != 'browse') {
         return $this->disabled("(action != 'browse')");
     }
     $redirectfrom = $request->getArg('redirectfrom');
     if ($redirectfrom !== false) {
         if ($redirectfrom) {
             return $this->disabled(_("Double redirect not allowed."));
         } else {
             // Got here by following the "Redirected from ..." link
             // on a browse page.
             return $this->disabled(_("Viewing redirecting page."));
         }
     }
     return $request->redirect($url);
 }
Example #21
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (strstr($sortby, 'mtime')) {
         trigger_error(_("sortby=mtime not supported with MostPopular"), E_USER_WARNING);
         $sortby = '';
     }
     $columns = $info ? explode(",", $info) : array();
     array_unshift($columns, 'hits');
     if (!$request->getArg('count')) {
         //$args['count'] = $dbi->numPages(false,$exclude);
         $allpages = $dbi->mostPopular(0, $sortby);
         $args['count'] = $allpages->count();
     } else {
         $args['count'] = $request->getArg('count');
     }
     //$dbi->touch();
     $pages = $dbi->mostPopular($limit, $sortby);
     $pagelist = new PageList($columns, $exclude, $args);
     while ($page = $pages->next()) {
         $hits = $page->get('hits');
         // don't show pages with no hits if most popular pages wanted
         if ($hits == 0 && $limit > 0) {
             break;
         }
         $pagelist->addPage($page);
     }
     $pages->free();
     if (!$noheader) {
         if ($limit > 0) {
             $pagelist->setCaption(fmt("The %d most popular pages of this wiki:", $limit));
         } else {
             if ($limit < 0) {
                 $pagelist->setCaption(fmt("The %d least popular pages of this wiki:", -$limit));
             } else {
                 $pagelist->setCaption(_("Visited pages on this wiki, ordered by popularity:"));
             }
         }
     }
     return $pagelist;
 }
Example #22
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $pagename = $page;
     $page = $request->getPage();
     $current = $page->getCurrentRevision();
     if ($current->getVersion() < 1) {
         return fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown'));
     }
     if (!empty($version)) {
         if (!($revision = $page->getRevision($version))) {
             NoSuchRevision($request, $page, $version);
         }
     } else {
         $revision = $current;
     }
     $template = new Template('info', $request, array('revision' => $revision));
     return $template;
 }
Example #23
0
 function setExternalPages(&$dbi, &$request, $pages)
 {
     $result = HTML::div();
     $ul = HTML::ul();
     $count = 0;
     foreach ($pages as $name) {
         $page = $dbi->getPage($name);
         $current = $page->getCurrentRevision();
         $external = $current->get('external');
         if (!$external) {
             $external = 0;
         }
         $external = (bool) $external;
         if (!$external) {
             if (!mayAccessPage('change', $name)) {
                 $result->setAttr('class', 'error');
                 $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.", WikiLink($name))));
             } else {
                 $version = $current->getVersion();
                 $page->set('external', (bool) 1);
                 $ul->pushContent(HTML::li(fmt("change page '%s' to external.", WikiLink($name))));
                 $count++;
             }
         }
     }
     if ($count) {
         $dbi->touch();
         $result->setAttr('class', 'feedback');
         if ($count == 1) {
             $result->pushContent(HTML::p("One page has been permanently changed:"));
         } else {
             $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count)));
         }
         $result->pushContent($ul);
         return $result;
     } else {
         $result->setAttr('class', 'error');
         $result->pushContent(HTML::p("No pages changed."));
         return $result;
     }
 }
Example #24
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request, false);
     $page =& $args['page'];
     if (ENABLE_AJAX) {
         if ($args['state']) {
             $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
         } else {
             $html = HTML(HTML::p(array('class' => 'transclusion-title'), fmt(" %s :", WikiLink($page))), HTML::div(array('class' => 'transclusion'), ''));
         }
         $ajaxuri = WikiURL($page, array('format' => 'xml'));
     } else {
         $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
     }
     $header = $html->_content[0];
     $body = $html->_content[1];
     $id = 'DynInc-' . MangleXmlIdentifier($page);
     $body->setAttr('id', $id . '-body');
     $png = $WikiTheme->_findData('images/folderArrow' . ($args['state'] ? 'Open' : 'Closed') . '.png');
     $icon = HTML::img(array('id' => $id . '-img', 'src' => $png, 'onclick' => ENABLE_AJAX ? "showHideAsync('" . $ajaxuri . "','{$id}')" : "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show")));
     $header = HTML::p(array('class' => 'transclusion-title', 'style' => "text-decoration: none;"), $icon, fmt(" %s :", WikiLink($page)));
     if ($args['state']) {
         // show base
         $body->setAttr('style', 'display:block');
         return HTML($header, $body);
     } else {
         // do not show base
         $body->setAttr('style', 'display:none');
         if (ENABLE_AJAX) {
             return HTML($header, $body);
         } else {
             return HTML($header, $body);
         }
         // sync (load but display:none)
     }
 }
Example #25
0
 function chmarkupPages(&$dbi, &$request, $pages, $newmarkup)
 {
     $ul = HTML::ul();
     $count = 0;
     foreach ($pages as $name) {
         $page = $dbi->getPage($name);
         $current = $page->getCurrentRevision();
         $markup = $current->get('markup');
         if (!$markup or $newmarkup != $markup) {
             if (!mayAccessPage('change', $name)) {
                 $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
             } else {
                 $version = $current->getVersion();
                 $meta = $current->_data;
                 $meta['markup'] = $newmarkup;
                 // convert text?
                 $text = $current->getPackedContent();
                 $meta['summary'] = sprintf(_("WikiAdminMarkup from %s to %s"), $markup, $newmarkup);
                 $page->save($text, $version + 1, $meta);
                 $current = $page->getCurrentRevision();
                 if ($current->get('markup') === $newmarkup) {
                     $ul->pushContent(HTML::li(fmt("change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup)));
                     $count++;
                 } else {
                     $ul->pushContent(HTML::li(fmt("Couldn't change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup)));
                 }
             }
         }
     }
     if ($count) {
         $dbi->touch();
         return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count)));
     } else {
         return HTML($ul, HTML::p(fmt("No pages changed.")));
     }
 }
Example #26
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return '';
     }
     $html = HTML(HTML::h3(fmt("Retransform page '%s'", $page)));
     // bypass WikiDB and cache, go directly through the backend.
     $backend =& $dbi->_backend;
     //$pagedata = $backend->get_pagedata($page);
     $version = $backend->get_latest_version($page);
     $vdata = $backend->get_versiondata($page, $version, true);
     include_once 'lib/PageType.php';
     $formatted = new TransformedText($dbi->getPage($page), $vdata['%content'], $vdata);
     $content =& $formatted->_content;
     $html->pushContent($this->_DebugPrintArray($content));
     $links = $formatted->getWikiPageLinks();
     if (count($links) > 0) {
         $html->pushContent(HTML::h3("Links"));
         $html->pushContent($this->_DebugPrintArray($links));
     }
     return $html;
 }
Example #27
0
 function chmodPages(&$dbi, &$request, $pages, $permstring)
 {
     $ul = HTML::ul();
     $count = 0;
     $acl = chmodHelper($permstring);
     if ($perm = new PagePermission($acl)) {
         foreach ($pages as $name) {
             if ($perm->store($dbi->getPage($name))) {
                 $ul->pushContent(HTML::li(fmt("chmod page '%s' to '%s'.", $name, $permstring)));
                 $count++;
             } else {
                 $ul->pushContent(HTML::li(fmt("Couldn't chmod page '%s' to '%s'.", $name, $permstring)));
             }
         }
     } else {
         $ul->pushContent(HTML::li(fmt("Invalid chmod string")));
     }
     if ($count) {
         $dbi->touch();
         return HTML($ul, HTML::p(fmt("%s pages have been changed.", $count)));
     } else {
         return HTML($ul, HTML::p(fmt("No pages changed.")));
     }
 }
Example #28
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (empty($args['s']) and isset($request->_searchhighlight)) {
         $args['s'] = $request->_searchhighlight['query'];
     }
     if (empty($args['s'])) {
         return '';
     }
     extract($args);
     $html = HTML();
     if (!$noheader and isset($request->_searchhighlight)) {
         $engine = $request->_searchhighlight['engine'];
         $html->pushContent(HTML::div(array('class' => 'search-context'), fmt("%s: Found %s through %s", $basepage, $request->_searchhighlight['query'], $engine)));
     }
     if ($hits) {
         $query = new TextSearchQuery($s, $case_exact, $regex);
         $lines = array();
         $hilight_re = $query->getHighlightRegexp();
         $page = $request->getPage();
         $html->pushContent($this->showhits($page, $hilight_re));
     }
     return $html;
 }
Example #29
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (empty($args['url'])) {
         return '';
     }
     extract($args);
     $posted = $GLOBALS['HTTP_POST_VARS'];
     if (in_array('url', array_keys($posted))) {
         $s = $posted['s'];
         $this->_url = $posted['url'];
         $this->_getInterWikiUrl($request);
         if (strstr($this->_url, '%s')) {
             $this->_url = sprintf($this->_url, $s);
         } else {
             $this->_url .= $s;
         }
         if (defined('DEBUG') && DEBUG && $debug) {
             trigger_error("redirect url: " . $this->_url);
         } else {
             $request->redirect($this->_url);
             //no return!
         }
     }
     $this->_name = $name;
     $this->_s = $s;
     if ($formsize < 1) {
         $formsize = 30;
     }
     $this->_url = $url;
     $this->_getInterWikiUrl($request);
     $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), HiddenInputs(array('pagename' => $basepage)));
     $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'url', 'value' => $this->_url)));
     $s = HTML::input(array('type' => 'text', 'value' => $this->_s, 'name' => 's', 'size' => $formsize));
     if (!empty($args["useimage"])) {
         //FIXME: This does not work with Gecko
         $button = HTML::img(array('src' => $useimage, 'alt' => 'imagebutton'));
         if (!empty($width)) {
             $button->setAttr('width', $width);
         }
         if (!empty($height)) {
             $button->setAttr('height', $height);
         }
         // on button_position => none display no input form
         if ($button_position == 'right') {
             $form->pushContent($s);
         }
         $form->pushContent(HTML::button(array('type' => 'button', 'class' => 'button', 'value' => $this->_name), $button));
         if ($button_position == 'left') {
             $form->pushContent($s);
         }
     } else {
         if ($button_position != 'left' and $button_position != 'right') {
             return $this->error(fmt("Invalid argument: %s=%s", 'button_position', $button_position));
         }
         $button = HTML::input(array('type' => 'submit', 'class' => 'button', 'value' => $this->_name));
         if ($button_position == 'left') {
             $form->pushContent($button);
             $form->pushContent($s);
         } elseif ($button_position == 'right') {
             $form->pushContent($s);
             $form->pushContent($button);
         }
     }
     return $form;
 }
Example #30
0
 function handleAction()
 {
     $action = $this->getArg('action');
     if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse') {
         $page = $this->getPage();
         if ($page->get('moderation')) {
             require_once "lib/WikiPlugin.php";
             $loader = new WikiPluginLoader();
             $plugin = $loader->getPlugin("ModeratedPage");
             if ($plugin->handler($this, $page)) {
                 $CONTENT = HTML::div(array('class' => 'wiki-edithelp'), fmt("%s: action forwarded to a moderator.", $action), HTML::br(), _("This action requires moderator approval. Please be patient."));
                 if (!empty($plugin->_tokens['CONTENT'])) {
                     $plugin->_tokens['CONTENT']->pushContent(HTML::br(), _("You must wait for moderator approval."));
                 } else {
                     $plugin->_tokens['CONTENT'] = $CONTENT;
                 }
                 require_once "lib/Template.php";
                 $title = WikiLink($page->getName());
                 $title->pushContent(' : ', WikiLink(_("ModeratedPage")));
                 GeneratePage(Template('browse', $plugin->_tokens), $title, $page->getCurrentRevision());
                 $this->finish();
             }
         }
     }
     $method = "action_{$action}";
     if (method_exists($this, $method)) {
         $this->{$method}();
     } elseif ($page = $this->findActionPage($action)) {
         $this->actionpage($page);
     } else {
         $this->finish(fmt("%s: Bad action", $action));
     }
 }