2025-06-02 10:01:12 +02:00
< ? php
/**
2025-06-23 20:45:15 +02:00
* Project : BeCast WebEngine - simple site engine
* File : / modules / text / text . output . php
2025-06-02 10:01:12 +02:00
*
* This program 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 ; version 2 of the License .
*
* This program 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 Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*
2025-06-23 20:45:15 +02:00
* @ link http :// www . becast . at
* @ copyright 2010 - 2025 becast . at
* @ author Bernhard Jaud < bernhard at becast dot at >
* @ package BcWe core
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
* @ version $Id $
*/
2025-06-02 10:01:12 +02:00
2025-06-23 20:45:15 +02:00
If ( ! defined ( " INBCWE " )) {
2025-06-02 10:01:12 +02:00
die ( " Dieses Script kann nicht ausserhalb des Frameworks laufen! " );
}
2025-06-02 22:38:25 +02:00
2025-06-02 10:01:12 +02:00
$session -> page_begin ( " Text Module " , FALSE );
class text extends module {
function output (){
global $module , $config , $db , $log , $core , $error ;
$textid = 0 ;
$url = " " ;
if ( Isset ( $this -> get [ " textid " ]) || Isset ( $this -> post [ " textid " ])){
if ( Isset ( $this -> get [ " textid " ])){
$textid = intval ( $this -> get [ " textid " ]);
} else {
$textid = intval ( $this -> post [ " textid " ]);
}
2025-06-04 10:36:52 +02:00
$result = $db -> query ( " SELECT a.`id` a.`text`, a.`title`, u.`username`, eu.`username` as edituser, a.`date`, a.`edittime`, a.`eid` FROM ` " . $config [ " prefix " ] . " article` a LEFT JOIN ` " . $config [ " prefix " ] . " users` eu on a.`eid` = eu.`uid` LEFT JOIN ` " . $config [ " prefix " ] . " users` u on a.`author` = u.`uid` WHERE a.`id`=' " . $textid . " ' AND a.`active`='true' " ) or die ( $db -> error ());
2025-06-02 10:01:12 +02:00
} elseif ( Isset ( $this -> get [ " url " ]) || Isset ( $this -> post [ " url " ])){
If ( Isset ( $this -> get [ " url " ])){
$url = preg_replace ( '/\.html($|\?)/i' , " $ 1 " , $this -> get [ " url " ] );
} else {
$url = preg_replace ( '/\.html($|\?)/i' , " $ 1 " , $db -> escape_string ( $this -> post [ " url " ]));
}
2025-06-04 10:36:52 +02:00
$result = $db -> query ( " SELECT a.`id`, a.`text`, a.`title`, u.`username`, eu.`username` as edituser, a.`date`, a.`edittime`, a.`eid` FROM ` " . $config [ " prefix " ] . " article` a LEFT JOIN ` " . $config [ " prefix " ] . " users` eu on a.`eid` = eu.`uid` LEFT JOIN ` " . $config [ " prefix " ] . " users` u on a.`author` = u.`uid` WHERE a.url=' " . $url . " ' AND a.`active`='true' " );
2025-06-02 10:01:12 +02:00
} else {
return $error -> http_error ( " 404 " );
}
$fid = " " ;
$fid .= $textid ;
$fid .= $url ;
if ( $db -> num_rows ( $result ) > 0 ){
if ( ! $this -> tpl -> isCached ( 'textview.tpl' , " textview " . $fid )) {
$row = $db -> fetch_array ( $result );
$cresult = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " article_categorys` c LEFT JOIN ` " . $config [ " prefix " ] . " article_category` s ON c.`id`=s.`c_id` WHERE s.`a_id`=' " . $row [ " id " ] . " ' " );
while ( $c = $db -> fetch_array ( $cresult )){
if ( ! $cat ){
$cat = $c [ " categoryname " ];
} else {
$cat .= " , " . $c [ " categoryname " ];
}
}
$editdate = date ( " d.m.Y, H:i " , $row [ " edittime " ]);
$date = date ( " d.m.Y, H:i " , $row [ " date " ]);
$this -> tpl -> assign ( 'article' , $row );
$this -> tpl -> assign ( 'cat' , $cat );
$this -> tpl -> assign ( 'editdate' , $editdate );
$this -> tpl -> assign ( 'date' , $date );
}
$this -> titleaddon = $row [ 'title' ] . ' - ' ;
$core -> add_navbit ( $row [ 'title' ]);
return $this -> tpl -> fetch ( 'textview.tpl' , " textview " . $fid );
} else {
return $error -> http_error ( " 404 " );
}
}
}
?>