aboutsummaryrefslogtreecommitdiffstats
path: root/include/fcontact.php
blob: 8821a985f2dc06e77619ce6bf7719c422358b031 (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
<?php



function fcontact_store($url,$name,$photo) {

	$nurl = str_replace(array('https:','//www.'), array('http:','//'), $url);

	$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
		dbesc($nurl)
	);

	if(count($r))
		return $r[0]['id'];

	$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
		dbesc($nurl),
		dbesc($name),
		dbesc($photo)
	);

	if($r) {
		$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
			dbesc($nurl)
		);
		if(count($r))
			return $r[0]['id'];
	}

	return 0;
}

function ffinder_store($uid,$cid,$fid) {
	$r = q("INSERT INTO `ffinder` ( `uid`, `cid`, `fid` ) VALUES ( %d, %d, %d ) ",
		intval($uid),
		intval($cid),
		intval($fid)
	);
	return $r;
}