Esempio n. 1
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"));
}
Esempio n. 2
0
 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;
 }
Esempio n. 3
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"));
}
Esempio n. 4
0
 static function redirect_to_action($r, $time = 0, $parameters = null)
 {
     $p = null;
     if (is_array($parameters)) {
         foreach ($parameters as $param => $value) {
             $p .= "&{$param}={$value}";
         }
     }
     echo "<meta http-equiv='Refresh' content='{$time}; url=index.php?ruta=" . $r . "" . $p . "'/>";
     echo HTML::br(2);
     echo MESSAGE_REDIRECT;
     //header("location: index.php?ruta=".$r."".$p."");
 }
Esempio n. 5
0
 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;
         }
     }
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $output = HTML(HTML::h1("Group Info"));
     $group = WikiGroup::getGroup();
     $allGroups = $group->getAllGroupsIn();
     foreach ($allGroups as $g) {
         $members = $group->getMembersOf($g);
         $output->pushContent(HTML::h3($g . " - members: " . sizeof($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no")));
         foreach ($members as $m) {
             $output->pushContent($m);
             $output->pushContent(HTML::br());
         }
     }
     $output->pushContent(HTML::p("--- the end ---"));
     return $output;
 }
Esempio n. 8
0
 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 == ' =&gt; ') ? ' &lt;= ' : ' =&gt; '\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('&nbsp;'), $direction, HTML::raw('&nbsp;'), $submit);
     return $form;
 }
Esempio n. 9
0
 function _do_syncwiki(&$request, $args)
 {
     global $charset;
     longer_timeout(240);
     if (!function_exists('wiki_xmlrpc_post')) {
         include_once "lib/XmlRpcClient.php";
     }
     $userid = $request->_user->_userid;
     $dbh = $request->getDbh();
     $merge_point = $dbh->get('mergepoint');
     if (empty($merge_point)) {
         $page = $dbh->getPage("ReleaseNotes");
         // this is usually the latest official page
         $last = $page->getCurrentRevision(false);
         $merge_point = $last->get("mtime");
         // for testing: 1160396075
         $dbh->set('mergepoint', $merge_point);
     }
     //TODO: remote auth, set session cookie
     $pagelist = wiki_xmlrpc_post('wiki.getRecentChanges', iso8601_encode($merge_point, 1), $args['url'], $args);
     $html = HTML();
     //$html->pushContent(HTML::div(HTML::em("check RPC2 interface...")));
     if (gettype($pagelist) === "array") {
         //$request->_deferredPageChangeNotification = array();
         $request->discardOutput();
         StartLoadDump($request, _("Syncing this PhpWiki"));
         PrintXML(HTML::strong(fmt("Download all externally changed sources.")));
         echo "<br />\n";
         PrintXML(fmt("Retrieving from external url %s wiki.getRecentChanges(%s)...", $args['url'], iso8601_encode($merge_point, 1)));
         echo "<br />\n";
         $ouriter = $dbh->mostRecent(array('since' => $merge_point));
         //$ol = HTML::ol();
         $done = array();
         foreach ($pagelist as $ext) {
             $reaction = _("<unknown>");
             // compare existance and dates with local page
             $extdate = iso8601_decode($ext['lastModified']->scalar, 1);
             // TODO: urldecode ???
             $name = utf8_decode($ext['name']);
             $our = $dbh->getPage($name);
             $done[$name] = 1;
             $ourrev = $our->getCurrentRevision(false);
             $rel = '<=>';
             if (!$our->exists()) {
                 // we might have deleted or moved it on purpose?
                 // check date of latest revision if there's one, and > mergepoint
                 if ($ourrev->getVersion() > 1 and $ourrev->get('mtime') > $merge_point) {
                     // our was deleted after sync, and changed after last sync.
                     $this->_addConflict('delete', $args, $our, $extdate);
                     $reaction = _(" skipped") . " (" . "locally deleted or moved" . ")";
                 } else {
                     $reaction = $this->_import($args, $our, $extdate);
                 }
             } else {
                 $ourdate = $ourrev->get('mtime');
                 if ($extdate > $ourdate and $ourdate < $merge_point) {
                     $rel = '>';
                     $reaction = $this->_import($args, $our, $extdate);
                 } elseif ($extdate > $ourdate and $ourdate >= $merge_point) {
                     $rel = '>';
                     // our is older then external but newer than last sync
                     $reaction = $this->_addConflict('import', $args, $our, $extdate);
                 } elseif ($extdate < $ourdate and $extdate < $merge_point) {
                     $rel = '>';
                     $reaction = $this->_export($args, $our);
                 } elseif ($extdate < $ourdate and $extdate >= $merge_point) {
                     $rel = '>';
                     // our is newer and external is also newer
                     $reaction = $this->_addConflict('export', $args, $our, $extdate);
                 } else {
                     $rel = '==';
                     $reaction = _("same date");
                 }
             }
             /*$ol->pushContent(HTML::li(HTML::strong($name)," ",
               $extdate,"<=>",$ourdate," ",
               HTML::strong($reaction))); */
             PrintXML(HTML::strong($name), " ", $extdate, " {$rel} ", $ourdate, " ", HTML::strong($reaction), HTML::br());
             $request->chunkOutput();
         }
         //$html->pushContent($ol);
     } else {
         $html->pushContent("xmlrpc error:  wiki.getRecentChanges returned " . "(" . gettype($pagelist) . ") " . $pagelist);
         trigger_error("xmlrpc error:  wiki.getRecentChanges returned " . "(" . gettype($pagelist) . ") " . $pagelist, E_USER_WARNING);
         EndLoadDump($request);
         return $this->error($html);
     }
     if (empty($args['noexport'])) {
         PrintXML(HTML::strong(fmt("Now upload all locally newer pages.")));
         echo "<br />\n";
         PrintXML(fmt("Checking all local pages newer than %s...", iso8601_encode($merge_point, 1)));
         echo "<br />\n";
         while ($our = $ouriter->next()) {
             $name = $our->getName();
             if ($done[$name]) {
                 continue;
             }
             $reaction = _(" skipped");
             $ext = wiki_xmlrpc_post('wiki.getPageInfo', $name, $args['url']);
             if (is_array($ext)) {
                 $extdate = iso8601_decode($ext['lastModified']->scalar, 1);
                 $ourdate = $our->get('mtime');
                 if ($extdate < $ourdate and $extdate < $merge_point) {
                     $reaction = $this->_export($args, $our);
                 } elseif ($extdate < $ourdate and $extdate >= $merge_point) {
                     // our newer and external newer
                     $reaction = $this->_addConflict($args, $our, $extdate);
                 }
             } else {
                 $reaction = 'xmlrpc error';
             }
             PrintXML(HTML::strong($name), " ", $extdate, " < ", $ourdate, " ", HTML::strong($reaction), HTML::br());
             $request->chunkOutput();
         }
         PrintXML(HTML::strong(fmt("Now upload all locally newer uploads.")));
         echo "<br />\n";
         PrintXML(fmt("Checking all local uploads newer than %s...", iso8601_encode($merge_point, 1)));
         echo "<br />\n";
         $this->_fileList = array();
         $prefix = getUploadFilePath();
         $this->_dir($prefix);
         $len = strlen($prefix);
         foreach ($this->_fileList as $path) {
             // strip prefix
             $file = substr($path, $len);
             $ourdate = filemtime($path);
             $oursize = filesize($path);
             $reaction = _(" skipped");
             $ext = wiki_xmlrpc_post('wiki.getUploadedFileInfo', $file, $args['url']);
             if (is_array($ext)) {
                 $extdate = iso8601_decode($ext['lastModified']->scalar, 1);
                 $extsize = $ext['size'];
                 if (empty($extsize) or $extdate < $ourdate) {
                     $timeout = $oursize * 0.0002;
                     // assume 50kb/sec upload speed
                     $reaction = $this->_upload($args, $path, $timeout);
                 }
             } else {
                 $reaction = 'xmlrpc error wiki.getUploadedFileInfo not supported';
             }
             PrintXML(HTML::strong($name), " ", "{$extdate} ({$extsize}) < {$ourdate} ({$oursize})", HTML::strong($reaction), HTML::br());
             $request->chunkOutput();
         }
     }
     $dbh->set('mergepoint', time());
     EndLoadDump($request);
     return '';
     //$html;
 }
