<?php
//$mysql = new mysql(DB_MAIN);
if((isset($_GET['id']) && !empty($_GET['id'])) && (isset($_GET['subsec']) && !empty($_GET['subsec'])))
{
$upd = $mysql->select(PRE."imgal", "cat='".$_GET['subsec']."' AND id='".$_GET['id']."'", "id", "DESC", "1");
while($ch=mysql_fetch_array($upd))
{
$vpone = $ch['views']+1;
}
if(!isset($_COOKIE['tut-'.$_GET["id"]]))
{
setcookie("tut-".$_GET['id'], "viewed", time()+604800);
$mysql->update(PRE."imgal", "views='".$vpone."'", "id='".$_GET['id']."'");
}
$listcat = $mysql->select(PRE."config", "section='imgal' AND name='categories'", "id", NULL, "1");
$l=mysql_fetch_array($listcat);
$val = explode("~", $l['setting']);
$expl = explode("~", $l['setting2']);
$all = array_combine($val, $expl);
foreach($all as $url => $name)
{
echo "<a href=\"ImGal/".$url."/\">".$name."</a> ¦ ";
}
echo "<a href=\"ImGal\">ImGal Home</a><hr />";
$showquery = $mysql->select(PRE."imgal", "id='".$_GET['id']."' AND cat='".$_GET['subsec']."'", "1");
if(!$showquery)
{
echo "The image doesn't exist...";
} else {
while($i=mysql_fetch_array($showquery))
{
$imglink = $i['link'];
echo "<a href=\"http://www.vouksh.info/imgs/".$_GET['subsec']."/".$imglink."\"><img src=\"http://www.vouksh.info/imgs/".$_GET['subsec']."/".$imglink."\" style=\"border: none; max-width: 570px;\" alt=\"".$i['alt']."\" title=\"".$i['alt']."\" /></a><br />
BBCode <fieldset><div><input value=\"[img]http://www.vouksh.info/imgs/".$_GET['subsec']."/".$imglink."[/img]\" size=\"40\" /><br />
HTML <input value='<img src=\"http://www.vouksh.info/imgs/".$_GET['subsec']."/".$imglink."\" border=\"0\" alt=\"".$i['alt']."\" />' size=\"40\" /><br />
Link <input value=\"http://www.vouksh.info/imgs/".$_GET['subsec']."/".$imglink."\" size=\"40\"/></div></fieldset><br />
<strong>Views:</strong> ".$i['views']."<br />
<strong>Desc/Alt text:</strong> ".$i['alt']."";
echo "<hr style=\"width:75%;\" /><div style=\"margin-top: 10px;\">";
$tc['query'] = $mysql->select(PRE."imgal_comments", "id='".$_GET['id']."'", "postid", "DESC");
$tc['rows'] = mysql_num_rows($tc['query']);
if(!$tc['rows'])
{
echo("No comments yet!");
} else {
if($tc['rows'] == "1"){
$a = array("is", "comment");
} else {
$a = array("are", "comments");
}
echo 'There '.$a["0"].' '.$tc["rows"].' '.$a["1"];
for($i = 0; $i < $tc['rows']; $i++)
{
if($i % 2) { //this means if there is a remainder
$style = "row1";
} else { //if there isn't a remainder we will do the else
$style = "row2";
}
$tcom=mysql_fetch_array($tc['query']);
if(mysql_num_rows($mysql->select(PRE."members", "username='".$tcom['username']."'", "id", "DESC", "1")) == "0")
{
$name = '<a href="javascript:email(\''.$email[0].'\',\''.$email[1].'\');">'.$tcom["username"].'</a>';
} else {
$name = '<a href="Members/Profile/'.str_replace(" ", "_",$tcom["username"]).'/">'.$tcom["username"].'</a>';
}
$email = explode("@", $tcom['email']);
$message = $tcom['message'];
$date = date(DATE, $tcom['date']);
$id = $tcom['id'];
echo "<div class=\"$style\" style=\"margin-top: 5px; height: 50px; overflow: auto;\">
<div style=\"width: 15%; float: left;\"><a href=\"javascript:email('$email[0]','$email[1]');\">$name</a><br />
$date</div>
<div style=\"width: 80%; float: right;\">$message</div>
</div>";
}
}
echo '<hr style="width: 95%;" />
<form method="post" action="misc/imgal-comment-in.php"><div>Post a Comment.</div>';
if(!isset($_COOKIE['mid']))
{
echo '<div class="formtext">Username</div>
<div class="formdiv"><input name="username" type="text" /></div>
<div class="formtext">Email</div>
<div class="formdiv"><input name="email" type="text" /></div>';
} else {
echo '<div><input type="hidden" name="username" value="'.$_COOKIE["user"].'" />
<input type="hidden" name="email" value="'.getuserinfo("email").'" /></div>';
}
echo '<div class="formtext">Message</div>
<div class="formtext"><textarea name="message" class="wysiwyg" cols="60" rows="14"></textarea></div>
<div class="formdiv"><input name="id" type="hidden" id="id" value="'.$_GET['id'].'" />
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset\" value="Reset" />
</div>
</form></div>';
if(isset($_GET['cerror']))
{
echo '<div class="error">Error: You skipped some info. Please fill it all out</div>';
}
// echo "</div>";
}
}
} elseif((!isset($_GET['id']) && empty($_GET['id'])) && (isset($_GET['subsec']) && !empty($_GET['subsec'])))
{
$listcat = $mysql->select(PRE."config", "section='imgal' AND name='categories'", "id", NULL, "1");
$l=mysql_fetch_array($listcat);
$val = explode("~", $l['setting']);
$expl = explode("~", $l['setting2']);
$all = array_combine($val, $expl);
foreach($all as $url => $name)
{
echo "<a href=\"ImGal/".$url."/\">".$name."</a> ¦ ";
}
echo "<a href=\"ImGal/\">ImGal Home</a><hr />";
// Pagination crap..
if(empty($_GET['view']) || !isset($_GET['view']))
{
$view = 1;
} else {
$view = $_GET['view'];
}
$limit = getuserinfo('pglimit');
if ($limit == 0)
{
$limit = 10;
}
$totalrows = mysql_num_rows($mysql->select(PRE."imgal", "cat='".$_GET['subsec']."'", "id"));
$limitvalue = $view * $limit - ($limit);
// end pagination crap
$showquery2 = $mysql->select(PRE."imgal", "cat='".$_GET['subsec']."'", "id", "DESC", $limitvalue.",".$limit);
if(mysql_num_rows($showquery2) > 0)
{
while($i2=mysql_fetch_array($showquery2))
{
$thumblink = $i2['thumb'];
echo "<a href=\"ImGal/".$_GET['subsec']."/".$i2['id']."/\"><img src=\"http://www.vouksh.info/imgs/".$_GET['subsec']."/".$thumblink."\" style=\"border:none;\" alt=\"".$i2['alt']."\" title=\"".$i2['alt']."\" /></a><br />
<strong>Creator:</strong> ".$i2['author']."<br />
<strong>Submitted on ".gmdate(DATE, $i2['date'])."</strong><br />
<strong>Views:</strong> ".$i2['views']."<br /><br />";
}
// More pagination crap..
echo '<div style="font-weight:bold;text-align:center;">';
if($view != 1)
{
$pageprev = $view-1;
echo '<a href="ImGal/'.$_GET['subsec'].'&view='.$pageprev.'"><<</a> ';
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++)
{
if($i == $view)
{
echo $i." ";
} else {
echo '<a href="ImGal/'.$_GET['subsec'].'&view='.$i.'">'.$i.'</a> ';
}
}
if(($totalrows % $limit) != 0)
{
if($i == $view)
{
echo $i.' ';
} else {
echo '<a href="ImGal/'.$_GET['subsec'].'&view='.$i.'">'.$i.'</a> ';
}
}
if(($totalrows - ($limit * $view)) > 0)
{
$pagenext = $view+1;
echo '<a href="ImGal/'.$_GET['subsec'].'&view='.$pagenext.'">>></a>';
}
echo '</div>';
// end more pagination crap
} else {
echo "No images in this category yet!";
}
} elseif((!isset($_GET['id']) && empty($_GET['id'])) && (!isset($_GET['subsec']) && empty($_GET['subsec'])))
{
$listcat = $mysql->select(PRE."config", "section='imgal' AND name='categories'", "id", NULL, "1");
$l=mysql_fetch_array($listcat);
$val = explode("~", $l['setting']);
$expl = explode("~", $l['setting2']);
$all = array_combine($val, $expl);
echo '<ul>';
foreach($all as $url => $name)
{
echo "<li><a href=\"ImGal/".$url."/\">".$name."</a></li>\n";
}
echo '</ul>';
}
// $mysql->close();
// unset($mysql);
?>