Browse Source

Beta 0.5.0 - Check TODO

Signed-off-by: Adrien Kara <adrien.ph@gmail.com>
master
Adrien Kara 5 years ago
parent
commit
85571c682e
25 changed files with 152 additions and 173 deletions
  1. 1
      Content/Accueil/en.txt
  2. 1
      Content/Accueil/fr.txt
  3. 1
      Content/Contact/fr.txt
  4. 97
      Database/Content.json
  5. 0
      Database/Errors.json
  6. 0
      Database/Guest.json
  7. 10
      Database/Plugins.json
  8. 4
      Include/Configuration/Config.inc.conf.php
  9. 21
      Include/Configuration/Options.inc.conf.php
  10. 0
      Include/Configuration/Private.inc.conf.php
  11. 0
      Include/Configuration/Require.inc.conf.php
  12. 82
      Include/ContentManager.inc.php
  13. 0
      Include/ErrorsAndInfos.inc.php
  14. 30
      Include/ErrorsManager.inc.php
  15. 16
      Include/JsonManager.inc.php
  16. 13
      Include/Language.inc.php
  17. 0
      Include/Main.inc.php
  18. 16
      Include/RequestInfos.inc.php
  19. 2
      Library/LittleSecureLib.php
  20. 9
      Plugins/Mail/Mail.plug.php
  21. 0
      Public/Templates/Default/Css/normalize.css
  22. 4
      Public/Templates/Default/index.tpl.php
  23. 2
      Public/index.php
  24. 0
      README.md
  25. 16
      TODO

1
Content/Accueil/en.txt

@ -0,0 +1 @@
Home page no:.<p id=\"test\">tout est cahos</p>

1
Content/Accueil/fr.txt

@ -0,0 +1 @@
Page d'accueil no:.<p id=\"test\">tout est cahos</p>

1
Content/Contact/fr.txt

@ -0,0 +1 @@
!PHP:pg_mail():PHP!

97
Database/Content.json