Esempio n. 10
0
 function setaclForm(&$header, $post_args, $pagehash)
 {
     $acl = $post_args['acl'];
     //FIXME: find intersection of all pages perms, not just from the last pagename
     $pages = array();
     foreach ($pagehash as $name => $checked) {
         if ($checked) {
             $pages[] = $name;
         }
     }
     $perm_tree = pagePermissions($name);
     $table = pagePermissionsAclFormat($perm_tree, !empty($pages));
     $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
     $first_page = $GLOBALS['request']->_dbi->getPage($name);
     $owner = $first_page->getOwner();
     list($type, $perm) = pagePermissionsAcl($perm_tree[0], $perm_tree);
     //if (DEBUG) $header->pushContent(HTML::pre("Permission tree for $name:\n",print_r($perm_tree,true)));
     if ($type == 'inherited') {
         $type = sprintf(_("page permission inherited from %s"), $perm_tree[1][0]);
     } elseif ($type == 'page') {
         $type = _("individual page permission");
     } elseif ($type == 'default') {
         $type = _("default page permission");
     }
     $header->pushContent(HTML::strong(_("Type") . ': '), HTML::tt($type), HTML::br());
     $header->pushContent(HTML::strong(_("ACL") . ': '), HTML::tt($perm->asAclLines()), HTML::br());
     $header->pushContent(HTML::p(HTML::strong(_("Description") . ': '), _("Selected Grant checkboxes allow access, unselected checkboxes deny access."), _("To ignore delete the line."), _("To add check 'Add' near the dropdown list.")));
     $header->pushContent($table);
     //
     // display array of checkboxes for existing perms
     // and a dropdown for user/group to add perms.
     // disabled if inherited,
     // checkbox to disable inheritance,
     // another checkbox to progate new permissions to all childs (if there exist some)
     //Todo:
     // warn if more pages are selected and they have different perms
     //$header->pushContent(HTML::input(array('name' => 'admin_setacl[acl]',
     //                                       'value' => $post_args['acl'])));
     $header->pushContent(HTML::br());
     if (!empty($pages) and defined('EXPERIMENTAL') and EXPERIMENTAL) {
         $checkbox = HTML::input(array('type' => 'checkbox', 'name' => 'admin_setacl[updatechildren]', 'value' => 1));
         if (!empty($post_args['updatechildren'])) {
             $checkbox->setAttr('checked', 'checked');
         }
         $header->pushContent($checkbox, _("Propagate new permissions to all subpages?"), HTML::raw("&nbsp;&nbsp;"), HTML::em(_("(disable individual page permissions, enable inheritance)?")), HTML::br(), HTML::em(_("(Currently not working)")));
     }
     $header->pushContent(HTML::hr());
     return $header;
 }
