// session_save_path("../private");
session_save_path($_SERVER['DOCUMENT_ROOT']."/../tmp");
// 100% Wahrscheinlichkeit für gc
ini_set("session.gc_probability", 50);
session_start();
require_once('admin/templates/class.FastTemplate.php3');
require_once('admin/db/dbconnect.php');
require_once('admin/db/connector.php');
require_once('admin/includes/functions.inc.php');
require_once('admin/includes/classes.inc.php');
require_once('admin/galconfig.php');
require_once('admin/galcss.php');
require_once('admin/getthumbs.php');
require_once('admin/language/lang-ger.inc.php');
require_once('util/captcha/class.CaptchaCheck.php');
$HOME = $_SERVER['PHP_SELF']."?";
if(isset($_GET['lc']))
listCategories();
else if(isset($_GET['lsc']) && isset($_GET['catid'])){
$id = $_GET['catid'];
if(is_numeric($id))
listSubCategories($id);
}
else if(isset($_GET['si']) && isset($_GET['catid']) && isset($_GET['subid']) || isset($_GET['page'])){
$catid = $_GET['catid'];
$subid = $_GET['subid'];
$page = $_GET['page'];
if(is_numeric($catid) && is_numeric($subid)){
if($page!="" && is_numeric($page))
showImages($catid, $subid, $page);
else
showImages($catid, $subid, 0);
}
}
else if(isset($_GET['li']) && isset($_GET['catid']) && isset($_GET['subid']) && isset($_GET['pos'])){
$catid = $_GET['catid'];
$subid = $_GET['subid'];
$pos = $_GET['pos'];
if(is_numeric($catid) && is_numeric($subid) && is_numeric($pos)){
if(isset($_POST['comment']) && isset($_POST['name']) && isset($_POST['imgid']))
performAddComment($catid, $subid, $pos, $_SERVER["REMOTE_ADDR"], trim(strip_tags($_POST['comment'])), trim(strip_tags($_POST['name'])), $_POST['imgid']);
else
showLargeImage($catid, $subid, $pos, true, NULL);
}
}else if(isset($_GET['addc']) && isset($_GET['catid']) && isset($_GET['subid']) && isset($_GET['pos'])){
$catid = $_GET['catid'];
$subid = $_GET['subid'];
$pos = $_GET['pos'];
if(is_numeric($catid) && is_numeric($subid) && is_numeric($pos))
showCommentImage($catid, $subid, $pos, NULL);
else
listCategories();
}
else if(isset($_GET['send']) && isset($_GET['catid']) && isset($_GET['subid']) && isset($_GET['pos'])){
$catid = $_GET['catid'];
$subid = $_GET['subid'];
$pos = $_GET['pos'];
$comment = new ImageComment();
$comment->id_img = $_POST['imgid'];
$comment->ip = $_SERVER['REMOTE_ADDR'];
$comment->name = trim(strip_tags($_POST['name']));
$comment->text = trim(strip_tags($_POST['comment']));
$comment->sec = trim(strip_tags($_POST['sec']));
if(is_numeric($catid) && is_numeric($subid) && is_numeric($pos) && isset($_POST['save']))
performAddComment($catid, $subid, $pos, $comment);
else if(is_numeric($catid) && is_numeric($subid) && is_numeric($pos) && isset($_POST['preview']))
showCommentPreview($catid, $subid, $pos, $comment);
else
listCategories();
}
else
listCategories();
function setHtml(&$tpl){
global $gal, $css_style;
if($gal['standalone']){
$tpl->assign('{HTML_HEAD}', $gal['html_head']);
$tpl->assign('{HTML_BOTTOM}', $gal['html_bottom']);
}else{
$tpl->assign('{HTML_HEAD}', "");
$tpl->assign('{HTML_BOTTOM}', "");
}
$tpl->assign('{STYLES}', $css_style);
}
function listCategories(){
global $gal, $glang, $HOME;
$catlist = new CatList();
$catlist->getCategories();
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "user_main.tpl",
'lnk_table' => "lnk_table.tpl",
'row' => "user_main_row.tpl",
'dialog' => "main.tpl" ));
$tpl->assign('{HEADLINE}', $glang['h_main']);
setHtml($tpl);
$tpl->assign('{FULL_LNK}', $glang['h_cat']);
$tpl->parse('{LNK_TABLE}', '.lnk_table');
$tpl->assign('{FIRST}', $glang['t_cat']);
$tpl->assign('{SECOND}', $glang['h_sub_cats']);
$tpl->assign('{THIRD}', $glang['h_images']);
foreach($catlist->categories as $elem){
if($elem->count_subcats>0)
$lnk = $HOME ."&lsc&catid=".$elem->id;
else
$lnk = $HOME ."&lc";
$tpl->assign('{LNK}', $lnk);
$tpl->assign('{LNK_DESC}', $elem->description);
$tpl->assign('{SECOND_COL}', $elem->count_subcats);
$tpl->assign('{THIRD_COL}', $elem->count_images);
$tpl->parse('{ROWS}', '.row');
}
$tpl->parse('{CONTENT}', '.content');
$tpl->parse('print', 'dialog');
$tpl->FastPrint('print');
}
function listSubCategories($id_cat){
global $gal, $glang, $HOME;
$subcatlist = new SubCatList($id_cat);
$subcatlist->getSubCategories($id_cat);
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "user_main.tpl",
'row' => "user_main_row.tpl",
'lnk_table' => "lnk_table.tpl",
'dialog' => "main.tpl" ));
$tpl->assign('{HEADLINE}', $glang['h_main']);
setHtml($tpl);
$lnk_row = "".$glang['h_cat']." >> ". $subcatlist->description;
$tpl->assign('{FULL_LNK}', $lnk_row);
$tpl->parse('{LNK_TABLE}', '.lnk_table');
$tpl->assign('{FIRST}', $glang['h_sub_cat']);
$tpl->assign('{SECOND}', $glang['h_date']);
$tpl->assign('{THIRD}', $glang['h_images']);
foreach($subcatlist->subcats as $elem){
if($elem->count_images>0)
$lnk = $HOME ."&si&catid=".$elem->id_cat."&subid=".$elem->id;
else
$lnk = $HOME ."&lsc&catid=".$elem->id_cat;
$tpl->assign('{LNK}', $lnk);
$tpl->assign('{LNK_DESC}', $elem->description);
$tpl->assign('{SECOND_COL}', $elem->subdate);
$tpl->assign('{THIRD_COL}', $elem->count_images);
$tpl->parse('{ROWS}', '.row');
}
$tpl->parse('{CONTENT}', '.content');
$tpl->parse('print', 'dialog');
$tpl->FastPrint('print');
}
function getPageNav($page, $pagecount, &$il){
global $gal, $HOME;
$res="";
if($pagecount>1){
//Seitenauswahl-Leiste
for ($i=1; $i<=$pagecount; $i++)
{
if ($i==$page)
$res = $res . "" . $i . " ";
else
$res = $res . " ";
}
}
return $res;
}
function showImages($catid, $subid, $page){
global $gal, $glang, $HOME;
$page = $page;
$il = new ImageList($catid, $subid, $gal['dirpath']);
$pagecount=ceil($il->countImg / $gal['pics_page']);
//Ungültige Seitenanzahlen korrigieren
if ($page<1) $page=1;
if ($page>$pagecount) $page=$pagecount;
//Ergebnisse lesen
$begin=($page-1)*$gal['pics_page'];
$il->getImages($catid, $subid, $begin, $gal['pics_page']);
//$il->setExistingImages();
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "user_thumbs.tpl",
'lnk_table' => "lnk_table.tpl",
'dialog' => "main.tpl" ));
setHtml($tpl);
$tpl->assign('{HEADLINE}', $glang['h_main']);
$lnk = "".$glang['h_cat']." >> ".$il->cat." >> ".$il->subcat. " ".$il->subdate;
$tpl->assign('{FULL_LNK}', $lnk);
$tpl->parse('{LNK_TABLE}', '.lnk_table');
$tpl->assign('{PAGE_NAV}', getPageNav($page, $pagecount, $il));
$tpl->assign('{ROWS}', performViewThumbs($il));
$tpl->parse('{CONTENT}','content');
$tpl->parse('print', 'dialog');
$tpl->FastPrint('print');
}
function performViewThumbs(&$il){
global $gal, $glang;
$result ="";
$cntImg = count($il->images);
$remainder;
$rows;
if($cntImg>0){
if($cntImg>=$gal['col_admin']){
$remainder = $cntImg%$gal['col_admin'];
$rows = ($cntImg-$remainder)/$gal['col_admin'];
$s=1;
$r=0;
for($i=1; $i<=$cntImg; $i++){
if($s==$gal['col_admin']){
$result = $result . displayThumbRow($il->images, $i-$gal['col_admin'], $i, $il->path);
$s=1;
$r++;
}
else if($r==$rows && $remainder>0 && $i-$cntImg==0)
$result = $result . displayThumbRow($il->images, $i-$remainder, $i, $il->path);
else
$s++;
}
}else
$result = $result . displayThumbRow($il->images, 0, $cntImg, $il->path);
}
return $result;
}
//displays
function displayThumb($img, $dir){
global $gal, $HOME;
$thumbsize = 150;
$imgsrc = $dir.$img->filename;
list($width, $height) = getimagesize($imgsrc);
$imgratio=$width/$height;
//Ist das Bild höher als breit?".$gal['url']."&
if($imgratio>1)
{
$newwidth = $thumbsize;
$newheight = $thumbsize/$imgratio;
}
else
{
$newheight = $thumbsize;
$newwidth = $thumbsize*$imgratio;
}
$imgdir = thumbnail($img->id_cat,$img->id_subcat,$img->filename, false);
//getthumbs.php?".$gal['url']."&catid=".$img->id_cat."&subid=".$img->id_subcat."&image=".$img->filename."
return "
| \n";
}
function displayThumbRow(&$images, $s, $e, $dir){
$res = "";
for($i=$s; $i<$e; $i++)
$res = $res . displayThumb($images[$i],$dir);
$res = $res . "
\n";
return $res;
}
function showLargeImage($catid, $subid, $pos, $count, $comment){
global $gal, $glang, $HOME;
$il = new ImageList($catid, $subid, $gal['dirpath']);
$il->getAllImages($catid, $subid);
//$il->setExistingImages();
$img = $il->getImageByPos($pos);
if($count)
$img->countAccess();
$img->getComments();
//echo "prev: ".$img->prev . " pos: ". $img->pos. " next: ".$img->next;
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "user_largeImage.tpl",
'lnk_table' => "lnk_table.tpl",
'comments' => "comment.tpl",
'dialog' => "main.tpl" ));
setHtml($tpl);
$tpl->assign('{HEADLINE}', $glang['h_main']);
$lnk = "".$glang['h_cat']." >> ".$il->cat." >> ".$il->subcat." ".$il->subdate."";
$tpl->assign('{FULL_LNK}', $lnk);
$tpl->parse('{LNK_TABLE}', '.lnk_table');
if($img->prev>=0){
$lnk = "";
}else{
$lnk = "";
}
$tpl->assign('{PREV}', $lnk);
//$lnk = "";
$tpl->assign('{BACK}', $img->pos+1 . " / " . $il->numImg);
if($img->next>=0){
$lnk = "";
}else{
$lnk = "";
}
$tpl->assign('{NEXT}', $lnk);
$image = "
";
$tpl->assign('{IMAGE}', $image);
if($img->description!="")
$tpl->assign('{IMAGE_TITLE}', $img->description);
else
$tpl->assign('{IMAGE_TITLE}', " ");
$lnk = "";
$tpl->assign('{COMMENT_LNK}', $lnk);
if(count($img->comments)>0){
foreach($img->comments as $elem){
$tpl->assign('{NAME_VALUE}', $elem->name);
$tpl->assign('{DATE_VALUE}', $elem->date_create);
$tpl->assign('{COMMENT_VALUE}', $elem->text);
$tpl->parse('{COMMENTS}', '.comments');
}
}else
$tpl->assign('{COMMENTS}', "");
if($comment){
$tpl->assign('{CF_HEAD}', "". $comment->msg . "
" . $glang['t_comment']);
$tpl->assign('{CF_NAME_VALUE}', $comment->name);
$tpl->assign('{CF_COMMENT_VALUE}', $comment->text);
}else{
$tpl->assign('{CF_HEAD}', $glang['t_comment']);
$tpl->assign('{CF_NAME_VALUE}', "");
$tpl->assign('{CF_COMMENT_VALUE}', "");
}
$tpl->assign('{B_SUBMIT}', $glang['b-submit']);
$tpl->parse('{CONTENT}','content');
$tpl->parse('print', 'dialog');
$tpl->FastPrint('print');
}
function performAddComment($catid, $subid, $pos, &$comment){
global $glang;
$check = new CaptchaCheck;
$mailcomment = new ImageComment();
$mailcomment = $comment;
$comment->name = htmlentities($comment->name, ENT_QUOTES);
$comment->text = htmlentities($comment->text, ENT_QUOTES);
if($comment->name!="" && $comment->text!="" && $comment->sec!=""){
if($check->check($comment->sec)==0){
if($comment->insertComment()){
performAdminCommentMail($mailcomment, $catid, $subid, $pos);
showLargeImage($catid, $subid, $pos, false, NULL);
}else{
$comment->msg = $glang['err_comment_db'];
showLargeImage($catid, $subid, $pos, false, $comment);
}
}else{
$comment->msg = $glang['err_comment_sec'];
showCommentImage($catid, $subid, $pos, $comment);
}
}else{
$comment->msg = $glang['err_comment'];
showCommentImage($catid, $subid, $pos, $comment);
}
}
function buildNewCommentMail(&$comment, $catid, $subid, $pos){
global $gal;
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "mail_commentAdmin.tpl"));
$tpl->assign('{NAME}', $comment->name);
$tpl->assign('{COMMENT}', $comment->text);
$lnk = "http://".$_SERVER['SERVER_NAME']."/admin/index.php?gallery&li&catid=".$catid."&subid=".$subid."&pos=".$pos;
$tpl->assign('{LNK}', $lnk);
$tpl->parse('print', 'content');
$body = $tpl->fetch('print');
return $body;
}
function performAdminCommentMail(&$comment, $catid, $subid, $pos){
global $glang;
include('admin/includes/maildata.php');
require('admin/includes/class.phpmailer.php');
$mail = new PHPMailer();
//$mail->SetLanguage("en");
$mail->IsSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $user; // SMTP username
$mail->Password = $pw; // SMTP password
$mail->From = $from;
$mail->FromName = $fromname;
$mail->AddAddress($from);
$mail->WordWrap = 75; // set word wrap to 75 characters
$mail->IsHTML(false); // set email format to HTML
$mail->Subject = $glang['h_comment_mail'];
$mail->Body = buildNewCommentMail($comment,$catid, $subid, $pos);
//echo $mail->Body;
if(!$mail->Send())
{
return false;
//echo $mail->ErrorInfo;
//header("Location: errorpage.php?errid=5");
}else{
return true;
}
}
function showCommentImage($catid, $subid, $pos, $comment){
global $gal, $glang, $HOME;
$il = new ImageList($catid, $subid, $gal['dirpath']);
$il->getAllImages($catid, $subid);
//$il->setExistingImages();
$img = $il->getImageByPos($pos);
$img->getComments();
//echo "prev: ".$img->prev . " pos: ". $img->pos. " next: ".$img->next;
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "user_largeImage.tpl",
'lnk_table' => "lnk_table.tpl",
'comments' => "comment.tpl",
'commentform'=> "commentform.tpl",
'dialog' => "main.tpl" ));
setHtml($tpl);
$tpl->assign('{HEADLINE}', $glang['h_comment_img']);
$lnk = "".$glang['lnk_view_img']."";
$tpl->assign('{FULL_LNK}', $lnk);
$tpl->parse('{LNK_TABLE}', '.lnk_table');
$tpl->assign('{PREV}', "");
//$lnk = "";
$tpl->assign('{BACK}', "");
$tpl->assign('{NEXT}', "");
$image = "
";
$tpl->assign('{IMAGE}', $image);
if($img->description!="")
$tpl->assign('{IMAGE_TITLE}', $img->description);
else
$tpl->assign('{IMAGE_TITLE}', " ");
$lnk = $HOME . "&send&catid=". $catid . "&subid=".$subid."&pos=".$pos;
$captcha = "util/captcha/captcha.php";
$tpl->assign('{CF_TARGET}', $lnk);
$tpl->assign('{IMAGE_ID}', $img->id);
$tpl->assign('{CF_NAME}', $glang['t_name']);
if($comment){
$tpl->assign('{CF_NAME}', "". $comment->msg . "
" . $glang['t_name']);
$tpl->assign('{CF_COMMENT}', $glang['t_comment']);
$tpl->assign('{CF_NAME_VALUE}', $comment->name);
$tpl->assign('{CF_COMMENT_VALUE}', $comment->text);
$tpl->assign('{CF_CODE}', $glang['t_code']);
$tpl->assign('{CF_COMMENT_CODE}',$captcha);
}else{
$tpl->assign('{CF_NAME}', $glang['t_name']);
$tpl->assign('{CF_COMMENT}', $glang['t_comment']);
$tpl->assign('{CF_NAME_VALUE}', "");
$tpl->assign('{CF_COMMENT_VALUE}', "");
$tpl->assign('{CF_CODE}', $glang['t_code']);
$tpl->assign('{CF_COMMENT_CODE}',$captcha);
}
$tpl->assign('{B_SUBMIT}', $glang['b-submit']);
$tpl->assign('{B_PREVIEW}', $glang['b_preview']);
$tpl->parse('{COMMENT_LNK}', 'commentform');
if(count($img->comments)>0){
foreach($img->comments as $elem){
$tpl->assign('{NAME_VALUE}', $elem->name);
$tpl->assign('{DATE_VALUE}', $elem->date_create);
$tpl->assign('{COMMENT_VALUE}', $elem->text);
$tpl->parse('{COMMENTS}', '.comments');
}
}else
$tpl->assign('{COMMENTS}', "");
$tpl->parse('{CONTENT}','content');
$tpl->parse('print', 'dialog');
$tpl->FastPrint('print');
}
function showCommentPreview($catid, $subid, $pos, &$comment){
global $gal, $glang, $HOME;
$il = new ImageList($catid, $subid, $gal['dirpath']);
$il->getAllImages($catid, $subid);
//$il->setExistingImages();
$img = $il->getImageByPos($pos);
$img->getComments();
//echo "prev: ".$img->prev . " pos: ". $img->pos. " next: ".$img->next;
$tpl = new FastTemplate($gal['sysdir'] . "templates");
$tpl->define( array( 'content' => "user_largeImagePreview.tpl",
'lnk_table' => "lnk_table.tpl",
'comment' => "comment.tpl",
'commentform'=> "commentform.tpl",
'dialog' => "main.tpl" ));
setHtml($tpl);
$tpl->assign('{HEADLINE}', $glang['h_comment_prev']);
$lnk = "".$glang['lnk_view_img']."";
$tpl->assign('{FULL_LNK}', $lnk);
$tpl->parse('{LNK_TABLE}', '.lnk_table');
$tpl->assign('{PREV}', "");
//$lnk = "";
$tpl->assign('{BACK}', "");
$tpl->assign('{NEXT}', "");
$image = "
";
$tpl->assign('{IMAGE}', $image);
if($img->description!="")
$tpl->assign('{IMAGE_TITLE}', $img->description);
else
$tpl->assign('{IMAGE_TITLE}', "Foto Rainer Buder");
$lnk = $HOME . "&send&catid=". $catid . "&subid=".$subid."&pos=".$pos;
$captcha = "util/captcha/captcha.php";
$tpl->assign('{CF_TARGET}', $lnk);
$tpl->assign('{IMAGE_ID}', $img->id);
$tpl->assign('{CF_NAME}', $glang['t_name']);
if($comment){
$tpl->assign('{CF_NAME}', "". $comment->msg . "
" . $glang['t_name']);
$tpl->assign('{CF_COMMENT}', $glang['t_comment']);
$tpl->assign('{CF_NAME_VALUE}', $comment->name);
$tpl->assign('{CF_COMMENT_VALUE}', $comment->text);
$tpl->assign('{NAME_VALUE}', $comment->name);
$tpl->assign('{DATE_VALUE}', $comment->date_create);
$tpl->assign('{COMMENT_VALUE}', mynl2br($comment->text));
$tpl->assign('{CF_CODE}', $glang['t_code']);
$tpl->assign('{CF_COMMENT_CODE}',$captcha);
$tpl->parse('{COMMENT}', '.comment');
}else{
$tpl->assign('{CF_NAME}', $glang['t_name']);
$tpl->assign('{CF_COMMENT}', $glang['t_comment']);
$tpl->assign('{CF_NAME_VALUE}', "");
$tpl->assign('{CF_COMMENT_VALUE}', "");
$tpl->assign('{COMMENT}', "");
$tpl->assign('{CF_CODE}', $glang['t_code']);
$tpl->assign('{CF_COMMENT_CODE}',$captcha);
}
$tpl->assign('{B_SUBMIT}', $glang['b-submit']);
$tpl->assign('{B_PREVIEW}', $glang['b_preview']);
$tpl->parse('{COMMENT_LNK}', 'commentform');
$tpl->assign('{COMMENTS}', "");
$tpl->parse('{CONTENT}','content');
$tpl->parse('print', 'dialog');
$tpl->FastPrint('print');
}
?>