<?php
session_start();
if(!isset($_SESSION['contador'])){$_SESSION['contador'] = 0;}
?>
<!doctype html>
<html lang="es">
<head>
<link rel="icon" type="image/png" href="img\fav.png">
<link rel=Stylesheet href="css/pcmac.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.js"></script>	
<script type="text/javascript" src="js/jquery.min.js"></script>

<?php
error_reporting(5);
include "config.inc";
$conexion = mysqli_connect($serv,$dbu,$dbp,$db);
mysqli_set_charset($conexion, "utf8");
$CUENTA = mysqli_query($conexion,"SELECT COUNT(ID) AS X FROM wms_configura_altacuentas  WHERE CVE_CUENTA =".$_GET['IDS']);
$CTA = mysqli_fetch_array($CUENTA);

if($_GET['IDS'] == "" or $_GET['IDS'] == 0 or $CTA['X']== "" or $CTA['X']==0 or $CTA['X']=="0"){
	echo "</head><body><center><img width='60%' src='img/404.jpg'></center></body></html>";
	exit();}
	
		function get_access_token($url, $postdata) {
	global $clientId, $clientSecret;
	$curl = curl_init($url); 
	curl_setopt($curl, CURLOPT_POST, true); 
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($curl, CURLOPT_USERPWD, $clientId . ":" . $clientSecret);
	curl_setopt($curl, CURLOPT_HEADER, false); 
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
	$response = curl_exec( $curl );
	if (empty($response)){
	    return "";
	    curl_close($curl);
	} else {
	$info = curl_getinfo($curl);
	    curl_close($curl);
		if($info['http_code'] != 200 && $info['http_code'] != 201 ) {
			return "";}
	else{
	$jsonResponse = json_decode( $response );
	return $jsonResponse->access_token;
	}}}
	
	$sqlGR = "SELECT * FROM ecomm_cuenta WHERE CVE_CUENTA='$_GET[IDS]'";
	$resultadoGR=mysql_query($sqlGR,$conexion);
	$x = mysql_fetch_array($resultadoGR);
	
		if($x['CLIENTID']!=NULL AND $x['SECRET']!=NULL){
		if ($x['TIPO']==0){$host = 'https://api.sandbox.paypal.com';}else{$host = 'https://api.paypal.com';}
		$clientId = $x['CLIENTID'];
		$clientSecret = $x['SECRET'];
		$token = '';
		$url = $host.'/v1/oauth2/token';
		$postArgs = 'grant_type=client_credentials';
		$token = get_access_token($url,$postArgs);	
		if($token==null){echo "</head><body><center><img width='60%' src='img/404.jpg'></center></body></html>";exit();}}

$visual = mysqli_query($conexion,"SELECT * FROM ecomm_visual WHERE CVE_CUENTA=".$_GET['IDS']);
$st = mysqli_fetch_array($visual);

echo '<style>body{font-family:'.$st['FUENTE'].';background-color:'.$st['C-BACK'].';font-family: '.$st['FUENTE'].';}#contenedor{background:'.$st['C-CONTAIN'].';}.counter{color:'.$st['C-TEXTO2'].';}pb{color: '.$st['C-TEXTO'].';}#detail{color: '.$st['C-TEXTO'].';border:none;background-color:'.$st['C-ENF2'].';}#detail:hover{border:2px solid '.$st['C-ENF1'].';background-color:'.$st['C-ENF2'].';}.product img {border: solid 1px '.$st['C-ENF1'].';}.products .title a.title-link {color:'.$st['C-TEXTO'].';}.product .desc {background-color: '.$st['C-ENF1'].';background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, '.$st['C-ENF1'].'), color-stop(1, '.$st['C-ENF2'].'));}.product .desc p {color: '.$st['C-TEXTO'].';}.product .desc p.precio { color: '.$st['C-TEXTO'].';}.tooltip span {	color:'.$st['C-TMENU'].';	background:'.$st['C-MENU'].';	border:2px solid '.$st['C-ENF1'].';box-shadow:0px 2px 4px '.$st['C-ENF2'].';}.tooltip span:after {border-top:10px solid '.$st['C-ENF1'].'; border-top:10px solid '.$st['C-ENF1'].';}#cssmenu ul {background: '.$st['C-HEAD'].'; box-shadow: 0px 0px 1px 1px '.$st['C-ENF1'].';}#cssmenu li {background-color: '.$st['C-HEAD'].';}#cssmenu li a{color: '.$st['C-ICON'].';}#cssmenu li a:hover, input[type=submit]:hover{color: '.$st['C-ICON'].';border-bottom: 3px solid '.$st['C-ENF1'].';}.botoncompra{color:'.$st['C-TEXTO'].';border:none;background-color:'.$st['C-ENF2'].';}.botoncompra:hover{border:2px solid '.$st['C-ENF1'].';background-color:'.$st['C-ENF2'].';}.btn{color:'.$st['C-TEXTO'].';border:none;background-color:'.$st['C-ENF2'].';}.btn:hover{border:2px solid '.$st['C-ENF1'].';background-color:'.$st['C-ENF2'].';}.btn:focus {background-color:'.$st['C-ENF1'].';}.botoncompra:focus {background-color:'.$st['C-ENF1'].';}.less{color:'.$st['C-TEXTO'].';border:none;background-color:'.$st['C-ENF2'].';}.less:hover{border:2px solid '.$st['C-ENF1'].';background-color:'.$st['C-ENF2'].';} .less:focus {background-color:'.$st['C-ENF1'].';}</style>';

echo "<title>|| Logsys WMS || Vista previa - E-store ".$st['EMPRESA']."</title></head><body><div id='contenedor'><header ><div id='cssmenu'><ul>";							
echo "<LI><img class='logo' src='img/".$st['LOGO']."'></li>";
	echo "<LI><a href='#'><img class='icono' src='img/".$st['C-ICON']."/hom1.png'><br><span class='i'> Inicio </span></a></LI>";
		echo "<LI><a href='#'><img class='icono' src='img/".$st['C-ICON']."/menu.png'><br><span class='i'> Categorias </span></a></LI>";
			echo "<LI><a href='#'><img class='icono' src='img/".$st['C-ICON']."/myc1.png'><span class='cant' ID='carrito' STYLE='color:".$st['C-ICON'].";'>  </span><br><span class='i'> Articulos </span></a></LI>";
				?>
				</ul>
				</div>
				</header>
			<section>			