Move PHP files to /common/php/
This commit is contained in:
13
common/php/footer.php
Normal file
13
common/php/footer.php
Normal file
@@ -0,0 +1,13 @@
|
||||
</div> <!--End of body tag -->
|
||||
<footer>
|
||||
<p align="center">
|
||||
<sub>We are hackers, that is why we have terminals with black backgrounds and green text.</sub><br/>
|
||||
<font size="1">
|
||||
Copyright <?php echo(strftime("%Y")); ?> 20xd6, webmaster.
|
||||
<a href="/license/" title="Licensing information for this site.">License</a>
|
||||
<a href="https://20xd6.net/git/20xd6/20xd6.net" title="Link to the git repository for this website.">Git</a>
|
||||
</font>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
46
common/php/get_month_name.php
Normal file
46
common/php/get_month_name.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
//Parses it's passed input to convert it to a month name.
|
||||
function get_month_name($passed_var){
|
||||
switch($passed_var){
|
||||
case "01":
|
||||
$month_name = "January";
|
||||
break;
|
||||
case "02":
|
||||
$month_name = "Febuary";
|
||||
break;
|
||||
case "03":
|
||||
$month_name = "March";
|
||||
break;
|
||||
case "04":
|
||||
$month_name = "April";
|
||||
break;
|
||||
case "05":
|
||||
$month_name = "May";
|
||||
break;
|
||||
case "06":
|
||||
$month_name = "June";
|
||||
break;
|
||||
case "07":
|
||||
$month_name = "July";
|
||||
break;
|
||||
case "08":
|
||||
$month_name = "August";
|
||||
break;
|
||||
case "09":
|
||||
$month_name = "September";
|
||||
break;
|
||||
case "10":
|
||||
$month_name = "October";
|
||||
break;
|
||||
case "11":
|
||||
$month_name = "November";
|
||||
break;
|
||||
case "12":
|
||||
$month_name = "December";
|
||||
break;
|
||||
default:
|
||||
$month_name = $passed_var;
|
||||
}
|
||||
return$month_name;
|
||||
}
|
||||
?>
|
||||
13
common/php/h1_month.php
Normal file
13
common/php/h1_month.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
//Sets the proper level 1 heading for the folder.
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/get_month_name.php');
|
||||
$current_dir = basename(getcwd());
|
||||
$named_month = get_month_name($current_dir);
|
||||
if ( $named_month == "blog") {
|
||||
echo "<h1>Blog Posts</h1>";
|
||||
}elseif ($named_month == "by_year"){
|
||||
echo "<h1>Posts by Year</h1>";
|
||||
} else {
|
||||
echo "<h1>Posts for ". $named_month ."</h1> ";
|
||||
}
|
||||
?>
|
||||
49
common/php/header.php
Normal file
49
common/php/header.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<?php
|
||||
//Sets the page title based on the name of the current directory
|
||||
function Title() {//Needs cleanup.
|
||||
//~ $new_title = $_SERVER['REQUEST_URI'];
|
||||
|
||||
//~ $new_title = preg_replace("/^^\//i", "", $new_title);
|
||||
//~ $new_title = preg_replace("/\//i", "", $new_title);
|
||||
//~ $page_title = $_SERVER['REQUEST_URI'];
|
||||
//~ $page_title = preg_replace("/^(.*)\//i", "", $page_title);
|
||||
$page_title = basename($_SERVER['SCRIPT_FILENAME'], '.php');
|
||||
//~ echo($page_title);
|
||||
if(strtolower($page_title) == 'index'){
|
||||
parse_str($_SERVER['REQUEST_URI'], $page_uri);
|
||||
$page_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
//~ echo($page_path);
|
||||
//~ $folder_name = sizeof($page_path);
|
||||
$folder_name = explode("/", trim($page_path, "/"));
|
||||
$page_title = $folder_name[(sizeof($folder_name) - 1)];
|
||||
} elseif(strtolower($page_title) == 'homepage'){
|
||||
$page_title = 'Homepage';
|
||||
}
|
||||
$page_title = str_replace('_', ' ', $page_title);
|
||||
$page_title = ucwords($page_title);
|
||||
return $page_title;
|
||||
}
|
||||
?>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<?php
|
||||
//If a tags file is present parse it and add any tags found to the renderd page's metadata.
|
||||
if(file_exists('tags')){
|
||||
$tag_data_raw = fopen('tags',"r");
|
||||
$tag_data = fread($tag_data_raw, filesize('tags'));
|
||||
$tag_data = str_replace("\n", "", $tag_data);
|
||||
echo "<meta name=\"keywords\" content=\"" . $tag_data . "\"/>\n";
|
||||
fclose($tag_data_raw);
|
||||
}
|
||||
?>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title><?php $title = Title(); echo $title;?></title>
|
||||
<link href="/common/css/styles.css?v=<?php echo date('his'); ?>" type="text/css" rel="stylesheet"/>
|
||||
<link href="/common/css/jmenu.css?v=<?php echo date('his'); ?>" type="text/css" rel="stylesheet"/>
|
||||
<link href="/common/css/print.css?v=<?php echo date('his'); ?>" type="text/css" media="print" rel="stylesheet"/>
|
||||
<script type="text/javascript" src="/common/js/page_format.js?v=<?php echo date('his'); ?>"></script>
|
||||
</head>
|
||||
<body lang="en-US">
|
||||
<div class="body" id="body">
|
||||
14
common/php/index.php
Normal file
14
common/php/index.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
//The common file used to render pages on the blog.
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/header.php');
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/menu.php');
|
||||
//Looks for an article.md to see if the current directory is an article or not
|
||||
//If it is not then it is a menu page.
|
||||
if (file_exists('article.md')){
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/md_read.php');
|
||||
} else {
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/h1_month.php');
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/page_menu.php');
|
||||
}
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/footer.php');
|
||||
?>
|
||||
13
common/php/markdown.php
Normal file
13
common/php/markdown.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
#Markdown display code
|
||||
require ($_SERVER['DOCUMENT_ROOT'].'/common/vendor/autoload.php');
|
||||
function get_markdown($markdown_source){
|
||||
#Markdown parseing code.
|
||||
$MD_Parser = new Parsedown();
|
||||
$MD_Path = $markdown_source;
|
||||
$MD_File = fopen($MD_Path, "r") or die("File not found.");
|
||||
$MD_Text = fread($MD_File, filesize($MD_Path));
|
||||
echo $MD_Parser->text($MD_Text);
|
||||
fclose($MD_File);
|
||||
}
|
||||
?>
|
||||
41
common/php/md_read.php
Normal file
41
common/php/md_read.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
#Markdown parser dependancy
|
||||
require ($_SERVER['DOCUMENT_ROOT'].'/common/vendor/autoload.php');
|
||||
#Markdown parseing code.
|
||||
$MD_Parser = new ParsedownExtra();
|
||||
$MD_Path = "article.md";
|
||||
$MD_File = fopen($MD_Path, "r") or die("File not found.");
|
||||
$MD_Text = fread($MD_File, filesize($MD_Path));
|
||||
echo "<article id=\"article\">\n" . /* Adds the option to change the font size of the article text. */
|
||||
"<div id=\"font_btns\">
|
||||
Text Size:
|
||||
<button id=\"btn_sml\" type=\"button\" onclick=\"font_set('small')\">a</button>
|
||||
<button id=\"btn_mid\" type=\"button\" onclick=\"font_set('medium')\">A</button>
|
||||
<button id=\"btn_lrg\" type=\"button\" onclick=\"font_set('25px')\">A</button>
|
||||
</div><!--End of font_btns-->
|
||||
<input type=\"button\" onclick=\"printDiv('print-content')\" title=\"Print this article\" value=\"Print\"/>
|
||||
<div id=\"print-content\">\n
|
||||
<nav class=\"jmenu\">
|
||||
<label for=\"menu-btn\" class=\"jm-menu-btn\">Download</label>
|
||||
<input type=\"checkbox\" id=\"menu-btn\" class=\"jm-menu-btn\"/>
|
||||
<ul class=\"jm-collapse\">
|
||||
</ul>
|
||||
<li><a>PDF</a></li>
|
||||
<li><a href=\"article.md\" title=\"Download \">MD</a></li>
|
||||
</nav>
|
||||
".
|
||||
$MD_Parser->text($MD_Text) . "\n</article>";
|
||||
fclose($MD_File);
|
||||
echo "\n</div><!--End of print-content div-->\n";
|
||||
echo("<nav class=\"jmenu\"><div class=\"pmenu\"><ul id=\"back_btn\"><li><a href='..'>Back</a></li></ul></div></nav>\n");
|
||||
if ($tag_data != NULL){
|
||||
$page_tags = str_getcsv($tag_data);
|
||||
natcasesort($page_tags);
|
||||
echo "<div id=\"tags\"><h2>Tags</h2>\n<ul>\n";
|
||||
foreach ($page_tags as $tag){
|
||||
echo "<li><a href=\"/blog/by_tag/#" . $tag . "\">" . $tag . "</a></li>\n";
|
||||
}
|
||||
echo "</ul>\n</div>\n";
|
||||
}
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/modal.php');
|
||||
?>
|
||||
21
common/php/menu.php
Normal file
21
common/php/menu.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<nav class="jmenu">
|
||||
<label for="menu-btn" class="jm-menu-btn">Menu</label>
|
||||
<input type="checkbox" id="menu-btn" class="jm-menu-btn"/>
|
||||
<ul class="jm-collapse">
|
||||
<li><a href="/">Homepage</a></li>
|
||||
<li class="jm-dropdown" id="blog"><a href="/blog/"> Blog</a>
|
||||
<ul>
|
||||
<li class="jm-dropdown" id="current_year"><a href="/blog/by_year/2021/">2021</a>
|
||||
<ul>
|
||||
<li id="current_month" date="2021-10"><a href="/blog/by_year/2021/10/">10</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/blog/by_tag/">Tags</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/contact/">Contact</a></li>
|
||||
<li><a href="/license/">License</a></li>
|
||||
<li><a href="/news/">Site News</a></li>
|
||||
<li><a href="/feeds/articles.rss"><img src="/common/imgs/icon-rss.png" name="rssicon" width="20" height="20" alt="RSS Icon"/></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
5
common/php/modal.php
Normal file
5
common/php/modal.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<div id="modal_gallery" class="modal_gal">
|
||||
<span class="close_modal">×</span>
|
||||
<img class="gallery_img" id="modal_img" alt="An Image"/>
|
||||
<div id="modal_img_caption"></div>
|
||||
</div><!--End of Modal Div-->
|
||||
52
common/php/page_menu.php
Normal file
52
common/php/page_menu.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<nav id="body_nav" class="jmenu">
|
||||
<div class="pmenu">
|
||||
<ul><li><a href=/>Home</a></li></ul>
|
||||
<?php
|
||||
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/get_month_name.php');
|
||||
|
||||
//Removes the number used to keep articles in post order from the displayed title.
|
||||
function remove_sorting_number($link_title){
|
||||
$first_three = mb_substr($link_title, 0, 3,"UTF-8");
|
||||
|
||||
if ( preg_match( '/[0-9][0-9] /', $first_three) ){
|
||||
$link_title = mb_substr($link_title,3);
|
||||
}
|
||||
return $link_title;
|
||||
}
|
||||
|
||||
|
||||
$dir = '.';
|
||||
// Check if the directory exists
|
||||
if (file_exists($dir) && is_dir($dir) ) {
|
||||
// Get the files of the directory as an array
|
||||
$scan_arr = scandir($dir);
|
||||
$files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') );
|
||||
// echo "<pre>"; print_r( $files_arr ); echo "</pre>";
|
||||
// Get each files of our directory with line break
|
||||
foreach ($files_arr as $file) {
|
||||
//Get the file path
|
||||
$file_path = "./".$file;
|
||||
// Get the file extension
|
||||
$file_ext = pathinfo($file_path, PATHINFO_EXTENSION);
|
||||
if ($file_ext=="php" || $file_ext=="html" || $file_ext=="htm" || $file_ext == "") {
|
||||
$file_array[] = $file;
|
||||
}
|
||||
}
|
||||
foreach($file_array as $file) {//Renders the folder names as more readable titles.
|
||||
$_replace = array('.php', '.html', '.htm');//Remove file extensions from webpages.
|
||||
$link_title = str_replace('_',' ',$file);//Remove undersores and replace them with spaces
|
||||
$link_title = str_replace($_replace,'',$link_title);
|
||||
$link_title = ucwords($link_title);//Set the first letter of each word to upercase.
|
||||
$link_title = get_month_name($link_title);//
|
||||
$link_title = remove_sorting_number($link_title);//Removes the number used to keep articles in post order from the displayed title.
|
||||
echo("<ul><li><a href='$file'> $link_title </a></li></ul>\n");//Output the result.
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "Directory does not exists";
|
||||
}
|
||||
echo("<ul><li><a href='..'>Back</a></li></ul>\n");
|
||||
?>
|
||||
</div><!--end of pmenu-->
|
||||
</nav>
|
||||
<br>
|
||||
36
common/php/page_menu_table.php
Normal file
36
common/php/page_menu_table.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<table border="1" class="pmenu">
|
||||
<tr>
|
||||
<td><a href=/>Home</a></td>
|
||||
</tr>
|
||||
<?php
|
||||
$dir = '.';
|
||||
// Check if the directory exists
|
||||
if (file_exists($dir) && is_dir($dir) ) {
|
||||
// Get the files of the directory as an array
|
||||
$scan_arr = scandir($dir);
|
||||
$files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') );
|
||||
// echo "<pre>"; print_r( $files_arr ); echo "</pre>";
|
||||
// Get each files of our directory with line break
|
||||
foreach ($files_arr as $file) {
|
||||
//Get the file path
|
||||
$file_path = "./".$file;
|
||||
// Get the file extension
|
||||
$file_ext = pathinfo($file_path, PATHINFO_EXTENSION);
|
||||
if ($file_ext=="php" || $file_ext=="html" || $file_ext=="htm" || $file_ext == "") {
|
||||
$file_array[] = $file;
|
||||
}
|
||||
}
|
||||
foreach($file_array as $file) {
|
||||
$_replace = array('.php', '.html', '.htm');
|
||||
$link_title = str_replace('_',' ',$file);
|
||||
$link_title = str_replace($_replace,'',$link_title);
|
||||
$link_title = ucwords($link_title);
|
||||
echo("<tr><td><a href='$file'> $link_title </a></td></tr>\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "Directory does not exists";
|
||||
}
|
||||
|
||||
?>
|
||||
</table>
|
||||
Reference in New Issue
Block a user