1
0
Fork 0

Removes more root dir references and makes more relative

This commit is contained in:
sloum 2023-12-21 14:51:05 -08:00
parent 69766d187a
commit 85e8307cd3
8 changed files with 24 additions and 24 deletions

View File

@ -4,8 +4,8 @@
<nav class="admin-bar"> <nav class="admin-bar">
<ul> <ul>
<li><a href="/admin.php">Admin Area</a> <li><a href="admin.php">Admin Area</a>
<li><a href="/logout.php">Log Out</a> <li><a href="logout.php">Log Out</a>
</ul> </ul>
</nav> </nav>

View File

@ -4,7 +4,7 @@
$invalid = false; $invalid = false;
$logged_in = $_COOKIE["checkin"] ?? null; $logged_in = $_COOKIE["checkin"] ?? null;
if ( $logged_in && $logged_in == "waiting for expiry" ) { if ( $logged_in && $logged_in == "waiting for expiry" ) {
header("Location: /admin.php"); header("Location: admin.php");
die(); die();
} }
$user = $_POST["user"] ?? null; $user = $_POST["user"] ?? null;
@ -17,7 +17,7 @@
error_log( BLOG_HASH ); error_log( BLOG_HASH );
if ( $secret == BLOG_HASH ) { if ( $secret == BLOG_HASH ) {
setcookie("checkin", "waiting for expiry", time()+60*60*24*30, "/", "", false, true); setcookie("checkin", "waiting for expiry", time()+60*60*24*30, "/", "", false, true);
header("Location: /admin.php"); header("Location: admin.php");
die(); die();
} else { } else {
$invalid = true; $invalid = true;
@ -35,7 +35,7 @@ PHP;
$success = file_put_contents( PW_FILE, sprintf( $template, $secret ) ); $success = file_put_contents( PW_FILE, sprintf( $template, $secret ) );
if ( !$success ) die( "Internal server error" ); if ( !$success ) die( "Internal server error" );
setcookie("checkin", "waiting for expiry", time()+60*60*24*30, "/", "", false, true); setcookie("checkin", "waiting for expiry", time()+60*60*24*30, "/", "", false, true);
header("Location: /admin.php"); header("Location: admin.php");
die(); die();
} }
} }

View File

@ -5,13 +5,13 @@ $kind = $_GET["k"] ?? null;
// Err if all parts didnt arrive // Err if all parts didnt arrive
if ( !file || !$kind ) { if ( !file || !$kind ) {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
// Err if not a valid prefix // Err if not a valid prefix
if ( $kind !== "media" && $kind !== "posts" ) { if ( $kind !== "media" && $kind !== "posts" ) {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
@ -20,16 +20,16 @@ $path = realpath( $kind . "/" . $file );
// Err if file does not exist // Err if file does not exist
if ( !file_exists($path) ) { if ( !file_exists($path) ) {
error_log( "File does not exist: " . $path ); error_log( "File does not exist: " . $path );
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
if ( is_writable( $path ) ) { if ( is_writable( $path ) ) {
$success = unlink( $path ) ? "6" : "0"; $success = unlink( $path ) ? "6" : "0";
header("Location: /admin.php?success=" . $success); header("Location: admin.php?success=" . $success);
die(); die();
} else { } else {
error_log( "File not writable: " . $path ); error_log( "File not writable: " . $path );
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }

View File

@ -10,10 +10,10 @@
if ( $update && $f ) { if ( $update && $f ) {
$success = file_put_contents( $f, $update ); $success = file_put_contents( $f, $update );
if ( $success ) { if ( $success ) {
header("Location: /admin.php?success=2"); header("Location: admin.php?success=2");
die(); die();
} else { } else {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
} }
@ -31,11 +31,11 @@
} }
$update = file_get_contents( $f ); $update = file_get_contents( $f );
if ( !$update ) { if ( !$update ) {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
} else { } else {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
?> ?>

View File

@ -7,6 +7,6 @@ if ( __FILE__ == $_SERVER['SCRIPT_FILENAME'] ) {
$logged_in = $_COOKIE["checkin"] ?? null; $logged_in = $_COOKIE["checkin"] ?? null;
if ( !$logged_in || $logged_in != "waiting for expiry" ) { if ( !$logged_in || $logged_in != "waiting for expiry" ) {
header("Location: /blog_log.php"); header("Location: blog_log.php");
die(); die();
} }

View File

@ -3,6 +3,6 @@
if ( $logged_in && $logged_in == "waiting for expiry" ) { if ( $logged_in && $logged_in == "waiting for expiry" ) {
setcookie("checkin", "", time() - 3600); setcookie("checkin", "", time() - 3600);
} }
header("Location: /blog_log.php"); header("Location: blog_log.php");
die(); die();

View File

@ -2,7 +2,7 @@
// Bounce if not logged in // Bounce if not logged in
$logged_in = $_COOKIE["checkin"] ?? null; $logged_in = $_COOKIE["checkin"] ?? null;
if ( !$logged_in || $logged_in != "waiting for expiry" ) { if ( !$logged_in || $logged_in != "waiting for expiry" ) {
header("Location: /blog_log.php"); header("Location: blog_log.php");
die(); die();
} }
@ -12,7 +12,7 @@
// Bounce if requirements are not met for the post // Bounce if requirements are not met for the post
if ( !$title || !$body || $title == "" || $body == "" ) { if ( !$title || !$body || $title == "" || $body == "" ) {
header("Location: /blog_log.php?success=0"); header("Location: blog_log.php?success=0");
die(); die();
} }
@ -20,9 +20,9 @@
$success = file_put_contents( "./posts/" . $ts . "_" . urlencode( $title ) . ".md", $body ); $success = file_put_contents( "./posts/" . $ts . "_" . urlencode( $title ) . ".md", $body );
if ( $success ) { if ( $success ) {
// Yay! Redirect to admin // Yay! Redirect to admin
header("Location: /admin.php?success=1"); header("Location: admin.php?success=1");
die(); die();
} else { } else {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }

View File

@ -5,7 +5,7 @@
if ( !is_null( $simplecss ) ) { if ( !is_null( $simplecss ) ) {
$file_data = file_get_contents( "config.php" ); $file_data = file_get_contents( "config.php" );
if ( !$file_data ) { if ( !$file_data ) {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
$re = '/(const\s+SIMPLE_CSS\s+=\s+)(true|false)(\s*;)/m'; $re = '/(const\s+SIMPLE_CSS\s+=\s+)(true|false)(\s*;)/m';
@ -13,14 +13,14 @@
$result = preg_replace($re, $subst, $file_data); $result = preg_replace($re, $subst, $file_data);
$success = file_put_contents( "config.php", $result ); $success = file_put_contents( "config.php", $result );
if ( $success ) { if ( $success ) {
header("Location: /admin.php?success=2"); header("Location: admin.php?success=2");
die(); die();
} else { } else {
header("Location: /admin.php?success=0"); header("Location: admin.php?success=0");
die(); die();
} }
} }
header("Location: /admin.php"); header("Location: admin.php");
die(); die();