Esempio n. 11
0
 public function usuarioEdit($usuario_id, $usuario_tipo)
 {
     $getDataDB = new DB();
     $login = new ModelLogin();
     $image = new ModelImage();
     switch ($usuario_tipo) {
         case "musico":
             if (isset($_POST['form_edit_account'])) {
                 if (empty($_POST['usuario_nombre'])) {
                     echo MESSAGE_FORM_NOMBRE_EMPTY;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif (!preg_match('/^[a-z\\d]{2,64}$/i', $_POST['usuario_telefono'])) {
                     echo MESSAGE_FORM_TELEFONO_EMPTY;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif (strlen($_POST['usuario_telefono']) != 9) {
                     echo MESSAGE_FORM_TELEFONO_INVALID;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif ($_POST['usuario_idioma'] == "") {
                     $_POST['usuario_idioma'] == $login->getUserDataCampo($usuario_id, "usuario_idioma");
                 } elseif ($_POST['usuario_idioma'] != "ca" && $_POST['usuario_idioma'] != "en" && $_POST['usuario_idioma'] != "es") {
                     echo MESSAGE_FORM_IDIOMA;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif ($_POST['usuario_idioma'] != "ca" && $_POST['usuario_idioma'] != "en" && $_POST['usuario_idioma'] != "es") {
                     echo MESSAGE_FORM_IDIOMA;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } else {
                     $query_mod_account = DB::connect()->prepare("UPDATE  `uqfhhbcn_whymusic`.`wm_usuarios` SET  `usuario_nombre` =  :usuario_nombre,\n                `usuario_telefono` =  :usuario_telefono,\n                `usuario_idioma` = :usuario_idioma,\n                `usuario_descripcion` = :usuario_descripcion,\n                `estilo_id` = :estilo_id WHERE  `wm_usuarios`.`usuario_id` = :usuario_id;");
                     $query_mod_account->bindValue(':usuario_id', $usuario_id, PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_nombre', $_POST['usuario_nombre'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_idioma', $_POST['usuario_idioma'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_telefono', $_POST['usuario_telefono'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_descripcion', $_POST['usuario_descripcion'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':estilo_id', $_POST['estilo_nombre'], PDO::PARAM_STR);
                     $query_mod_account->execute();
                     if ($query_mod_account) {
                         echo MESSAGE_CORRECT_MOD;
                         if ($login->getTypeOfUser() == "administrador") {
                             ROUTER::redirect_to_action("admin/admin", 2);
                         } else {
                             ROUTER::redirect_to_action("account/edit", 2);
                         }
                     } else {
                         echo MESSAGE_ERROR_SQL;
                         echo HTML::br(2);
                         echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                     }
                 }
             } else {
                 echo HTML::title("h3", "Editar foto de perfil");
                 echo HTML::open_form(ROUTER::create_action_url("account/edit"), "POST", "fileToUpload", array("enctype" => "multipart/form-data"));
                 echo HTML::label("fileToUpload", "Sube tu foto");
                 echo HTML::input("file", "fileToUpload", null, array("id" => "fileToUpload"));
                 echo HTML::br(1);
                 echo HTML::input("submit", "usuario_foto", "Subir foto");
                 echo HTML::close_form();
                 echo HTML::open_form(ROUTER::create_action_url('account/edit'), "POST", "form_edit_account");
                 /*Guarrada provisional*/
                 $_SESSION['usuario_id_edit'] = $login->getUserDataCampo($usuario_id, "usuario_id");
                 $_SESSION['usuario_tipo_edit'] = $login->getUserDataCampo($usuario_id, "usuario_tipo");
                 /*Fin de la gurrada*/
                 echo HTML::title("h3", "Editar foto de perfil");
                 echo HTML::open_form(ROUTER::create_action_url("account/edit"), "POST", "usuario_foto", array("enctype" => "multipart/form-data"));
                 echo HTML::label("usuario_foto", "Sube tu foto");
                 echo HTML::input("file", "fileToUpload", null, array("id" => "fileToUpload"));
                 echo HTML::input("submit", "usuario_foto", "Subir foto");
                 echo HTML::close_form();
                 echo HTML::label("usuario_nombre", WORDING_NOMBRE_MUSICO);
                 echo HTML::input("text", "usuario_nombre", $login->getUserDataCampo($usuario_id, "usuario_nombre"), array("placeholder" => "Su nombre"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_idioma", WORDING_IDIOMA);
                 echo HTML::select("usuario_idioma", array("Idioma por defecto" => $login->getUserDataCampo($usuario_id, 'usuario_idioma'), "Inglés" => "en", "Castellano" => "es", "Catalán" => "ca"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_telefono", WORDING_TELEFON);
                 echo HTML::input("text", "usuario_telefono", $login->getUserDataCampo($usuario_id, "usuario_telefono"), array("placeholder" => "9XXXXXXXX"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_descripcion", "Descripción grupo:");
                 echo HTML::textArea("4", "50", $login->getUserDataCampo($usuario_id, "usuario_descripcion"), "usuario_descripcion");
                 echo HTML::br(2);
                 echo HTML::label("estilo_nombre", "Estilo de música:");
                 echo HTML::selectArray("estilo_nombre", $getDataDB->getFieldSQL("wm_estilo", "estilo_nombre , estilo_id", ""));
                 echo HTML::br(2);
                 echo HTML::button_HTML5("submit", BUTTON_MOD_DATA, "form_edit_account");
                 echo HTML::close_form();
             }
             break;
         case "local":
             if (isset($_POST['form_edit_account'])) {
                 if (empty($_POST['usuario_nombre'])) {
                     echo MESSAGE_FORM_NOMBRE_EMPTY;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif (!preg_match('/^[a-z\\d]{2,64}$/i', $_POST['usuario_telefono'])) {
                     echo MESSAGE_FORM_TELEFONO_EMPTY;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif (strlen($_POST['usuario_telefono']) != 9) {
                     echo MESSAGE_FORM_TELEFONO_INVALID;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif ($_POST['usuario_idioma'] == "") {
                     $_POST['usuario_idioma'] == $login->getUserDataCampo($usuario_id, "usuario_idioma");
                 } elseif ($_POST['usuario_idioma'] != "ca" && $_POST['usuario_idioma'] != "en" && $_POST['usuario_idioma'] != "es") {
                     echo MESSAGE_FORM_IDIOMA;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } else {
                     $query_mod_account = DB::connect()->prepare("UPDATE  `uqfhhbcn_whymusic`.`wm_usuarios` SET  `usuario_nombre` =  :usuario_nombre,\n                `usuario_telefono` =  :usuario_telefono,\n                `usuario_direccion` =  :usuario_direccion,\n                `usuario_descripcion` =  :usuario_descripcion,\n                `usuario_lat` =  :usuario_lat,\n                `usuario_lon` =  :usuario_lon,\n                `usuario_idioma` = :usuario_idioma WHERE  `wm_usuarios`.`usuario_id` = :usuario_id;");
                     $query_mod_account->bindValue(':usuario_id', $usuario_id, PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_nombre', $_POST['usuario_nombre'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_direccion', $_POST['usuario_direccion'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_descripcion', $_POST['usuario_descripcion'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_lon', $_POST['usuario_lon'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_lat', $_POST['usuario_lat'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_idioma', $_POST['usuario_idioma'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_telefono', $_POST['usuario_telefono'], PDO::PARAM_STR);
                     $query_mod_account->execute();
                     if ($query_mod_account) {
                         echo MESSAGE_CORRECT_MOD;
                         if ($login->getTypeOfUser() == "administrador") {
                             ROUTER::redirect_to_action("admin/admin", 2);
                         } else {
                             ROUTER::redirect_to_action("account/edit", 2);
                         }
                     } else {
                         echo MESSAGE_ERROR_SQL;
                         echo HTML::br(2);
                         echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                     }
                 }
             } else {
                 echo HTML::title("h3", "Editar foto de perfil");
                 echo HTML::open_form(ROUTER::create_action_url("account/edit"), "POST", "fileToUpload", array("enctype" => "multipart/form-data"));
                 echo HTML::label("fileToUpload", "Sube tu foto");
                 echo HTML::input("file", "fileToUpload", null, array("id" => "fileToUpload"));
                 echo HTML::br(1);
                 echo HTML::input("submit", "usuario_foto", "Subir foto");
                 echo HTML::close_form();
                 echo HTML::open_form(ROUTER::create_action_url('account/edit'), "POST", "form_edit_account");
                 /*Guarrada provisional*/
                 $_SESSION['usuario_id_edit'] = $login->getUserDataCampo($usuario_id, "usuario_id");
                 $_SESSION['usuario_tipo_edit'] = $login->getUserDataCampo($usuario_id, "usuario_tipo");
                 /*Fin de la gurrada*/
                 echo HTML::label("usuario_nombre", WORDING_NOMBRE_LOCAL);
                 echo HTML::input("text", "usuario_nombre", $login->getUserDataCampo($usuario_id, "usuario_nombre"), array("placeholder" => "Su nombre"));
                 echo HTML::br(2);
                 echo HTML::label("Gmaps", "Selecciona tu ubicación:");
                 echo HTML::open_div(array("id" => "myMap"));
                 echo HTML::close_div();
                 echo HTML::br(2);
                 echo HTML::label("usuario_direccion", WORDING_DIRECCION);
                 echo HTML::input("text", "usuario_direccion", $login->getUserDataCampo($usuario_id, 'usuario_direccion'), array("id" => "address", "style" => "width:600px;"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_lat", WORDING_LATITUD);
                 echo HTML::input("text", "usuario_lat", $login->getUserDataCampo($usuario_id, 'usuario_lat'), array("id" => "latitude"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_lon", WORDING_LONGITUD);
                 echo HTML::input("text", "usuario_lon", $login->getUserDataCampo($usuario_id, 'usuario_lon'), array("id" => "longitude"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_idioma", WORDING_IDIOMA);
                 echo HTML::select("usuario_idioma", array("Idioma por defecto" => $login->getUserDataCampo($usuario_id, 'usuario_idioma'), "Inglés" => "en", "Castellano" => "es", "Catalán" => "ca"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_telefono", WORDING_TELEFON);
                 echo HTML::input("text", "usuario_telefono", $login->getUserDataCampo($usuario_id, "usuario_telefono"), array("placeholder" => "9XXXXXXXX"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_descripcion", "Descripción grupo:");
                 echo HTML::textArea("4", "50", $login->getUserDataCampo($usuario_id, "usuario_descripcion"), "usuario_descripcion");
                 echo HTML::br(2);
                 echo HTML::label("estilo_nombre", WORDING_PROFILE_ESTILO);
                 echo HTML::selectArray("estilo_nombre", $getDataDB->getFieldSQL("wm_estilo", "estilo_nombre , estilo_id", ""));
                 echo HTML::br(2);
                 echo HTML::button_HTML5("submit", BUTTON_MOD_DATA, "form_edit_account");
                 echo HTML::close_form();
             }
             break;
             /**
              * FORM FAN
              */
         /**
          * FORM FAN
          */
         case "fan":
             if (isset($_POST['form_edit_account'])) {
                 if (empty($_POST['usuario_nombre'])) {
                     echo MESSAGE_FORM_NOMBRE_EMPTY;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif ($_POST['usuario_idioma'] == "") {
                     $_POST['usuario_idioma'] == $login->getUserDataCampo($usuario_id, "usuario_idioma");
                 } elseif ($_POST['usuario_idioma'] != "ca" && $_POST['usuario_idioma'] != "en" && $_POST['usuario_idioma'] != "es") {
                     echo MESSAGE_FORM_IDIOMA;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } elseif ($_POST['usuario_idioma'] != "ca" && $_POST['usuario_idioma'] != "en" && $_POST['usuario_idioma'] != "es") {
                     echo MESSAGE_FORM_IDIOMA;
                     echo HTML::br(2);
                     echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                 } else {
                     $query_mod_account = DB::connect()->prepare("UPDATE  `uqfhhbcn_whymusic`.`wm_usuarios` SET  \n                `usuario_nombre` =  :usuario_nombre,\n                `usuario_apellido1` =  :usuario_apellido1,\n                `usuario_apellido2` =  :usuario_apellido2,\n                `usuario_idioma` = :usuario_idioma \n                 WHERE  `wm_usuarios`.`usuario_id` = :usuario_id;");
                     $query_mod_account->bindValue(':usuario_id', $usuario_id, PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_nombre', $_POST['usuario_nombre'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_apellido1', $_POST['usuario_apellido1'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_apellido2', $_POST['usuario_apellido2'], PDO::PARAM_STR);
                     $query_mod_account->bindValue(':usuario_idioma', $_POST['usuario_idioma'], PDO::PARAM_STR);
                     $query_mod_account->execute();
                     if ($query_mod_account) {
                         echo MESSAGE_CORRECT_MOD;
                         if ($login->getTypeOfUser() == "administrador") {
                             ROUTER::redirect_to_action("admin/admin", 2);
                         } else {
                             ROUTER::redirect_to_action("account/edit", 2);
                         }
                     } else {
                         echo MESSAGE_ERROR_SQL;
                         echo HTML::br(2);
                         echo "<a href='javascript:history.back()'> Volver Atrás</a>";
                     }
                 }
             } else {
                 echo HTML::title("h3", "Editar foto de perfil");
                 echo HTML::open_form(ROUTER::create_action_url("account/edit"), "POST", "fileToUpload", array("enctype" => "multipart/form-data"));
                 echo HTML::label("fileToUpload", "Sube tu foto");
                 echo HTML::input("file", "fileToUpload", null, array("id" => "fileToUpload"));
                 echo HTML::br(1);
                 echo HTML::input("submit", "usuario_foto", "Subir foto");
                 echo HTML::close_form();
                 echo HTML::open_form(ROUTER::create_action_url('account/edit'), "POST", "form_edit_account");
                 echo HTML::title("h3", "Edición de los datos de usuario");
                 /*Guarrada provisional*/
                 $_SESSION['usuario_id_edit'] = $login->getUserDataCampo($usuario_id, "usuario_id");
                 $_SESSION['usuario_tipo_edit'] = $login->getUserDataCampo($usuario_id, "usuario_tipo");
                 /*Fin de la gurrada*/
                 echo HTML::label("usuario_nombre", WORDING_NOMBRE);
                 echo HTML::input("text", "usuario_nombre", $login->getUserDataCampo($usuario_id, "usuario_nombre"), array("placeholder" => "Su nombre"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_apellido1", WORDING_APELLIDO1);
                 echo HTML::input("text", "usuario_apellido1", $login->getUserDataCampo($usuario_id, "usuario_apellido1"), array("placeholder" => "Su nombre"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_apellido2", WORDING_APELLIDO2);
                 echo HTML::input("text", "usuario_apellido2", $login->getUserDataCampo($usuario_id, "usuario_apellido2"), array("placeholder" => "Su nombre"));
                 echo HTML::br(2);
                 echo HTML::label("usuario_idioma", WORDING_IDIOMA);
                 echo HTML::select("usuario_idioma", array("Idioma por defecto" => $login->getUserDataCampo($usuario_id, 'usuario_idioma'), "Inglés" => "en", "Castellano" => "es", "Catalán" => "ca"));
                 echo HTML::br(2);
                 echo HTML::button_HTML5("submit", BUTTON_MOD_DATA, "form_edit_account");
                 echo HTML::close_form();
             }
             break;
         case "administrador":
             echo "DESDE LA BASE DE DATOS";
             break;
         default:
             echo "No tienes permisos para estar aquí...";
             break;
     }
 }
Esempio n. 12
0
 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;
 }
Esempio n. 13
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     //$this->_request = & $request;
     //$this->_dbi = & $dbi;
     $user = $request->getUser();
     //FIXME: fails on test with DumpHtml:RateIt
     if (!is_object($user)) {
         return HTML::raw('');
     }
     $this->userid = $user->getId();
     if (!$this->userid) {
         return HTML::raw('');
     }
     $args = $this->getArgs($argstr, $request);
     $this->dimension = $args['dimension'];
     $this->imgPrefix = $args['imgPrefix'];
     if ($this->dimension == '') {
         $this->dimension = 0;
         $args['dimension'] = 0;
     }
     if ($args['pagename']) {
         // Expand relative page names.
         $page = new WikiPageName($args['pagename'], $basepage);
         $args['pagename'] = $page->name;
     }
     if (empty($args['pagename'])) {
         return $this->error(_("no page specified"));
     }
     $this->pagename = $args['pagename'];
     $rdbi = RatingsDb::getTheRatingsDb();
     $this->_rdbi =& $rdbi;
     if ($args['mode'] === 'add') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $this->rating = $request->getArg('rating');
         $rdbi->addRating($this->rating, $this->userid, $this->pagename, $this->dimension);
         $this->displayActionImg('add');
     } elseif ($args['mode'] === 'delete') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $rdbi->deleteRating($this->userid, $this->pagename, $this->dimension);
         unset($this->rating);
         $this->displayActionImg('delete');
     } elseif (!$args['show']) {
         return $this->RatingWidgetHtml($args['pagename'], $args['version'], $args['imgPrefix'], $args['dimension'], $args['small']);
     } else {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         //extract($args);
         $this->rating = $rdbi->getRating($this->userid, $this->pagename, $this->dimension);
         $this->avg = $rdbi->getAvg($this->pagename, $this->dimension);
         $this->numusers = $rdbi->getNumUsers($this->pagename, $this->dimension);
         // Update this text on rateit in javascript. needed: NumUsers, Avg
         $html = HTML::div(HTML::span(array('class' => 'rateit'), sprintf(_("Rating: %.1f (%d votes)"), $this->avg, $this->numusers)));
         if ($args['show'] == 'top') {
             if (ENABLE_PAGE_PUBLIC) {
                 $page = $dbi->getPage($this->pagename);
                 if ($page->get('public')) {
                     $html->setAttr('class', "public");
                 }
             }
             $html->setAttr('id', "rateit-widget-top");
             $html->pushContent(HTML::br(), $this->RatingWidgetHtml($args['pagename'], $args['version'], $args['imgPrefix'], $args['dimension'], $args['small']));
         } elseif ($args['show'] == 'text') {
             if (!$WikiTheme->DUMP_MODE) {
                 $html->pushContent(HTML::br(), sprintf(_("Your rating was %.1f"), $this->rating));
             }
         } elseif ($this->rating) {
             $html->pushContent(HTML::br(), sprintf(_("Your rating was %.1f"), $this->rating));
         } else {
             $this->pred = $rdbi->getPrediction($this->userid, $this->pagename, $this->dimension);
             if (is_string($this->pred)) {
                 $html->pushContent(HTML::br(), sprintf(_("Prediction: %s"), $this->pred));
             } elseif ($this->pred) {
                 $html->pushContent(HTML::br(), sprintf(_("Prediction: %.1f"), $this->pred));
             }
         }
         //$html->pushContent(HTML::p());
         //$html->pushContent(HTML::em("(Experimental: This might be entirely bogus data)"));
         return $html;
     }
 }
Esempio n. 14
0
<?php

$login = new ModelLogin();
$concert = new Concert();
foreach ($concert->getConciertoAll(null, "aceptado") as $row) {
    echo HTML::open_div(array("class" => "col-lg-6"));
    echo HTML::title("h3", "Concierto de " . $login->getUserDataCampo($row['musico_id'], "usuario_nombre") . " en " . $login->getUserDataCampo($row['local_id'], "usuario_nombre"));
    echo HTML::label("concierto_fecha", "Fecha:");
    echo $row['concierto_fecha'];
    echo HTML::br(2);
    echo HTML::label("concierto_precio", "Precio entrada:");
    echo $row['concierto_precio'] . "€";
    echo HTML::br(2);
    echo HTML::label("concierto_duracion", "Duración concierto:");
    echo $row['concierto_duracion'] . " min";
    echo HTML::br(2);
    echo HTML::label("concierto_asistentes", "Aforo:");
    echo $row['concierto_asistentes'];
    echo HTML::close_div();
}
 function getDocumentPath($id, $group_id, $referrer_id = null)
 {
     $parents = array();
     $html = HTML();
     $hp =& Codendi_HTMLPurifier::instance();
     $item_factory =& $this->_getItemFactory($group_id);
     $item =& $item_factory->getItemFromDb($id);
     $reference =& $item;
     if ($reference && $referrer_id != $id) {
         while ($item && $item->getParentId() != 0) {
             $item =& $item_factory->getItemFromDb($item->getParentId());
             $parents[] = array('id' => $item->getId(), 'title' => $item->getTitle());
         }
         $parents = array_reverse($parents);
         $item_url = '/plugins/docman/?group_id=' . $group_id . '&sort_update_date=0&action=show&id=';
         foreach ($parents as $parent) {
             $html->pushContent(HTML::a(array('href' => $item_url . $parent['id'], 'target' => '_blank'), HTML::strong($parent['title'])));
             $html->pushContent(' / ');
         }
         $md_uri = '/plugins/docman/?group_id=' . $group_id . '&action=details&id=' . $id;
         //Add a pen icon linked to document properties.
         $pen_icon = HTML::a(array('href' => $md_uri), HTML::img(array('src' => util_get_image_theme("ic/edit.png"))));
         $html->pushContent(HTML::a(array('href' => $item_url . $reference->getId()), HTML::strong($reference->getTitle())));
         $html->pushContent($pen_icon);
         $html->pushContent(HTML::br());
     }
     return $html;
 }
Esempio n. 16
0
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('&nbsp;'), Button("submit:dbadmin[cancel]", _("Cancel"), 'button')))));
        $form->printXml();
        echo "</div><!-- content -->\n";
        echo asXML(Template("bottom"));
        echo "</body></html>\n";
        $request->finish();
        exit;
    }
}
Esempio n. 17
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     //$this->_request = & $request;
     //$this->_dbi = & $dbi;
     $user = $request->getUser();
     //FIXME: fails on test with DumpHtml:RateIt
     if (!is_object($user)) {
         return HTML();
     }
     $this->userid = $user->getId();
     $args = $this->getArgs($argstr, $request);
     $this->dimension = $args['dimension'];
     $this->imgPrefix = $args['imgPrefix'];
     if ($this->dimension == '') {
         $this->dimension = 0;
         $args['dimension'] = 0;
     }
     if ($args['pagename']) {
         // Expand relative page names.
         $page = new WikiPageName($args['pagename'], $basepage);
         $args['pagename'] = $page->name;
     }
     if (empty($args['pagename'])) {
         return $this->error(_("no page specified"));
     }
     $this->pagename = $args['pagename'];
     $rdbi = RatingsDb::getTheRatingsDb();
     $this->_rdbi =& $rdbi;
     if ($args['mode'] === 'add') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $actionImg = $WikiTheme->_path . $this->actionImgPath();
         $rdbi->addRating($request->getArg('rating'), $this->userid, $this->pagename, $this->dimension);
         if (!empty($request->_is_buffering_output)) {
             ob_end_clean();
         }
         // discard any previous output
         // delete the cache
         $page = $request->getPage();
         //$page->set('_cached_html', false);
         $request->cacheControl('MUST-REVALIDATE');
         $dbi->touch();
         //fake validators without args
         $request->appendValidators(array('wikiname' => WIKI_NAME, 'args' => wikihash('')));
         header('Content-type: image/png');
         readfile($actionImg);
         exit;
     } elseif ($args['mode'] === 'delete') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $actionImg = $WikiTheme->_path . $this->actionImgPath();
         $rdbi->deleteRating($this->userid, $this->pagename, $this->dimension);
         if (!empty($request->_is_buffering_output)) {
             ob_end_clean();
         }
         // discard any previous output
         // delete the cache
         $page = $request->getPage();
         //$page->set('_cached_html', false);
         $request->cacheControl('MUST-REVALIDATE');
         $dbi->touch();
         //fake validators without args
         $request->appendValidators(array('wikiname' => WIKI_NAME, 'args' => wikihash('')));
         header('Content-type: image/png');
         readfile($actionImg);
         exit;
     } elseif (!$args['show']) {
         return $this->RatingWidgetHtml($args['pagename'], $args['version'], $args['imgPrefix'], $args['dimension'], $args['small']);
     } else {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         //extract($args);
         $rating = $rdbi->getRating();
         $html = HTML::p($this->pagename . ": " . sprintf(_("Rated by %d users | Average rating %.1f stars"), $rdbi->getNumUsers($this->pagename, $this->dimension), $rdbi->getAvg($this->pagename, $this->dimension)), HTML::br());
         if ($rating) {
             $html->pushContent(sprintf(_("Your rating was %.1f"), $rating));
         } else {
             $pred = $rdbi->getPrediction($this->userid, $this->pagename, $this->dimension);
             if (is_string($pred)) {
                 $html->pushContent(sprintf(_("%s prediction for you is %s stars"), WIKI_NAME, $pred));
             } elseif ($pred) {
                 $html->pushContent(sprintf(_("%s prediction for you is %.1f stars"), WIKI_NAME, $pred));
             }
         }
         //$html->pushContent(HTML::p());
         //$html->pushContent(HTML::em("(Experimental: This might be entirely bogus data)"));
         return $html;
     }
 }
Esempio n. 18
0
 /** Header of the Anti Spam message 
  */
 function getSpamMessage()
 {
     return HTML(HTML::h2(_("Spam Prevention")), HTML::p(_("This page edit seems to contain spam and was therefore not saved."), HTML::br(), _("Sorry for the inconvenience.")), HTML::p(""));
 }
Esempio n. 19
0
function _DumpHtmlToDir($target, $page_iter, $exclude = false)
{
    global $WikiTheme, $request, $ErrorManager;
    $silent = true;
    $zip = false;
    $directory = false;
    if ($WikiTheme->DUMP_MODE == 'HTML') {
        $directory = $target;
        $silent = false;
    } elseif ($WikiTheme->DUMP_MODE == 'PDFHTML') {
        $directory = $target;
    } elseif (is_object($target)) {
        // $WikiTheme->DUMP_MODE == 'ZIPHTML'
        $zip = $target;
    }
    $request->_TemplatesProcessed = array();
    if ($exclude) {
        // exclude which pagenames
        $excludeList = explodePageList($exclude);
    } else {
        $excludeList = array('DebugAuthInfo', 'DebugGroupInfo', 'AuthInfo');
    }
    $WikiTheme->VALID_LINKS = array();
    if ($request->getArg('format')) {
        // pagelist
        $page_iter_sav = $page_iter;
        foreach ($page_iter_sav->asArray() as $handle) {
            $WikiTheme->VALID_LINKS[] = is_string($handle) ? $handle : $handle->getName();
        }
        $page_iter_sav->reset();
    }
    if (defined('HTML_DUMP_SUFFIX')) {
        $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
    }
    $_bodyAttr = @$WikiTheme->_MoreAttr['body'];
    unset($WikiTheme->_MoreAttr['body']);
    $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
    // check if the dumped file will be accessible from outside
    $doc_root = $request->get("DOCUMENT_ROOT");
    if ($WikiTheme->DUMP_MODE == 'HTML') {
        $ldir = NormalizeLocalFileName($directory);
        $wikiroot = NormalizeLocalFileName('');
        if (string_starts_with($ldir, $doc_root)) {
            $link_prefix = substr($directory, strlen($doc_root)) . "/";
        } elseif (string_starts_with($ldir, $wikiroot)) {
            $link_prefix = NormalizeWebFileName(substr($directory, strlen($wikiroot))) . "/";
        } else {
            $prefix = '';
            if (isWindows()) {
                $prefix = '/';
                // . substr($doc_root,0,2); // add drive where apache is installed
            }
            $link_prefix = "file://" . $prefix . $directory . "/";
        }
    } else {
        $link_prefix = "";
    }
    $request_args = $request->args;
    $timeout = !$request->getArg('start_debug') ? 60 : 240;
    if ($directory) {
        if (isWindows()) {
            $directory = str_replace("\\", "/", $directory);
        }
        // no Win95 support.
        @mkdir("{$directory}/images");
    }
    $already = array();
    $outfiles = array();
    $already_images = array();
    while ($page = $page_iter->next()) {
        if (is_string($page)) {
            $pagename = $page;
            $page = $request->_dbi->getPage($pagename);
        } else {
            $pagename = $page->getName();
        }
        if (empty($firstpage)) {
            $firstpage = $pagename;
        }
        if (array_key_exists($pagename, $already)) {
            continue;
        }
        $already[$pagename] = 1;
        $current = $page->getCurrentRevision();
        //if ($current->getVersion() == 0)
        //    continue;
        $request->args = $request_args;
        // some plugins might change them (esp. on POST)
        longer_timeout($timeout);
        // Reset watchdog
        if ($zip) {
            $attrib = array('mtime' => $current->get('mtime'), 'is_ascii' => 1);
            if ($page->get('locked')) {
                $attrib['write_protected'] = 1;
            }
        } elseif (!$silent) {
            if (!isa($request, 'MockRequest')) {
                PrintXML(HTML::br(), $pagename, ' ... ');
                flush();
            }
        }
        if (in_array($pagename, $excludeList)) {
            if (!$silent and !isa($request, 'MockRequest')) {
                PrintXML(_("Skipped."));
                flush();
            }
            continue;
        }
        $relative_base = '';
        if ($WikiTheme->DUMP_MODE == 'PDFHTML') {
            $request->setArg('action', 'pdf');
        }
        // to omit cache headers
        $request->setArg('pagename', $pagename);
        // Template::_basepage fix
        $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX;
        $args = array('revision' => $current, 'CONTENT' => $current->getTransformedContent(), 'relative_base' => $relative_base);
        // For every %2F will need to mkdir -p dirname($pagename)
        if (preg_match("/(%2F|\\/)/", $filename)) {
            // mkdir -p and set relative base for subdir pages
            $filename = preg_replace("/%2F/", "/", $filename);
            $count = substr_count($filename, "/");
            $dirname = dirname($filename);
            if ($directory) {
                mkdir_p($directory . "/" . $dirname);
            }
            // Fails with "XX / YY", "XX" is created, "XX / YY" cannot be written
            // if (isWindows()) // interesting Windows bug: cannot mkdir "bla "
            // Since dumps needs to be copied, we have to disallow this for all platforms.
            $filename = preg_replace("/ \\//", "/", $filename);
            $relative_base = "../";
            while ($count > 1) {
                $relative_base .= "../";
                $count--;
            }
            $args['relative_base'] = $relative_base;
        }
        $msg = HTML();
        $DUMP_MODE = $WikiTheme->DUMP_MODE;
        $data = GeneratePageasXML(new Template('browse', $request, $args), $pagename, $current, $args);
        $WikiTheme->DUMP_MODE = $DUMP_MODE;
        if (preg_match_all("/<img .*?src=\"(\\/.+?)\"/", $data, $m)) {
            // fix to local relative path for uploaded images, so that pdf will work
            foreach ($m[1] as $img_file) {
                $base = basename($img_file);
                $data = str_replace('src="' . $img_file . '"', 'src="images/' . $base . '"', $data);
                if (array_key_exists($img_file, $already_images)) {
                    continue;
                }
                $already_images[$img_file] = 1;
                // resolve src from webdata to file
                $src = $doc_root . $img_file;
                if (file_exists($src) and $base) {
                    if ($directory) {
                        $target = "{$directory}/images/{$base}";
                        if (copy($src, $target)) {
                            if (!$silent) {
                                _copyMsg($img_file, fmt("... copied to %s", $target));
                            }
                        } else {
                            if (!$silent) {
                                _copyMsg($img_file, fmt("... not copied to %s", $target));
                            }
                        }
                    } else {
                        $target = "images/{$base}";
                        $zip->addSrcFile($target, $src);
                    }
                }
            }
        }
        if ($directory) {
            $outfile = $directory . "/" . $filename;
            if (!($fd = fopen($outfile, "wb"))) {
                $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing", $outfile)));
                $request->finish($msg);
            }
            $len = strlen($data);
            $num = fwrite($fd, $data, $len);
            if ($pagename != $filename) {
                $link = LinkURL($link_prefix . $filename, $filename);
                $msg->pushContent(HTML::small(_("saved as "), $link, " ... "));
            }
            $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n"));
            if (!$silent) {
                if (!isa($request, 'MockRequest')) {
                    PrintXML($msg);
                }
                flush();
                $request->chunkOutput();
            }
            assert($num == $len);
            fclose($fd);
            $outfiles[] = $outfile;
        } else {
            $zip->addRegularFile($filename, $data, $attrib);
        }
        if (USECACHE) {
            $request->_dbi->_cache->invalidate_cache($pagename);
            unset($request->_dbi->_cache->_pagedata_cache);
            unset($request->_dbi->_cache->_versiondata_cache);
            unset($request->_dbi->_cache->_glv_cache);
        }
        unset($request->_dbi->_cache->_backend->_page_data);
        unset($msg);
        unset($current->_transformedContent);
        unset($current);
        if (!empty($template)) {
            unset($template->_request);
            unset($template);
        }
        unset($data);
    }
    $page_iter->free();
    $attrib = false;
    //array('is_ascii' => 0);
    if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) {
        // @mkdir("$directory/images");
        foreach ($WikiTheme->dumped_images as $img_file) {
            if (array_key_exists($img_file, $already_images)) {
                continue;
            }
            $already_images[$img_file] = 1;
            if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) {
                if ($directory) {
                    $target = "{$directory}/images/" . basename($from);
                    if ($silent) {
                        copy($WikiTheme->_path . $from, $target);
                    } else {
                        if (copy($WikiTheme->_path . $from, $target)) {
                            _copyMsg($from, fmt("... copied to %s", $target));
                        } else {
                            _copyMsg($from, fmt("... not copied to %s", $target));
                        }
                    }
                } else {
                    $target = "images/" . basename($from);
                    $zip->addSrcFile($target, $WikiTheme->_path . $from);
                }
            } elseif (!$silent) {
                _copyMsg($from, _("... not found"));
            }
        }
    }
    if (!empty($WikiTheme->dumped_buttons) and is_array($WikiTheme->dumped_buttons)) {
        // Buttons also
        if ($directory) {
            @mkdir("{$directory}/images/buttons");
        }
        foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
            if (array_key_exists($img_file, $already_images)) {
                continue;
            }
            $already_images[$img_file] = 1;
            if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) {
                if ($directory) {
                    $target = "{$directory}/images/buttons/" . basename($from);
                    if ($silent) {
                        copy($WikiTheme->_path . $from, $target);
                    } else {
                        if (copy($WikiTheme->_path . $from, $target)) {
                            _copyMsg($from, fmt("... copied to %s", $target));
                        } else {
                            _copyMsg($from, fmt("... not copied to %s", $target));
                        }
                    }
                } else {
                    $target = "images/buttons/" . basename($from);
                    $zip->addSrcFile($target, $WikiTheme->_path . $from);
                }
            } elseif (!$silent) {
                _copyMsg($from, _("... not found"));
            }
        }
    }
    if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
        foreach ($WikiTheme->dumped_css as $css_file) {
            if (array_key_exists($css_file, $already_images)) {
                continue;
            }
            $already_images[$css_file] = 1;
            if ($css_file and $from = $WikiTheme->_findFile(basename($css_file), true) and basename($from)) {
                // TODO: fix @import url(main.css);
                if ($directory) {
                    $target = "{$directory}/" . basename($css_file);
                    if ($silent) {
                        copy($WikiTheme->_path . $from, $target);
                    } else {
                        if (copy($WikiTheme->_path . $from, $target)) {
                            _copyMsg($from, fmt("... copied to %s", $target));
                        } else {
                            _copyMsg($from, fmt("... not copied to %s", $target));
                        }
                    }
                } else {
                    //$attrib = array('is_ascii' => 0);
                    $target = basename($css_file);
                    $zip->addSrcFile($target, $WikiTheme->_path . $from);
                }
            } elseif (!$silent) {
                _copyMsg($from, _("... not found"));
            }
        }
    }
    if ($zip) {
        $zip->finish();
    }
    if ($WikiTheme->DUMP_MODE == 'PDFHTML') {
        if (USE_EXTERNAL_HTML2PDF and $outfiles) {
            $cmd = EXTERNAL_HTML2PDF_PAGELIST . ' "' . join('" "', $outfiles) . '"';
            $filename = FilenameForPage($firstpage);
            if (DEBUG) {
                $tmpfile = $directory . "/createpdf.bat";
                $fp = fopen($tmpfile, "wb");
                fwrite($fp, $cmd . " > {$filename}.pdf");
                fclose($fp);
            }
            if (!headers_sent()) {
                Header('Content-Type: application/pdf');
                passthru($cmd);
            } else {
                $tmpdir = getUploadFilePath();
                $s = passthru($cmd . " > {$tmpdir}/{$filename}.pdf");
                $errormsg = "<br />\nGenerated <a href=\"" . getUploadDataPath() . "{$filename}.pdf\">Upload:{$filename}.pdf</a>\n";
                $errormsg .= $s;
                echo $errormsg;
            }
            if (!DEBUG) {
                foreach ($outfiles as $f) {
                    unlink($f);
                }
            }
        }
        if (!empty($errormsg)) {
            $request->discardOutput();
            $GLOBALS['ErrorManager']->_postponed_errors = array();
        }
    }
    $ErrorManager->popErrorHandler();
    $WikiTheme->HTML_DUMP_SUFFIX = '';
    $WikiTheme->DUMP_MODE = false;
    $WikiTheme->_MoreAttr['body'] = $_bodyAttr;
}
Esempio n. 20
0
 public function __actionAdminNotices()
 {
     if ($this->isIllegal()) {
         echo HTML::div()->class('error')->add(HTML::p()->add(__('Your theme comes from unauthorized source and might include viruses or malicious code.', $this->domain), HTML::br(), sprintf(__('Use official theme version which you can <a href="%s">purchase on ThemeForest.net</a> only.', $this->domain), self::ENVATO_PROFILE_URL)))->html();
     }
 }
Esempio n. 21
0
 function markup($match)
 {
     return HTML::br();
 }
Esempio n. 22
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $attributes = $attrib ? explode(",", $attrib) : array();
     $photos = array();
     $html = HTML();
     $count = 0;
     // check all parameters
     // what type do we have?
     if (!$src) {
         $showdesc = 'none';
         $src = $request->getArg('pagename');
         $error = $this->fromLocation($src, $photos);
     } else {
         $error = $this->fromFile($src, $photos, $url);
     }
     if ($error) {
         return $this->error($error);
     }
     if ($numcols < 1) {
         $numcols = 1;
     }
     if ($align != 'left' && $align != 'center' && $align != 'right') {
         $align = 'center';
     }
     if (count($photos) == 0) {
         return;
     }
     if (in_array("sort", $attributes)) {
         sort($photos);
     }
     if ($p) {
         $mode = "normal";
     }
     if ($mode == "column") {
         $mode = "normal";
         $numcols = "1";
     }
     // set some fixed properties for each $mode
     if ($mode == 'thumbs' || $mode == 'tiles') {
         $attributes = array_merge($attributes, "alt");
         $attributes = array_merge($attributes, "nowrap");
         $cellwidth = 'auto';
         // else cell won't nowrap
         $width = 50;
     } elseif ($mode == 'list') {
         $numcols = 1;
         $cellwidth = "auto";
         $width = 50;
     } elseif ($mode == 'slide') {
         $tableheight = 0;
         $cell_width = 0;
         $numcols = count($photos);
         $keep = $photos;
         while (list($key, $value) = each($photos)) {
             list($x, $y, $s, $t) = @getimagesize($value['src']);
             if ($height != 'auto') {
                 $y = $this->newSize($y, $height);
             }
             if ($width != 'auto') {
                 $y = round($y * $this->newSize($x, $width) / $x);
             }
             if ($x > $cell_width) {
                 $cell_width = $x;
             }
             if ($y > $tableheight) {
                 $tableheight = $y;
             }
         }
         $tableheight += 50;
         $photos = $keep;
         unset($x, $y, $s, $t, $key, $value, $keep);
     }
     $row = HTML();
     $duration = 1000 * $duration;
     if ($mode == 'slide') {
         $row->pushContent(JavaScript("\ni = 0;\nfunction display_slides() {\n  j = i - 1;\n  cell0 = document.getElementsByName('wikislide' + j);\n  cell = document.getElementsByName('wikislide' + i);\n  if (cell0.item(0) != null)\n    cell0.item(0).style.display='none';\n  if (cell.item(0) != null)\n    cell.item(0).style.display='block';\n  i += 1;\n  if (cell.item(0) == null) i = 0;\n  setTimeout('display_slides()',{$duration});\n}\ndisplay_slides();"));
     }
     while (list($key, $value) = each($photos)) {
         if ($p && basename($value["name"]) != "{$p}") {
             continue;
         }
         if ($h && basename($value["name"]) == "{$h}") {
             $color = $hlcolor ? $hlcolor : $bgcolor;
         } else {
             $color = $bgcolor;
         }
         // $params will be used for each <img > tag
         $params = array('src' => $value["name"], 'src_tile' => $value["name_tile"], 'border' => "0", 'alt' => ($value["desc"] != "" and in_array("alt", $attributes)) ? $value["desc"] : basename($value["name"]));
         if (!@empty($value['location'])) {
             $params = array_merge($params, array("location" => $value['location']));
         }
         // check description
         switch ($showdesc) {
             case 'none':
                 $value["desc"] = '';
                 break;
             case 'name':
                 $value["desc"] = basename($value["name"]);
                 break;
             case 'desc':
                 break;
             default:
                 // 'both'
                 if (!$value["desc"]) {
                     $value["desc"] = basename($value["name"]);
                 }
                 break;
         }
         // FIXME: get getimagesize to work with names with spaces in it.
         // convert $value["name"] from webpath to local path
         $size = @getimagesize($value["name"]);
         // try " " => "\\ "
         if (!$size and !empty($value["src"])) {
             $size = @getimagesize($value["src"]);
             if (!$size) {
                 trigger_error("Unable to getimagesize(" . $value["name"] . ")", E_USER_NOTICE);
             }
         }
         $newwidth = $this->newSize($size[0], $width);
         if ($mode == 'thumbs' || $mode == 'tiles' || $mode == 'list') {
             if (!empty($size[0])) {
                 $newheight = round(50 * $size[1] / $size[0]);
             } else {
                 $newheight = '';
             }
             if ($height == 'auto') {
                 $height = 150;
             }
         } else {
             $newheight = $this->newSize($size[1], $height);
         }
         if ($width != 'auto' && $newwidth > 0) {
             $params = array_merge($params, array("width" => $newwidth));
         }
         if ($height != 'auto' && $newheight > 0) {
             $params = array_merge($params, array("height" => $newheight));
         }
         // cell operations
         $cell = array('align' => "center", 'valign' => "top", 'bgcolor' => "{$color}");
         if ($cellwidth != 'auto') {
             if ($cellwidth == 'equal') {
                 $newcellwidth = round(100 / $numcols) . "%";
             } else {
                 if ($cellwidth == 'image') {
                     $newcellwidth = $newwidth;
                 } else {
                     $newcellwidth = $cellwidth;
                 }
             }
             $cell = array_merge($cell, array("width" => $newcellwidth));
         }
         if (in_array("nowrap", $attributes)) {
             $cell = array_merge($cell, array("nowrap" => "nowrap"));
         }
         //create url to display single larger version of image on page
         $url = WikiURL($request->getPage(), array("p" => basename($value["name"]))) . "#" . basename($value["name"]);
         $b_url = WikiURL($request->getPage(), array("h" => basename($value["name"]))) . "#" . basename($value["name"]);
         $url_text = $link ? HTML::a(array("href" => "{$url}"), basename($value["desc"])) : basename($value["name"]);
         if (!$p) {
             if ($mode == 'normal' || $mode == 'slide') {
                 if (!@empty($params['location'])) {
                     $params['src'] = $params['location'];
                 }
                 unset($params['location'], $params['src_tile']);
                 $url_image = $link ? HTML::a(array("id" => basename($value["name"])), HTML::a(array("href" => "{$url}"), HTML::img($params))) : HTML::img($params);
             } else {
                 $keep = $params;
                 if (!@empty($params['src_tile'])) {
                     $params['src'] = $params['src_tile'];
                 }
                 unset($params['location'], $params['src_tile']);
                 $url_image = $link ? HTML::a(array("id" => basename($value["name"])), HTML::a(array("href" => "{$url}"), ImageTile::image_tile($params))) : HTML::img($params);
                 $params = $keep;
                 unset($keep);
             }
         } else {
             if (!@empty($params['location'])) {
                 $params['src'] = $params['location'];
             }
             unset($params['location'], $params['src_tile']);
             $url_image = $link ? HTML::a(array("id" => basename($value["name"])), HTML::a(array("href" => "{$b_url}"), HTML::img($params))) : HTML::img($params);
         }
         if ($mode == 'list') {
             $url_text = HTML::a(array("id" => basename($value["name"])), $url_text);
         }
         // here we use different modes
         if ($mode == 'tiles') {
             $row->pushContent(HTML::td($cell, HTML::table(array("cellpadding" => 1, "border" => 0), HTML::tr(HTML::td(array("valign" => "top", "rowspan" => 2), $url_image), HTML::td(array("valign" => "top", "nowrap" => 0), HTML::span(array('class' => 'boldsmall'), $url_text), HTML::br(), HTML::span(array('class' => 'gensmall'), $size[0] . " x " . $size[1] . " pixels"))))));
         } elseif ($mode == 'list') {
             $desc = $showdesc != 'none' ? $value["desc"] : '';
             $row->pushContent(HTML::td(array("valign" => "top", "nowrap" => 0, "bgcolor" => $color), HTML::span(array('class' => 'boldsmall'), $url_text)));
             $row->pushContent(HTML::td(array("valign" => "top", "nowrap" => 0, "bgcolor" => $color), HTML::span(array('class' => 'gensmall'), $size[0] . " x " . $size[1] . " pixels")));
             if ($desc != '') {
                 $row->pushContent(HTML::td(array("valign" => "top", "nowrap" => 0, "bgcolor" => $color), HTML::span(array('class' => 'gensmall'), $desc)));
             }
         } elseif ($mode == 'thumbs') {
             $desc = $showdesc != 'none' ? HTML::p(HTML::a(array("href" => "{$url}"), $url_text)) : '';
             $row->pushContent(HTML::td($cell, $url_image, HTML::span(array('class' => 'gensmall'), $desc)));
         } elseif ($mode == 'normal') {
             $desc = $showdesc != 'none' ? HTML::p($value["desc"]) : '';
             $row->pushContent(HTML::td($cell, $url_image, HTML::span(array('class' => 'gensmall'), $desc)));
         } elseif ($mode == 'slide') {
             if ($newwidth == 'auto' || !$newwidth) {
                 $newwidth = $this->newSize($size[0], $width);
             }
             if ($newwidth == 'auto' || !$newwidth) {
                 $newwidth = $size[0];
             }
             if ($newheight != 'auto') {
                 $newwidth = round($size[0] * $newheight / $size[1]);
             }
             $desc = $showdesc != 'none' ? HTML::p($value["desc"]) : '';
             if ($count == 0) {
                 $cell = array('style' => 'display: block; ' . 'position: absolute; ' . 'left: 50% ; ' . 'margin-left: -' . round($newwidth / 2) . 'px;' . 'text-align: center; ' . 'vertical-align: top', 'name' => "wikislide" . $count);
             } else {
                 $cell = array('style' => 'display: none; ' . 'position: absolute ;' . 'left: 50% ;' . 'margin-left: -' . round($newwidth / 2) . 'px;' . 'text-align: center; ' . 'vertical-align: top', 'name' => "wikislide" . $count);
             }
             if ($align == 'left' || $align == 'right') {
                 if ($count == 0) {
                     $cell = array('style' => 'display: block; ' . 'position: absolute; ' . $align . ': 50px; ' . 'vertical-align: top', 'name' => "wikislide" . $count);
                 } else {
                     $cell = array('style' => 'display: none; ' . 'position: absolute; ' . $align . ': 50px; ' . 'vertical-align: top', 'name' => "wikislide" . $count);
                 }
             }
             $row->pushContent(HTML::td($cell, $url_image, HTML::span(array('class' => 'gensmall'), $desc)));
             $count++;
         } elseif ($mode == 'row') {
             $desc = $showdesc != 'none' ? HTML::p($value["desc"]) : '';
             $row->pushContent(HTML::table(array("style" => "display: inline"), HTML::tr(HTML::td($url_image)), HTML::tr(HTML::td(array("class" => "gensmall", "style" => "text-align: center; " . "background-color: {$color}"), $desc))));
         } else {
             return $this->error(fmt("Invalid argument: %s=%s", 'mode', $mode));
         }
         // no more images in one row as defined by $numcols
         if (($key + 1) % $numcols == 0 || $key + 1 == count($photos) || $p) {
             if ($mode == 'row') {
                 $html->pushcontent(HTML::span($row));
             } else {
                 $html->pushcontent(HTML::tr($row));
             }
             $row->setContent('');
         }
     }
     //create main table
     $table_attributes = array("border" => 0, "cellpadding" => 5, "cellspacing" => 2, "width" => $tablewidth);
     if (!@empty($tableheight)) {
         $table_attributes = array_merge($table_attributes, array("height" => $tableheight));
     }
     if ($mode != 'row') {
         $html = HTML::table($table_attributes, $html);
     }
     // align all
     return HTML::div(array("align" => $align), $html);
 }
Esempio n. 23
0
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('&nbsp;'), 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();
}
Esempio n. 24
0
<h1>Edición del perfil</h1>
<?php 
$login = new ModelLogin();
?>
Tipo de cuenta: <?php 
echo $login->getTypeOfUser();
echo HTML::br(1);
echo $error;
$EditAccount = new EditAccount();
if ($login->isUserLoggedIn() == "true" && ($login->getTypeOfUser() == "musico" || $login->getTypeOfUser() == "fan" || $login->getTypeOfUser() == "local")) {
    $EditAccount->usuarioEdit($login->getUserId(), $login->getTypeOfUser());
} else {
    if ($login->getTypeOfUser() == "administrador") {
        $EditAccount->usuarioEdit($_SESSION['usuario_id_edit'], $_SESSION['usuario_tipo_edit']);
    } else {
        echo "No tienes permisos para estar aquí";
    }
}
Esempio n. 25
0
 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('&nbsp;');
     $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;
 }
Esempio n. 26
0
 function RelatedExternalLinksBox($title = false, $body = '', $limit = 20)
 {
     global $request;
     $this->title = $title ? $title : _("External Links");
     $this->body = HTML($body);
     $page = $request->getPage($request->getArg('pagename'));
     $cache =& $page->_wikidb->_cache;
     $counter = 0;
     $sp = HTML::Raw('&middot; ');
     foreach ($cache->getWikiPageLinks() as $link) {
         if ($link) {
             $this->body->pushContent($sp, WikiLink($link), HTML::br());
             $counter++;
             if ($limit and $counter > $limit) {
                 continue;
             }
         }
     }
 }
Esempio n. 27
0
 function format($changes)
 {
     include_once 'lib/InlineParser.php';
     $last_date = '';
     $first = true;
     $html = HTML();
     $counter = 1;
     $sp = HTML::Raw("\n&nbsp;&middot;&nbsp;");
     while ($rev = $changes->next()) {
         // enforce view permission
         if (mayAccessPage('view', $rev->_pagename)) {
             if ($link = $this->pageLink($rev)) {
                 // some entries may be empty
                 // (/Blog/.. interim pages)
                 $html->pushContent($sp, $link, HTML::br());
             }
             if ($first) {
                 $this->setValidators($rev);
             }
             $first = false;
         }
     }
     if ($first) {
         $html->pushContent(HTML::p(array('class' => 'rc-empty'), $this->empty_message()));
     }
     return $html;
 }
Esempio n. 28
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $this->_supported_operators = array(':=', '<', '<=', '>', '>=', '!=', '==', '=~');
     $this->_text_operators = array(':=', '==', '=~', '!=');
     $args = $this->getArgs($argstr, $request);
     if (empty($args['page'])) {
         $args['page'] = "*";
     }
     if (!isset($args['s'])) {
         // it might be (integer) 0
         $args['s'] = "*";
     }
     $posted = $request->getArg("semsearch");
     $form = $this->showForm($dbi, $request, $args);
     if (isset($this->_norelations_warning)) {
         $form->pushContent(HTML::div(array('class' => 'warning'), _("Warning:"), HTML::br(), _("No relations nor attributes in the whole wikidb defined!"), "\n", fmt("See %s", WikiLink(_("Help:SemanticRelations")))));
     }
     extract($args);
     // for convenience and harmony we allow GET requests also.
     if (!$request->isPost()) {
         if ($relation or $attribute) {
             // check for good GET request
         } else {
             return $form;
         }
         // nobody called us, so just display our supadupa form
     }
     $pagequery = $this->regex_query($page, $args['case_exact'], $args['regex']);
     // we might want to check for semsearch['relations'] and semsearch['attributes'] also
     if (empty($relation) and empty($attribute)) {
         // so we just clicked without selecting any relation.
         // hmm. check which button we clicked, before we do the massive alltogether search.
         if (isset($posted['relations']) and $posted['relations']) {
             $relation = '*';
         } elseif (isset($posted['attributes']) and $posted['attributes']) {
             $attribute = '*';
             // here we have to check for invalid text operators. ignore it then
             if (!in_array($attr_op, $this->_text_operators)) {
                 $attribute = '';
             }
         }
     }
     $searchtype = "Text";
     if (!empty($relation)) {
         $querydesc = $relation . "::" . $s;
         $linkquery = $this->regex_query($s, $args['case_exact'], $args['regex']);
         $relquery = $this->regex_query($relation, $args['case_exact'], $args['regex']);
         $links = $dbi->linkSearch($pagequery, $linkquery, 'relation', $relquery);
         $pagelist = new PageList($info, $exclude, $args);
         $pagelist->_links = array();
         while ($link = $links->next()) {
             $pagelist->addPage($link['pagename']);
             $pagelist->_links[] = $link;
         }
         // default (=empty info) wants all three. but we want to be able to override this.
         // $pagelist->_columns_seen is the exploded info
         if (!$info or $info and isset($pagelist->_columns_seen['relation'])) {
             $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('relation', _("Relation"), $pagelist));
         }
         if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['linkto'])) {
             $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('linkto', _("Link"), $pagelist));
         }
     }
     // can we merge two different pagelist?
     if (!empty($attribute)) {
         $relquery = $this->regex_query($attribute, $args['case_exact'], $args['regex']);
         if (!in_array($attr_op, $this->_supported_operators)) {
             return HTML($form, $this->error(fmt("Illegal operator: %s", HTML::tt($attr_op))));
         }
         $s_base = preg_replace("/,/", "", $s);
         $units = new Units();
         if (!is_numeric($s_base)) {
             $s_base = $units->basevalue($s_base);
             $is_numeric = is_numeric($s_base);
         } else {
             $is_numeric = true;
         }
         // check which type to search with:
         // at first check if forced text matcher
         if ($attr_op == '=~') {
             if ($s == '*') {
                 $s = '.*';
             }
             // help the poor user. we need pcre syntax.
             $linkquery = new TextSearchQuery("{$s}", $args['case_exact'], 'pcre');
             $querydesc = "{$attribute} {$attr_op} {$s}";
         } elseif ($is_numeric) {
             // do comparison with numbers
             /* We want to search for multiple attributes also. linkSearch can do this.
              * But we have to construct the query somehow. (that's why we try the AND OR dhtml)
              *     population < 1 million AND area > 50 km2
              * Here we check only for one attribute per page.
              * See SemanticSearchAdvanced for the full expression.
              */
             // it might not be the best idea to use '*' as variable to expand. hmm.
             if ($attribute == '*') {
                 $attribute = '_star_';
             }
             $searchtype = "Numeric";
             $query = $attribute . " " . $attr_op . " " . $s_base;
             $linkquery = new SemanticAttributeSearchQuery($query, $attribute, $units->baseunit($s));
             if ($attribute == '_star_') {
                 $attribute = '*';
             }
             $querydesc = $attribute . " " . $attr_op . " " . $s;
             // no number or unit: check other text matchers or '*' MATCH_ALL
         } elseif (in_array($attr_op, $this->_text_operators)) {
             if ($attr_op == '=~') {
                 if ($s == '*') {
                     $s = '.*';
                 }
                 // help the poor user. we need pcre syntax.
                 $linkquery = new TextSearchQuery("{$s}", $args['case_exact'], 'pcre');
             } else {
                 $linkquery = $this->regex_query($s, $args['case_exact'], $args['regex']);
             }
             $querydesc = "{$attribute} {$attr_op} {$s}";
             // should we fail or skip when the user clicks on Relations?
         } elseif (isset($posted['relations']) and $posted['relations']) {
             $linkquery = false;
             // skip
         } else {
             $querydesc = $attribute . " " . $attr_op . " " . $s;
             return HTML($form, $this->error(fmt("Only text operators can be used with strings: %s", HTML::tt($querydesc))));
         }
         if ($linkquery) {
             $links = $dbi->linkSearch($pagequery, $linkquery, 'attribute', $relquery);
             if (empty($relation)) {
                 $pagelist = new PageList($args['info'], $args['exclude'], $args);
                 $pagelist->_links = array();
             }
             while ($link = $links->next()) {
                 $pagelist->addPage($link['pagename']);
                 $pagelist->_links[] = $link;
             }
             // default (=empty info) wants all three. but we want to override this.
             if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['attribute'])) {
                 $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('attribute', _("Attribute"), $pagelist));
             }
             if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['value'])) {
                 $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('value', _("Value"), $pagelist));
             }
         }
     }
     if (!isset($pagelist)) {
         $querydesc = _("<empty>");
         $pagelist = new PageList();
     }
     if (!$noheader) {
         // We put the form into the caption just to be able to return one pagelist object,
         // and to still have the convenience form at the top. we could workaround this by
         // putting the form as WikiFormRich into the actionpage. but thid doesnt look as
         // nice as this here.
         $pagelist->setCaption(HTML($noform ? '' : HTML($form, HTML::hr()), fmt("Semantic %s Search Result for \"%s\" in pages \"%s\"", $searchtype, $querydesc, $page)));
     }
     return $pagelist;
 }
Esempio n. 29
0
 function finish($errormsg = false)
 {
     static $in_exit = 0;
     if ($in_exit) {
         exit;
     }
     // just in case CloseDataBase calls us
     $in_exit = true;
     global $ErrorManager;
     $ErrorManager->flushPostponedErrors();
     if (!empty($errormsg)) {
         PrintXML(HTML::br(), HTML::hr(), HTML::h2(_("Fatal PhpWiki Error")), $errormsg);
         // HACK:
         echo "\n</body></html>";
     }
     if (is_object($this->_user)) {
         $this->_user->page = $this->getArg('pagename');
         $this->_user->action = $this->getArg('action');
         unset($this->_user->_HomePagehandle);
         unset($this->_user->_auth_dbi);
     }
     Request::finish();
     exit;
 }
Esempio n. 30
0
        foreach ($login->errors as $error) {
            echo HTML::open_div(array("class" => "form-group has-error"));
            echo HTML::label("usuario_nombre_usuario", $error, array("class" => "control-label"));
            echo HTML::close_div();
        }
    }
    if ($login->messages) {
        foreach ($login->messages as $message) {
            echo HTML::open_div(array("class" => "form-group has-error"));
            echo HTML::label("usuario_nombre_usuario", $message, array("class" => "control-label"));
            echo HTML::close_div();
        }
    }
}
if ($login->isUserLoggedIn() == true) {
    ROUTER::redirect_to_action("account/user");
} else {
    echo ROUTER::create_action_url("account/login");
    echo HTML::open_div(array("id" => "login"));
    echo HTML::open_form(ROUTER::create_action_url('account/login'), "POST", "form_login");
    echo HTML::label("usuario_nombre_usuario", "Introduce tu nombre de usuario");
    echo HTML::input("text", "usuario_nombre_usuario", null, array("placeholder" => "Introduce tu nombre de usuario"));
    echo HTML::label("usuario_contrasena", "Introduce tu contraseña");
    echo HTML::input("password", "usuario_contrasena", null, array("placeholder" => "········"));
    echo HTML::label("usuario_recuerdame", "Recordar session?");
    echo HTML::checkbox("usuario_recuerdame", "usuario_recuerdame", false);
    echo HTML::button_HTML5("submit", "Entrar!", "login");
    echo HTML::close_form();
    echo HTML::close_div();
    echo HTML::br(3);
}