Update the rest of the PHP functions to use camelCase

This commit is contained in:
johnnyq
2026-07-23 17:39:06 -04:00
parent 3d94846a61
commit 9c65644adc
27 changed files with 121 additions and 198 deletions

View File

@@ -79,7 +79,7 @@ $phpConfig[] = [
];
// Check upload_max_filesize and post_max_size >= 500M
function return_bytes($val) {
function toBytes($val) {
$val = trim($val);
$unit = strtolower(substr($val, -1));
$num = (float)$val;
@@ -99,8 +99,8 @@ $required_bytes = 500 * 1024 * 1024; // 500M in bytes
$upload_max_filesize = ini_get('upload_max_filesize');
$post_max_size = ini_get('post_max_size');
$upload_passed = return_bytes($upload_max_filesize) >= $required_bytes;
$post_passed = return_bytes($post_max_size) >= $required_bytes;
$upload_passed = toBytes($upload_max_filesize) >= $required_bytes;
$post_passed = toBytes($post_max_size) >= $required_bytes;
$phpConfig[] = [
'name' => 'upload_max_filesize >= 500M',
@@ -116,7 +116,7 @@ $phpConfig[] = [
// PHP Memory Limit >= 128M
$memoryLimit = ini_get('memory_limit');
$memoryLimitBytes = return_bytes($memoryLimit);
$memoryLimitBytes = toBytes($memoryLimit);
$memoryLimitPassed = $memoryLimitBytes >= (128 * 1024 * 1024);
$phpConfig[] = [
'name' => 'PHP Memory Limit >= 128M',

View File

@@ -301,7 +301,7 @@
while ($row = mysqli_fetch_assoc($sql_custom_links)) {
$custom_link_name = escapeHtml($row['custom_link_name']);
$custom_link_uri = sanitize_url($row['custom_link_uri']);
$custom_link_uri = escapeUrl($row['custom_link_uri']);
$custom_link_icon = escapeHtml($row['custom_link_icon']);
$custom_link_new_tab = intval($row['custom_link_new_tab']);
if ($custom_link_new_tab == 1) {

View File

@@ -18,7 +18,7 @@ if (function_exists('ini_set')) {
/**
* Write a line to a file handle with newline.
*/
function fwrite_ln($fh, string $s): void {
function writeLine($fh, string $s): void {
fwrite($fh, $s);
fwrite($fh, PHP_EOL);
}
@@ -31,7 +31,7 @@ function fwrite_ln($fh, string $s): void {
*
* NOTE: Routines/events are not dumped here. Add if needed.
*/
function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
function dumpDatabase(mysqli $mysqli, string $sqlFile): void {
$fh = fopen($sqlFile, 'wb');
if (!$fh) {
http_response_code(500);
@@ -39,12 +39,12 @@ function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
}
// Preamble
fwrite_ln($fh, "-- UTF-8 + Foreign Key Safe Dump");
fwrite_ln($fh, "SET NAMES 'utf8mb4';");
fwrite_ln($fh, "SET FOREIGN_KEY_CHECKS = 0;");
fwrite_ln($fh, "SET UNIQUE_CHECKS = 0;");
fwrite_ln($fh, "SET AUTOCOMMIT = 0;");
fwrite_ln($fh, "");
writeLine($fh, "-- UTF-8 + Foreign Key Safe Dump");
writeLine($fh, "SET NAMES 'utf8mb4';");
writeLine($fh, "SET FOREIGN_KEY_CHECKS = 0;");
writeLine($fh, "SET UNIQUE_CHECKS = 0;");
writeLine($fh, "SET AUTOCOMMIT = 0;");
writeLine($fh, "");
// Gather tables and views
$tables = [];
@@ -80,12 +80,12 @@ function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
$createSQL = array_values($createRow)[1] ?? '';
$createRes->close();
fwrite_ln($fh, "-- ----------------------------");
fwrite_ln($fh, "-- Table structure for `{$table}`");
fwrite_ln($fh, "-- ----------------------------");
fwrite_ln($fh, "DROP TABLE IF EXISTS `{$table}`;");
fwrite_ln($fh, $createSQL . ";");
fwrite_ln($fh, "");
writeLine($fh, "-- ----------------------------");
writeLine($fh, "-- Table structure for `{$table}`");
writeLine($fh, "-- ----------------------------");
writeLine($fh, "DROP TABLE IF EXISTS `{$table}`;");
writeLine($fh, $createSQL . ";");
writeLine($fh, "");
// Dump data in a streaming fashion
$dataRes = $mysqli->query("SELECT * FROM `{$mysqli->real_escape_string($table)}`", MYSQLI_USE_RESULT);
@@ -93,7 +93,7 @@ function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
$wroteHeader = false;
while ($row = $dataRes->fetch_assoc()) {
if (!$wroteHeader) {
fwrite_ln($fh, "-- Dumping data for table `{$table}`");
writeLine($fh, "-- Dumping data for table `{$table}`");
$wroteHeader = true;
}
$cols = array_map(fn($c) => '`' . $mysqli->real_escape_string($c) . '`', array_keys($row));
@@ -103,10 +103,10 @@ function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
},
array_values($row)
);
fwrite_ln($fh, "INSERT INTO `{$table}` (" . implode(", ", $cols) . ") VALUES (" . implode(", ", $vals) . ");");
writeLine($fh, "INSERT INTO `{$table}` (" . implode(", ", $cols) . ") VALUES (" . implode(", ", $vals) . ");");
}
$dataRes->close();
if ($wroteHeader) fwrite_ln($fh, "");
if ($wroteHeader) writeLine($fh, "");
}
}
@@ -119,14 +119,14 @@ function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
$createView = $row['Create View'] ?? '';
$cRes->close();
fwrite_ln($fh, "-- ----------------------------");
fwrite_ln($fh, "-- View structure for `{$view}`");
fwrite_ln($fh, "-- ----------------------------");
fwrite_ln($fh, "DROP VIEW IF EXISTS `{$view}`;");
writeLine($fh, "-- ----------------------------");
writeLine($fh, "-- View structure for `{$view}`");
writeLine($fh, "-- ----------------------------");
writeLine($fh, "DROP VIEW IF EXISTS `{$view}`;");
// Ensure statement ends with semicolon
if (!str_ends_with($createView, ';')) $createView .= ';';
fwrite_ln($fh, $createView);
fwrite_ln($fh, "");
writeLine($fh, $createView);
writeLine($fh, "");
}
}
@@ -142,22 +142,22 @@ function dump_database_streaming(mysqli $mysqli, string $sqlFile): void {
$createTrig = $row['SQL Original Statement'] ?? ($row['Create Trigger'] ?? '');
$crt->close();
fwrite_ln($fh, "-- ----------------------------");
fwrite_ln($fh, "-- Trigger for `{$triggerName}`");
fwrite_ln($fh, "-- ----------------------------");
fwrite_ln($fh, "DROP TRIGGER IF EXISTS `{$triggerName}`;");
writeLine($fh, "-- ----------------------------");
writeLine($fh, "-- Trigger for `{$triggerName}`");
writeLine($fh, "-- ----------------------------");
writeLine($fh, "DROP TRIGGER IF EXISTS `{$triggerName}`;");
if (!str_ends_with($createTrig, ';')) $createTrig .= ';';
fwrite_ln($fh, $createTrig);
fwrite_ln($fh, "");
writeLine($fh, $createTrig);
writeLine($fh, "");
}
}
$tRes->close();
}
// Postamble
fwrite_ln($fh, "SET FOREIGN_KEY_CHECKS = 1;");
fwrite_ln($fh, "SET UNIQUE_CHECKS = 1;");
fwrite_ln($fh, "COMMIT;");
writeLine($fh, "SET FOREIGN_KEY_CHECKS = 1;");
writeLine($fh, "SET UNIQUE_CHECKS = 1;");
writeLine($fh, "COMMIT;");
fclose($fh);
}
@@ -235,7 +235,7 @@ if (isset($_GET['download_backup'])) {
}
// === Generate SQL Dump (streaming) ===
dump_database_streaming($mysqli, $sqlFile);
dumpDatabase($mysqli, $sqlFile);
// === Zip the uploads folder (strict) ===
zipFolderStrict("../uploads", $uploadsZip);

View File

@@ -2,7 +2,7 @@
require_once "includes/inc_all_admin.php";
// ---- Tiny status dot for tab labels ----------------------------------------
function mail_status_dot($on) {
function renderMailStatusDot($on) {
return $on
? '<i class="fas fa-circle text-success ml-2" style="font-size:.5rem;vertical-align:middle;" title="Configured"></i>'
: '<i class="far fa-circle text-muted ml-2" style="font-size:.5rem;vertical-align:middle;" title="Not configured"></i>';
@@ -64,12 +64,12 @@ $imap_ready = $imap_standard_ready || $imap_oauth_ready;
<ul class="nav nav-tabs" id="mailTabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" href="#tab-smtp" data-target="#tab-smtp">
<i class="fas fa-fw fa-paper-plane mr-1"></i>Sending<?php echo mail_status_dot($smtp_on); ?>
<i class="fas fa-fw fa-paper-plane mr-1"></i>Sending<?php echo renderMailStatusDot($smtp_on); ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#tab-imap" data-target="#tab-imap">
<i class="fas fa-fw fa-inbox mr-1"></i>Receiving<?php echo mail_status_dot($imap_on); ?>
<i class="fas fa-fw fa-inbox mr-1"></i>Receiving<?php echo renderMailStatusDot($imap_on); ?>
</a>
</li>
<li class="nav-item" id="tabitem-oauth" style="<?php echo $oauth_needed ? '' : 'display:none;'; ?>">