6 require_once("include/remoteupdate.php");
7 require_once("include/enotify.php");
8 require_once("include/text.php");
11 * @brief process send data from the admin panels subpages
13 * This function acts as relais for processing the data send from the subpages
14 * of the admin panel. Depending on the 1st parameter of the url (argv[1])
15 * specialized functions are called to process the data from the subpages.
17 * The function itself does not return anything, but the subsequencely function
18 * return the HTML for the pages of the admin panel.
23 function admin_post(&$a){
26 if(!is_site_admin()) {
30 // do not allow a page manager to access the admin panel at all.
32 if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
41 admin_page_site_post($a);
44 admin_page_users_post($a);
48 is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")){
49 @include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
50 if(function_exists($a->argv[2].'_plugin_admin_post')) {
51 $func = $a->argv[2].'_plugin_admin_post';
55 goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] );
61 goaway($a->get_baseurl(true) . '/admin/' );
66 if (is_file("view/theme/$theme/config.php")){
67 function __call_theme_admin_post(&$a, $theme) {
68 $orig_theme = $a->theme;
69 $orig_page = $a->page;
70 $orig_session_theme = $_SESSION['theme'];
71 require_once("view/theme/$theme/theme.php");
72 require_once("view/theme/$theme/config.php");
73 $_SESSION['theme'] = $theme;
76 $init = $theme."_init";
77 if(function_exists($init)) $init($a);
78 if(function_exists("theme_admin_post")){
79 $admin_form = theme_admin_post($a);
82 $_SESSION['theme'] = $orig_session_theme;
83 $a->theme = $orig_theme;
84 $a->page = $orig_page;
87 __call_theme_admin_post($a, $theme);
89 info(t('Theme settings updated.'));
92 goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
96 admin_page_logs_post($a);
99 admin_page_dbsync_post($a);
102 admin_page_remoteupdate_post($a);
107 goaway($a->get_baseurl(true) . '/admin' );
108 return; // NOTREACHED
112 * This function generates the content for the admin panel.
113 * @brief generates content of the admin panel pages
117 function admin_content(&$a) {
119 if(!is_site_admin()) {
123 if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
126 // APC deactivated, since there are problems with PHP 5.5
127 //if (function_exists("apc_delete")) {
128 // $toDelete = new APCIterator('user', APC_ITER_VALUE);
129 // apc_delete($toDelete);
135 $aside_tools = Array();
136 // array( url, name, extra css classes )
137 // not part of $aside to make the template more adjustable
139 'site' => Array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"),
140 'users' => Array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"),
141 'plugins'=> Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"),
142 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"),
143 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"),
144 'queue' => Array($a->get_baseurl(true)."/admin/queue/", t('Inspect Queue'), "queue"),
145 'federation' => Array($a->get_baseurl(true)."/admin/federation/", t('Federation Statistics'), "federation"),
146 //'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update")
149 /* get plugins admin page */
151 $r = q("SELECT `name` FROM `addon` WHERE `plugin_admin`=1 ORDER BY `name`");
152 $aside_tools['plugins_admin']=Array();
155 $aside['plugins_admin'][] = Array($a->get_baseurl(true)."/admin/plugins/".$plugin, $plugin, "plugin");
156 // temp plugins with admin
157 $a->plugins_admin[] = $plugin;
160 $aside_tools['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs");
161 $aside_tools['viewlogs'] = Array($a->get_baseurl(true)."/admin/viewlogs/", t("View Logs"), 'viewlogs');
162 $aside_tools['diagnostics_probe'] = Array($a->get_baseurl(true).'/probe/', t('probe address'), 'probe');
163 $aside_tools['diagnostics_webfinger'] = Array($a->get_baseurl(true).'/webfinger/', t('check webfinger'), 'webfinger');
165 $t = get_markup_template("admin_aside.tpl");
166 $a->page['aside'] .= replace_macros( $t, array(
167 '$admin' => $aside_tools,
168 '$subpages' => $aside_sub,
169 '$admtxt' => t('Admin'),
170 '$plugadmtxt' => t('Plugin Features'),
171 '$logtxt' => t('Logs'),
172 '$diagnosticstxt' => t('diagnostics'),
173 '$h_pending' => t('User registrations waiting for confirmation'),
174 '$admurl'=> $a->get_baseurl(true)."/admin/"
185 switch ($a->argv[1]){
187 $o = admin_page_site($a);
190 $o = admin_page_users($a);
193 $o = admin_page_plugins($a);
196 $o = admin_page_themes($a);
199 $o = admin_page_logs($a);
202 $o = admin_page_viewlogs($a);
205 $o = admin_page_dbsync($a);
208 $o = admin_page_remoteupdate($a);
211 $o = admin_page_queue($a);
214 $o = admin_page_federation($a);
217 notice( t("Item not found.") );
220 $o = admin_page_summary($a);
233 * This function generates the "Federation Statistics" subpage for the admin
234 * panel. The page lists some numbers to the part of "The Federation" known to
235 * the node. This data includes the different connected networks (e.g.
236 * Diaspora, Hubzilla, GNU Social) and the used versions in the different
239 * The returned string contains the HTML code of the subpage for display.
241 * @brief subpage with some stats about "the federstion" network
245 function admin_page_federation(&$a) {
246 // get counts on active friendica, diaspora, redmatrix, hubzilla, gnu
247 // social and statusnet nodes this node is knowing
249 // We are looking for the following platforms in the DB, "Red" should find
250 // all variants of that platform ID string as the q() function is stripping
251 // off one % two of them are needed in the query
252 $platforms = array('Diaspora', 'Friendica', '%%red%%', 'Hubzilla', 'GNU Social', 'StatusNet');
254 foreach ($platforms as $p) {
255 // get a total count for the platform, the name and version of the
256 // highest version and the protocol tpe
257 $c = q('select count(*), platform, network, version from gserver
258 where platform like "'.$p.'" and last_contact > last_failure
259 order by version asc;');
260 // what versions for that platform do we know at all?
261 // again only the active nodes
262 $v = q('select count(*), version from gserver
263 where last_contact > last_failure and platform like "'.$p.'"
267 // clean up version numbers
269 // in the DB the Diaspora versions have the format x.x.x.x-xx the last
270 // part (-xx) should be removed to clean up the versions from the "head
271 // commit" information and combined into a single entry for x.x.x.x
272 if ($p=='Diaspora') {
276 $newVC = $vv['count(*)'];
277 $newVV = $vv['version'];
278 $posDash = strpos($newVV, '-');
280 $newVV = substr($newVV, 0, $posDash);
281 if (isset($newV[$newVV]))
283 $newV[$newVV] += $newVC;
285 $newV[$newVV] = $newVC;
288 foreach ($newV as $key => $value) {
289 array_push($newVv, array('count(*)'=>$value, 'version'=>$key));
293 // early friendica versions have the format x.x.xxxx where xxxx is the
294 // DB version stamp; those should be operated out and versions be
296 if ($p=='Friendica') {
299 foreach ($v as $vv) {
300 $newVC = $vv['count(*)'];
301 $newVV = $vv['version'];
302 $lastDot = strrpos($newVV,'.');
303 $len = strlen($newVV)-1;
304 if (($lastDot == $len-4) && (!strrpos($newVV,'-rc')==$len-3))
305 $newVV = substr($newVV, 0, $lastDot);
306 if (isset($newV[$newVV]))
308 $newV[$newVV] += $newVC;
310 $newV[$newVV] = $newVC;
313 foreach ($newV as $key => $value) {
314 array_push($newVv, array('count(*)'=>$value, 'version'=>$key));
318 // the 3rd array item is needed for the JavaScript graphs as JS does
319 // not like some characters in the names of variables...
320 $counts[$p]=array($c[0], $v, str_replace(array(' ','%'),'',$p));
323 $intro = t('This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of.');
324 $hint = t('The <em>Auto Discovered Contact Directory</em> feature is not enabled, it will improve the data displayed here.');
325 // load the template, replace the macros and return the page content
326 $t = get_markup_template("admin_federation.tpl");
327 return replace_macros($t, array(
328 '$title' => t('Administration'),
329 '$page' => t('Federation Statistics'),
332 '$autoactive' => get_config('system', 'poco_completion'),
333 '$counts' => $counts,
334 '$version' => FRIENDICA_VERSION,
335 '$legendtext' => t('Currently this node is aware of nodes from the following platforms:'),
339 * @brief Admin Inspect Queue Page
343 function admin_page_queue(&$a) {
344 // get content from the queue table
345 $r = q("SELECT c.name,c.nurl,q.id,q.network,q.created,q.last from queue as q, contact as c where c.id=q.cid order by q.cid, q.created;");
347 $t = get_markup_template("admin_queue.tpl");
348 return replace_macros($t, array(
349 '$title' => t('Administration'),
350 '$page' => t('Inspect Queue'),
351 '$count' => sizeof($r),
352 'id_header' => t('ID'),
353 '$to_header' => t('Recipient Name'),
354 '$url_header' => t('Recipient Profile'),
355 '$network_header' => t('Network'),
356 '$created_header' => t('Created'),
357 '$last_header' => t('Last Tried'),
358 '$info' => t('This page lists the content of the queue for outgoing postings. These are postings the initial delivery failed for. They will be resend later and eventually deleted if the delivery fails permanently.'),
363 * @brief Admin Summary Page
367 function admin_page_summary(&$a) {
368 $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`");
370 Array( t('Normal Account'), 0),
371 Array( t('Soapbox Account'), 0),
372 Array( t('Community/Celebrity Account'), 0),
373 Array( t('Automatic Friend Account'), 0),
374 Array( t('Blog Account'), 0),
375 Array( t('Private Forum'), 0)
379 foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
381 logger('accounts: ' . print_r($accounts,true),LOGGER_DATA);
383 $r = q("SELECT COUNT(id) as `count` FROM `register`");
384 $pending = $r[0]['count'];
386 $r = q("select count(*) as total from deliverq where 1");
387 $deliverq = (($r) ? $r[0]['total'] : 0);
389 $r = q("select count(*) as total from queue where 1");
390 $queue = (($r) ? $r[0]['total'] : 0);
392 // We can do better, but this is a quick queue status
394 $queues = array( 'label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue );
397 $t = get_markup_template("admin_summary.tpl");
398 return replace_macros($t, array(
399 '$title' => t('Administration'),
400 '$page' => t('Summary'),
401 '$queues' => $queues,
402 '$users' => Array( t('Registered users'), $users),
403 '$accounts' => $accounts,
404 '$pending' => Array( t('Pending registrations'), $pending),
405 '$version' => Array( t('Version'), FRIENDICA_VERSION),
406 '$baseurl' => $a->get_baseurl(),
407 '$platform' => FRIENDICA_PLATFORM,
408 '$codename' => FRIENDICA_CODENAME,
409 '$build' => get_config('system','build'),
410 '$plugins' => Array( t('Active plugins'), $a->plugins )
416 * @brief process send data from Admin Site Page
419 function admin_page_site_post(&$a){
420 if (!x($_POST,"page_site")){
424 check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
427 if (x($_POST,'relocate') && x($_POST,'relocate_url') && $_POST['relocate_url']!=""){
428 $new_url = $_POST['relocate_url'];
429 $new_url = rtrim($new_url,"/");
431 $parsed = @parse_url($new_url);
432 if (!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) {
433 notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
434 goaway($a->get_baseurl(true) . '/admin/site' );
438 * replace all "baseurl" to "new_url" in config, profile, term, items and contacts
439 * send relocate for every local user
442 $old_url = $a->get_baseurl(true);
444 function update_table($table_name, $fields, $old_url, $new_url) {
447 $dbold = dbesc($old_url);
448 $dbnew = dbesc($new_url);
451 foreach ($fields as $f) {
452 $upd[] = "`$f` = REPLACE(`$f`, '$dbold', '$dbnew')";
455 $upds = implode(", ", $upd);
459 $q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
462 notice( "Failed updating '$table_name': " . $db->error );
463 goaway($a->get_baseurl(true) . '/admin/site' );
468 update_table("profile", array('photo', 'thumb'), $old_url, $new_url);
469 update_table("term", array('url'), $old_url, $new_url);
470 update_table("contact", array('photo','thumb','micro','url','nurl','request','notify','poll','confirm','poco'), $old_url, $new_url);
471 update_table("gcontact", array('photo','url','nurl','server_url'), $old_url, $new_url);
472 update_table("item", array('owner-link','owner-avatar','author-name','author-link','author-avatar','body','plink','tag'), $old_url, $new_url);
475 $a->set_baseurl($new_url);
476 set_config('system','url',$new_url);
479 $users = q("SELECT uid FROM user WHERE account_removed = 0 AND account_expired = 0");
481 foreach ($users as $user) {
482 proc_run('php', 'include/notifier.php', 'relocate', $user['uid']);
485 info("Relocation started. Could take a while to complete.");
487 goaway($a->get_baseurl(true) . '/admin/site' );
491 $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
492 $hostname = ((x($_POST,'hostname')) ? notags(trim($_POST['hostname'])) : '');
493 $sender_email = ((x($_POST,'sender_email')) ? notags(trim($_POST['sender_email'])) : '');
494 $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
495 $shortcut_icon = ((x($_POST,'shortcut_icon')) ? notags(trim($_POST['shortcut_icon'])) : '');
496 $touch_icon = ((x($_POST,'touch_icon')) ? notags(trim($_POST['touch_icon'])) : '');
497 $info = ((x($_POST,'info')) ? trim($_POST['info']) : false);
498 $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
499 $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
500 $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : '');
501 $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
502 $maximagelength = ((x($_POST,'maximagelength')) ? intval(trim($_POST['maximagelength'])) : MAX_IMAGE_LENGTH);
503 $jpegimagequality = ((x($_POST,'jpegimagequality')) ? intval(trim($_POST['jpegimagequality'])) : JPEG_QUALITY);
506 $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
507 $daily_registrations = ((x($_POST,'max_daily_registrations')) ? intval(trim($_POST['max_daily_registrations'])) :0);
508 $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
510 $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
512 $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
513 $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
514 $block_public = ((x($_POST,'block_public')) ? True : False);
515 $force_publish = ((x($_POST,'publish_all')) ? True : False);
516 $global_directory = ((x($_POST,'directory')) ? notags(trim($_POST['directory'])) : '');
517 $thread_allow = ((x($_POST,'thread_allow')) ? True : False);
518 $newuser_private = ((x($_POST,'newuser_private')) ? True : False);
519 $enotify_no_content = ((x($_POST,'enotify_no_content')) ? True : False);
520 $private_addons = ((x($_POST,'private_addons')) ? True : False);
521 $disable_embedded = ((x($_POST,'disable_embedded')) ? True : False);
522 $allow_users_remote_self = ((x($_POST,'allow_users_remote_self')) ? True : False);
524 $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
525 $no_openid = !((x($_POST,'no_openid')) ? True : False);
526 $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
527 $no_utf = !((x($_POST,'no_utf')) ? True : False);
528 $community_page_style = ((x($_POST,'community_page_style')) ? intval(trim($_POST['community_page_style'])) : 0);
529 $max_author_posts_community_page = ((x($_POST,'max_author_posts_community_page')) ? intval(trim($_POST['max_author_posts_community_page'])) : 0);
531 $verifyssl = ((x($_POST,'verifyssl')) ? True : False);
532 $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
533 $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
534 $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
535 $delivery_interval = ((x($_POST,'delivery_interval')) ? intval(trim($_POST['delivery_interval'])) : 0);
536 $poll_interval = ((x($_POST,'poll_interval')) ? intval(trim($_POST['poll_interval'])) : 0);
537 $maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
538 $maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
539 $optimize_max_tablesize = ((x($_POST,'optimize_max_tablesize')) ? intval(trim($_POST['optimize_max_tablesize'])): 100);
540 $optimize_fragmentation = ((x($_POST,'optimize_fragmentation')) ? intval(trim($_POST['optimize_fragmentation'])): 30);
541 $poco_completion = ((x($_POST,'poco_completion')) ? intval(trim($_POST['poco_completion'])) : false);
542 $poco_requery_days = ((x($_POST,'poco_requery_days')) ? intval(trim($_POST['poco_requery_days'])) : 7);
543 $poco_discovery = ((x($_POST,'poco_discovery')) ? intval(trim($_POST['poco_discovery'])) : 0);
544 $poco_discovery_since = ((x($_POST,'poco_discovery_since')) ? intval(trim($_POST['poco_discovery_since'])) : 30);
545 $poco_local_search = ((x($_POST,'poco_local_search')) ? intval(trim($_POST['poco_local_search'])) : false);
546 $nodeinfo = ((x($_POST,'nodeinfo')) ? intval(trim($_POST['nodeinfo'])) : false);
547 $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
548 $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
549 $ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0);
550 $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
551 $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
552 $force_ssl = ((x($_POST,'force_ssl')) ? True : False);
553 $old_share = ((x($_POST,'old_share')) ? True : False);
554 $hide_help = ((x($_POST,'hide_help')) ? True : False);
555 $suppress_language = ((x($_POST,'suppress_language')) ? True : False);
556 $suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
557 $use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
558 $itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
559 $itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
560 $max_comments = ((x($_POST,'max_comments')) ? intval($_POST['max_comments']) : 0);
561 $lockpath = ((x($_POST,'lockpath')) ? notags(trim($_POST['lockpath'])) : '');
562 $temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
563 $basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
564 $singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
565 $proxy_disabled = ((x($_POST,'proxy_disabled')) ? True : False);
566 $old_pager = ((x($_POST,'old_pager')) ? True : False);
567 $only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
568 $rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
569 $embedly = ((x($_POST,'embedly')) ? notags(trim($_POST['embedly'])) : '');
571 if ($a->get_path() != "")
572 $diaspora_enabled = false;
575 $ostatus_disabled = true;
577 if($ssl_policy != intval(get_config('system','ssl_policy'))) {
578 if($ssl_policy == SSL_POLICY_FULL) {
579 q("update `contact` set
580 `url` = replace(`url` , 'http:' , 'https:'),
581 `photo` = replace(`photo` , 'http:' , 'https:'),
582 `thumb` = replace(`thumb` , 'http:' , 'https:'),
583 `micro` = replace(`micro` , 'http:' , 'https:'),
584 `request` = replace(`request`, 'http:' , 'https:'),
585 `notify` = replace(`notify` , 'http:' , 'https:'),
586 `poll` = replace(`poll` , 'http:' , 'https:'),
587 `confirm` = replace(`confirm`, 'http:' , 'https:'),
588 `poco` = replace(`poco` , 'http:' , 'https:')
591 q("update `profile` set
592 `photo` = replace(`photo` , 'http:' , 'https:'),
593 `thumb` = replace(`thumb` , 'http:' , 'https:')
597 elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
598 q("update `contact` set
599 `url` = replace(`url` , 'https:' , 'http:'),
600 `photo` = replace(`photo` , 'https:' , 'http:'),
601 `thumb` = replace(`thumb` , 'https:' , 'http:'),
602 `micro` = replace(`micro` , 'https:' , 'http:'),
603 `request` = replace(`request`, 'https:' , 'http:'),
604 `notify` = replace(`notify` , 'https:' , 'http:'),
605 `poll` = replace(`poll` , 'https:' , 'http:'),
606 `confirm` = replace(`confirm`, 'https:' , 'http:'),
607 `poco` = replace(`poco` , 'https:' , 'http:')
610 q("update `profile` set
611 `photo` = replace(`photo` , 'https:' , 'http:'),
612 `thumb` = replace(`thumb` , 'https:' , 'http:')
617 set_config('system','ssl_policy',$ssl_policy);
618 set_config('system','delivery_interval',$delivery_interval);
619 set_config('system','poll_interval',$poll_interval);
620 set_config('system','maxloadavg',$maxloadavg);
621 set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
622 set_config('system','optimize_max_tablesize',$optimize_max_tablesize);
623 set_config('system','optimize_fragmentation',$optimize_fragmentation);
624 set_config('system','poco_completion',$poco_completion);
625 set_config('system','poco_requery_days',$poco_requery_days);
626 set_config('system','poco_discovery',$poco_discovery);
627 set_config('system','poco_discovery_since',$poco_discovery_since);
628 set_config('system','poco_local_search',$poco_local_search);
629 set_config('system','nodeinfo',$nodeinfo);
630 set_config('config','sitename',$sitename);
631 set_config('config','hostname',$hostname);
632 set_config('config','sender_email', $sender_email);
633 set_config('system','suppress_language',$suppress_language);
634 set_config('system','suppress_tags',$suppress_tags);
635 set_config('system','shortcut_icon',$shortcut_icon);
636 set_config('system','touch_icon',$touch_icon);
639 // don't know why, but del_config doesn't work...
640 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
645 set_config('system','banner', $banner);
648 del_config('config','info');
650 set_config('config','info',$info);
652 set_config('system','language', $language);
653 set_config('system','theme', $theme);
654 if ( $theme_mobile === '---' ) {
655 del_config('system','mobile-theme');
657 set_config('system','mobile-theme', $theme_mobile);
659 if ( $singleuser === '---' ) {
660 del_config('system','singleuser');
662 set_config('system','singleuser', $singleuser);
664 set_config('system','maximagesize', $maximagesize);
665 set_config('system','max_image_length', $maximagelength);
666 set_config('system','jpeg_quality', $jpegimagequality);
668 set_config('config','register_policy', $register_policy);
669 set_config('system','max_daily_registrations', $daily_registrations);
670 set_config('system','account_abandon_days', $abandon_days);
671 set_config('config','register_text', $register_text);
672 set_config('system','allowed_sites', $allowed_sites);
673 set_config('system','allowed_email', $allowed_email);
674 set_config('system','block_public', $block_public);
675 set_config('system','publish_all', $force_publish);
676 set_config('system','directory', $global_directory);
677 set_config('system','thread_allow', $thread_allow);
678 set_config('system','newuser_private', $newuser_private);
679 set_config('system','enotify_no_content', $enotify_no_content);
680 set_config('system','disable_embedded', $disable_embedded);
681 set_config('system','allow_users_remote_self', $allow_users_remote_self);
683 set_config('system','block_extended_register', $no_multi_reg);
684 set_config('system','no_openid', $no_openid);
685 set_config('system','no_regfullname', $no_regfullname);
686 set_config('system','community_page_style', $community_page_style);
687 set_config('system','max_author_posts_community_page', $max_author_posts_community_page);
688 set_config('system','no_utf', $no_utf);
689 set_config('system','verifyssl', $verifyssl);
690 set_config('system','proxyuser', $proxyuser);
691 set_config('system','proxy', $proxy);
692 set_config('system','curl_timeout', $timeout);
693 set_config('system','dfrn_only', $dfrn_only);
694 set_config('system','ostatus_disabled', $ostatus_disabled);
695 set_config('system','ostatus_poll_interval', $ostatus_poll_interval);
696 set_config('system','diaspora_enabled', $diaspora_enabled);
698 set_config('config','private_addons', $private_addons);
700 set_config('system','force_ssl', $force_ssl);
701 set_config('system','old_share', $old_share);
702 set_config('system','hide_help', $hide_help);
703 set_config('system','use_fulltext_engine', $use_fulltext_engine);
704 set_config('system','itemcache', $itemcache);
705 set_config('system','itemcache_duration', $itemcache_duration);
706 set_config('system','max_comments', $max_comments);
707 set_config('system','lockpath', $lockpath);
708 set_config('system','temppath', $temppath);
709 set_config('system','basepath', $basepath);
710 set_config('system','proxy_disabled', $proxy_disabled);
711 set_config('system','old_pager', $old_pager);
712 set_config('system','only_tag_search', $only_tag_search);
715 if ($rino==2 and !function_exists('mcrypt_create_iv')){
716 notice(t("RINO2 needs mcrypt php extension to work."));
718 set_config('system','rino_encrypt', $rino);
721 set_config('system','embedly', $embedly);
724 info( t('Site settings updated.') . EOL);
725 goaway($a->get_baseurl(true) . '/admin/site' );
726 return; // NOTREACHED
731 * @brief generate Admin Site subpage
735 function admin_page_site(&$a) {
737 /* Installed langs */
738 $lang_choices = get_avaiable_languages();
740 if (strlen(get_config('system','directory_submit_url')) AND
741 !strlen(get_config('system','directory'))) {
742 set_config('system','directory', dirname(get_config('system','directory_submit_url')));
743 del_config('system','directory_submit_url');
746 /* Installed themes */
747 $theme_choices = array();
748 $theme_choices_mobile = array();
749 $theme_choices_mobile["---"] = t("No special theme for mobile devices");
750 $files = glob('view/theme/*'); /**/
752 foreach($files as $file) {
753 if (intval(file_exists($file . '/unsupported')))
756 $f = basename($file);
757 $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
758 if (file_exists($file . '/mobile')) {
759 $theme_choices_mobile[$f] = $theme_name;
761 $theme_choices[$f] = $theme_name;
766 /* Community page style */
767 $community_page_style_choices = array(
768 CP_NO_COMMUNITY_PAGE => t("No community page"),
769 CP_USERS_ON_SERVER => t("Public postings from users of this site"),
770 CP_GLOBAL_COMMUNITY => t("Global community page")
773 /* OStatus conversation poll choices */
774 $ostatus_poll_choices = array(
776 "-1" => t("At post arrival"),
777 "0" => t("Frequently"),
779 "720" => t("Twice daily"),
783 $poco_discovery_choices = array(
784 "0" => t("Disabled"),
786 "2" => t("Users, Global Contacts"),
787 "3" => t("Users, Global Contacts/fallback"),
790 $poco_discovery_since_choices = array(
791 "30" => t("One month"),
792 "91" => t("Three months"),
793 "182" => t("Half a year"),
794 "365" => t("One year"),
797 /* get user names to make the install a personal install of X */
798 $user_names = array();
799 $user_names['---'] = t('Multi user instance');
800 $users = q("SELECT username, nickname FROM `user`");
801 foreach ($users as $user) {
802 $user_names[$user['nickname']] = $user['username'];
806 $banner = get_config('system','banner');
808 $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
809 $banner = htmlspecialchars($banner);
810 $info = get_config('config','info');
811 $info = htmlspecialchars($info);
813 // Automatically create temporary paths
818 //echo "<pre>"; var_dump($lang_choices); die("</pre>");
820 /* Register policy */
821 $register_choices = Array(
822 REGISTER_CLOSED => t("Closed"),
823 REGISTER_APPROVE => t("Requires approval"),
824 REGISTER_OPEN => t("Open")
827 $ssl_choices = array(
828 SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
829 SSL_POLICY_FULL => t("Force all links to use SSL"),
830 SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
833 if ($a->config['hostname'] == "")
834 $a->config['hostname'] = $a->get_hostname();
836 $diaspora_able = ($a->get_path() == "");
838 $t = get_markup_template("admin_site.tpl");
839 return replace_macros($t, array(
840 '$title' => t('Administration'),
841 '$page' => t('Site'),
842 '$submit' => t('Save Settings'),
843 '$registration' => t('Registration'),
844 '$upload' => t('File upload'),
845 '$corporate' => t('Policies'),
846 '$advanced' => t('Advanced'),
847 '$portable_contacts' => t('Auto Discovered Contact Directory'),
848 '$performance' => t('Performance'),
849 '$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
850 '$baseurl' => $a->get_baseurl(true),
851 // name, label, value, help string, extra data...
852 '$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''),
853 '$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""),
854 '$sender_email' => array('sender_email', t("Sender Email"), $a->config['sender_email'], t("The email address your server shall use to send notification emails from."), "", "", "email"),
855 '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
856 '$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), get_config('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")),
857 '$touch_icon' => array('touch_icon', t("Touch icon"), get_config('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")),
858 '$info' => array('info',t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/siteinfo.'), get_server())),
859 '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
860 '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
861 '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
862 '$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
863 '$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
864 '$old_share' => array('old_share', t("Old style 'Share'"), get_config('system','old_share'), t("Deactivates the bbcode element 'share' for repeating items.")),
865 '$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
866 '$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
867 '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
868 '$maximagelength' => array('maximagelength', t("Maximum image length"), get_config('system','max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")),
869 '$jpegimagequality' => array('jpegimagequality', t("JPEG image quality"), get_config('system','jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")),
871 '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
872 '$daily_registrations' => array('max_daily_registrations', t("Maximum Daily Registrations"), get_config('system', 'max_daily_registrations'), t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")),
873 '$register_text' => array('register_text', t("Register text"), $a->config['register_text'], t("Will be displayed prominently on the registration page.")),
874 '$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')),
875 '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
876 '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
877 '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")),
878 '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")),
879 '$global_directory' => array('directory', t("Global directory URL"), get_config('system','directory'), t("URL to the global directory. If this is not set, the global directory is completely unavailable to the application.")),
880 '$thread_allow' => array('thread_allow', t("Allow threaded items"), get_config('system','thread_allow'), t("Allow infinite level threading for items on this site.")),
881 '$newuser_private' => array('newuser_private', t("Private posts by default for new users"), get_config('system','newuser_private'), t("Set default post permissions for all new members to the default privacy group rather than public.")),
882 '$enotify_no_content' => array('enotify_no_content', t("Don't include post content in email notifications"), get_config('system','enotify_no_content'), t("Don't include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.")),
883 '$private_addons' => array('private_addons', t("Disallow public access to addons listed in the apps menu."), get_config('config','private_addons'), t("Checking this box will restrict addons listed in the apps menu to members only.")),
884 '$disable_embedded' => array('disable_embedded', t("Don't embed private images in posts"), get_config('system','disable_embedded'), t("Don't replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.")),
885 '$allow_users_remote_self' => array('allow_users_remote_self', t('Allow Users to set remote_self'), get_config('system','allow_users_remote_self'), t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')),
886 '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")),
887 '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
888 '$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")),
889 '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
890 '$community_page_style' => array('community_page_style', t("Community Page Style"), get_config('system','community_page_style'), t("Type of community page to show. 'Global community' shows every public posting from an open distributed network that arrived on this server."), $community_page_style_choices),
891 '$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), get_config('system','max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")),
892 '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")),
893 '$ostatus_poll_interval' => array('ostatus_poll_interval', t("OStatus conversation completion interval"), (string) intval(get_config('system','ostatus_poll_interval')), t("How often shall the poller check for new entries in OStatus conversations? This can be a very ressource task."), $ostatus_poll_choices),
894 '$ostatus_not_able' => t("OStatus support can only be enabled if threading is enabled."),
895 '$diaspora_able' => $diaspora_able,
896 '$diaspora_not_able' => t("Diaspora support can't be enabled because Friendica was installed into a sub directory."),
897 '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
898 '$dfrn_only' => array('dfrn_only', t('Only allow Friendica contacts'), get_config('system','dfrn_only'), t("All contacts must use Friendica protocols. All other built-in communication protocols disabled.")),
899 '$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), t("If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.")),
900 '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
901 '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
902 '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
903 '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")),
904 '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
905 '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
906 '$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
907 '$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), ((intval(get_config('system','optimize_max_tablesize')) > 0)?get_config('system','optimize_max_tablesize'):100), t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
908 '$optimize_fragmentation'=> array('optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(get_config('system','optimize_fragmentation')) > 0)?get_config('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")),
910 '$poco_completion' => array('poco_completion', t("Periodical check of global contacts"), get_config('system','poco_completion'), t("If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.")),
911 '$poco_requery_days' => array('poco_requery_days', t("Days between requery"), get_config('system','poco_requery_days'), t("Number of days after which a server is requeried for his contacts.")),
912 '$poco_discovery' => array('poco_discovery', t("Discover contacts from other servers"), (string) intval(get_config('system','poco_discovery')), t("Periodically query other servers for contacts. You can choose between 'users': the users on the remote system, 'Global Contacts': active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren't available. The fallback increases the server load, so the recommened setting is 'Users, Global Contacts'."), $poco_discovery_choices),
913 '$poco_discovery_since' => array('poco_discovery_since', t("Timeframe for fetching global contacts"), (string) intval(get_config('system','poco_discovery_since')), t("When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers."), $poco_discovery_since_choices),
914 '$poco_local_search' => array('poco_local_search', t("Search the local directory"), get_config('system','poco_local_search'), t("Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.")),
916 '$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
918 '$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
919 '$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
920 '$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
921 '$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
922 '$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
923 '$max_comments' => array('max_comments', t("Maximum numbers of comments per post"), get_config('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")),
924 '$lockpath' => array('lockpath', t("Path for lock file"), get_config('system','lockpath'), t("The lock file is used to avoid multiple pollers at one time. Only define a folder here.")),
925 '$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")),
926 '$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")),
927 '$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")),
928 '$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")),
929 '$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
931 '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
933 '$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
934 '$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
936 '$form_security_token' => get_form_security_token("admin_site")
943 * @brief generates admin panel subpage for DB syncronization
947 function admin_page_dbsync(&$a) {
951 if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
952 set_config('database', 'update_' . intval($a->argv[3]), 'success');
953 $curr = get_config('system','build');
954 if(intval($curr) == intval($a->argv[3]))
955 set_config('system','build',intval($curr) + 1);
956 info( t('Update has been marked successful') . EOL);
957 goaway($a->get_baseurl(true) . '/admin/dbsync');
960 if(($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) {
961 require_once("include/dbstructure.php");
962 $retval = update_structure(false, true);
964 $o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION)."<br />";
965 set_config('database', 'dbupdate_'.DB_UPDATE_VERSION, 'success');
967 $o .= sprintf(t("Executing of database structure update %s failed with error: %s"),
968 DB_UPDATE_VERSION, $retval)."<br />";
969 if ($a->argv[2] === 'check')
973 if ($a->argc > 2 && intval($a->argv[2])) {
974 require_once('update.php');
975 $func = 'update_' . intval($a->argv[2]);
976 if(function_exists($func)) {
978 if($retval === UPDATE_FAILED) {
979 $o .= sprintf(t("Executing %s failed with error: %s"), $func, $retval);
981 elseif($retval === UPDATE_SUCCESS) {
982 $o .= sprintf(t('Update %s was successfully applied.', $func));
983 set_config('database',$func, 'success');
986 $o .= sprintf(t('Update %s did not return a status. Unknown if it succeeded.'), $func);
988 $o .= sprintf(t('There was no additional update function %s that needed to be called.'), $func)."<br />";
989 set_config('database',$func, 'success');
995 $r = q("select k, v from config where `cat` = 'database' ");
998 $upd = intval(substr($rr['k'],7));
999 if($upd < 1139 || $rr['v'] === 'success')
1004 if(! count($failed)) {
1005 $o = replace_macros(get_markup_template('structure_check.tpl'),array(
1006 '$base' => $a->get_baseurl(true),
1007 '$banner' => t('No failed updates.'),
1008 '$check' => t('Check database structure'),
1011 $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
1012 '$base' => $a->get_baseurl(true),
1013 '$banner' => t('Failed Updates'),
1014 '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
1015 '$mark' => t('Mark success (if update was manually applied)'),
1016 '$apply' => t('Attempt to execute this update step automatically'),
1017 '$failed' => $failed
1026 * @brief process data send by Users admin page
1029 function admin_page_users_post(&$a){
1030 $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
1031 $users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
1032 $nu_name = ( x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
1033 $nu_nickname = ( x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
1034 $nu_email = ( x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
1036 check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
1038 if (!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
1039 require_once('include/user.php');
1041 $result = create_user( array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1) );
1042 if(! $result['success']) {
1043 notice($result['message']);
1046 $nu = $result['user'];
1047 $preamble = deindent(t('
1049 the administrator of %2$s has set up an account for you.'));
1050 $body = deindent(t('
1051 The login details are as follows:
1057 You may change your password from your account "Settings" page after logging
1060 Please take a few moments to review the other account settings on that page.
1062 You may also wish to add some basic information to your default profile
1063 (on the "Profiles" page) so that other people can easily find you.
1065 We recommend setting your full name, adding a profile photo,
1066 adding some profile "keywords" (very useful in making new friends) - and
1067 perhaps what country you live in; if you do not wish to be more specific
1070 We fully respect your right to privacy, and none of these items are necessary.
1071 If you are new and do not know anybody here, they may help
1072 you to make some new and interesting friends.
1074 Thank you and welcome to %4$s.'));
1076 $preamble = sprintf($preamble, $nu['username'], $a->config['sitename']);
1077 $body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
1080 'type' => "SYSTEM_EMAIL",
1081 'to_email' => $nu['email'],
1082 'subject'=> sprintf( t('Registration details for %s'), $a->config['sitename']),
1083 'preamble'=> $preamble,
1088 if (x($_POST,'page_users_block')){
1089 foreach($users as $uid){
1090 q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
1094 notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) );
1096 if (x($_POST,'page_users_delete')){
1097 require_once("include/Contact.php");
1098 foreach($users as $uid){
1101 notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
1104 if (x($_POST,'page_users_approve')){
1105 require_once("mod/regmod.php");
1106 foreach($pending as $hash){
1110 if (x($_POST,'page_users_deny')){
1111 require_once("mod/regmod.php");
1112 foreach($pending as $hash){
1116 goaway($a->get_baseurl(true) . '/admin/users' );
1117 return; // NOTREACHED
1121 * @brief admin panel subpage for User management
1125 function admin_page_users(&$a){
1128 $user = q("SELECT username, blocked FROM `user` WHERE `uid`=%d", intval($uid));
1129 if (count($user)==0){
1130 notice( 'User not found' . EOL);
1131 goaway($a->get_baseurl(true) . '/admin/users' );
1132 return ''; // NOTREACHED
1134 switch($a->argv[2]){
1136 check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
1138 require_once("include/Contact.php");
1141 notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
1144 check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
1145 q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
1146 intval( 1-$user[0]['blocked'] ),
1149 notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
1152 goaway($a->get_baseurl(true) . '/admin/users' );
1153 return ''; // NOTREACHED
1158 $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
1160 LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
1161 LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
1166 $total = q("SELECT count(*) as total FROM `user` where 1");
1168 $a->set_pager_total($total[0]['total']);
1169 $a->set_pager_itemspage(100);
1173 $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
1175 (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
1177 WHERE `item`.`type` = 'wall'
1178 GROUP BY `item`.`uid`) AS `lastitem`
1179 RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
1182 `user`.`uid` = `contact`.`uid`
1183 AND `user`.`verified` =1
1184 AND `contact`.`self` =1
1185 ORDER BY `contact`.`name` LIMIT %d, %d
1187 intval($a->pager['start']),
1188 intval($a->pager['itemspage'])
1191 $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
1192 $_setup_users = function ($e) use ($adminlist){
1194 t('Normal Account'),
1195 t('Soapbox Account'),
1196 t('Community/Celebrity Account'),
1197 t('Automatic Friend Account')
1199 $e['page-flags'] = $accounts[$e['page-flags']];
1200 $e['register_date'] = relative_date($e['register_date']);
1201 $e['login_date'] = relative_date($e['login_date']);
1202 $e['lastitem_date'] = relative_date($e['lastitem_date']);
1203 //$e['is_admin'] = ($e['email'] === $a->config['admin_email']);
1204 $e['is_admin'] = in_array($e['email'], $adminlist);
1205 $e['is_deletable'] = (intval($e['uid']) != local_user());
1206 $e['deleted'] = ($e['account_removed']?relative_date($e['account_expires_on']):False);
1209 $users = array_map($_setup_users, $users);
1212 // Get rid of dashes in key names, Smarty3 can't handle them
1213 // and extracting deleted users
1215 $tmp_users = Array();
1218 while(count($users)) {
1219 $new_user = Array();
1220 foreach( array_pop($users) as $k => $v) {
1221 $k = str_replace('-','_',$k);
1224 if($new_user['deleted']) {
1225 array_push($deleted, $new_user);
1228 array_push($tmp_users, $new_user);
1231 //Reversing the two array, and moving $tmp_users to $users
1232 array_reverse($deleted);
1233 while(count($tmp_users)) {
1234 array_push($users, array_pop($tmp_users));
1237 $t = get_markup_template("admin_users.tpl");
1238 $o = replace_macros($t, array(
1240 '$title' => t('Administration'),
1241 '$page' => t('Users'),
1242 '$submit' => t('Add User'),
1243 '$select_all' => t('select all'),
1244 '$h_pending' => t('User registrations waiting for confirm'),
1245 '$h_deleted' => t('User waiting for permanent deletion'),
1246 '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
1247 '$no_pending' => t('No registrations.'),
1248 '$approve' => t('Approve'),
1249 '$deny' => t('Deny'),
1250 '$delete' => t('Delete'),
1251 '$block' => t('Block'),
1252 '$unblock' => t('Unblock'),
1253 '$siteadmin' => t('Site admin'),
1254 '$accountexpired' => t('Account expired'),
1256 '$h_users' => t('Users'),
1257 '$h_newuser' => t('New User'),
1258 '$th_deleted' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since') ),
1259 '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
1261 '$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'),
1262 '$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'),
1264 '$form_security_token' => get_form_security_token("admin_users"),
1267 '$baseurl' => $a->get_baseurl(true),
1269 '$pending' => $pending,
1270 'deleted' => $deleted,
1272 '$newusername' => array('new_user_name', t("Name"), '', t("Name of the new user.")),
1273 '$newusernickname' => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")),
1274 '$newuseremail' => array('new_user_email', t("Email"), '', t("Email address of the new user."), '', '', 'email'),
1282 * @brief Plugins admin page
1286 function admin_page_plugins(&$a){
1292 $plugin = $a->argv[2];
1293 if (!is_file("addon/$plugin/$plugin.php")){
1294 notice( t("Item not found.") );
1298 if (x($_GET,"a") && $_GET['a']=="t"){
1299 check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
1301 // Toggle plugin status
1302 $idx = array_search($plugin, $a->plugins);
1303 if ($idx !== false){
1304 unset($a->plugins[$idx]);
1305 uninstall_plugin($plugin);
1306 info( sprintf( t("Plugin %s disabled."), $plugin ) );
1308 $a->plugins[] = $plugin;
1309 install_plugin($plugin);
1310 info( sprintf( t("Plugin %s enabled."), $plugin ) );
1312 set_config("system","addon", implode(", ",$a->plugins));
1313 goaway($a->get_baseurl(true) . '/admin/plugins' );
1314 return ''; // NOTREACHED
1316 // display plugin details
1317 require_once('library/markdown.php');
1319 if (in_array($plugin, $a->plugins)){
1320 $status="on"; $action= t("Disable");
1322 $status="off"; $action= t("Enable");
1326 if (is_file("addon/$plugin/README.md")){
1327 $readme = file_get_contents("addon/$plugin/README.md");
1328 $readme = Markdown($readme);
1329 } else if (is_file("addon/$plugin/README")){
1330 $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
1334 if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
1335 @require_once("addon/$plugin/$plugin.php");
1336 $func = $plugin.'_plugin_admin';
1337 $func($a, $admin_form);
1340 $t = get_markup_template("admin_plugins_details.tpl");
1342 return replace_macros($t, array(
1343 '$title' => t('Administration'),
1344 '$page' => t('Plugins'),
1345 '$toggle' => t('Toggle'),
1346 '$settings' => t('Settings'),
1347 '$baseurl' => $a->get_baseurl(true),
1349 '$plugin' => $plugin,
1350 '$status' => $status,
1351 '$action' => $action,
1352 '$info' => get_plugin_info($plugin),
1353 '$str_author' => t('Author: '),
1354 '$str_maintainer' => t('Maintainer: '),
1356 '$admin_form' => $admin_form,
1357 '$function' => 'plugins',
1358 '$screenshot' => '',
1359 '$readme' => $readme,
1361 '$form_security_token' => get_form_security_token("admin_themes"),
1371 if (x($_GET,"a") && $_GET['a']=="r"){
1372 check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/plugins', 'admin_themes', 't');
1374 info("Plugins reloaded");
1375 goaway($a->get_baseurl().'/admin/plugins');
1379 $files = glob("addon/*/"); /* */
1381 foreach($files as $file) {
1383 list($tmp, $id)=array_map("trim", explode("/",$file));
1384 $info = get_plugin_info($id);
1385 $show_plugin = true;
1387 // If the addon is unsupported, then only show it, when it is enabled
1388 if ((strtolower($info["status"]) == "unsupported") AND !in_array($id, $a->plugins))
1389 $show_plugin = false;
1391 // Override the above szenario, when the admin really wants to see outdated stuff
1392 if (get_config("system", "show_unsupported_addons"))
1393 $show_plugin = true;
1396 $plugins[] = array($id, (in_array($id, $a->plugins)?"on":"off") , $info);
1401 $t = get_markup_template("admin_plugins.tpl");
1402 return replace_macros($t, array(
1403 '$title' => t('Administration'),
1404 '$page' => t('Plugins'),
1405 '$submit' => t('Save Settings'),
1406 '$reload' => t('Reload active plugins'),
1407 '$baseurl' => $a->get_baseurl(true),
1408 '$function' => 'plugins',
1409 '$plugins' => $plugins,
1410 '$form_security_token' => get_form_security_token("admin_themes"),
1415 * @param array $themes
1417 * @param int $result
1419 function toggle_theme(&$themes,$th,&$result) {
1420 for($x = 0; $x < count($themes); $x ++) {
1421 if($themes[$x]['name'] === $th) {
1422 if($themes[$x]['allowed']) {
1423 $themes[$x]['allowed'] = 0;
1427 $themes[$x]['allowed'] = 1;
1435 * @param array $themes
1439 function theme_status($themes,$th) {
1440 for($x = 0; $x < count($themes); $x ++) {
1441 if($themes[$x]['name'] === $th) {
1442 if($themes[$x]['allowed']) {
1455 * @param array $themes
1458 function rebuild_theme_table($themes) {
1460 if(count($themes)) {
1461 foreach($themes as $th) {
1462 if($th['allowed']) {
1479 function admin_page_themes(&$a){
1481 $allowed_themes_str = get_config('system','allowed_themes');
1482 $allowed_themes_raw = explode(',',$allowed_themes_str);
1483 $allowed_themes = array();
1484 if(count($allowed_themes_raw))
1485 foreach($allowed_themes_raw as $x)
1486 if(strlen(trim($x)))
1487 $allowed_themes[] = trim($x);
1490 $files = glob('view/theme/*'); /* */
1492 foreach($files as $file) {
1493 $f = basename($file);
1494 $is_experimental = intval(file_exists($file . '/experimental'));
1495 $is_supported = 1-(intval(file_exists($file . '/unsupported')));
1496 $is_allowed = intval(in_array($f,$allowed_themes));
1498 if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes"))
1499 $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
1503 if(! count($themes)) {
1504 notice( t('No themes found.'));
1513 $theme = $a->argv[2];
1514 if(! is_dir("view/theme/$theme")){
1515 notice( t("Item not found.") );
1519 if (x($_GET,"a") && $_GET['a']=="t"){
1520 check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
1522 // Toggle theme status
1524 toggle_theme($themes,$theme,$result);
1525 $s = rebuild_theme_table($themes);
1527 install_theme($theme);
1528 info( sprintf('Theme %s enabled.',$theme));
1531 uninstall_theme($theme);
1532 info( sprintf('Theme %s disabled.',$theme));
1535 set_config('system','allowed_themes',$s);
1536 goaway($a->get_baseurl(true) . '/admin/themes' );
1537 return ''; // NOTREACHED
1540 // display theme details
1541 require_once('library/markdown.php');
1543 if (theme_status($themes,$theme)) {
1544 $status="on"; $action= t("Disable");
1546 $status="off"; $action= t("Enable");
1550 if (is_file("view/theme/$theme/README.md")){
1551 $readme = file_get_contents("view/theme/$theme/README.md");
1552 $readme = Markdown($readme);
1553 } else if (is_file("view/theme/$theme/README")){
1554 $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
1558 if (is_file("view/theme/$theme/config.php")){
1559 function __get_theme_admin_form(&$a, $theme) {
1560 $orig_theme = $a->theme;
1561 $orig_page = $a->page;
1562 $orig_session_theme = $_SESSION['theme'];
1563 require_once("view/theme/$theme/theme.php");
1564 require_once("view/theme/$theme/config.php");
1565 $_SESSION['theme'] = $theme;
1568 $init = $theme."_init";
1569 if(function_exists($init)) $init($a);
1570 if(function_exists("theme_admin")){
1571 $admin_form = theme_admin($a);
1574 $_SESSION['theme'] = $orig_session_theme;
1575 $a->theme = $orig_theme;
1576 $a->page = $orig_page;
1579 $admin_form = __get_theme_admin_form($a, $theme);
1582 $screenshot = array( get_theme_screenshot($theme), t('Screenshot'));
1583 if(! stristr($screenshot[0],$theme))
1586 $t = get_markup_template("admin_plugins_details.tpl");
1587 return replace_macros($t, array(
1588 '$title' => t('Administration'),
1589 '$page' => t('Themes'),
1590 '$toggle' => t('Toggle'),
1591 '$settings' => t('Settings'),
1592 '$baseurl' => $a->get_baseurl(true),
1594 '$plugin' => $theme,
1595 '$status' => $status,
1596 '$action' => $action,
1597 '$info' => get_theme_info($theme),
1598 '$function' => 'themes',
1599 '$admin_form' => $admin_form,
1600 '$str_author' => t('Author: '),
1601 '$str_maintainer' => t('Maintainer: '),
1602 '$screenshot' => $screenshot,
1603 '$readme' => $readme,
1605 '$form_security_token' => get_form_security_token("admin_themes"),
1610 // reload active themes
1611 if (x($_GET,"a") && $_GET['a']=="r"){
1612 check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/themes', 'admin_themes', 't');
1614 foreach($themes as $th) {
1615 if ($th['allowed']) {
1616 uninstall_theme($th['name']);
1617 install_theme($th['name']);
1621 info("Themes reloaded");
1622 goaway($a->get_baseurl().'/admin/themes');
1631 foreach($themes as $th) {
1632 $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
1637 $t = get_markup_template("admin_plugins.tpl");
1638 return replace_macros($t, array(
1639 '$title' => t('Administration'),
1640 '$page' => t('Themes'),
1641 '$submit' => t('Save Settings'),
1642 '$reload' => t('Reload active themes'),
1643 '$baseurl' => $a->get_baseurl(true),
1644 '$function' => 'themes',
1645 '$plugins' => $xthemes,
1646 '$experimental' => t('[Experimental]'),
1647 '$unsupported' => t('[Unsupported]'),
1648 '$form_security_token' => get_form_security_token("admin_themes"),
1654 * @brief prosesses data send by Logs admin page
1658 function admin_page_logs_post(&$a) {
1659 if (x($_POST,"page_logs")) {
1660 check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
1662 $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
1663 $debugging = ((x($_POST,'debugging')) ? true : false);
1664 $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
1666 set_config('system','logfile', $logfile);
1667 set_config('system','debugging', $debugging);
1668 set_config('system','loglevel', $loglevel);
1673 info( t("Log settings updated.") );
1674 goaway($a->get_baseurl(true) . '/admin/logs' );
1675 return; // NOTREACHED
1679 * @brief generates admin panel subpage for configuration of the logs
1681 * This function take the view/templates/admin_logs.tpl file and generates a
1682 * page where admin can configure the logging of friendica.
1684 * Displaying the log is separated from the log config as the logfile can get
1685 * big depending on the settings and changing settings regarding the logs can
1686 * thus waste bandwidth.
1688 * The string returned contains the content of the template file with replaced
1694 function admin_page_logs(&$a){
1696 $log_choices = Array(
1697 LOGGER_NORMAL => 'Normal',
1698 LOGGER_TRACE => 'Trace',
1699 LOGGER_DEBUG => 'Debug',
1700 LOGGER_DATA => 'Data',
1704 $t = get_markup_template("admin_logs.tpl");
1706 /* $f = get_config('system','logfile');
1710 if(!file_exists($f)) {
1711 $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
1715 $fp = fopen($f, 'r');
1717 $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
1720 $fstat = fstat($fp);
1721 $size = $fstat['size'];
1724 if($size > 5000000 || $size < 0)
1726 $seek = fseek($fp,0-$size,SEEK_END);
1728 $data = escape_tags(fread($fp,$size));
1730 $data .= escape_tags(fread($fp,4096));
1737 return replace_macros($t, array(
1738 '$title' => t('Administration'),
1739 '$page' => t('Logs'),
1740 '$submit' => t('Save Settings'),
1741 '$clear' => t('Clear'),
1742 // '$data' => $data,
1743 '$baseurl' => $a->get_baseurl(true),
1744 '$logname' => get_config('system','logfile'),
1746 // name, label, value, help string, extra data...
1747 '$debugging' => array('debugging', t("Enable Debugging"),get_config('system','debugging'), ""),
1748 '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
1749 '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
1751 '$form_security_token' => get_form_security_token("admin_logs"),
1752 '$phpheader' => t("PHP logging"),
1753 '$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
1754 '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE );\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
1759 * @brief generates admin panel subpage to view the Friendica log
1761 * This function loads the template view/templates/admin_viewlogs.tpl to
1762 * display the systemlog content. The filename for the systemlog of friendica
1763 * is relative to the base directory and taken from the config entry 'logfile'
1764 * in the 'system' category.
1766 * Displaying the log is separated from the log config as the logfile can get
1767 * big depending on the settings and changing settings regarding the logs can
1768 * thus waste bandwidth.
1770 * The string returned contains the content of the template file with replaced
1776 function admin_page_viewlogs(&$a){
1777 $t = get_markup_template("admin_viewlogs.tpl");
1778 $f = get_config('system','logfile');
1781 if(!file_exists($f)) {
1782 $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is readable.");
1785 $fp = fopen($f, 'r');
1787 $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
1790 $fstat = fstat($fp);
1791 $size = $fstat['size'];
1794 if($size > 5000000 || $size < 0)
1796 $seek = fseek($fp,0-$size,SEEK_END);
1798 $data = escape_tags(fread($fp,$size));
1800 $data .= escape_tags(fread($fp,4096));
1806 return replace_macros($t, array(
1807 '$title' => t('Administration'),
1808 '$page' => t('View Logs'),
1810 '$logname' => get_config('system','logfile')
1816 function admin_page_remoteupdate_post(&$a) {
1817 // this function should be called via ajax post
1818 if(!is_site_admin()) {
1823 if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
1824 $remotefile = $_POST['remotefile'];
1825 $ftpdata = (x($_POST['ftphost'])?$_POST:false);
1826 doUpdate($remotefile, $ftpdata);
1828 echo "No remote file to download. Abort!";
1838 function admin_page_remoteupdate(&$a) {
1839 if(!is_site_admin()) {
1840 return login(false);
1843 $canwrite = canWeWrite();
1844 $canftp = function_exists('ftp_connect');
1849 $needupdate = false;
1850 $u = array('','','');
1853 $tpl = get_markup_template("admin_remoteupdate.tpl");
1854 return replace_macros($tpl, array(
1855 '$baseurl' => $a->get_baseurl(true),
1856 '$submit' => t("Update now"),
1857 '$close' => t("Close"),
1858 '$localversion' => FRIENDICA_VERSION,
1859 '$remoteversion' => $u[1],
1860 '$needupdate' => $needupdate,
1861 '$canwrite' => $canwrite,
1862 '$canftp' => $canftp,
1863 '$ftphost' => array('ftphost', t("FTP Host"), '',''),
1864 '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
1865 '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
1866 '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
1867 '$remotefile'=>array('remotefile','', $u['2'],''),