From f1d01a4e508f534d4f62645d7f4103fe6571dd71 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 27 Feb 2012 16:30:53 +0100 Subject: [PATCH 1/5] Facebook: Don't import empty messages --- facebook/facebook.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/facebook/facebook.php b/facebook/facebook.php index 6b6c7f84..c5f3a0b7 100755 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -1016,12 +1016,17 @@ function fb_consume_stream($uid,$j,$wall = false) { $datarray['private'] = 1; $datarray['allow_cid'] = '<' . $uid . '>'; } - + + if(trim($datarray['body']) == '') { + logger('facebook: empty body'); + continue; + } + $top_item = item_store($datarray); $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($top_item), intval($uid) - ); + ); if(count($r)) { $orig_post = $r[0]; logger('fb: new top level item posted'); From 0f3f8deee3b1cc9a1ec18a4184903aa95fe819f2 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 11 Mar 2012 19:24:05 +0100 Subject: [PATCH 2/5] Pages: New plugin that displays a list of community pages on the sidebar. --- pages/README | 3 ++ pages/pages.php | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ pages/test.php | 28 ++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100755 pages/README create mode 100755 pages/pages.php create mode 100644 pages/test.php diff --git a/pages/README b/pages/README new file mode 100755 index 00000000..6ec314b7 --- /dev/null +++ b/pages/README @@ -0,0 +1,3 @@ +Pages + +Shows lists of community pages diff --git a/pages/pages.php b/pages/pages.php new file mode 100755 index 00000000..9e90cc24 --- /dev/null +++ b/pages/pages.php @@ -0,0 +1,86 @@ + + * + */ + +function pages_install() { + register_hook('page_end', 'addon/pages/pages.php', 'pages_page_end'); +} + +function pages_uninstall() { + unregister_hook('page_end', 'addon/pages/pages.php', 'pages_page_end'); +} + +function pages_iscommunity($url, &$pagelist) { + // check every week for the status - should be enough + if ($pagelist[$url]["checked"]') != 0); + + $pagelist[$url] = array("community" => $iscommunity, "checked" => time()); + } else // Fetch from cache + $iscommunity = $pagelist[$url]["community"]; + return($iscommunity); +} + +function pages_getpages($uid) { + + // Fetch cached pagelist from configuration + $pagelist = get_pconfig($uid,'pages','pagelist'); + + if (sizeof($pagelist) == 0) + $pagelist = array(); + + $contacts = q("SELECT `id`, `url`, `Name` FROM `contact` + WHERE `network`= 'dfrn' AND `uid` = %d", + intval($uid)); + + $pages = array(); + + // Look if the profile is a community page + foreach($contacts as $contact) { + if (pages_iscommunity($contact["url"], $pagelist)) + $pages[] = array("url"=>$contact["url"], "Name"=>$contact["Name"], "id"=>$contact["id"]); + } + + // Write back cached pagelist + set_pconfig($uid,'pages','pagelist', $pagelist); + return($pages); +} + +function pages_page_end($a,&$b) { + // Only move on if if it's the "network" module and there is a logged on user + if (($a->module != "network") OR ($a->user['uid'] == 0)) + return; + + $pages = '
+
+

'.t("Community").'

