import os, zipfile, textwrap, datetime, json root = "/mnt/data/norcar_site_pro_final" if not os.path.isdir(root): os.makedirs(root, exist_ok=True) # --------------- Common Snippets ----------------- GA4_ID = "G-XXXXXXXXXX" tailwind = """ """ ga4 = f""" """ header = """
""" footer = """ """ site_js = """ """ # --------------- Index (professional design) ----------------- index_html = f""" NORCAR — Soluciones financieras para empresas {tailwind} {ga4} {header}
Empresas y finanzas
Soluciones financieras para empresas en Chile

Liquidez y financiamiento con respuesta ágil

Factoring, Leasing Financiero, Leaseback, Capital de Trabajo y Créditos. Acompañamiento experto y procesos 100% digitales.

24h
Evaluación inicial
100%
Procesos digitales
+10
Años de experiencia
Equipo financiero

Servicios

Soluciones a la medida para tu empresa.

Quiénes somos

Somos NORCAR: soluciones financieras para empresas en Chile. Priorizamos respuesta rápida, acompañamiento ejecutivo y procesos 100% digitales.

Tiempo de respuesta
< 24 horas
Disponibilidad
Lun–Vie

Beneficios clave

  • Liquidez inmediata y condiciones flexibles
  • Evaluación ágil y requisitos claros
  • Acompañamiento de un ejecutivo

¿Cómo trabajamos?

Un flujo claro y rápido para tu empresa.

1

Evaluación

Revisamos tu solicitud y requisitos en menos de 24h.

2

Propuesta

Te presentamos alternativas de financiamiento a medida.

3

Desembolso

Formalización simple y desembolso oportuno.

Contacto

Cuéntanos tu necesidad y te contactamos.

También puedes escribirnos

Horario

Lunes a Viernes: 9:00 – 18:00

Síguenos

Conecta con nuestras redes para novedades y soporte.

{footer} {site_js} """ with open(os.path.join(root,"index.html"),"w",encoding="utf-8") as f: f.write(index_html) # --------------- Service pages --------------- services = { "factoring":"Liquidez inmediata anticipando el cobro de facturas.", "leasing-financiero":"Arriendo con opción de compra para tus activos.", "leaseback":"Liquidez manteniendo el uso del activo y opción de recompra.", "capital-de-trabajo":"Recursos para operar, crecer y enfrentar contingencias.", "credito-automotriz":"Crédito flexible para renovar o ampliar tu flota.", "credito-hipotecario":"Financiamiento para inversión o adquisición de inmuebles." } def service_page(title,desc,slug): return f""" {title} — NORCAR{tailwind}{ga4} {header}

{title}

{desc}

