Skip to content
Permalink
Browse files

added 404-errorpage including template and image, changed some variables

in templates and pulled parts out in new templates, fixed some bugs and
typos from previous commits

moved new events, ratings and caches HTML code generation into separate
templates and changed templates accordingly to avoid redundant code

moved generation of HTML code for RSSParser into separate smarty
template and changed involved files accordingly

moved code that generates the "new" (cache, event, rating, forum, blog,
etc.) sections into separate class to avoid redundant code
  • Loading branch information...
bohrsty authored and following committed Apr 22, 2013
1 parent 7d190bd commit ed1a383ee62c5dc92875779ac4c652310dbc72ee
@@ -0,0 +1,49 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
***************************************************************************/
$opt['rootpath'] = '../';
require($opt['rootpath'].'lib2/web.inc.php');
require($opt['rootpath'].'lib2/logic/logpics.inc.php');
$sUserCountry = $login->getUserCountry();
// create object for "newest" information
$getNew = new getNew($sUserCountry);
$tpl->main_template = 'sys_oc404';
$tpl->name = 'sys_oc404';
$tpl->caching = false;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $sUserCountry;
// rootpath
$tpl->assign('rootpath',$opt['rootpath']);
// website
// check length
$uril = 70;
$uri = 'http://'.strtolower($_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI'];
// limit to $uril
if(strlen($uri) > $uril) {
$uri = substr($uri,0,$uril-3).'...';
}
$tpl->assign('website',$uri);
// get newest blog entries
$tpl->assign('blog', $getNew->feedForSmarty('blog',3));
// get newest forum posts
$tpl->assign('forum',$getNew->feedForSmarty('forum',3));
// get newest wiki
$tpl->assign('wiki', $getNew->feedForSmarty('wiki',3));
// get newest caches
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache',array($sUserCountry, $opt['template']['locale'],3)));
$tpl->display();
?>
@@ -11,6 +11,9 @@
require('./lib2/logic/logpics.inc.php');
$sUserCountry = $login->getUserCountry();
// create object for "newest" information
$getNew = new getNew($sUserCountry);
$tpl->name = 'start';
$tpl->menuitem = MNU_START;
@@ -52,9 +55,8 @@
$url = str_replace('{style}', $opt['template']['style'], $url);
$newscontent = read_file($url, $opt['news']['maxsize']);
*/
$newscontent = RSSParser::parse($opt['news']['count'],$opt['news']['include'], false);
$tpl->assign('news', $newscontent);
// get newest blog entries
$tpl->assign('news', $getNew->feedForSmarty('blog'));
$tpl->assign('newsfeed', $opt['news']['include']);
$tpl->assign('extern_news', true);
}
@@ -72,9 +74,9 @@
* requires $opt['forum']['count'] in settings for number of lastest forum-posts
* requires $opt['forum']['url'] in settings: RSS-feed-URL of the forum
*/
$tpl->assign('phpbb_enabled', true);
$forumcontent = RSSParser::parse($opt['forum']['count'], $opt['forum']['url'], false);
$tpl->assign('forum',$forumcontent);
// get newest forum posts
$tpl->assign('phpbb_enabled', true);
$tpl->assign('forum',$getNew->feedForSmarty('forum'));
}
else
{
@@ -93,89 +95,14 @@
$tpl->assign('count_founds', sql_value_slave('SELECT COUNT(*) AS `founds` FROM `cache_logs` WHERE `type`=1', 0));
$tpl->assign('count_users', sql_value_slave('SELECT COUNT(*) AS `users` FROM (SELECT DISTINCT `user_id` FROM `cache_logs` UNION DISTINCT SELECT DISTINCT `user_id` FROM `caches`) AS `t`', 0));
// new events
$events = array();
$rs = sql_slave("SELECT `user`.`user_id` `user_id`,
`user`.`username` `username`,
`caches`.`cache_id` `cache_id`,
`caches`.`name` `name`,
`caches`.`date_hidden`,
IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`,
`cache_location`.`adm2`,
`cache_location`.`adm3`,
`cache_location`.`adm4`
FROM `caches`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`
LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1`
LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `caches`.`country`='&1' AND
`caches`.`date_hidden` >= curdate() AND
`caches`.`type` = 6 AND
`caches`.`status`=1
ORDER BY `date_hidden` ASC LIMIT 0, 10",
$sUserCountry, $opt['template']['locale']);
$tpl->assign_rs('events', $rs);
sql_free_result($rs);
// get newest events
$tpl->assign_rs('events', $getNew->rsForSmarty('event'));
// new caches
$rs = sql_slave("SELECT `user`.`user_id` `user_id`,
`user`.`username` `username`,
`caches`.`cache_id` `cache_id`,
`caches`.`name` `name`,
`caches`.`date_created` `date_created`,
`caches`.`type`,
IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`,
`cache_location`.`adm2`,
`cache_location`.`adm3`,
`cache_location`.`adm4`
FROM `caches`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`
LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1`
LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `caches`.`country`='&1' AND
`caches`.`type` != 6 AND
`caches`.`status` = 1
ORDER BY `caches`.`date_created` DESC LIMIT 0, 10",
$sUserCountry, $opt['template']['locale']);
$tpl->assign_rs('newcaches', $rs);
sql_free_result($rs);
// get newest caches
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache'));
// last 30 days' top ratings
//
// 2012-08-24 following
// optimized by adding rating_date field to cache_rating, so we don't need the log table.
$rs = sql_slave("SELECT COUNT(`cache_rating`.`user_id`) AS `cRatings`,
MAX(`cache_rating`.`rating_date`) AS `dLastLog`,
`user`.`user_id` AS `user_id`,
`user`.`username` AS `username`,
`caches`.`cache_id` AS `cache_id`,
`caches`.`name` AS `name`,
`caches`.`type`,
IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`,
`cache_location`.`adm2`,
`cache_location`.`adm3`,
`cache_location`.`adm4`
FROM `cache_rating`
INNER JOIN `caches` ON `caches`.`cache_id`=`cache_rating`.`cache_id`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_location` ON `cache_rating`.`cache_id`=`cache_location`.`cache_id`
LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1`
LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `caches`.`country`='&1' AND
`cache_rating`.`rating_date`>DATE_SUB(NOW(), INTERVAL 30 DAY) AND
`caches`.`type`!=6 AND
`caches`.`status`=1
GROUP BY `cache_rating`.`cache_id`
ORDER BY `cRatings` DESC,
`dLastLog` DESC,
`cache_id` DESC
LIMIT 0, 10",
$sUserCountry, $opt['template']['locale']);
$tpl->assign_rs('topratings', $rs);
sql_free_result($rs);
$tpl->assign_rs('topratings', $getNew->rsForSmarty('rating'));
$sUserCountryName = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
@@ -11,24 +11,22 @@ class RSSParser {
* @return string $item feeditems as HTML-string
*/
public static function parse($items,$url,$includetext) {
global $translate;
global $tpl;
if ($items <= 0)
return '';
// error
$error = false;
$rss = array();
// check $url
if(!preg_match('!^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&amp;%\$#\=~_\-]+))*$!',$url)) {
if(!preg_match('!^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\:\,\?\'\\\+&amp;%\$#\=~_\-]+))*$!',$url)) {
$error = true;
} else {
// output
$html = '<div class="buffer" style="width: 500px;height: 2px;">&nbsp;</div>'."\n";
$html .= '<div class="newsblock">';
if (!$includetext)
$html .= "<table class='narrowtable' style='margin-top:0'>\n";
$tpl->assign('includetext',$includetext);
// get xml-data
$data = @file_get_contents($url);
@@ -44,9 +42,9 @@ public static function parse($items,$url,$includetext) {
// get SimpleXML-object
$xml = new SimpleXMLElement($data);
// walk through items
$i=0;
$headlines = array();
// walk through items
foreach($xml->channel->item as $item) {
// check length
@@ -57,45 +55,43 @@ public static function parse($items,$url,$includetext) {
// add html
if ($includetext)
{
$html .= '<p class="content-title-noshade-size15" style="display: inline;">'."\n";
$html .= strftime('%e. %B %Y',strtotime($item->pubDate)).' - '. $item->title;
$html .= '</p> <p style="line-height: 1.6em;display: inline;">&emsp;[<b><a class="link" href="'.$item->link.'">mehr...</a></b>]</p>'."\n";
$html .= '<div class="rsstext">'.$item->description.'</div>'."\n";
// fill array
$rss[] = array(
'pubDate' => strftime('%e. %B %Y',strtotime($item->pubDate)),
'title' => $item->title,
'link' => $item->link,
'description' => $item->description
);
// increment counter
$i++;
}
else if (!in_array($item->title,$headlines) &&
strpos($item->title,'VERSCHOBEN') === FALSE) // hack to exclude forum thread-move messages
{
$html .= '<tr><td style="text-align:right">' . strftime('%e. %B %Y',strtotime($item->pubDate)).'</td>';
$html .= '<td><a class="links" href="'.$item->link.'">';
$html .= $item->title;
$html .= '</td></tr>';
// fill array
$rss[] = array(
'pubDate' => strftime('%e. %B %Y',strtotime($item->pubDate)),
'title' => $item->title,
'link' => $item->link
);
$headlines[] = "" . $item->title;
// increment counter
$i++;
}
}
}
// finish html
if (!$includetext)
$html .= "</table>";
$html .= "</div>";
$html .= '<div class="buffer" style="width: 500px;">&nbsp;</div>'."\n";
}
catch(Exception $e) {
$error = true;
}
}
}
// assign to template
$tpl->assign('rsserror',$error);
// return
if(!$error) {
return $html;
} else {
return '<p><em>' . $translate->t('currently not available','','',0) . '</em></p>';
}
return $rss;
}
}
Oops, something went wrong.

0 comments on commit ed1a383

Please sign in to comment.
You can’t perform that action at this time.