403Webshell
Server IP : 172.67.191.97  /  Your IP : 104.23.243.197
Web Server : Apache/2.4.63 (Ubuntu)
System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.4.5
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/idiomas/media/idiomas/faq/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/idiomas/media/idiomas/faq/feed.php
<?php
declare(strict_types=1);

header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store, max-age=0');

$root = dirname(__DIR__, 3);
$configFile = $root . '/configuration.php';

if (!is_file($configFile)) {
    http_response_code(500);
    echo json_encode(['error' => 'No se encontro configuration.php']);
    exit;
}

require_once $configFile;

$config = new JConfig();
$scriptName = str_replace('\\', '/', $_SERVER['SCRIPT_NAME'] ?? '');
$basePath = preg_replace('#/media/idiomas/faq/feed\.php$#', '', $scriptName);

$assetUrl = static function (?string $path) use ($basePath): string {
    $path = trim((string) $path);

    if ($path === '' || preg_match('#^(https?:)?//#', $path) || str_starts_with($path, '/')) {
        return $path;
    }

    return $basePath . '/' . ltrim($path, '/');
};

try {
    $pdo = new PDO(
        'mysql:host=' . $config->host . ';dbname=' . $config->db . ';charset=utf8mb4',
        $config->user,
        $config->password,
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );

    $stmt = $pdo->query(
        "SELECT id, categoria, orden_cat, imagen_cat, pregunta, respuesta, orden
         FROM ciidiomas_faq
         WHERE activo = 1
         ORDER BY orden_cat ASC, orden ASC, id ASC"
    );

    $groups = [];

    foreach ($stmt as $row) {
        $category = (string) $row['categoria'];

        if (!isset($groups[$category])) {
            $groups[$category] = [
                'title' => $category,
                'order' => (int) $row['orden_cat'],
                'image' => $assetUrl($row['imagen_cat'] ?? ''),
                'items' => [],
            ];
        }

        $groups[$category]['items'][] = [
            'id' => (int) $row['id'],
            'question' => (string) $row['pregunta'],
            'answer' => (string) $row['respuesta'],
            'order' => (int) $row['orden'],
        ];
    }

    echo json_encode([
        'generatedAt' => date('c'),
        'total' => array_sum(array_map(static fn ($group) => count($group['items']), $groups)),
        'categories' => array_values($groups),
    ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} catch (Throwable $e) {
    http_response_code(500);
    echo json_encode(['error' => 'faq_feed', 'message' => $e->getMessage()], JSON_UNESCAPED_UNICODE);
}

Youez - 2016 - github.com/yon3zu
LinuXploit