dir/mod/updatesites.php

52 lines
1.1 KiB
PHP
Raw Normal View History

2012-05-16 07:31:36 +02:00
<?php
require_once('include/datetime.php');
function updatesites_content(&$a) {
$r = q("select * from site where url != '' order by name asc");
if(count($r)) {
foreach($r as $rr) {
$s = '';
2012-05-30 12:15:56 +02:00
$s = fetch_url($rr['url'] . '/friendica/json');
2012-05-16 07:31:36 +02:00
if($s)
$j = json_decode($s);
else
continue;
if($j) {
2018-02-24 16:45:54 +01:00
$plugs = (array) $j->addons;
2012-05-30 12:15:56 +02:00
if(in_array('testdrive',$plugs)) {
$j->site_name = '!!! Test/Demo ONLY. !!! ' . $j->site_name;
$j->info = 'Accounts are temporary, expiration is enabled. ' . $j->info;
}
2012-05-16 07:31:36 +02:00
asort($plugs);
2012-05-30 12:15:56 +02:00
2012-05-16 07:31:36 +02:00
q("UPDATE site set
name = '%s',
2018-02-24 16:45:54 +01:00
url = '%s',
2012-05-16 07:31:36 +02:00
version = '%s',
2018-02-24 16:45:54 +01:00
addons = '%s',
2012-05-16 07:31:36 +02:00
reg_policy = '%s',
info = '%s',
admin_name = '%s',
admin_profile = '%s',
updated = '%s'
where id = %d limit 1",
dbesc($j->site_name),
dbesc($j->url),
dbesc($j->version),
dbesc(implode(',',$plugs)),
dbesc($j->register_policy),
dbesc(($j->info) ? $j->info : ''),
dbesc($j->admin->name),
dbesc($j->admin->profile),
dbesc(datetime_convert()),
intval($rr['id'])
);
}
}
}
}