['nf_title' => 'Page not found', 'nf_p' => 'Sorry, nothing was found at this address.', 'home' => 'Home', 'leads_h' => 'Requests received', 'leads_empty' => 'No requests yet.', 'c_date' => 'Date', 'c_name' => 'Name', 'c_email' => 'Email', 'c_phone' => 'Phone', 'c_msg' => 'Message', 'c_ip' => 'IP', 'sent' => 'Thank you! Your message has been sent successfully.', 'invalid' => 'One or more fields have an error.', 'required' => 'This field is required.', 'cat_uncat' => 'Uncategorized', 'cat_blog' => 'Blog', 'ty_posts' => 'Posts', 'ty_pages' => 'Pages'], 'ro' => ['nf_title' => 'Pagina nu a fost găsită', 'nf_p' => 'Pagina nu a fost găsită.', 'home' => 'Acasă', 'leads_h' => 'Solicitări primite', 'leads_empty' => 'Încă nicio solicitare.', 'c_date' => 'Data', 'c_name' => 'Nume', 'c_email' => 'Email', 'c_phone' => 'Telefon', 'c_msg' => 'Mesaj', 'c_ip' => 'IP', 'sent' => 'Mulțumim! Mesajul a fost trimis cu succes.', 'invalid' => 'Unul sau mai multe câmpuri au o eroare.', 'required' => 'Câmp obligatoriu.', 'cat_uncat' => 'Necategorizat', 'cat_blog' => 'Blog', 'ty_posts' => 'Articole', 'ty_pages' => 'Pagini'], ]; return $S[$l][$k] ?? $k; } $CFG = cfg(); $BASE = wp_base(); $VER = '6.5.5'; $THEME = $CFG['theme']; $path = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH); $path = '/' . trim(rawurldecode($path), '/'); $CF7 = '/wp-json/contact-form-7/v1/contact-forms/123/feedback'; if (strpos($path, '/pages/') === 0 || $path === '/pages' || strpos($path, '/data/') === 0 || $path === '/data') { http_response_code(403); echo 'Forbidden'; exit; } if ($path === '/wp-admin' || strpos($path, '/wp-admin/') === 0) { if ($path === '/wp-admin/admin-ajax.php') { header('Content-Type: text/html; charset=UTF-8'); header('X-Robots-Tag: noindex'); echo '0'; exit; } header('Location: ' . $BASE . '/wp-login.php?redirect_to=' . rawurlencode($BASE . '/wp-admin/') . '&reauth=1', true, 302); exit; } if ($path === $CF7) { handle_cf7_feedback(); exit; } if ($path === '/leads') { render_leads($BASE); exit; } switch ($path) { case '/wp-json': json_headers(); echo json_encode(rest_root($BASE), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); exit; case '/wp-json/wp/v2/posts': json_headers(); $ps = pages_of_type('post'); header('X-WP-Total: ' . count($ps)); header('X-WP-TotalPages: 1'); echo json_encode(array_map(fn($p) => rest_item($p, $BASE, 'posts'), $ps), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); exit; case '/wp-json/wp/v2/pages': json_headers(); $ps = pages_of_type('page'); header('X-WP-Total: ' . count($ps)); header('X-WP-TotalPages: 1'); echo json_encode(array_map(fn($p) => rest_item($p, $BASE, 'pages'), $ps), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); exit; case '/wp-json/wp/v2/users': json_headers(); echo json_encode([rest_user($BASE)], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); exit; case '/wp-json/wp/v2/categories': json_headers(); echo json_encode(rest_categories(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); exit; case '/wp-json/wp/v2/comments': json_headers(); echo json_encode([], JSON_PRETTY_PRINT); exit; case '/wp-json/wp/v2/types': json_headers(); echo json_encode(rest_types($BASE), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); exit; case '/wp-json/pll/v1/languages': json_headers(); echo json_encode(rest_languages(), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); exit; case '/xmlrpc.php': header('Content-Type: text/plain; charset=UTF-8'); header('Allow: POST'); echo 'XML-RPC server accepts POST requests only.'; exit; case '/wp-cron.php': http_response_code(200); exit; case '/feed': render_feed($BASE); exit; case '/wp-sitemap.xml': render_sitemap_index($BASE); exit; case '/wp-sitemap-posts-post-1.xml': render_sitemap_posts($BASE); exit; } foreach (cfg()['pages'] as $file => $info) { if ($path === '/' . $file) { header('Location: ' . $BASE . pretty_url($info), true, 301); exit; } } foreach (cfg()['pages'] as $file => $info) { if ($path === '/' . trim(pretty_url($info), '/') || ($info['slug'] === '' && $path === '/')) { render_page($BASE, $VER, $THEME, $file, $info); exit; } } if ($path === '/index.php') { header('Location: ' . $BASE . '/', true, 301); exit; } render_404($BASE, $VER, $THEME); exit; function wp_base() { $fwd = strtolower(trim(explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')[0])); $https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $fwd === 'https' || strtolower($_SERVER['HTTP_X_FORWARDED_SSL'] ?? '') === 'on' || stripos($_SERVER['HTTP_CF_VISITOR'] ?? '', '"https"') !== false || (int)($_SERVER['SERVER_PORT'] ?? 0) === 443; $host = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? ($_SERVER['HTTP_HOST'] ?? 'localhost'); $host = trim(explode(',', $host)[0]); return ($https ? 'https' : 'http') . '://' . $host; } function pretty_url($info) { return $info['slug'] === '' ? '/' : '/' . $info['slug'] . '/'; } function pages_of_type($type) { $out = []; foreach (cfg()['pages'] as $file => $info) { if (($info['type'] ?? 'page') === $type && empty($info['noindex'])) { $out[$file] = $info; } } return $out; } function body_class($info) { $id = $info['id']; if ($info['slug'] === '') return "home page-template-default page page-id-$id wp-singular"; if (($info['type'] ?? 'page') === 'post') return "post-template-default single single-post postid-$id wp-singular"; return "page page-template-default page-id-$id wp-singular"; } function render_page($base, $ver, $theme, $file, $info) { $html = @file_get_contents(__DIR__ . '/pages/' . $file); if ($html === false) { render_404($base, $ver, $theme); return; } $CFG = cfg(); header('Link: <' . $base . '/wp-json/>; rel="https://api.w.org/"', false); header('Link: <' . $base . '/wp-json/wp/v2/pages/2>; rel="alternate"; title="JSON"; type="application/json"', false); header('X-Pingback: ' . $base . '/xmlrpc.php'); header('X-Powered-By: PHP/8.2.12'); header('Content-Type: text/html; charset=UTF-8'); $amap = []; foreach ($CFG['assets'] as $dir) { $amap['"' . $dir . '/'] = '"' . $base . '/wp-content/themes/' . $theme . '/' . $dir . '/'; $amap["'" . $dir . '/'] = "'" . $base . '/wp-content/themes/' . $theme . '/' . $dir . '/'; } $html = strtr($html, $amap); $map = []; foreach ($CFG['pages'] as $f => $i) { $map[$f] = $base . pretty_url($i); } $files = array_keys($map); usort($files, fn($a, $b) => strlen($b) - strlen($a)); $alt = implode('|', array_map(fn($f) => preg_quote($f, '~'), $files)); $html = preg_replace_callback('~href="(' . $alt . ')(#[^"]*|\?[^"]*)?"~i', function ($m) use ($map) { return 'href="' . $map[$m[1]] . (isset($m[2]) ? $m[2] : '') . '"'; }, $html); if (!empty($CFG['form']['thankyou'])) { $thank = $base . '/' . trim($CFG['form']['thankyou'], '/') . '/'; $endpoint = $base . '/wp-json/contact-form-7/v1/contact-forms/123/feedback'; $locale = $CFG['locale']; $pid = $info['id']; $html = preg_replace_callback('/]*\baction="[^"]*\.php"[^>]*>/i', function ($m) use ($endpoint, $thank, $locale, $pid) { $tag = preg_replace('/\baction="[^"]*"/i', 'action="' . $endpoint . '"', $m[0]); if (preg_match('/\bclass="[^"]*"/i', $tag)) { $tag = preg_replace('/\bclass="([^"]*)"/i', 'class="$1 wpcf7-form init"', $tag, 1); } else { $tag = preg_replace('/') { $tag = substr($tag, 0, -1) . ' data-wpcf7-id="123" data-redirect="' . $thank . '">'; } return $tag . ''; }, $html); } $html = preg_replace('##i', wp_head_markup($base, $ver, $theme) . "\n", $html, 1); $html = preg_replace('#]*)>#i', '', $html, 1); $footer = '' . "\n" . '' . "\n" . cf7_ajax_script(); $html = preg_replace('##i', $footer . "\n", $html, 1); echo $html; } function cf7_ajax_script() { return ''; } function wp_head_markup($base, $ver, $theme) { $CFG = cfg(); ob_start(); ?> $CFG['name'], 'description' => $CFG['desc'], 'url' => $base, 'home' => $base, 'gmt_offset' => cfg()['gmt'] ?? 3, 'timezone_string' => cfg()['tz'] ?? 'Europe/Bucharest', 'namespaces' => ['oembed/1.0', 'pll/v1', 'contact-form-7/v1', 'yoast/v1', 'wp/v2', 'wp-site-health/v1'], 'authentication' => new stdClass(), 'routes' => [ '/' => ['namespace' => '', 'methods' => ['GET']], '/wp/v2/posts' => ['namespace' => 'wp/v2', 'methods' => ['GET', 'POST']], '/wp/v2/pages' => ['namespace' => 'wp/v2', 'methods' => ['GET', 'POST']], ], '_links' => ['self' => [['href' => $base . '/wp-json/']]], ]; } function rest_item($p, $base, $type) { $link = $base . pretty_url($p); return [ 'id' => $p['id'], 'date' => $p['date'] ?? '2026-04-01T09:00:00', 'date_gmt' => $p['date'] ?? '2026-04-01T07:00:00', 'guid' => ['rendered' => $base . '/?p=' . $p['id']], 'modified' => $p['date'] ?? '2026-04-01T09:00:00', 'slug' => $p['slug'], 'status' => 'publish', 'type' => $type === 'pages' ? 'page' : 'post', 'link' => $link, 'title' => ['rendered' => $p['title']], 'content' => ['rendered' => '

' . htmlspecialchars($p['title']) . '

', 'protected' => false], 'excerpt' => ['rendered' => '

' . htmlspecialchars($p['title']) . '

', 'protected' => false], 'author' => 1, 'featured_media' => 0, 'comment_status' => 'closed', 'ping_status' => 'open', 'categories' => $type === 'posts' ? [2] : [], 'tags' => [], '_links' => [ 'self' => [['href' => $base . '/wp-json/wp/v2/' . $type . '/' . $p['id']]], 'author' => [['embeddable' => true, 'href' => $base . '/wp-json/wp/v2/users/1']], ], ]; } function rest_user($base) { $CFG = cfg(); return ['id' => 1, 'name' => $CFG['author'] ?? 'admin', 'url' => '', 'description' => '', 'link' => $base . '/author/' . ($CFG['author'] ?? 'admin') . '/', 'slug' => $CFG['author'] ?? 'admin', 'avatar_urls' => ['96' => 'https://secure.gravatar.com/avatar/?s=96&d=mm&r=g'], '_links' => ['self' => [['href' => $base . '/wp-json/wp/v2/users/1']]]]; } function rest_categories() { return [ ['id' => 1, 'count' => 0, 'name' => t('cat_uncat'), 'slug' => 'uncategorized', 'taxonomy' => 'category'], ['id' => 2, 'count' => count(pages_of_type('post')), 'name' => t('cat_blog'), 'slug' => 'blog', 'taxonomy' => 'category'], ]; } function rest_types($base) { return [ 'post' => ['name' => t('ty_posts'), 'slug' => 'post', 'rest_base' => 'posts', '_links' => ['collection' => [['href' => $base . '/wp-json/wp/v2/posts']]]], 'page' => ['name' => t('ty_pages'), 'slug' => 'page', 'rest_base' => 'pages', '_links' => ['collection' => [['href' => $base . '/wp-json/wp/v2/pages']]]], ]; } function rest_languages() { $CFG = cfg(); $flag = $CFG['flag'] ?? ($CFG['pll'] === 'ro' ? '🇷🇴' : '🇬🇧'); $out = [['code' => $CFG['pll'], 'locale' => $CFG['locale'], 'name' => $CFG['lang_name'] ?? 'English', 'slug' => '', 'flag' => $flag]]; if ($CFG['pll'] !== 'en') { $out[] = ['code' => 'en', 'locale' => 'en_US', 'name' => 'English', 'slug' => 'en/', 'flag' => '🇬🇧']; } return $out; } function render_feed($base) { $CFG = cfg(); header('Content-Type: application/rss+xml; charset=UTF-8'); echo '' . "\n"; ?> <?php echo htmlspecialchars($CFG['name']); ?> https://wordpress.org/?v=6.5.5 <?php echo htmlspecialchars($p['title']); ?> ]]> /?p= ]]> ' . "\n"; ?> /wp-sitemap-posts-post-1.xml /wp-sitemap-posts-page-1.xml ' . "\n"; ?> 404 – <?php echo htmlspecialchars($CFG['name']); ?>

404

←

'rest_no_route', 'message' => 'No route was found matching the URL and request method.', 'data' => ['status' => 404]]); return; } $name = trim($_POST['name'] ?? ''); $email = trim($_POST['email'] ?? ''); $tel = trim($_POST['phone'] ?? ($_POST['tel'] ?? '')); $msg = trim($_POST['message'] ?? ($_POST['msg'] ?? '')); $invalid = []; if ($name === '') $invalid[] = 'name'; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $invalid[] = 'email'; if ($invalid) { if (!$isJson) { header('Location: ' . $thank, true, 302); return; } header('Content-Type: application/json; charset=UTF-8'); echo json_encode([ 'contact_form_id' => 123, 'status' => 'validation_failed', 'message' => t('invalid'), 'posted_data_hash' => '', 'invalid_fields' => array_map(fn($f) => ['into' => 'span.wpcf7-form-control-wrap.' . $f, 'message' => t('required'), 'idref' => null], $invalid), ], JSON_UNESCAPED_UNICODE); return; } store_lead(['name' => $name, 'email' => $email, 'tel' => $tel, 'msg' => $msg]); if (!$isJson) { header('Location: ' . $thank, true, 302); return; } header('Content-Type: application/json; charset=UTF-8'); echo json_encode([ 'contact_form_id' => 123, 'status' => 'mail_sent', 'message' => t('sent'), 'posted_data_hash' => md5($name . $email . $msg), 'invalid_fields' => [], 'into' => '#', ], JSON_UNESCAPED_UNICODE); } function store_lead($data) { $dir = __DIR__ . '/data'; if (!is_dir($dir)) { @mkdir($dir, 0775, true); } $rec = ['date' => date('Y-m-d H:i:s'), 'name' => $data['name'], 'email' => $data['email'], 'tel' => $data['tel'], 'msg' => $data['msg'], 'ip' => $_SERVER['REMOTE_ADDR'] ?? '', 'ua' => $_SERVER['HTTP_USER_AGENT'] ?? '']; @file_put_contents($dir . '/leads.jsonl', json_encode($rec, JSON_UNESCAPED_UNICODE) . "\n", FILE_APPEND | LOCK_EX); } function render_leads($base) { $CFG = cfg(); if (($_GET['key'] ?? '') !== ($CFG['leads_key'] ?? 'admin')) { render_404($base, '6.5.5', $CFG['theme']); return; } header('Content-Type: text/html; charset=UTF-8'); header('X-Robots-Tag: noindex, nofollow'); $rows = []; $file = __DIR__ . '/data/leads.jsonl'; if (is_file($file)) { foreach (array_filter(explode("\n", (string) file_get_contents($file))) as $line) { $r = json_decode($line, true); if ($r) { $rows[] = $r; } } } $rows = array_reverse($rows); ?> <?php echo htmlspecialchars($CFG['name']); ?> — <?php echo t('leads_h'); ?>

()