PageRenderTime 134ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/newssystem/index.php

http://flaimo-php.googlecode.com/
PHP | 608 lines | 494 code | 75 blank | 39 comment | 165 complexity | 26df57702f3ddf735cdcab2352a24e5d MD5 | raw file
  1. <?php
  2. ob_start('ob_gzhandler');
  3. ini_set('arg_separator.output','&#38;');
  4. ini_set('session.use_trans_sid','0');
  5. putenv('TZ=CET');
  6. header('Content-Encoding: gzip');
  7. header('Cache-Control: must-revalidate');
  8. header('Expires: ' . date("D, d M Y H:i:s", time() + (60 * 60 * 20)) . ' GMT');
  9. /*----------------*/
  10. /* C L A S S E S */
  11. /*----------------*/
  12. require_once('Smarty.class.php');
  13. require_once('functions.inc.php');
  14. require_once('class.ChooseLanguage.inc.php');
  15. require_once('class.FormatLongString.inc.php');
  16. require_once('class.ChooseFormatDate.inc.php');
  17. require_once('class.Newslist.inc.php');
  18. require_once('class.Helpers.inc.php');
  19. require_once('class.Author.inc.php');
  20. require_once('class.AuthorList.inc.php');
  21. require_once('class.CategoryList.inc.php');
  22. require_once('class.NewsUser.inc.php');
  23. $tpl = (object) new Smarty;
  24. $tpl->left_delimiter = (string) '{{';
  25. $tpl->right_delimiter = (string) '}}';
  26. $tpl->template_dir = (string) 'tpl';
  27. $tpl->compile_dir = (string) 'tpl_c';
  28. $tpl->config_dir = (string) 'conf';
  29. //$tpl->compile_check = (boolean) false; // Wenn Template fertig ist kommentar weg...
  30. $tpl->cache_dir = (string) 'cache';
  31. $tpl->cache_lifetime = (0);
  32. //$tpl->caching = (boolean) true; // Nur einschalten wenn redundante Seite (also kein "dynamischer" Inhalt)$tpl->cache_dir = (string) 'cache';
  33. /*-------------------------------------*/
  34. /* C O O K I E S + S E S S I O N S */
  35. /*-------------------------------------*/
  36. session_start();
  37. $user = (object) new NewsUser();
  38. define('LASTVISIT',$user->getLastVisit()); //Cookie bzw Session um neue Beitrage als NEU zu kennzeichnen (ist aber unter Win buggy (timezone))
  39. $user->setLastVisit();
  40. /*-------------------------------*/
  41. /* V A R I A B L E N (berechnen) */
  42. /*-------------------------------*/
  43. define('PICTUREPATH','pics/'); // Relativer Pfad zu den Newsbildern
  44. define('SHOW_RS',10); // Anzahl der News die pro Seite angezeigt werden sollen
  45. define('NOW',date('Y-m-d H:i:s'));
  46. define('NOW_TIMESTAMP',time());
  47. define('PHP_SELF',$_SERVER['PHP_SELF']);
  48. $tpl->assign('PHP_SELF',PHP_SELF);
  49. if (isset($_GET['cat'])) {
  50. define('CAT',$_GET['cat']);
  51. }
  52. if (isset($_POST['author'])) {
  53. define('AUTHOR',$_POST['author']);
  54. }
  55. if (isset($_POST['cat_search'])) {
  56. define('CAT_SEARCH',$_POST['cat_search']);
  57. }
  58. if (isset($_GET['profile'])) {
  59. define('PROFILE',$_GET['profile']);
  60. }
  61. if (isset($_POST['search']) && strlen(trim($_POST['search'])) > 0) {
  62. $search = (string) $_POST['search'];
  63. }
  64. elseif (isset($_GET['search']) && strlen(trim($_GET['search'])) > 0) {
  65. $search = (string) urldecode($_GET['search']);
  66. }
  67. if (isset($search)) {
  68. $searchstring_temp = (string) $search;
  69. define('SEARCHSTRING',htmlentities($search));
  70. } else {
  71. $searchstring_temp = (string) '';
  72. define('SEARCHSTRING','');
  73. }
  74. $lg = (object) new ChooseLanguage('','');
  75. $sp = (object) new FormatLongString($searchstring_temp);
  76. $dp = (object) new ChooseFormatDate();
  77. $helpers = (object) new Helpers();
  78. $sp->SetSessionURL(session_name(),session_id());
  79. // $language_select->lang_content
  80. define('LANG_ISO',str_replace('_','-',$lg->getLang()));
  81. $tpl->assign('LANG_ISO',LANG_ISO);
  82. define('HIGHLIGHT',$sp->SetURLencoder('search',urlencode($searchstring_temp),'&'));
  83. define('SESSIONID',$sp->SetURLencoder(session_name(),session_id(),'&#38;'));
  84. defined('CAT') ? define('LISTCAT',$sp->SetURLencoder('cat',CAT,'&#38;')) : define('LISTCAT','');
  85. (defined('CAT') && !isset($search)) ? define('ONLY_CAT','?cat=' . CAT) : define('ONLY_CAT','');
  86. if (isset($_POST['id'])) {
  87. $id = (int) $_POST['id'];
  88. }
  89. elseif (isset($_GET['id'])) {
  90. $id = (int) $_GET['id'];
  91. }
  92. define('ONLY_ID',((isset($id)) ? '?id=' . $id : ''));
  93. /* Startpunkt f?r Auflistung */
  94. if (isset($_POST['startlisting'])) {
  95. $startlisting = (int) $_POST['startlisting'];
  96. }
  97. elseif (isset($_GET['startlisting'])) {
  98. $startlisting = (int) $_GET['startlisting'];
  99. }
  100. if (!isset($startlisting) || $startlisting < 0) { // Falls kein Startwert f?r Weiter/Zur?ck Links gegeben bei 0 anfangen
  101. define('STARTLISTING',0);
  102. }
  103. elseif ($startlisting > SUM_NEWS) { // Falls Startwert gr??er als die Anzahl and Datens?tzen
  104. define('STARTLISTING',(SUM_NEWS - SHOW_RS));
  105. } else {
  106. define('STARTLISTING',$startlisting);
  107. }
  108. if (isset($startlisting)) {
  109. unset($startlisting);
  110. }
  111. /*---------------------------------------*/
  112. /* D B A B F R A G E D E R N E W S */
  113. /*---------------------------------------*/
  114. if (isset($id) && is_int($id) && $id != 0) { // Auswahl der Abfrage zur Darstellung der News gesamt, Kategorie oder ID Nummer
  115. $newslist = new NewsList('onenews', STARTLISTING, SHOW_RS, $id, '', '', '');
  116. }
  117. elseif (defined('CAT')) {
  118. $newslist = new NewsList('category', STARTLISTING, SHOW_RS, CAT, '', '', '');
  119. }
  120. elseif (isset($search)) {
  121. $newslist = new NewsList('search', 0, 0, 0, AUTHOR, $search, CAT_SEARCH);
  122. } else {
  123. $newslist = new NewsList('all', STARTLISTING, SHOW_RS, $id, '', '', '');
  124. } // end if
  125. define('SUM_NEWS',count($newslist->getNewsListCountAll()));
  126. $tpl->assign_by_ref('PAGE_TITLE',$lg->__('newssystem_title'));
  127. $tpl->assign('META_EXPIRES',gmdate("D, d M Y H:i:s", time() + (60 * 60 * 20)));
  128. $tpl->assign_by_ref('LANG_MENU_TITLE',$lg->__('menu'));
  129. $tpl->assign('PICTURE_PATH',PICTUREPATH);
  130. /*---------*/
  131. /* M E N ? */
  132. /*---------*/
  133. $categorylist = (object) new CategoryList($lg->getLangContent());
  134. $tpl->assign('COUNT_CATEGORIES',count($categorylist->getCategoryList()));
  135. foreach ($categorylist->getCategoryList() as $name => $value) {
  136. $values = (array) explode('_', $value);
  137. if (defined('CAT') && CAT == $values[0]) {
  138. $cat_name = (string) $name;
  139. }
  140. if (defined('CAT_SEARCH') && CAT_SEARCH == $values[0]) {
  141. $cat_name = (string) $name;
  142. }
  143. $CategoryName = (string) $sp->FormatShortText($name);
  144. $menu_cat_nr[] = $values[0];
  145. $menu_cat_name[] = $sp->FormatShortText($name);
  146. $menu_cat_count[] = $values[1];
  147. } // end foreach
  148. if (isset($sum_cat_news)) {
  149. unset($sum_cat_news);
  150. }
  151. $tpl->assign('MENU_CAT_NR',$menu_cat_nr);
  152. $tpl->assign('MENU_CAT_NAME',$menu_cat_name);
  153. $tpl->assign('MENU_CAT_COUNT',$menu_cat_count);
  154. $tpl->assign_by_ref('FORM_SEARCH',$lg->__('search'));
  155. $tpl->assign_by_ref('FORM_KEYWORD',$lg->__('form_keyword'));
  156. $tpl->assign('FORM_SEARCHSTRING',SEARCHSTRING);
  157. $tpl->assign('FORM_ADV_SEARCH',((isset($_GET['advsearch'])) ? 1 : 0));
  158. $tpl->assign_by_ref('FORM_CATEGORY',$lg->__('form_category'));
  159. $tpl->assign_by_ref('FORM_ALL',$lg->__('form_all'));
  160. $tpl->assign('FORM_CAT_SEARCH',CAT_SEARCH);
  161. $tpl->assign_by_ref('FORM_AUTHOR',$lg->__('form_author'));
  162. $authorlist = (object) new AuthorList();
  163. $author_keys = (array) array_keys($authorlist->getAuthorList());
  164. foreach ($author_keys as $authorID) {
  165. $author =& $authorlist->getAuthor($authorID);
  166. if ($author->getCountArticles() > 0) {
  167. $menu_author_nr[] = $author->getAuthorID();
  168. $menu_author_name[] = $sp->FormatShortText($author->getAuthorName());
  169. $menu_author_count[] = $author->getCountArticles();
  170. } // end if
  171. } // end foreach
  172. if (isset($author)) {
  173. unset($author);
  174. }
  175. if (isset($author_keys)) {
  176. unset($author_keys);
  177. }
  178. $tpl->assign('MENU_AUTHOR_NR',$menu_author_nr);
  179. $tpl->assign('MENU_AUTHOR_NAME',$menu_author_name);
  180. $tpl->assign('MENU_AUTHOR_COUNT',$menu_author_count);
  181. $tpl->assign('STARTLISTING',STARTLISTING);
  182. $tpl->assign('SESSION_NAME',session_name());
  183. $tpl->assign('SESSION_ID',session_id());
  184. $tpl->assign_by_ref('FORM_SEARCH_BUTTON',$lg->__('form_search'));
  185. $tpl->assign_by_ref('ADV_SEARCH_LINK',$lg->__('advanced_search'));
  186. $tpl->assign_by_ref('FORM_LANGUAGE',ucfirst($lg->__('language')));
  187. $tpl->assign_by_ref('FORM_OSM',ucfirst($lg->__('OSM')));
  188. $tpl->assign('FORM_DROPDOWN_LANG',$lg->returnDropdownLang());
  189. $tpl->assign_by_ref('FORM_LANGUAGE_CONTENT',ucfirst($lg->__('Content')));
  190. $tpl->assign('FORM_DROPDOWN_LANG_CONTENT',$lg->returnDropdownLangContent());
  191. $tpl->assign_by_ref('FORM_TIME',ucfirst($lg->__('time')));
  192. $tpl->assign('FORM_DROPDOWN_TIME',$dp->returnDropdownSelecttime());
  193. $tpl->assign_by_ref('FORM_CHANGE',$lg->__('Change'));
  194. $tpl->assign('SUM_ALL_NEWS',$helpers->getSumNews());
  195. $tpl->assign_by_ref('LANG_NEWS',$lg->__('news'));
  196. $tpl->assign('SUM_ALL_COMMENTS',$helpers->getSumComments());
  197. $tpl->assign_by_ref('LANG_COMMENTS',$lg->__('comments'));
  198. $tpl->assign('USER_ONLINE',user_online24());
  199. $tpl->assign_by_ref('LANG_USER_ONLINE',$lg->__('user_online'));
  200. $tpl->assign_by_ref('LANG_TIMEZONE_IS',$lg->__('timezone_is'));
  201. $tpl->assign_by_ref('LANG_SWATCHTIME',$lg->__('swatch_time'));
  202. if (isset($helpers)) {
  203. unset($helpers);
  204. }
  205. if ($dp->GetTimeset() == 1) { // Falls swatch Zeit
  206. $tpl->assign('TIMEZONE_LINK','http://www.swatch.com/alu_beat/fs_itime.html');
  207. $tpl->assign('TIMEZONE','BMT');
  208. $tpl->assign_by_ref('LANG_TIMEZONE',$lg->__('swatch_time'));
  209. $tpl->assign('TIMEZONE_DATE',$dp->swatchdate());
  210. $tpl->assign('TIMEZONE_TIME',$dp->swatchtime());
  211. }
  212. elseif ($dp->GetTimeset() == 2) {
  213. $tpl->assign('TIMEZONE_LINK','http://www.stacken.kth.se/~kvickers/timezone.html');
  214. $tpl->assign('TIMEZONE',getenv('TZ'));
  215. $tpl->assign_by_ref('LANG_TIMEZONE',$lg->__('ISO_time'));
  216. $tpl->assign('TIMEZONE_DATE',$dp->ShortDate());
  217. $tpl->assign('TIMEZONE_TIME',$dp->TimeString());
  218. } else {
  219. $tpl->assign('TIMEZONE_LINK','http://www.stacken.kth.se/~kvickers/timezone.html');
  220. $tpl->assign('TIMEZONE',getenv('TZ'));
  221. $tpl->assign_by_ref('LANG_TIMEZONE',$lg->__('time'));
  222. $tpl->assign('TIMEZONE_DATE',$dp->ShortDate());
  223. $tpl->assign('TIMEZONE_TIME',$dp->TimeString());
  224. } // end if
  225. $tpl->assign('RSS_LINK',$lg->getLangContent() . LISTCAT);
  226. /*---------------------------------*/
  227. /* A U S G A B E D E R N E W S */
  228. /*---------------------------------*/
  229. $tpl->assign('COUNT_NEWSLIST',count($newslist->getNewsList()));
  230. $tpl->assign('PROFILE_DEFINED',((defined('PROFILE')) ? 1 : 0));
  231. $tpl->assign('CAT_DEFINED',((defined('CAT')) ? 1 : 0));
  232. $tpl->assign('CATSEARCH_DEFINED',((defined('CAT_SEARCH')) ? 1 : 0));
  233. $tpl->assign('CATSEARCH_NOT_ALL',((CAT_SEARCH != 'all') ? 1 : 0));
  234. if (!defined('PROFILE')) { // Schleife zur Auflistung der News
  235. if (defined('CAT') || (defined('CAT_SEARCH') && CAT_SEARCH != 'all')) {
  236. $tpl->assign('CAT',CAT);
  237. $tpl->assign('DISPLAY_CAT_HEADER',$sp->FormatShortText($cat_name));
  238. } else {
  239. $tpl->assign('CAT','');
  240. $tpl->assign('DISPLAY_CAT_HEADER','');
  241. } // end if
  242. $tpl->assign('SEARCHTERM_DEFINED',((isset($search)) ? 1 : 0));
  243. $tpl->assign('NEWSID_DEFINED',((isset($id)) ? 1 : 0));
  244. $tpl->assign_by_ref('LANG_SEARCHRESULT_FOR',$lg->__('search_result_for'));
  245. $tpl->assign('SEARCHTERM',$sp->FormatShortText($search));
  246. $tpl->assign('SUM_NEWS',SUM_NEWS);
  247. $tpl->assign('LANG_NEWS_FOUND',$lg->__('news_found'));
  248. $tpl->assign_by_ref('LANG_NEWS_POSTED_BY',ucfirst($lg->__('posted_by')));
  249. $tpl->assign_by_ref('LANG_LINKS',ucfirst($lg->__('links')));
  250. $tpl->assign_by_ref('LANG_SOURCE',$lg->__('source'));
  251. $news_keys = (array) array_keys($newslist->getNewsList());
  252. foreach ($news_keys as $newsID) {
  253. $news =& $newslist->getNews($newsID);
  254. $css_color[] = $news->getCategoryID();
  255. $news_headline[] = $sp->FormatShortText($news->getHeadline());
  256. $author = (object) $news->getAuthor();
  257. $author_nick[] = $sp->FormatShortText($author->getAuthorName());
  258. $newsimage_alttext[] = $sp->FormatShortText($news->getImageAlttext());
  259. $no_comments[] = $news->getNoComments();
  260. $nocomments = (boolean) $news->getNoComments();
  261. $news_image[] = $news->getImage();
  262. $news_date[] = $dp->LongDate($dp->ISOdatetimeToUnixtimestamp($news->getNewsdate()));
  263. $author_id[] = $author->getAuthorID();
  264. $news_id[] = $news->getNewsID();
  265. if ((!defined('CAT') && !defined('CAT_SEARCH')) || (defined('CAT_SEARCH') && CAT_SEARCH == 'all')) {
  266. $category_name[] = $sp->FormatShortText($news->getCategoryName());
  267. } else {
  268. $category_name[] = '';
  269. } // end if
  270. if ((LASTVISIT != '') && (LASTVISIT < $news->getNewsdate())) {
  271. $news_new[] = '(' . strtoupper($lg->__('new')) . ')';
  272. } else {
  273. $news_new[] = '';
  274. } // end if
  275. if (isset($search)) {
  276. $news_text[] = $sp->SearchResult($news->getNewstext(), $news->getNewsID());
  277. }
  278. elseif (!isset($id)) { // Ausgabe Newstext
  279. $news_text[] = (($news->getShowFullText() != true) ? $sp->AbstractText($news->getNewstext(), $news->getNewsID()) : $sp->FormatLongText($news->getNewstext()));
  280. } else {
  281. $news_text[] = $sp->FormatLongText($news->getNewstext());
  282. } // end if
  283. $news_links_link_temp = array();
  284. $news_links_text_temp = array();
  285. if (count($news->getLinks()) > 0) { // Gibt Linkliste aus falls String vorhanden
  286. $show_links[] = 1;
  287. foreach ($news->getLinks() as $link => $linktext) {
  288. $news_links_link_temp[] = $link;
  289. $news_links_text_temp[] = $linktext;
  290. } // end foreach
  291. } else {
  292. $show_links[] = 0;
  293. } // end if
  294. $news_links_link[] = $news_links_link_temp;
  295. $news_links_text[] = $news_links_text_temp;
  296. $news_source_available[] = strlen(trim($news->getSource()));
  297. $news_source_link[] = $news->getSourceLink();
  298. $news_source[] = $news->getSource();
  299. if ((!isset($id)) && ($nocomments == false)) { // Anzeige der Anzahl von Kommentaren
  300. $commentlist =& $news->getComments();
  301. $count_comments[] = count($commentlist->getCommentList());
  302. if ($count_comments > 0) { // Gibt Namen der Kommentarautoren im title Tag aus.
  303. foreach ($commentlist->getAuthors() as $author) {
  304. $comment_link_title .= (string) $sp->FormatShortText($author) . ', ';
  305. } // foreach
  306. $news_comments_by[] = $lg->__('comments_by') . ' ' . substr($comment_link_title, 0, (strlen($comment_link_title)-2)); // Letztes Kosmma entfernen
  307. } else {
  308. $news_comments_by[] = '';
  309. }// end if
  310. $news_lang_comments[] = ((count($commentlist->getCommentList()) != 1) ? $lg->__('comments') : $lg->__('comment'));
  311. } // end if
  312. } // end if [count($newslist->getNewsList()) > 0 && !defined('PROFILE')]
  313. $tpl->assign('NEWS_SHOW_LINKS',$show_links);
  314. $tpl->assign('NEWS_CSS_COLOR',$css_color);
  315. $tpl->assign('NEWS_AUTHOR_NAME',$author_nick);
  316. $tpl->assign('NEWS_DATE',$news_date);
  317. $tpl->assign('NEWS_CAT_HEADER',$category_name);
  318. $tpl->assign('NEWS_AUTHOR_ID',$author_id);
  319. $tpl->assign('NEWS_HEADLINE',$news_headline);
  320. $tpl->assign('NEWS_LANG_NEW',$news_new);
  321. $tpl->assign('NEWS_IMAGE_ALTTEXT',$newsimage_alttext);
  322. $tpl->assign('NEWS_IMAGE',$news_image);
  323. $tpl->assign('NEWS_TEXT',$news_text);
  324. $tpl->assign('NEWS_SOURCE_AVAILABLE',$news_source_available);
  325. $tpl->assign('NEWS_LINKS_LINK',$news_links_link);
  326. $tpl->assign('NEWS_LINKS_TEXT',$news_links_text);
  327. $tpl->assign('NEWS_SOURCE_LINK',$news_source_link);
  328. $tpl->assign('NEWS_SOURCE',$news_source);
  329. $tpl->assign('NEWS_NO_COMMENTS',$no_comments);
  330. $tpl->assign('NEWS_ID',$news_id);
  331. $tpl->assign('HIGHLIGHT',HIGHLIGHT);
  332. $tpl->assign('NEWS_COMMENTS_COUNT',$count_comments);
  333. $tpl->assign('NEWS_COMMENTS_BY',$news_comments_by);
  334. $tpl->assign('NEWS_LANG_COMMENTS',$news_lang_comments);
  335. if (isset($show_links)) { unset($show_links); }
  336. if (isset($css_color)) { unset($css_color); }
  337. if (isset($author_nick)) { unset($author_nick); }
  338. if (isset($news_date)) { unset($news_date); }
  339. if (isset($category_name)) { unset($category_name); }
  340. if (isset($author_id)) { unset($author_id); }
  341. if (isset($news_headline)) { unset($news_headline); }
  342. if (isset($news_new)) { unset($news_new); }
  343. if (isset($newsimage_alttext)) { unset($newsimage_alttext); }
  344. if (isset($news_image)) { unset($news_image); }
  345. if (isset($news_text)) { unset($news_text); }
  346. if (isset($news_source_available)) { unset($news_source_available); }
  347. if (isset($news_links_link)) { unset($news_links_link); }
  348. if (isset($news_links_text)) { unset($news_links_text); }
  349. if (isset($news_source_link)) { unset($news_source_link); }
  350. if (isset($news_source)) { unset($news_source); }
  351. if (isset($no_comments)) { unset($no_comments); }
  352. if (isset($news_id)) { unset($news_id); }
  353. if (isset($count_comments)) { unset($count_comments); }
  354. if (isset($news_comments_by)) { unset($news_comments_by); }
  355. if (isset($news_lang_comments)) { unset($news_lang_comments); }
  356. /*---------------------------------------------------*/
  357. /* A U S G A B E V O N Z U R ? C K / W E I T E R */
  358. /*---------------------------------------------------*/
  359. $prevpage = (string) (($newslist->getPrevPage() == true) ? '&laquo;&laquo; <a href="' . PHP_SELF . $sp->SetURLencoder('startlisting',(STARTLISTING - SHOW_RS)) . LISTCAT . SESSIONID . '">' . $lg->__('back') . '</a> &laquo;&laquo;' : '&nbsp;');
  360. $nextpage = (string) (($newslist->getNextPage() == true) ? '&raquo;&raquo; <a href="' . PHP_SELF . $sp->SetURLencoder('startlisting',(STARTLISTING + SHOW_RS)) . LISTCAT . SESSIONID . '">' . $lg->__('next') . '</a> &raquo;&raquo;' : '&nbsp;');
  361. if (count($newslist->getPages()) > 0) {
  362. $listpages = (string) $lg->__('page') . ': ';
  363. foreach ($newslist->getPages() as $page => $startlisting) {
  364. $listpages .= (string) (((($page-1) * SHOW_RS) != STARTLISTING) ? '<a href="' . PHP_SELF . '?startlisting=' . $startlisting . LISTCAT . SESSIONID . '">' . $page . '</a> ' : $page . ' ');
  365. } // end foreach
  366. if (isset($page)) { unset($page); }
  367. if (isset($startlisting)) { unset($startlisting); }
  368. } else {
  369. $listpages = (string) '&nbsp;';
  370. } // end if
  371. $tpl->assign('PREV_PAGE',$prevpage);
  372. $tpl->assign('NEXT_PAGE',$nextpage);
  373. $tpl->assign('LIST_PAGES',$listpages);
  374. if (isset($prevpage)) { unset($prevpage); }
  375. if (isset($listpages)) { unset($listpages); }
  376. if (isset($nextpage)) { unset($nextpage); }
  377. $tpl->assign('SINGLE_NEWS',((isset($id) && is_int($id) && $id != 0) ? 1 : 0));
  378. /*-------------------------------------------*/
  379. /* N E X T / P R E V I O U S A R T I C L E */
  380. /*-------------------------------------------*/
  381. if (isset($id) && is_int($id) && $id != 0) {
  382. $prev_news = $news->getPreviousNews();
  383. if ($prev_news != false) {
  384. $tpl->assign('PREV_ARTICLE','&#171; <a href="' . PHP_SELF . '?id=' . $prev_news->getNewsID() . SESSIONID . '" title="' . $prev_news->getHeadline() . '">' . $lg->__('previous_newsarticle') . '</a>');
  385. } else {
  386. $tpl->assign('PREV_ARTICLE','&nbsp;');
  387. } // end if
  388. $next_news = $news->getNextNews();
  389. if ($next_news != false) {
  390. $tpl->assign('NEXT_ARTICLE','<a href="' . PHP_SELF . '?id=' . $next_news->getNewsID() . SESSIONID . '" title="' . $next_news->getHeadline() . '">' . $lg->__('next_newsarticle') . '</a> &#187;');
  391. } else {
  392. $tpl->assign('NEXT_ARTICLE','&nbsp;');
  393. } // end if
  394. if (isset($prev_news)) { unset($prev_news); }
  395. if (isset($next_news)) { unset($next_news); }
  396. /*---------------------*/
  397. /* K O M M E N T A R E */
  398. /*---------------------*/
  399. /* Eintragen von Kommentaren */
  400. if (isset($_POST['commentsend']) && $user->isCommentWritten($id) == false) { // ?berpr?fung des Formulares/Cookies und Eintragen eines Kommentars
  401. $tpl->assign_by_ref('ERROR_COMMENT',$lg->__('error_comment'));
  402. if ($news->insertComment($_POST['comment'], $_POST['name'], $_POST['email']) == false) {
  403. $tpl->assign_by_ref('ERROR_COMMENT',$lg->__('error_comment'));
  404. } else {
  405. $tpl->assign('ERROR_COMMENT','');
  406. }// end if
  407. } else {
  408. $tpl->assign('ERROR_COMMENT','');
  409. } // end if
  410. /* Markieren des Newseintrages, dass Kommentar geschrieben wurde */
  411. if (isset($_POST['commentsend'])) { // Setzt nach dem Absenden des Formulares ein Cookie f?r ein paar Minuten, dass ein erneutes Kommentar verhindert (Spam Schutz)
  412. $user->setCommentWritten($_POST['commentsend']);
  413. $user->setNickname($_POST['name']);
  414. $user->setMail($_POST['email']);
  415. }
  416. $news->updateNewsRead();
  417. $day_old = (int) 0;
  418. $commentlist =& $news->getComments();
  419. $comments_keys = (array) array_keys($commentlist->getCommentList());
  420. foreach ($comments_keys as $commentID) {
  421. $comment =& $commentlist->getComment($commentID);
  422. $CommentText[] = (string) $sp->FormatLongText($comment->getCommentText());
  423. $CommentAuthor = (string) $sp->FormatShortText($comment->getAuthorName());
  424. $CommentEmail = (string) $sp->CheckMailHomepage($comment->getAuthorMail());
  425. $timestring_comment = (int) $dp->ISOdatetimeToUnixtimestamp($comment->getCommentDate());
  426. $timestring[] = $timestring_comment;
  427. $date_comment[] = (string) $dp->DateString($timestring_comment);
  428. $time_comment[] = (string) $dp->TimeString($timestring_comment);
  429. $CommentEmailFormat[] = (string) (($CommentEmail != '') ? '<a href="' . $CommentEmail . '" target="_blank">' . $CommentAuthor . '</a>' : $CommentAuthor);
  430. if (date('d',$timestring_comment) != $day_old) {
  431. $display_day[] = 1;
  432. } else {
  433. $display_day[] = 0;
  434. } // end if
  435. $day_old = (int) date('d',$timestring_comment);
  436. } // end foreach
  437. $tpl->assign_by_ref('LANG_COMMENTS',$lg->__('Comments'));
  438. $tpl->assign('COMMENT_DISPLAY_DAY',$display_day);
  439. $tpl->assign('COMMENT_TEXT',$CommentText);
  440. $tpl->assign('COMMENT_AUTHOR_AND_MAIL',$CommentEmailFormat);
  441. $tpl->assign('COMMENT_DATE',$date_comment);
  442. $tpl->assign('COMMENT_TIME',$time_comment);
  443. $tpl->assign('COMMENT_DAY',$timestring);
  444. $tpl->assign('COMMENT_DAY_OLD',$timestring);
  445. $tpl->assign_by_ref('LANG_NO_COMMENTS',$lg->__('no_comments'));
  446. if (isset($comments_keys)) { unset($comments_keys); }
  447. if (isset($comment)) { unset($comment); }
  448. if (isset($commentlist)) { unset($commentlist); }
  449. if (isset($news)) { unset($news); }
  450. if (isset($day_old)) { unset($day_old); }
  451. if (isset($CommentText)) { unset($CommentText); }
  452. if (isset($CommentAuthor)) { unset($CommentAuthor); }
  453. if (isset($CommentEmail)) { unset($CommentEmail); }
  454. if (isset($timestring_comment)) { unset($timestring_comment); }
  455. if (isset($timestring)) { unset($timestring); }
  456. if (isset($date_comment)) { unset($date_comment); }
  457. if (isset($time_comment)) { unset($time_comment); }
  458. if (isset($CommentEmailFormat)) { unset($CommentEmailFormat); }
  459. if (isset($display_day)) { unset($display_day); }
  460. /*-----------------*/
  461. /* F O R M U L A R */
  462. /*-----------------*/
  463. if ($user->isCommentWritten($id) == false && !isset($commentsend) && $nocomments == false) { // Formular f?r Kommentar
  464. $tpl->assign('SHOW_COMMENT_FORM',1);
  465. } else {
  466. $tpl->assign('SHOW_COMMENT_FORM',0);
  467. } // end if
  468. $tpl->assign_by_ref('FORM_WRITE_COMMENT',$lg->__('form_write_answer'));
  469. $tpl->assign_by_ref('FORM_NAME',$lg->__('form_name'));
  470. $tpl->assign_by_ref('FORM_EMAIL',$lg->__('form_email'));
  471. $tpl->assign_by_ref('FORM_OR',$lg->__('or'));
  472. $tpl->assign_by_ref('FORM_HOMEPAGE',$lg->__('form_homepage'));
  473. $tpl->assign_by_ref('FORM_COMMENT',$lg->__('form_comment'));
  474. $tpl->assign('FORM_SESSION_NAME',$user->getNickname());
  475. $tpl->assign('FORM_SESSION_EMAIL',$user->getMail());
  476. $tpl->assign('SINGLE_NEWS_ID',$id);
  477. $tpl->assign_by_ref('FORM_BUTTON_SEND',$lg->__('form_send'));
  478. if (isset($user)) { unset($user); }
  479. if (isset($sess_name)) { unset($sess_name); }
  480. if (isset($sess_email)) { unset($sess_email); }
  481. if (isset($id)) { unset($id); }
  482. if (isset($nocomments)) { unset($nocomments); }
  483. if (isset($commentsend)) { unset($commentsend); }
  484. } // end if [isset($id) && is_int($id) && $id != 0]
  485. } else {
  486. /*---------------*/
  487. /* P R O F I L E */
  488. /*---------------*/
  489. if (!defined('PROFILE') && strlen(trim($newslist->getErrorMessage())) > 0) {
  490. $tpl->assign_by_ref('ERROR_MESSAGE',$lg->__($newslist->getErrorMessage()));
  491. } else {
  492. $author = new Author(PROFILE);
  493. $authorname = (string) $sp->FormatShortText($author->getAuthorName());
  494. $newslist_author = (object) $author->getLastArticles();
  495. $authornews_keys = (array) array_keys($newslist_author->getNewsList());
  496. foreach ($authornews_keys as $newsID) {
  497. $news =& $newslist_author->getNews($newsID);
  498. $date_news[] = $dp->ShortDate($dp->ISOdatetimeToUnixtimestamp($news->getNewsdate()));
  499. $cat_id[] = $news->getCategoryID();
  500. $news_id[] = $news->getNewsID();
  501. $cat_name[] = $news->getCategoryName();
  502. $news_headline[] = $sp->FormatShortText($news->getHeadline());
  503. } // end foreach
  504. $tpl->assign('ERROR_MESSAGE','');
  505. $tpl->assign('LANG_PROFILE',ucfirst($lg->__('profile')));
  506. $tpl->assign('AUTHOR_NAME',$authorname);
  507. $tpl->assign('AUTHOR_PICTURE',$author->getAuthorPicture());
  508. $tpl->assign('AUTHOR_ABSTRACT',$sp->FormatLongText($author->getAuthorAbstract()));
  509. $tpl->assign('LANG_LATEST_NEWS_BY',ucfirst($lg->__('latest_news_by')));
  510. $tpl->assign('AUTHOR_LN_DATE',$date_news);
  511. $tpl->assign('AUTHOR_LN_NEWSID',$news_id);
  512. $tpl->assign('AUTHOR_LN_CATID',$cat_id);
  513. $tpl->assign('AUTHOR_LN_CATNAME',$cat_name);
  514. $tpl->assign('AUTHOR_LN_HEADLINE',$news_headline);
  515. if (isset($authornews_keys)) { unset($authornews_keys); }
  516. if (isset($news)) { unset($news); }
  517. if (isset($newslist_author)) { unset($newslist_author); }
  518. if (isset($authorname)) { unset($authorname); }
  519. if (isset($author)) { unset($author); }
  520. if (isset($date_news)) { unset($date_news); }
  521. if (isset($news_id)) { unset($news_id); }
  522. if (isset($cat_id)) { unset($cat_id); }
  523. if (isset($cat_name)) { unset($cat_name); }
  524. if (isset($news_headline)) { unset($news_headline); }
  525. } // end if
  526. } // end if
  527. if (isset($dp)) { unset($dp); }
  528. if (isset($sp)) { unset($sp); }
  529. if (isset($lg)) { unset($lg); }
  530. $tpl->display('index.tpl.php');
  531. ob_end_flush();
  532. ob_end_clean();
  533. ?>