2025-06-23 20:45:15 +02:00
< ? php global $session ;
2025-06-02 10:01:12 +02:00
/**
2025-06-19 00:07:46 +02:00
* Project : BeCast WebEngine - simple site engine
2025-06-02 10:01:12 +02:00
* File : / modules / nickpage / nickpage . output . php
*
* 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-19 00:07:46 +02:00
* @ link http :// www . becast . at SVN : $URL $
2025-06-02 10:01:12 +02:00
* @ copyright 2009 becast . at
* @ author Bernhard Jaud < bernhard at becast dot at >
2025-06-19 00:07:46 +02:00
* @ package BeCast WebEngine Nickpage
2025-06-02 10:01:12 +02:00
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
* @ version $Id $
*/
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! " );
}
$session -> page_begin ( " Nickpage " , FALSE );
2025-06-15 22:25:18 +02:00
use Smarty\Smarty ;
2025-06-02 10:01:12 +02:00
class nickpage extends module {
2025-06-15 22:25:18 +02:00
var $mybb_conf , $session ;
2025-06-02 10:01:12 +02:00
function __construct (){
2025-06-15 22:25:18 +02:00
parent :: __construct ();
2025-06-02 10:01:12 +02:00
$this -> mybb_conf = $this -> fetchboardconfig ();
}
function output (){
2025-06-15 22:25:18 +02:00
global $module , $config , $db , $log , $core , $error , $session ;
2025-06-02 10:01:12 +02:00
$count = 20 ;
$result = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " v_nickpage` WHERE `username`=' " . $db -> escape ( $_GET [ 'user' ]) . " ' LIMIT 1 " );
$user = $db -> fetch_array ( $result );
if ( ! isset ( $_GET [ 'user' ]) || $db -> num_rows ( $result ) <= 0 || $_GET [ 'user' ] == '' ){
$db -> free_result ( $result );
header ( " HTTP/1.1 404 Not Found " );
header ( " Status: 404 Not Found " );
$user [ 'sitetitle' ] = 'Nickpage nicht gefunden' ;
} else {
$parser = new textparser ();
2025-06-15 22:25:18 +02:00
$loggedin = false ;
2025-06-02 10:01:12 +02:00
$db -> free_result ( $result );
$user [ 'sitetitle' ] = 'Nickpage von ' . $user [ 'username' ];
2025-06-15 22:25:18 +02:00
if ( $session -> userdata [ 'uid' ] != 0 ){
$loggedin = true ;
}
$result = $db -> query ( " SELECT * FROM ` " . $this -> mybb_conf [ " prefix " ] . " users` WHERE `uid`=' " . $user [ 'fuid' ] . " ' LIMIT 1 " );
2025-06-02 10:01:12 +02:00
$forum = $db -> fetch_array ( $result );
$db -> free_result ( $result );
$result = $db -> query ( " SELECT * FROM `v_ptc_users` WHERE `uid`=' " . $user [ 'uid' ] . " ' LIMIT 1 " );
$chat = $db -> fetch_array ( $result );
$db -> free_result ( $result );
2025-06-15 22:25:18 +02:00
$result = $db -> query ( " SELECT count(`id`) as `count` FROM ` " . $config [ " prefix " ] . " npguestbook` WHERE `guid`=' " . $user [ 'uid' ] . " ' " );
2025-06-02 10:01:12 +02:00
$gb_count = $db -> fetch_array ( $result );
$gb_pages = ceil ( $gb_count [ 'count' ] / $count );
$db -> free_result ( $result );
if ( $user [ 'birthday' ] != '' ){
$today = new DateTime ();
2025-06-19 00:07:46 +02:00
$birthday = $today -> createFromFormat ( 'j-n-Y' , $user [ 'birthday' ]);
2025-06-02 10:01:12 +02:00
$now = new DateTime ();
$age = $now -> diff ( $birthday );
$user [ 'age' ] = $age -> y ;
} else {
$user [ 'age' ] = 'unbekannt' ;
}
2025-06-15 22:25:18 +02:00
$page = 0 ;
if ( ! isset ( $_GET [ 'page' ]) || $_GET [ 'page' ] == " first " ){
2025-06-02 10:01:12 +02:00
$start = 0 ;
} elseif ( $_GET [ 'page' ] == " last " ){
$page = $gb_pages - 1 ;
} elseif ( $_GET [ 'page' ] >= 1 ){
$page = $_GET [ 'page' ] - 1 ;
}
$start = $page * $count ;
$sql = " SELECT g.*, u.`username` FROM ` " . $config [ 'prefix' ] . " npguestbook` g LEFT JOIN ` " . $config [ 'prefix' ] . " users` u ON u.`uid`=g.`wuid` WHERE g.`guid`=' " . $user [ 'uid' ] . " ' ORDER BY g.`timestamp` DESC LIMIT " . $start . " , " . $count ;
$resultgb = $db -> query ( $sql );
while ( $row = $db -> fetch_array ( $resultgb )){
$row [ 'date' ] = date ( 'd.m.Y, H:i' , $row [ 'timestamp' ]);
$row [ 'text' ] = $parser -> parse ( $row [ 'text' ]);
$gb [] = $row ;
}
$db -> free_result ( $resultgb );
if ( $page > 0 ){
$pagination = '<a href="gb/page/' . $page . '.html" class="page-numbers">< Zurück</a>' ;
} else {
$pagination = '<span class="page-numbers prev inactive">< Zurück</span>' ;
}
for ( $i = 1 ; $i < $gb_pages ; $i ++ ){
if ( $i = $page + 1 ){
$pagination .= '<span class="page-numbers current">' . $i . '</span>' ;
} else {
$pagination .= '<a href="gb/page/' . $i . '.html" class="page-numbers">' . $i . '</a>' ;
}
}
$rpage = $page + 1 ;
$pagination .= ' Seite ' . $rpage . ' von ' . $gb_pages ;
if ( $gb_pages > $page + 1 ){
$pagination .= '<a href="gb/page/' . ( $page + 2 ) . '.html" class="page-numbers next">Weiter ></a>' ;
} else {
$pagination .= '<span class="page-numbers next inactive">Weiter ></span>' ;
}
$user [ 'chattime' ] = $this -> intervall ( $chat [ 'chattime' ]);
2025-06-19 00:07:46 +02:00
2025-06-02 10:01:12 +02:00
switch ( $chat [ 'rights' ]){
2025-06-15 22:25:18 +02:00
case ( 99 ) :
2025-06-02 10:01:12 +02:00
$user [ 'chatright' ] = 'Chatadmin' ;
break ;
2025-06-15 22:25:18 +02:00
case ( 50 ) :
2025-06-02 10:01:12 +02:00
$user [ 'chatright' ] = 'Chat-VIP' ;
break ;
}
if ( $user [ 'np_picture' ] == '' ){
$user [ 'np_picture' ] = 'nopic.png' ;
}
$user [ 'text' ] = $parser -> parse ( $user [ 'np_text' ]);
2025-06-18 15:02:56 +02:00
$data = get_user_room ( $user [ 'username' ]);
2025-06-02 10:01:12 +02:00
if ( $data ){
2025-06-18 20:12:29 +02:00
$user [ 'room' ] = $data [ 'room' ];
$user [ 'roomlock' ] = '<img src="' . $path . '/themes/funchat/images/unlocked.png" alt="Offen" />' ;
if ( $user [ 'roomlocked' ]){
$user [ 'roomlock' ] = '<img src="' . $path . '/themes/funchat/images/locked.png" alt="Abgeschlossen" />' ;
}
2025-06-02 10:01:12 +02:00
}
//$forum['buddylist'];
if ( $session -> userdata [ 'uid' ] != " " ){
2025-06-15 22:25:18 +02:00
2025-06-02 10:01:12 +02:00
$result = $db -> query ( " SELECT `buddylist` FROM ` " . $this -> mybb_conf [ " prefix " ] . " users` WHERE `uid`=' " . $session -> userdata [ 'fuid' ] . " ' LIMIT 1 " );
$friends = $db -> fetch_array ( $result );
$db -> free_result ( $result );
$friendsid = $friends [ 'buddylist' ];
$idarray = explode ( " , " , $friendsid );
if ( in_array ( $user [ " fuid " ], $idarray )){
$user [ " friendlink " ] = $user [ " username " ] . " ist in deiner Freundesliste " ;
} else {
$user [ " friendlink " ] = " <a href= \" /adduser/ " . $user [ " fuid " ] . " \" > " . $user [ " username " ] . " zur Freundesliste hinzufügen.</a> " ;
}
}
$user [ 'favourits' ] = '' ;
for ( $i = 1 ; $i <= 4 ; $i ++ ){
$link = unserialize ( $user [ 'np_link' . $i ]);
if ( $link [ 'text' ] != '' ){
$user [ 'favourits' ] .= '<li><a href="' . $link [ 'value' ] . '" rel="nofollow" target="_blank">' . $link [ 'text' ] . '</a></li>' ;
}
}
if ( $forum [ 'buddylist' ] != " " ){
$idarray = explode ( " , " , $forum [ 'buddylist' ]);
foreach ( $idarray as $current_id ){
$current_id = intval ( $current_id );
if ( $current_id <= 0 ) {
continue ;
}
$sql_string = " SELECT `username` AS nick FROM ` " . $this -> mybb_conf [ " prefix " ] . " users` WHERE `uid` = ' " . $current_id . " ' LIMIT 1 " ;
$result = $db -> query ( $sql_string );
if ( $db -> num_rows ( $result ) >= 1 ) {
$name = $db -> fetch_array ( $result );
if ( $friendl ) {
$friendl .= " , " ;
}
$nick = $name [ 'nick' ];
2025-06-19 00:07:46 +02:00
$friendl .= '<nobr><a style="text-decoration:none;" href="http://funch.at/np/' . rawurlencode ( $nick ) . '">' . $nick . '</a></nobr>' ;
2025-06-02 10:01:12 +02:00
}
$db -> free_result ( $result );
}
}
2025-06-18 15:02:56 +02:00
$this -> tpl -> assign ( " themepath " , '/themes/' . $config [ 'theme' ]);
2025-06-15 22:25:18 +02:00
$this -> tpl -> assign ( 'friends' , $friendl );
$this -> tpl -> assign ( 'user' , $user );
$this -> tpl -> assign ( 'forum' , $forum );
$this -> tpl -> assign ( 'loggedin' , $loggedin );
$this -> tpl -> assign ( 'domain' , $config [ 'domain' ]);
$this -> tpl -> assign ( 'gb' , $gb );
$this -> tpl -> assign ( 'pagination' , $pagination );
2025-06-18 15:02:56 +02:00
$content = $this -> tpl -> fetch ( 'nickpage_content.tpl' );
}
$themedir = $this -> getTemplateDir ();
$core -> make_page ( $content , TRUE , $themedir . '/nickpage.tpl' , NULL , NULL );
}
function getTemplateDir (){
global $config ;
$root = $_SERVER [ 'DOCUMENT_ROOT' ] . $config [ 'path' ];
if ( isset ( $config [ 'theme' ]) && $config [ 'theme' ] != '' && is_dir ( $root . '/modules/nickpage/templates/' . $config [ 'theme' ])){
$themedir = $root . '/modules/nickpage/templates/' . $config [ 'theme' ];
} else {
$themedir = $root . '/modules/nickpage/templates/default' ;
2025-06-02 10:01:12 +02:00
}
2025-06-18 15:02:56 +02:00
return $themedir ;
2025-06-02 10:01:12 +02:00
}
function output_edit (){
global $module , $tpl , $config , $db , $log , $core , $error , $session ;
If ( $_POST [ 'submit' ]){
$err = false ;
for ( $i = 1 ; $i <= 4 ; $i ++ ){
if ( $_POST [ 'np_link' . $i . '_link' ] != '' ){
if ( $_POST [ 'np_link' . $i . '_name' ] == '' ){
$_POST [ 'np_link' . $i . '_name' ] = 'Kein Name' ;
}
$link [ $i ] = serialize ( array ( 'text' => $_POST [ 'np_link' . $i . '_name' ], 'value' => $_POST [ 'np_link' . $i . '_link' ]));
} else {
$link [ $i ] = '' ;
}
}
$text = $db -> escape ( $_POST [ 'np_text' ]);
$end = explode ( '.' , $_FILES [ 'np_picture' ][ 'name' ]);
$userfile_name = 'np_' . $session -> userdata [ " uid " ] . '.' . $end [ 1 ];
$userfile_tmp = $_FILES [ 'np_picture' ][ 'tmp_name' ];
$userfile_size = $_FILES [ 'np_picture' ][ 'size' ];
$userfile_type = $_FILES [ 'np_picture' ][ 'type' ];
$root = $_SERVER [ 'DOCUMENT_ROOT' ] . $config [ 'path' ];
$filedir = $root . '/np_images/' ;
$size = 200 ;
if (( $userfile_size / 1024 ) > 250 ){
2025-06-23 20:45:15 +02:00
$err = '<span style="font-color:red;">Das Bild darf nicht gr<67> sser als 250kb sein.</span>' ;
2025-06-02 10:01:12 +02:00
}
if ( isset ( $_FILES [ 'np_picture' ][ 'name' ]) && $_FILES [ 'np_picture' ][ 'name' ] != " " && ! $err ){
$prod_img = $filedir . $userfile_name ;
$ret = $core -> upload_file ( $prod_img , $userfile_tmp , $size , $size , TRUE , TRUE );
if ( $ret !== TRUE ){
$err = '<span style="font-color:red;">' . $ret . '</span>' ;
}
} elseif ( $_POST [ " delimg " ] == 1 ){
$result = $db -> query ( " SELECT `picture` FROM ` " . $config [ " prefix " ] . " news_category` WHERE `id`=' " . intval ( $_POST [ " id " ]) . " ' LIMIT 1 " );
$file = $db -> fetch_array ( $result );
@ unlink ( $filedir . $file [ 'picture' ]);
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " news_category` SET `picture`='' WHERE `id`=' " . intval ( $_POST [ " id " ]) . " ' " );
}
if ( ! $err ){
if ( isset ( $_FILES [ 'np_picture' ][ 'name' ]) && $_FILES [ 'np_picture' ][ 'name' ] != " " ){
$result = $db -> query ( " SELECT `np_picture` FROM ` " . $config [ " prefix " ] . " v_nickpage` WHERE `id`=' " . intval ( $session -> userdata [ " uid " ]) . " ' LIMIT 1 " ) or die ( $db -> error ());
$file = $db -> fetch_array ( $result );
@ unlink ( $filedir . $file [ 'np_picture' ]);
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " v_nickpage` SET `np_picture`=' " . $userfile_name . " ' WHERE `id`=' " . intval ( $session -> userdata [ " uid " ]) . " ' " );
}
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " v_nickpage` SET `np_link1`=' " . $link [ 1 ] . " ',`np_link2`=' " . $link [ 2 ] . " ',`np_link3`=' " . $link [ 3 ] . " ',`np_link4`=' " . $link [ 4 ] . " ',`np_text`=' " . $text . " ' WHERE `id`=' " . intval ( $session -> userdata [ " uid " ]) . " ' " );
} else {
$this -> tpl -> assign ( 'emsg' , $err );
$this -> tpl -> assign ( 'np' , $_POST );
$content = $this -> tpl -> fetch ( 'edit_nickpage.tpl' );
}
}
$result = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " v_nickpage` WHERE `uid`=' " . $session -> userdata [ 'uid' ] . " ' LIMIT 1 " );
$np = $db -> fetch_array ( $result );
$np [ 'np_link1' ] = unserialize ( $np [ 'np_link1' ]);
$np [ 'np_link2' ] = unserialize ( $np [ 'np_link2' ]);
$np [ 'np_link3' ] = unserialize ( $np [ 'np_link3' ]);
$np [ 'np_link4' ] = unserialize ( $np [ 'np_link4' ]);
$np [ 'link1_text' ] = $np [ 'np_link1' ][ 'text' ];
$np [ 'link1_value' ] = $np [ 'np_link1' ][ 'value' ];
$np [ 'link2_text' ] = $np [ 'np_link2' ][ 'text' ];
$np [ 'link2_value' ] = $np [ 'np_link2' ][ 'value' ];
$np [ 'link3_text' ] = $np [ 'np_link3' ][ 'text' ];
$np [ 'link3_value' ] = $np [ 'np_link3' ][ 'value' ];
$np [ 'link4_text' ] = $np [ 'np_link4' ][ 'text' ];
$np [ 'link4_value' ] = $np [ 'np_link4' ][ 'value' ];
$parse = new textparser ( false );
$np [ 'np_text' ] = $parse -> parse ( $np [ 'np_text' ]);
$this -> tpl -> assign ( 'np' , $np );
$content = $this -> tpl -> fetch ( 'edit_nickpage.tpl' );
return $content ;
}
2025-06-19 00:07:46 +02:00
function meta (){
global $session , $config , $db , $tpl , $log , $plugin ;
$meta = '' ;
return $meta ;
2025-06-02 10:01:12 +02:00
}
2025-06-19 00:07:46 +02:00
2025-06-02 10:01:12 +02:00
function meta_edit (){
global $session , $config , $db , $tpl , $log , $plugin ;
$meta = '<script type="text/javascript" src="' . $config [ 'path' ] . ' / modules / reviews / comments / nicEdit . js ? ver = 1500 " ></script>
< script type = " text/javascript " >
bkLib . onDomLoaded ( function () { nicEditors . allTextAreas ({ iconsPath : \ '' . $config [ 'path' ] . ' / modules / reviews / comments / nicEditorIcons . gif\ ' , xHtml : true , bbCode : true }) });
</ script > ' ;
return $meta ;
}
function fetchboardconfig (){
global $db , $config , $cache , $log ;
$mybb = $cache -> read ( 'mybbconfig' );
try {
$result = $db -> query ( " SELECT `name`, `value` FROM " . $mybb [ 'prefix' ] . " settings " );
if ( ! $result ){
throw new Exception ( $db -> error ());
}
while ( $row = $db -> fetch_array ( $result )){
$boardconfig [ $row [ 'name' ]] = $row [ 'value' ];
}
$boardconfig [ 'prefix' ] = $mybb [ 'prefix' ];
return $boardconfig ;
} catch ( Exception $e ){
$log -> write ( $e , 2 , __LINE__ , __FILE__ );
return NULL ;
}
}
function intervall ( $sek ) {
$i = sprintf ( '%d Stunde%s,' .
' %d Minute%s und %d Sekunde%s' ,
$sek / 3600 ,
floor ( $sek / 3600 ) != 1 ? 'n' : '' ,
$sek / 60 % 60 ,
floor ( $sek / 60 % 60 ) != 1 ? 'n' : '' ,
$sek % 60 ,
floor ( $sek % 60 ) != 1 ? 'n' : ''
);
return $i ;
}
function getage ( $date ) {
$date = explode ( '-' , $date );
if ( $date [ 2 ] == " " ){
return " Nicht angegeben. " ;
} else {
return date ( 'Y' ) - $date [ 2 ] - ( date ( 'n' ) < ( ltrim ( $date [ 1 ], '0' ) + ( date ( 'j' ) < ltrim ( $date [ 0 ], '0' ))));
}
}
}
?>