{footer} {site_js} """ pages = { "factoring.html": service_page("Factoring", services["factoring"], "factoring"), "leasing.html": service_page("Leasing Financiero", services["leasing-financiero"], "leasing-financiero"), "leaseback.html": service_page("Leaseback", services["leaseback"], "leaseback"), "capital-de-trabajo.html": service_page("Capital de Trabajo", services["capital-de-trabajo"], "capital-de-trabajo"), "credito-automotriz.html": service_page("Crédito Automotriz", services["credito-automotriz"], "credito-automotriz"), "credito-hipotecario.html": service_page("Crédito Hipotecario", services["credito-hipotecario"], "credito-hipotecario"), } for fn,content in pages.items(): with open(os.path.join(root,fn),"w",encoding="utf-8") as f: f.write(content) # --------------- contacto.php (SMTP + RUT + copy + optional WA + counter) --------------- contacto_php = r"""false,'error'=>'Método no permitido']); exit; } if (!empty($_POST['company'])) { echo json_encode(['success'=>true]); exit; } // honeypot function clean($v){ return trim($v ?? ''); } // RUT validator function rut_valido($rut) { $r = preg_replace('/[^0-9kK]/', '', $rut); if (strlen($r) < 2) return false; $body = substr($r, 0, -1); $dv = strtolower(substr($r, -1)); $s = 0; $m = 2; for ($i = strlen($body)-1; $i >= 0; $i--) { $s += intval($body[$i]) * $m; $m = ($m == 7) ? 2 : $m+1; } $resto = $s % 11; $dvc = 11 - $resto; if ($dvc == 11) $dvc = '0'; elseif ($dvc == 10) $dvc = 'k'; else $dvc = strval($dvc); return $dv == $dvc; } $name = clean($_POST['name'] ?? ''); $rut = clean($_POST['rut'] ?? ''); $company_name = clean($_POST['company_name'] ?? ''); $company_rut = clean($_POST['company_rut'] ?? ''); $phone = preg_replace('/\D+/', '', clean($_POST['phone'] ?? '')); $email = filter_var(clean($_POST['email'] ?? ''), FILTER_SANITIZE_EMAIL); $request_type = clean($_POST['request_type'] ?? ''); $message = clean($_POST['message'] ?? ''); if (!$name || !$rut || !$company_name || !$company_rut || !$phone || !$email || !$message || !$request_type) { echo json_encode(['success'=>false,'error'=>'Completa todos los campos.']); exit; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo json_encode(['success'=>false,'error'=>'Email inválido.']); exit; } if (!rut_valido($rut) || !rut_valido($company_rut)) { echo json_encode(['success'=>false,'error'=>'El RUT o el RUT de la empresa no es válido.']); exit; } // ===== PHPMailer ===== require __DIR__ . '/phpmailer/PHPMailer.php'; require __DIR__ . '/phpmailer/SMTP.php'; require __DIR__ . '/phpmailer/Exception.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; $ok_email = false; $err_email = ''; $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = $SMTP_HOST; $mail->SMTPAuth = true; $mail->Username = $SMTP_USER; $mail->Password = $SMTP_PASS; if ($SMTP_SECURE === 'tls') { $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = $SMTP_PORT ?: 587; } else { $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; $mail->Port = $SMTP_PORT ?: 465; } $mail->CharSet = 'UTF-8'; $mail->setFrom($SMTP_USER, 'Sitio Web NORCAR'); $mail->addAddress($MAIL_TO); $mail->addReplyTo($email, $name); $mail->Subject = 'Nuevo contacto desde el sitio web'; $body = "Solicitud: $request_type\nNombre: $name\nRUT: $rut\nEmpresa: $company_name\nRUT Empresa: $company_rut\nTeléfono: $phone\nEmail: $email\nMensaje:\n$message\n"; $mail->Body = $body; // Copia al cliente $mail->addCC($email); $mail->send(); $ok_email = true; // Contador de leads try { $counterFile = __DIR__ . '/contador.txt'; if (!file_exists($counterFile)) { file_put_contents($counterFile, "0", LOCK_EX); @chmod($counterFile, 0644); } $count = (int) @file_get_contents($counterFile); $count++; file_put_contents($counterFile, (string)$count, LOCK_EX); } catch (Throwable $e) {} } catch (Exception $e) { $err_email = 'Error SMTP: '.$mail->ErrorInfo; } // ===== WhatsApp Cloud API (opcional, con plantilla) ===== $wa_sent = false; $wa_err = ''; if ($USE_WHATSAPP_API && $ok_email) { $endpoint = "https://graph.facebook.com/v20.0/$WA_PHONE_NUMBER_ID/messages"; $payload = [ 'messaging_product' => 'whatsapp', 'to' => $phone, 'type' => 'template', 'template' => [ 'name' => $WA_TEMPLATE, 'language' => ['code' => $WA_LANG] ] ]; $ch = curl_init($endpoint); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $WA_TOKEN, 'Content-Type: application/json']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $resp = curl_exec($ch); $http = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http >= 200 && $http < 300) { $wa_sent = true; } else { $wa_err = 'WA HTTP '.$http.': '.$resp; } curl_close($ch); } if ($ok_email) { echo json_encode(['success'=>true,'whatsapp'=>$wa_sent,'note'=>$wa_sent?'WhatsApp enviado':'OK email; WhatsApp opcional']); } else { http_response_code(500); echo json_encode(['success'=>false,'error'=>$err_email ?: 'No se pudo enviar el correo.']); } """ with open(os.path.join(root,"contacto.php"),"w",encoding="utf-8") as f: f.write(contacto_php) # phpmailer directory placeholder os.makedirs(os.path.join(root,"phpmailer"), exist_ok=True) with open(os.path.join(root,"phpmailer","README.txt"),"w",encoding="utf-8") as f: f.write("Sube aquí los archivos de PHPMailer: PHPMailer.php, SMTP.php, Exception.php") # ver-contador with open(os.path.join(root,"ver-contador.php"),"w",encoding="utf-8") as f: f.write("\n {domain}{u}\n {today}\n weekly\n 0.8\n " for u in urls]) with open(os.path.join(root,"sitemap.xml"),"w",encoding="utf-8") as f: f.write(f'\n\n{url_entries}\n') # robots.txt with open(os.path.join(root,"robots.txt"),"w",encoding="utf-8") as f: f.write("User-agent: *\nAllow: /\n\nSitemap: https://norcar.cl/sitemap.xml\n") # README with open(os.path.join(root,"README.txt"),"w",encoding="utf-8") as f: f.write(textwrap.dedent(f""" NORCAR — Sitio profesional listo para subir a public_html/ Incluye: - Diseño hero con imagen, tarjetas de servicios, sección proceso. - index.html + 6 páginas de servicio. - contacto.php con validación de RUT, correo a empresa + copia cliente, contador de leads y WhatsApp Cloud API opcional. - .htaccess (URLs limpias, index.html->/, 404->home), sitemap.xml, robots.txt. - GA4 insertado (Measurement ID placeholder: {GA4_ID}). Pasos: 1) Sube y descomprime todo en public_html/. 2) En /phpmailer/ sube PHPMailer.php, SMTP.php, Exception.php. 3) Edita contacto.php con tu $SMTP_PASS real y, si usas WhatsApp, TOKEN/PHONE_NUMBER_ID/PLANTILLA. 4) Abre /ver-contador.php para ver total de leads. """)) # Zip it zip_path = "/mnt/data/norcar_site_PRO_FINAL.zip" with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z: for base, _, files in os.walk(root): for fn in files: full = os.path.join(base, fn) arc = os.path.relpath(full, root) z.write(full, arc) zip_path