6 require_once("include/remoteupdate.php");
8 function admin_post(&$a){
11 if(!is_site_admin()) {
15 // do not allow a page manager to access the admin panel at all.
17 if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
26 admin_page_site_post($a);
29 admin_page_users_post($a);
33 is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")){
34 @include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
35 if(function_exists($a->argv[2].'_plugin_admin_post')) {
36 $func = $a->argv[2].'_plugin_admin_post';
40 goaway($a->get_baseurl() . '/admin/plugins/' . $a->argv[2] );
44 admin_page_logs_post($a);
47 admin_page_remoteupdate_post($a);
52 goaway($a->get_baseurl() . '/admin' );
56 function admin_content(&$a) {
58 if(!is_site_admin()) {
62 if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
69 // array( url, name, extra css classes )
71 'site' => Array($a->get_baseurl()."/admin/site/", t("Site") , "site"),
72 'users' => Array($a->get_baseurl()."/admin/users/", t("Users") , "users"),
73 'plugins'=> Array($a->get_baseurl()."/admin/plugins/", t("Plugins") , "plugins"),
74 'themes' => Array($a->get_baseurl()."/admin/themes/", t("Themes") , "themes"),
75 'update' => Array($a->get_baseurl()."/admin/update/", t("Update") , "update")
78 /* get plugins admin page */
80 $r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1");
81 $aside['plugins_admin']=Array();
84 $aside['plugins_admin'][] = Array($a->get_baseurl()."/admin/plugins/".$plugin, $plugin, "plugin");
85 // temp plugins with admin
86 $a->plugins_admin[] = $plugin;
89 $aside['logs'] = Array($a->get_baseurl()."/admin/logs/", t("Logs"), "logs");
91 $t = get_markup_template("admin_aside.tpl");
92 $a->page['aside'] = replace_macros( $t, array(
94 '$h_pending' => t('User registrations waiting for confirmation'),
95 '$admurl'=> $a->get_baseurl()."/admin/"
107 switch ($a->argv[1]){
109 $o = admin_page_site($a);
112 $o = admin_page_users($a);
115 $o = admin_page_plugins($a);
118 $o = admin_page_themes($a);
121 $o = admin_page_logs($a);
124 $o = admin_page_remoteupdate($a);
127 notice( t("Item not found.") );
130 $o = admin_page_summary($a);
139 function admin_page_summary(&$a) {
140 $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`");
142 Array( t('Normal Account'), 0),
143 Array( t('Soapbox Account'), 0),
144 Array( t('Community/Celebrity Account'), 0),
145 Array( t('Automatic Friend Account'), 0)
148 foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
150 logger('accounts: ' . print_r($accounts,true));
152 $r = q("SELECT COUNT(id) as `count` FROM `register`");
153 $pending = $r[0]['count'];
159 $t = get_markup_template("admin_summary.tpl");
160 return replace_macros($t, array(
161 '$title' => t('Administration'),
162 '$page' => t('Summary'),
163 '$users' => Array( t('Registered users'), $users),
164 '$accounts' => $accounts,
165 '$pending' => Array( t('Pending registrations'), $pending),
166 '$version' => Array( t('Version'), FRIENDICA_VERSION),
167 '$build' => get_config('system','build'),
168 '$plugins' => Array( t('Active plugins'), $a->plugins )
176 function admin_page_site_post(&$a){
177 if (!x($_POST,"page_site")){
182 $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
183 $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
184 $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
185 $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
186 $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
189 $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
190 $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
192 $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
194 $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
195 $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
196 $block_public = ((x($_POST,'block_public')) ? True : False);
197 $force_publish = ((x($_POST,'publish_all')) ? True : False);
198 $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
199 $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
200 $no_openid = !((x($_POST,'no_openid')) ? True : False);
201 $no_gravatar = !((x($_POST,'no_gravatar')) ? True : False);
202 $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
203 $no_utf = !((x($_POST,'no_utf')) ? True : False);
204 $no_community_page = !((x($_POST,'no_community_page')) ? True : False);
206 $verifyssl = ((x($_POST,'verifyssl')) ? True : False);
207 $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
208 $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
209 $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
210 $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
211 $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
212 $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
215 set_config('config','sitename',$sitename);
217 // don't know why, but del_config doesn't work...
218 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
223 set_config('system','banner', $banner);
225 set_config('system','language', $language);
226 set_config('system','theme', $theme);
227 set_config('system','maximagesize', $maximagesize);
229 set_config('config','register_policy', $register_policy);
230 set_config('system','account_abandon_days', $abandon_days);
231 set_config('config','register_text', $register_text);
232 set_config('system','allowed_sites', $allowed_sites);
233 set_config('system','allowed_email', $allowed_email);
234 set_config('system','block_public', $block_public);
235 set_config('system','publish_all', $force_publish);
236 if ($global_directory==""){
237 // don't know why, but del_config doesn't work...
238 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
240 dbesc("directory_submit_url")
243 set_config('system','directory_submit_url', $global_directory);
245 set_config('system','directory_search_url', $global_search_url);
246 set_config('system','block_extended_register', $no_multi_reg);
247 set_config('system','no_openid', $no_openid);
248 set_config('system','no_gravatar', $no_gravatar);
249 set_config('system','no_regfullname', $no_regfullname);
250 set_config('system','no_community_page', $no_community_page);
251 set_config('system','no_utf', $no_utf);
252 set_config('system','verifyssl', $verifyssl);
253 set_config('system','proxyuser', $proxyuser);
254 set_config('system','proxy', $proxy);
255 set_config('system','curl_timeout', $timeout);
256 set_config('system','dfrn_only', $dfrn_only);
257 set_config('system','ostatus_disabled', $ostatus_disabled);
258 set_config('system','diaspora_enabled', $diaspora_enabled);
260 info( t('Site settings updated.') . EOL);
261 goaway($a->get_baseurl() . '/admin/site' );
262 return; // NOTREACHED
266 function admin_page_site(&$a) {
268 /* Installed langs */
269 $lang_choices = array();
270 $langs = glob('view/*/strings.php');
272 if(is_array($langs) && count($langs)) {
273 if(! in_array('view/en/strings.php',$langs))
274 $langs[] = 'view/en/';
276 foreach($langs as $l) {
277 $t = explode("/",$l);
278 $lang_choices[$t[1]] = $t[1];
282 /* Installed themes */
283 $theme_choices = array();
284 $files = glob('view/theme/*');
286 foreach($files as $file) {
287 $f = basename($file);
288 $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
289 $theme_choices[$f] = $theme_name;
295 $banner = get_config('system','banner');
297 $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>';
298 $banner = htmlspecialchars($banner);
300 //echo "<pre>"; var_dump($lang_choices); die("</pre>");
302 /* Register policy */
303 $register_choices = Array(
304 REGISTER_CLOSED => t("Closed"),
305 REGISTER_APPROVE => t("Requires approval"),
306 REGISTER_OPEN => t("Open")
309 $t = get_markup_template("admin_site.tpl");
310 return replace_macros($t, array(
311 '$title' => t('Administration'),
312 '$page' => t('Site'),
313 '$submit' => t('Submit'),
314 '$registration' => t('Registration'),
315 '$upload' => t('File upload'),
316 '$corporate' => t('Policies'),
317 '$advanced' => t('Advanced'),
319 '$baseurl' => $a->get_baseurl(),
320 // name, label, value, help string, extra data...
321 '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""),
322 '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
323 '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
324 '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles"), $theme_choices),
326 '$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.")),
328 '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
329 '$register_text' => array('register_text', t("Register text"), htmlentities($a->config['register_text'], ENT_QUOTES), t("Will be displayed prominently on the registration page.")),
330 '$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.')),
331 '$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")),
332 '$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")),
333 '$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.")),
334 '$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.")),
335 '$global_directory' => array('directory_submit_url', t("Global directory update URL"), get_config('system','directory_submit_url'), t("URL to update the global directory. If this is not set, the global directory is completely unavailable to the application.")),
337 '$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.")),
338 '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
339 '$no_gravatar' => array('no_gravatar', t("Gravatar support"), !get_config('system','no_gravatar'), t("Search new user's photo on Gravatar.")),
340 '$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")),
341 '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
342 '$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), t("Display a Community page showing all recent public postings on this site.")),
343 '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disable'), t("Provide built-in OStatus \x28identi.ca, status.net, etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")),
344 '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
345 '$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.")),
346 '$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.")),
347 '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
348 '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
349 '$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).")),
360 function admin_page_users_post(&$a){
361 $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
362 $users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
364 if (x($_POST,'page_users_block')){
365 foreach($users as $uid){
366 q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
370 notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) );
372 if (x($_POST,'page_users_delete')){
373 require_once("include/Contact.php");
374 foreach($users as $uid){
377 notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
380 if (x($_POST,'page_users_approve')){
381 require_once("mod/regmod.php");
382 foreach($pending as $hash){
386 if (x($_POST,'page_users_deny')){
387 require_once("mod/regmod.php");
388 foreach($pending as $hash){
392 goaway($a->get_baseurl() . '/admin/users' );
393 return; // NOTREACHED
396 function admin_page_users(&$a){
399 $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
400 if (count($user)==0){
401 notice( 'User not found' . EOL);
402 goaway($a->get_baseurl() . '/admin/users' );
403 return; // NOTREACHED
408 require_once("include/Contact.php");
411 notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
414 q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
415 intval( 1-$user[0]['blocked'] ),
418 notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
421 goaway($a->get_baseurl() . '/admin/users' );
422 return; // NOTREACHED
427 $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
429 LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
430 LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
435 $total = q("SELECT count(*) as total FROM `user` where 1");
437 $a->set_pager_total($total[0]['total']);
438 $a->set_pager_itemspage(100);
442 $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`
444 (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
446 WHERE `item`.`type` = 'wall'
447 GROUP BY `item`.`uid`) AS `lastitem`
448 RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
451 `user`.`uid` = `contact`.`uid`
452 AND `user`.`verified` =1
453 AND `contact`.`self` =1
454 ORDER BY `contact`.`name` LIMIT %d, %d
456 intval($a->pager['start']),
457 intval($a->pager['itemspage'])
460 function _setup_users($e){
463 t('Soapbox Account'),
464 t('Community/Celebrity Account'),
465 t('Automatic Friend Account')
467 $e['page-flags'] = $accounts[$e['page-flags']];
468 $e['register_date'] = relative_date($e['register_date']);
469 $e['login_date'] = relative_date($e['login_date']);
470 $e['lastitem_date'] = relative_date($e['lastitem_date']);
473 $users = array_map("_setup_users", $users);
476 $t = get_markup_template("admin_users.tpl");
477 $o = replace_macros($t, array(
479 '$title' => t('Administration'),
480 '$page' => t('Users'),
481 '$submit' => t('Submit'),
482 '$select_all' => t('select all'),
483 '$h_pending' => t('User registrations waiting for confirm'),
484 '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
485 '$no_pending' => t('No registrations.'),
486 '$approve' => t('Approve'),
487 '$deny' => t('Deny'),
488 '$delete' => t('Delete'),
489 '$block' => t('Block'),
490 '$unblock' => t('Unblock'),
492 '$h_users' => t('Users'),
493 '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
495 '$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?'),
496 '$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?'),
500 '$baseurl' => $a->get_baseurl(),
502 '$pending' => $pending,
514 function admin_page_plugins(&$a){
520 $plugin = $a->argv[2];
521 if (!is_file("addon/$plugin/$plugin.php")){
522 notice( t("Item not found.") );
526 if (x($_GET,"a") && $_GET['a']=="t"){
527 // Toggle plugin status
528 $idx = array_search($plugin, $a->plugins);
530 unset($a->plugins[$idx]);
531 uninstall_plugin($plugin);
532 info( sprintf( t("Plugin %s disabled."), $plugin ) );
534 $a->plugins[] = $plugin;
535 install_plugin($plugin);
536 info( sprintf( t("Plugin %s enabled."), $plugin ) );
538 set_config("system","addon", implode(", ",$a->plugins));
539 goaway($a->get_baseurl() . '/admin/plugins' );
540 return; // NOTREACHED
542 // display plugin details
543 require_once('library/markdown.php');
545 if (in_array($plugin, $a->plugins)){
546 $status="on"; $action= t("Disable");
548 $status="off"; $action= t("Enable");
552 if (is_file("addon/$plugin/README.md")){
553 $readme = file_get_contents("addon/$plugin/README.md");
554 $readme = Markdown($readme);
555 } else if (is_file("addon/$plugin/README")){
556 $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
560 if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
561 @require_once("addon/$plugin/$plugin.php");
562 $func = $plugin.'_plugin_admin';
563 $func($a, $admin_form);
566 $t = get_markup_template("admin_plugins_details.tpl");
567 return replace_macros($t, array(
568 '$title' => t('Administration'),
569 '$page' => t('Plugins'),
570 '$toggle' => t('Toggle'),
571 '$settings' => t('Settings'),
572 '$baseurl' => $a->get_baseurl(),
574 '$plugin' => $plugin,
575 '$status' => $status,
576 '$action' => $action,
577 '$info' => get_plugin_info($plugin),
578 '$str_author' => t('Author: '),
579 '$str_maintainer' => t('Maintainer: '),
581 '$admin_form' => $admin_form,
582 '$function' => 'plugins',
594 $files = glob("addon/*/");
596 foreach($files as $file) {
598 list($tmp, $id)=array_map("trim", explode("/",$file));
599 $info = get_plugin_info($id);
600 $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
605 $t = get_markup_template("admin_plugins.tpl");
606 return replace_macros($t, array(
607 '$title' => t('Administration'),
608 '$page' => t('Plugins'),
609 '$submit' => t('Submit'),
610 '$baseurl' => $a->get_baseurl(),
611 '$function' => 'plugins',
612 '$plugins' => $plugins
616 function toggle_theme(&$themes,$th,&$result) {
617 for($x = 0; $x < count($themes); $x ++) {
618 if($themes[$x]['name'] === $th) {
619 if($themes[$x]['allowed']) {
620 $themes[$x]['allowed'] = 0;
624 $themes[$x]['allowed'] = 1;
631 function theme_status($themes,$th) {
632 for($x = 0; $x < count($themes); $x ++) {
633 if($themes[$x]['name'] === $th) {
634 if($themes[$x]['allowed']) {
647 function rebuild_theme_table($themes) {
650 foreach($themes as $th) {
666 function admin_page_themes(&$a){
668 $allowed_themes_str = get_config('system','allowed_themes');
669 $allowed_themes_raw = explode(',',$allowed_themes_str);
670 $allowed_themes = array();
671 if(count($allowed_themes_raw))
672 foreach($allowed_themes_raw as $x)
674 $allowed_themes[] = trim($x);
677 $files = glob('view/theme/*');
679 foreach($files as $file) {
680 $f = basename($file);
681 $is_experimental = intval(file_exists($file . '/experimental'));
682 $is_unsupported = 1-(intval(file_exists($file . '/unsupported')));
683 $is_allowed = intval(in_array($f,$allowed_themes));
684 $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
688 if(! count($themes)) {
689 notice( t('No themes found.'));
698 $theme = $a->argv[2];
699 if(! is_dir("view/theme/$theme")){
700 notice( t("Item not found.") );
704 if (x($_GET,"a") && $_GET['a']=="t"){
706 // Toggle theme status
708 toggle_theme($themes,$theme,$result);
709 $s = rebuild_theme_table($themes);
711 info( sprintf('Theme %s enabled.',$theme));
713 info( sprintf('Theme %s disabled.',$theme));
715 set_config('system','allowed_themes',$s);
716 goaway($a->get_baseurl() . '/admin/themes' );
717 return; // NOTREACHED
720 // display theme details
721 require_once('library/markdown.php');
723 if (theme_status($themes,$theme)) {
724 $status="on"; $action= t("Disable");
726 $status="off"; $action= t("Enable");
730 if (is_file("view/$theme/README.md")){
731 $readme = file_get_contents("view/$theme/README.md");
732 $readme = Markdown($readme);
733 } else if (is_file("view/$theme/README")){
734 $readme = "<pre>". file_get_contents("view/$theme/README") ."</pre>";
739 $t = get_markup_template("admin_plugins_details.tpl");
740 return replace_macros($t, array(
741 '$title' => t('Administration'),
742 '$page' => t('Themes'),
743 '$toggle' => t('Toggle'),
744 '$settings' => t('Settings'),
745 '$baseurl' => $a->get_baseurl(),
748 '$status' => $status,
749 '$action' => $action,
750 '$info' => get_theme_info($theme),
751 '$function' => 'themes',
752 '$admin_form' => $admin_form,
753 '$str_author' => t('Author: '),
754 '$str_maintainer' => t('Maintainer: '),
767 foreach($themes as $th) {
768 $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
772 $t = get_markup_template("admin_plugins.tpl");
773 return replace_macros($t, array(
774 '$title' => t('Administration'),
775 '$page' => t('Themes'),
776 '$submit' => t('Submit'),
777 '$baseurl' => $a->get_baseurl(),
778 '$function' => 'themes',
779 '$plugins' => $xthemes,
780 '$experimental' => t('[Experimental]'),
781 '$unsupported' => t('[Unsupported]')
790 function admin_page_logs_post(&$a) {
791 if (x($_POST,"page_logs")) {
793 $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
794 $debugging = ((x($_POST,'debugging')) ? true : false);
795 $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
797 set_config('system','logfile', $logfile);
798 set_config('system','debugging', $debugging);
799 set_config('system','loglevel', $loglevel);
804 info( t("Log settings updated.") );
805 goaway($a->get_baseurl() . '/admin/logs' );
806 return; // NOTREACHED
809 function admin_page_logs(&$a){
811 $log_choices = Array(
812 LOGGER_NORMAL => 'Normal',
813 LOGGER_TRACE => 'Trace',
814 LOGGER_DEBUG => 'Debug',
815 LOGGER_DATA => 'Data',
819 $t = get_markup_template("admin_logs.tpl");
821 $f = get_config('system','logfile');
825 if(!file_exists($f)) {
826 $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
830 $fp = fopen($f, 'r');
832 $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
836 $size = $fstat['size'];
839 if($size > 5000000 || $size < 0)
841 $seek = fseek($fp,0-$size,SEEK_END);
843 fgets($fp); // throw away the first partial line
844 $data = escape_tags(fread($fp,$size));
846 $data .= escape_tags(fread($fp,4096));
853 return replace_macros($t, array(
854 '$title' => t('Administration'),
855 '$page' => t('Logs'),
856 '$submit' => t('Submit'),
857 '$clear' => t('Clear'),
859 '$baseurl' => $a->get_baseurl(),
860 '$logname' => get_config('system','logfile'),
862 // name, label, value, help string, extra data...
863 '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
864 '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
865 '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
869 function admin_page_remoteupdate_post(&$a) {
870 // this function should be called via ajax post
871 if(!is_site_admin()) {
876 if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
877 $remotefile = $_POST['remotefile'];
878 $ftpdata = (x($_POST['ftphost'])?$_POST:false);
879 doUpdate($remotefile, $ftpdata);
881 echo "No remote file to download. Abort!";
887 function admin_page_remoteupdate(&$a) {
888 if(!is_site_admin()) {
892 $canwrite = canWeWrite();
893 $canftp = function_exists('ftp_connect');
899 $u = array('','','');
902 $tpl = get_markup_template("admin_remoteupdate.tpl");
903 return replace_macros($tpl, array(
904 '$baseurl' => $a->get_baseurl(),
905 '$submit' => t("Update now"),
906 '$close' => t("Close"),
907 '$localversion' => FRIENDICA_VERSION,
908 '$remoteversion' => $u[1],
909 '$needupdate' => $needupdate,
910 '$canwrite' => $canwrite,
911 '$canftp' => $canftp,
912 '$ftphost' => array('ftphost', t("FTP Host"), '',''),
913 '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
914 '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
915 '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
916 '$remotefile'=>array('remotefile','', $u['2'],'')