setMysql($TEMPLATES_MAIN_TABLE, $TEMPLATES_MAIN_TEMPLATE_FIELD, $TEMPLATES_MAIN_CODE_FIELD); $id = $_GET['id']==""?$_POST['id']:$_GET['id']; if(!is_numeric($id)){ $id=-1; } $g_row = mysql_fetch_object(mysql_query("select * from galleries where status=1 and id=$id")); if($g_row->id==""){ header("Location: ./index.php"); exit; } $page_row = mysql_fetch_object(mysql_query("select pages.*, html_templates.html_code from pages left outer join html_templates on html_templates.id = pages.template_id where pages.id=$g_row->dep_id")); if($page_row->id==""){ header("Location: ./index.php"); exit; } $page = $_GET['page']==""?$_POST['page']:$_GET['page']; $page = is_numeric($page)?$page:1; $row = mysql_fetch_object(mysql_query("select * from galleries where id=$id")); $items_per_line = $PHOTOS_PER_LINE; $items_per_page = $PHOTOS_PER_PAGE; $row = mysql_fetch_row(mysql_query("select count(*) from photos where g_id=$id")); $total_amount = $row[0]; $num_pages = floor($total_amount/$items_per_page); $start_item = ($page-1)*$items_per_page + 1; $end_item = $page*$items_per_page; if($total_amount==0){ $start_item = 0; $end_item = 0; } if($end_item > $total_amount){ $end_item = $total_amont; } if($total_amount > $num_pages*$items_per_page){ $num_pages++; } $row = mysql_fetch_object(mysql_query("select * from galleries where id=$id")); $script = ' '; $gal_name = stripslashes($row->name); #$content .=''; $res = mysql_query("select * from photos where g_id=$id limit ".($start_item - 1).",$items_per_page"); $num_items = mysql_num_rows($res); $photo_body = ""; while($row=mysql_fetch_object($res)){ $photo_body .= ""; if(($num_items-$items_per_line) >=0) { for($i=1;$i<=$items_per_line;$i++) { if ( $i > 1 ) { $row = mysql_fetch_object($res); } $size = @getimagesize($PHOTO_PATH."/".$row->file); # $img_text='Увеличить'; # $text .= ""; $tmp .= stripslashes( $tpl->get("GPAGE_ROW") ); $tmp = str_replace("[[SITE_URL]]", $SITE_URL, $tmp); $tmp = str_replace("[[id]]", $row->id, $tmp); $tmp = str_replace("[[file]]", $row->file, $tmp); $tmp = str_replace("[[size0]]", $size[0],$tmp); $tmp = str_replace("[[size1]]", $size[1], $tmp); $tmp = str_replace("[[g_id]]",$row->g_id,$tmp); $tmp = str_replace("[[description]]",stripslashes($row->description),$tmp); $photo_body .= $tmp; $tmp = ""; } $num_items -= $items_per_line; } else{ for($i=1;$i<=$num_items;$i++){ if($i>1){ $row=mysql_fetch_object($res); } $size = @getimagesize($PHOTO_PATH."/".$row->file); # $img_text='Увеличить'; # $text .= ""; $tmp .= stripslashes( $tpl->get("GPAGE_ROW") ); $tmp = str_replace("[[SITE_URL]]", $SITE_URL, $tmp); $tmp = str_replace("[[id]]", $row->id, $tmp); $tmp = str_replace("[[file]]", $row->file, $tmp); $tmp = str_replace("[[size0]]", $size[0],$tmp); $tmp = str_replace("[[size1]]", $size[1], $tmp); $tmp = str_replace("[[g_id]]",$row->g_id,$tmp); $tmp = str_replace("[[description]]",stripslashes($row->description),$tmp); $photo_body .= $tmp; $tmp = ""; } for($i=1;$i<=($items_per_line-$num_items);$i++){ $photo_body .= ""; } } $photo_body .= "\n"; } if($num_pages>1){ for($i=1;$i<=$num_pages;$i++){ if($page==$i){ $tmp .= $tpl->get("PAGER"); $tmp = str_replace("[[page]]",$i,$tmp); $pager .= $tmp; $tmp = ""; } else{ $tmp .= $tpl->get("PAGER"); $tmp = str_replace("[[page]]","$i",$tmp); $pager .= $tmp; $tmp = ""; } } } #photo_body #$gal_name $tmp .= stripslashes($tpl->get("GPAGE_MAIN")); $tmp = str_replace("[[row_body]]",$photo_body,$tmp); $tmp = str_replace("[[pager]]",$pager,$tmp); $tmp = str_replace("[[id]]",$id,$tmp); $tmp = str_replace("[[name]]",$gal_name,$tmp); $content = $tmp; $content .= $script; $html_result = str_replace("_CONTENT_",$content,GetTemplateCode($page_row->template_id,$page_row->title)); $html_result = eregi_replace(".*","".$page_row->title.". $g_row->name",$html_result); $html_result = str_replace("_TITLE_", "", $html_result); echo $html_result; ?>
$img_text
".stripslashes($row->description)."
$img_text
".stripslashes($row->description)."