aboutsummaryrefslogtreecommitdiffstats
path: root/mod/uexport.php
blob: 423c3a82fa137c1d7d86b8f50005947d198a2f45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

function uexport_init(&$a) {

	if(! local_user())
		killme();

	$user = array();
	$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
		local_user()
	);
	if(count($r)) {
		foreach($r as $rr)
			foreach($rr as $k => $v)
				$user[$k] = $v;

	}
	$contact = array();
	$r = q("SELECT * FROM `contact` WHERE `uid` = %d ",
		local_user()
	);
	if(count($r)) {
		foreach($r as $rr)
			foreach($rr as $k => $v)
				$contact[][$k] = $v;

	}

	$profile = array();
	$r = q("SELECT * FROM `profile` WHERE `uid` = %d ",
		local_user()
	);
	if(count($r)) {
		foreach($r as $rr)
			foreach($rr as $k => $v)
				$profile[][$k] = $v;
	}



	$output = array('user' => $user, 'contact' => $contact, 'profile' => $profile);

	header("Content-type: text/json");
	echo str_replace('\\/','/',json_encode($output));

	killme();

}