<?php
session_start();

if (isset($_SESSION["user_id"]) and isset($_SESSION["password"])) {
	$dbhost=$_SESSION["dbhost"];
	$dbuser=$_SESSION["dbuser"];
	$dbpass=$_SESSION["dbpass"];
	
	$id=$_SESSION["user_id"];
	header('Content-Type: application/json; charset=utf-8');

	$pdo=new PDO($dbhost, $dbuser, $dbpass);
	$stmt = $pdo->prepare("SELECT * FROM users WHERE (user_id!=:id AND client_public IS NOT NULL)");
	$stmt->execute(array(':id' => $id));
	$rows = $stmt->fetchAll(pdo::FETCH_ASSOC);
	$stuff = array();
	foreach ($rows as $row) {
		$stuff[] = array(
			"user_id" => $row["user_id"],
			"name" => $row["name"],
			"fullname" => $row["fullname"],
			"client_public" => $row["client_public"],
		);
	}
	$extract = array("objectz" => $stuff);
	echo(json_encode($extract, JSON_PRETTY_PRINT));
}
?>