$UploadDir . $UploadPrefixFmt, 'thumbs_dir' => "$UploadDir" . "$UploadPrefixFmt" . "thumbs/", 'images_url' => $UploadUrlFmt . $UploadPrefixFmt, 'thumbs_url' => $UploadUrlFmt . $UploadPrefixFmt . "thumbs/", 'group' => $Group, 'title' => $Title, 'image_types' => "jpg, JPG", 't_width' => "100", 't_height' => "75"); $xGalleryVars['output_template'] = "[[notitle]]!{{[[\$Group]]}} / {{" . $Title . "}} ||table width=100% || \$image_url || || [+[[\$Titlespaced]]+] ||"; // . "[[x-comment:]]"; // requires x-comment.php $xGalleryVars['upload_button_template'] = " " . "U
p
l
o
a
d
"; $xGalleryVars['row_start_template'] = "
\n
"; $xGalleryVars['row_end_template'] = "\n
\n
\n"; SDVA($xGalleryParams, array( 'titleprefix' => 'Image-', 'show_upload_button' => 'yes', // yes/no 'show_empty_gallery' => 'yes', // yes/no 'border' => '0', 'wrap' => '5')); // 'show' => '', // not used // 'id' => '1', // not used return; } function xGallery($input) { $params = explode(" ", $input); foreach($params as $param){ list($key,$value) = explode("=", $param); $xGalleryParams["$key"] = $value;} xGallery_Init($xGalleryVars, $xGalleryParams); $html = "\n\n\n"; $html .= xGallery_UpdateThumbnails($xGalleryVars, $xGalleryParams); // update thumbs (and create pages) if needed $html .= xGallery_ShowThumbnails($xGalleryVars, $xGalleryParams); // display thumbs $html .= "\n\n\n"; return $html; } function xGallery_UpdateThumbnails(& $xGalleryVars, &$xGalleryParams) { $html = ''; $images_dir = $xGalleryVars['images_dir']; $thumbs_dir = $xGalleryVars['thumbs_dir']; $existing_images = xGallery_Directory($images_dir, $xGalleryVars['image_types']); if (sizeof($existing_images) == 0) { global $pagename; $PageUrl = FmtPageName('$PageUrl', $pagename); $html_now = ''; // will check this later for changes and report them (if any) if ($xGalleryParams['show_empty_gallery']=='yes') { $UploadPrefixFmt = FmtPageName('$UploadPrefixFmt', $xGalleryVars['group'] . "." . $xGalleryVars['title']); $html .= $xGalleryVars['row_start_template']; if ($xGalleryParams['show_upload_button'] == 'yes') {$html .= $xGalleryVars['upload_button_template'];} $html .= Keep("" . "X Gallery
$UploadPrefixFmt is empty."); if ($xGalleryParams['show_upload_button'] == 'yes') {$html .= $xGalleryVars['upload_button_template'];} $html .= "" . $xGalleryVars['row_end_template']; } } else // if needed, create new thumbnails and/or WikiPages { // make the thumbs_dir if needed if (!file_exists($thumbs_dir)) { $html_now = "
Creating Directory ($thumbs_dir)"; echo ($html_now); } // if the thumbs dir exists check it against the images if (file_exists($thumbs_dir)) { $Gallery = $xGalleryVars['group']; $Album = $xGalleryVars['title']; foreach ($existing_images as $image_name) { // create the thumbnail if needed if (!file_exists("$thumbs_dir/$image_name")) { $html_now = "
Creating Thumbnail ($thumbs_dir$image_name)Creating WikiPage ($Gallery/$Title)"; echo ($html_now); } } } } if ($html_now != '') { echo ("

