<?php
$db = new SQLite3('./appsnscripts_smart.db');

if (isset($_GET['action'])) {
	$action = $_GET['action'];
}

if ($action == 'dns') {
	$res = $db->query('SELECT * FROM dns');
	$rows = [];

	while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
		$rows[] = $row['url'];
	}

	$dns = rtrim(implode(',', $rows), ',');
	echo '{"status":true,"su":"' . $dns . '","sc":"","ndd":""}';
}
else if ($action == 'note') {
	$note = $db->query('SELECT * FROM notifications');

	while ($notes = $note->fetchArray(SQLITE3_ASSOC)) {
		$data[] = ['Title' => $notes['Title'], 'Description' => $notes['Description'], 'CreateDate' => $notes['CreateDate']];
	}

	$jdata = json_encode($data);
	echo '{"status":true, "response": ' . $jdata . ' }';
}
else {
	include 'index1.php';
}

?>