Commit 097b120c authored by David Revoy's avatar David Revoy 🎨
Browse files

Initial commit: first core

This is the first core of the website: the structure, design for
URLrewrite, main name of content/pages and a fake menu for testing.
parents
# Pepper&Carrot website specific
# ==============================
# Don't track the huge local database
0_sources/
# OS generated
# ============
**/.DS_Store
**/.DS_Store?
**/._*
**/.Spotlight-V100
**/.Trashes
**/ehthumbs.db
**/Thumbs.db
**/.directory
**/desktop.ini
**/*.iml
**/.idea
**/*~
**/*.bak
**/*.log*
RewriteEngine on
RewriteRule ^([a-z][a-z])/(.*)/(.*)__(.*).html index.php?lang=$1&mode=$2&content=$3&option=$4 [L]
RewriteRule ^([a-z][a-z])/(.*)/(.*).html index.php?lang=$1&mode=$2&content=$3 [L]
RewriteRule ^([a-z][a-z])/(.*) index.php?lang=$1&mode=$2 [L]
RewriteRule ^([a-z][a-z])/ index.php?lang=$1 [L]
/home/deevad/peppercarrot/webcomics
\ No newline at end of file
/* Custom theme for peppercarrot.com
* Copyright (c) 2021 David Revoy,GPL license
* (http://www.gnu.org/licenses/gpl.html)
*/
body {
margin: 2em;
padding: 0;
background: #FFF;
color: #666;
font-size: 1.2em;
text-align: center;
font-family: Arial, sans;
}
h1 {
color: #333;
font-size: 2em;
font-family: Arial, sans;
font-weight: bold;
margin: 0 0 .1em 0;
}
h2 {
color: #333;
margin: 1.5em 0 0;
font-size: 2em;
font-family: Arial, sans;
font-weight: normal;
}
h3 {
color: #333;
margin: .75em 0 0;
font-size: 1.3em;
font-family: Arial, sans;
font-weight: normal;
}
a {
color: #00aad4;
text-decoration: none;
padding-right: 10px;
}
hr {
border: 10px solid #efefef;
border-radius: 5px;
}
<?php if ($root=="") exit;
echo '<br/><br/>'."\n";
echo '<hr>'."\n";
echo '</body>'."\n";
echo '</html>'."\n";
?>
<?php if ($root=="") exit;
// Document header
echo '<!doctype html>'."\n";
echo "\n";
echo '<html lang="'.$lang.'">'."\n";
echo '<head>'."\n";
echo ' <meta charset="utf-8">'."\n";
echo ' <meta name="viewport" content="width=device-width, initial-scale=1">'."\n";
echo ' <title>Pepper&amp;Carrot 2021 Refactor</title>'."\n";
echo ' <link rel="stylesheet" href="'.$root.'core/css/styles.css?v='.$version.'">'."\n";
echo '</head>'."\n";
echo '<body>'."\n";
// Header
echo '<h1><a href="'.$root.'">Pepper&amp;Carrot 2021 Refactor</a></h1>'."\n";
// Menu
echo '<a href="http://localhost/peppercarrot2021/cn/">[cn/ Homepage] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/en/article468/episode-35-the-reflection">[Legacy-ep URL] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/en/wiki/Character.html">[en/ Wiki > Character] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/fr/webcomic/ep01-The-Potion-of-Flight.html">[fr/ Comic > episode1] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/jb/webcomic/ep01-The-Potion-of-Flight__hd.html">[jb/ Comic > episode1 HD] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/kr/webcomic/ep01-The-Potion-of-Flight__hd-transcript.html">[kr/ Comic > episode1 HD Transcript] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/es/page/philosophy.html">[es/ Page > philosophy] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/extras/">[Extras URL] </a>'."\n";
echo '<a href="http://localhost/peppercarrot2021/picture.jpg">[picture.jpg] </a>'."\n";
echo '<br/>'."\n";
echo '<hr>'."\n";
?>
You are in extra!</br>
<a href="../index.php"> Go back</a>
<?php
// Design of a URL for peppercarrot2021:
// =====================================
// https://wwww.peppercarrot.com/{$lang}/{$mode}/{$content}__{$option}.html
// ...or same URL without URL rewrite:
// https://www.peppercarrot.com/index.php?lang=en?mode=webcomic?content=ep01_Potion-of-Flight?option=hd-transcript
// Every URL starting by two small case letter and a slash (eg "en/") will trigger website engine to process the URL.
// $mode: loads a specific engine to read a type content (eg. page|wiki|webcomic)
// $option is cut after two underscore delimiter "__" and word in it are split into an array by "-" delimiter.
// (see .htaccess to see how rewrite rule distribute them)
// Design for language detection:
// ==============================
// If the URL contains a ISO language, apply the language.
// If a cookie exists, extract and apply language.
// If no cookie found or URL, apply webbrowser default language.
// If no language applied, fallback to English.
// config:
if (strpos($_SERVER['SERVER_NAME'], "localhost") !== false) {
$root = "http://localhost/peppercarrot2021/";
} else {
$root = "https://www.peppercarrot.com/";
}
$version = "0.1a";
// init:
$lang = "";
$mode = "";
$content = "";
$option = "";
// Loading variable
$lang = htmlspecialchars($_GET['lang']);
$mode = htmlspecialchars($_GET['mode']);
$content = htmlspecialchars($_GET['content']);
$option = htmlspecialchars($_GET['option']);
// Security
$lang = preg_replace('/[^a-z\._-]/', '', $lang);
$mode = preg_replace('/[^A-Za-z0-9\._-]/', '', $mode);
$content = preg_replace('/[^A-Za-z0-9\._-]/', '', $content);
$option = preg_replace('/[^A-Za-z0-9\._-]/', '', $option);
// Fallback
if (empty($lang)) { $lang = "??"; };
if (empty($mode)) { $mode = "not-found"; };
if (empty($content)) { $content = "not-found"; };
if (empty($option)) { $option = "empty"; };
// Explode option into an array (eg. "hd-transcript" > ["hd", "transcript"])
$option = explode("-", rtrim($option, "/"));
// Header
include(dirname(__FILE__).'/core/header.php');
// Content
echo '<img src="https://www.peppercarrot.com/0_sources/0ther/misc/low-res/2016-04-13_carrot-updating-or-repairing_by-David-Revoy.jpg" style="max-height:320px;max-width:320px;" >'."\n";
echo '<br/>'."\n";
echo "<u>Variable retrieved:</u> <br/>";
echo "<b>lang</b>: ".$lang."<br/>";
echo "<b>mode</b>: ".$mode."<br/>";
echo "<b>page</b>: ".$content."<br/>";
echo "<b>option</b>: ";
print_r($option);
// Footer
include(dirname(__FILE__).'/core/footer.php');
?>
picture.jpg

16.9 KB

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment