<?php
//1st Store Call

$user_id = $_GET['user_id'];

$db = new SQLite3('./api/.db.db');
$res = $db->query ("SELECT * FROM key WHERE api='$user_id'"); 
while ($row = $res->fetchArray()) {
    $code = $row['api'];
}


$res = $db->query ("SELECT * FROM store WHERE key='$code'");

while ($row = $res->fetchArray()) {
    $added_date = $row['added_date'];
    $description = $row['description'];
    $icon = $row['icon'];
    $name = $row['name'];
    $url = $row['url'];
    $video = $row['video'];
    $version = $row['version'];
    $id = $row['version_code'];
    $code = $row['key'];

   if(!empty($url))
    {    $outputa.='{"user_id":"'.$code.'","title":"'.$name.'","description":"'.$description.'","link":"'.$url.'","thumbnail":"'.$icon.'","tag":"tag","date":"'.$added_date.'","spare1":"null","spare2":"null","id":"'.$id.'"}';
    }
}
$output1=str_replace('}{','},{',$outputa);
$json_string='['.$output1.']';



if (@$_REQUEST['user_id'] == $code) {
	echo $json_string;

}
//print_r($outputa);
?>