View difference between Paste ID: BULKQaJ8 and q4a0bUJm
SHOW: | | - or go back to the newest paste.
1
<?php
2
	include("config.inc.php");
3
4
	// initialization
5
	$result_array = array();
6
	$counter = 0;
7
8
	$cid = (int)($_GET['cid']);
9
	$pid = (int)($_GET['pid']);
10
11
	// Category Listing
12
13
	if( empty($cid) && empty($pid) )
14
	{
15
		$number_of_categories_in_row = 4;
16
17
		$result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
18
						FROM gallery_category as c
19
						LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
20
						GROUP BY c.category_id" );
21
		while( $row = mysql_fetch_array( $result ) )
22
		{
23
			$result_array[] = "<a href='index.php?p=gallerij&cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
24
		}
25
		mysql_free_result( $result );	
26
27
		$result_final = "<tr>\n";
28
29
		foreach($result_array as $category_link)
30
		{
31
			if($counter == $number_of_categories_in_row)
32
			{	
33
				$counter = 1;
34
				$result_final .= "\n</tr>\n<tr>\n";
35
			}
36
			else
37
			$counter++;
38
39
			$result_final .= "\t<td>".$category_link."</td>\n";
40
		}
41
42
		if($counter)
43
		{
44
			if($number_of_categories_in_row-$counter)
45
			$result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'>&nbsp;</td>\n";
46
47
			$result_final .= "</tr>";
48
		}
49
	}
50
51
52
	// Thumbnail Listing
53
54
	else if( $cid && empty( $pid ) )
55
	{
56
		$number_of_thumbs_in_row = 5;
57
58
		$result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" );
59
		$nr = mysql_num_rows( $result );
60
61
		if( empty( $nr ) )
62
		{
63
			$result_final = "\t<tr><td>No Category found</td></tr>\n";
64
		}
65
		else
66
		{
67
			while( $row = mysql_fetch_array( $result ) )
68
			{
69
			// die class=iframe zou die moeten pakken en dan die link openen in die frame….. :(	
70
			$result_array[] = "<a class='iframe' rel='lightbox' href='gallery/viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a> ";
71
			}
72
			
73
			mysql_free_result( $result );	
74
75
			$result_final = "<tr>\n";
76
	
77
			foreach($result_array as $thumbnail_link)
78
			{
79
				if($counter == $number_of_thumbs_in_row)
80
				{	
81
					$counter = 1;
82
					$result_final .= "\n</tr>\n<tr>\n";
83
				}
84
				else
85
				$counter++;
86
87
				$result_final .= "\t<td>".$thumbnail_link."</td>\n";
88
			}
89
	
90
			if($counter)
91
			{
92
				if($number_of_photos_in_row-$counter)
93
			$result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'>&nbsp;</td>\n";
94
95
				$result_final .= "</tr>";
96
			}
97
		}
98
	}
99
100
	// Full Size View of Photo
101
	else if( $pid )
102
	{
103
		$result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
104
		list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
105
		$nr = mysql_num_rows( $result );
106
		mysql_free_result( $result );	
107
108
		if( empty( $nr ) )
109
		{
110
			$result_final = "\t<tr><td>No Photo found</td></tr>\n";
111
		}
112
		else
113
		{
114
			$result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
115
			list($category_name) = mysql_fetch_array( $result );
116
			mysql_free_result( $result );	
117
118
			$result_final .= "<tr>\n\t<td>
119
						<a href='index.php?p=gallerij'>Categories</a> &gt; 
120
						<a href='index.php?p=gallerij&cid=$cid'>$category_name</a></td>\n</tr>\n";
121
122
			$result_final .= "<tr>\n\t<td align='center'>
123
					<br />
124
					<img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
125
					<br />
126
					$photo_caption
127
					</td>
128
					</tr>";
129
		}
130
	}
131
132
// Final Output
133
echo <<<__HTML_END
134
135
<html>
136
<head>
137
	<title>Gallery View</title>
138
<script type="text/javascript">
139
    $(function () {
140
        $("a.iframe").fancybox()
141
    })
142
</script>
143
144
</head>
145
<body>
146
<table width='100%' border='0' align='center' style='width: 70%;'>
147-
?>
147+
148
</table>
149
</body>
150
</html>
151
152-
</script>
152+
153
?>
154