Pith - miter
miter/back/tenon/tenon_inserts_edit.php [1.6 kb]
Modified: 17:48:40 114 026 (11 Jul 026)
14 Days Ago
<?php
declare(strict_types=1);
session_start();

if (empty($_SESSION['miter'])) {
	header('Location: ../../index.php');
	exit;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
	// delete file + entry
	$txt_file = "tenon_inserts.txt";
	if (file_exists($txt_file) && is_file($txt_file)) {
		unlink($txt_file);
	}

	// get post
	$more_butt_post = $_POST["more_butt"] ?? '';

	include '../admin/otc.php';

		// errors
		$log_file = __DIR__ . '/../admin/log.txt'; 
		
		$log_custom_error = function($message) use ($log_file, $o_date) {
			$error_log_data = ($o_date ?? ' ') . " -- " . $message . PHP_EOL;
			file_put_contents($log_file, $error_log_data, FILE_APPEND | LOCK_EX);
		};

		if (empty($txt_file)) { 
		    $log_custom_error("Error: File path is empty.");
		    header('Location: ../../index.php');
		    exit;
		}
		
		$tenon_dir = dirname($txt_file);
		if (!is_dir($tenon_dir)) { 
		    $log_custom_error("Error: Dir $tenon_dir does not exist.");
		    header('Location: ../../index.php');
		    exit; 
		}
		if (!is_writable($tenon_dir)) { 
		    $log_custom_error("Error: Dir $tenon_dir is not writable.");
		    header('Location: ../../index.php');
		    exit; 
		}
	
	// create and write
	try {
	    $write_status = file_put_contents($txt_file, $more_butt_post, LOCK_EX);
	    if ($write_status === false) { 
	        throw new Exception("Failed to write stream."); 
	    }
	} catch (\Throwable $e) { 
	    $log_custom_error("Exception: " . $e->getMessage());
	}

	header("location:../../index.php?u=tenon_inserts");
	exit;
} else {
	header('Location: ../../index.php');
	exit;
}
?>
Updates
Wedge - Android 126.026
Wedge - Linux 124.026
Shim - Android 117.026
Miter - 114.026
Kerf - Android 112.026
Dev
TVShow (227) 'CSA'
TVShow (228) 'APT'
TVProgram (83) 'BXT'
Miter Update(s)
Peen (Messaging)

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)