function LinkHTTP($pagename, $imap, $path, $alt, $txt, $fmt = NULL) { global $EnableUrlApprovalRequired, $IMap, $WhiteUrlPatterns, $FmtV, $UnapprovedLink, $UnapprovedLinkCount, $UnapprovedLinkFmt; if (!IsEnabled($EnableUrlApprovalRequired, 1)) { return LinkIMap($pagename, $imap, $path, $alt, $txt, $fmt); } static $havereadpages; if (!$havereadpages) { ReadApprovedUrls($pagename); $havereadpages = true; } $p = str_replace(' ', '%20', $path); $url = str_replace('$1', $p, $IMap[$imap]); if (!isset($UnapprovedLink)) { $UnapprovedLink = array(); } foreach ((array) $WhiteUrlPatterns as $pat) { if (preg_match("!^{$pat}(/|\$)!i", $url)) { return LinkIMap($pagename, $imap, $path, $alt, $txt, $fmt); } } $FmtV['$LinkUrl'] = PUE(str_replace('$1', $path, $IMap[$imap])); $FmtV['$LinkText'] = $txt; $FmtV['$LinkAlt'] = str_replace(array('"', "'"), array('"', '''), $alt); $UnapprovedLink[] = $url; @$UnapprovedLinkCount++; return FmtPageName($UnapprovedLinkFmt, $pagename); }
function DeObfuscateLinkIMap($pagename, $imap, $path, $title, $txt, $fmt = NULL) { global $FmtV, $IMap, $IMapLinkFmt, $DeObMail; $FmtV['$LinkUrl'] = obfuscate_email(PUE(str_replace('$1', $path, $IMap[$imap]))); $FmtV['$LinkText'] = obfuscate_email(preg_replace('/^mailto:/i', '', $txt)); if ($FmtV['$LinkText'] == preg_replace('/^mailto:/i', '', $FmtV['$LinkUrl'])) { $FmtV['$LinkUrl'] = ''; } else { $FmtV['$LinkUrl'] = " -> " . $FmtV['$LinkUrl']; } $FmtV['$LinkAlt'] = str_replace(array('"', "'"), array('"', '''), obfuscate_email($title, 0)); return str_replace(array_keys($FmtV), array_values($FmtV), $IMapLinkFmt['mailto:']); }
function FmtUploadList2($pagename, $args) { global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $FileListTimeFmt, $EnableDirectDownload, $HTMLStylesFmt, $FarmPubDirUrl; $HTMLStylesFmt['filelist'] = "\r\n table.filelist { padding:0; margin:0; border-spacing:0; }\r\n table.filelist td { padding:3px 0 0 0; margin:0; }\r\n .filelist a { text-decoration:underline; }\r\n .dotted { background:url({$FarmPubDirUrl}/images/dot3.png) repeat-x bottom; }\r\n .nodots { background:#feffff; }\r\n "; $opt = ParseArgs($args); if (@$opt[''][0]) { $pagename = MakePageName($pagename, $opt[''][0]); } if (@$opt['re']) { $matchre = '/^(' . $opt['re'] . ')$/i'; } if (@$opt['ext']) { $matchext = '/\\.(' . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY)) . ')$/i'; } $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename); $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "{$UploadUrlFmt}{$UploadPrefixFmt}/" : "\$PageUrl?action=download&upname=", $pagename); $dirp = @opendir($uploaddir); if (!$dirp) { return ''; } $filelist = array(); while (($file = readdir($dirp)) !== false) { if ($file[0] == '.') { continue; } if (@$matchext && !preg_match(@$matchext, $file)) { continue; } if (@$matchre && !preg_match(@$matchre, $file)) { continue; } $filelist[$file] = $file; } closedir($dirp); $out = array(); #asort($filelist); $overwrite = ''; foreach ($filelist as $file => $x) { $name = PUE("{$uploadurl}{$file}"); $stat = stat("{$uploaddir}/{$file}"); if ($EnableUploadOverwrite) { $overwrite = FmtPageName("<a class='createlink'\r\n href='\$PageUrl?action=upload&upname={$file}'> Δ</a>", $pagename); } $out[] = "<tr><td class='dotted'> <a href='{$name}'>{$file}</a>{$overwrite} </td>" . "<td class='dotted' align=right><span class='nodots'>" . number_format($stat['size'] / 1024) . "Kb</span></td>" . "<td> " . strftime($FileListTimeFmt, $stat['mtime']) . "</td>" . "<tr>"; } return implode("\n", $out); }
function FmtUploadList($pagename, $args) { global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $TimeFmt, $EnableDirectDownload; $opt = ParseArgs($args); if (@$opt[''][0]) $pagename = MakePageName($pagename, $opt[''][0]); if (@$opt['ext']) $matchext = '/\\.(' . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY)) . ')$/i'; $uploaddir = FmtPageName("$UploadDir$UploadPrefixFmt", $pagename); $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "$UploadUrlFmt$UploadPrefixFmt/" : "\$PageUrl?action=download&upname=", $pagename); $dirp = @opendir($uploaddir); if (!$dirp) return ''; $filelist = array(); while (($file=readdir($dirp)) !== false) { if ($file{0} == '.') continue; if (@$matchext && !preg_match(@$matchext, $file)) continue; $filelist[$file] = $file; } closedir($dirp); $out = array(); natcasesort($filelist); $overwrite = ''; foreach($filelist as $file=>$x) { $name = PUE("$uploadurl$file"); $stat = stat("$uploaddir/$file"); if ($EnableUploadOverwrite) $overwrite = FmtPageName("<a rel='nofollow' class='createlink' href='\$PageUrl?action=upload&upname=$file'> Δ</a>", $pagename); $out[] = "<li> <a href='$name'>$file</a>$overwrite ... ". number_format($stat['size']) . " bytes ... " . strftime($TimeFmt, $stat['mtime']) . "</li>"; } return implode("\n",$out); }
function LinkPage($pagename,$imap,$path,$title,$txt,$fmt=NULL) { global $QueryFragPattern,$LinkPageExistsFmt,$LinkPageSelfFmt, $LinkPageCreateSpaceFmt,$LinkPageCreateFmt,$FmtV,$LinkTargets; if (!$fmt && $path{0} == '#') { $path = preg_replace("/[^-.:\\w]/", '', $path); return ($path) ? "<a href='#$path'>$txt</a>" : ''; } if (!preg_match("/^\\s*([^#?]+)($QueryFragPattern)?$/",$path,$match)) return ''; $tgtname = MakePageName($pagename, $match[1]); if (!$tgtname) return ''; $qf = @$match[2]; @$LinkTargets[$tgtname]++; if (!$fmt) { if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf)) $fmt = preg_match('/\\s/', $txt) ? $LinkPageCreateSpaceFmt : $LinkPageCreateFmt; else $fmt = ($tgtname == $pagename && $qf == '') ? $LinkPageSelfFmt : $LinkPageExistsFmt; } $fmt = str_replace(array('$LinkUrl', '$LinkText'), array(PageVar($tgtname, '$PageUrl').PUE($qf), $txt), $fmt); return FmtPageName($fmt,$tgtname); }
function LinkPage($pagename,$imap,$path,$alt,$txt,$fmt=NULL) { global $QueryFragPattern, $LinkPageExistsFmt, $LinkPageSelfFmt, $LinkPageCreateSpaceFmt, $LinkPageCreateFmt, $LinkTargets, $EnableLinkPageRelative; $alt = str_replace(array('"',"'"),array('"','''),$alt); if (!$fmt && $path{0} == '#') { $path = preg_replace("/[^-.:\\w]/", '', $path); if (trim($txt) == '+') $txt = PageVar($pagename, '$Title'); if($alt) $alt = " title='$alt'"; return ($path) ? "<a href='#$path'$alt>".str_replace("$", "$", $txt)."</a>" : ''; } if (!preg_match("/^\\s*([^#?]+)($QueryFragPattern)?$/",$path,$match)) return ''; $tgtname = MakePageName($pagename, $match[1]); if (!$tgtname) return ''; $qf = @$match[2]; @$LinkTargets[$tgtname]++; if (!$fmt) { if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf)) $fmt = preg_match('/\\s/', $txt) ? $LinkPageCreateSpaceFmt : $LinkPageCreateFmt; else $fmt = ($tgtname == $pagename && $qf == '') ? $LinkPageSelfFmt : $LinkPageExistsFmt; } $url = PageVar($tgtname, '$PageUrl'); if (trim($txt) == '+') $txt = PageVar($tgtname, '$Title'); $txt = str_replace("$", "$", $txt); if (@$EnableLinkPageRelative) $url = preg_replace('!^[a-z]+://[^/]*!i', '', $url); $fmt = str_replace(array('$LinkUrl', '$LinkText', '$LinkAlt'), array($url.PUE($qf), $txt, $alt), $fmt); return FmtPageName($fmt,$tgtname); }
function LinkPage($pagename, $imap, $path, $title, $txt, $fmt = NULL) { global $QueryFragPattern, $LinkPageExistsFmt, $LinkPageSelfFmt, $LinkPageCreateSpaceFmt, $LinkPageCreateFmt, $FmtV, $LinkTargets; if (!$fmt && $path[0] == '#') { $path = preg_replace("/[^-.:\\w]/", '', $path); return "<a href='#{$path}'>{$txt}</a>"; } if (!preg_match("/^([^#?]+)({$QueryFragPattern})?\$/", $path, $match)) { return ''; } $tgtname = MakePageName($pagename, $match[1]); $qf = @$match[2]; @$LinkTargets[$tgtname]++; if (!$fmt) { if (PageExists($tgtname)) { $fmt = $tgtname == $pagename && $qf == '' ? $LinkPageSelfFmt : $LinkPageExistsFmt; } elseif (preg_match('/\\s/', $txt)) { $fmt = $LinkPageCreateSpaceFmt; } else { $fmt = $LinkPageCreateFmt; } } $fmt = str_replace(array('$LinkUrl', '$LinkText'), array(PageVar($tgtname, '$PageUrl') . PUE($qf), $txt), $fmt); return FmtPageName($fmt, $tgtname); }
function LinkPage($pagename, $imap, $path, $title, $txt, $fmt = NULL) { global $QueryFragPattern, $LinkPageExistsFmt, $LinkPageSelfFmt, $LinkPageCreateSpaceFmt, $LinkPageCreateFmt, $FmtV, $LinkTargets; if (substr($path, 0, 1) == '#' && !$fmt) { $path = preg_replace("/[^-.:\\w]/", '', $path); return "<a href='#{$path}'>{$txt}</a>"; } if (!preg_match("/^([^#?]+)({$QueryFragPattern})?\$/", $path, $match)) { return ''; } $tgtname = MakePageName($pagename, $match[1]); $qf = @$match[2]; @$LinkTargets[$tgtname]++; if (!$fmt) { if (PageExists($tgtname)) { $fmt = $tgtname == $pagename && $qf == '' ? $LinkPageSelfFmt : $LinkPageExistsFmt; } elseif (preg_match('/\\s/', $txt)) { $fmt = $LinkPageCreateSpaceFmt; } else { $fmt = $LinkPageCreateFmt; } } $FmtV['$LinkUrl'] = Keep(PUE(FmtPageName("\$PageUrl{$qf}", $tgtname))); $FmtV['$LinkText'] = $txt; return FmtPageName($fmt, $tgtname); }
function FmtUploadList($pagename, $args) { global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $TimeFmt, $EnableDirectDownload; $opt = ParseArgs($args); if (@$opt[''][0]) { $pagename = MakePageName($pagename, $opt[''][0]); } if (@$opt['ext']) { $matchext = '/\\.(' . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY)) . ')$/i'; } $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename); $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "{$UploadUrlFmt}{$UploadPrefixFmt}/" : "\$PageUrl?action=download&upname=", $pagename); $dirp = @opendir($uploaddir); if (!$dirp) { return ''; } $filelist = array(); while (($file = readdir($dirp)) !== false) { if ($file[0] == '.') { continue; } if (@$matchext && !preg_match(@$matchext, $file)) { continue; } $filelist[$file] = $file; } closedir($dirp); $out = array(); asort($filelist); $overwrite = ''; foreach ($filelist as $file => $x) { $name = PUE("{$uploadurl}{$file}"); $stat = stat("{$uploaddir}/{$file}"); if ($EnableUploadOverwrite) { $overwrite = FmtPageName("<a class='createlink'\n href='\$PageUrl?action=upload&upname={$file}'> Δ</a>", $pagename); } $out[] = "<li> <a href='{$name}'>{$file}</a>{$overwrite} ... " . number_format($stat['size']) . " bytes ... " . strftime($TimeFmt, $stat['mtime']) . "</li>"; } return implode("\n", $out); }
function LinkPage($pagename, $imap, $path, $title, $txt, $fmt = NULL) { global $QueryFragPattern, $LinkPageExistsFmt, $LinkPageSelfFmt, $LinkPageCreateSpaceFmt, $LinkPageCreateFmt, $LinkTargets, $EnableLinkPageRelative; if (!$fmt && $path[0] == '#') { $path = preg_replace("/[^-.:\\w]/", '', $path); return $path ? "<a href='#{$path}'>{$txt}</a>" : ''; } if (!preg_match("/^\\s*([^#?]+)({$QueryFragPattern})?\$/", $path, $match)) { return ''; } $tgtname = MakePageName($pagename, $match[1]); if (!$tgtname) { return ''; } $qf = @$match[2]; @$LinkTargets[$tgtname]++; if (!$fmt) { if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf)) { $fmt = preg_match('/\\s/', $txt) ? $LinkPageCreateSpaceFmt : $LinkPageCreateFmt; } else { $fmt = $tgtname == $pagename && $qf == '' ? $LinkPageSelfFmt : $LinkPageExistsFmt; } } $url = PageVar($tgtname, '$PageUrl'); if (@$EnableLinkPageRelative) { $url = preg_replace('!^[a-z]+://[^/]*!i', '', $url); } $fmt = str_replace(array('$LinkUrl', '$LinkText'), array($url . PUE($qf), $txt), $fmt); return FmtPageName($fmt, $tgtname); }
function FmtUploadList($pagename, $opt) { global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $TimeFmt; $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename); $uploadurl = FmtPageName("{$UploadUrlFmt}{$UploadPrefixFmt}", $pagename); $dirp = @opendir($uploaddir); if (!$dirp) { return ''; } $filelist = array(); while (($file = readdir($dirp)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $filelist[$file] = $file; } closedir($dirp); $out = array(); asort($filelist); $overwrite = ''; foreach ($filelist as $file => $x) { $name = PUE("{$uploadurl}/{$file}"); $stat = stat("{$uploaddir}/{$file}"); if ($EnableUploadOverwrite) { $overwrite = FmtPageName("<a class='createlink'\n href='\$PageUrl?action=upload&upname={$file}'> Δ</a>", $pagename); } $out[] = "<li> <a href='{$name}'>{$file}</a>{$overwrite} ... \n {$stat['size']} bytes ... " . strftime($TimeFmt, $stat['mtime']) . "</li>"; } return implode("\n", $out); }
function ThumbrunListItem($pagename, $file, $uploadurl, $uploaddir, $px) { global $TimeFmt, $Thumbrun; $pinfo = pathinfo($file); $bn = basename($file, '.' . $pinfo['extension']); $thumbfile = $Thumbrun['ThumbPrefix'] . ${bn} . ".png"; $thumblink = ''; if ($Thumbrun['ThumbDir']) { $thumbdir = $Thumbrun['ThumbDir']; $fulldir = "{$uploaddir}/{$thumbdir}"; if (!is_dir($fulldir)) { mkdir($fulldir); } $thumblink = PUE("{$uploadurl}/{$thumbdir}/{$thumbfile}"); } else { $thumblink = PUE("{$uploadurl}{$thumbfile}"); } $link = PUE("{$uploadurl}/{$file}"); $stat = stat("{$uploaddir}/{$file}"); $imginfo = "<span><a href='{$link}'>{$file}</a></span> " . "<span>" . number_format($stat['size']) . " bytes</span> "; $ident = shell_exec("identify {$uploaddir}/{$file}"); if (preg_match("/(\\d+x\\d+)/", $ident, $m)) { $imginfo .= "<span>{$m['1']}</span> "; } $imginfo .= "<span>" . strftime($TimeFmt, $stat['mtime']) . "</span>"; ThumbrunMakeThumb($uploaddir, $file, $thumbfile, $px, $px); $linkfmt = "<li><span class='item'><a href='%s'><img src='%s' alt='%s' title='%s'/></a> <span class='imginfo'>%s</span><span class='imgupdate'>%s</span></span></li>"; $update = ThumbrunListItemUpdate($pagename, $file); $out = sprintf($linkfmt, $link, $thumblink, $file, $file, $imginfo, $update); return $out; }
function FmtUploadList($pagename, $opt) { global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $TimeFmt; $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename); $uploadurl = FmtPageName("{$UploadUrlFmt}{$UploadPrefixFmt}", $pagename); $dirp = @opendir($uploaddir); if (!$dirp) { return ''; } $filelist = array(); while (($file = readdir($dirp)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $filelist[$file] = $file; } closedir($dirp); $out = array(); asort($filelist); foreach ($filelist as $file => $x) { $name = PUE("{$uploadurl}/{$file}"); $stat = stat("{$uploaddir}/{$file}"); $out[] = "<li> <a href='{$name}'>{$file}</a> ... \n {$stat['size']} bytes ... " . strftime($TimeFmt, $stat['mtime']) . "</li>"; } return implode("\n", $out); }
function include_file($pagename, $argstr) { global $UploadFileFmt, $UploadUrlFmt, $UploadPrefixFmt; global $IncludeUploadTextToHtmlCmd; global $IncludeUploadToHtmlCmd; global $UrlScheme, $IncludeUploadUrlFopenEnabled; global $HandleAuth, $AuthFunction; $args = ParseArgs($argstr); $path = $args[''] ? implode('', $args['']) : ''; $class = $args['class'] ? $args['class'] : $this->class; $abs_url = ''; # figure out the file path if (preg_match("/^\\s*\\//", $path)) { # a path was given, give it a http: path # so that this will honour Apache permissions # However, this will only work if allow_url_fopen is enabled. if ($IncludeUploadUrlFopenEnabled) { $http = $UrlScheme ? $UrlScheme : 'http'; $filepath = $http . '://' . $_SERVER['HTTP_HOST'] . $path; } else { $filepath = $_SERVER['DOCUMENT_ROOT'] . $path; } // make the abs_url from the part of the URL minus the file $bits = explode("/", $filepath); array_pop($bits); $abs_url = implode('/', $bits); $abs_url .= '/'; } else { if (preg_match('!^(.*)/([^/]+)$!', $path, $match)) { $pagename = MakePageName($pagename, $match[1]); $path = $match[2]; } // permission check for accessing files from given page if (!$AuthFunction($pagename, $HandleAuth['includeupload'], false)) { return Keep("(:includeupload {$path}:) failed: access denied to include files from {$pagename}<br>\n"); } $upname = MakeUploadName($pagename, $path); $filepath = FmtPageName("{$UploadFileFmt}/{$upname}", $pagename); $abs_url = PUE(FmtPageName("{$UploadUrlFmt}{$UploadPrefixFmt}", $pagename)); } // read the file; if there was failure, the content is empty $filetext = $this->read_file($filepath); if ($filetext) { $ext = ''; if (preg_match('!\\.(\\w+)$!', $filepath, $match)) { $ext = $match[1]; } $filetype = $args['type'] ? $args['type'] : $ext; if ($IncludeUploadToHtmlCmd[$filetype]) { $command = $IncludeUploadToHtmlCmd[$filetype]; $tempfile = $this->put_file($filetext); $fcont = `{$command} {$tempfile}`; $fcont = $this->extract_body($fcont); $fcont = $this->absolute_url($fcont, $abs_url); @unlink($tempfile); return Keep(($class ? "<div class='{$class}'>" : '<div>') . $fcont . '</div>'); } else { if (preg_match('/htm.?/', $ext)) { $fcont = $this->extract_body($filetext); $fcont = $this->absolute_url($fcont, $abs_url); return Keep(($class ? "<div class='{$class}'>" : '<div>') . $fcont . '</div>'); } else { // by default, treat as text and escape HTML chars return Keep(($class ? "<pre class='{$class}'>" : '<pre>') . "filetype={$filetype}\n" . htmlspecialchars($filetext) . '</pre>'); } } } # fall through return Keep("(:includeupload {$path}:) failed: Could not open {$filepath}<br>\n"); }
function getUploadURL ($pagename, $path) { global $UploadFileFmt, $UploadPrefixFmt, $UploadUrlFmt, $EnableDirectDownload; if (preg_match('!^(.*)/([^/]+)$!', $path, $m)) { $pagename = MakePageName($pagename, $m[1]); $path = $m[2]; } $upname = MakeUploadName($pagename, $path); $filepath = FmtPageName("$UploadFileFmt/$upname", $pagename); $url = PUE(FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "$UploadUrlFmt$UploadPrefixFmt/$upname" : "{\$PageUrl}?action=download&upname=$upname", $pagename)); return $url; }