big php change
This commit is contained in:
parent
d6c22c45d2
commit
2fb77c6c1f
20
index.php
20
index.php
@ -11,6 +11,17 @@ function sanitize_template_strings($indata){
|
|||||||
return preg_replace($sanit_pattern, '', $indata);
|
return preg_replace($sanit_pattern, '', $indata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceTemplateTags($content) {
|
||||||
|
// Add any additional template replacements here
|
||||||
|
$hash = md5(strtolower(trim($_SESSION['user_email'])));
|
||||||
|
$gravatarUrl = "https://www.gravatar.com/avatar/$hash?s=100";
|
||||||
|
$content = str_replace('<template name="gravatar image">', "<img src='$gravatarUrl' alt='Gravatar Profile Picture'>", $content);
|
||||||
|
|
||||||
|
// Add more replacements if needed
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
@ -27,9 +38,9 @@ if (isset($_SESSION['user_id'])) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nav = include_ob("$template_dir/navigation.html");
|
$nav = include_ob("$template_dir/navigation.html");
|
||||||
|
$nav = replaceTemplateTags($nav); // Apply templating to the navigation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($page_dir == "global") {
|
if($page_dir == "global") {
|
||||||
if(!file_exists("$page_dir/index.html")) {
|
if(!file_exists("$page_dir/index.html")) {
|
||||||
$page_file = "$page_dir/login.html";
|
$page_file = "$page_dir/login.html";
|
||||||
@ -57,8 +68,6 @@ $paths_to_check[] = "pages/global";
|
|||||||
|
|
||||||
$page_file = "$template_dir/404.html";
|
$page_file = "$template_dir/404.html";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach($paths_to_check as $page_dir){
|
foreach($paths_to_check as $page_dir){
|
||||||
$page_file_tmp = "$page_dir/$page.html";
|
$page_file_tmp = "$page_dir/$page.html";
|
||||||
if(file_exists($page_file_tmp)){
|
if(file_exists($page_file_tmp)){
|
||||||
@ -76,7 +85,6 @@ if (isset($_SESSION['user_id'])) {
|
|||||||
$gravatarUrl = "https://www.gravatar.com/avatar/$hash?s=100";
|
$gravatarUrl = "https://www.gravatar.com/avatar/$hash?s=100";
|
||||||
$gravatarTag = "<img src='$gravatarUrl' alt='Gravatar Profile Picture'>";
|
$gravatarTag = "<img src='$gravatarUrl' alt='Gravatar Profile Picture'>";
|
||||||
$page_data = str_replace('<template name="gravatar image">', $gravatarTag, $page_data);
|
$page_data = str_replace('<template name="gravatar image">', $gravatarTag, $page_data);
|
||||||
$nav = str_replace('<template name="gravatar image">', $gravatarTag, $nav);
|
|
||||||
|
|
||||||
$page_data = str_replace('<template name="username">', $_SESSION['user_username'], $page_data);
|
$page_data = str_replace('<template name="username">', $_SESSION['user_username'], $page_data);
|
||||||
}
|
}
|
||||||
@ -93,7 +101,7 @@ if (preg_match($page_regex, $page_data, $matches)) {
|
|||||||
|
|
||||||
if (preg_match($page_style_regex, $page_data, $style_matches)) {
|
if (preg_match($page_style_regex, $page_data, $style_matches)) {
|
||||||
$page_style = $style_matches[1];
|
$page_style = $style_matches[1];
|
||||||
$page_data = str_replace('<!--PAGESTYLE=' . $page_style . '-->', '', $page_data);
|
$page_data = preg_replace($page_style_regex, '', $page_data); // Replace the PAGESTYLE tag
|
||||||
} else {
|
} else {
|
||||||
$page_style = "/styles/pages/$page_name.css";
|
$page_style = "/styles/pages/$page_name.css";
|
||||||
$page_data = str_replace('<template name="page styling">', $page_style, $page_data);
|
$page_data = str_replace('<template name="page styling">', $page_style, $page_data);
|
||||||
@ -104,4 +112,4 @@ $output = str_replace('<template name="page styling">', $page_style, $output);
|
|||||||
$output = str_replace('<template name="page content">', $page_data, $output);
|
$output = str_replace('<template name="page content">', $page_data, $output);
|
||||||
|
|
||||||
echo $output;
|
echo $output;
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user