+
"; + if (sizeof($contacts) > 0) + $a->page['aside'] = $pages.$a->page['aside']; +} +?> diff --git a/pages/test.php b/pages/test.php new file mode 100644 index 00000000..4490c4a1 --- /dev/null +++ b/pages/test.php @@ -0,0 +1,28 @@ +"Blubb"); +$test[] = array("test"=>"Blubb"); + +print_r($test); +$serial = serialize($test); + +print_r(unserialize($serial)); +die(); + +$url = "https://pirati.ca/profile/test1"; + +$ch = curl_init(); + +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_HEADER, 0); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); +curl_setopt($ch, CURLOPT_TIMEOUT, 2); + +$page = curl_exec($ch); + +curl_close($ch); + +if (strpos($page, '')) + echo "Ping"; + +?> From a0f3c982ef5d1e6aced8e78c91560d7642652f7c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 11 Mar 2012 19:28:39 +0100 Subject: [PATCH 3/5] Pages: Added pages.tgz --- pages.tgz | Bin 0 -> 1446 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pages.tgz diff --git a/pages.tgz b/pages.tgz new file mode 100644 index 0000000000000000000000000000000000000000..7be170afa3a968cc049ec11260e8ae8a386629ab GIT binary patch literal 1446 zcmV;X1zGwZiwFS9?p#j*1MOICQ`<%m<}3ac+Z#8M8DrVtmkzO=(!`l`CP2m^$p?nP zXX|X;SeDe&2|_#h@7+DgMi>IL9VhKn3u8&Q&+YrI){gj0#Lm`6sgBfXwdlHsH`%pg z)-&2_G&*~o#(sUjxxZC!)c4xWEog1ltdx>ia|N&^=i))!WBmUpMJE5|vle;LMsz%q z|7NSx$nxKAw%U~cJ^b5(`bMl-qyKsSyDu>7C1+=+1Uqod7vcckQ8CctD-lnWjI<1c z19 z+;zjiSu18@q+(Xk%Jb5fJ4(=xyqYA~lp-0g!e*BfV62mUUUYPhUj0K1wOlDqbTTa1V2|6Rm=V#0a5-vOMYPk@0W%s9c zvtHln7)7M%lP3buVF)2gLnT3|QCSkWFco^@<&{oVxG>L=3a8Q+D4>jp9!yXdCP``= z9mZAj919&r+D1ebUVa$9J$ZL}ftM5=PCVm);Y?1J}%;7dW)+!3)H0GH5?m}n| z0iK>7n<|OnvZ&5xlCKgq4B5UcE_qh2oSMc9ttS!u9%h_A!dfErwYj zj&yIWa+5A*;P*h{~8wI zr2s@?tmt1`u?aoPlFAU^CYS?`Ef5(h%Z4A$W@tBVOk$zZ+C%ZX{S1x=c_pF(Cqpny z!k$^^m35xhB?UaS|5iy@T~}U$bbHLK?8ed+W3I4g_&kn#>`Je&1R@C+kQ2wr8f2pHQ8d zw>5Itmn#>H@m&s{64M^DY9yUHz?jDZ3(rOe93@<-9OT`qu$r|Bkk7}$XMj^2ZtXGg z8DHE1_tB|f&M+k8_x5_-)>zl!7#LsnnJLzsiO9l8q(MtR36k$POGhiv&l(OIPW#U+ zPLZXQr-d8W?y#t8U-V1gd+^IBon*9#^~T13Gv~LP&9BY>je5Pc{QlQ&cWC}^bm;qE zG5>F#()qtsrV7Zv2k065I{U>>#$$%({BcAnQuyY(P_}{67Hkxf`?w{&!PB$it-wi; zW2U$C(sZRT?@5|WPyq9^j^YEyG2a|yZNi=GjcIDP!3cWKMEaz8^hwj`Uz$aqI*ERL z4!t{tng;aG=T2-_V&a9s-pOD_Vf**=qJq9XrTu@1g?=>Hl#WM#|7*6>{*Q~zdV~6Z zqgC|(Z$jyhJ*7u}-TB^D7F19{1r=0KK?N05P(cM1R8T<$74&!MPtA!j-T){709H5E AHUIzs literal 0 HcmV?d00001 From bdbefde50a5645071d90b6e69d73afec8962c485 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 11 Mar 2012 19:43:37 +0100 Subject: [PATCH 4/5] Removed the test file --- pages/test.php | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 pages/test.php diff --git a/pages/test.php b/pages/test.php deleted file mode 100644 index 4490c4a1..00000000 --- a/pages/test.php +++ /dev/null @@ -1,28 +0,0 @@ -"Blubb"); -$test[] = array("test"=>"Blubb"); - -print_r($test); -$serial = serialize($test); - -print_r(unserialize($serial)); -die(); - -$url = "https://pirati.ca/profile/test1"; - -$ch = curl_init(); - -curl_setopt($ch, CURLOPT_URL, $url); -curl_setopt($ch, CURLOPT_HEADER, 0); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -curl_setopt($ch, CURLOPT_TIMEOUT, 2); - -$page = curl_exec($ch); - -curl_close($ch); - -if (strpos($page, '')) - echo "Ping"; - -?> From 61edc9ff5ec7ae160223562ee82088a84c4b9753 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 15 Mar 2012 21:15:40 +0100 Subject: [PATCH 5/5] Pages: Some minor improvements (I guess) :) --- pages/pages.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/pages.php b/pages/pages.php index 9e90cc24..bc56d2e4 100755 --- a/pages/pages.php +++ b/pages/pages.php @@ -21,6 +21,8 @@ function pages_iscommunity($url, &$pagelist) { // When too old or not found fetch the status from the profile $ch = curl_init(); + $url = str_replace("/profile/","/hcard/", $url); + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);