function start_form() { $this->form .= '<form id="extension__list" accept-charset="utf-8" method="post" action="">'; $hidden = array('do' => 'admin', 'page' => 'extension', 'sectok' => getSecurityToken()); $this->add_hidden($hidden); $this->form .= '<ul class="extensionList">'; }
/** * Constructor * * Sets parameters and autoadds a security token. The old calling convention * with up to four parameters is deprecated, instead the first parameter * should be an array with parameters. * * @param mixed $params Parameters for the HTML form element; Using the * deprecated calling convention this is the ID * attribute of the form * @param string $action (optional, deprecated) submit URL, defaults to * current page * @param string $method (optional, deprecated) 'POST' or 'GET', default * is POST * @param string $enctype (optional, deprecated) Encoding type of the * data * @author Tom N Harris <*****@*****.**> */ function Doku_Form($params, $action = false, $method = false, $enctype = false) { if (!is_array($params)) { $this->params = array('id' => $params); if ($action !== false) { $this->params['action'] = $action; } if ($method !== false) { $this->params['method'] = strtolower($method); } if ($enctype !== false) { $this->params['enctype'] = $enctype; } } else { $this->params = $params; } if (!isset($this->params['method'])) { $this->params['method'] = 'post'; } else { $this->params['method'] = strtolower($this->params['method']); } if (!isset($this->params['action'])) { $this->params['action'] = ''; } $this->addHidden('sectok', getSecurityToken()); }
public function __construct($dataFormat, $responseDataFormat, $environment) { $this->dataFormat = $dataFormat; $this->responseDataFormat = $responseDataFormat; $this->environment = $environment; $this->securityToken = getSecurityToken($environment); }
/** * Creates a new, empty form with some default attributes * * @param array $attributes */ public function __construct($attributes = array()) { global $ID; parent::__construct('form', $attributes); // use the current URL as default action if (!$this->attr('action')) { $get = $_GET; if (isset($get['id'])) { unset($get['id']); } $self = wl($ID, $get, false, '&'); //attributes are escaped later $this->attr('action', $self); } // post is default if (!$this->attr('method')) { $this->attr('method', 'post'); } // we like UTF-8 if (!$this->attr('accept-charset')) { $this->attr('accept-charset', 'utf-8'); } // add the security token by default $this->setHiddenField('sectok', getSecurityToken()); // identify this as a new form based form in HTML $this->addClass('doku_form'); }
/** * Register the events * * @param $event DOKU event on ajax call * @param $param parameters, ignored */ function _ajax_call(&$event, $param) { if ($event->data !== 'plugin_explorertree') { return; } //no other ajax call handlers needed $event->stopPropagation(); $event->preventDefault(); //e.g. access additional request variables global $INPUT; //available since release 2012-10-13 "Adora Belle" if (!checkSecurityToken()) { $data = array('error' => true, 'msg' => 'invalid security token!'); } else { switch ($INPUT->str('operation')) { case 'explorertree_branch': if (!($helper = plugin_load('helper', 'explorertree'))) { $data = array('error' => true, 'msg' => "Can't load tree helper."); break; } if (!($route = $helper->loadRoute($INPUT->str('route'), $INPUT->arr('loader')))) { $data = array('error' => true, 'msg' => "Can't load route '" . $INPUT->str('route') . "'!"); } $data = array('html' => $helper->htmlExplorer($INPUT->str('route'), ltrim(':' . $INPUT->str('itemid')), ':')); if (!$data['html']) { $data['error'] = true; $data['msg'] = "Can't load tree html."; } break; case 'callback': if (!($helper = plugin_load('helper', 'explorertree'))) { $data = array('error' => true, 'msg' => "Can't load tree helper."); break; } $route = $helper->loadRoute($INPUT->str('route'), $INPUT->arr('loader')); if (!$route || !is_callable(@$route['callbacks'][$INPUT->str(event)])) { $data = array('error' => true, 'msg' => "Can't load callback '" . $INPUT->str('event') . "'for '" . $INPUT->str('route') . "'!"); } $data = @call_user_func_array($route['callbacks'][$INPUT->str(event)], array($INPUT->str('itemid'))); if (!is_array($data)) { $data = array('error' => true, 'msg' => "Callback for '" . $INPUT->str('event') . "' does not exists!"); } break; default: $data = array('error' => true, 'msg' => 'Unknown operation: ' . $INPUT->str('operation')); break; } //data //json library of DokuWiki } if (is_array($data)) { $data['token'] = getSecurityToken(); } require_once DOKU_INC . 'inc/JSON.php'; $json = new JSON(); //set content type header('Content-Type: application/json'); echo $json->encode($data); // $this->get_helper()->check_meta_changes(); }
/** * Print a hidden form field with a secret CSRF token * * @author Andreas Gohr <*****@*****.**> */ function formSecurityToken($print = true) { $ret = '<div class="no"><input type="hidden" name="sectok" value="' . getSecurityToken() . '" /></div>' . "\n"; if ($print) { echo $ret; } else { return $ret; } }
function test_form_print() { $form = $this->_testform(); ob_start(); $form->printForm(); $output = ob_get_contents(); ob_end_clean(); $form->addHidden('sectok', getSecurityToken()); $this->assertEquals($this->_ignoreTagWS($output), $this->_ignoreTagWS($this->_realoutput())); }
/** * Constructor * * Autoadds a security token * * @param string $id ID attribute of the form. * @param string $action (optional) submit URL, defaults to DOKU_SCRIPT * @param string $method (optional) 'POST' or 'GET', default is post * @author Tom N Harris <*****@*****.**> */ function Doku_Form($id, $action = false, $method = false, $enctype = false) { $this->id = $id; $this->action = $action ? $action : script(); if ($method) { $this->method = $method; } if ($enctype) { $this->enctype = $enctype; } $this->addHidden('sectok', getSecurityToken()); }
public function html() { $abrt = false; $next = false; echo '<h1>' . $this->getLang('menu') . '</h1>'; global $conf; if ($conf['safemodehack']) { $abrt = false; $next = false; echo $this->locale_xhtml('safemode'); return; } $this->_say('<div id="plugin__upgrade">'); // enable auto scroll ?> <script language="javascript" type="text/javascript"> var plugin_upgrade = window.setInterval(function () { var obj = document.getElementById('plugin__upgrade'); if (obj) obj.scrollTop = obj.scrollHeight; }, 25); </script> <?php // handle current step $this->_stepit($abrt, $next); // disable auto scroll ?> <script language="javascript" type="text/javascript"> window.setTimeout(function () { window.clearInterval(plugin_upgrade); }, 50); </script> <?php $this->_say('</div>'); echo '<form action="" method="get" id="plugin__upgrade_form">'; echo '<input type="hidden" name="do" value="admin" />'; echo '<input type="hidden" name="page" value="upgrade" />'; echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />'; if ($next) { echo '<input type="submit" name="step[' . $next . ']" value="' . $this->getLang('btn_continue') . ' ➡" class="button continue" />'; } if ($abrt) { echo '<input type="submit" name="step[cancel]" value="✖ ' . $this->getLang('btn_abort') . '" class="button abort" />'; } echo '</form>'; $this->_progress($next); }
function add_mediamanager_upload_region(&$event) { global $NS; $ext = 'png'; $default_filename = "screenshot-" . date("Y-m-d_H-i-s") . "." . $ext; echo "<!-- SUPA begin -->\n"; echo "<script type='text/javascript'>\n"; #echo "alert( 'loading' );"; echo "addInitEvent(function(){\n"; echo " supa_handler.init(\n"; echo " '" . addslashes(getSecurityToken()) . "',\n"; echo " '" . addslashes($this->getConf("previewscaler")) . "',\n"; echo " '" . addslashes($this->getConf("previewwidth")) . "',\n"; echo " '" . addslashes($this->getConf("previewheight")) . "',\n"; echo " '" . addslashes(hsc($NS)) . "',\n"; echo " '" . addslashes($default_filename) . "'\n"; echo " );\n"; echo "});\n"; echo "</script>\n"; echo "<!-- SUPA end -->\n"; return true; }
} else { $top_bar = true; } } ?> <?php if (class_exists('Ld_Ui') && method_exists('Ld_Ui', 'top_bar') && $top_bar) { ?> <?php $loginUrl = Ld_Ui::getAdminUrl(array('module' => 'default', 'controller' => 'auth', 'action' => 'login')); if (empty($loginUrl)) { $loginUrl = wl($ID, 'do=login&sectok=' . getSecurityToken()); } if (empty($logoutUrl)) { $logoutUrl = wl($ID, 'do=logout&sectok=' . getSecurityToken()); } ?> <?php Ld_Ui::top_bar(array('loginUrl' => $loginUrl, 'logoutUrl' => $logoutUrl)); } else { ?> <div class="user-info"> <?php tpl_userinfo(); ?> <?php tpl_actionlink('subscription'); ?> <?php tpl_actionlink('profile');
/** * Display all currently set permissions in a table * * @author Andreas Gohr <*****@*****.**> */ function _html_table() { global $lang; global $ID; echo '<form action="' . wl() . '" method="post" accept-charset="utf-8"><div class="no">' . NL; if ($this->ns) { echo '<input type="hidden" name="ns" value="' . hsc($this->ns) . '" />' . NL; } else { echo '<input type="hidden" name="id" value="' . hsc($ID) . '" />' . NL; } echo '<input type="hidden" name="acl_w" value="' . hsc($this->who) . '" />' . NL; echo '<input type="hidden" name="do" value="admin" />' . NL; echo '<input type="hidden" name="page" value="acl" />' . NL; echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />' . NL; echo '<div class="table">'; echo '<table class="inline">'; echo '<tr>'; echo '<th>' . $this->getLang('where') . '</th>'; echo '<th>' . $this->getLang('who') . '</th>'; echo '<th>' . $this->getLang('perm') . '<sup><a id="fnt__1" class="fn_top" href="#fn__1">1)</a></sup></th>'; echo '<th>' . $lang['btn_delete'] . '</th>'; echo '</tr>'; foreach ($this->acl as $where => $set) { foreach ($set as $who => $perm) { echo '<tr>'; echo '<td>'; if (substr($where, -1) == '*') { echo '<span class="aclns">' . hsc($where) . '</span>'; $ispage = false; } else { echo '<span class="aclpage">' . hsc($where) . '</span>'; $ispage = true; } echo '</td>'; echo '<td>'; if ($who[0] == '@') { echo '<span class="aclgroup">' . hsc($who) . '</span>'; } else { echo '<span class="acluser">' . hsc($who) . '</span>'; } echo '</td>'; echo '<td>'; echo $this->_html_checkboxes($perm, $ispage, 'acl[' . $where . '][' . $who . ']'); echo '</td>'; echo '<td class="check">'; echo '<input type="checkbox" name="del[' . hsc($where) . '][]" value="' . hsc($who) . '" />'; echo '</td>'; echo '</tr>'; } } echo '<tr>'; echo '<th class="action" colspan="4">'; echo '<input type="submit" value="' . $lang['btn_update'] . '" name="cmd[update]" class="button" />'; echo '</th>'; echo '</tr>'; echo '</table>'; echo '</div>'; echo '</div></form>' . NL; }
/** * Display the subscribe form * * @author Adrian Lang <*****@*****.**> */ function tpl_subscribe() { global $INFO; global $ID; global $lang; global $conf; $stime_days = $conf['subscribe_time'] / 60 / 60 / 24; echo p_locale_xhtml('subscr_form'); echo '<h2>' . $lang['subscr_m_current_header'] . '</h2>'; echo '<div class="level2">'; if ($INFO['subscribed'] === false) { echo '<p>' . $lang['subscr_m_not_subscribed'] . '</p>'; } else { echo '<ul>'; foreach ($INFO['subscribed'] as $sub) { echo '<li><div class="li">'; if ($sub['target'] !== $ID) { echo '<code class="ns">' . hsc(prettyprint_id($sub['target'])) . '</code>'; } else { echo '<code class="page">' . hsc(prettyprint_id($sub['target'])) . '</code>'; } $sstl = sprintf($lang['subscr_style_' . $sub['style']], $stime_days); if (!$sstl) { $sstl = hsc($sub['style']); } echo ' (' . $sstl . ') '; echo '<a href="' . wl($ID, array('do' => 'subscribe', 'sub_target' => $sub['target'], 'sub_style' => $sub['style'], 'sub_action' => 'unsubscribe', 'sectok' => getSecurityToken())) . '" class="unsubscribe">' . $lang['subscr_m_unsubscribe'] . '</a></div></li>'; } echo '</ul>'; } echo '</div>'; // Add new subscription form echo '<h2>' . $lang['subscr_m_new_header'] . '</h2>'; echo '<div class="level2">'; $ns = getNS($ID) . ':'; $targets = array($ID => '<code class="page">' . prettyprint_id($ID) . '</code>', $ns => '<code class="ns">' . prettyprint_id($ns) . '</code>'); $styles = array('every' => $lang['subscr_style_every'], 'digest' => sprintf($lang['subscr_style_digest'], $stime_days), 'list' => sprintf($lang['subscr_style_list'], $stime_days)); $form = new Doku_Form(array('id' => 'subscribe__form')); $form->startFieldset($lang['subscr_m_subscribe']); $form->addRadioSet('sub_target', $targets); $form->startFieldset($lang['subscr_m_receive']); $form->addRadioSet('sub_style', $styles); $form->addHidden('sub_action', 'subscribe'); $form->addHidden('do', 'subscribe'); $form->addHidden('id', $ID); $form->endFieldset(); $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe'])); html_form('SUBSCRIBE', $form); echo '</div>'; }
/** * output appropriate html */ function html() { global $ID; ptln('<h1>' . $this->getLang('menu') . '</h1>'); $form = new Doku_Form(array('id' => 'vg', 'action' => wl($ID))); $form->addHidden('cmd', $this->edit ? 'edit' : 'add'); $form->addHidden('sectok', getSecurityToken()); $form->addHidden('page', $this->getPluginName()); $form->addHidden('do', 'admin'); $form->startFieldset($this->getLang($this->edit ? 'edituser' : 'adduser')); if ($this->edit) { $form->addElement(form_makeField('text', 'user', $this->data['user'], $this->getLang('user'), '', '', array('disabled' => 'disabled'))); $form->addHidden('uid', $this->data['user']); $form->addElement('<br />'); } else { $form->addElement(form_makeField('text', 'uid', '', $this->getLang('user'))); $form->addElement('<br />'); } $form->addElement(form_makeField('text', 'grp', $this->edit ? implode(', ', $this->data['grp']) : '', $this->getLang('grp'))); $form->addElement('<br />'); $form->addElement(form_makeButton('submit', '', $this->getLang($this->edit ? 'change' : 'add'))); $form->endFieldset(); $form->printForm(); ptln('<table class="inline" id="vg__show">'); ptln(' <tr>'); ptln(' <th class="user">' . hsc($this->getLang('users')) . '</th>'); ptln(' <th class="grp">' . hsc($this->getLang('grps')) . '</th>'); ptln(' <th> </th>'); ptln(' </tr>'); foreach ($this->users as $user => $grps) { //$userdata=$this->_auth->getUserData($user); ptln(' <tr>'); ptln(' <td>' . hsc($user) . (isset($userdata['name']) ? hsc(' (' . $userdata['name'] . ')') : '') . '</td>'); ptln(' <td>' . hsc(implode(', ', $grps)) . '</td>'); ptln(' <td class="act">'); ptln(' <a class="vg_edit" href="' . wl($ID, array('do' => 'admin', 'page' => $this->getPluginName(), 'cmd' => 'edit', 'uid' => $user, 'sectok' => getSecurityToken())) . '">' . hsc($this->getLang('edit')) . '</a>'); ptln(' • '); ptln(' <a class="vg_del" href="' . wl($ID, array('do' => 'admin', 'page' => $this->getPluginName(), 'cmd' => 'del', 'uid' => $user, 'sectok' => getSecurityToken())) . '">' . hsc($this->getLang('del')) . '</a>'); ptln(' </td>'); ptln(' </tr>'); } ptln('</table>'); $form = new Doku_Form(array('id' => 'vg', 'action' => wl($ID))); $form->addHidden('cmd', $this->editgroup ? 'editgroup' : 'addgroup'); $form->addHidden('sectok', getSecurityToken()); $form->addHidden('page', $this->getPluginName()); $form->addHidden('do', 'admin'); if ($this->editgroup) { $form->startFieldset($this->getLang('editgroup')); $form->addElement(form_makeField('text', 'group', $this->data['group'], $this->getLang('grp'), '', '', array('disabled' => 'disabled'))); $form->addElement('<br />'); $form->addHidden('uid', $this->data['group']); $form->addElement(form_makeField('text', 'users', implode(', ', $this->data['users']), $this->getLang('users'))); $form->addElement('<br />'); } else { $form->startFieldset($this->getLang('addgroup')); $form->addElement(form_makeField('text', 'uid', '', $this->getLang('grp'))); $form->addElement('<br />'); $form->addElement(form_makeField('text', 'users', '', $this->getLang('users'))); $form->addElement('<br />'); } $form->addElement(form_makeButton('submit', '', $this->getLang($this->editgroup ? 'change' : 'add'))); $form->endFieldset(); $form->printForm(); ptln('<table class="inline" id="vg__show">'); ptln(' <tr>'); ptln(' <th class="grp">' . hsc($this->getLang('grps')) . '</th>'); ptln(' <th class="user">' . hsc($this->getLang('users')) . '</th>'); ptln(' <th class="act"> </th>'); ptln(' </tr>'); foreach ($this->groups as $group => $users) { ptln(' <tr>'); ptln(' <td>' . hsc($group) . '</td>'); ptln(' <td>' . hsc(implode(', ', $users)) . '</td>'); ptln(' <td class="act">'); ptln(' <a class="vg_edit" href="' . wl($ID, array('do' => 'admin', 'page' => $this->getPluginName(), 'cmd' => 'editgroup', 'uid' => $group, 'sectok' => getSecurityToken())) . '">' . hsc($this->getLang('edit')) . '</a>'); ptln(' • '); ptln(' <a class="vg_del" href="' . wl($ID, array('do' => 'admin', 'page' => $this->getPluginName(), 'cmd' => 'delgroup', 'uid' => $group, 'sectok' => getSecurityToken())) . '">' . hsc($this->getLang('del')) . '</a>'); ptln(' </td>'); ptln(' </tr>'); } ptln('</table>'); $form = new Doku_Form(array('id' => 'vg', 'action' => wl($ID))); $form->addHidden('cmd', 'search'); $form->addHidden('sectok', getSecurityToken()); $form->addHidden('page', $this->getPluginName()); $form->addHidden('do', 'admin'); $form->startFieldset($this->getLang('searchuser')); $form->addElement(form_makeField('text', 'uid', '', $this->getLang('searchname'))); $form->addElement(form_makeButton('submit', '', $this->getLang('search'))); $form->printForm(); if (!empty($this->_auth_userlist)) { ptln('<table class="inline" id="vg__show">'); ptln(' <tr>'); ptln(' <th class="user">' . hsc($this->getLang('users')) . '</th>'); ptln(' <th class="act"> </th>'); ptln(' </tr>'); foreach ($this->_auth_userlist as $user => $userinfo) { ptln(' <tr>'); ptln(' <td>' . hsc($user . ' (' . $userinfo['name'] . ')') . '</td>'); ptln(' <td class="act">'); ptln(' <a class="vg_edit" href="' . wl($ID, array('do' => 'admin', 'page' => $this->getPluginName(), 'cmd' => 'edit', 'uid' => $user, 'sectok' => getSecurityToken())) . '">' . hsc($this->getLang('edit')) . '</a>'); ptln(' </td>'); ptln(' </tr>'); } ptln('</table>'); } }
/** * Display all currently set permissions in a table * * @author Andreas Gohr <*****@*****.**> */ function _html_table() { global $lang; global $ID; echo '<form action="' . wl() . '" method="post" accept-charset="utf-8"><div class="no">' . NL; if ($this->ns) { echo '<input type="hidden" name="ns" value="' . hsc($this->ns) . '" />' . NL; } echo '<input type="hidden" name="do" value="admin" />' . NL; echo '<input type="hidden" name="page" value="dokutranslate" />' . NL; echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />' . NL; echo '<table class="inline">'; echo '<tr>'; echo '<th>' . $this->getLang('where') . '</th>'; echo '<th>' . $this->getLang('who') . '</th>'; echo '<th>' . $lang['btn_delete'] . '</th>'; echo '</tr>'; foreach ($this->acl as $where => $who) { echo '<tr>'; echo '<td>'; echo '<span class="dokutranslatens">' . hsc($where) . '</span>'; echo '</td>'; echo '<td>'; echo '<span class="dokutranslategroup">' . hsc($who) . '</span>'; echo '</td>'; echo '<td align="center">'; echo '<input type="hidden" name="acl[' . hsc($where) . ']" value="' . hsc($who) . '" />'; echo '<input type="checkbox" name="del[]" value="' . hsc($where) . '" />'; echo '</td>'; echo '</tr>'; } echo '<tr>'; echo '<th align="right" colspan="3">'; echo '<input type="submit" value="' . $this->getLang('delsel') . '" name="cmd[update]" class="button" />'; echo '</th>'; echo '</tr>'; echo '</table>'; echo '</div></form>' . NL; }
/** * Print a dropdown menu with all DokuWiki actions * * Note: this will not use any pretty URLs * * @author Andreas Gohr <*****@*****.**> */ function tpl_actiondropdown($empty = '', $button = '>') { global $ID; global $INFO; global $REV; global $ACT; global $conf; global $lang; global $auth; echo '<form method="post" accept-charset="utf-8">'; #FIXME action echo '<input type="hidden" name="id" value="' . $ID . '" />'; if ($REV) { echo '<input type="hidden" name="rev" value="' . $REV . '" />'; } echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />'; echo '<select name="do" id="action__selector" class="edit">'; echo '<option value="">' . $empty . '</option>'; echo '<optgroup label=" — ">'; // 'edit' - most complicated type, we need to decide on current action if ($ACT == 'show' || $ACT == 'search') { if ($INFO['writable']) { if (!empty($INFO['draft'])) { echo '<option value="edit">' . $lang['btn_draft'] . '</option>'; } else { if ($INFO['exists']) { echo '<option value="edit">' . $lang['btn_edit'] . '</option>'; } else { echo '<option value="edit">' . $lang['btn_create'] . '</option>'; } } } else { if (actionOK('source')) { //pseudo action echo '<option value="edit">' . $lang['btn_source'] . '</option>'; } } } else { echo '<option value="show">' . $lang['btn_show'] . '</option>'; } echo '<option value="revisions">' . $lang['btn_revs'] . '</option>'; echo '<option value="backlink">' . $lang['btn_backlink'] . '</option>'; echo '</optgroup>'; echo '<optgroup label=" — ">'; echo '<option value="recent">' . $lang['btn_recent'] . '</option>'; echo '<option value="index">' . $lang['btn_index'] . '</option>'; echo '</optgroup>'; echo '<optgroup label=" — ">'; if ($conf['useacl'] && $auth) { if ($_SERVER['REMOTE_USER']) { echo '<option value="logout">' . $lang['btn_logout'] . '</option>'; } else { echo '<option value="login">' . $lang['btn_login'] . '</option>'; } } if ($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && $auth->canDo('Profile') && $ACT != 'profile') { echo '<option value="profile">' . $lang['btn_profile'] . '</option>'; } if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1) { if ($_SERVER['REMOTE_USER']) { if ($INFO['subscribed']) { echo '<option value="unsubscribe">' . $lang['btn_unsubscribe'] . '</option>'; } else { echo '<option value="subscribe">' . $lang['btn_subscribe'] . '</option>'; } } } if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1) { if ($_SERVER['REMOTE_USER']) { if ($INFO['subscribedns']) { echo '<option value="unsubscribens">' . $lang['btn_unsubscribens'] . '</option>'; } else { echo '<option value="subscribens">' . $lang['btn_subscribens'] . '</option>'; } } } if ($INFO['ismanager']) { echo '<option value="admin">' . $lang['btn_admin'] . '</option>'; } echo '</optgroup>'; echo '</select>'; echo '<input type="submit" value="' . $button . '" id="action__selectorbtn" />'; echo '</form>'; }
function getTOC() { global $conf; global $ID; $toc = array(); $dbfiles = glob($conf['metadir'] . '/*.sqlite'); if (is_array($dbfiles)) { foreach ($dbfiles as $file) { $db = basename($file, '.sqlite'); $toc[] = array('link' => wl($ID, array('do' => 'admin', 'page' => 'sqlite', 'db' => $db, 'sectok' => getSecurityToken())), 'title' => $this->getLang('db') . ' ' . $db, 'level' => 1, 'type' => 'ul'); } } return $toc; }
/** * Register the events * * @param $event DOKU event on ajax call * @param $param parameters, ignored */ function _ajax_call(&$event, $param) { if ($event->data !== 'plugin_settingstree') { return; } //no other ajax call handlers needed $event->stopPropagation(); $event->preventDefault(); //e.g. access additional request variables global $INPUT; //available since release 2012-10-13 "Adora Belle" if (!checkSecurityToken()) { $data = array('error' => true, 'msg' => 'invalid security token!'); } else { switch ($INPUT->str('operation')) { case 'loadlevel': if (!($helper = plugin_load('helper', 'settingstree'))) { $data = array('error' => true, 'msg' => "Can't load tree helper."); break; } switch ($INPUT->str('showtype', 'normal')) { case 'export': $data = array('html' => $helper->showExportHtml($INPUT->str('pluginname'), ':' . ltrim($INPUT->str('path'), ':'), $INPUT->arr('options', array())), 'path' => ':' . ltrim($INPUT->str('path'), ':')); break; case 'normal': default: $data = array('html' => $helper->showHtml($INPUT->str('pluginname'), ':' . ltrim($INPUT->str('path'), ':')), 'path' => ':' . ltrim($INPUT->str('path'), ':')); } if (!$data['html']) { $data['error'] = true; $data['msg'] = "Can't load level html."; } break; case 'show_hierarchy': if (!($helper = plugin_load('helper', 'settingstree'))) { $data = array('error' => true, 'msg' => "Can't load tree helper."); break; } $data = array('html' => $helper->showHierarchy($INPUT->str('pluginname'), $INPUT->str('key'))); if (!$data['html']) { $data['error'] = true; $data['msg'] = "Can't load level html."; } break; case 'savelevel': if (!($helper = plugin_load('helper', 'settingstree'))) { $data = array('error' => true, 'msg' => "Can't load tree helper."); break; } $html = $helper->saveLevel($INPUT->str('pluginname'), ':' . ltrim($INPUT->str('path'), ':'), $INPUT->arr('data'), $data); $data['html'] = $html; if (!$data['html']) { $data['error'] = true; $data['msg'] = "Can't load level html."; } break; case 'exportlevel': if (!($helper = plugin_load('helper', 'settingstree'))) { $data = array('error' => true, 'msg' => "Can't load tree helper."); break; } $html = $helper->exportLevel($INPUT->str('pluginname'), ':' . ltrim($INPUT->str('path'), ':'), $INPUT->arr('data'), $data, $INPUT->arr('options', array())); $data['html'] = $html; // we expect null for success (export will start with the options) and only need to display the configurations again when there is an error. if (!$data['html'] && !$data['success']) { $data['error'] = true; $data['msg'] = "Can't load level html."; } break; default: $data = array('error' => true, 'msg' => 'Unknown operation: ' . $INPUT->str('operation')); break; } //data //json library of DokuWiki } if (is_array($data)) { $data['token'] = getSecurityToken(); } require_once DOKU_INC . 'inc/JSON.php'; $json = new JSON(); //set content type header('Content-Type: application/json'); echo $json->encode($data); // $this->get_helper()->check_meta_changes(); }
function test_basic_parameters() { global $ACT, $INPUT, $conf, $auth; $ACT = 'profile_delete'; $conf['profileconfirm'] = true; $_SERVER['REMOTE_USER'] = '******'; $input = array('do' => $ACT, 'sectok' => getSecurityToken(), 'delete' => '1', 'confirm_delete' => '1', 'oldpass' => 'password'); $_POST = $input; $_REQUEST = $input; $input_foundation = new Input(); $auth = new Mock_Auth_Plugin(); $INPUT = clone $input_foundation; $INPUT->remove('delete'); $this->assertFalse(auth_deleteprofile()); $INPUT = clone $input_foundation; $INPUT->set('sectok', 'wrong'); $this->assertFalse(auth_deleteprofile()); $INPUT = clone $input_foundation; $INPUT->remove('confirm_delete'); $this->assertFalse(auth_deleteprofile()); }
/** * Display login form matching the style the drupal CSS expects but conforming to what the DokuWiki backend needs * * @author Clemens Lang <*****@*****.**> */ function _tpl_html_login() { global $lang; global $conf; global $ID; if (false === ($html_form = file_get_contents(dirname(__FILE__) . '/login.html'))) { printf("<!-- Error reading %s -->\n", dirname(__FILE__) . '/login.html'); return; } $html_form = str_replace( array( '@ACTION@', '@SECTOK@', '@ID@', '@R@', '@U@', ), array( '', getSecurityToken(), $ID, 0, '', ), $html_form ); print($html_form); }
/** * Output html of the admin page */ public function html() { global $ID; global $INPUT; if (is_null($this->_auth)) { print $this->lang['badauth']; return false; } $sqlite = $this->hlp->_getDB(); if (!$sqlite) { return; } $fn = $INPUT->param('fn'); if (is_array($fn)) { $cmd = key($fn); $param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null; } else { $cmd = $fn; $param = null; } $user_list = $this->_auth->retrieveUsers($this->_start, $this->_pagesize, $this->_filter); echo $this->locale_xhtml('admin_intro'); $form = new Doku_Form(array('method' => 'post')); $form->addHidden('page', 'userprofile_users'); // List registered users $form->addElement('<table>' . '<tr>' . '<th>' . $this->getLang('username') . '</th>' . '<th>' . $this->getLang('realname') . '</th>' . '<th>' . $this->getLang('email') . '</th>' . '</tr>'); foreach ($user_list as $user => $userinfo) { extract($userinfo); /** * @var string $name * @var string $pass * @var string $mail * @var array $grps */ if (!in_array('noprofile', $grps)) { $form->addElement('<tr>' . '<td><a href="' . wl($ID, array('fn[edit][' . $user . ']' => 1, 'do' => 'admin', 'page' => 'userprofile_users', 'sectok' => getSecurityToken())) . '" title="' . $this->lang['edit_prompt'] . '">' . hsc($user) . '</a></td>' . '<td>' . hsc($name) . '</td>' . '<td>' . hsc($mail) . '</td>' . '</tr>'); } } $form->addElement('</table>'); // Edit table if ($cmd == "edit") { $user = $param; $profile = $this->hlp->getProfile($user); // create hidden fields $form->addHidden('up[user][user]', $user); $form->addHidden('up[user][name]', $user_list[$user]['name']); $form->addHidden('up[user][email]', $user_list[$user]['mail']); $sql = "SELECT * FROM fields"; $res = $sqlite->query($sql); $fields = $sqlite->res2arr($res); $form->addElement('<table>' . '<tr>' . '<th colspan="2">' . $this->getLang('th_edit') . '</th>' . '</tr>' . '<tr>' . '<td>' . $this->getLang('realname') . '</td>' . '<td>' . hsc($user_list[$user]['name']) . '</td>' . '</tr>' . '<tr>' . '<td>' . $this->getLang('email') . '</td>' . '<td>' . hsc($user_list[$user]['mail']) . '</td>' . '</tr>'); foreach ($fields as $field) { $form->addElement('<tr>'); $form->addElement('<td>' . hsc($field['title']) . '</td>'); $form->addElement('<td>'); $defaults_array = explode('|', $field['defaultval']); if (count($defaults_array) > 1) { // create select field $defaults_array = array_map('trim', $defaults_array); $form->addElement(form_makeMenuField('up[data][' . $field['name'] . ']', $defaults_array, $profile[$field['name']], '')); } else { // create regular text field $form->addElement(form_makeTextField('up[data][' . $field['name'] . ']', $profile[$field['name']], '')); } $form->addElement('</td>'); $form->addElement('</tr>'); } $form->addElement('<tr>' . '<td colspan="2">'); $form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit'))); $form->addElement('</td>'); $form->addElement('</table>'); } $form->printForm(); }
/** * output appropriate html */ function html() { global $ID; if (is_null($this->_auth)) { print $this->lang['badauth']; return false; } $user_list = $this->_auth->retrieveUsers($this->_start, $this->_pagesize, $this->_filter); $users = array_keys($user_list); $page_buttons = $this->_pagination(); $delete_disable = $this->_auth->canDo('delUser') ? '' : 'disabled="disabled"'; $editable = $this->_auth->canDo('UserMod'); print $this->locale_xhtml('intro'); print $this->locale_xhtml('list'); ptln("<div id=\"user__manager\">"); ptln("<div class=\"level2\">"); if ($this->_user_total > 0) { ptln("<p>" . sprintf($this->lang['summary'], $this->_start + 1, $this->_last, $this->_user_total, $this->_auth->getUserCount()) . "</p>"); } else { ptln("<p>" . sprintf($this->lang['nonefound'], $this->_auth->getUserCount()) . "</p>"); } ptln("<form action=\"" . wl($ID) . "\" method=\"post\">"); formSecurityToken(); ptln(" <table class=\"inline\">"); ptln(" <thead>"); ptln(" <tr>"); ptln(" <th> </th><th>" . $this->lang["user_id"] . "</th><th>" . $this->lang["user_name"] . "</th><th>" . $this->lang["user_mail"] . "</th><th>" . $this->lang["user_groups"] . "</th>"); ptln(" </tr>"); ptln(" <tr>"); ptln(" <td class=\"rightalign\"><input type=\"image\" src=\"" . DOKU_PLUGIN_IMAGES . "search.png\" name=\"fn[search][new]\" title=\"" . $this->lang['search_prompt'] . "\" alt=\"" . $this->lang['search'] . "\" class=\"button\" /></td>"); ptln(" <td><input type=\"text\" name=\"userid\" class=\"edit\" value=\"" . $this->_htmlFilter('user') . "\" /></td>"); ptln(" <td><input type=\"text\" name=\"username\" class=\"edit\" value=\"" . $this->_htmlFilter('name') . "\" /></td>"); ptln(" <td><input type=\"text\" name=\"usermail\" class=\"edit\" value=\"" . $this->_htmlFilter('mail') . "\" /></td>"); ptln(" <td><input type=\"text\" name=\"usergroups\" class=\"edit\" value=\"" . $this->_htmlFilter('grps') . "\" /></td>"); ptln(" </tr>"); ptln(" </thead>"); if ($this->_user_total) { ptln(" <tbody>"); foreach ($user_list as $user => $userinfo) { extract($userinfo); $groups = join(', ', $grps); ptln(" <tr class=\"user_info\">"); ptln(" <td class=\"centeralign\"><input type=\"checkbox\" name=\"delete[" . $user . "]\" " . $delete_disable . " /></td>"); if ($editable) { ptln(" <td><a href=\"" . wl($ID, array('fn[edit][' . hsc($user) . ']' => 1, 'do' => 'admin', 'page' => 'usermanager', 'sectok' => getSecurityToken())) . "\" title=\"" . $this->lang['edit_prompt'] . "\">" . hsc($user) . "</a></td>"); } else { ptln(" <td>" . hsc($user) . "</td>"); } ptln(" <td>" . hsc($name) . "</td><td>" . hsc($mail) . "</td><td>" . hsc($groups) . "</td>"); ptln(" </tr>"); } ptln(" </tbody>"); } ptln(" <tbody>"); ptln(" <tr><td colspan=\"5\" class=\"centeralign\">"); ptln(" <span class=\"medialeft\">"); ptln(" <input type=\"submit\" name=\"fn[delete]\" " . $delete_disable . " class=\"button\" value=\"" . $this->lang['delete_selected'] . "\" id=\"usrmgr__del\" />"); ptln(" </span>"); ptln(" <span class=\"mediaright\">"); ptln(" <input type=\"submit\" name=\"fn[start]\" " . $page_buttons['start'] . " class=\"button\" value=\"" . $this->lang['start'] . "\" />"); ptln(" <input type=\"submit\" name=\"fn[prev]\" " . $page_buttons['prev'] . " class=\"button\" value=\"" . $this->lang['prev'] . "\" />"); ptln(" <input type=\"submit\" name=\"fn[next]\" " . $page_buttons['next'] . " class=\"button\" value=\"" . $this->lang['next'] . "\" />"); ptln(" <input type=\"submit\" name=\"fn[last]\" " . $page_buttons['last'] . " class=\"button\" value=\"" . $this->lang['last'] . "\" />"); ptln(" </span>"); ptln(" <input type=\"submit\" name=\"fn[search][clear]\" class=\"button\" value=\"" . $this->lang['clear'] . "\" />"); ptln(" <input type=\"hidden\" name=\"do\" value=\"admin\" />"); ptln(" <input type=\"hidden\" name=\"page\" value=\"usermanager\" />"); $this->_htmlFilterSettings(2); ptln(" </td></tr>"); ptln(" </tbody>"); ptln(" </table>"); ptln("</form>"); ptln("</div>"); $style = $this->_edit_user ? " class=\"edit_user\"" : ""; if ($this->_auth->canDo('addUser')) { ptln("<div" . $style . ">"); print $this->locale_xhtml('add'); ptln(" <div class=\"level2\">"); $this->_htmlUserForm('add', null, array(), 4); ptln(" </div>"); ptln("</div>"); } if ($this->_edit_user && $this->_auth->canDo('UserMod')) { ptln("<div" . $style . " id=\"scroll__here\">"); print $this->locale_xhtml('edit'); ptln(" <div class=\"level2\">"); $this->_htmlUserForm('modify', $this->_edit_user, $this->_edit_userdata, 4); ptln(" </div>"); ptln("</div>"); } ptln("</div>"); }
Download it from <a href="http://java.sun.com">http://java.sun.com</a>. </applet> </embed> </object> <!-- <APPLET CODE = "com.hammurapi.jcapture.JCaptureApplet.class" ARCHIVE = "<?php echo DOKU_BASE; ?> /lib/plugins/jcapture/lib/jcapture.jar" NAME = "jCapture"> <PARAM NAME = "dokuBase" VALUE="<?php echo bin2hex(DOKU_BASE); ?> "> <PARAM NAME = "sectok" VALUE="<?php echo getSecurityToken(); ?> "> <PARAM NAME = "cookies" VALUE="<?php echo $cookies; ?> "> <PARAM NAME = "host" VALUE="<?php echo $hostName; ?> "> Java 2 Standard Edition v 1.7 or above is required for this applet.<br/> Download it from <a href="http://java.sun.com">http://java.sun.com</a>. </APPLET> -->
/** * Print the media upload form if permissions are correct * * @author Andreas Gohr <*****@*****.**> */ function media_uploadform($ns, $auth) { global $lang; if ($auth < AUTH_UPLOAD) { return; } //fixme print info on missing permissions? // The default HTML upload form $form = new Doku_Form(array('id' => 'dw__upload', 'action' => DOKU_BASE . 'lib/exe/mediamanager.php', 'enctype' => 'multipart/form-data')); $form->addElement('<div class="upload">' . $lang['mediaupload'] . '</div>'); $form->addElement(formSecurityToken()); $form->addHidden('ns', hsc($ns)); $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeFileField('upload', $lang['txt_upload'] . ':', 'upload__file')); $form->addElement(form_makeCloseTag('p')); $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeTextField('id', '', $lang['txt_filename'] . ':', 'upload__name')); $form->addElement(form_makeButton('submit', '', $lang['btn_upload'])); $form->addElement(form_makeCloseTag('p')); if ($auth >= AUTH_DELETE) { $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check')); $form->addElement(form_makeCloseTag('p')); } html_form('upload', $form); // prepare flashvars for multiupload $opt = array('L_gridname' => $lang['mu_gridname'], 'L_gridsize' => $lang['mu_gridsize'], 'L_gridstat' => $lang['mu_gridstat'], 'L_namespace' => $lang['mu_namespace'], 'L_overwrite' => $lang['txt_overwrt'], 'L_browse' => $lang['mu_browse'], 'L_upload' => $lang['btn_upload'], 'L_toobig' => $lang['mu_toobig'], 'L_ready' => $lang['mu_ready'], 'L_done' => $lang['mu_done'], 'L_fail' => $lang['mu_fail'], 'L_authfail' => $lang['mu_authfail'], 'L_progress' => $lang['mu_progress'], 'L_filetypes' => $lang['mu_filetypes'], 'L_info' => $lang['mu_info'], 'L_lasterr' => $lang['mu_lasterr'], 'O_ns' => ":{$ns}", 'O_backend' => 'mediamanager.php?' . session_name() . '=' . session_id(), 'O_maxsize' => php_to_byte(ini_get('upload_max_filesize')), 'O_extensions' => join('|', array_keys(getMimeTypes())), 'O_overwrite' => $auth >= AUTH_DELETE, 'O_sectok' => getSecurityToken(), 'O_authtok' => auth_createToken()); $var = buildURLparams($opt); // output the flash uploader ?> <div id="dw__flashupload" style="display:none"> <div class="upload"><?php echo $lang['mu_intro']; ?> </div> <?php echo html_flashobject('multipleUpload.swf', '500', '190', null, $opt); ?> </div> <?php }
function _treeOpts($name, $current) { $opts = $this->loadRoute($name); $o = array('route' => $name, 'classname' => $opts['vars']['class'], 'loader' => $opts['init_plugin'], 'current' => ':' . ltrim(strtr($current, '/', ':'), ':'), 'onselectpage' => (bool) $opts['callbacks']['page_selected_cb'], 'onselectns' => (bool) $opts['callbacks']['ns_selected_cb'], 'onselectnsjs' => null, 'onselectpagejs' => null, 'token' => getSecurityToken()); $json = json_encode($o); $json = preg_replace_callback('~("onselect(ns|page)js"\\s*:\\s*)null\\s*,~', function ($m) use($opts) { if (is_string($x = $opts['callbacks'][$m[2] . '_selected_js']) && strlen($x) > 0) { return $m[1] . $x . '||null,'; } return $m[0]; }, $json); return $json; }
public function html() { global $lang, $ID; ptln('<h1>' . $this->getLang('title') . ' : '.getNS($ID).'</h1>'); if($this->error != ""){ ptln("<div class='error'>".$this->error."</div>"); } if($this->ok != ""){ ptln("<div class='success'>".$this->ok."</div>"); } if(count($this->orphans_medias)>0){ ptln('<table class="inline">'); ptln('<tr><th class="centeralign">ID</strong></th><th>Actions</th></tr>'); $i=0; foreach($this->orphans_medias as $id => $media){ ptln('<tr>'); ptln('<td>' . $id . '</td>'); $link = ml($id,'',true); $btn_view = ' <a href="'.$link.'" target="_blank"> <img src="'.DOKU_BASE.'lib/images/magnifier.png" alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" /> </a>'; $btn_delete = ' <form id="unusedmedias_form_'.$i.'_delete" method="post" action=""> <input type="hidden" name="media_id_to_delete" value="'.$id.'" /> <input type="hidden" name="sectok" value="'.getSecurityToken().'" /> </form> <a href="#" class="btn_media_delete" title="'.$id.'" onclick=\'if(confirm("'.$this->getLang('js_confirm_delete').'")){document.getElementById("unusedmedias_form_'.$i.'_delete").submit();}return false;\'> <img src="'.DOKU_BASE.'lib/images/trash.png" alt="'.$lang['btn_delete'].'" title="'.$lang['btn_delete'].'" class="btn" /> </a>'; ptln('<td> '.$btn_view.' '.$btn_delete.'</td>'); ptln('</tr>'); $i++; } ptln('</table>'); }else{ ptln('<div>'.$this->getLang('nomatches').'</div>'); } }
/** * Reads all available input data extracting values related to this plugin. * * @return array set of input data related to current plugin */ protected function getInput() { if (is_null($this->input)) { $index = $this->getIndex(); $this->input = array(); $matchingSecTok = $_REQUEST['sectok'] == getSecurityToken(); foreach ($_REQUEST as $name => $value) { if (preg_match('/^db2do(.+?)(_[xy])?$/i', $name, $matches)) { if ($matchingSecTok || $_GET[$name] && preg_match('/^(cmd|opt)/i', $matches[1])) { if (is_null($this->input[$matches[1]])) { if (!is_array($value) || !is_null($value[$index])) { $this->input[$matches[1]] = is_array($value) ? $value[$index] : $value; } } } } } } return $this->input; }
/** * Like the action buttons but links * * Available links are * * edit - edit/create/show link * history - old revisions * recent - recent changes * login - login/logout link - if ACL enabled * profile - user profile link (if logged in) * index - The index * admin - admin page - if enough rights * top - a back to top link * back - a back to parent link - if available * backlink - links to the list of backlinks * subscribe/subscription - subscribe/unsubscribe link * * @author Andreas Gohr <*****@*****.**> * @author Matthias Grimm <*****@*****.**> * @see tpl_button */ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '') { global $ID; global $INFO; global $REV; global $ACT; global $conf; global $lang; global $auth; // check disabled actions and fix the badly named ones $ctype = $type; if ($type == 'history') { $ctype = 'revisions'; } if (!actionOK($ctype)) { return false; } switch ($type) { case 'edit': #most complicated type - we need to decide on current action if ($ACT == 'show' || $ACT == 'search') { if ($INFO['writable']) { if (!empty($INFO['draft'])) { tpl_link(wl($ID, 'do=draft'), $pre . ($inner ? $inner : $lang['btn_draft']) . $suf, 'class="action edit" accesskey="e" rel="nofollow"'); } else { if ($INFO['exists']) { tpl_link(wl($ID, 'do=edit&rev=' . $REV), $pre . ($inner ? $inner : $lang['btn_edit']) . $suf, 'class="action edit" accesskey="e" rel="nofollow"'); } else { tpl_link(wl($ID, 'do=edit&rev=' . $REV), $pre . ($inner ? $inner : $lang['btn_create']) . $suf, 'class="action create" accesskey="e" rel="nofollow"'); } } } else { if (!actionOK('source')) { return false; } //pseudo action tpl_link(wl($ID, 'do=edit&rev=' . $REV), $pre . ($inner ? $inner : $lang['btn_source']) . $suf, 'class="action source" accesskey="v" rel="nofollow"'); } } else { tpl_link(wl($ID, 'do=show'), $pre . ($inner ? $inner : $lang['btn_show']) . $suf, 'class="action show" accesskey="v" rel="nofollow"'); } return true; case 'history': tpl_link(wl($ID, 'do=revisions'), $pre . ($inner ? $inner : $lang['btn_revs']) . $suf, 'class="action revisions" accesskey="o" rel="nofollow"'); return true; case 'recent': tpl_link(wl('', 'do=recent'), $pre . ($inner ? $inner : $lang['btn_recent']) . $suf, 'class="action recent" accesskey="r" rel="nofollow"'); return true; case 'index': tpl_link(wl($ID, 'do=index'), $pre . ($inner ? $inner : $lang['btn_index']) . $suf, 'class="action index" accesskey="x" rel="nofollow"'); return true; case 'top': print '<a href="#dokuwiki__top" class="action top" accesskey="x">' . $pre . ($inner ? $inner : $lang['btn_top']) . $suf . '</a>'; return true; case 'back': if ($parent = tpl_getparent($ID)) { tpl_link(wl($parent, 'do=show'), $pre . ($inner ? $inner : $lang['btn_back']) . $suf, 'class="action back" accesskey="b" rel="nofollow"'); return true; } return false; case 'login': if ($conf['useacl'] && $auth) { if ($_SERVER['REMOTE_USER']) { tpl_link(wl($ID, 'do=logout&sectok=' . getSecurityToken()), $pre . ($inner ? $inner : $lang['btn_logout']) . $suf, 'class="action logout" rel="nofollow"'); } else { tpl_link(wl($ID, 'do=login&sectok=' . getSecurityToken()), $pre . ($inner ? $inner : $lang['btn_login']) . $suf, 'class="action login" rel="nofollow"'); } return true; } return false; case 'admin': if ($INFO['ismanager']) { tpl_link(wl($ID, 'do=admin'), $pre . ($inner ? $inner : $lang['btn_admin']) . $suf, 'class="action admin" rel="nofollow"'); return true; } return false; case 'subscribe': case 'subscription': if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1) { if ($_SERVER['REMOTE_USER']) { if ($INFO['subscribed']) { tpl_link(wl($ID, 'do=unsubscribe'), $pre . ($inner ? $inner : $lang['btn_unsubscribe']) . $suf, 'class="action unsubscribe" rel="nofollow"'); } else { tpl_link(wl($ID, 'do=subscribe'), $pre . ($inner ? $inner : $lang['btn_subscribe']) . $suf, 'class="action subscribe" rel="nofollow"'); } return true; } } return false; case 'subscribens': if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1) { if ($_SERVER['REMOTE_USER']) { if ($INFO['subscribedns']) { tpl_link(wl($ID, 'do=unsubscribens'), $pre . ($inner ? $inner : $lang['btn_unsubscribens']) . $suf, 'class="action unsubscribens" rel="nofollow"'); } else { tpl_link(wl($ID, 'do=subscribens'), $pre . ($inner ? $inner : $lang['btn_subscribens']) . $suf, 'class="action subscribens" rel="nofollow"'); } return true; } } return false; case 'backlink': tpl_link(wl($ID, 'do=backlink'), $pre . ($inner ? $inner : $lang['btn_backlink']) . $suf, 'class="action backlink" rel="nofollow"'); return true; case 'profile': if ($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && $auth->canDo('Profile') && $ACT != 'profile') { tpl_link(wl($ID, 'do=profile'), $pre . ($inner ? $inner : $lang['btn_profile']) . $suf, 'class="action profile" rel="nofollow"'); return true; } return false; default: print '[unknown link type]'; return true; } }
/** * Formats and prints one file in the list * * @see media_printfile() */ function _mod_media_printfile($item, $auth, $jump, $display_namespace = false) { global $lang; global $conf; // Prepare zebra coloring // I always wanted to use this variable name :-D static $twibble = 1; $twibble *= -1; $zebra = $twibble == -1 ? 'odd' : 'even'; // Automatically jump to recent action if ($jump == $item['id']) { $jump = ' id="scroll__here" '; } else { $jump = ''; } // Prepare fileicons list($ext, $mime, $dl) = mimetype($item['file'], false); $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext); $class = 'select mediafile mf_' . $class; // Prepare filename $file = $this->_getOriginalFileName($item['id']); if ($file === false) { $file = utf8_decodeFN($item['file']); } // build fake media id $ns = getNS($item['id']); $fakeId = $ns === false ? $file : "{$ns}:{$file}"; $fakeId_escaped = hsc($fakeId); // Prepare info $info = ''; if ($item['isimg']) { $info .= (int) $item['meta']->getField('File.Width'); $info .= '×'; $info .= (int) $item['meta']->getField('File.Height'); $info .= ' '; } $info .= '<i>' . dformat($item['mtime']) . '</i>'; $info .= ' '; $info .= filesize_h($item['size']); // output echo '<div class="' . $zebra . '"' . $jump . ' title="' . $fakeId_escaped . '">' . NL; if (!$display_namespace) { echo '<a name="h_:' . $item['id'] . '" class="' . $class . '">' . hsc($file) . '</a> '; } else { echo '<a name="h_:' . $item['id'] . '" class="' . $class . '">' . $fakeId_escaped . '</a><br/>'; } echo '<span class="info">(' . $info . ')</span>' . NL; // view button $link = ml($fakeId, '', true); echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>'; // mediamanager button $link = wl('', array('do' => 'media', 'image' => $fakeId, 'ns' => $ns)); echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/mediamanager.png" ' . 'alt="' . $lang['btn_media'] . '" title="' . $lang['btn_media'] . '" class="btn" /></a>'; // delete button if ($item['writable'] && $auth >= AUTH_DELETE) { $link = DOKU_BASE . 'lib/exe/mediamanager.php?delete=' . rawurlencode($fakeId) . '&sectok=' . getSecurityToken(); echo ' <a href="' . $link . '" class="btn_media_delete" title="' . $fakeId_escaped . '">' . '<img src="' . DOKU_BASE . 'lib/images/trash.png" alt="' . $lang['btn_delete'] . '" ' . 'title="' . $lang['btn_delete'] . '" class="btn" /></a>'; } echo '<div class="example" id="ex_' . str_replace(':', '_', $item['id']) . '">'; echo $lang['mediausage'] . ' <code>{{:' . str_replace(array('{', '}'), array('(', ')'), $fakeId_escaped) . '}}</code>'; echo '</div>'; if ($item['isimg']) { media_printimgdetail($item); } echo '<div class="clearer"></div>' . NL; echo '</div>' . NL; }
/** * Render HTML output, e.g. helpful text and a form */ public function html() { global $ID; echo $this->locale_xhtml('assignments_intro'); $ass = new Assignments(); $assignments = $ass->getAllPatterns(); echo '<form action="' . wl($ID) . '" action="post">'; echo '<input type="hidden" name="do" value="admin" />'; echo '<input type="hidden" name="page" value="struct_assignments" />'; echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />'; echo '<table class="inline">'; // header echo '<tr>'; echo '<th>' . $this->getLang('assign_assign') . '</th>'; echo '<th>' . $this->getLang('assign_tbl') . '</th>'; echo '<th></th>'; echo '</tr>'; // existing assignments foreach ($assignments as $assignment) { $schema = $assignment['tbl']; $assignee = $assignment['pattern']; $link = wl($ID, array('do' => 'admin', 'page' => 'struct_assignments', 'action' => 'delete', 'sectok' => getSecurityToken(), 'assignment[tbl]' => $schema, 'assignment[assign]' => $assignee)); echo '<tr>'; echo '<td>' . hsc($assignee) . '</td>'; echo '<td>' . hsc($schema) . '</td>'; echo '<td><a class="deleteSchema" href="' . $link . '">' . $this->getLang('assign_del') . '</a></td>'; echo '</tr>'; } // new assignment form echo '<tr>'; echo '<td><input type="text" name="assignment[assign]" /></td>'; echo '<td>'; echo '<select name="assignment[tbl]">'; foreach (Schema::getAll('page') as $table) { echo '<option value="' . hsc($table) . '">' . hsc($table) . '</option>'; } echo '</select>'; echo '</td>'; echo '<td><button type="submit" name="action" value="add">' . $this->getLang('assign_add') . '</button></td>'; echo '</tr>'; echo '</table>'; }