"); //$html .= "[[{{" . "$Gallery" . ".$Album}} Reload page to clear message(s)]]\n\n"; } return $html; } function xGallery_CreateThumbsDirectory($dir) { if (mkdir("$dir")) {return "";} return "χ"; } function xGallery_CreateThumbnail ($source_name, $destination_name, $max_x, $max_y) { if ($pic = imagecreatefromjpeg($source_name)) { $source_width = imagesx($pic); $source_height = imagesy($pic); $t_height = $max_y; $t_width = $t_height * $source_width / $source_height; $thumb = imagecreatetruecolor ($t_width, $t_height); imagecopyresized($thumb, $pic, 0, 0, 0, 0, $t_width, $t_height, $source_width, $source_height); if (ImageJPEG($thumb,$destination_name,75)) {$html = "";} else {$html = "χ";} imagedestroy($thumb); imagedestroy($pic); } return $html; } function xGallery_CreateImagePage($pagename) { global $WikiDir,$DeleteKeyWord,$RecentChanges,$RCDelimPattern,$Now, $TimeFmt,$CurrentTime,$PageFileFmt,$DiffKeepDays,$Author,$PostFields, $DiffFunction; $CurrentTime = strftime($TimeFmt,$Now); foreach($PostFields as $k) {if (isset($_POST[$k])) {$new[$k]=str_replace("\r","",stripmagic($_POST[$k])); }} Lock(2); $page = RetrieveAuthPage($pagename,"edit"); if (!$page) { return " χ"; } $pagename = FmtPageName('$PageName',$pagename); $diffclass=preg_replace('/\\W/','',@$_POST['diffclass']); if ($page["time"]>0) $new["diff:$Now:".$page['time'].":$diffclass"] = $DiffFunction($new['text'],$page['text']); $new['author'] = $Author; $new["author:$Now"] = $Author; $new["host:$Now"] = $_SERVER['REMOTE_ADDR']; foreach($new as $k=>$v) { if ($k=='pagename' || $k=='action') continue; $page[$k] = $v; } $keepgmt = $Now-$DiffKeepDays*86400; $keys = array_keys($page); foreach ($keys as $k) if (preg_match("/^\\w+:(\\d+)/",$k,$match)) if ($match[1] < $keepgmt) unset($page[$k]); $pagefile = FmtPageName($PageFileFmt,$pagename); if ($page['text']==$DeleteKeyWord) { @rename("$WikiDir/$pagefile","$WikiDir/$pagefile,$Now"); } else WritePage($pagename,$page); foreach($RecentChanges as $rcfmt => $pgfmt) { $rcname=FmtPageName($rcfmt,$pagename); if (!$rcname) continue; $pgtext=FmtPageName($pgfmt,$pagename); if (!$pgtext) continue; if (@$seen[$rcname]++) continue; $rcpage = ReadPage($rcname,""); $rcelim = preg_quote(preg_replace("/$RCDelimPattern.*$/",' ',$pgtext),'/'); $rcpage['text'] = preg_replace("/[^\n]*$rcelim.*\n/","",$rcpage['text']); if (!preg_match("/$RCDelimPattern/",$rcpage['text'])) $rcpage['text'] .= "$pgtext\n"; else $rcpage['text'] = preg_replace("/([^\n]*$RCDelimPattern.*\n)/", "$pgtext\n$1",$rcpage['text'],1); $html = WriteGalleryPage($rcname,$rcpage); return $html; } } function WriteGalleryPage($pagename,$page) { // cut-and-paste fro mpmwiki and renamed. only change is, fucntion returns success/failure global $Now,$HTTP_SERVER_VARS,$WikiDir,$PageFileFmt,$Version,$Newline; Lock(2); foreach (array('timefmt','pagename','action','version','newline') as $k) unset($page[$k]); $page['name'] = $pagename; $page['time'] = $Now; $page['host'] = $HTTP_SERVER_VARS['REMOTE_ADDR']; $page['agent'] = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; $page['rev'] = @$page['rev']+1; $pagefile = FmtPageName("$WikiDir/$PageFileFmt",$pagename); $pagedir = preg_replace('#/[^/]*$#','',$pagefile); if ($pagedir) mkgiddir($pagedir); $s = false; if ($pagefile && ($fp=fopen("$pagefile.new","w"))) { $s = true && fputs($fp,"version=$Version\nnewline=$Newline\n"); foreach($page as $k=>$v) if ($k>"") $s = $s && fputs($fp,str_replace("\n",$Newline,"$k=$v")."\n"); $s = fclose($fp) && $s; if (file_exists($pagefile)) $s = $s && unlink($pagefile); $s = $s && rename("$pagefile.new",$pagefile); } if (!$s) // failure {$html = " χ";} else // success {$html = "";} return $html; } function xGallery_Directory($dir,$filters) { if (!file_exists($dir)) {return NULL;} $handle=opendir($dir); $files=array(); if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != "all"){ $filters=explode(",",$filters); while (($file = readdir($handle))!==false) { for ($f=0;$f 0) {$html .= $xGalleryVars['row_start_template'];} while ($count < $num_images) { $html .= "" . "\n " . "\n {$thumbs[$count]}"; //
a little bit of text if ( ($count+1 == $num_images) && ($xGalleryParams['show_upload_button']) ) {$html .= $xGalleryVars['upload_button_template'];} if (($count+1) % $wrap == 0) {$html .= $xGalleryVars['row_end_template'];} if ( (($count+1)%$wrap == 0) && ($count+1 < $num_images)) {$html .= $xGalleryVars['row_start_template'];} $count++; } if (($num_images > 0 ) && ($count+1 % $num_images != 0)) {$html .= $xGalleryVars['row_end_template'];} return Keep($html); } $DoubleBrackets["/\\[\\[x-gallery:(.*?)\\]\\]/e"] = 'xGallery("$1");'; ?>