View Single Post
  #7  
Old 01-31-2004, 06:35 PM
Mijae's Avatar
Mijae Mijae is offline
 
Join Date: Nov 2001
Location: Russia
Posts: 523
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mijae
I still can't get it to work because the way my script works.

What it does is call a php file with the image thumbnails and links from another folder (say /php/1.php), and then loads the content of it. Then if you click on a link (gallery.php?page=2), it will call 2.php and load the next 25 images. I know its primitive, but its been working fine for over a year now :P

Thats whats keeping me from adding the code to the templates, because I have 10 php files, for a total of 250 images.
Here is another gallery I tried to make work, but it just wont:

PHP Code:
<?
require_once('./global.php');

define('THIS_SCRIPT', 'gallery_test');
eval('print_output("' . fetch_template('gallery_main') . '");');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Invoid's Anime Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<style type="text/css">
<!--
/* Default styles incase you don't have an external css. */
body { background-color: #ffffff; color: rgb(180,180,180); font: 82% verdana, arial, sans-serif 

}
table { font-size: inherit }
p, td, div { color: rgb(180,180,180); font-family: verdana, arial, sans-serif }
h2 { font-size: 1.2em; font-weight: bold }
h2, p { text-align: center }

a:link, a:active, a:visited { color: #708090; text-decoration: none; font-size: 12px }
a:hover { text-decoration: underline }

/* the following styles must be included somewhere, since they controll all formatting */
#photo { text-align: center }
#photo table {text-align: center; margin-right: auto; margin-left: auto }
#photo table td { padding: 10px 10px 10px 10px }
#photo .fulltitle { margin-bottom: 0px; padding-bottom: 0px }
#photo .series { margin-top: 0px; padding-top: 0px }
br.hideme { visibility: hidden; volume: silent }
/* hidden from netscape 4: */
div#photo img { border: 1px solid #708090 } 
div#photo .caption { text-align: left; width: 500px; margin-right: auto; margin-left: auto }
.tborder
{
    background: #ffffff;
    color: #000000;
    border: 1px solid  #6C87B0;
}
-->
</style>
</head>
  
<body>

<!-- start of image gallery "stuff" -->
<div id="photo">
<?
//error_reporting (E_ALL);

/***********************************************************************
*  Start Configuration
***********************************************************************/

// 1 for XHTML or 0 for HTML?
$xhtml = 1;

// thumbnail directory name
$thumbs_dir = '../anime/thumbs';

// full size image directory name
$full_dir = '../anime/images_sdlncvkjhs';

// captions directory name (captions are option, ignore if you dont' have any)
$captions_dir = 'captions';

// thumbnails title (1 to show, 0 to hide)
$thumb_title = 1;

// full size images title (1 to show, 0 to hide)
$full_title = 1;

// kill beginning numbers for the title (1 to hide, 0 to show)
// hiding would make 0005_baby_pic.jpg have a title of 'Baby pic'
$kill_title_nums = 1;

// how many thumbnails should appear per row? (3 usually looks best)
$cols = 5;

// how many thumbnails per page? (a multiple of $cols, or 0 for all)
$max_thumbs = 25;

// extension name (if your server is not set for "index.$ext to be the index page, put 0)
$ext = 'php';

// captions extension
$cext = 'inc';  // use whatever you're comfortable with

// show random option for single page view (1 to show, 0 to hide)
$showrand = 1;

// closing (X)HTML options
// if you use a function to close your code, put that in, otherwise leave as is
$print_footer = 'print_footer';

/***********************************************************************
*  End Configuration
***********************************************************************/

// figure out this script's name
$self = $_SERVER['PHP_SELF'];

if (basename($self) == "index.$ext") {
    $self = str_replace(basename($self), '', $self);
}

// do you have an existing function to close your page?  if not, use this default...
if (!function_exists($print_footer)) {
    function print_gallery_footer() {
?>

</body>
</html>
<?
    }
    $print_footer = 'print_gallery_footer';
}

// our error function, cleanly exits the script on user errors
function imgerror($error) {
    global $print_footer;
    print "<p><b>$error</b></p>\n\n";
    $print_footer();
    exit();
}

// check to see which kind of closing tag we should use
$close_tag =  !empty($xhtml) ? ' />' : '>';

// check for directories
if (!is_dir($thumbs_dir)) {
  imgerror('Directory "'.$thumbs_dir.'" does not exist.');
}

if (!is_dir($full_dir)) {
  imgerror('Directory "'.$full_dir.'" does not exist.');
}

// get contents of $thumbs_dir
$dir = @opendir($thumbs_dir) or imgerror('Can\'t open ' . $thumbs_dir . ' directory');

while (($thumb = readdir($dir)) !== false) {
    if (preg_match('/((?i)jpg|jpeg|gif|tif|bmp|png)$/', $thumb))
        $thumbs[] = $thumb;
}

natcasesort($thumbs);
$thumbs_size = sizeof($thumbs);

// lowest displayed image in the array
// use http_get_vars incase register_globals is off in php.ini
$i = !empty($_GET['i']) ? $_GET['i'] : 0;

$random = array_rand($thumbs, 2);
$i = $i === 'rand' ? $thumbs[$random[rand(0, 1)]] : $i;

// check to see if all thumbs are meant to be displayed on one page
if ($max_thumbs == 0) {
    $max_thumbs = $thumbs_size;
    $mt_check = 1;
}

// thumbnail view
if (is_numeric($i)) {
    // check to see which thumbnail to start with
    $start = empty($mt_check) && $i > 0 ? $max_thumbs * ($i - 1) : 0;
    // are they looking for thumbs pages that don't exist?
    if ($start >= $thumbs_size) {
        print '<a href="' . $self . '">index</a>' . "\n\n";
        imgerror('Sorry, there are no images to display on this page');
    }
?>
<table class="tborder" cellpadding="6" cellspacing="1" border="0" align="center">

<tr>
<?
    // loop through $thumbs and display $max_thumbs per page
    for ($count = 1; $count <= $max_thumbs; $start++) {
        // break if past max_thumbs
        if ($start >= $thumbs_size) {
            break;
        }
        
        // print new row after predefined number of thumbnails
       if (($count % $cols == 1) && $count != 1 && $cols > 1) {
            print "</tr>\n\n<tr>\n";
        } elseif ($cols == 1) {
            print "</tr>\n\n<tr>\n";
        }
        
       // open cell
        print '<td bgcolor="#E9EDF3" style="width:100px">';
        
       // insert thumb
        print '<a href="' . $self . '?i=' . rawurlencode($thumbs[$start]) . '">';
        print '<img src="' . $thumbs_dir . '/' . rawurlencode($thumbs[$start]) . '" ';
        list($width, $height) = getimagesize("$thumbs_dir/$thumbs[$start]");
        print 'width="' . $width . '" height="' . $height . '"';
        
        // alt information
        print ' alt="Link to full sized version of ' . $thumbs[$start] . '"' . 

$close_tag .'</a>';
        
        // image title
       if ($thumb_title) {
            if ($kill_title_nums) {
                $title = ltrim(ltrim(str_replace('_', ' ', $thumbs[$start]), 

"0..9"));
            } else {
                $title = ltrim(str_replace('_', ' ', $thumbs[$start]));
            }
            
            $title = explode(".", ucfirst($title));
            print '<br' . $close_tag . "\n" . $title[0];
        }
        
        // close cell
        // supress line break for screen readers, but force a line break for lynx
        print '</td>' . "\n";
        $count++;
    }
?>
</tr>

</table>
<?
    // thumbs page nav
    if (!$mt_check) {
        print "\n<p>";
        // how many total thumbs pages, including a "remainder" page if needed
        $pages = ceil($thumbs_size / $max_thumbs);
        for ($count = 1; $count <= $pages; $count++) {
            if ($count == 1) {
                if ($count == $i || $i == 0) {
                    print $count;
                } else {
                    print "<a href=\"$self\">$count</a>";
                }
            } else {
                if ($count == $i) {
                    print " | $count</a>";
                } else {
                    print " | <a href=\"$self?i=$count\">$count</a>";
                }
            }
        }
        print '</p>';
    }
}

// single image view
else if (file_exists("$full_dir/$i")) {
    // find where it is in the array
    $key = array_search($i, $thumbs);
    if (is_null($key)) {
        $key = -1;
    }

    // navigation
    print '<p>';
    
    // previous
    print $key >= 1 ? '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key - 1]) . '">' : 

'';
    print '&laquo; previous';
    print $key >= 1 ? '</a>' : '';
    print ' | ';

    // index
    print '<a href="' . $self . '">index</a>';
    print ' | ';
    
    // random
    if ($showrand != 0) {
        print '<a href="' . $self . '?i=rand">random</a>';
      print ' | ';
    }
    
    // next
    print $key < $thumbs_size - 1 ? '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key 

+ 1]) . '">' : '';
    print 'next &raquo;';
    print $key < $thumbs_size - 1 ? '</a>' : '';

    print "</p>\n\n";
    // image
    print '<img src="' . $full_dir . '/' . rawurlencode($i) . '" ';
    list($width, $height) = GetImageSize("$full_dir/$i");
    print 'width="' . $width . '" height="' . $height . '"';
    
    // alt information
    print ' alt="';
  if (!$full_title) {
        print $i;
    }
    print "\"$close_tag\n\n";

    if ($full_title) {
        if ($kill_title_nums) {
            $title = $title = ltrim(ltrim(str_replace('_', ' ', $i), "0..9"));
        } else {
            $title = ltrim(str_replace('_', ' ', $i));
        }
        $title = explode('.', ucfirst($title));
        print "<div class=\"fulltitle\">$title[0]</div>\n\n";
    }

    // numerically show what image it is in the series; hide this if image isn't in the 

series
    if ($key >= 0) {
        // add 1 so that the first image is image 1 in the series, not 0
        print '<div class="series">' . ($key + 1) . ' of ' . $thumbs_size . 

"</div>\n\n";
    }

    // caption (optional)
    if (file_exists("$captions_dir/$i.$cext")) {
        print '<div class="caption">' . "\n";
        require("$captions_dir/$i.$cext");
        print "\n</div>\n";
    }
} else {  // no image found
?><p><a href="<?=$self?>">index</a></p>

<?
    imgerror('Sorry, that image does not exist...');
}
?>
</div>
<!-- end of image gallery "stuff" -->

</body>
</html>
If I add the eval at the bottom, the images will show up before the header. It wont work for any gallery I try to make >_<

How hard can adding header/footer be >_<
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01240 seconds
  • Memory Usage 1,874KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete