aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-08-04 21:20:03 -0700
committerfriendica <info@friendica.com>2013-08-04 21:20:03 -0700
commitc86dfd2e0c1626003711194cdd4871790f1d6879 (patch)
tree6a011c3a8a5c18a8e0667d21c91e8ac5fd974930
parente265a943c8d30a72fbcebab1403e1ea1c3ec45cc (diff)
downloadvolse-hubzilla-c86dfd2e0c1626003711194cdd4871790f1d6879.tar.gz
volse-hubzilla-c86dfd2e0c1626003711194cdd4871790f1d6879.tar.bz2
volse-hubzilla-c86dfd2e0c1626003711194cdd4871790f1d6879.zip
directory server sitelist module (needed for public site list and building friend suggestions for new sites/channels with no known contacts)
-rw-r--r--include/socgraph.php1
-rw-r--r--mod/sitelist.php51
2 files changed, 52 insertions, 0 deletions
diff --git a/include/socgraph.php b/include/socgraph.php
index 3970acd0d..ef1bab1d6 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -274,6 +274,7 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
intval($limit)
);
+
/*
$r = q("SELECT count(xlink.xchan) as `total`, gcontact.* from gcontact
left join glink on glink.gcid = gcontact.id
diff --git a/mod/sitelist.php b/mod/sitelist.php
new file mode 100644
index 000000000..1e6d0fcfb
--- /dev/null
+++ b/mod/sitelist.php
@@ -0,0 +1,51 @@
+<?php /** @file */
+
+function sitelist_init(&$a) {
+
+ $start = (($_REQUEST['start']) ? intval($_REQUEST['start']) : 0);
+ $limit = ((intval($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 30);
+ $order = (($_REQUEST['order']) ? $_REQUEST['order'] : 'random');
+ $open = (($_REQUEST['open']) ? intval($_REQUEST['open']) : false);
+
+
+ $sql_order = " order by site_url ";
+ if($order == 'random')
+ $sql_order = " order by rand() ";
+
+ $sql_limit = " limit $start, $limit ";
+
+ $sql_extra = "";
+ if($open)
+ $sql_extra = " and site_register = " . intval(REGISTER_OPEN) . " ";
+
+
+ $result = array('success' => false);
+
+ $r = q("select count(site_url) as total from site where 1 $sql_extra ");
+
+ if($r)
+ $result['total'] = intval($r[0]['total']);
+
+ $result['start'] = $start;
+ $result['limit'] = $limit;
+
+ $r = q("select * from site where true $sql_extra $sql_order $sql_limit");
+
+ $result['results'] = 0;
+ $result['entries'] = array();
+
+ if($r) {
+ $result['success'] = true;
+ $result['results'] = count($r);
+
+ foreach($r as $rr) {
+ $result['entries'][] = array('url' => $rr['site_url']);
+ }
+
+ }
+
+ echo json_encode($result);
+ killme();
+
+
+} \ No newline at end of file