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">
<ul>
<li><a href="/admin.php">Admin Area</a>
<li><a href="/logout.php">Log Out</a>
<li><a href="admin.php">Admin Area</a>
<li><a href="logout.php">Log Out</a>
</ul>
</nav>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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