public site list (will take a few days to populate, assuming folks have updated their site access policy which old sites do not have)
This commit is contained in:
@@ -22,6 +22,12 @@ function dirsearch_content(&$a) {
|
||||
json_return_and_die($ret);
|
||||
}
|
||||
|
||||
if(argc > 1 && argv(1) === 'sites') {
|
||||
$ret = list_public_sites();
|
||||
json_return_and_die($ret);
|
||||
}
|
||||
|
||||
|
||||
$name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : '');
|
||||
$hub = ((x($_REQUEST,'hub')) ? $_REQUEST['hub'] : '');
|
||||
$address = ((x($_REQUEST,'address')) ? $_REQUEST['address'] : '');
|
||||
@@ -163,3 +169,33 @@ function dirsearch_content(&$a) {
|
||||
json_return_and_die($ret);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function list_public_sites() {
|
||||
$r = q("select * from site where site_access != 0 order by rand()");
|
||||
$ret = array('success' => false);
|
||||
|
||||
if($r) {
|
||||
$ret['success'] = true;
|
||||
$ret['sites'] = array();
|
||||
foreach($r as $rr) {
|
||||
|
||||
if($rr['site_access'] == ACCESS_FREE)
|
||||
$access = 'free';
|
||||
elseif($rr['site_access'] == ACCESS_PAID)
|
||||
$access = 'paid';
|
||||
else
|
||||
$access = 'private';
|
||||
|
||||
if($rr['site_register'] == REGISTER_OPEN)
|
||||
$register = 'open';
|
||||
elseif($rr['site_register'] == REGISTER_APPROVE)
|
||||
$register = 'approve';
|
||||
else
|
||||
$register = 'closed';
|
||||
|
||||
$ret['sites'][] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register);
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
37
mod/pubsites.php
Normal file
37
mod/pubsites.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
function pubsites_content(&$a) {
|
||||
|
||||
$dirmode = intval(get_config('system','directory_mode'));
|
||||
|
||||
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
|
||||
$url = z_root() . '/dirsearch';
|
||||
}
|
||||
if(! $url) {
|
||||
$directory = find_upstream_directory($dirmode);
|
||||
|
||||
if($directory) {
|
||||
$url = $directory['url'] . '/dirsearch';
|
||||
}
|
||||
else {
|
||||
$url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
|
||||
}
|
||||
}
|
||||
$url .= '/sites';
|
||||
|
||||
$o .= '<h1>' . t('Public Sites') . '</h1>';
|
||||
|
||||
$ret = z_fetch_url($url);
|
||||
if($ret['success']) {
|
||||
$j = json_decode($ret['body'],true);
|
||||
if($j) {
|
||||
$o .= '<table><tr><td>' . t('Site URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td></tr>';
|
||||
foreach($j as $jj) {
|
||||
$o .= '<tr><td>' . $jj['url'] . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td></tr>';
|
||||
}
|
||||
|
||||
$o .= '</table>';
|
||||
}
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
Reference in New Issue
Block a user