2013-08-28 22:47:04 +02:00
< ? php
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
/**
* File : page_news . php .
* Author : Ulrich Block
* Date : 13.05 . 12
* Time : 10 : 31
* Contact : < ulrich . block @ easy - wi . com >
*
* This file is part of Easy - WI .
*
* Easy - WI is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* Easy - WI is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with Easy - WI . If not , see < http :// www . gnu . org / licenses />.
*
* Diese Datei ist Teil von Easy - WI .
*
* Easy - WI ist Freie Software : Sie koennen es unter den Bedingungen
* der GNU General Public License , wie von der Free Software Foundation ,
* Version 3 der Lizenz oder ( nach Ihrer Wahl ) jeder spaeteren
* veroeffentlichten Version , weiterverbreiten und / oder modifizieren .
*
* Easy - WI wird in der Hoffnung , dass es nuetzlich sein wird , aber
* OHNE JEDE GEWAEHELEISTUNG , bereitgestellt ; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK .
* Siehe die GNU General Public License fuer weitere Details .
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben . Wenn nicht , siehe < http :// www . gnu . org / licenses />.
*/
2014-01-03 22:08:11 +01:00
if ( $ui -> id ( 'id' , 10 , 'get' )) {
$page_id = $ui -> id ( 'id' , 10 , 'get' );
} else if ( isset ( $page_name ) and $page_name != szrp ( $page_sprache -> older ) and isset ( $page_name ) and $page_name != '' and $page_name != null and $page_name != false ) {
2013-09-29 15:29:58 +02:00
$pagesAvailable = array ();
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT p.`id`,t.`title` FROM `page_pages` p LEFT JOIN `page_pages_text` t ON p.`id`=t.`pageid` WHERE `type`='news' AND t.`language`=? AND p.`released`=1 AND p.`resellerid`=0 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $user_language ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2013-10-05 13:39:56 +02:00
$pagesAvailable [ szrp ( $row [ 'title' ])] = $row [ 'id' ];
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
if ( array_key_exists ( strtolower ( $page_name ), $pagesAvailable )) {
2013-10-13 11:42:31 +02:00
$page_id = $pagesAvailable [ strtolower ( $page_name )];
2013-08-28 22:47:04 +02:00
}
}
2014-01-03 22:08:11 +01:00
2014-01-09 13:11:09 +01:00
if (( isset ( $page_name ) and $page_name != szrp ( $page_sprache -> older ) and isset ( $page_id ) and is_numeric ( $page_id )) or $ui -> id ( 'id' , 10 , 'get' )) {
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
$query = $sql -> prepare ( " SELECT p.`date`,p.`comments`,p.`authorname`,t.`id` AS `textID`,t.`title`,t.`text`,t.`id`,t.`language` FROM `page_pages` p LEFT JOIN `page_pages_text` t ON p.`id`=t.`pageid` WHERE p.`id`=? AND `type`='news' AND t.`language`=? AND p.`released`='1' AND p.`resellerid`=0 LIMIT 1 " );
2013-09-29 15:29:58 +02:00
$query2 = $sql -> prepare ( " SELECT t.`name`,t.`type` FROM `page_terms_used` u LEFT JOIN `page_terms` t ON u.`term_id`=t.`id` WHERE u.`language_id`=? AND u.`resellerid`='0' ORDER BY t.`name` DESC " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $page_id , $user_language ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$page_keywords = array ();
$allTags = array ();
$allCategories = array ();
2014-01-03 22:08:11 +01:00
2014-02-15 12:57:05 +01:00
$page_data -> title = $row [ 'title' ];
2014-01-03 22:08:11 +01:00
$page_title = $row [ 'title' ];
$page_text = nl2br ( $row [ 'text' ]);
2013-10-13 11:42:31 +02:00
$comments = $row [ 'comments' ];
$authorname = $row [ 'authorname' ];
$textID = $row [ 'textID' ];
2013-08-28 22:47:04 +02:00
$query2 -> execute ( array ( $textID ));
2014-01-03 22:08:11 +01:00
2014-11-30 12:55:07 +01:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
$page_data -> AddData ( 'keywords' , $row2 [ 'name' ]);
2014-01-03 22:08:11 +01:00
2014-02-23 13:13:48 +01:00
if ( $seo == 'Y' and $row2 [ 'type' ] == 'tag' ) {
2013-10-26 11:59:03 +02:00
$tagLink = $page_url . '/' . $user_language . '/' . szrp ( $page_sprache -> tag ) . '/' . szrp ( $row2 [ 'name' ]) . '/' ;
2013-10-03 12:49:13 +02:00
} else if ( $row2 [ 'type' ] == 'tag' ) {
2013-10-13 11:42:31 +02:00
$tagLink = $page_url . '/index.php?site=tag&tag=' . szrp ( $row2 [ 'name' ]);
2014-02-23 13:13:48 +01:00
} else if ( $seo == 'Y' and $row2 [ 'type' ] == 'category' ) {
2013-10-26 11:59:03 +02:00
$categoryLink = $page_url . '/' . $user_language . '/' . szrp ( $page_sprache -> categories ) . '/' . szrp ( $row2 [ 'name' ]) . '/' ;
2013-10-03 12:49:13 +02:00
} else if ( $row2 [ 'type' ] == 'category' ) {
2013-10-13 11:42:31 +02:00
$categoryLink = $page_url . '/index.php?site=categories&tag=' . szrp ( $row2 [ 'name' ]);
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
if ( $row2 [ 'type' ] == 'tag' ) {
2013-10-10 08:06:37 +02:00
$allTags [] = array ( 'name' => $row2 [ 'name' ], 'link' => $tagLink , 'href' => '<a href="' . $tagLink . '">' . $row2 [ 'name' ] . '</a>' );
2013-10-03 12:49:13 +02:00
} else if ( $row2 [ 'type' ] == 'category' ) {
2013-10-10 08:06:37 +02:00
$allCategories [] = array ( 'name' => $row2 [ 'name' ], 'link' => $categoryLink , 'href' => '<a href="' . $categoryLink . '">' . $row2 [ 'name' ] . '</a>' );
2013-08-28 22:47:04 +02:00
}
}
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
$pageLanguage = $row [ 'language' ];
2014-01-03 22:08:11 +01:00
$date = ( $pageLanguage == 'de' ) ? date ( 'd.m.Y' , strtotime ( $row [ 'date' ])) : date ( 'm.d.Y' , strtotime ( $row [ 'date' ]));
2013-08-28 22:47:04 +02:00
}
2013-09-07 11:31:00 +02:00
// https://github.com/easy-wi/developer/issues/62
2013-09-29 15:29:58 +02:00
$langLinks = array ();
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT `title`,`language` FROM `page_pages_text` WHERE `pageid`=? " );
2013-09-07 11:31:00 +02:00
$query -> execute ( array ( $page_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-03 22:08:11 +01:00
$tempLanguage = getlanguagefile ( 'general' , $row [ 'language' ], 0 );
$langLinks [ $row [ 'language' ]] = ( $page_data -> seo == 'Y' ) ? szrp ( $tempLanguage -> news ) . '/' . szrp ( $row [ 'title' ]) : '?s=news&id=' . $page_id ;
2013-09-07 11:31:00 +02:00
}
2014-01-12 10:51:51 +01:00
2013-09-07 11:31:00 +02:00
$page_data -> langLinks ( $langLinks );
2013-08-28 22:47:04 +02:00
if ( isset ( $textID ) or isset ( $comments )) {
2014-01-16 21:02:06 +01:00
2013-09-29 15:29:58 +02:00
$email = '' ;
$author = '' ;
$url = '' ;
$comment = '' ;
2013-10-03 12:49:13 +02:00
if ( isset ( $comments ) and $comments == 'Y' ) {
2014-01-16 21:02:06 +01:00
2013-10-13 13:11:38 +02:00
if ( $ui -> escaped ( 'comment' , 'post' )) {
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
$comment = $ui -> escaped ( 'comment' , 'post' );
2014-01-03 22:08:11 +01:00
2014-01-16 21:02:06 +01:00
if ( strlen ( $ui -> escaped ( 'comment' , 'post' )) <= $commentMinLength ) {
2013-10-03 12:49:13 +02:00
$error = true ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-10-13 13:11:38 +02:00
if ( ! isset ( $admin_id ) and ! isset ( $user_id )){
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
$email = $ui -> ismail ( 'email' , 'post' );
2014-01-03 22:08:11 +01:00
$author = $ui -> names ( 'author' , 255 , 'post' );
2014-01-16 21:02:06 +01:00
if ( $mailRequired == 'Y' and ! $ui -> ismail ( 'email' , 'post' )) {
2013-10-03 12:49:13 +02:00
$error = true ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
if ( ! $ui -> names ( 'author' , 255 , 'post' )) {
2013-10-03 12:49:13 +02:00
$error = true ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
} else {
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT `cname`,`mail` FROM `userdata` WHERE `id`=? LIMIT 1 " );
2014-01-03 22:08:11 +01:00
$query -> execute ( array (( isset ( $admin_id )) ? $admin_id : $user_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2013-10-13 11:42:31 +02:00
$author = $row [ 'cname' ];
$email = $row [ 'mail' ];
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
if ( ! isset ( $error )) {
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
$isSpam = 'N' ;
2014-01-03 22:08:11 +01:00
$comment = '' ;
$posted = true ;
$replyTo = $ui -> id ( 'replyTo' , 19 , 'post' );
2013-10-13 11:42:31 +02:00
if ( $ui -> url ( 'url' , 'post' )) {
$url = $ui -> url ( 'url' , 'post' );
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
if ( $ui -> domain ( 'url' , 'post' )) {
2014-01-12 10:51:51 +01:00
$url = 'http://' . $ui -> domain ( 'url' , 'post' );
2013-08-28 22:47:04 +02:00
}
2014-01-12 10:51:51 +01:00
if ( isset ( $spamFilter ) and $spamFilter != 'Y' ) {
$spamArray = checkForSpam ();
2014-01-03 22:08:11 +01:00
2014-01-12 10:51:51 +01:00
if ( count ( $spamArray ) > 0 ) {
$isSpam = 'Y' ;
} else {
2014-01-03 22:08:11 +01:00
2014-01-12 10:51:51 +01:00
$spamArray = checkForSpam ( $url );
2014-01-03 22:08:11 +01:00
2014-01-16 21:02:06 +01:00
if ( count ( $spamArray ) > 0 ) {
2014-01-12 10:51:51 +01:00
$isSpam = 'Y' ;
}
2013-08-28 22:47:04 +02:00
}
2014-01-16 21:02:06 +01:00
} else {
$spamArray = array ();
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
$spamReason = implode ( ', ' , $spamArray );
if ( isset ( $commentsModerated ) and $commentsModerated == 'Y' and ( ! isset ( $admin_id ) and ! isset ( $user_id ))) {
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " INSERT INTO `page_comments` (`date`,`moderateAccepted`,`pageTextID`,`replyTo`,`authorname`,`homepage`,`comment`,`ip`,`dns`,`markedSpam`,`spamReason`,`email`) VALUES (NOW(),'N',?,?,?,?,?,?,?,?,?,?) " );
2014-01-16 21:02:06 +01:00
$query -> execute ( array ( $textID , $replyTo , $author , $url , $ui -> escaped ( 'comment' , 'post' ), $ui -> ip ( 'REMOTE_ADDR' , 'server' ), gethostbyaddr ( $ui -> ip4 ( 'REMOTE_ADDR' , 'server' )), $isSpam , $spamReason , $email ));
2014-01-03 22:08:11 +01:00
2013-10-05 13:39:56 +02:00
$_SESSION [ 'toBeModerated' ][] = $sql -> lastInsertId ();
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " INSERT INTO `page_comments` (`date`,`moderateAccepted`,`pageTextID`,`replyTo`,`authorname`,`homepage`,`comment`,`ip`,`dns`,`markedSpam`,`spamReason`,`email`) VALUES (NOW(),'Y',?,?,?,?,?,?,?,?,?,?) " );
2014-01-16 21:02:06 +01:00
$query -> execute ( array ( $textID , $replyTo , $author , $url , $ui -> escaped ( 'comment' , 'post' ), $ui -> ip ( 'REMOTE_ADDR' , 'server' ), gethostbyaddr ( $ui -> ip4 ( 'REMOTE_ADDR' , 'server' )), $isSpam , $spamReason , $email ));
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
}
}
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$commentArray = array ();
2014-01-03 22:08:11 +01:00
$token = md5 ( passwordgenerate ( 10 ));
$_SESSION [ 'news' ][ $textID ] = $token ;
2013-09-29 15:29:58 +02:00
$OR = '' ;
2014-01-03 22:08:11 +01:00
2014-01-16 21:02:06 +01:00
if ( isset ( $_SESSION [ 'toBeModerated' ]) and count ( $_SESSION [ 'toBeModerated' ]) > 0 ) {
2013-08-28 22:47:04 +02:00
foreach ( $_SESSION [ 'toBeModerated' ] as $id ) {
2014-01-16 21:02:06 +01:00
if ( isid ( $id , 19 )) {
$OR .= ' OR `commentID`=' . $id ;
2013-08-28 22:47:04 +02:00
}
}
}
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT `commentID`,`replyTo`,`date`,`authorname`,`homepage`,`comment` FROM `page_comments` WHERE `pageTextID`=? AND ((`markedSpam`!='Y' AND `moderateAccepted`='Y') $OR ) AND `resellerid`=0 ORDER BY `replyTo` DESC,`commentID` DESC " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $textID ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-16 21:02:06 +01:00
$commentDate = ( isset ( $pageLanguage ) and $pageLanguage == 'de' ) ? date ( 'd.m.Y H:i' , strtotime ( $row [ 'date' ])) : date ( 'm.d.Y H:i' , strtotime ( $row [ 'date' ]));
2013-10-10 08:06:37 +02:00
$commentArray [] = array ( 'commentID' => $row [ 'commentID' ], 'replyTo' => $row [ 'replyTo' ], 'homepage' => $row [ 'homepage' ], 'date' => $commentDate , 'author' => htmlentities ( $row [ 'authorname' ]), 'comment' => htmlentities ( $row [ 'comment' ]));
2013-08-28 22:47:04 +02:00
}
}
2014-01-03 22:08:11 +01:00
$page_data -> setCanonicalUrl ( $s , $textID );
2013-09-29 15:29:58 +02:00
$template_file = 'page_news_single.tpl' ;
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$template_file = 'page_404.tpl' ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
} else if ( isset ( $page_name ) and $page_name != szrp ( $page_sprache -> older ) and isset ( $page_name ) and $page_name != '' and $page_name != null and $page_name != false and ! isset ( $page_id ) and $ui -> smallletters ( 'preview' , 4 , 'get' ) != 'true' ) {
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$template_file = 'page_404.tpl' ;
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
} else if ( isset ( $admin_id ) and $ui -> smallletters ( 'preview' , 4 , 'get' ) == 'true' ) {
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
if ( is_array ( $ui -> escaped ( 'text' , 'post' )) or is_object ( $ui -> escaped ( 'text' , 'post' ))) {
2014-02-15 12:57:05 +01:00
2013-10-13 11:42:31 +02:00
foreach ( $ui -> escaped ( 'text' , 'post' ) as $key => $value ) {
$page_title = $ui -> htmlcode ( 'title' , 'post' , $key );
2014-02-15 12:57:05 +01:00
$page_data -> title = $ui -> htmlcode ( 'title' , 'post' , $key );
$page_text = nl2br ( $value );
2013-08-28 22:47:04 +02:00
}
2014-02-15 12:57:05 +01:00
2013-08-28 22:47:04 +02:00
} else {
2014-02-15 12:57:05 +01:00
2013-10-13 11:42:31 +02:00
$page_title = $ui -> escaped ( 'title' , 'post' );
2014-02-15 12:57:05 +01:00
$page_data -> title = $ui -> escaped ( 'title' , 'post' );
2013-10-13 11:42:31 +02:00
$page_text = nl2br ( $ui -> escaped ( 'text' , 'post' ));
2014-02-15 12:57:05 +01:00
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$allTags = array ();
$allCategories = array ();
$comments = array ();
$category_tags = array ();
$tag_tags = array ();
2014-01-03 22:08:11 +01:00
$template_file = ( isset ( $page_title )) ? 'page_news_single.tpl' : 'page_404.tpl' ;
2014-01-09 13:11:09 +01:00
} else {
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$news = array ();
$category_tags = array ();
$tag_tags = array ();
$allTags = array ();
$allCategories = array ();
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT COUNT(p.`id`) AS `amount` FROM `page_pages` p LEFT JOIN `page_pages_text` t ON p.`id`=t.`pageid` WHERE p.`released`='1' AND p.`type`='news' AND t.`language`=? AND p.`resellerid`=0 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $user_language ));
2013-10-13 11:42:31 +02:00
$totalCount = $query -> fetchColumn ();
2014-01-03 22:08:11 +01:00
$pagesCount = ceil ( $totalCount / $maxnews );
if ( isset ( $page_name ) and $page_name == szrp ( $page_sprache -> older ) and ( isset ( $page_count ) and isid ( $page_count , 255 )) or ( $ui -> id ( 'start' , 255 , 'get' ))) {
2014-01-09 13:11:09 +01:00
if ( $ui -> id ( 'start' , 255 , 'get' ) and $ui -> id ( 'start' , 255 , 'get' ) <= $pagesCount ) {
2014-01-03 22:08:11 +01:00
$pageOpen = $ui -> id ( 'start' , 255 , 'get' );
} else if ( isset ( $page_count ) and $page_count <= $pagesCount ) {
2013-10-13 11:42:31 +02:00
$pageOpen = $page_count ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$pageOpen = $pagesCount ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
$startLooking = $pageOpen * $maxnews ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
if ( ! isset ( $startLooking ) or $startLooking < 0 ) {
2013-09-29 15:29:58 +02:00
$startLooking = 0 ;
2013-08-28 22:47:04 +02:00
}
2014-01-16 21:02:06 +01:00
2014-01-03 22:08:11 +01:00
if ( ! isset ( $pageOpen ) or $pageOpen < 0 ) {
2013-09-29 15:29:58 +02:00
$pageOpen = 0 ;
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT p.`id`,p.`date`,p.`comments`,p.`authorname`,t.`id` AS `textID`,t.`title`,t.`text`,t.`language` FROM `page_pages` p LEFT JOIN `page_pages_text` t ON p.`id`=t.`pageid` WHERE p.`released`='1' AND p.`type`='news' AND t.`language`=? AND p.`resellerid`=0 ORDER BY `date` DESC LIMIT $startLooking , $maxnews " );
$query2 = $sql -> prepare ( " SELECT t.`name`,t.`type` FROM `page_terms_used` u LEFT JOIN `page_terms` t ON u.`term_id`=t.`id` WHERE u.`language_id`=? AND u.`resellerid`=0 ORDER BY t.`name` DESC " );
$query3 = $sql -> prepare ( " SELECT COUNT(`commentID`) as `amount` FROM `page_comments` WHERE `pageTextID`=? AND `resellerID`=0 " );
2014-01-16 21:02:06 +01:00
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $user_language ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-03 22:08:11 +01:00
2013-10-13 11:42:31 +02:00
$page_title = $row [ 'title' ];
2014-01-03 22:08:11 +01:00
$page_text = nl2br ( $row [ 'text' ]);
if ( $seo == 'Y' ) {
$link = $page_url . '/' . $user_language . '/' . szrp ( $gsprache -> news ) . '/' . szrp ( $row [ 'title' ]) . '/' ;
2013-08-28 22:47:04 +02:00
} else {
2014-01-03 22:08:11 +01:00
$link = $page_url . '/index.php?site=news&id=' . $row [ 'id' ];
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
$href = '<a href="' . $link . '">' . $row [ 'title' ] . '</a>' ;
2013-08-28 22:47:04 +02:00
$query2 -> execute ( array ( $row [ 'textID' ]));
2014-11-30 12:55:07 +01:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
$page_data -> AddData ( 'keywords' , $row2 [ 'name' ]);
2014-01-03 22:08:11 +01:00
if ( $page_data -> seo == 'Y' and $row2 [ 'type' ] == 'tag' ) {
2013-10-26 11:59:03 +02:00
$tagLink = $page_url . '/' . $user_language . '/' . szrp ( $page_sprache -> tag ) . '/' . szrp ( $row2 [ 'name' ]) . '/' ;
2013-10-03 12:49:13 +02:00
} else if ( $row2 [ 'type' ] == 'tag' ) {
2013-10-13 11:42:31 +02:00
$tagLink = $page_url . '/index.php?site=tag&tag=' . szrp ( $row2 [ 'name' ]);
2014-02-23 13:13:48 +01:00
} else if ( $seo == 'Y' and $row2 [ 'type' ] == 'category' ) {
2013-10-26 11:59:03 +02:00
$categoryLink = $page_url . '/' . $user_language . '/' . szrp ( $page_sprache -> categories ) . '/' . szrp ( $row2 [ 'name' ]) . '/' ;
2013-10-03 12:49:13 +02:00
} else if ( $row2 [ 'type' ] == 'category' ) {
2014-01-03 22:08:11 +01:00
$categoryLink = $page_url . '/index.php?site=categories&tag=' . szrp ( $row2 [ 'name' ]);
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
$page_data -> AddData ( 'keywords' , $row2 [ 'name' ]);
2014-01-03 22:08:11 +01:00
2013-10-03 12:49:13 +02:00
if ( $row2 [ 'type' ] == 'tag' ) {
2014-01-03 22:08:11 +01:00
$allTags [] = array ( 'name' => $row2 [ 'name' ], 'link' => $tagLink , 'href' => '<a href="' . $tagLink . '">' . $row2 [ 'name' ] . '</a>' );
$tag_tags [] = array ( 'name' => $row2 [ 'name' ], 'link' => $tagLink , 'href' => '<a href="' . $tagLink . '">' . $row2 [ 'name' ] . '</a>' );
2013-10-03 12:49:13 +02:00
} else if ( $row2 [ 'type' ] == 'category' ) {
2014-01-03 22:08:11 +01:00
$allCategories [] = array ( 'name' => $row2 [ 'name' ], 'link' => $categoryLink , 'href' => '<a href="' . $categoryLink . '">' . $row2 [ 'name' ] . '</a>' );
$category_tags [] = array ( 'name' => $row2 [ 'name' ], 'link' => $categoryLink , 'href' => '<a href="' . $categoryLink . '">' . $row2 [ 'name' ] . '</a>' );
2013-08-28 22:47:04 +02:00
}
}
2014-01-03 22:08:11 +01:00
$date = ( $row [ 'language' ] == 'de' ) ? date ( 'd.m.Y' , strtotime ( $row [ 'date' ])) : date ( 'm.d.Y' , strtotime ( $row [ 'date' ]));
2013-10-03 12:49:13 +02:00
if ( $row [ 'comments' ] == 'Y' ) {
2013-08-28 22:47:04 +02:00
$query3 -> execute ( array ( $row [ 'textID' ]));
2013-10-13 11:42:31 +02:00
$commentCount = $query3 -> fetchColumn ();
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$commentCount = 0 ;
2013-08-28 22:47:04 +02:00
}
2013-10-10 08:06:37 +02:00
$news [] = array ( 'date' => $date , 'title' => $page_title , 'text' => $page_text , 'href' => $href , 'link' => $link , 'tags' => $tag_tags , 'categories' => $category_tags , 'comments' => $row [ 'comments' ], 'commentCount' => $commentCount , 'authorname' => $row [ 'authorname' ]);
2013-08-28 22:47:04 +02:00
}
2014-01-03 22:08:11 +01:00
$paginationLink = ( $page_data -> seo == 'Y' ) ? $page_url . '/' . $user_language . '/' . szrp ( $gsprache -> news ) . '/' . szrp ( $page_sprache -> older ) . '/' : $page_url . '/index.php?site=news&start=' ;
2013-09-07 11:31:00 +02:00
// https://github.com/easy-wi/developer/issues/62
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$langLinks = array ();
2014-01-03 22:08:11 +01:00
2013-09-07 11:31:00 +02:00
foreach ( $languages as $l ) {
2014-01-03 22:08:11 +01:00
$tempLanguage = getlanguagefile ( 'general' , $l , 0 );
$langLinks [ $l ] = ( $page_data -> seo == 'Y' ) ? szrp ( $tempLanguage -> news ) : '?s=news' ;
2013-09-07 11:31:00 +02:00
}
2014-01-03 22:08:11 +01:00
$page_data -> langLinks ( $langLinks );
2014-02-15 12:57:05 +01:00
$page_data -> title = $gsprache -> news ;
2013-08-28 22:47:04 +02:00
$page_data -> setCanonicalUrl ( $s );
2014-01-03 22:08:11 +01:00
2013-09-29 15:29:58 +02:00
$template_file = 'page_news.tpl' ;
2014-01-03 22:08:11 +01:00
2013-08-28 22:47:04 +02:00
}