'; }//if ((@file_exists($file2)) && (@unlink($file)) && (@copy($file2, $file))) /****** theme not found ******/ else msg('Could not set correct style.ini file for your chosen theme.', -1); }//if ($ini['__theme__'] != $theme) }//function rb_checkTheme() /** * get user name and groups * Works around bug in DokuWiki <= 2009-09-22 and also appends * 'ALL' to list of groups to facilitate group access checking * * @author Chris Arndt */ function rb_get_user_info() {//func /****** declare global variables ******/ global $INFO; /****** set user array ******/ $user = array(); /****** no valid user ******/ if ($_REQUEST['do'] == 'logout' or !isset($INFO['userinfo'])) $user['groups'] = array(); /****** set user information ******/ else {//do $user['groups'] = $INFO['userinfo']['grps']; $user['name'] = $_SERVER['REMOTE_USER']; }//else do /****** add ALL ******/ array_push($user['groups'], 'ALL'); /****** return user ******/ return $user; }//function rb_get_user_info() /** * check if current user should have access to given action * Relies on certain configuration parameters to be present * * @author Chris Arndt */ function rb_check_action_perms($action, $perms, $user) {//func /****** declare global variables ******/ global $conf; /****** set access control variables ******/ $ac_lvls = tpl_getConf('rb_act_ac_lvl'); $ac_users = tpl_getConf('rb_act_users'); $ac_lvl = $ac_lvls[$action]; /****** set default access level ******/ if (!isset($ac_lvl) or $ac_lvl == '') $ac_lvl = 255; /****** access level is ok ******/ if ($perms >= $ac_lvl) return true; /****** check access level ******/ elseif (!empty($ac_users[$action])) {//do $speclist = explode(',', $ac_users[$action]); $allowed_users = array(); $allowed_groups = array(); foreach ($speclist as $spec) {//do $spec = trim($spec); if (substr($spec, 0, 1) == '@') array_push($allowed_groups, substr($spec, 1)); else array_push($allowed_users, $spec); }//foreach ($speclist as $spec) if (!empty($info['user']) and in_array($user['name'], $allowed_users)) return true; foreach ($user['groups'] as $group) {//do if (in_array($group, $allowed_groups)) return true; }//foreach ($user['groups'] as $group) }//if (!empty($ac_users[$action])) /****** refuse access ******/ return false; }//function rb_check_action_perms($action, $perms, $user) /** * show button or link for given action depending on visibility settings * * @author Chris Arndt */ function rb_button($action, $perms, $user) {//func /****** declare global variables ******/ global $conf; /****** generate button/link if allowed ******/ if (rb_check_action_perms($action, $perms, $user)) {//do /****** generate link ******/ if (tpl_getConf('rb_uselinks')) {//do if (tpl_get_action($action)) {//do} ptln('
  • '); tpl_actionlink($action); ptln('
  • '); }//if (tpl_get_action($action)) }//if (tpl_getConf('rb_uselinks')) /****** generate button ******/ else {//if not (tpl_getConf('rb_uselinks')) tpl_button($action); ptln('
    '); }//if not (tpl_getConf('rb_uselinks')) }//if (rb_check_action_perms($action, $perms, $user)) }//function rb_button($action, $perms, $user) /** * prints the contents of the command box in the sidebar * * @author Chris Arndt */ function rb_sitecmds($perms, $user) {//func /****** declare global variables ******/ global $conf; /****** start list of links ******/ if (tpl_getConf('rb_uselinks')) ptln('
      '); /****** start button box ******/ else ptln('
      '); /****** generate buttons/links ******/ foreach (tpl_getConf('rb_actions') as $command) {//do /****** generate break ******/ if ($command == '-') {//do if (tpl_getConf('rb_uselinks')) {//do ptln('
    '); ptln('
      '); }//if (tpl_getConf('rb_uselinks')) else //if not (tpl_getConf('rb_uselinks')) ptln('
      '); }//if ($command == '-') /****** generate button/link ******/ else rb_button($command, $perms, $user); }//foreach (tpl_getConf('rb_actions') as $command) /****** finish list of links ******/ if (tpl_getConf('rb_uselinks')) ptln('
    '); /****** finish button box ******/ else ptln(''); }//function rb_sitecmds($perms, $user) /** * replacement for tpl_youarehere() * Links namespaces to :index * * taken from: * */ function rb_youarehere() {//func /****** declare global variables ******/ global $conf; global $ID; global $lang; /****** break id into parts ******/ $parts = explode(':', $ID); /****** show line header ******/ echo hsc($lang['youarehere']).': '; /****** always show start page ******/ if ($a_part[0] != $conf['start']) {//do tpl_link(wl($conf['start']), $conf['start'], 'title="'.$conf['start'].'"'); }//if ($a_part[0] != $conf['start']) /****** set variables ******/ $page = ''; $last = count($parts); $count = 1; /****** process each part ******/ foreach ($parts as $part) {//do /****** process part ******/ if ($count != $last || $part != tpl_getConf('rb_index')) {//do /****** skip start page if already done ******/ if ($part == $conf['start']) continue; /****** show separator ******/ echo tpl_getConf('rb_crumbsep'); /****** edit page ******/ $page .= $part; /****** remove underscores ******/ if (tpl_getConf('rb_removeunderscores') == 1) $part = str_replace('_', ' ', $part); /****** set link variable ******/ if ($count == $last) $link = $page; else $link = "$page:" . tpl_getConf('rb_index'); /****** show link if page exists ******/ if (file_exists(wikiFN($link))) tpl_link(wl($link), $part, 'title="'.$link.'"'); /****** show link, but mark as not-existing ******/ else tpl_link(wl($link), $part, 'title="'.$link.'" class="wikilink2"'); /****** add namespace separator ******/ $page .= ':'; }//if ($count != $last || $part != tpl_getConf('rb_index')) /****** increment count ******/ $count++; }//foreach ($parts as $part) }//function rb_youarehere() /** * Show meta information for images * * @author Chris Arndt */ function rb_img_meta($debug=false) {//func /****** declare global variables ******/ global $conf; global $lang; global $IMG; /* change the order of fields in this array to change the order in which * the image information tags are listed */ $tags = array( 'img_caption' => array('IPTC.Caption', 'EXIF.UserComment', 'EXIF.TIFFImageDescription', 'EXIF.TIFFUserComment'), 'img_artist' => array('Iptc.Byline', 'Exif.TIFFArtist', 'Exif.Artist', 'Iptc.Credit'), 'img_keywords' => array('IPTC.Keywords','IPTC.Category'), 'img_copyr' => array('Iptc.CopyrightNotice', 'Exif.TIFFCopyright', 'Exif.Copyright'), 'img_camera' => 'Simple.Camera', 'img_fname' => 'File.Name', 'img_format' => 'File.Format', 'img_dimen'=> null, // built from File.Width and File.Height 'img_date' => 'Date.EarliestTime', 'img_fsize'=> 'File.NiceSize', ); /****** start table ******/ ptln(''); /****** show caption ******/ ptln('', 2); /****** show column headers ******/ ptln('', 2); ptln('', 4); ptln('', 6); ptln('', 6); ptln('', 4); ptln('', 2); /****** generate table ******/ ptln('', 2); foreach ($tags as $tagname => $meta) {//do if ($tagname == 'img_dimen') {//do $info = tpl_img_getTag('File.Width') . '×' . tpl_img_getTag('File.Height'); }//if ($tagname == 'img_dimen') else {//if not ($tagname == 'img_dimen') $info = tpl_img_getTag($meta); if ($info && $tagname == 'img_date') $info = dformat($info, $conf['dformat']); else $info = nl2br(hsc($info)); }//if not ($tagname == 'img_dimen') if ($info) {//do ptln('', 4); ptln('', 6); ptln('', 6); ptln('', 4); }//if ($info) }//foreach ($tags as $tagname => $meta) ptln('', 2); ptln('
    ', 2); ptln($lang['img_metaheading'], 4); // if (tpl_img_getTag('File.Mime') == 'image/jpeg') rb_btn_img_meta_edit($IMG, true); ptln('
    ' . $lang['colfield'] . '' . $lang['colvalue'] . '
    ' . hsc($lang[$tagname]) . '' . $info . '
    '); /****** debug ******/ if ($debug) dbg(tpl_img_getTag('Simple.Raw')); }//function rb_img_meta($debug=false) /** * Show link to mediaedit page * * @author Chris Arndt */ function rb_btn_img_meta_edit($id, $newwin=false) {//func /****** declare global variables ******/ global $AUTH; global $lang; /****** show link ******/ if ($AUTH >= AUTH_UPLOAD) {//do echo ''; echo '' .
        $lang['metaedit'] . ''; ptln(''); }//if ($AUTH >= AUTH_UPLOAD) }//function rb_btn_img_meta_edit($id, $newwin=false) ?>