function run($dbi, $argstr, &$request, $basepage) { $request->setArg('action', false); $args = $this->getArgs($argstr, $request); extract($args); if ($goto = $request->getArg('goto')) { // The user has pressed 'Go'; process request $request->setArg('goto', false); $target = $goto['target']; if ($dbi->isWikiPage($target)) { $url = WikiURL($target, 0, 1); } else { $url = WikiURL($target, array('action' => 'edit'), 1); } $request->redirect($url); // User should see nothing after redirect return ''; } $action = $request->getURLtoSelf(); $form = HTML::form(array('action' => $action, 'method' => 'post')); $form->pushContent(HiddenInputs($request->getArgs())); $textfield = HTML::input(array('type' => 'text', 'size' => $size, 'name' => 'goto[target]')); $button = Button('submit:goto[go]', _("Go"), false); $form->pushContent($textfield, $button); return $form; }
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")); }
function run($dbi, $argstr, &$request, $basepage) { /* plugin not yet has arguments - save for later (copied from UpLoad) $args = $this->getArgs($argstr, $request); extract($args); */ $form = HTML::form(array('action' => $request->getPostURL(), 'enctype' => 'multipart/form-data', 'method' => 'post')); $contents = HTML::div(array('class' => 'wikiaction')); $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => MAX_UPLOAD_SIZE))); $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => '50'))); $contents->pushContent(HTML::raw(" ")); $contents->pushContent(HTML::input(array('value' => _("Convert"), 'type' => 'submit'))); $form->pushContent($contents); $message = HTML(); $userfile = $request->getUploadedFile('userfile'); if ($userfile) { $userfile_name = $userfile->getName(); $userfile_name = basename($userfile_name); $userfile_tmpname = $userfile->getTmpName(); if (!preg_match("/(\\.html|\\.htm)\$/i", $userfile_name)) { $message->pushContent(_("Only files with extension HTML are allowed"), HTML::br(), HTML::br()); } else { $message->pushContent(_("Processed {$userfile_name}"), HTML::br(), HTML::br()); $message->pushContent(_("Copy the output below and paste it into your Wiki page."), HTML::br()); $message->pushContent($this->_process($userfile_tmpname)); } } else { $message->pushContent(HTML::br(), HTML::br()); } $result = HTML(); $result->pushContent($form); $result->pushContent($message); return $result; }
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")); }
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(' '), 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(' '), Button('submit:cancel', _("Cancel")))); } $fieldset = HTML::fieldset(HTML::legend("Watch Page"), $form); return $fieldset; }
function run($dbi, $argstr, &$request, $basepage) { /* ignore fatal on loading */ /* global $ErrorManager; $ErrorManager->pushErrorHandler(new WikiMethodCb($this,'_error_handler')); */ // Require the XML_FOAF_Parser class. This is a pear library not included with phpwiki. // see doc/README.foaf if (findFile('XML/FOAF/Parser.php', 'missing_ok')) { require_once 'XML/FOAF/Parser.php'; } //$ErrorManager->popErrorHandler(); if (!class_exists('XML_FOAF_Parser')) { return $this->error(_("required pear library XML/FOAF/Parser.php not found in include_path")); } extract($this->getArgs($argstr, $request)); // Get our FOAF File from the foaf plugin argument or $_GET['foaf'] if (empty($foaf)) { $foaf = $request->getArg('foaf'); } $chooser = HTML::form(array('method' => 'get', 'action' => $request->getURLtoSelf()), HTML::h4(_("FOAF File URI")), HTML::input(array('id' => 'foaf', 'name' => 'foaf', 'type' => 'text', 'size' => '80', 'value' => $foaf)), HTML::br(), HTML::input(array('id' => 'pretty', 'name' => 'pretty', 'type' => 'radio', 'checked' => 'checked'), _("Pretty HTML")), HTML::input(array('id' => 'original', 'name' => 'original', 'type' => 'radio'), _("Original URL (Redirect)")), HTML::br(), HTML::input(array('type' => 'submit', 'value' => _("Parse FOAF")))); if (empty($foaf)) { return $chooser; } else { //Error Checking if (substr($foaf, 0, 7) != "http://") { return $this->error(_("foaf must be a URI starting with http://")); } // Start of output if (!empty($original)) { $request->redirect($foaf); } else { $foaffile = url_get_contents($foaf); if (!$foaffile) { //TODO: get errormsg return HTML(HTML::p("Resource isn't available: Something went wrong, probably a 404!")); } // Create new Parser object $parser = new XML_FOAF_Parser(); // Parser FOAF into $foaffile $parser->parseFromMem($foaffile); $a = $parser->toArray(); $html = HTML(HTML::h1(@$a[0]["name"]), HTML::table(HTML::thead(), HTML::tbody(@$a[0]["title"] ? HTML::tr(HTML::td(_("Title")), HTML::td($a[0]["title"])) : null, @$a[0]["homepage"][0] ? $this->iterateHTML($a[0], "homepage", $a["dc"]) : null, @$a[0]["weblog"][0] ? $this->iterateHTML($a[0], "weblog", $a["dc"]) : null, HTML::tr(HTML::td("Full Name"), @$a[0]["name"][0] ? HTML::td(@$a[0]["name"]) : null), @$a[0]["nick"][0] ? $this->iterateHTML($a[0], "nick", $a["dc"]) : null, @$a[0]["mboxsha1sum"][0] ? $this->iterateHTML($a[0], "mboxsha1sum", $a["dc"]) : null, @$a[0]["depiction"][0] ? $this->iterateHTML($a[0], "depiction", $a["dc"]) : null, @$a[0]["seealso"][0] ? $this->iterateHTML($a[0], "seealso", $a["dc"]) : null, HTML::tr(HTML::td("Source"), HTML::td(HTML::a(array('href' => @$foaf), "RDF")))))); if (DEBUG) { $html->pushContent(HTML::hr(), $chooser); } return $html; } } }
function showForm(&$dbi, &$request, $args, $allrelations) { global $WikiTheme; $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's')); $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $help = Button('submit:semsearch[help]', "?", false); $svalues = empty($allrelations) ? "" : join("','", $allrelations); $reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')"); $querybox = HTML::textarea(array('name' => 's', 'title' => _("Enter a valid query expression"), 'rows' => 4, 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), $args['s']); $submit = Button('submit:semsearch[relations]', _("Search"), false, array('title' => 'Move to help page. No seperate window')); $instructions = _("Search in all specified pages for the expression."); $form = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => '0', 'width' => '100%'), HTML::tr(HTML::td(_("Pagename(s): "), $pagefilter), HTML::td(array('align' => 'right'), $help)), HTML::tr(HTML::td(array('colspan' => 2), $querybox))), HTML::br(), HTML::div(array('align' => 'center'), $submit)); return $form; }
function showForm(&$dbi, &$request, $args) { $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'direction')); $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $query = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $dirsign_switch = JavaScript("\nfunction dirsign_switch() {\n var d = document.getElementById('dirsign')\n d.innerHTML = (d.innerHTML == ' => ') ? ' <= ' : ' => '\n}\n"); $dirsign = " => "; $in = $out = array('name' => 'direction', 'type' => 'radio', 'onChange' => 'dirsign_switch()'); $out['value'] = 'out'; $out['id'] = 'dir_out'; if ($args['direction'] == 'out') { $out['checked'] = 'checked'; } $in['value'] = 'in'; $in['id'] = 'dir_in'; if ($args['direction'] == 'in') { $in['checked'] = 'checked'; $dirsign = " <= "; } $direction = HTML(HTML::input($out), HTML::label(array('for' => 'dir_out'), _("outgoing")), HTML::input($in), HTML::label(array('for' => 'dir_in'), _("incoming"))); /* $direction = HTML::select(array('name'=>'direction', 'onChange' => 'dirsign_switch()')); $out = array('value' => 'out'); if ($args['direction']=='out') $out['selected'] = 'selected'; $in = array('value' => 'in'); if ($args['direction']=='in') { $in['selected'] = 'selected'; $dirsign = " <= "; } $direction->pushContent(HTML::option($out, _("outgoing"))); $direction->pushContent(HTML::option($in, _("incoming"))); */ $submit = Button('submit:search', _("LinkSearch"), false); $instructions = _("Search in pages for links with the matching name."); $form = HTML::form(array('action' => $action, 'method' => 'GET', 'accept-charset' => $GLOBALS['charset']), $dirsign_switch, $hiddenfield, $instructions, HTML::br(), $pagefilter, HTML::strong(HTML::tt(array('id' => 'dirsign'), $dirsign)), $query, HTML::raw(' '), $direction, HTML::raw(' '), $submit); return $form; }
} if (isset($list5)) { array_push($list, $list5); } $data_html = $obj->list_html($var_name, $label, $list, $div_name); $data_css = $obj_css->styles($var_name, $color, $width, $height, $x_position, $y_position, $z_index, $font_size, $font_color); $obj->write_to_file($data_html, $html_file_name, $css_file_name, $data_css); $insert = "INSERT INTO `CMS`.`html_css` (`ID`, `HTML`, `CSS`, `FORM_ID`,`STATUS`, `NAME`) VALUES (NULL, '{$data_html}', '{$data_css}', {$index_of_form},'1', '{$label}');"; $result = $conn->query($insert); $ID = mysqli_insert_id($conn); $insert_div_data = "INSERT INTO `CMS`.`divs` (`ID`, `ELEMENT`, `HTML_CSS_ID`) VALUES (NULL, '{$data_html}',{$ID});"; $result = $conn->query($insert_div_data); echo 'HTML & CSS Code created successfully<br/>'; break; case 'form': $data_html = $obj->form($var_name, $label, $value, $div_name); $data_css = $obj_css->styles($var_name, $color, $width, $height, $x_position, $y_position, $z_index, $font_size, $font_color); $obj->write_to_file($data_html, $html_file_name, $css_file_name, $data_css); $insert = "INSERT INTO `CMS`.`html_css` (`ID`, `HTML`, `CSS`, `FORM_ID`,`STATUS`, `NAME`) VALUES (NULL, '{$data_html}', '{$data_css}', {$index_of_form},'1', '{$label}');"; $result = $conn->query($insert); $ID = mysqli_insert_id($conn); $insert_div_data = "INSERT INTO `CMS`.`divs` (`ID`, `ELEMENT`, `HTML_CSS_ID`) VALUES (NULL, '{$data_html}',{$ID});"; $result = $conn->query($insert_div_data); echo 'HTML & CSS Code created successfully<br/>'; break; case 'image': $data_html = $obj->image($var_name, $label, $value, $div_name); $data_css = $obj_css->styles($var_name, $color, $width, $height, $x_position, $y_position, $z_index, $font_size, $font_color); $obj->write_to_file($data_html, $html_file_name, $css_file_name, $data_css); $insert = "INSERT INTO `CMS`.`html_css` (`ID`, `HTML`, `CSS`, `FORM_ID`,`STATUS`, `NAME`) VALUES (NULL, '{$data_html}', '{$data_css}', {$index_of_form},'1', '{$label}');"; $result = $conn->query($insert);
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if ($request->getArg('action') != _("PhpWikiAdministration/SetAcl")) { return $this->disabled("(action != 'browse')"); } } if (!ENABLE_PAGEPERM) { return $this->disabled("ENABLE_PAGEPERM = false"); } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); $post_args = $request->getArg('admin_setacl'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } elseif ($this->_list) { $pages = $this->_list; } $header = HTML::fieldset(); if ($p && $request->isPost() && !empty($post_args['acl']) && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify') { // Real action return $this->setaclPages($request, array_keys($p), $request->getArg('acl')); } if ($post_args['action'] == 'select') { if (!empty($post_args['acl'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,perm,mtime,owner,author"; } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('perm' => new _PageList_Column_perm('perm', _("Permission")), 'acl' => new _PageList_Column_acl('acl', _("ACL"))))); $pagelist->addPageList($pages); if ($next_action == 'verify') { $button_label = _("Yes"); $header = $this->setaclForm($header, $post_args, $pages); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently change access rights to the selected files?")))); } else { $button_label = _("Change Access Rights"); $header = $this->setaclForm($header, $post_args, $pages); $header->pushContent(HTML::legend(_("Select the pages where to change access rights"))); } $buttons = HTML::p(Button('submit:admin_setacl[acl]', $button_label, 'wikiadmin'), Button('submit:admin_setacl[cancel]', _("Cancel"), 'button')); $header->pushContent($buttons); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_setacl')), HiddenInputs(array('admin_setacl[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if ($request->getArg('action') != _("PhpWikiAdministration/Rename")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_rename'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['rename']) && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } // DONE: error message if not allowed. if ($post_args['action'] == 'verify') { // Real action return $this->renamePages($dbi, $request, array_keys($p), $post_args['from'], $post_args['to'], !empty($post_args['updatelinks'])); } if ($post_args['action'] == 'select') { if (!empty($post_args['from'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,renamed_pagename"; } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('renamed_pagename' => new _PageList_Column_renamed_pagename('rename', _("Rename to"))))); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently rename the selected files?")))); $header = $this->renameForm($header, $post_args); } else { $button_label = _("Rename selected pages"); $header->pushContent(HTML::p(_("Select the pages to rename:"))); if (!$post_args and count($pages) == 1) { list($post_args['from'], ) = array_keys($pages); $post_args['to'] = $post_args['from']; } $header = $this->renameForm($header, $post_args); } $buttons = HTML::p(Button('submit:admin_rename[rename]', $button_label, 'wikiadmin'), Button('submit:admin_rename[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_rename')), HiddenInputs(array('admin_rename[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if (empty($action)) { return $this->error(fmt("A required argument '%s' is missing.", "action")); } $form = HTML::form(array('action' => $request->getPostURL(), 'method' => strtolower($method), 'class' => 'wikiaction', 'accept-charset' => $GLOBALS['charset']), HiddenInputs(array('action' => $action, 'group_id' => GROUP_ID))); $nbsp = HTML::Raw(' '); $already_submit = 0; foreach ($this->inputbox as $inputbox) { foreach ($inputbox as $inputtype => $input) { if ($inputtype == 'radiobutton') { $inputtype = 'radio'; } // convert from older versions $input['type'] = $inputtype; $text = ''; if ($inputtype != 'submit') { if (empty($input['name'])) { return $this->error(fmt("A required argument '%s' is missing.", $inputtype . "[][name]")); } if (!isset($input['text'])) { $input['text'] = gettext($input['name']); } $text = $input['text']; unset($input['text']); } switch ($inputtype) { case 'checkbox': case 'radio': if (empty($input['value'])) { $input['value'] = 1; } if (is_array($input['value'])) { $div = HTML::div(array('class' => $class)); $values = $input['value']; $name = $input['name']; $input['name'] = $inputtype == 'checkbox' ? $name . "[]" : $name; foreach ($values as $val) { $input['value'] = $val; if ($request->getArg($name)) { if ($request->getArg($name) == $val) { $input['checked'] = 'checked'; } else { unset($input['checked']); } } $div->pushContent(HTML::input($input), $nbsp, $val, $nbsp, "\n"); if (!$nobr) { $div->pushContent(HTML::br()); } } $form->pushContent($div); } else { if (empty($input['checked'])) { if ($request->getArg($input['name'])) { $input['checked'] = 'checked'; } } else { $input['checked'] = 'checked'; } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } } break; case 'editbox': $input['type'] = 'text'; if (empty($input['value']) and $s = $request->getArg($input['name'])) { $input['value'] = $s; } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } break; case 'combobox': // TODO: moACDROPDOWN $values = $input['value']; unset($input['value']); $input['type'] = 'text'; if (is_string($values)) { $values = explode(",", $values); } if (empty($values)) { if ($input['method']) { $input['value'] = xmlrequest($input['method']); } elseif ($s = $request->getArg($input['name'])) { $input['value'] = $s; } } elseif (is_array($values)) { $name = $input['name']; unset($input['name']); foreach ($values as $val) { $input = array('value' => $val); if ($request->getArg($name)) { if ($request->getArg($name) == $val) { $input['selected'] = 'selected'; } else { unset($input['selected']); } } //$select->pushContent(HTML::option($input, $val)); } } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } break; case 'pulldown': $values = $input['value']; unset($input['value']); unset($input['type']); $select = HTML::select($input); if (is_string($values)) { $values = explode(",", $values); } if (empty($values) and $s = $request->getArg($input['name'])) { $select->pushContent(HTML::option(array('value' => $s), $s)); } elseif (is_array($values)) { $name = $input['name']; unset($input['name']); foreach ($values as $val) { $input = array('value' => $val); if ($request->getArg($name)) { if ($request->getArg($name) == $val) { $input['selected'] = 'selected'; } else { unset($input['selected']); } } $select->pushContent(HTML::option($input, $val)); } } $form->pushContent($text, $nbsp, $select); break; case 'reset': case 'hidden': $form->pushContent(HTML::input($input)); break; // change the order of inputs, by explicitly placing a submit button here. // change the order of inputs, by explicitly placing a submit button here. case 'submit': //$input['type'] = 'submit'; if (empty($input['value'])) { $input['value'] = $buttontext ? $buttontext : $action; } unset($input['text']); if (empty($input['class'])) { $input['class'] = $class; } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } // unset the default submit button $already_submit = 1; break; } } } if ($request->getArg('start_debug')) { $form->pushContent(HTML::input(array('name' => 'start_debug', 'value' => $request->getArg('start_debug'), 'type' => 'hidden'))); } if (!USE_PATH_INFO) { $form->pushContent(HiddenInputs(array('pagename' => $basepage))); } if (!$already_submit) { if (empty($buttontext)) { $buttontext = $action; } $submit = Button('submit:', $buttontext, $class); if ($cancel) { $form->pushContent(HTML::span(array('class' => $class), $submit, Button('submit:cancel', _("Cancel"), $class))); } else { $form->pushContent(HTML::span(array('class' => $class), $submit)); } } return $form; }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); $user =& $request->_user; if (isa($request, 'MockRequest')) { return ''; } if (!$request->isActionPage($request->getArg('pagename')) and (!isset($user->_prefs->_method) or !in_array($user->_prefs->_method, array('ADODB', 'SQL'))) or in_array($request->getArg('action'), array('zip', 'ziphtml', 'dumphtml')) or isa($user, '_ForbiddenUser')) { $no_args = $this->getDefaultArguments(); // ? // foreach ($no_args as $key => $value) { // $no_args[$value] = false; // } $no_args['errmsg'] = HTML(HTML::h2(_("Error: The user HomePage must be a valid WikiWord. Sorry, UserPreferences cannot be saved."), HTML::hr())); $no_args['isForm'] = false; return Template('userprefs', $no_args); } $userid = $user->UserName(); if ($user->isAuthenticated() and !empty($userid)) { $pref =& $request->_prefs; $args['isForm'] = true; //trigger_error("DEBUG: reading prefs from getPreferences".print_r($pref)); if ($request->isPost()) { $errmsg = ''; $delete = $request->getArg('delete'); if ($delete and $request->getArg('verify')) { // deleting prefs, verified $default_prefs = $pref->defaultPreferences(); $default_prefs['userid'] = $user->UserName(); $user->setPreferences($default_prefs); $request->_setUser($user); $request->setArg("verify", false); $request->setArg("delete", false); $alert = new Alert(_("Message"), _("Your UserPreferences have been successfully deleted.")); $alert->show(); return; } elseif ($delete and !$request->getArg('verify')) { return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs()), HTML::p(_("Do you really want to delete all your UserPreferences?")), HTML::p(Button('submit:delete', _("Yes"), 'delete'), HTML::Raw(' '), Button('cancel', _("Cancel")))); } elseif ($rp = $request->getArg('pref')) { // replace only changed prefs in $pref with those from request if (!empty($rp['passwd']) and $rp['passwd2'] != $rp['passwd']) { $errmsg = _("Wrong password. Try again."); } else { //trigger_error("DEBUG: reading prefs from request".print_r($rp)); //trigger_error("DEBUG: writing prefs with setPreferences".print_r($pref)); if (empty($rp['passwd'])) { unset($rp['passwd']); } // fix to set system pulldown's. empty values don't get posted if (empty($rp['theme'])) { $rp['theme'] = ''; } if (empty($rp['lang'])) { $rp['lang'] = ''; } $num = $user->setPreferences($rp); if (!empty($rp['passwd'])) { $passchanged = false; if ($user->mayChangePass()) { if (method_exists($user, 'storePass')) { $passchanged = $user->storePass($rp['passwd']); } if (!$passchanged and method_exists($user, 'changePass')) { $passchanged = $user->changePass($rp['passwd']); } if ($passchanged) { $errmsg = _("Password updated."); } else { $errmsg = _("Password was not changed."); } } else { $errmsg = _("Password cannot be changed."); } } if (!$num) { $errmsg .= " " . _("No changes."); } else { $request->_setUser($user); $pref = $user->_prefs; $errmsg .= sprintf(_("%d UserPreferences fields successfully updated."), $num); } } $args['errmsg'] = HTML(HTML::h2($errmsg), HTML::hr()); } } $args['available_themes'] = listAvailableThemes(); $args['available_languages'] = listAvailableLanguages(); return Template('userprefs', $args); } else { // wrong or unauthenticated user return $request->_notAuthorized(WIKIAUTH_BOGO); //return $user->PrintLoginForm ($request, $args, false, false); } }
function run($dbi, $argstr, &$request, $basepage) { //if ($request->getArg('action') != 'browse') // return $this->disabled("(action != 'browse')"); $args = $this->getArgs($argstr, $request); $this->_args = $args; extract($args); $this->preSelectS($args, $request); $info = $args['info']; $this->debug = $args['debug']; // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC); $pagename = $request->getArg('pagename'); // GetUrlToSelf() with all given params //$uri = $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']; // without s would be better. //$uri = $request->getURLtoSelf();//false, array('verify')); $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'POST')); if ($request->getArg('WikiAdminSelect') == _("Go")) { $p = false; } else { $p = $request->getArg('p'); } //$p = @$GLOBALS['HTTP_POST_VARS']['p']; $form->pushContent(HTML::p(array('class' => 'wikitext'), _("Select: "), HTML::input(array('type' => 'text', 'name' => 's', 'value' => $args['s'])), HTML::input(array('type' => 'submit', 'name' => 'WikiAdminSelect', 'value' => _("Go"))))); if ($request->isPost() && !$request->getArg('wikiadmin') && !empty($p)) { $this->_list = array(); // List all selected pages again. foreach ($p as $page => $name) { $this->_list[$name] = 1; } } elseif ($request->isPost() and $request->_user->isAdmin() and !empty($p) and $request->getArg('action') == 'WikiAdminSelect' and $request->getArg('wikiadmin')) { // handle external plugin $loader = new WikiPluginLoader(); $a = array_keys($request->getArg('wikiadmin')); $plugin_action = $a[0]; $single_arg_plugins = array("Remove"); if (in_array($plugin_action, $single_arg_plugins)) { $plugin = $loader->getPlugin($plugin_action); $ul = HTML::ul(); foreach ($p as $page => $name) { $plugin_args = "run_page={$name}"; $request->setArg($plugin_action, 1); $request->setArg('p', array($page => $name)); // if the plugin requires more args than the pagename, // then this plugin will not return. (Rename, SearchReplace, ...) $action_result = $plugin->run($dbi, $plugin_args, $request, $basepage); $ul->pushContent(HTML::li(fmt("Selected page '%s' passed to '%s'.", $name, $select))); $ul->pushContent(HTML::ul(HTML::li($action_result))); } } else { // redirect to the plugin page. // in which page is this plugin? $plugin_action = preg_replace("/^WikiAdmin/", "", $plugin_action); $args = array(); foreach ($p as $page => $x) { $args["p[{$page}]"] = 1; } header("Location: " . WikiURL(_("PhpWikiAdministration") . "/" . _($plugin_action), $args, 1)); exit; } } elseif (empty($args['s'])) { // List all pages to select from. $this->_list = $this->collectPages($this->_list, $dbi, $args['sortby'], $args['limit']); } $pagelist = new PageList_Selectable($info, $args['exclude'], $args); $pagelist->addPageList($this->_list); $form->pushContent($pagelist->getContent()); foreach ($args as $k => $v) { if (!in_array($k, array('s', 'WikiAdminSelect', 'action', 'verify'))) { $form->pushContent(HiddenInputs(array($k => $v))); } // plugin params } /* foreach ($_GET as $k => $v) { if (!in_array($k,array('s','WikiAdminSelect','action'))) $form->pushContent(HiddenInputs(array($k => $v))); // debugging params, ... } */ if (!$request->getArg('verify')) { $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'verify'))); $form->pushContent(Button('submit:verify', _("Select pages"), 'wikiadmin'), Button('submit:cancel', _("Cancel"), 'button')); } else { global $WikiTheme; $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'WikiAdminSelect'))); // Add the Buttons for all registered WikiAdmin plugins $plugin_dir = 'lib/plugin'; if (defined('PHPWIKI_DIR')) { $plugin_dir = PHPWIKI_DIR . "/{$plugin_dir}"; } $fs = new fileSet($plugin_dir, 'WikiAdmin*.php'); $actions = $fs->getFiles(); foreach ($actions as $f) { $f = preg_replace('/.php$/', '', $f); $s = preg_replace('/^WikiAdmin/', '', $f); if (!in_array($s, array("Select", "Utils"))) { // disable Select and Utils $form->pushContent(Button("submit:wikiadmin[{$f}]", _($s), "wikiadmin")); $form->pushContent($WikiTheme->getButtonSeparator()); } } $form->pushContent(Button('submit:cancel', _("Cancel"), 'button')); } if (!$request->getArg('select')) { return $form; } else { //return $action_result; } }
function run($dbi, $argstr, &$request, $basepage) { $this->_args = $this->getArgs($argstr, $request); extract($this->_args); if (!$page) { return ''; } $hidden_pagemeta = array('_cached_html'); $readonly_pagemeta = array('hits'); $dbi = $request->getDbh(); $p = $dbi->getPage($page); $pagemeta = $p->getMetaData(); // Look at arguments to see if submit was entered. If so, // process this request before displaying. // if ($request->isPost() and $request->_user->isAdmin() and $request->getArg('metaedit')) { $metafield = trim($request->getArg('metafield')); $metavalue = trim($request->getArg('metavalue')); if (!in_array($metafield, $readonly_pagemeta)) { if (preg_match('/^(.*?)\\[(.*?)\\]$/', $metafield, $matches)) { list(, $array_field, $array_key) = $matches; $array_value = $pagemeta[$array_field]; $array_value[$array_key] = $metavalue; $p->set($array_field, $array_value); } else { $p->set($metafield, $metavalue); } } $dbi->touch(); $url = $request->getURLtoSelf(false, array('metaedit', 'metafield', 'metavalue')); $request->redirect($url); // The rest of the output will not be seen due to the // redirect. } // Now we show the meta data and provide entry box for new data. $html = HTML(); $html->pushContent(fmt("Existing page-level metadata for %s:", $page)); $dl = HTML::dl(); foreach ($pagemeta as $key => $val) { if (is_string($val) and substr($val, 0, 2) == 'a:') { $dl->pushContent(HTML::dt("\n{$key} => {$val}\n", $dl1 = HTML::dl())); foreach (unserialize($val) as $akey => $aval) { $dl1->pushContent(HTML::dt(HTML::strong("{$key}" . '[' . $akey . "] => {$aval}\n"))); } $dl->pushContent($dl1); } elseif (is_array($val)) { $dl->pushContent(HTML::dt("\n{$key}:\n", $dl1 = HTML::dl())); foreach ($val as $akey => $aval) { $dl1->pushContent(HTML::dt(HTML::strong("{$key}" . '[' . $akey . "] => {$aval}\n"))); } $dl->pushContent($dl1); } elseif (in_array($key, $hidden_pagemeta)) { } elseif (in_array($key, $readonly_pagemeta)) { $dl->pushContent(HTML::dt(array('style' => 'background: #dddddd'), "{$key} => {$val}\n")); } else { $dl->pushContent(HTML::dt(HTML::strong("{$key} => {$val}\n"))); } } $html->pushContent($dl); if ($request->_user->isAdmin()) { $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs()); $instructions = _("Add or change a page-level metadata 'key=>value' pair. Note that you can remove a key by leaving the value-box empty."); $keyfield = HTML::input(array('name' => 'metafield'), ''); $valfield = HTML::input(array('name' => 'metavalue'), ''); $button = Button('submit:metaedit', _("Submit"), false); $form = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $hiddenfield, $instructions, HTML::br(), $keyfield, ' => ', $valfield, HTML::raw(' '), $button); $html->pushContent(HTML::br(), $form); } else { $html->pushContent(HTML::em(_("Requires WikiAdmin privileges to edit."))); } return $html; }
function run($dbi, $argstr, &$request, $basepage) { // When 'phpweather/phpweather.php' is not installed then // PHPWEATHER_BASE_DIR will be undefined. if (!defined('PHPWEATHER_BASE_DIR')) { return $this->error(_("You have to define PHPWEATHER_BASE_DIR before use. (config/config.ini)")); } //early return require_once PHPWEATHER_BASE_DIR . '/output/pw_images.php'; require_once PHPWEATHER_BASE_DIR . '/pw_utilities.php'; extract($this->getArgs($argstr, $request)); $html = HTML(); $w = new phpweather(); // Our weather object if (!empty($icao)) { /* We assign the ICAO to the weather object: */ $w->set_icao($icao); if (!$w->get_country_code()) { /* The country code couldn't be resolved, so we * shouldn't use the ICAO: */ trigger_error(sprintf(_("The ICAO '%s' wasn't recognized."), $icao), E_USER_NOTICE); $icao = ''; } } if (!empty($icao)) { /* We check and correct the language if necessary: */ //if (!in_array($language, array_keys($w->get_languages('text')))) { if (!in_array($language, array_keys(get_languages('text')))) { trigger_error(sprintf(_("%s does not know about the language '%s', using 'en' instead."), $this->getName(), $language), E_USER_NOTICE); $language = 'en'; } $class = "pw_text_{$language}"; require_once PHPWEATHER_BASE_DIR . "/output/{$class}.php"; $t = new $class($w); $t->set_pref_units($units); $i = new pw_images($w); $i_temp = HTML::img(array('src' => $i->get_temp_image())); $i_wind = HTML::img(array('src' => $i->get_winddir_image())); $i_sky = HTML::img(array('src' => $i->get_sky_image())); $m = $t->print_pretty(); $m_td = HTML::td(HTML::p(new RawXml($m))); $i_tr = HTML::tr(); $i_tr->pushContent(HTML::td($i_temp)); $i_tr->pushContent(HTML::td($i_wind)); $i_table = HTML::table($i_tr); $i_table->pushContent(HTML::tr(HTML::td(array('colspan' => '2'), $i_sky))); $tr = HTML::tr(); $tr->pushContent($m_td); $tr->pushContent(HTML::td($i_table)); $html->pushContent(HTML::table($tr)); } /* We make a menu if asked to, or if $icao is empty: */ if ($menu || empty($icao)) { $form_arg = array('action' => $request->getURLtoSelf(), 'method' => 'get'); /* The country box is always part of the menu: */ $p1 = HTML::p(new RawXml(get_countries_select($w, $cc))); /* We want to save the language: */ $p1->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'language', 'value' => $language))); /* And also the ICAO: */ $p1->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'icao', 'value' => $icao))); $caption = empty($cc) ? _("Submit country") : _("Change country"); $p1->pushContent(HTML::input(array('type' => 'submit', 'value' => $caption))); $html->pushContent(HTML::form($form_arg, $p1)); if (!empty($cc)) { /* We have selected a country, now display a list with * the available stations in that country: */ $p2 = HTML::p(); /* We need the country code after the form is submitted: */ $p2->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'cc', 'value' => $cc))); $p2->pushContent(new RawXml(get_stations_select($w, $cc, $icao))); $p2->pushContent(new RawXml(get_languages_select($language))); $p2->pushContent(HTML::input(array('type' => 'submit', 'value' => _("Submit location")))); $html->pushContent(HTML::form($form_arg, $p2)); } } return $html; }
public static function contactForm($field_callback, $before_callback = null, $after_callback = null, $return = false) { $_this = self::getInstance(); if (!isset($_this->features['contact-form'])) { return; } $options = $_this->theme_options->child(array($_this->features['contact-form']['group'], $_this->features['contact-form']['name'])); $labels = array('name' => __('Name', $_this->domain), 'email' => __('E-mail', $_this->domain), 'website' => __('Website', $_this->domain), 'phone' => __('Phone number', $_this->domain), 'subject' => __('Subject', $_this->domain), 'message' => __('Message', $_this->domain), 'captcha' => __('Captcha', $_this->domain)); $requires = array('name' => true, 'email' => true, 'website' => false, 'phone' => false, 'subject' => false, 'message' => true, 'captcha' => true); $output = HTML::form()->action(admin_url(self::WP_AJAX_URI))->method('post')->add(HTML::makeInput('hidden', 'action', $_this->features['contact-form']['action'])); if ($_this->features['contact-form']['form_id']) { $output->id($_this->features['contact-form']['form_id']); } if ($_this->features['contact-form']['form_class']) { $output->class($_this->features['contact-form']['form_class']); } if ($before_callback !== null) { $output->add(is_callable($before_callback) ? call_user_func($before_callback) : (string) $before_callback); } if (is_callable($field_callback)) { foreach ($options->value('fields') as $field) { $html = call_user_func($field_callback, $field, $requires[$field], $labels[$field]); if ($field == 'captcha' && function_exists('cptch_display_captcha_custom')) { $captcha = HTML::makeInput('hidden', 'cntctfrm_contact_action', 'true')->html() . preg_replace('/ style="[^"]*"/i', '', cptch_display_captcha_custom()); $html = strpos($html, '%s') !== false ? sprintf($html, $captcha) : $captcha; } $output->add($html); } } if ($after_callback !== null) { $output->add(is_callable($after_callback) ? call_user_func($after_callback) : (string) $after_callback); } if ($return) { return $output->html(); } else { echo $output->html(); } }
function _upgrade_db_init(&$dbh) { global $request, $DBParams, $DBAuthParams; if (!in_array($DBParams['dbtype'], array('SQL', 'ADODB', 'PDO'))) { return; } if (DBADMIN_USER) { // if need to connect as the root user, for CREATE and ALTER privileges $AdminParams = $DBParams; if ($DBParams['dbtype'] == 'SQL') { $dsn = DB::parseDSN($AdminParams['dsn']); } else { // ADODB or PDO $dsn = parseDSN($AdminParams['dsn']); } $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], DBADMIN_USER, DBADMIN_PASSWD, $dsn['hostspec'], $dsn['database']); if (DEBUG & _DEBUG_SQL and $DBParams['dbtype'] == 'PDO') { echo "<br>\nDBParams['dsn']: '", $DBParams['dsn'], "'"; echo "<br>\ndsn: '", print_r($dsn), "'"; echo "<br>\nAdminParams['dsn']: '", $AdminParams['dsn'], "'"; } $dbh = WikiDB::open($AdminParams); } elseif ($dbadmin = $request->getArg('dbadmin')) { if (empty($dbadmin['user']) or isset($dbadmin['cancel'])) { $dbh =& $request->_dbi; } else { $AdminParams = $DBParams; if ($DBParams['dbtype'] == 'SQL') { $dsn = DB::parseDSN($AdminParams['dsn']); } else { $dsn = parseDSN($AdminParams['dsn']); } $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], $dbadmin['user'], $dbadmin['passwd'], $dsn['hostspec'], $dsn['database']); $dbh = WikiDB::open($AdminParams); } } else { // Check if the privileges are enough. Need CREATE and ALTER perms. // And on windows: SELECT FROM mysql, possibly: UPDATE mysql. $form = HTML::form(array("method" => "post", "action" => $request->getPostURL(), "accept-charset" => $GLOBALS['charset']), HTML::p(_("Upgrade requires database privileges to CREATE and ALTER the phpwiki database."), HTML::br(), _("And on windows at least the privilege to SELECT FROM mysql, and possibly UPDATE mysql")), HiddenInputs(array('action' => 'upgrade')), HTML::table(array("cellspacing" => 4), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin user:"******"dbadmin[user]", 'size' => 12, 'maxlength' => 256, 'value' => 'root')))), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin password:"******"dbadmin[passwd]", 'type' => 'password', 'size' => 12, 'maxlength' => 256)))), HTML::tr(HTML::td(array('align' => 'center', 'colspan' => 2), Button("submit:", _("Submit"), 'wikiaction'), HTML::raw(' '), Button("submit:dbadmin[cancel]", _("Cancel"), 'button'))))); $form->printXml(); echo "</div><!-- content -->\n"; echo asXML(Template("bottom")); echo "</body></html>\n"; $request->finish(); exit; } }
function run($dbi, $argstr, &$request, $basepage) { // no action=replace support yet if ($request->getArg('action') != 'browse') { return $this->disabled("(action != 'browse')"); } $args = $this->getArgs($argstr, $request); $this->_args = $args; //TODO: support p from <!plugin-list !> $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_replace'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify' and !empty($post_args['from'])) { // Real action return $this->searchReplacePages($dbi, $request, array_keys($p), $post_args['from'], $post_args['to']); } if ($post_args['action'] == 'select') { if (!empty($post_args['from'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { // List all pages to select from. //TODO: check for permissions and list only the allowed $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,hi_content"; } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array_merge($args, array('types' => array('hi_content' => new _PageList_Column_content('rev:hi_content', _("Content")))))); $pagelist->addPageList($pages); $header = HTML::p(); if (empty($post_args['from'])) { $header->pushContent(HTML::p(HTML::em(_("Warning: The search string cannot be empty!")))); } if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently search & replace text in the selected files?")))); $this->replaceForm($header, $post_args); } else { $button_label = _("Search & Replace"); $this->replaceForm($header, $post_args); $header->pushContent(HTML::p(_("Select the pages to search:"))); } $buttons = HTML::p(Button('submit:admin_replace[rename]', $button_label, 'wikiadmin'), Button('submit:admin_replace[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_replace')), HiddenInputs(array('admin_replace[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if ($request->getArg('action') != _("PhpWikiAdministration/MassRevert")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); if (!is_numeric($args['min_age'])) { $args['min_age'] = -1; } $this->_args =& $args; /*if (!empty($args['exclude'])) $exclude = explodePageList($args['exclude']); else $exclude = false;*/ $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_revert'); $next_action = 'select'; $pages = array(); if ($p && $request->isPost() && !empty($post_args['revert']) && empty($post_args['cancel'])) { // check individual PagePermissions if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify') { // Real delete. return $this->revertPages($request, array_keys($p)); } if ($post_args['action'] == 'select') { $next_action = 'verify'; foreach ($p as $name => $c) { $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name); $pages[$name] = $c; } } } elseif ($p && is_array($p) && !$request->isPost()) { // from WikiAdminSelect $next_action = 'verify'; foreach ($p as $name => $c) { $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name); $pages[$name] = $c; } $request->setArg('p', false); } if ($next_action == 'select') { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('revert' => new _PageList_Column_revert('revert', _("Revert")), 'diff' => new _PageList_Column_diff('diff', _("Changes"))))); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::strong(_("Are you sure you want to overwrite the selected files with the previous version?"))); } else { $button_label = _("Revert selected pages"); $header->pushContent(_("Permanently remove the selected files:"), HTML::br()); if ($args['min_age'] > 0) { $header->pushContent(fmt("Also pages which have been deleted at least %s days.", $args['min_age'])); } else { $header->pushContent(_("List all pages.")); } if ($args['max_age'] > 0) { $header->pushContent(" ", fmt("(Pages which have been deleted at least %s days are already checked.)", $args['max_age'])); } } $buttons = HTML::p(Button('submit:admin_revert[revert]', $button_label, 'wikiadmin'), Button('submit:admin_revert[cancel]', _("Cancel"), 'button')); // TODO: quick select by regex javascript? return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_revert')), HiddenInputs(array('admin_revert[action]' => $next_action, 'require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function run($dbi, $argstr, &$request, $basepage) { if (!isset($_SERVER)) { $_SERVER =& $GLOBALS['HTTP_SERVER_VARS']; } $request->setArg('nocache', 'purge'); $args = $this->getArgs($argstr, $request); if (!$args['page']) { return $this->error("No page specified"); } if (!empty($args['admin']) and $request->_user->isAdmin()) { // reset statistics return $this->doPollAdmin($dbi, $request, $page); } extract($this->_args); $page = $dbi->getPage($args['page']); // check ip and last visit $poll = $page->get("poll"); $ip = $_SERVER['REMOTE_ADDR']; $disable_submit = false; if (isset($poll['ip'][$ip]) and time() - $poll['ip'][$ip] < 20 * 60) { //view at least the result or disable the Go button $html = HTML(HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!"))); $html->pushContent($this->doPoll($page, $request, $request->getArg('answer'), true)); return $html; } $poll['ip'][$ip] = time(); // purge older ip's foreach ($poll['ip'] as $ip => $time) { if (time() - $time > 21 * 60) { unset($poll['ip'][$ip]); } } $html = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post')); if ($request->isPost()) { // checkme: check if all answers are answered if ($request->getArg('answer') and ($args['require_all'] and count($request->getArg('answer')) == count($question) or $args['require_least'] and count($request->getArg('answer')) >= $args['require_least'])) { $page->set("poll", $poll); // update statistics and present them the user return $this->doPoll($page, $request, $request->getArg('answer')); } else { $html->pushContent(HTML::p(HTML::strong(_("Not enough questions answered!")))); } } $init = isset($question[0]) ? 0 : 1; for ($i = $init; $i <= count($question); $i++) { if (!isset($question[$i])) { break; } $q = $question[$i]; if (!isset($answer[$i])) { trigger_error(fmt("Missing %s for %s", "answer" . "[{$i}]", "question" . "[{$i}]"), E_USER_ERROR); } $a = $answer[$i]; if (!is_array($a)) { // a simple checkbox $html->pushContent(HTML::p(HTML::strong($q))); $html->pushContent(HTML::div(HTML::input(array('type' => 'checkbox', 'name' => "answer[{$i}]", 'value' => 1)), HTML::raw(" "), $a)); } else { $row = HTML(); for ($j = 0; $j <= count($a); $j++) { if (isset($a[$j])) { $row->pushContent(HTML::div(HTML::input(array('type' => 'radio', 'name' => "answer[{$i}]", 'value' => $j)), HTML::raw(" "), $a[$j])); } } $html->pushContent(HTML::p(HTML::strong($q)), $row); } } if (!$disable_submit) { $html->pushContent(HTML::p(HTML::input(array('type' => 'submit', 'name' => "WikiPoll", 'value' => _("OK"))), HTML::input(array('type' => 'reset', 'name' => "reset", 'value' => _("Reset"))))); } else { $html->pushContent(HTML::p(), HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!"))); } return $html; }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if (!$request->getArg('action') == _("PhpWikiAdministration/SetExternal")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_external'); if (!$request->isPost() and empty($post_args['external'])) { $post_args['external'] = $args['external']; } $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['button']) && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } // Real action return $this->setExternalPages($dbi, $request, array_keys($p)); } $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); $pagelist->addPageList($pages); $header = HTML::fieldset(); $button_label = _("Set pages to external"); $header->pushContent(HTML::legend(_("Select the pages to set as external"))); $buttons = HTML::p(Button('submit:admin_external[button]', $button_label, 'wikiadmin'), Button('submit:admin_external[cancel]', _("Cancel"), 'button')); $header->pushContent($buttons); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_external')), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); }
function run($dbi, $argstr, &$request, $basepage) { return $this->disabled("This action is blocked by administrator. Sorry for the inconvenience !"); if ($request->getArg('action') != 'browse') { if (!$request->getArg('action') == _("PhpWikiAdministration/Chown")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); $this->_args = $args; if (empty($args['user'])) { $args['user'] = $request->_user->UserName(); } /*if (!empty($args['exclude'])) $exclude = explodePageList($args['exclude']); else $exclude = false;*/ $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_chown'); if (!$request->isPost() and empty($post_args['user'])) { $post_args['user'] = $args['user']; } $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['chown']) && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } // DONE: error message if not allowed. if ($post_args['action'] == 'verify') { // Real action return $this->chownPages($dbi, $request, array_keys($p), $post_args['user']); } if ($post_args['action'] == 'select') { if (!empty($post_args['user'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } /* // let the user decide which info if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,owner,mtime"; } */ $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently chown the selected files?")))); $header = $this->chownForm($header, $post_args); } else { $button_label = _("Chown selected pages"); $header->pushContent(HTML::p(_("Select the pages to change the owner:"))); $header = $this->chownForm($header, $post_args); } $buttons = HTML::p(Button('submit:admin_chown[chown]', $button_label, 'wikiadmin'), Button('submit:admin_chown[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_chown')), HiddenInputs(array('admin_chown[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function makeForm($argstr, $request) { $form_defaults = $this->getDefaultFormArguments(); $defaults = array_merge($form_defaults, array('start_debug' => $request->getArg('start_debug')), $this->getDefaultArguments()); $args = $this->getArgs($argstr, $request, $defaults); $plugin = $this->getName(); $textinput = $args['textinput']; assert(!empty($textinput) && isset($args['textinput'])); $form = HTML::form(array('action' => WikiURL($args['targetpage']), 'method' => $args['method'], 'class' => $args['class'], 'accept-charset' => $GLOBALS['charset'])); $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'group_id', 'value' => GROUP_ID))); if (!USE_PATH_INFO) { $pagename = $request->get('pagename'); $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'pagename', 'value' => $args['targetpage']))); } if ($args['targetpage'] != $this->getName()) { $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => $this->getName()))); } $contents = HTML::div(); $contents->setAttr('class', $args['class']); foreach ($args as $arg => $val) { if (isset($form_defaults[$arg])) { continue; } if ($arg != $textinput && $val == $defaults[$arg]) { continue; } $i = HTML::input(array('name' => $arg, 'value' => $val)); if ($arg == $textinput) { //if ($inputs[$arg] == 'file') // $attr['type'] = 'file'; //else $i->setAttr('type', 'text'); $i->setAttr('size', $args['formsize']); if ($args['description']) { $i->addTooltip($args['description']); } } else { $i->setAttr('type', 'hidden'); } $contents->pushContent($i); // FIXME: hackage if ($i->getAttr('type') == 'file') { $form->setAttr('enctype', 'multipart/form-data'); $form->setAttr('method', 'post'); $contents->pushContent(HTML::input(array('name' => 'MAX_FILE_SIZE', 'value' => MAX_UPLOAD_SIZE, 'type' => 'hidden'))); } } if (!empty($args['buttontext'])) { $contents->pushContent(HTML::input(array('type' => 'submit', 'class' => 'button', 'value' => $args['buttontext']))); } $form->pushContent($contents); return $form; }
function RevertPage(&$request) { $mesg = HTML::dd(); $pagename = $request->getArg('pagename'); $version = $request->getArg('version'); if (!$version) { PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), HTML::dd(_("missing required version argument"))); return; } $dbi =& $request->_dbi; $page = $dbi->getPage($pagename); $current = $page->getCurrentRevision(); $currversion = $current->getVersion(); if ($currversion == 0) { $mesg->pushContent(' ', _("no page content")); PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), $mesg); flush(); return; } if ($currversion == $version) { $mesg->pushContent(' ', _("same version page")); PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), $mesg); flush(); return; } if ($request->getArg('cancel')) { $mesg->pushContent(' ', _("Cancelled")); PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), $mesg); flush(); return; } if (!$request->getArg('verify')) { $mesg->pushContent(HTML::br(), _("Are you sure?"), HTML::br(), HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs($request->getArgs(), false, array('verify')), HiddenInputs(array('verify' => 1)), Button('submit:verify', _("Yes"), 'button'), HTML::Raw(' '), Button('submit:cancel', _("Cancel"), 'button'))); $rev = $page->getRevision($version); $html = HTML(HTML::dt(fmt("Revert %s to version {$version}", WikiLink($pagename))), $mesg, $rev->getTransformedContent()); $template = Template('browse', array('CONTENT' => $html)); GeneratePage($template, $pagename, $rev); $request->checkValidators(); flush(); return; } $rev = $page->getRevision($version); $content = $rev->getPackedContent(); $versiondata = $rev->_data; $versiondata['summary'] = sprintf(_("revert to version %d"), $version); $new = $page->save($content, $currversion + 1, $versiondata); $dbi->touch(); $pagelink = WikiLink($pagename); $mesg->pushContent(fmt("Revert: %s", $pagelink), fmt("- version %d saved to database as version %d", $version, $new->getVersion())); // Force browse of current page version. $request->setArg('version', false); $template = Template('savepage', array()); $template->replace('CONTENT', $new->getTransformedContent()); GeneratePage($template, $mesg, $new); flush(); }
function showForm(&$dbi, &$request, $args) { global $WikiTheme; $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'semsearch', 'relation', 'attribute')); $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $allrelations = $dbi->listRelations(false, false, true); $svalues = empty($allrelations) ? "" : join("','", $allrelations); $reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')"); $relation = HTML::input(array('name' => 'relation', 'value' => $args['relation'], 'title' => _("Filter by this relation. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), ''); $queryrel = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $relsubmit = Button('submit:semsearch[relations]', _("Relations"), false); // just testing some dhtml... not yet done $enhancements = HTML(); $nbsp = HTML::raw(' '); $this_uri = $_SERVER['REQUEST_URI'] . '#'; $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'and')", 'title' => _("Add an AND query"))); $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'or')", 'title' => _("Add an OR query"))); if (DEBUG) { $enhancements = HTML::span($andbutton, $nbsp, $orbutton); } $instructions = _("Search in pages for a relation with that value (a pagename)."); $form1 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Relation'), HTML::th(), HTML::th('Links'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($relation), HTML::td(HTML::strong(HTML::tt(' :: '))), HTML::td($queryrel), HTML::td($nbsp, $relsubmit, $nbsp, $enhancements))))); $allattrs = $dbi->listRelations(false, true, true); if (empty($allrelations) and empty($allattrs)) { // be nice to the dummy. $this->_norelations_warning = 1; } $svalues = empty($allattrs) ? "" : join("','", $allattrs); $attdef = JavaScript("var semsearch_attributes = new Array('" . $svalues . "')\n" . "var semsearch_op = new Array('" . join("','", $this->_supported_operators) . "')"); // TODO: We want some more tricks: Autofill the base unit of the selected // attribute into the s area. $attribute = HTML::input(array('name' => 'attribute', 'value' => $args['attribute'], 'title' => _("Filter by this attribute name. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_attributes'), ''); $attr_op = HTML::input(array('name' => 'attr_op', 'value' => $args['attr_op'], 'title' => _("Comparison operator. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:2em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_op'), ''); $queryatt = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this numeric attribute value. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'plugin:SemanticSearch page=' . $args['page'] . ' attribute=^[S] attr_op==~'), ''); $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'and')", 'title' => _("Add an AND query"))); $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'or')", 'title' => _("Add an OR query"))); if (DEBUG) { $enhancements = HTML::span($andbutton, $nbsp, $orbutton); } $attsubmit = Button('submit:semsearch[attributes]', _("Attributes"), false); $instructions = HTML::span(_("Search in pages for an attribute with that numeric value."), "\n"); if (DEBUG) { $instructions->pushContent(HTML(" ", new Button(_("Advanced..."), _("SemanticSearchAdvanced")))); } $form2 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $attdef, $hiddenfield, HiddenInputs(array('relation' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Attribute'), HTML::th('Op'), HTML::th('Value'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($attribute), HTML::td($attr_op), HTML::td($queryatt), HTML::td($nbsp, $attsubmit, $nbsp, $enhancements))))); return HTML($form1, $form2); }
function run($dbi, $argstr, &$request, $basepage) { $this->allowed_extensions = explode("\n", "7z\navi\nbmp\nbz2\nc\ncfg\ndiff\ndoc\ndocx\nflv\ngif\nh\nics\nini\njpeg\njpg\nkmz\nmp3\nodg\nodp\nods\nodt\nogg\npatch\npdf\npng\nppt\npptx\nrar\nsvg\ntar\ntar.gz\ntxt\nxls\nxlsx\nxml\nxsd\nzip"); $this->disallowed_extensions = explode("\n", "ad[ep]\nasd\nba[st]\nchm\ncmd\ncom\ncgi\ncpl\ncrt\ndll\neml\nexe\nhlp\nhta\nin[fs]\nisp\njse?\nlnk\nmd[betw]\nms[cipt]\nnws\nocx\nops\npcd\np[ir]f\nphp\\d?\nphtml\npl\npy\nreg\nsc[frt]\nsh[bsm]?\nswf\nurl\nvb[esx]?\nvxd\nws[cfh]"); //removed "\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\}" $args = $this->getArgs($argstr, $request); extract($args); $file_dir = getUploadFilePath(); $file_dir .= "/"; $form = HTML::form(array('action' => $request->getPostURL(), 'enctype' => 'multipart/form-data', 'method' => 'post')); $contents = HTML::div(array('class' => 'wikiaction')); $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => MAX_UPLOAD_SIZE))); $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => $size))); if ($mode == 'edit') { $contents->pushContent(HTML::input(array('name' => 'action', 'type' => 'hidden', 'value' => 'edit'))); $contents->pushContent(HTML::raw(" ")); $contents->pushContent(HTML::input(array('value' => _("Upload"), 'name' => 'edit[upload]', 'type' => 'submit'))); } else { $contents->pushContent(HTML::raw(" ")); $contents->pushContent(HTML::input(array('value' => _("Upload"), 'type' => 'submit'))); } $form->pushContent($contents); $message = HTML(); if ($request->isPost() and $this->only_authenticated) { // Make sure that the user is logged in. $user = $request->getUser(); if (!$user->isAuthenticated()) { if (defined('FUSIONFORGE') and FUSIONFORGE) { $message->pushContent(HTML::div(array('class' => 'error'), HTML::p(_("You cannot upload files.")), HTML::ul(HTML::li(_("Check you are logged in.")), HTML::li(_("Check you are in the right project.")), HTML::li(_("Check you are a member of the current project."))))); } else { $message->pushContent(HTML::div(array('class' => 'error'), HTML::p(_("ACCESS DENIED: You must log in to upload files.")))); } $result = HTML(); $result->pushContent($form); $result->pushContent($message); return $result; } } $userfile = $request->getUploadedFile('userfile'); if ($userfile) { $userfile_name = $userfile->getName(); $userfile_name = trim(basename($userfile_name)); if (UPLOAD_USERDIR) { $file_dir .= $request->_user->_userid; if (!file_exists($file_dir)) { mkdir($file_dir, 0775); } $file_dir .= "/"; $u_userfile = $request->_user->_userid . "/" . $userfile_name; } else { $u_userfile = $userfile_name; } $u_userfile = preg_replace("/ /", "%20", $u_userfile); $userfile_tmpname = $userfile->getTmpName(); $err_header = HTML::div(array('class' => 'error'), HTML::p(fmt("ERROR uploading '%s'", $userfile_name))); if (preg_match("/(\\." . join("|\\.", $this->disallowed_extensions) . ")(\\.|\$)/i", $userfile_name)) { $message->pushContent($err_header); $message->pushContent(HTML::p(fmt("Files with extension %s are not allowed.", join(", ", $this->disallowed_extensions)))); } elseif (!DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS and !preg_match("/(\\." . join("|\\.", $this->allowed_extensions) . ")\$/i", $userfile_name)) { $message->pushContent($err_header); $message->pushContent(HTML::p(fmt("Only files with the extension %s are allowed.", join(", ", $this->allowed_extensions)))); } elseif (preg_match("/[^._a-zA-Z0-9- ]/", strip_accents($userfile_name))) { $message->pushContent($err_header); $message->pushContent(HTML::p(_("Invalid filename. File names may only contain alphanumeric characters and dot, underscore, space or dash."))); } elseif (file_exists($file_dir . $userfile_name)) { $message->pushContent($err_header); $message->pushContent(HTML::p(fmt("There is already a file with name %s uploaded.", $u_userfile))); } elseif ($userfile->getSize() > MAX_UPLOAD_SIZE) { $message->pushContent($err_header); $message->pushContent(HTML::p(_("Sorry but this file is too big."))); } elseif (move_uploaded_file($userfile_tmpname, $file_dir . $userfile_name) or IsWindows() and rename($userfile_tmpname, $file_dir . $userfile_name)) { $interwiki = new PageType_interwikimap(); $link = $interwiki->link("Upload:{$u_userfile}"); $message->pushContent(HTML::div(array('class' => 'feedback'), HTML::p(_("File successfully uploaded.")), HTML::p($link))); // the upload was a success and we need to mark this event in the "upload log" if ($logfile) { $upload_log = $file_dir . basename($logfile); $this->log($userfile, $upload_log, $message); } if ($autolink) { require_once "lib/loadsave.php"; $pagehandle = $dbi->getPage($page); if ($pagehandle->exists()) { // don't replace default contents $current = $pagehandle->getCurrentRevision(); $version = $current->getVersion(); $text = $current->getPackedContent(); $newtext = $text . "\n* Upload:{$u_userfile}"; // don't inline images $meta = $current->_data; $meta['summary'] = sprintf(_("uploaded %s"), $u_userfile); $pagehandle->save($newtext, $version + 1, $meta); } } } else { $message->pushContent($err_header); $message->pushContent(HTML::br(), _("Uploading failed."), HTML::br()); } } else { $message->pushContent(HTML::br(), _("No file selected. Please select one."), HTML::br()); } //$result = HTML::div( array( 'class' => 'wikiaction' ) ); $result = HTML(); $result->pushContent($form); $result->pushContent($message); return $result; }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if ($request->getArg('action') != _("PhpWikiAdministration/SetAclSimple")) { return $this->disabled("(action != 'browse')"); } } if (!ENABLE_PAGEPERM) { return $this->disabled("ENABLE_PAGEPERM = false"); } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); $post_args = $request->getArg('admin_setacl'); $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } elseif ($this->_list) { $pages = $this->_list; } $header = HTML::fieldset(); if ($p && $request->isPost() && (!empty($post_args['aclliberal']) || !empty($post_args['aclrestricted']))) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if (!empty($post_args['aclliberal'])) { return $this->setaclPages($request, array_keys($p), $this->liberalPerms()); } else { if (!empty($post_args['aclrestricted'])) { return $this->setaclPages($request, array_keys($p), $this->restrictedPerms()); } } } if (empty($pages)) { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('acl' => new _PageList_Column_acl('acl', _("ACL"))))); $pagelist->addPageList($pages); $button_label_liberal = _("Set Liberal Access Rights"); $button_label_restrictive = _("Set Restrictive Access Rights"); $header = $this->setaclForm($header, $pages); $header->pushContent(HTML::legend(_("Select the pages where to change access rights"))); $buttons = HTML::p(Button('submit:admin_setacl[aclliberal]', $button_label_liberal, 'wikiadmin'), Button('submit:admin_setacl[aclrestricted]', $button_label_restrictive, 'wikiadmin')); $header->pushContent($buttons); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_setacl')), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); }
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; }
function run($dbi, $argstr, &$request, $basepage) { return $this->disabled("This action is blocked by administrator. Sorry for the inconvenience !"); if (!DEBUG) { return $this->disabled("WikiAdminChmod not yet enabled. Set DEBUG to try it."); } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_chmod'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['chmod']) && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify') { // Real action return $this->chmodPages($dbi, $request, array_keys($p), $post_args['perm']); } if ($post_args['action'] == 'select') { if (!empty($post_args['perm'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,perm,author,mtime"; } $args['types'] = array('perm' => new _PageList_Column_chmod_perm('perm', _("Permission"))); $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header = $this->chmodForm($header, $post_args); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently change the selected files?")))); } else { $button_label = _("Chmod"); $header = $this->chmodForm($header, $post_args); $header->pushContent(HTML::p(_("Select the pages to change:"))); } $buttons = HTML::p(Button('submit:admin_chmod[chmod]', $button_label, 'wikiadmin'), Button('submit:admin_chmod[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_chmod')), HiddenInputs(array('admin_chmod[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }