To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Code Critique

Code Critique Having someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-21-2003, 11:53 AM   #1
intenz
Xtreme Member
 
intenz's Avatar
 
Join Date: Aug 2001
Location: Reykjavik, Iceland
Posts: 506
ImageGallery

An image gallery I made a long time ago.
What do you think?

PHP Code:
<?
$curfile
= basename( $_SERVER['PHP_SELF'] );
?>
<html>
<style>
<!--
body {
    font-family: Verdana;
    font-size: 11px;
    color: #000000;
}
table {
    font-family: Verdana;
    font-size: 12px;
    color: #000000;
}
a {
    text-decoration: none;
    color: darkred;
}
-->
</style>
<?
if( !$popup )
{
?>
<script language=JavaScript>
<!--
function mynd(album,mynd)
{
    window.open('<?=$curfile?>?sAlbum='+album+'&sPic='+mynd,'myndasafn','status=0,menu=0,toolbar=0,scrollbarsl=no,width=10,height=20');
    return false;
}
-->
</script>
<?
}
# Please change this to fit your needs...

# Album Mode; 1 = yes. 0 = no.
# 0 = You put pictures in the picture folder.
# 1 = You put the albums in the picture folder (album = folders with pictures in it)
$album = 0;

# Picture pops up; 1 = yes. 0 = no.
$popup = 1;

# Folder with all pictures/albums.
$mappa = 'pics';

# Pictures per row.
$cols = 3;

# How many rows until new page.
$rows = 3;

# Do not change anything below here.

if( $_GET['sAlbum'] )
    
$heild = $mappa . '/' . $_GET['sAlbum'];
else
    
$heild = $mappa;

if(
$_GET['sPic'] )
{
    if(
$popup )
    {
?>
<script>
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(500, 500);
width = 500 - (document.body.clientWidth -  document.images[0].width);
height = 500 - (document.body.clientHeight -  document.images[0].height);
window.resizeTo(width, height);
   }
   }
</script>
<body onload="fitWindowSize()" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<?
    
}
    else
        echo
'<div align="center"><a href="' . $curfile . '?sAlbum=' . $_GET['sAlbum'] . '&sPage=' . $_GET['sPage'] . '">Aftur í albúm</a></div><br><br>';
       
?>
<div align="center"><img src="<? if( $popup ) echo $_GET['sAlbum'] . '/' . $_GET['sPic']; else echo $heild . '/' . $_GET['sPic']; ?>" border="0" style="border: 1px solid #000000" <? if( $popup ) { ?>onClick="window.close();window.opener.focus()" style="cursor: hand" title="Loka glugga"<? } ?>></div>
<?
}
elseif( !
$_GET['sAlbum'] && $album )
{
?>
    <b>Veldu albúm:</b><br><br>
<?
    $handle
= opendir( $mappa );
    while(
false !== ( $skra = readdir( $handle ) ) )
    {
        if(
$skra != '.' && $skra != '..' && is_dir( $mappa . '/' . $skra ) )
        {
?>
            <a href="<?=$curfile?>?sAlbum=<?=$skra?>"><?=str_replace( '_', ' ', $skra )?></a><br>
<?
        
}
    }
}
else
{
    
$perpage = $cols * $rows;
       
    if( !
$_GET['sPage'] )
        
$sPage = 1;
    else
        
$sPage = $_GET['sPage'];
           
    
$begin = ( $sPage * $perpage ) - $perpage;
    
$end = ( $sPage * $perpage ) - 1;
       
    
$handle = opendir( $heild );
    while(
false !== ( $pic = readdir( $handle ) ) )
    {
        if(
$pic != '.' && $pic != '..' && !is_dir( $heild . '/' . $pic ) )
            
$arrPics[] = $pic;
    }
       
    
$num = count( $arrPics );

    
$pages = ceil( $num / $perpage );
    if(
$pages != 1 )
    {
?>
        <div align="center"><font size="3">
<?
        
for( $i = 1; $i <= $pages; $i++ )
        {
           
            if(
$sPage == $i )
                echo
$i;
            else
            {
?>
                <a href="<?=$curfile?>?sAlbum=<?=$_GET['sAlbum']?>&sPage=<?=$i?>" style="text-decoration: none"><u><?=$i?></u></a>
<?
            
}
               
            if(
$i != $pages )
                echo
' ';
        }
?>
        </font></div>
<?
    
}
?>
    <table border="0" cellspacing="3" align="center">
    <tr>
    <td colspan="<?=$cols?>">&nbsp;</td>
    </tr>
    <tr>
<?
    $i
= 0;
    for(
$j = $begin; $j <= $end; $j++ )
    {
?>
        <td align="center" valign="top">
<?
        
if( $arrPics[$j] )
        {
?>
            <a href="<? if( !$popup ) echo $curfile . '?sAlbum=' . $_GET['sAlbum'] . '&sPage=' . $sPage . '&sPic=' . $arrPics[$j]; else echo '#' ?>"<? if( $popup ) { ?> onClick="return mynd('<?=$heild?>','<?=$arrPics[$j]?>')"<? } ?>><img src="<?=$heild?>/<?=$arrPics[$j]?>" height="100" border="0" style="border: 1px solid #000000"></a><br><?=$arrPics[$j]?>
<?
        
}
?>
        </td>
<?
               
        $i
++;
           
        if(
$i == $cols )
        {
?>
            </tr><tr>
<?
            $i
= 0;
        }
    }
?>
    </tr>
    </table>
<?
}

if( !
$_GET['sPic'] )
{
?>
<br><br>
<div align="center"><i>Copyright © 2004 <a href="http://www.gaui.is">gaui</a></i></div>
<?
}
?>
</body>
</html>
__________________
Curiosity killed the cat.

Last edited by intenz; 01-14-2004 at 10:33 PM.
intenz is offline   Reply With Quote
Old 01-06-2004, 11:16 AM   #2
Grisu
Member
 
Grisu's Avatar
 
Join Date: Dec 2003
Location: Germany
Posts: 54
I tried the script, adjusted the directory but it does not show the pics. Would be helpful, if your comments were in English. How should somebody give a comment otherwise.

Grisu
Grisu is offline   Reply With Quote
Old 01-14-2004, 10:32 PM   #3
intenz
Xtreme Member
 
intenz's Avatar
 
Join Date: Aug 2001
Location: Reykjavik, Iceland
Posts: 506
It works here and with all my friends.
Btw. I fixed the comments.
__________________
Curiosity killed the cat.
intenz is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 07:56 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.