function ReadTrail($pagename, $trailname) { global $SuffixPattern, $GroupNamePattern, $WikiWordPattern; $trailname = MakePageName($pagename, $trailname); $trailpage = ReadPage($trailname); if (!$trailpage) { return false; } $t = array(); $n = 0; foreach (explode("\n", @$trailpage['text']) as $x) { $x = preg_replace("/^([#*]+)\\s*(({$GroupNamePattern}([\\.]))?{$WikiWordPattern})/", '$1 [[$2]]', $x); if (!preg_match("/^([#*]+)\\s*(\\[\\[(.*?)\\]\\]({$SuffixPattern}))(.*)\$/", $x, $match)) { continue; } $tgt = MakeLink($trailname, $match[3], NULL, NULL, '$PageName'); if ($tgt == '$PageName') { continue; } $t[$n]['depth'] = $depth = strlen($match[1]); $t[$n]['pagename'] = $tgt; $t[$n]['markup'] = $match[2]; for ($i = $depth; $i < 10; $i++) { $d[$i] = $n; } if ($depth > 1) { $t[$n]['parent'] = @$d[$depth - 1]; } $n++; } return $t; }
function WikiLink($pagename, $word) { global $LinkWikiWords, $WikiWordCount, $SpaceWikiWords, $AsSpacedFunction, $MarkupFrame, $WikiWordCountMax; if (!$LinkWikiWords || ($WikiWordCount[$word] < 0)) return $word; $text = ($SpaceWikiWords) ? $AsSpacedFunction($word) : $word; $text = preg_replace('!.*/!', '', $text); if (!isset($MarkupFrame[0]['wwcount'][$word])) $MarkupFrame[0]['wwcount'][$word] = $WikiWordCountMax; if ($MarkupFrame[0]['wwcount'][$word]-- < 1) return $text; return MakeLink($pagename, $word, $text); }
function WikiGallerySlideshow($pagename, $auth = 'read') { global $WikiGallery_DefaultSlideshowDelay, $HTMLHeaderFmt, $WikiGallery_Register; // get delay from url if (isset($_GET["delay"])) { $delay = intval($_GET["delay"]); } else { $delay = $WikiGallery_DefaultSlideshowDelay; } // find following picture $group = PageVar($pagename, '$Group'); $next = $WikiGallery_Register[$group]->neighbourPicturePage(PageVar($pagename, '$Name'), 1); $nextpage = "{$group}.{$next}"; // exists? if ($next && PageExists($nextpage)) { // add refresh header $url = MakeLink($nextpage, $nextpage, NULL, NULL, "\$LinkUrl"); array_unshift($HTMLHeaderFmt, "<meta http-equiv=\"refresh\" content=\"{$delay}; URL={$url}?action=slideshow&delay={$delay}\" />"); } return HandleBrowse($pagename, $auth); }
function WikiLink($pagename, $word) { global $LinkWikiWords, $SpaceWikiWords, $AsSpacedFunction; $text = $SpaceWikiWords ? $AsSpacedFunction($word) : $word; $text = preg_replace('!.*/!', '', $text); if (!$LinkWikiWords) { return $text; } return MakeLink($pagename, $word, $text); }
function WikiLink($pagename, $word) { global $LinkWikiWords, $SpaceWikiWords, $AsSpacedFunction, $MarkupFrame, $WikiWordCountMax; $text = $SpaceWikiWords ? $AsSpacedFunction($word) : $word; if (!$LinkWikiWords) { return $text; } $text = preg_replace('!.*/!', '', $text); if (!isset($MarkupFrame[0]['wwcount'][$word])) { $MarkupFrame[0]['wwcount'][$word] = $WikiWordCountMax; } if ($MarkupFrame[0]['wwcount'][$word]-- < 1) { return $text; } return MakeLink($pagename, $word, $text); }
function BuildGroupList($list) { $out = ''; $group = ''; foreach ($list as $page) { # if group name is empty or != previous group name, capture it and start new unordered list preg_match('/\\((.*?).\\)/', $page, $matches); if ($group == '' || $group != $matches[1]) { # only close if a group has been set if ($group != '') { $out .= "</ul></li>"; } $group = $matches[1]; $out .= "<li class='nav nav-list'>{$group}<b class='caret'></b>"; $out .= "<ul class='dropdown-menu'>"; } $out .= '<li>'; $out .= MakeLink($pagename, $page); $out .= '</li>'; } $out .= "</ul></li>"; return $out; }
/** * Main routine called from markup within wiki pages */ function pmGallery($args) { $o = array('album' => '', 'wikitarget' => '', 'startimg' => '', 'tag' => '', 'random' => '', 'width' => '', 'height' => '', 'imageurl' => '', 'query' => '', 'user' => '', 'thumbsize' => '', 'imagesize' => '', 'maxresults' => '', 'wrapper' => 'ul > li', 'mode' => '', 'provider' => 'picasa', 'exif' => false, 'urlbase' => 'com', 'proxy' => '', 'authkey' => '', 'debug' => false, 'cachedir' => '', 'cachelife' => '7200'); $o = array_merge($o, $GLOBALS['pmGallery']); // Allows the markup to be used in an (:include user="******":) where {$$user} might be blank, and thus passed to this routine as {$$user}. $o = array_merge($o, preg_grep('/(\\{\\$\\$.*\\}|^$)/', ParseArgs($args), PREG_GREP_INVERT)); #find all elements NOT like {$$user} or empty $o = array_merge($o, $_GET); $o['wikitarget'] = empty($o['wikitarget']) ? $GLOBALS['pmGroup'] : $o['wikitarget']; // if the image url supplied, then show the image if (!empty($o['imageurl'])) { return '<div class="pmGalleryWrapperImage"><img src="http://' . $o['imageurl'] . '" /></div>'; } require_once 'picasa.php5'; $myPicasaParser = new picasaAPI(); $myPicasaParser->updateOption('startimg', $o['startimg']); $myPicasaParser->updateOption('tag', $o['tag']); $myPicasaParser->updateOption('query', $o['query']); $myPicasaParser->updateOption('user', $o['user'], false); $myPicasaParser->updateOption('thumbsize', $o['thumbsize'], false); $myPicasaParser->updateOption('imagesize', $o['imagesize'], false); $myPicasaParser->updateOption('maxresults', $o['maxresults'], false); $myPicasaParser->updateOption('urlbase', $o['urlbase']); $myPicasaParser->updateOption('cachelife', $o['cachelife']); $myPicasaParser->updateOption('cachedir', $o['cachedir']); $myPicasaParser->updateOption('proxy', $o['proxy']); $myPicasaParser->updateOption('authkey', $o['authkey']); // parse out the HTML outter and inner wrappers "ul > li" or "div > div", etc // NB: html_entity_decode doesn't replace > under RTF8 $wrapper = explode('>', preg_replace('!>!', '>', $o['wrapper'])); $wrapper[0] = trim($wrapper[0]); $wrapper[1] = trim($wrapper[empty($wrapper[1]) ? 0 : 1]); // holds the album/image sequencing; used to allow randomizing. Format: $seqA[n]='album#:image#' $seqA = array(); $albums = explode(',', $o['album']); $text = ''; // displaying one or more album covers: either $o['display'] is 'cover' or no album specified $displayCover = $o['mode'] == 'cover' || empty($o['album']); $linkDirect = $o['mode'] == 'linkdirect'; // handle procesing of more than one album, ie, (:pmGallery album=album1,album2 :) for ($albumN = 0; $displayCover && $albumN == 0 || !$displayCover && $albumN < count($albums) || count($albums) == 0; $albumN++) { $albumsA[$albumN] = $myPicasaParser->parseFeed($myPicasaParser->createFeedUrl($displayCover ? '' : $albums[$albumN], false)); genArray($seqA, $albumN, count($albumsA[$albumN]['main'])); } $seqN = empty($o['random']) || $o['random'] > count($seqA) ? count($seqA) : $o['random']; if (!empty($o['random'])) { randomizeArray($seqA, $seqN); } // loop through the sequential album/image or the randomized album/images for ($i = 0; $i < $seqN; $i++) { $x = explode(':', $seqA[$i]); $albumN = $x[0]; $imageN = $x[1]; $image = $albumsA[$albumN]['main'][$imageN]; $entry = $albumsA[$albumN]['entry'][$imageN]; $gphoto = $albumsA[$albumN]['gphoto'][$imageN]; $exif = $albumsA[$albumN]['exif'][$imageN]; //remove filename extension, otherwise PmWiki thinks it's a group.pagename format $image_title = explode('.', $image['title']); if ($displayCover && in_array($gphoto['name'], $albums) || !$displayCover) { $text .= '<' . $wrapper[1] . '>' . MakeLink($GLOBALS['pagename'], $linkDirect ? $image['largeSrc'] : (preg_match('!(\\.|\\/)!', $o['wikitarget']) ? $o['wikitarget'] : $image_title[0]), '<img src="' . $image['thumbSrc'] . '" ' . ($displayCover ? '' : 'height="' . (empty($o['height']) ? $entry['thumbnail_h'] : $o['height']) . '"' . 'width="' . (empty($o['width']) ? $entry['thumbnail_w'] : $o['width']) . '"') . ' />', '', '<a class="pmGallery' . ($displayCover ? 'Album' : 'Image') . 'Thumb" ' . "href='\$LinkUrl" . ($linkDirect ? '' : ($displayCover ? '?album=' . htmlentities($gphoto['name']) : '?imageurl=' . htmlentities(str_replace('http://', '', $image['largeSrc'])))) . "' " . (empty($entry['description']) ? '' : 'title="' . htmlentities($entry['description']) . '"') . ">\$LinkText" . '</a>') . '</' . $wrapper[1] . ">\n"; } } return '<div class="pmGalleryWrapper">' . (empty($text) ? '' : '<' . $wrapper[0] . " class='pmGallery" . ($displayCover ? 'Album' : 'Image') . "List'>\n" . $text . '</' . $wrapper[0] . '>') . '</div>'; }
function BBuildGroupList($list) { $out = ''; $group = ''; $multipleGroups = CheckForMultipleGroups($list); foreach ($list as $page) { # if group name is empty or != previous group name, capture it and start new unordered list # if only one group is present (or some param indicated to do so) menu will be flat preg_match('/\\((.*?).\\)/', $page, $matches); if ($multipleGroups == True && ($group == '' || $group != $matches[1])) { # only close if a group has been set if ($group != '') { $out .= "</ul></li>"; } $group = $matches[1]; # open a sub-menu for the new group $out .= "<li class='nav nav-list'>{$group}<b class='caret'></b>"; $out .= "<ul class='dropdown-menu'>"; } $cleanPage = preg_replace('/[()]/', '', $page); $title = FmtPageName('$Title', $cleanPage); $out .= '<li>'; $out .= MakeLink($page, $page, $title); $out .= '</li>'; } if ($multipleGroups == True) { $out .= "</ul></li>"; } return $out; }
} echo "</table>\n"; } else { AddSortedTable("mytable"); echo "<table align=center id='mytable'\n\t\t border=1 cellpadding=5 cellspacing=2>\n"; echo "<thead class='sort'>\n"; echo "<tr>\n <th>Run</th>\n <th>Instance</th>\n <th>Template</th>\n <th>ID</th>\n <th>Started</th>\n <th>Stopped</th>\n <th>Description</th>\n </tr>\n"; echo "</thead>\n"; while ($row = mysql_fetch_array($query_result)) { $pvers = $row['parent_vers']; $runidx = $row['runidx']; $runid = $row['runid']; $exptidx = $row['exptidx']; $desc = $row['description']; $started = $row['start_time']; $stopped = $row['stop_time']; $onmouseover = MakeMouseOver($desc); if (strlen($desc) > 30) { $desc = substr($desc, 0, 30) . " <b>... </b>"; } $template_link = MakeLink("template", "guid={$guid}&version={$pvers}", "{$pvers}"); $instance_link = MakeLink("instance", "instance={$exptidx}", "{$exptidx}"); $run_link = MakeLink("run", "instance={$exptidx}&runidx={$runidx}", "{$runidx}"); echo "<tr>" . "<td>{$run_link}</td>" . "<td>{$instance_link}</td>" . "<td>{$template_link}</td>" . "<td>{$runid}</td>" . "<td>{$started}</td>" . "<td>{$stopped}</td>" . "<td {$onmouseover}>{$desc}</td>"; } echo "</table>\n"; } # # Standard Testbed Footer # PAGEFOOTER();
function album($args) { $o = ParseArgs($args); global $pagename; return '<div class="album">' . (empty($o['thumb']) ? '' : '<div class="thumb">' . MakeLink($pagename, PSS($o['link']), '<img src="' . $o['thumb'] . '" />') . '</div>') . '<div class="albumdesc">' . '<h3>' . MakeLink($pagename, PSS($o['link']), $o['title']) . '</h3><p>' . html_entity_decode($o['desc']) . '</p></div>' . '</div>'; }
function thumbUrl($path, $width, $height, $resizeMode) { global $WikiGallery_UseAuthorization, $pagename; // we can use a direct url to the file if authorization is not needed if (!$WikiGallery_UseAuthorization) { if ($width == 0 && ($height = 0)) { // give direct url to the original file return 'http://' . $_SERVER['HTTP_HOST'] . "/" . preg_replace("/ /", "%20", $this->picturesWebPath . $path); } else { // give direct url to the cache file $thumbnail = $this->cacheFileName($path, $width, $height, $resizeMode); $thumbname = $this->cacheBasePath . "/" . $thumbnail; $originalname = $this->picturesBasePath . "/" . $path; if (WikiGalleryIsFileAndNonZero($thumbname) && filemtime($thumbname) >= filemtime($originalname)) { // touch it so that it is not purged during cleanup touch($this->cacheBasePath . "/" . $thumbnail); // ok, thumbnail exists, otherwise fall through return 'http://' . $_SERVER['HTTP_HOST'] . "/" . preg_replace("/ /", "%20", $this->cacheWebPath . $thumbnail); } } } $picpage = $this->group . "." . fileNameToPageName($path); $url = MakeLink($picpage, $picpage, NULL, NULL, "\$LinkUrl"); $url .= '?action=thumbnail&'; if ($width != 0) { $url .= 'width=' . urlencode($width) . '&'; } if ($height != 0) { $url .= 'height=' . urlencode($height) . '&'; } if ($resizeMode) { $url .= 'mode=' . urlencode($resizeMode) . '&'; } return $url . 'group=' . urlencode($this->group) . '&image=' . urlencode($path) . ' '; }
/** * Display all users */ function see_users() { global $Pivot_Vars, $Users; PageHeader(lang('adminbar', 'seeusers_title'), 1); PageAnkeiler(lang('userbar', 'admin') . ' » ' . lang('adminbar', 'seeusers_title')); DispPage(array(array(lang('userinfo', 'editfields'), 'userfields', lang('userinfo', 'desc_editfields')), array(lang('userinfo', 'newuser'), 'new_user', lang('userinfo', 'desc_newuser'))), "users"); StartTable(); GenSetting('', lang('userinfo', 'users'), '', 8, '', 2); // make a temp array with the userlevels. $user_lev = array(0 => lang('userlevels', 4), 1 => lang('userlevels', 3), 2 => lang('userlevels', 2), 3 => lang('userlevels', 1), 4 => lang('userlevels', 0)); //echo "</table><table border='1'>"; printf("<tr class='tabular_header'><td class='tabular'>%s: </td><td class='tabular'>%s: </td>\r\n\t\t\t<td class='tabular'>%s: </td><td class='tabular'>%s: </td><td>%s: </td><td> </td>", lang('userinfo', 'username'), lang('userinfo', 'userlevel'), lang('userinfo', 'lastlogin'), lang('userinfo', 'nickname'), lang('userinfo', 'email')); foreach ($Users as $key => $array) { echo '<tr><td class="tabular"><b>' . $key . '</b></td>'; echo '<td class="tabular">' . $user_lev[$Users[$key]['userlevel']] . ' </td>'; if ($Users[$key]['lastlogin'] == 0) { $lastlogin = "******"; } else { $lastlogin = date("Y-m-d", $Users[$key]['lastlogin']); } echo '<td class="tabular">' . $lastlogin . ' </td>'; echo '<td class="tabular">' . $Users[$key]['nick'] . ' </td>'; echo '<td class="tabular">' . $Users[$key]['email'] . ' </td><td class="tabular">'; if ($Users[$Pivot_Vars['user']]['userlevel'] > $Users[$key]['userlevel'] || $Pivot_Vars['user'] == $key) { echo MakeLink(array('func' => 'admin', 'do' => 'edituser', 'edituser' => $key)); echo lang('userinfo', 'edituser') . '</a></td>'; } else { echo lang('userinfo', 'edituser') . '</td>'; } echo '</tr>'; } echo '</table><br />'; PageFooter(); }
function Show() { $metadata_guid = $this->guid(); $metadata_vers = $this->vers(); $created = $this->created(); $metadata_name = $this->name(); $metadata_value = $this->value(); $metadata_type = $this->type(); echo "<table align=center cellpadding=2 cellspacing=2 border=1>\n"; ShowItem("GUID", "{$metadata_guid}/{$metadata_vers}"); ShowItem("Name", $metadata_name); if (ISADMIN() && isset($metadata_type)) { ShowItem("Type", $metadata_type); } ShowItem("Created", $created); if (!is_null($this->template)) { $template_guid = $template->guid(); $template_vers = $template->vers(); ShowItem("Template", MakeLink("template", "guid={$template_guid}&version={$template_vers}", "{$template_guid}/{$template_vers}")); } if ($this->parent_guid()) { $parent_guid = $this->parent_guid(); $parent_vers = $this->parent_vers(); ShowItem("Parent Version", MakeLink("metadata", "action=show&guid={$parent_guid}" . "&version={$parent_vers}", "{$parent_guid}/{$parent_vers}")); } echo "<tr>\n <td align=center colspan=2>\n Metadata Value\n </td>\n </tr>\n <tr>\n <td colspan=2 align=center class=left>\n <textarea readonly\n rows=10 cols=80>" . str_replace("\r", "", $metadata_value) . "</textarea>\n </td>\n </tr>\n"; echo "</table>\n"; }
function DispPage($toshow = '', $screenname = '') { global $Pivot_Vars, $theme_icon; if (is_array($toshow)) { echo "<table width='95%' border='0' cellpadding='5' cellspacing='0'>\n"; $cnt = count($toshow); for ($i = 0; $i < $cnt; $i++) { // Make the link.. if (isset($Pivot_Vars['func']) && $Pivot_Vars['func'] == 'admin' || isset($Pivot_Vars['menu']) && $Pivot_Vars['menu'] == 'admin') { $links = array('func' => 'admin', 'do' => $toshow[$i][1]); } else { $links = array('func' => $toshow[$i][1]); } if (isset($toshow[$i][3])) { $links = array('menu' => $toshow[$i][3]); } $link = MakeLink($links); // Print the icon.. echo "<tr><td width='48' valign='top' align='center'>\n"; print_icon($screenname, $toshow[$i][1], $link); echo "</td><td><h3>"; echo $link; echo $toshow[$i][0]; echo "</a></h3>\n<p class='dim'>"; // Edit the comments that were posted to this entry. echo $toshow[$i][2]; echo "</p></td>\n"; echo "</tr>\n\n"; } echo "</table>\n\n"; } }
} } } if (count($errors)) { SPITFORM($template, $formfields, $parameters, $errors); PAGEFOOTER(); exit(1); } # # Avoid SIGPROF in child. # set_time_limit(0); # Okay, we can spit back a header now that there is no worry of redirect. PAGEHEADER("Instantiate Experiment Template"); echo $template->PageHeader(); echo "<font size=+2>, Instance <b>" . MakeLink("project", "pid={$pid}", $pid) . "/" . MakeLink("experiment", "pid={$pid}&eid={$eid}", $eid) . "</b></font>"; echo "<br><br>\n"; echo "<script type='text/javascript' language='javascript' " . " src='template_sup.js'>\n"; echo "</script>\n"; STARTBUSY("Starting template instantiation!"); # # Run the backend script. # $retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_instantiate " . "{$command_options} -e {$eid} {$guid}/{$vers}", SUEXEC_ACTION_IGNORE); HIDEBUSY(); if ($retval) { # # Fatal Error. Report to the user, even though there is not much he can # do with the error. Also reports to tbops. # if ($retval < 0) {