404 page: simplified base url-path calculation and moved it to OcSmarty class, so that it is universally available
updates #246
This commit is contained in:
+8
-30
@@ -19,43 +19,18 @@
|
||||
$tpl->cache_lifetime = 300;
|
||||
$tpl->cache_id = $sUserCountry;
|
||||
|
||||
// simplify variables if exists
|
||||
$redirectUrl = '';
|
||||
$isRedirect404 = false;
|
||||
if (isset($_SERVER['REDIRECT_URL']))
|
||||
{
|
||||
$redirectUrl = $_SERVER['REDIRECT_URL'];
|
||||
$isRedirect404 = true;
|
||||
}
|
||||
|
||||
// assign redirection status
|
||||
// test for redirection to this page
|
||||
$isRedirect404 = isset($_SERVER['REDIRECT_URL']);
|
||||
$tpl->assign('isRedirect404', $isRedirect404);
|
||||
|
||||
// check if original path starts with "/" and remove it
|
||||
if (substr($redirectUrl, 0, 1) == '/')
|
||||
$redirectUrl = substr($redirectUrl, 1);
|
||||
|
||||
// get number of subdirectories (-1 because the last part of url is treated as file)
|
||||
$numDirs = count(explode('/', $redirectUrl)) - 1 -2;
|
||||
|
||||
// put ../ together according to $numDirs
|
||||
$prePath = '';
|
||||
for ($i=0; $i<$numDirs; $i++)
|
||||
{
|
||||
$prePath .= '../';
|
||||
}
|
||||
|
||||
// assign path
|
||||
$tpl->assign('actualpath',$prePath);
|
||||
|
||||
// website, if is 404 redirection
|
||||
// determine website url, if is 404 redirection
|
||||
if ($isRedirect404)
|
||||
{
|
||||
// check length
|
||||
$uril = 70;
|
||||
$uri = 'http://'.strtolower($_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI'];
|
||||
// limit to $uril
|
||||
if(strlen($uri) > $uril) {
|
||||
if (strlen($uri) > $uril) {
|
||||
$uri = substr($uri,0,$uril-3).'...';
|
||||
}
|
||||
|
||||
@@ -73,7 +48,10 @@
|
||||
// simplify $opt
|
||||
foreach ($options as $option)
|
||||
{
|
||||
$opt404[$option] = (isset($opt['page']['404'][$_SERVER['SERVER_NAME']][$option]) ? $opt['page']['404'][$_SERVER['SERVER_NAME']][$option] : $opt['page']['404']['www.opencaching.de'][$option]);
|
||||
if (isset($opt['page']['404'][$_SERVER['SERVER_NAME']][$option]))
|
||||
$opt404[$option] = $opt['page']['404'][$_SERVER['SERVER_NAME']][$option];
|
||||
else
|
||||
$opt404[$option] = $opt['page']['404']['www.opencaching.de'][$option];
|
||||
}
|
||||
|
||||
// get feeds from $feeds array
|
||||
|
||||
@@ -164,6 +164,7 @@ class OcSmarty extends Smarty
|
||||
$optn['page']['headimagepath'] = $opt['page']['headimagepath'];
|
||||
$optn['page']['max_logins_per_hour'] = $opt['page']['max_logins_per_hour'];
|
||||
$optn['page']['absolute_url'] = $opt['page']['absolute_url'];
|
||||
$optn['page']['absolute_urlpath'] = parse_url($opt['page']['absolute_url'], PHP_URL_PATH);
|
||||
$optn['page']['target'] = $this->target;
|
||||
$optn['page']['showdonations'] = $opt['page']['showdonations'];
|
||||
$optn['page']['title'] = $opt['page']['title'];
|
||||
|
||||
@@ -3,32 +3,29 @@
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************}
|
||||
{* check if actualpath is set *}
|
||||
{if !isset($actualpath)}{assign var='actualpath' value=''}{/if}
|
||||
|
||||
{strip} {* OCSTYLE *}
|
||||
{*cachetype=1 status=1 logtype=0 owner=false small=false*}
|
||||
|
||||
{if $cachetype==1}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/unknown.gif" alt="{t}Unknown Geocache{/t}" title="{t}Unknown Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/unknown.gif" alt="{t}Unknown Geocache{/t}" title="{t}Unknown Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==2}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/traditional.gif" alt="{t}Traditional Geocache{/t}" title="{t}Traditional Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/traditional.gif" alt="{t}Traditional Geocache{/t}" title="{t}Traditional Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==3}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/multi.gif" alt="{t}Multicache{/t}" title="{t}Multicache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/multi.gif" alt="{t}Multicache{/t}" title="{t}Multicache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==4}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/virtual.gif" alt="{t}Virtual Geocache{/t}" title="{t}Virtual Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/virtual.gif" alt="{t}Virtual Geocache{/t}" title="{t}Virtual Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==5}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/webcam.gif" alt="{t}Webcam Geocache{/t}" title="{t}Webcam Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/webcam.gif" alt="{t}Webcam Geocache{/t}" title="{t}Webcam Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==6}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/event.gif" alt="{t}Event Geocache{/t}" title="{t}Event Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/event.gif" alt="{t}Event Geocache{/t}" title="{t}Event Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==7}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/mystery.gif" alt="{t}Quizcache{/t}" title="{t}Quizcache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/mystery.gif" alt="{t}Quizcache{/t}" title="{t}Quizcache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==8}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/mathe.gif" alt="{t}Math/Physics Geocache{/t}" title="{t}Math/Physics Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/mathe.gif" alt="{t}Math/Physics Geocache{/t}" title="{t}Math/Physics Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==9}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/moving.gif" alt="{t}Moving Geocache{/t}" title="{t}Moving Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/moving.gif" alt="{t}Moving Geocache{/t}" title="{t}Moving Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{elseif $cachetype==10}
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/cacheicon/drivein.gif" alt="{t}Drive-In Geocache{/t}" title="{t}Drive-In Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/cacheicon/drivein.gif" alt="{t}Drive-In Geocache{/t}" title="{t}Drive-In Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />
|
||||
{else}
|
||||
|
||||
{/if}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************}
|
||||
{* check if actualpath is set *}
|
||||
{if !isset($actualpath)}{assign var='actualpath' value=''}{/if}
|
||||
|
||||
{if $minimap_enabled}
|
||||
<div>
|
||||
<img class="img-minimap" style="margin:16px 20px 16px 16px; width: 220px; height: 220px; float: right;" src="{$minimap_url}{foreach name=newcaches from=$newcaches item=cacheitem}|{$cacheitem.latitude},{$cacheitem.longitude}{/foreach}">
|
||||
@@ -14,9 +11,9 @@
|
||||
{foreach name=newcaches from=$newcaches item=cacheitem}
|
||||
<li class="newcache_list_multi" style="margin-bottom: 8px;">
|
||||
<table class="null" cellspacing="0" cellpadding="0"><tr>
|
||||
<td style="vertical-align:top; padding-right:2px; padding-top:2px" rowspan="2">{include file="res_cacheicon_22.tpl" cachetype=$cacheitem.type actualpath=$actualpath}</td>
|
||||
<td style="vertical-align:top; padding-right:2px; padding-top:2px" rowspan="2">{include file="res_cacheicon_22.tpl" cachetype=$cacheitem.type}</td>
|
||||
<td style="vertical-align:top; ">{$cacheitem.date_created|date_format:$opt.format.date} </td>
|
||||
<td style="text-align:left; width:100%"><b><a class="links" href="viewcache.php?cacheid={$cacheitem.cache_id}">{$cacheitem.name|escape}</a></b> {include file="res_oconly.tpl" oconly=$cacheitem.oconly actualpath=$actualpath}
|
||||
<td style="text-align:left; width:100%"><b><a class="links" href="viewcache.php?cacheid={$cacheitem.cache_id}">{$cacheitem.name|escape}</a></b> {include file="res_oconly.tpl" oconly=$cacheitem.oconly}
|
||||
{t}by{/t}
|
||||
<b><a class="links" href="viewprofile.php?userid={$cacheitem.user_id}">{$cacheitem.username|escape}</a></b></td>
|
||||
</tr>
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************}
|
||||
{* check if actualpath is set *}
|
||||
{if !isset($actualpath)}{assign var='actualpath' value=''}{/if}
|
||||
|
||||
{if $oconly}
|
||||
{if $opt.help.oconly != ''}{$opt.help.oconly}{/if}{if $size=='15x21'}<img src="{$actualpath}resource2/ocstyle/images/misc/15x21-oc.png" width="15" height="21" >{else}<img src="{$actualpath}resource2/ocstyle/images/misc/15x15-oc.png" width="15" height="15" >{/if}{if $opt.help.oconly != ''}</a>{/if}
|
||||
{if $opt.help.oconly != ''}{$opt.help.oconly}{/if}{if $size=='15x21'}<img src="{$opt.page.absolute_urlpath}resource2/ocstyle/images/misc/15x21-oc.png" width="15" height="21" >{else}<img src="{$opt.page.absolute_urlpath}resource2/ocstyle/images/misc/15x15-oc.png" width="15" height="15" >{/if}{if $opt.help.oconly != ''}</a>{/if}
|
||||
{/if}
|
||||
|
||||
@@ -27,26 +27,26 @@
|
||||
<meta http-equiv="gallerimg" content="no" />
|
||||
<meta http-equiv="cache-control" content="no-cache" />
|
||||
<link rel="SHORTCUT ICON" href="favicon.ico">
|
||||
<link rel="apple-touch-icon" href="{$actualpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-iphone.png" />
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="{$actualpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-ipad.png" />
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="{$actualpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-iphone-retina.png" />
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="{$actualpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-ipad-retina.png" />
|
||||
<link rel="stylesheet" type="text/css" href="{$actualpath}resource2/{$opt.template.style}/css/style_screen.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{$actualpath}resource2/{$opt.template.style}/css/style_oc404.css" />
|
||||
<link rel="apple-touch-icon" href="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-iphone.png" />
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-ipad.png" />
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-iphone-retina.png" />
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/oclogo/apple-touch-icon-ipad-retina.png" />
|
||||
<link rel="stylesheet" type="text/css" href="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/css/style_screen.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/css/style_oc404.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="frame">
|
||||
<div class="header">
|
||||
<div class="headerimage">
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/head/rotator.php?path={$opt.page.headimagepath}" class="headerimagecontent" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/head/rotator.php?path={$opt.page.headimagepath}" class="headerimagecontent" />
|
||||
</div>
|
||||
<div class="headerlogo">
|
||||
<img src="{$actualpath}resource2/{$opt.template.style}/images/oclogo/oc_head_alpha3.png" class="headerimagecontent" />
|
||||
<img src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/oclogo/oc_head_alpha3.png" class="headerimagecontent" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="head">
|
||||
<p>
|
||||
<img id="oc404" src="{$actualpath}resource2/{$opt.template.style}/images/oc_404.png" title="opencaching.de 404" alt="opencaching.de 404" />
|
||||
<img id="oc404" src="{$opt.page.absolute_urlpath}resource2/{$opt.template.style}/images/oc_404.png" title="opencaching.de 404" alt="opencaching.de 404" />
|
||||
<span class="dnf">- {t}Page not found{/t} - DNF</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user