home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
csi.uticak12.org
/
csi.uticak12.org.tar
/
csi.uticak12.org
/
back
/
photos.php
< prev
next >
Wrap
PHP Script
|
2011-10-20
|
6KB
|
170 lines
<?
include 'guard.php';
mysql_connect(HostName,UserName,Password) or die("<html><body>Can not connect to MySql server!<br></body></html>");
mysql_select_db (DBName) or die ("<html><body>Could not select database ".DBName."<br></body></html>");
if ($cat_id>0) {$add=" AND cat_id='".$cat_id."' ";};
$query=mysql_query("SELECT * FROM `gal_photos` WHERE title LIKE '%$title%' ".$add." ORDER BY approved, `id` desc") or die (mysql_error());
?>
<? $header = "Manage Photos";
include ('top.inc'); ?>
<form action="photos.php" method="post">
<table border=0 cellspacing=0 cellpadding=5 align=center width="40%">
<tr>
<td class="border">
<table border=0 cellspacing=1 cellpadding=5 width="100%" class="back">
<tr>
<td class="th" colspan=2>Filter</td>
</tr>
<tr>
<td class="odd" align=right><b>Gallery:</b></td>
<td class="odd">
<select name="cat_id" class="inp">
<option value="">-- Any gallery --</option>
<?
$res=mysql_query("SELECT * FROM `gal_cats` ORDER BY `title`");
while ($f=mysql_fetch_array($res)) {
if ($cat_id==$f['id']) {$add="selected";} else {$add="";};
echo '<option value="'.$f['id'].'" '.$add.'>'.stripslashes(ucfirst(strtolower($f['title']))).'</option>';
};
?>
</select>
</td>
</tr>
<tr>
<td class="even" align=right><b>Title:</b><br/><small>(or its part)</small></td>
<td class="even"><input type="text" size="30" class="inp" name="title" value="<?=$title?>"></td>
</tr>
<tr>
<td class="tf" colspan=2 align=center>
<input type=submit value="Filter" class="btn">
<input type=button value="Show all" class="btn" onClick="location.href='photos.php'">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<table width="100%"><tr><td align=left>
<?
if ($pn=="") {$pn=1;};
if(mysql_num_rows($query)!=0) {
$num=mysql_num_rows($query);
$kol_it=ceil($num/ $nrp);
echo '<p class="navbar"><b>Pages: </b>';
if ($pn>1) {echo '<a href="photos.php?pn='.($pn-1).'&cat_id='.$cat_id.'&title='.$title.'" class=navbar><img src="int/pages_less.gif" alt="<<" border=0> </a>'; }
$i=1;
while ($i!=$kol_it+1) {
if ($i==$kol_it) {
if ($pn==$i) {echo'<b class=navbar>'.$i.'</b> '; $curren=$i;}
else {
echo '<a href="photos.php?pn='.$i.'&cat_id='.$cat_id.'&title='.$title.'" class="navbar">'.$i.'</a> ';};
}
else {
if ($pn==$i) {echo '<b class=navbar>'.$i.'</b>, '; $curren=$i;}
else {
echo '<a href="photos.php?pn='.$i.'&cat_id='.$cat_id.'&title='.$title.'" class="navbar">'.$i.'</a>, ';};
};
$i++;};
if ($pn<$kol_it) {echo '<a href="photos.php?pn='.($pn+1).'&cat_id='.$cat_id.'&title='.$title.'" class=navbar><img src="int/pages_more.gif" alt=">>" border=0></a></p>';}
else { echo '</p>'; };
;}
?>
</td></td></table>
<form action="photos_add.php?pn=<?=$pn?>&cat_id=<?=$cat_id?>&title=<?=$title?>" method="post" name="main">
<table border=0 cellspacing=0 cellpadding=5 align=center width="100%">
<tr>
<td class="border">
<table border=0 cellspacing=1 cellpadding=5 width="100%" class="back">
<tr>
<td class="tf" colspan=6 align=center>
<input type=submit class="btn" value="Add new">
</td>
</tr>
<tr align=center>
<td class="th" width="7%">n/n</td>
<td class="th">Photo</td>
<td class="th" width="25%">Gallery</td>
<td class="th" width="10%">Approved</td>
<td class="th" width="18%">Action</td>
</tr>
<?
$i=1;
while ($f=mysql_fetch_array($query)) {
if ($i>(($curren-1)*$nrp) && $i<($curren*$nrp+1)) {
$my_class="even";
$my_class1="odd";
$z=fmod($i, 2);
if ($z==0) {$my_class="odd"; $my_class1="even";};
echo '<tr align=center>';
echo '<td class="'.$my_class.'">'.$i.'.</td>';
echo '<td class="'.$my_class.'" align="left">';
if (file_exists('photos/photo_'.$f['id'].'.jpg')) {echo '<img src="photos/photo_'.$f['id'].'.jpg" height="100" />';};
echo '<br/><i>'.stripslashes($f['title']).'</i>';
echo '</td>';
$q=mysql_query("SELECT * FROM gal_cats WHERE id='".$f['cat_id']."'");
$f1=mysql_fetch_array($q);
echo '<td class="'.$my_class.'">'.stripslashes($f1['title']).'</td>';
if ($f['approved']=='1') {$approved='Yes';} else {$approved='<font color="#ff0000"><b>NO</b></font>';};
echo '<td class="'.$my_class.'">'.$approved.'</td>';
echo '<td class="'.$my_class.'">';
echo '<a href="photos_edit.php?id='.$f['id'].'&pn='.$pn.'&cat_id='.$cat_id.'&title='.$title.'" class="'.$my_class.'">Edit</a> ';
$x="'Are you sure you want to delete this entry?'";
echo ' | <a href="_delentry.php?id='.$f['id'].'&pn='.$pn.'&mode=photos&cat_id='.$cat_id.'&title='.$title.'" class="'.$my_class.'" onClick="return(confirm('.$x.'))">Delete</a>';
echo '</td></tr>';
}; $i++; };
?>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%"><tr><td align=left>
<br/><?
if ($pn=="") {$pn=1;};
if(mysql_num_rows($query)!=0) {
$num=mysql_num_rows($query);
$kol_it=ceil($num/ $nrp);
echo '<p class="navbar"><b>Pages: </b>';
if ($pn>1) {echo '<a href="photos.php?pn='.($pn-1).'&cat_id='.$cat_id.'&title='.$title.'" class=navbar><img src="int/pages_less.gif" alt="<<" border=0> </a>'; }
$i=1;
while ($i!=$kol_it+1) {
if ($i==$kol_it) {
if ($pn==$i) {echo'<b class=navbar>'.$i.'</b> '; $curren=$i;}
else {
echo '<a href="photos.php?pn='.$i.'&cat_id='.$cat_id.'&title='.$title.'" class="navbar">'.$i.'</a> ';};
}
else {
if ($pn==$i) {echo '<b class=navbar>'.$i.'</b>, '; $curren=$i;}
else {
echo '<a href="photos.php?pn='.$i.'&cat_id='.$cat_id.'&title='.$title.'" class="navbar">'.$i.'</a>, ';};
};
$i++;};
if ($pn<$kol_it) {echo '<a href="photos.php?pn='.($pn+1).'&cat_id='.$cat_id.'&title='.$title.'" class=navbar><img src="int/pages_more.gif" alt=">>" border=0></a></p>';}
else { echo '</p>'; };
;}
?>
</td></tr></table>
</form>
<? include ('btm.inc'); ?>