From 59828593c14a64cecf7ee5c077da9f918062ed60 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 13 Feb 2015 14:25:04 -0800 Subject: some ratings fixes --- include/socgraph.php | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'include/socgraph.php') diff --git a/include/socgraph.php b/include/socgraph.php index 13957e814..59830ef1b 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -185,29 +185,6 @@ function poco_load($xchan = '',$url = null) { $total ++; - - $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 0 limit 1", - dbesc($xchan), - dbesc($hash) - ); - - if(! $r) { - q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', 0 ) ", - dbesc($xchan), - dbesc($hash), - intval($rating), - dbesc($rating_text), - dbesc(datetime_convert()) - ); - } - else { - q("update xlink set xlink_updated = '%s', xlink_rating = %d, xlink_rating_text = '%s' where xlink_id = %d", - dbesc(datetime_convert()), - intval($rating), - dbesc($rating_text), - intval($r[0]['xlink_id']) - ); - } } logger("poco_load: loaded $total entries",LOGGER_DEBUG); -- cgit v1.2.3 From 0d601563d02d7e9b7414586486f1623a93cf958b Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Wed, 4 Mar 2015 00:03:19 +0100 Subject: Some cleanups and documentation. Fixed some wrong variable names. Initialized some variables before using them. Removed some checks for STATUSNET_PRIVACY_COMPATIBILITY in include/security.php as it does not seem to be defined anywhere. --- include/socgraph.php | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'include/socgraph.php') diff --git a/include/socgraph.php b/include/socgraph.php index 59830ef1b..7f03f8696 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -3,7 +3,7 @@ require_once('include/dir_fns.php'); require_once('include/zot.php'); -/* +/** * poco_load * * xchan is your connection @@ -21,13 +21,10 @@ require_once('include/zot.php'); * the given uid, cid to the global contact entry. There can be many uid/cid combinations * pointing to the same global contact id. * + * @param string $xchan + * @param string $url */ - - - - -function poco_load($xchan = '',$url = null) { - $a = get_app(); +function poco_load($xchan = '', $url = null) { if($xchan && ! $url) { $r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1", @@ -43,7 +40,6 @@ function poco_load($xchan = '',$url = null) { return; } - $url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ; logger('poco_load: ' . $url, LOGGER_DEBUG); @@ -148,7 +144,7 @@ function poco_load($xchan = '',$url = null) { logger('poco_load: missing data'); continue; } - + $x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", dbesc($hash) ); @@ -182,9 +178,8 @@ function poco_load($xchan = '',$url = null) { continue; } } - - $total ++; + $total ++; } logger("poco_load: loaded $total entries",LOGGER_DEBUG); @@ -193,7 +188,6 @@ function poco_load($xchan = '',$url = null) { db_utcnow(), db_quoteinterval('2 DAY') ); - } @@ -230,7 +224,6 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false ); return $r; - } @@ -246,8 +239,8 @@ function count_common_friends_zcid($uid,$zcid) { if(count($r)) return $r[0]['total']; - return 0; + return 0; } function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = false) { @@ -269,7 +262,6 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal ); return $r; - } @@ -284,8 +276,8 @@ function count_all_friends($uid,$cid) { if(count($r)) return $r[0]['total']; - return 0; + return 0; } @@ -358,9 +350,7 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) { function update_suggestions() { - $a = get_app(); - - $dirmode = get_config('system','directory_mode'); + $dirmode = get_config('system', 'directory_mode'); if($dirmode === false) $dirmode = DIRECTORY_MODE_NORMAL; @@ -374,8 +364,6 @@ function update_suggestions() { if(! $url) return; - - $ret = z_fetch_url($url); if($ret['success']) { @@ -388,7 +376,6 @@ function update_suggestions() { db_utcnow(), db_quoteinterval('7 DAY') ); - $j = json_decode($ret['body'],true); if($j && $j['success']) { foreach($j['entries'] as $host) { @@ -422,7 +409,6 @@ function poco($a,$extended = false) { $system_mode = true; } - $format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json'); $justme = false; @@ -437,7 +423,7 @@ function poco($a,$extended = false) { } if(argc() > 4 && intval(argv(4)) && $justme == false) $cid = intval(argv(4)); - + if(! $system_mode) { $r = q("SELECT channel_id from channel where channel_address = '%s' limit 1", @@ -487,8 +473,8 @@ function poco($a,$extended = false) { $startIndex = intval($_GET['startIndex']); if(! $startIndex) $startIndex = 0; - $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); + $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); if($system_mode) { $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF . @@ -496,8 +482,7 @@ function poco($a,$extended = false) { intval($itemsPerPage), intval($startIndex) ); - } - else { + } else { $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $sql_extra LIMIT %d OFFSET %d", intval($channel_id), @@ -525,8 +510,7 @@ function poco($a,$extended = false) { } } - $ret['entry'] = array(); - + $ret['entry'] = array(); $fields_ret = array( 'id' => false, @@ -540,10 +524,10 @@ function poco($a,$extended = false) { 'rating' => false ); - if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) + if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) { foreach($fields_ret as $k => $v) $fields_ret[$k] = true; - else { + } else { $fields_req = explode(',',$_GET['fields']); foreach($fields_req as $f) $fields_ret[trim($f)] = true; -- cgit v1.2.3 From 3a3563a4b1673cdd86fdba01985ccfea98ab8b0e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 6 Apr 2015 19:00:13 -0700 Subject: commit 59828593c broke some important poco stuff, looks like the cat might have climbed over the keyboard and deleted something that wasn't intended to be deleted. --- include/socgraph.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/socgraph.php') diff --git a/include/socgraph.php b/include/socgraph.php index 7f03f8696..acebec419 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -180,6 +180,26 @@ function poco_load($xchan = '', $url = null) { } $total ++; + + + $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 0 limit 1", + dbesc($xchan), + dbesc($hash) + ); + + if(! $r) { + q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated, xlink_static ) values ( '%s', '%s', '%s', 0 ) ", + dbesc($xchan), + dbesc($hash), + dbesc(datetime_convert()) + ); + } + else { + q("update xlink set xlink_updated = '%s' where xlink_id = %d", + dbesc(datetime_convert()), + intval($r[0]['xlink_id']) + ); + } } logger("poco_load: loaded $total entries",LOGGER_DEBUG); -- cgit v1.2.3