Location: PHPKode > projects > PHPEcho CMS > modules/gallery/index.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Tigran Abrahamyan
*   |     License:       GPL
*   |     Last updated:  15.02.07
*   |     For version:   1.6  
*   |     Desc:          Photo Gallery module
*   |        
*   +--------------------------------------------
*/ 

if( !@$BASE_LOAD )
{
    die('Application error.');
}

switch (@$_GET['op'])
{
    case "viewimg":
        view_image ();
        break;
    default:
        view_cat ();
}

function view_cat ()
{
    global $core;
    
    $mlang = $core->getlang("gallery");
    
    $content = "";
    
    if ( @$_GET['catid'] )
    {
        $cat = query ( "SELECT * FROM ".PREFIX."gallery WHERE cat = '".addslashes ($_GET['catid'])."'", 1);
        $catname = query ( "SELECT * FROM ".PREFIX."gallery_cats WHERE id = '".addslashes ($_GET['catid'])."'", 4);
	$num = mysql_num_rows($cat);

	if ($num>0)
	{
	  $content .= "<h3>".$mlang['003']."<i>".$catname['name']."</i></h3>";
	  $content .= "<table width='100%'><tr>";
	  $ii = 0;
          while ( $img = mysql_fetch_array($cat) )
          {
		if ($ii < 4)
		{
			$content .= "<td width='25%'><center><a href='index.php?module=gallery&op=viewimg&id=".$img['id']."'><table><tr><td height='140'><img src='uploads/s".$img['link']."' width='150' heigh='150' border='0'></td></tr><tr><td><center>".$img['title']."</center></td></tr></table></a></center></td>";
			$ii++;
		}
		else
		{
			$content .= "</tr><tr><td width='25%'><center><a href='index.php?module=gallery&op=viewimg&id=".$img['id']."'><table><tr><td height='140'><img src=uploads/s'".$img['link']."' width='150' heigh='150' border='0'></td></tr><tr><td><center>".$img['title']."</center></td></tr></table></a></center></td>";
			$ii = 1;
		}
          }
	  $content .= "</tr></table>";
	}
	else 
		$content .= $mlang['002'];
    }
    else
    {
        $cats = query ( "SELECT * FROM ".PREFIX."gallery_cats", 1);
    
        if ( !(mysql_num_rows($cats)) )
        {
            $content = $mlang['001'];
        }
        else
        {
		$content .= "<ul>";
            while ( $cat = mysql_fetch_array ( $cats ) )
            {
                $catnum = query ("SELECT * FROM ".PREFIX."gallery WHERE cat = '".$cat['id']."'", 3);
            
                $content .= "<li>&nbsp;<a href='index.php?module=gallery&op=viewcat&catid=".$cat['id']."'>".$cat['name'] . "</a> (" . $catnum . ")</li>";
            }
		$content .= "</ul>";
        }
    }
    
    echo $content;
}
function view_image ()
{
    $img = query ( "SELECT * FROM ".PREFIX."gallery WHERE id = '". addslashes ( $_GET['id'] ) ."'" , 4 );
    
    $content = "<img src = 'uploads/".$img['link']."'>";
    
    echo $content;
}
?>
Return current item: PHPEcho CMS