Initial production backup

This commit is contained in:
Tesscorp
2026-07-15 19:45:08 -06:00
commit 65b7af866f
433 changed files with 24089 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
<?php
/**
* Blog Configuration - TRIMAPE
* Conexión PDO a la base de datos trimape_blog (separada de producción)
*/
// --- Database ---
define('DB_HOST', 'localhost');
define('DB_NAME', 'trimape_blog');
define('DB_USER', 'trimape_blog_usr');
define('DB_PASS', 'Tr1m4p3Bl0g2026!xK');
define('DB_CHARSET', 'utf8mb4');
// --- Blog Settings ---
define('BLOG_TITLE', 'Blog - TRIMAPE');
define('BLOG_DESCRIPTION', 'Artículos sobre mantenimiento industrial, eficiencia energética y más.');
define('BLOG_URL', 'https://trimape.mx/blog');
define('SITE_URL', 'https://trimape.mx');
define('POSTS_PER_PAGE', 6);
define('UPLOAD_DIR', __DIR__ . '/uploads/');
define('UPLOAD_URL', BLOG_URL . '/uploads/');
define('MAX_UPLOAD_SIZE', 5 * 1024 * 1024); // 5MB
// --- PDO Connection ---
function getDB(): PDO {
static $pdo = null;
if ($pdo === null) {
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=' . DB_CHARSET;
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
}
return $pdo;
}
// --- Helper Functions ---
function e(string $str): string {
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
function slugify(string $text): string {
$text = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $text);
$text = preg_replace('/[^a-zA-Z0-9\s-]/', '', $text);
$text = strtolower(trim($text));
$text = preg_replace('/[\s-]+/', '-', $text);
return $text;
}
function truncate(string $text, int $length = 150): string {
$text = strip_tags($text);
if (mb_strlen($text) <= $length) return $text;
return mb_substr($text, 0, $length) . '...';
}
function timeAgo(string $datetime): string {
$now = new DateTime();
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
if ($diff->y > 0) return $diff->y . ' año' . ($diff->y > 1 ? 's' : '');
if ($diff->m > 0) return $diff->m . ' mes' . ($diff->m > 1 ? 'es' : '');
if ($diff->d > 0) return $diff->d . ' día' . ($diff->d > 1 ? 's' : '');
if ($diff->h > 0) return $diff->h . ' hora' . ($diff->h > 1 ? 's' : '');
return 'hace un momento';
}
// Create uploads directory if not exists
if (!is_dir(UPLOAD_DIR)) {
mkdir(UPLOAD_DIR, 0755, true);
}