����JFIF��`�`�����Viewing File: /home/u820193700/domains/thereown.com/public_html/do_split.py
import re
import os

html_path = 'c:/xampp/htdocs/thereown/index.html'

if not os.path.exists(html_path):
    print("index.html not found!")
    exit(1)

with open(html_path, 'r', encoding='utf-8') as f:
    lines = f.readlines()

header_end = 0
footer_start = 0

for i, line in enumerate(lines):
    if '</nav>' in line:
        header_end = i
    if '<footer>' in line:
        footer_start = i
        break

header_lines = lines[:header_end + 1]
middle_lines = lines[header_end + 1:footer_start]
footer_lines = lines[footer_start:]

header_content = "".join(header_lines)
footer_content = "".join(footer_lines)
middle_content = "".join(middle_lines)

# Fix JS in footer
new_set_hero = """async function setHeroPhoto(files){
  if(!files||!files[0])return;
  const fd = new FormData();
  fd.append('files[]', files[0]);
  fd.append('kind', 'hero');
  try {
    const res = await fetch('api/index.php?action=upload', {method: 'POST', body: fd});
    const data = await res.json();
    if(data.ok && data.files.length) {
      const bg=document.getElementById("heroBg");
      bg.style.backgroundImage=`url(${data.files[0]})`;
      const bike = bg.querySelector(".hero-bike");
      if(bike) bike.style.display="none";
      showToast("Hero photo updated");
    } else {
      showToast("Upload failed");
    }
  } catch(e) {
    showToast("Upload error");
  }
}"""

footer_content = re.sub(
    r'function setHeroPhoto\(files\)\{.*?r\.readAsDataURL\(files\[0\]\);\s*\}',
    new_set_hero,
    footer_content,
    flags=re.DOTALL
)

footer_content = re.sub(
    r'\(function\(\)\{\s*const savedHero=localStorage\.getItem\("reown_hero"\);.*?\}\)\(\);',
    '',
    footer_content,
    flags=re.DOTALL
)

middle_content = middle_content.replace(
    '<div class="hero-bg" id="heroBg">',
    '<div class="hero-bg" id="heroBg" <?php if(!empty($heroUrl)) echo \'style="background-image:url(\'.$heroUrl.\')" \'; ?>>'
)
middle_content = middle_content.replace(
    '<svg class="hero-bike"',
    '<svg class="hero-bike" <?php if(!empty($heroUrl)) echo \'style="display:none;" \'; ?>'
)

index_php = """<?php
require_once __DIR__ . '/api/config.php';
$stmt = db()->query("SELECT file_path FROM media WHERE kind='hero' ORDER BY id DESC LIMIT 1");
$heroUrl = $stmt->fetchColumn();
?>
<?php include 'header.php'; ?>
""" + middle_content + """<?php include 'footer.php'; ?>\n"""

with open('c:/xampp/htdocs/thereown/header.php', 'w', encoding='utf-8') as f:
    f.write(header_content)

with open('c:/xampp/htdocs/thereown/footer.php', 'w', encoding='utf-8') as f:
    f.write(footer_content)

with open('c:/xampp/htdocs/thereown/index.php', 'w', encoding='utf-8') as f:
    f.write(index_php)

print("Split completed.")
Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����