<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update from Cosmores</title>
</head>
<?php require_once "../includes/connect.php"; ?>

<body>
<div id="spanTest"></div>
<?php
$counte=0;
//empty db
mysql_query("TRUNCATE reviews");
//read members
$sql2 = "SELECT * FROM siteinfo where  id='1'";

$result2 = mysql_query($sql2);
   $countmem=0;	
	while ($myrow=mysql_fetch_array($result2)) {
	        $countmem++;
			$idmem=$myrow['id'];
			$uuid=$myrow['code'];
		
	
		
echo $uuid;
?>
<div>
<?php echo $countmem ?> . <?php echo $member2 ?>
<br />
<?php echo $online ?><br />
<?php

//connect to cosmores if  uuid and online exists 
if (($idmem!="") ) {
echo "https://hotelier.cosmores.com/services/get_reviews.php?id=".$uuid ;
echo "<br>";
$chnow = curl_init("https://hotelier.cosmores.com/services/get_reviews.php?id=$uuid");
curl_setopt($chnow, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chnow, CURLOPT_BINARYTRANSFER, true);
$leaderboard = curl_exec($chnow);
curl_close($chnow);
$leaderboard  = substr($leaderboard, 0, -2); 
$leaderboard  =substr($leaderboard, 1); 
echo $leaderboard ;
if ($leaderboard=='{"items":null}') {
echo "NO REVIEWS AVAILABLE";
}
if ($leaderboard!='{"items":null}') {
?>
<div>
<strong><?php echo $member2 ?> REVIEWS</strong><br />
<?PHP
$json_a=json_decode($leaderboard,true);
foreach ( $json_a[items] as  $value )
{
   echo $idmem; 
   
   echo "cat : ".$value['$rCat'];
  $rCat=$value['$rCat'];
  echo "<br>";
  
    echo "cat : ".$value['$rTitle'];
	  $rTitle=$value['$rTitle'];
  echo "<br>";
   echo "over : ".$value['$over'];
    $over=$value['$over'];
  echo "<br>";
  echo "loc : ".$value['$loc'];
   $loc=$value['$loc'];
  echo "<br>";

  echo "staff : ".$value['$staff'];
  $staff=$value['$staff'];
  echo "<br>";
  
  echo "serv : ".$value['$serv'];
  $serv=$value['$serv'];
  echo "<br>";
  
  echo "clean : ".$value['$clean'];
  $clean=$value['$clean'];
  echo "<br>";

  echo "conf : ".$value['$conf'];
  $confE=$value['$conf'];
  echo "<br>";

  echo "value : ".$value['$value'];
   $valueE=$value['$value'];
  echo "<br>";

  echo "revAge : ".$value['$revAge'];
  $revAge=$value['$revAge'];
  echo "<br>";
 
  echo "revText : ".$value['$revText'];
  $revTextE=$value['$revText'];
  echo "<br>";
 
  echo "revDate : ".$value['$revDate'];
  $revDateE=$value['$revDate'];
  echo "<br>";    
$counte++;
echo $counte;
  
  
  echo '<hr>';

  //Fulltexts 	
  $sql = "INSERT INTO reviews  (member_id, 	rCat, 	rTitle, 	over, 	loc, 	staff, 	serv, 	clean, 	conf, 	value, 	revAge, revText, revDate) VALUES ('$idmem', 	'$rCat', '$rTitle', '$over', '$loc', '$staff', '$serv', 	'$clean', 	'$confE', '$valueE', 	'$revAge', 	'$revTextE', '$revDateE')";
		$result = mysql_query($sql);
		echo $sql;
}

?>
</div>
<?php } }?>
<br /><br />

</div>
<?php } 
?>
<hr />

<?php
mysql_query("TRUNCATE offers");
?>
<div>
<?php
echo "https://hotelier.cosmores.com/services/get_offers.php?id=".$uuid ;
echo "<br>";
$chnow = curl_init("http://hotelier.cosmores.com/services/get_offers.php?id=$uuid");

curl_setopt($chnow, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chnow, CURLOPT_BINARYTRANSFER, true);
$leaderboard = curl_exec($chnow);
curl_close($chnow);
$leaderboard  = substr($leaderboard, 0, -2); 
$leaderboard  =substr($leaderboard, 1); 
echo  $leaderboard;
if ($leaderboard=='{"items":null}') {
echo "NO OFFERS AVAILABLE";
}
if ($leaderboard!='{"items":null}') {
?>
<div>
<strong><?php echo $member2 ?> OFFERS</strong><br />
<?PHP
$json_a=json_decode($leaderboard,true);
foreach ( $json_a[items] as  $value )
{

  echo "Title : ".$value[title];
  $newtitle=$value[title];
  echo "<br>";
   echo "Description : ".$value[desc_en];
   $des=$value[desc_en];
  echo "<br>";
       echo "Description greek : ".$value[desc_el];
   $des_el=$value[desc_el];
  echo "<br>";
  
  
  
  echo "start date : ".$value[start];
  $thestartdate=$value[start];
  $thestartdate = str_replace("-", "", $thestartdate );
  echo "<br>";
  $theenddate=$value[end];
  $theenddate = str_replace("-", "", $theenddate );
 echo "end date : ".$value[end];
  echo "<br><br>";
$sql = "INSERT INTO offers  (  member_id,  description, description_gr, title, startdate,  enddate, publish ) VALUES ('$idmem','$des', '$des_el',  '$newtitle',  '$thestartdate',  '$theenddate',  '1' )";
		$result = mysql_query($sql);
		
}
?>
</div>
<?php } ?>
<br /><br />

</div>

<hr />


</body>
</html>