@ -1,70 +1,109 @@
{
"Pages": {
"Accueil": {
"Title": {
"fr": "Accueil"
},
"Text": {
"fr": "Page d'accueil no:.<p id=\"test\">tout est cahos</p>"
"category": false,
"title": {
"fr": "Accueil",
"en": "Home"
}
},
"Contact": {
"Title": {
"category": false,
"title": {
"fr": "Contact"
},
"Text": {
"fr": "!PHP:pg_mail():PHP!"
}
},
"TestPage02": {
"Title": {
"fr": "boubidouda tata toto"
"Saison01": {
"category": true,
"title": {
"fr": "Saison 01",
"en": "Saison 01"
},
"Chappitre1": {
"category": false,
"title": {
"fr": "Chapitre 01",
"en": "Chapster 01"
}
},
"Text": {
"fr": "Ceci est un texte de test"
"Chappitre2": {
"category": true,
"title": {
"fr": "Chapitre 02",
"en": "Chapster 02"
},
"Ep1": {
"category": false,
"title": {
"fr": "Episode1",
"en": "Machin"
}
},
"Ep2": {
"category": false,
"title": {
"fr": "Episode2",
"en": "Machin"
}
}
}
}
},
"Menu": {
"Main": {
"Accueil": {
"Title": {
"fr": "Accueil"
"Extra": {
"Friends": {
"category": true,
"Blogs": {
"category": true,
"title": {
"fr": "Liste des blogs"
},
"Link": "http://toto.toto"
"adrien": {
"category": false,
"title": {
"fr": "Blog iglou"
},
"link": "http://blog.iglou.eu",
"blank": true
}
},
"Multi": {
"Title": {
"category": true,
"title": {
"fr": "MultiLinks"
},
"Sousmenu1": {
"Title": {
"category": true,
"title": {
"fr": "Sous menu1"
},
"Sousousmenu": {
"Title": {
"category": false,
"title": {
"fr": "Sous SOUS menu"
},
"Link": "http://toto.toto"
"link": "http://toto.toto"
}
},
"Sousmenu2": {
"Title": {
"category": true,
"title": {
"fr": "Sous menu2"
},
"Sousousmenu2": {
"Title": {
"category": false,
"title": {
"fr": "Sous SOUS menu2"
},
"Link": "http://toto.toto"
"link": "http://toto.toto"
}
}
},
"FAQ": {
"Title": {
"category": false,
"title": {
"fr": "FAQ"
},
"Link": "http://toto.toto"
"link": "http://toto.toto"
}
}
}

0
Database/Errors.json

0
Database/Guest.json

10
Database/Plugins.json

@ -5,16 +5,12 @@
"fr": "Mod de contact par mail"
},
"Activate": "1",
"Config": {
"DataBase": {
"Map": {
"champ=>Name": {
"Mail": "champ=>E-mail"
}
"string=>Name": "string=>E-mail"
},
"Used": {
"Admin": {
"Mail": "adrien.ph@gmail.com"
}
"Admin": "adrien.ph@gmail.com"
}
}
}

4
Include/Configuration/Config.inc.conf.php

@ -31,6 +31,10 @@ function cmsConfig($arg, $change = 0, $newValue = null) {
static $webName = 'Iglou.eu';
static $webDescription = 'Blablabla Mister Freeman. Welcom to my web Site ! The right man in the wrong place can make all the difference in the world';
// Content option
static $contentFileExt = '.txt';
static $contentFolder = 'Content/';
// ! END OF CONRFIG ! //
// Mixing var

21
Include/Configuration/Options.inc.conf.php

@ -1,21 +0,0 @@
<?php
// $serverUrl use $_SERVER['SERVER_NAME'] if is empty.
// WARN : SERVER_NAME is based on 'ServerName' HTTP server option
// but HTTP_HOST which is defined by header(Client side), when SERVER_NAME is called return HTTP host header ...
// this is an Apache bug ! To solve it set 'UseCanonicalName' directive to 'on' in the '<VirtualHost>'
$serverUrl='';
// Template selector
// Template should be in 'Public/Templates/*'
$templateUsed = 'Default';
// DB
$dbLocation = 'Database/'; // Empty = root, add "/"
$dbContent = 'Content.json';
$dbGuest = 'Guest.json';
// Language !lowercase!
$defaultLanguage = 'fr';
// HTTPS Only - If is true and https is not activated, script dies !
$onlyHTTPS = False;

0
Include/Configuration/Private.inc.conf.php

0
Include/Configuration/Require.inc.conf.php

82
Include/ContentManager.inc.php

@ -13,10 +13,10 @@ function currentPage()
function contentLanguage($arg)
{
if (isset($arg[$_COOKIE['LGG']])) {
$arg = $arg[$_COOKIE['LGG']];
if (isset($_COOKIE['LGG']) && array_key_exists($_COOKIE['LGG'], $arg)) {
$arg = $_COOKIE['LGG'];
} else {
$arg = $arg[cmsConfig('defaultLanguage')];
$arg = cmsConfig('defaultLanguage');
}
return ($arg);
@ -45,7 +45,7 @@ function jsonLoaded($dbRead)
if (null === $content) {
$confFile = cmsConfig(array('dbPluginsPath', 'dbGuestPath', 'dbErrorsPath', 'dbContentPath'));
$guest = readJson($confFile['dbGuestPath']);
$errors = readJson($confFile['dbErrorsPath']);
$content = readJson($confFile['dbContentPath']);
@ -61,6 +61,7 @@ function readJson($arg)
if (is_file($arg)) {
$arg = file_get_contents($arg, null, null);
$arg = utf8_encode($arg);
$arg = json_decode($arg, true);
if (json_last_error()) {
@ -73,8 +74,19 @@ function readJson($arg)
return ($arg);
}
function pluginsDb()
{
$dirConfig = strlen(APP_ROOT.cmsConfig('pgLocation'));
$requestBy = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)['0']['file'];
$requestBy = substr($requestBy, $dirConfig);
$requestBy = substr($requestBy, 0, strpos($requestBy, '/'));
return (jsonLoaded('plugins')[$requestBy]['DataBase']['Used']);
}
/* ---------- Php content generator ---------- */
function execPhpContent(&$content, &$nTime)
function execPhpContent(&$content, $nTime)
{
while (0 < $nTime) {
--$nTime;
@ -111,14 +123,22 @@ function pluginsManager()
}
/* ---------- Return content ---------- */
function returnPage(&$arrJson, $page, $type = 'Title', $execPhp = 0) // $type, must be Title or Text
function returnPage(&$argJson, $page, $type = NULL, $execPhp = 0) // $type, must be Title or Text
{
if (isset($arrJson['Pages'][$page]) && isset($arrJson['Pages'][$page][$type])) {
$outPut = contentLanguage($arrJson['Pages'][$page][$type]);
if(isset($argJson['Pages'][$page])) {
$language = contentLanguage($argJson['Pages'][$page]['title']);
if('Title' === $type) {
$outPut = $argJson['Pages'][$page]['title'][$language];
} else {
$outPut = cmsConfig(array('contentFileExt', 'contentFolder'));
$outPut = APP_ROOT.$outPut['contentFolder'].$page.'/'.$language.$outPut['contentFileExt'];
$outPut = file_get_contents($outPut);
if ($execPhp) { execPhpContent($outPut, substr_count($outPut, '!PHP:')); }
if ($execPhp) { execPhpContent($outPut, substr_count($outPut, '!PHP:')); }
}
} else {
if ('Title' === $type) {
if('Title' === $type) {
$outPut = 'Keep calm ! May the 404 page be with you !';
} else {
$outPut = declareError($page, '404')."\n";
@ -128,33 +148,41 @@ function returnPage(&$arrJson, $page, $type = 'Title', $execPhp = 0) // $type, m
return ($outPut);
}
function returnMenu(&$arrJson, $menu, $type = 'ul') // $type, must be 'ul', 'ol' and 'menu'
function returnMenu(&$arrJson, $type, $cat = NULL, $tag = 'ul') // $type, must be 'ul', 'ol' and 'menu'
{
if (isset($arrJson['Menu'][$menu])) {
$outPut = '<'.$type.'>';
$outPut .= arrayMenuParser($outPut, $arrJson['Menu'][$menu], $type);
$outPut .= '</'.$type.'>';
if (isset($arrJson[$type]) || isset($arrJson[$type][$cat])) {
$outPut = '<'.$tag.'>';
if (NULL === $cat) {
$outPut .= arrayMenuParser($outPut, $arrJson[$type], $tag);
} else {
$outPut .= arrayMenuParser($outPut, $arrJson[$type][$cat], $tag);
}
$outPut .= '</'.$tag.'>'."\n";
} else {
$outPut = declareError('Menu => '.$menu, 'Nfound')."\n";
$outPut = declareError('Menu => '.$type.' - '.$cat, 'Nfound')."\n";
}
return ($outPut);
}
function arrayMenuParser(&$outPut, &$arg, &$type)
function arrayMenuParser(&$outPut, &$arg, &$tag)
{
foreach ($arg as $key => &$value) {
if (isset($value['Link'])) {
$title = contentLanguage($value['Title']);
$outPut .= '<li id="'.$key.'" class="link"><a href="'.$value['Link'].'">'.$title.'</a></li>'."\n";
} elseif ((array) $value === $value) {
if ($key !== 'Title') {
$title = contentLanguage($value['Title']);
$outPut .= '<li class="menuCat">'.$title.'<'.$type.'>';
$outPut .= arrayMenuParser($outPut, $value, $type);
$outPut .= '</'.$type.'></li>';
if (isset($value['title'])) {
$link = (isset($value['link'])) ? $value['link'] : '?Page='.$key;
$language = contentLanguage($value['title']);
if ($value['category']) {
$outPut .= '<li id="'.$key.'" class="link"><span>'.$value['title'][$language].'</span><'.$tag.'>';
$outPut .= arrayMenuParser($outPut, $value, $tag);
$outPut .= '</'.$tag.'></li>';
} else {
$outPut .= '<li id="'.$key.'" class="link"><a ';
$outPut .= (isset($value['blank']) && $value['blank']) ? 'target="_blank" ' : '' ;
$outPut .= 'href="'.$link.'">'.$value['title'][$language].'</a></li>';
}
}
}

0
Include/ErrorsAndInfos.inc.php

30
Include/ErrorsManager.inc.php

@ -1,30 +0,0 @@
<?php
function declareError($arg, $err)
{
$outPut = readJson(cmsConfig('dbErrorsPath'), true);
switch ($err) {
case '404':
$outPut = contentLanguage($outPut[$err]);
$outPut = str_replace('[!PAGE_VAR!]', $arg, $outPut);
break;
case 'Nfound':
$outPut = contentLanguage($outPut[$err]);
$outPut = str_replace('[:NFOUND:]', $arg, $outPut);
break;
default:
exit('ErrorsManager.inc.php => Bad type error on '.$err);
break;
}
return ($outPut);
}
function phpChecker()
{
$actualPhp = phpversion();
if (version_compare($actualPhp, REQUIRED_PHP_VERSION, '<')) {
exit('Ouups => '.$actualPhp.', Your php version is too old. This script require PHP V: '.REQUIRED_PHP_VERSION.' or newer, sorry.');
}
}

16
Include/JsonManager.inc.php

@ -1,16 +0,0 @@
<?php
function readJson($arg)
{
if (is_file($arg)) {
$arg = file_get_contents($arg, null, null);
$arg = json_decode($arg, true);
if (json_last_error()) {
exit('Error: '.json_last_error().' - Json: '.$arg);
}
} else {
exit('Error: This file: '.$arg.', is not found or not accessible.');
}
return ($arg);
}

13
Include/Language.inc.php

@ -1,13 +0,0 @@
<?php
function checkLanguage() {
if (isset($_GET['LGG'])) {
$_COOKIE['LGG'] = securityParser(substr($_GET['LGG'], 0, 2), true);
} else {
if (isset($_COOKIE['LGG'])) {
} elseif (!isset($_COOKIE['LGG']) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$_COOKIE['LGG'] = securityParser(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), true);
} elseif (!isset($_COOKIE['LGG'])) {
$_COOKIE['LGG'] = cmsConfig('defaultLanguage');
}
}
}

0
Include/Main.inc.php

16
Include/RequestInfos.inc.php

@ -1,16 +0,0 @@
<?php
function timeDB()
{
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
$time = round($time , 4);
return ($time);
}
function memoryDB()
{
$memory = memory_get_usage() / 1048576;
$memory = round($memory , 3);
return ($memory);
}

2
Library/LittleSecureLib.php

@ -114,7 +114,7 @@ function utf8Encode(&$arg)
if (('UTF-8' !== $inCharset) && ('ASCII' !== $inCharset)) {
$mbAllow = mb_list_encodings();
if ($inCharset === 'ISO-8859-1') {
if ('ISO-8859-1' === $inCharset) {
$arg = utf8_encode($arg);
} elseif (in_array($inCharset, $mbAllow)) {
error_log($arg.' ERROR_01');

9
Plugins/Mail/Mail.plug.php

@ -2,7 +2,7 @@
function pg_mail()
{
if (true) {
$outPut = '
$outPut = pluginsDb();/*.'
<form id="pg_mail" method="post" action="">
<h2>Contact formulaire</h2>
<fieldset>
@ -29,7 +29,7 @@ function pg_mail()
<input type="submit" value="Send" />
</fieldset>
</from>
';
';*/
}
return ($outPut);
@ -39,3 +39,8 @@ function pg_mailSend()
{
}
function pg_recipList()
{
}

0
Public/Templates/Default/Css/normalize.css

4
Public/Templates/Default/index.tpl.php

@ -11,7 +11,9 @@
<p class="browserupgrade">You are using an <strong>outdated</strong> browser.
Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<?php echo returnMenu($jsonContent, 'Main');
<?php echo returnMenu($jsonContent, 'Pages');
echo returnMenu($jsonContent, 'Pages', 'Saison01');
echo returnMenu($jsonContent, 'Extra', 'Friends');
echo returnPage($jsonContent, currentPage(), 'Text', 1);
echo timeDB(),'secondes - ',memoryDB(),'mo'; ?>
</body>

2
Public/index.php

@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ----------
* Beta 0.4.0 - 03 décembre 2015
* Beta 0.5.0 - 03 mars 2016
* ----------
* Moteur du site IGLOU.EU
** ---------- */

0
README.md

16
TODO

@ -1,13 +1,11 @@
-- AF --
add plugin mail
add admin state
all message call by language
add admin state, function and GUI
-- RA --
Opti arrayMenuParser() and main()
Change String concatenation
Can exec php code inside json text
Remove file, better perf
Load json on a function
Opti config function
Add plugins manager
Refactoring menu and page (generation, json, data, language)
Add data to file on Content folder, config on Config.inc.conf.php
Add utf8_encode() for json, json_decode() accept only utf8 file
Add fonction for plugins load db
Multiple bug
Clear include and duplicate functions
Loading…
Cancel
Save