dirsearch cleanup

This commit is contained in:
Mike Macgirvin 2024-06-22 20:59:43 +10:00
parent 4f9730fcd5
commit 9f02f73e12

View file

@ -23,15 +23,6 @@ class Dirsearch extends Controller
// logger('request: ' . print_r($_REQUEST,true));
if (argc() > 1 && argv(1) === 'sites') {
$ret = $this->list_public_sites();
json_return_and_die($ret);
}
$dirmode = intval(get_config('system', 'directory_mode'));
$network = EMPTY_STR;
$sql_extra = '';
@ -89,20 +80,7 @@ class Dirsearch extends Controller
if ($safe === false) {
$safe = 1;
}
// Directory mirrors will request sync packets, which are lists
// of records that have changed since the sync datetime.
if (array_key_exists('sync', $_REQUEST)) {
if ($_REQUEST['sync']) {
$sync = Time::convert('UTC', 'UTC', $_REQUEST['sync']);
} else {
$sync = Time::convert('UTC', 'UTC', '2010-01-01 01:01:00');
}
} else {
$sync = false;
}
if ($hub) {
$hub_query = " and xchan_hash in (select hubloc_hash from hubloc where hubloc_deleted = 0 and hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') ";
} else {
@ -410,45 +388,4 @@ class Dirsearch extends Controller
return $ret;
}
public function list_public_sites()
{
$rand = db_getfunc('rand');
$r = q(
"select * from site where site_type = %d and site_dead = 0",
intval(SITE_TYPE_ZOT)
);
$ret = ['success' => false];
if ($r) {
$ret['success'] = true;
$ret['sites'] = [];
foreach ($r as $rr) {
if ($rr['site_access'] == ACCESS_FREE) {
$access = 'free';
} elseif ($rr['site_access'] == ACCESS_PAID) {
$access = 'paid';
} elseif ($rr['site_access'] == ACCESS_TIERED) {
$access = 'tiered';
} else {
$access = 'private';
}
if ($rr['site_register'] == REGISTER_OPEN) {
$register = 'open';
} elseif ($rr['site_register'] == REGISTER_APPROVE) {
$register = 'approve';
} else {
$register = 'closed';
}
$ret['sites'][] = ['url' => $rr['site_url'], 'access' => $access, 'register' => $register, 'sellpage' => $rr['site_sellpage'], 'location' => $rr['site_location'], 'project' => $rr['site_project'], 'version' => $rr['site_version']];
}
}
return $ret;
}
}