2013-08-28 22:47:04 +02:00
< ? php
2013-09-29 16:27:48 +02:00
2013-08-28 22:47:04 +02:00
/**
* File : userpanel_home . php .
* Author : Ulrich Block
* 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 />.
*/
2013-09-29 16:27:48 +02:00
2013-10-05 13:39:56 +02:00
if (( ! isset ( $user_id ) or ! $main == " 1 " ) or ( isset ( $user_id ) and ! isanyuser ( $user_id ))) {
2013-08-28 22:47:04 +02:00
header ( 'Location: login.php' );
2015-09-24 09:31:52 +02:00
die ( 'No Access' );
2013-08-28 22:47:04 +02:00
}
2015-11-02 22:34:35 +01:00
include ( EASYWIDIR . '/third_party/Decoda/autoloader.php' );
use Decoda\Decoda ;
2013-09-29 16:27:48 +02:00
$sprache_bad = getlanguagefile ( 'home' , $user_language , $reseller_id );
2014-05-18 13:48:42 +02:00
if ( isset ( $admin_id ) and $reseller_id != 0 and $admin_id != $reseller_id ) {
2013-10-05 18:39:30 +02:00
$reseller_id = $admin_id ;
2013-08-28 22:47:04 +02:00
}
2013-09-29 16:27:48 +02:00
2014-05-18 13:48:42 +02:00
$statsArray = array (
'gameserverActive' => 0 ,
'gameserverSlotsActive' => 0 ,
'gameserverSlotsUsed' => 0 ,
'gameserverNoPassword' => 0 ,
'gameserverNoTag' => 0 ,
'gameserverNotRunning' => 0 ,
'mysqlDBActive' => 0 ,
'mysqlDBSpaceUsed' => 0 ,
'ticketsCompleted' => 0 ,
'ticketsInProcess' => 0 ,
'ticketsNew' => 0 ,
'virtualActive' => 0 ,
'voiceserverActive' => 0 ,
'voiceserverSlotsActive' => 0 ,
'voiceserverSlotsUsed' => 0 ,
'voiceserverTrafficAllowed' => 0 ,
'voiceserverTrafficUsed' => 0 ,
'voiceserverCrashed' => 0 ,
'webspaceActive' => 0 ,
'webspaceSpaceGivenActive' => 0 ,
'webspaceSpaceUsed' => 0
);
2015-05-14 18:06:59 +02:00
$query = $sql -> prepare ( " SELECT * FROM `easywi_statistics_current` WHERE `userID`=? LIMIT 1 " );
2014-05-18 13:48:42 +02:00
$query -> execute ( array ( $user_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-05-18 13:48:42 +02:00
$statsArray = $row ;
}
$statsArray [ 'warningTotal' ] = $statsArray [ 'gameserverNoPassword' ] + $statsArray [ 'gameserverNoTag' ] + $statsArray [ 'gameserverNotRunning' ] + $statsArray [ 'voiceserverCrashed' ];
2014-08-30 17:55:52 +02:00
$statsArray [ 'ticketsTotal' ] = $statsArray [ 'ticketsInProcess' ];
2014-05-18 13:48:42 +02:00
2015-05-14 18:06:59 +02:00
if ( $ui -> smallletters ( 'w' , 2 , 'get' ) == 'da' or ( ! $ui -> smallletters ( 'w' , 2 , 'get' ) and ! $ui -> smallletters ( 'd' , 2 , 'get' ))) {
$statsArray [ 'gameserverActivePercent' ] = ( $statsArray [ 'gameserverInstalled' ] > 0 ) ? round ( $statsArray [ 'gameserverActive' ] / ( $statsArray [ 'gameserverInstalled' ] / 100 ), 2 ) : 0 ;
$statsArray [ 'gameserverSlotsUsedPercent' ] = ( $statsArray [ 'gameserverSlotsActive' ] > 0 ) ? round ( $statsArray [ 'gameserverSlotsUsed' ] / ( $statsArray [ 'gameserverSlotsActive' ] / 100 ), 2 ) : 0 ;
2018-01-20 12:07:22 +01:00
$statsArray [ 'gameserverCrashedPercent' ] = ( $statsArray [ 'gameserverActive' ] > 0 ) ? round ( $statsArray [ 'gameserverNotRunning' ] / ( $statsArray [ 'gameserverActive' ] / 100 ), 2 ) : 0 ;
2015-05-14 18:06:59 +02:00
$statsArray [ 'gameserverRuleBreakPercent' ] = ( $statsArray [ 'gameserverActive' ] > 0 ) ? round (( $statsArray [ 'gameserverNoTag' ] + $statsArray [ 'gameserverNoPassword' ]) / ( $statsArray [ 'gameserverActive' ] / 100 ), 2 ) : 0 ;
$statsArray [ 'voiceserverActivePercent' ] = ( $statsArray [ 'voiceserverInstalled' ] > 0 ) ? round ( $statsArray [ 'voiceserverActive' ] / ( $statsArray [ 'voiceserverInstalled' ] / 100 ), 2 ) : 0 ;
$statsArray [ 'voiceserverSlotsUsedPercent' ] = ( $statsArray [ 'voiceserverSlotsActive' ] > 0 ) ? round ( $statsArray [ 'voiceserverSlotsUsed' ] / ( $statsArray [ 'voiceserverSlotsActive' ] / 100 ), 2 ) : 0 ;
$statsArray [ 'voiceserverCrashedPercent' ] = ( $statsArray [ 'voiceserverSlotsActive' ] > 0 ) ? round ( $statsArray [ 'voiceserverCrashed' ] / ( $statsArray [ 'voiceserverActive' ] / 100 ), 2 ) : 0 ;
$statsArray [ 'voiceserverTrafficPercent' ] = ( $statsArray [ 'voiceserverTrafficAllowed' ] > 0 ) ? round ( $statsArray [ 'voiceserverTrafficUsed' ] / ( $statsArray [ 'voiceserverTrafficAllowed' ] / 100 ), 2 ) : 0 ;
}
2014-05-18 13:48:42 +02:00
$lastdate = null ;
$feedArray = array ();
2014-04-20 10:48:23 +02:00
if ( $ui -> smallletters ( 'w' , 2 , 'get' ) == 'da' or ( ! $ui -> smallletters ( 'w' , 2 , 'get' ) and ! $ui -> smallletters ( 'd' , 2 , 'get' ))) {
2014-05-18 13:48:42 +02:00
// start collecting news feed data. When combined, timestamps will be used as array index
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT * FROM `feeds_settings` WHERE `resellerID`=? AND `active`='Y' LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-28 21:38:11 +01:00
2013-09-29 16:27:48 +02:00
if ( $row [ 'orderBy' ] == 'I' and $row [ 'merge' ] == 'N' ){
2014-04-20 10:48:23 +02:00
$orderFeedsBy = '`feedID` ASC' ;
2013-09-29 16:27:48 +02:00
} else if ( $row [ 'orderBy' ] == 'U' and $row [ 'merge' ] == 'N' ){
2014-04-20 10:48:23 +02:00
$orderFeedsBy = '`feedUrl` ASC' ;
2013-08-28 22:47:04 +02:00
} else {
2014-04-20 10:48:23 +02:00
$orderFeedsBy = 'n.`pubDate` DESC' ;
2013-08-28 22:47:04 +02:00
}
2014-01-28 21:38:11 +01:00
2013-10-13 11:42:31 +02:00
$newsAmount = $row [ 'newsAmount' ];
2014-06-01 11:47:23 +02:00
if ( $row [ 'merge' ] == 'N' ) {
2013-09-29 16:27:48 +02:00
2014-06-01 11:47:23 +02:00
#https://github.com/easy-wi/developer/issues/80 Include CMS news in dashboards
$query2 = $sql -> prepare ( " SELECT p.`id`,p.`date`,t.`id` AS `textID`,t.`title`,t.`text` 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 0, $newsAmount " );
$query2 -> execute ( array ( $user_language ));
2014-09-21 12:49:48 +02:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-05-18 13:48:42 +02:00
$feedArray [ $page_url ][] = array ( 'title' => $row2 [ 'title' ], 'link' => ( isset ( $seo ) and $seo == 'Y' ) ? $page_url . '/' . $user_language . '/' . szrp ( $gsprache -> news ) . '/' . szrp ( $row2 [ 'title' ]) . '/' : $page_url . '/index.php?site=news&id=' . $row2 [ 'id' ], 'text' => nl2br ( $row2 [ 'text' ]), 'url' => $page_url , 'date' => date ( 'Y-m-d' , $strtotime ), 'time' => date ( 'H:i' , $strtotime ));
2013-09-29 16:27:48 +02:00
}
2014-01-28 21:38:11 +01:00
2013-09-29 15:29:58 +02:00
$query2 = $sql -> prepare ( " SELECT `feedID`,`feedUrl`,`feedID`,`twitter`,`loginName` FROM `feeds_url` WHERE `resellerID`=? AND `active`='Y' ORDER BY $orderFeedsBy " );
2013-08-28 22:47:04 +02:00
$query2 -> execute ( array ( $row [ 'resellerID' ]));
2013-10-13 11:42:31 +02:00
$object = $query2 -> fetchAll ( PDO :: FETCH_ASSOC );
2014-01-28 21:38:11 +01:00
2013-09-29 16:27:48 +02:00
if ( $row [ 'steamFeeds' ] == 'Y' ) {
2014-04-20 10:48:23 +02:00
$object [] = array ( 'feedID' => 0 , 'feedUrl' => 'http://store.steampowered.com/news/' , 'twitter' => 'N' , 'loginName' => '' );
2013-08-28 22:47:04 +02:00
}
2014-01-28 21:38:11 +01:00
2013-08-28 22:47:04 +02:00
foreach ( $object as $row2 ) {
2014-01-28 21:38:11 +01:00
2014-05-18 13:48:42 +02:00
$query3 = $sql -> prepare ( " SELECT `title`,`link`,`description`,`content`,`pubDate` FROM `feeds_news` WHERE `feedID`=? AND `resellerID`=? AND `active`='Y' ORDER BY `pubDate` DESC LIMIT $newsAmount " );
2013-10-03 12:49:13 +02:00
$query3 -> execute ( array ( $row2 [ 'feedID' ], $row [ 'resellerID' ]));
2014-09-21 12:49:48 +02:00
while ( $row3 = $query3 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-28 21:38:11 +01:00
2013-09-29 16:27:48 +02:00
if ( $row [ 'displayContent' ] == 'Y' and $row [ 'limitDisplay' ] == 'Y' and $row2 [ 'twitter' ] == 'N' ){
2014-01-28 21:38:11 +01:00
$text = substr ( $row3 [ 'content' ], 0 , $row [ 'maxChars' ]);
2013-09-29 16:27:48 +02:00
} else if ( $row [ 'displayContent' ] == 'Y' and $row [ 'limitDisplay' ] == 'N' and $row2 [ 'twitter' ] == 'N' ){
2013-10-13 11:42:31 +02:00
$text = $row3 [ 'content' ];
2013-09-29 16:27:48 +02:00
} else if ( $row [ 'displayContent' ] == 'N' and $row [ 'limitDisplay' ] == 'Y' and $row2 [ 'twitter' ] == 'N' ){
2014-01-28 21:38:11 +01:00
$text = substr ( $row3 [ 'description' ], 0 , $row [ 'maxChars' ]);
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$text = $row3 [ 'description' ];
2013-08-28 22:47:04 +02:00
}
2014-01-28 21:38:11 +01:00
$url = ( $row2 [ 'twitter' ] == 'N' ) ? $row2 [ 'feedUrl' ] : 'https://twitter.com/' . $row2 [ 'loginName' ];
2014-05-18 13:48:42 +02:00
$strtotime = strtotime ( $row2 [ 'pubDate' ]);
2014-01-28 21:38:11 +01:00
2014-05-18 13:48:42 +02:00
$feedArray [ 'News' ][ $strtotime ] = array ( 'title' => $row3 [ 'title' ], 'link' => $row3 [ 'link' ], 'text' => $text , 'url' => $url , 'date' => date ( 'Y-m-d' , $strtotime ), 'time' => date ( 'H:i' , $strtotime ));
2013-08-28 22:47:04 +02:00
}
}
2014-01-28 21:38:11 +01:00
2013-08-28 22:47:04 +02:00
unset ( $object );
2014-01-28 21:38:11 +01:00
2013-08-28 22:47:04 +02:00
} else {
2014-01-28 21:38:11 +01:00
2014-08-31 20:03:49 +02:00
$steamAppIDs = '' ;
if ( $row [ 'steamFeeds' ] == 'Y' ) {
$steamAppIDsArray = array ();
2014-09-13 13:46:40 +02:00
$query2 = $sql -> prepare ( " SELECT t.`appID`,t.`shorten` FROM `gsswitch` AS g INNER JOIN `serverlist` AS s ON s.`id`=g.`serverid` INNER JOIN `servertypes` AS t ON s.`servertype`=t.`id` WHERE g.`active`='Y' AND g.`userid`=? AND g.`resellerid`=? AND t.`steamgame`='S' " );
2014-08-31 20:03:49 +02:00
$query2 -> execute ( array ( $user_id , $reseller_id ));
2014-09-21 12:49:48 +02:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-09-13 13:46:40 +02:00
$steamAppIDsArray [] = workAroundForValveChaos ( $row2 [ 'appID' ], $row2 [ 'shorten' ]);
2014-08-31 20:03:49 +02:00
}
$steamAppIDs = ( count ( $steamAppIDsArray ) > 0 ) ? ' OR (n.`feedID`=0 AND n.`content` IN (' . implode ( ',' , $steamAppIDsArray ) . '))' : '' ;
}
2014-06-01 11:47:23 +02:00
$query2 = $sql -> prepare ( " (SELECT 'cms' AS `newsType`,p.`id` AS `newsID`,p.`date` AS `newsDate`,t.`id` AS `textID`,t.`title` AS `newsTitle`,t.`text` AS `newsText`,'' AS `twitterText`,'' AS `feedUrl`,'N' AS `twitter`,'' AS `loginName`,'' AS `link` 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`=:lang AND p.`resellerid`=0) UNION (SELECT 'feed' AS `newsType`,u.`feedID` AS `newsID`,n.`pubDate` AS `newsDate`,0 AS `textID`,n.`title` AS `newsTitle`,n.`content` AS `newsText`,n.`description` AS `twitterText`,u.`feedUrl`,u.`twitter`,u.`loginName`,n.`link` FROM `feeds_news` n LEFT JOIN `feeds_url` u ON n.`feedID`=u.`feedID` WHERE n.`resellerID`=:resellerID AND n.`active`='Y' AND (u.`active`='Y' $steamAppIDs )) ORDER BY `newsDate` DESC LIMIT 0, $newsAmount " );
$query2 -> execute ( array ( ':lang' => $user_language , ':resellerID' => $row [ 'resellerID' ]));
2014-09-21 12:49:48 +02:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-04-20 10:48:23 +02:00
2014-06-01 11:47:23 +02:00
if ( $row2 [ 'newsType' ] == 'cms' ) {
$url = $page_url ;
$link = ( isset ( $seo ) and $seo == 'Y' ) ? $page_url . '/' . $user_language . '/' . szrp ( $gsprache -> news ) . '/' . szrp ( $row2 [ 'newsTitle' ]) . '/' : $page_url . '/index.php?site=news&id=' . $row2 [ 'newsID' ];
$text = nl2br ( $row2 [ 'newsText' ]);
2014-04-20 10:48:23 +02:00
2013-08-28 22:47:04 +02:00
} else {
2014-01-28 21:38:11 +01:00
2014-06-01 11:47:23 +02:00
$url = ( $row2 [ 'twitter' ] == 'N' ) ? $row2 [ 'feedUrl' ] : 'https://twitter.com/' . $row2 [ 'loginName' ];
$link = $row2 [ 'link' ];
if ( $row [ 'displayContent' ] == 'Y' and $row [ 'limitDisplay' ] == 'Y' and $row2 [ 'twitter' ] == 'N' ){
$text = substr ( preg_replace ( '/<(.*?)>/' , '' , preg_replace ( '/<*?[^<>]*?>(.*?)<\/*?>/' , '$1' , $row2 [ 'newsText' ], - 1 ), - 1 ), 0 , $row [ 'maxChars' ]);
} else if ( $row [ 'displayContent' ] == 'Y' and $row [ 'limitDisplay' ] == 'N' and $row2 [ 'twitter' ] == 'N' ){
$text = $row2 [ 'newsText' ];
} else if ( $row [ 'displayContent' ] == 'N' and $row [ 'limitDisplay' ] == 'Y' and $row2 [ 'twitter' ] == 'N' ){
$text = substr ( preg_replace ( '/<(.*?)>/' , '' , preg_replace ( '/<*?[^<>]*?>(.*?)<\/*?>/' , '$1' , $row2 [ 'twitterText' ], - 1 ), - 1 ), 0 , $row [ 'maxChars' ]);
} else {
$text = $row2 [ 'twitterText' ];
}
}
2014-01-28 21:38:11 +01:00
2015-11-02 22:34:35 +01:00
if ( preg_match ( '/(\[\/img\]|\[\/url\]|\[\/b\]|\[\/h1\])/i' , $text )) {
$code = new \Decoda\Decoda ( $text );
$code -> addFilter ( new \Decoda\Filter\DefaultFilter ());
$code -> addFilter ( new \Decoda\Filter\ImageFilter ());
$code -> addFilter ( new \Decoda\Filter\BlockFilter ());
$code -> addFilter ( new \Decoda\Filter\EmailFilter ());
$code -> addFilter ( new \Decoda\Filter\UrlFilter ());
$code -> addFilter ( new \Decoda\Filter\VideoFilter ());
$code -> addFilter ( new \Decoda\Filter\HeadLineFilter ());
$code -> addHook ( new \Decoda\Hook\ClickableHook ());
$text = $code -> parse ();
}
2014-06-01 11:47:23 +02:00
$title = $row2 [ 'newsTitle' ];
2014-01-28 21:38:11 +01:00
2014-06-01 11:47:23 +02:00
if ( strlen ( $row2 [ 'newsTitle' ]) <= 1 ) {
$title = $link ;
2013-08-28 22:47:04 +02:00
}
2014-01-28 21:38:11 +01:00
2014-06-01 11:47:23 +02:00
$strtotime = strtotime ( $row2 [ 'newsDate' ]);
2014-05-18 13:48:42 +02:00
2014-09-21 12:49:48 +02:00
$feedArray [ 'News' ][] = array ( 'title' => $title , 'link' => $link , 'text' => preg_replace ( '/<img[^>]+\>/i' , '' , $text ), 'url' => $url , 'date' => date ( 'Y-m-d' , $strtotime ), 'time' => date ( 'H:i' , $strtotime ));
2013-08-28 22:47:04 +02:00
}
}
}
2015-09-07 18:38:07 +02:00
}