Fix #153 You can now load sub files (custom pages created in layout folder) instead of the default Znote AAC files. (override system).

This commit is contained in:
Stefan Brannfjell 2014-09-03 00:59:12 +02:00
parent 89a775c23f
commit e0ad3aae09
4 changed files with 106 additions and 22 deletions

View File

@ -113,4 +113,31 @@ if ($config['log_ip']) {
//var_dump($v_activity, $v_register, $v_highscore, $v_c_char, $v_s_char, $v_form);
//echo ' <--- IP logging activity past 10 seconds.';
}
// Sub page override system
if ($config['allowSubPages']) {
require_once 'layout/sub.php';
$filename = explode('/', $_SERVER['PHP_SELF']);
$filename = $filename[count($filename)-1];
if (isset($subpages) && !empty($subpages)) {
foreach ($subpages as $page) {
if ($page['override'] && $page['file'] === $filename) {
require_once 'layout/overall/header.php';
require_once 'layout/sub/'.$page['file'];
require_once 'layout/overall/footer.php';
exit;
}
}
} else {
?>
<div style="background-color: white; padding: 20px; width: 100%; float:left;">
<h2 style="color: black;">Old layout!</h2>
<p style="color: black;">The layout is running an outdated sub system which is not compatible with this version of Znote AAC.</p>
<p style="color: black;">The file /layout/sub.php is outdated.
<br>Please update it to look like <a style="color: orange;" target="_BLANK" href="https://github.com/Znote/ZnoteAAC/blob/master/layout/sub.php">THIS.</a>
</p>
</div>
<?php
}
}
?>

View File

@ -1,19 +1,37 @@
<?php
switch ($_GET['page'])
{
case 'blank':
include 'layout/sub/blank.php';
break;
case 'houses':
include 'layout/sub/houses.php';
break;
case 'bomberman':
include 'layout/sub/bomberman.php';
break;
default:
echo '<h2>Sub page not recognized.</h2><p>The sub page you requested is not recognized.</p>';
}
/* Znote AAC Sub System
- Used to create custom pages
- Place the contents of the page in /layout/sub/ folder.
: You don't need to include init, header or footer.
Its already taken care of, just write the contents you want.
Then add that page to the configuration below. Config syntax:
'PAGENAME' => array(
'file' => 'fileName.php',
'override' => false
),
................
There are 2 ways to view your page, by using sub.php file, or by overriding an existing default page.
1: yourwebiste.com/sub.php?page=PAGENAME
2: By having override => true, then it will load your sub file instead of the default znote aac file.
*/
$subpages = array(
// website.com/sub.php?page=blank
'blank' => array(
// layout/sub/blank.php
'file' => 'blank.php',
// false means don't run this file instead of the regular file at website.com/blank.php
'override' => false
),
'houses' => array(
'file' => 'houses.php',
'override' => false
),
'downloads' => array(
'file' => 'downloads.php',
'override' => false
),
);
?>

35
layout/sub/downloads.php Normal file
View File

@ -0,0 +1,35 @@
<div style="background-color: pink;">
<h1>Downloads</h1>
<h2>Sub system Override DEMO</h2>
<p>In order to play, you need an compatible IP changer and a Tibia client.</p>
<p>Download otland IP changer <a href="http://static0.otland.net/ipchanger.exe">HERE</a>.</p>
<p>Download Tibia client <?php echo ($config['client'] / 100); ?> for windows <a href="<?php echo $config['client_download']; ?>">HERE</a>.</p>
<p>Download Tibia client <?php echo ($config['client'] / 100); ?> for linux <a href="<?php echo $config['client_download_linux']; ?>">HERE</a>.</p>
<h2>How to connect and play:</h2>
<ol>
<li>
<a href="<?php echo $config['client_download']; ?>">Download</a> and install the tibia client if you havent already.
</li>
<li>
<a href="http://static0.otland.net/ipchanger.exe">Download</a> and run the IP changer.
</li>
<li>
In the IP changer, write this in the IP field: <?php echo $_SERVER['SERVER_NAME']; ?>
</li>
<li>
In the IP changer, click on <strong>Settings</strong> and then <strong>Add new Tibia client.</strong>
</li>
<li>
In the IP changer, in the Version field, write your desired version.
</li>
<li>
In the IP changer, click on <strong>Browse</strong>, navigate to your desired Tibia version folder, select Tibia.exe and click <strong>Add</strong>. Then click <strong>Close</strong>
</li>
<li>
Now you can successfully login on the tibia client and play clicking on <strong>Apply</strong> every time you want.<br>
If you do not have an account to login with, you need to register an account <a href="register.php">HERE</a>.
</li>
</ol>
</div>

14
sub.php
View File

@ -1,6 +1,10 @@
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['allowSubPages']) include 'layout/sub.php';
<?php require_once 'engine/init.php'; require_once 'layout/overall/header.php';
if ($config['allowSubPages']) {
$page = (isset($_GET['page']) && !empty($_GET['page'])) ? getValue($_GET['page']) : '';
if (isset($subpages[$page]['file'])) require_once 'layout/sub/'.$subpages[$page]['file'];
else {
if (isset($subpages)) echo '<h2>Sub page not recognized.</h2><p>The sub page you requested is not recognized.</p>';
}
}
else echo '<h2>System disabled.</h2><p>The sub page system is disabled.</p>';
include 'layout/overall/footer.php'; ?>
require_once 'layout/overall/footer.php'; ?>