first commit
This commit is contained in:
23
temp/cms_clearcache.php
Normal file
23
temp/cms_clearcache.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// Clear CMS cache recursively from temp/
|
||||
$temp_dir = realpath(__DIR__);
|
||||
$deleted = 0;
|
||||
|
||||
function clear_dir($dir, &$deleted) {
|
||||
foreach (glob($dir . '/*') as $item) {
|
||||
if (is_dir($item)) {
|
||||
clear_dir($item, $deleted);
|
||||
@rmdir($item);
|
||||
} elseif (is_file($item) && basename($item) !== 'cms_clearcache.php') {
|
||||
unlink($item);
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clear_dir($temp_dir, $deleted);
|
||||
echo "Cache cleared: $deleted files.\n";
|
||||
|
||||
unlink(__FILE__);
|
||||
echo "Done.\n";
|
||||
?>
|
||||
36
temp/cms_favicon.php
Normal file
36
temp/cms_favicon.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once '../config.php';
|
||||
|
||||
$pdo = new PDO(
|
||||
"mysql:host={$database['host']};dbname={$database['name']};charset=utf8",
|
||||
$database['user'],
|
||||
$database['password'],
|
||||
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
||||
);
|
||||
|
||||
$favicon_tag = '<link rel="icon" type="image/svg+xml" href="/favicon.svg">' . "\n";
|
||||
|
||||
$stmt = $pdo->query("SELECT css FROM pp_layouts WHERE id = 2");
|
||||
$layout = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (strpos($layout['css'], 'favicon') !== false) {
|
||||
echo "Favicon already present.\n";
|
||||
} else {
|
||||
$new_css = $favicon_tag . $layout['css'];
|
||||
$pdo->prepare("UPDATE pp_layouts SET css = ? WHERE id = 2")->execute([$new_css]);
|
||||
echo "Favicon link added.\n";
|
||||
}
|
||||
|
||||
// Clear cache
|
||||
$deleted = 0;
|
||||
foreach (glob(__DIR__ . '/../temp/*') as $file) {
|
||||
if (is_file($file) && basename($file) !== 'cms_favicon.php') {
|
||||
unlink($file);
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
echo "Cache cleared: $deleted files.\n";
|
||||
|
||||
unlink(__FILE__);
|
||||
echo "Done.\n";
|
||||
?>
|
||||
74
temp/cms_gen_favicon.php
Normal file
74
temp/cms_gen_favicon.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
require_once '../config.php';
|
||||
|
||||
// ─── 1. Generuj favicon.png z logo ───────────────────────────────────────────
|
||||
$logo_path = __DIR__ . '/../upload/filemanager/logo.png';
|
||||
$logo = imagecreatefrompng($logo_path);
|
||||
$lw = imagesx($logo); // 2560
|
||||
$lh = imagesy($logo); // 373
|
||||
|
||||
// Wycinamy tylko lewą część z symbolem drogi (pierwsze ~20% szerokości)
|
||||
$crop_w = (int)($lw * 0.20); // ~512px – symbol drogi bez tekstu
|
||||
$crop_h = $lh;
|
||||
|
||||
// Tworzymy kwadrat 512x512 z białym tłem
|
||||
$size = 512;
|
||||
$out = imagecreatetruecolor($size, $size);
|
||||
$white = imagecolorallocate($out, 255, 255, 255);
|
||||
imagefilledrectangle($out, 0, 0, $size-1, $size-1, $white);
|
||||
imagealphablending($out, true);
|
||||
|
||||
// Skalujemy wycięty symbol, 88% wielkości kanwy (z marginesem)
|
||||
$margin = 0.88;
|
||||
$scale = min(($size * $margin) / $crop_w, ($size * $margin) / $crop_h);
|
||||
$dst_w = (int)($crop_w * $scale);
|
||||
$dst_h = (int)($crop_h * $scale);
|
||||
$dst_x = (int)(($size - $dst_w) / 2);
|
||||
$dst_y = (int)(($size - $dst_h) / 2);
|
||||
|
||||
imagecopyresampled($out, $logo, $dst_x, $dst_y, 0, 0, $dst_w, $dst_h, $crop_w, $crop_h);
|
||||
|
||||
imagepng($out, __DIR__ . '/../favicon.png', 9);
|
||||
imagedestroy($out);
|
||||
imagedestroy($logo);
|
||||
|
||||
echo "favicon.png OK (crop {$crop_w}x{$crop_h} → {$dst_w}x{$dst_h} in {$size}x{$size})\n";
|
||||
|
||||
// ─── 2. Zaktualizuj CSS field w DB ───────────────────────────────────────────
|
||||
$pdo = new PDO(
|
||||
"mysql:host={$database['host']};dbname={$database['name']};charset=utf8",
|
||||
$database['user'], $database['password'],
|
||||
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
||||
);
|
||||
|
||||
$stmt = $pdo->query("SELECT css FROM pp_layouts WHERE id = 2");
|
||||
$css = $stmt->fetchColumn();
|
||||
|
||||
// Zamień link favicon.svg → favicon.png
|
||||
$new_css = preg_replace(
|
||||
'~<link rel="icon"[^>]+href="/favicon\.svg"[^>]*>~',
|
||||
'<link rel="icon" type="image/png" href="/favicon.png">',
|
||||
$css
|
||||
);
|
||||
|
||||
if ($new_css !== $css) {
|
||||
$pdo->prepare("UPDATE pp_layouts SET css = ? WHERE id = 2")->execute([$new_css]);
|
||||
echo "CSS field updated (svg → png).\n";
|
||||
} else {
|
||||
echo "Favicon link not found in CSS field (no change).\n";
|
||||
}
|
||||
|
||||
// ─── 3. Wyczyść cache ─────────────────────────────────────────────────────────
|
||||
$deleted = 0;
|
||||
function clear_dir($dir, &$deleted) {
|
||||
foreach (glob($dir . '/*') as $item) {
|
||||
if (is_dir($item)) { clear_dir($item, $deleted); @rmdir($item); }
|
||||
elseif (is_file($item) && basename($item) !== 'cms_gen_favicon.php') { unlink($item); $deleted++; }
|
||||
}
|
||||
}
|
||||
clear_dir(__DIR__, $deleted);
|
||||
echo "Cache cleared: $deleted files.\n";
|
||||
|
||||
unlink(__FILE__);
|
||||
echo "Done.\n";
|
||||
?>
|
||||
Reference in New Issue
Block a user