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(true) . '/admin/plugins/' . $a->argv[2] );
44 admin_page_logs_post($a);
47 admin_page_remoteupdate_post($a);
52 goaway($a->get_baseurl(true) . '/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(true)."/admin/site/", t("Site") , "site"),
72 'users' => Array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"),
73 'plugins'=> Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"),
74 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"),
75 'update' => Array($a->get_baseurl(true)."/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(true)."/admin/plugins/".$plugin, $plugin, "plugin");
85 // temp plugins with admin
86 $a->plugins_admin[] = $plugin;
89 $aside['logs'] = Array($a->get_baseurl(true)."/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(true)."/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'];
155 $t = get_markup_template("admin_summary.tpl");
156 return replace_macros($t, array(
157 '$title' => t('Administration'),
158 '$page' => t('Summary'),
159 '$users' => Array( t('Registered users'), $users),
160 '$accounts' => $accounts,
161 '$pending' => Array( t('Pending registrations'), $pending),
162 '$version' => Array( t('Version'), FRIENDICA_VERSION),
163 '$build' => get_config('system','build'),
164 '$plugins' => Array( t('Active plugins'), $a->plugins )
172 function admin_page_site_post(&$a){
173 if (!x($_POST,"page_site")){
178 $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
179 $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
180 $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
181 $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
182 $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
185 $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
186 $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
188 $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
190 $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
191 $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
192 $block_public = ((x($_POST,'block_public')) ? True : False);
193 $force_publish = ((x($_POST,'publish_all')) ? True : False);
194 $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
195 $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
196 $no_openid = !((x($_POST,'no_openid')) ? True : False);
197 $no_gravatar = !((x($_POST,'no_gravatar')) ? True : False);
198 $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
199 $no_utf = !((x($_POST,'no_utf')) ? True : False);
200 $no_community_page = !((x($_POST,'no_community_page')) ? True : False);
202 $verifyssl = ((x($_POST,'verifyssl')) ? True : False);
203 $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
204 $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
205 $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
206 $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
207 $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
208 $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
209 $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
211 set_config('config','sitename',$sitename);
213 // don't know why, but del_config doesn't work...
214 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
219 set_config('system','banner', $banner);
221 set_config('system','ssl_policy',$ssl_policy);
222 set_config('system','language', $language);
223 set_config('system','theme', $theme);
224 set_config('system','maximagesize', $maximagesize);
226 set_config('config','register_policy', $register_policy);
227 set_config('system','account_abandon_days', $abandon_days);
228 set_config('config','register_text', $register_text);
229 set_config('system','allowed_sites', $allowed_sites);
230 set_config('system','allowed_email', $allowed_email);
231 set_config('system','block_public', $block_public);
232 set_config('system','publish_all', $force_publish);
233 if ($global_directory==""){
234 // don't know why, but del_config doesn't work...
235 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
237 dbesc("directory_submit_url")
240 set_config('system','directory_submit_url', $global_directory);
242 set_config('system','directory_search_url', $global_search_url);
243 set_config('system','block_extended_register', $no_multi_reg);
244 set_config('system','no_openid', $no_openid);
245 set_config('system','no_gravatar', $no_gravatar);
246 set_config('system','no_regfullname', $no_regfullname);
247 set_config('system','no_community_page', $no_community_page);
248 set_config('system','no_utf', $no_utf);
249 set_config('system','verifyssl', $verifyssl);
250 set_config('system','proxyuser', $proxyuser);
251 set_config('system','proxy', $proxy);
252 set_config('system','curl_timeout', $timeout);
253 set_config('system','dfrn_only', $dfrn_only);
254 set_config('system','ostatus_disabled', $ostatus_disabled);
255 set_config('system','diaspora_enabled', $diaspora_enabled);
257 info( t('Site settings updated.') . EOL);
258 goaway($a->get_baseurl(true) . '/admin/site' );
259 return; // NOTREACHED
263 function admin_page_site(&$a) {
265 /* Installed langs */
266 $lang_choices = array();
267 $langs = glob('view/*/strings.php');
269 if(is_array($langs) && count($langs)) {
270 if(! in_array('view/en/strings.php',$langs))
271 $langs[] = 'view/en/';
273 foreach($langs as $l) {
274 $t = explode("/",$l);
275 $lang_choices[$t[1]] = $t[1];
279 /* Installed themes */
280 $theme_choices = array();
281 $files = glob('view/theme/*');
283 foreach($files as $file) {
284 $f = basename($file);
285 $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
286 $theme_choices[$f] = $theme_name;
292 $banner = get_config('system','banner');
294 $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>';
295 $banner = htmlspecialchars($banner);
297 //echo "<pre>"; var_dump($lang_choices); die("</pre>");
299 /* Register policy */
300 $register_choices = Array(
301 REGISTER_CLOSED => t("Closed"),
302 REGISTER_APPROVE => t("Requires approval"),
303 REGISTER_OPEN => t("Open")
306 $ssl_choices = array(
307 SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
308 SSL_POLICY_FULL => t("Force all links to use SSL"),
309 SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
312 $t = get_markup_template("admin_site.tpl");
313 return replace_macros($t, array(
314 '$title' => t('Administration'),
315 '$page' => t('Site'),
316 '$submit' => t('Submit'),
317 '$registration' => t('Registration'),
318 '$upload' => t('File upload'),
319 '$corporate' => t('Policies'),
320 '$advanced' => t('Advanced'),
322 '$baseurl' => $a->get_baseurl(true),
323 // name, label, value, help string, extra data...
324 '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""),
325 '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
326 '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
327 '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles"), $theme_choices),
328 '$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),
329 '$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.")),
331 '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
332 '$register_text' => array('register_text', t("Register text"), htmlentities($a->config['register_text'], ENT_QUOTES), t("Will be displayed prominently on the registration page.")),
333 '$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.')),
334 '$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")),
335 '$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")),
336 '$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.")),
337 '$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.")),
338 '$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.")),
340 '$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.")),
341 '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
342 '$no_gravatar' => array('no_gravatar', t("Gravatar support"), !get_config('system','no_gravatar'), t("Search new user's photo on Gravatar.")),
343 '$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")),
344 '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
345 '$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.")),
346 '$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.")),
347 '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
348 '$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.")),
349 '$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.")),
350 '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
351 '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
352 '$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).")),
363 function admin_page_users_post(&$a){
364 $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
365 $users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
367 if (x($_POST,'page_users_block')){
368 foreach($users as $uid){
369 q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
373 notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) );
375 if (x($_POST,'page_users_delete')){
376 require_once("include/Contact.php");
377 foreach($users as $uid){
380 notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
383 if (x($_POST,'page_users_approve')){
384 require_once("mod/regmod.php");
385 foreach($pending as $hash){
389 if (x($_POST,'page_users_deny')){
390 require_once("mod/regmod.php");
391 foreach($pending as $hash){
395 goaway($a->get_baseurl(true) . '/admin/users' );
396 return; // NOTREACHED
399 function admin_page_users(&$a){
402 $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
403 if (count($user)==0){
404 notice( 'User not found' . EOL);
405 goaway($a->get_baseurl(true) . '/admin/users' );
406 return; // NOTREACHED
411 require_once("include/Contact.php");
414 notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
417 q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
418 intval( 1-$user[0]['blocked'] ),
421 notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
424 goaway($a->get_baseurl(true) . '/admin/users' );
425 return; // NOTREACHED
430 $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
432 LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
433 LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
438 $total = q("SELECT count(*) as total FROM `user` where 1");
440 $a->set_pager_total($total[0]['total']);
441 $a->set_pager_itemspage(100);
445 $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`
447 (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
449 WHERE `item`.`type` = 'wall'
450 GROUP BY `item`.`uid`) AS `lastitem`
451 RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
454 `user`.`uid` = `contact`.`uid`
455 AND `user`.`verified` =1
456 AND `contact`.`self` =1
457 ORDER BY `contact`.`name` LIMIT %d, %d
459 intval($a->pager['start']),
460 intval($a->pager['itemspage'])
463 function _setup_users($e){
466 t('Soapbox Account'),
467 t('Community/Celebrity Account'),
468 t('Automatic Friend Account')
470 $e['page-flags'] = $accounts[$e['page-flags']];
471 $e['register_date'] = relative_date($e['register_date']);
472 $e['login_date'] = relative_date($e['login_date']);
473 $e['lastitem_date'] = relative_date($e['lastitem_date']);
476 $users = array_map("_setup_users", $users);
479 $t = get_markup_template("admin_users.tpl");
480 $o = replace_macros($t, array(
482 '$title' => t('Administration'),
483 '$page' => t('Users'),
484 '$submit' => t('Submit'),
485 '$select_all' => t('select all'),
486 '$h_pending' => t('User registrations waiting for confirm'),
487 '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
488 '$no_pending' => t('No registrations.'),
489 '$approve' => t('Approve'),
490 '$deny' => t('Deny'),
491 '$delete' => t('Delete'),
492 '$block' => t('Block'),
493 '$unblock' => t('Unblock'),
495 '$h_users' => t('Users'),
496 '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
498 '$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?'),
499 '$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?'),
503 '$baseurl' => $a->get_baseurl(true),
505 '$pending' => $pending,
517 function admin_page_plugins(&$a){
523 $plugin = $a->argv[2];
524 if (!is_file("addon/$plugin/$plugin.php")){
525 notice( t("Item not found.") );
529 if (x($_GET,"a") && $_GET['a']=="t"){
530 // Toggle plugin status
531 $idx = array_search($plugin, $a->plugins);
533 unset($a->plugins[$idx]);
534 uninstall_plugin($plugin);
535 info( sprintf( t("Plugin %s disabled."), $plugin ) );
537 $a->plugins[] = $plugin;
538 install_plugin($plugin);
539 info( sprintf( t("Plugin %s enabled."), $plugin ) );
541 set_config("system","addon", implode(", ",$a->plugins));
542 goaway($a->get_baseurl(true) . '/admin/plugins' );
543 return; // NOTREACHED
545 // display plugin details
546 require_once('library/markdown.php');
548 if (in_array($plugin, $a->plugins)){
549 $status="on"; $action= t("Disable");
551 $status="off"; $action= t("Enable");
555 if (is_file("addon/$plugin/README.md")){
556 $readme = file_get_contents("addon/$plugin/README.md");
557 $readme = Markdown($readme);
558 } else if (is_file("addon/$plugin/README")){
559 $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
563 if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
564 @require_once("addon/$plugin/$plugin.php");
565 $func = $plugin.'_plugin_admin';
566 $func($a, $admin_form);
569 $t = get_markup_template("admin_plugins_details.tpl");
570 return replace_macros($t, array(
571 '$title' => t('Administration'),
572 '$page' => t('Plugins'),
573 '$toggle' => t('Toggle'),
574 '$settings' => t('Settings'),
575 '$baseurl' => $a->get_baseurl(true),
577 '$plugin' => $plugin,
578 '$status' => $status,
579 '$action' => $action,
580 '$info' => get_plugin_info($plugin),
581 '$str_author' => t('Author: '),
582 '$str_maintainer' => t('Maintainer: '),
584 '$admin_form' => $admin_form,
585 '$function' => 'plugins',
598 $files = glob("addon/*/");
600 foreach($files as $file) {
602 list($tmp, $id)=array_map("trim", explode("/",$file));
603 $info = get_plugin_info($id);
604 $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
609 $t = get_markup_template("admin_plugins.tpl");
610 return replace_macros($t, array(
611 '$title' => t('Administration'),
612 '$page' => t('Plugins'),
613 '$submit' => t('Submit'),
614 '$baseurl' => $a->get_baseurl(true),
615 '$function' => 'plugins',
616 '$plugins' => $plugins
620 function toggle_theme(&$themes,$th,&$result) {
621 for($x = 0; $x < count($themes); $x ++) {
622 if($themes[$x]['name'] === $th) {
623 if($themes[$x]['allowed']) {
624 $themes[$x]['allowed'] = 0;
628 $themes[$x]['allowed'] = 1;
635 function theme_status($themes,$th) {
636 for($x = 0; $x < count($themes); $x ++) {
637 if($themes[$x]['name'] === $th) {
638 if($themes[$x]['allowed']) {
651 function rebuild_theme_table($themes) {
654 foreach($themes as $th) {
670 function admin_page_themes(&$a){
672 $allowed_themes_str = get_config('system','allowed_themes');
673 $allowed_themes_raw = explode(',',$allowed_themes_str);
674 $allowed_themes = array();
675 if(count($allowed_themes_raw))
676 foreach($allowed_themes_raw as $x)
678 $allowed_themes[] = trim($x);
681 $files = glob('view/theme/*');
683 foreach($files as $file) {
684 $f = basename($file);
685 $is_experimental = intval(file_exists($file . '/experimental'));
686 $is_unsupported = 1-(intval(file_exists($file . '/unsupported')));
687 $is_allowed = intval(in_array($f,$allowed_themes));
688 $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
692 if(! count($themes)) {
693 notice( t('No themes found.'));
702 $theme = $a->argv[2];
703 if(! is_dir("view/theme/$theme")){
704 notice( t("Item not found.") );
708 if (x($_GET,"a") && $_GET['a']=="t"){
710 // Toggle theme status
712 toggle_theme($themes,$theme,$result);
713 $s = rebuild_theme_table($themes);
715 info( sprintf('Theme %s enabled.',$theme));
717 info( sprintf('Theme %s disabled.',$theme));
719 set_config('system','allowed_themes',$s);
720 goaway($a->get_baseurl(true) . '/admin/themes' );
721 return; // NOTREACHED
724 // display theme details
725 require_once('library/markdown.php');
727 if (theme_status($themes,$theme)) {
728 $status="on"; $action= t("Disable");
730 $status="off"; $action= t("Enable");
734 if (is_file("view/$theme/README.md")){
735 $readme = file_get_contents("view/$theme/README.md");
736 $readme = Markdown($readme);
737 } else if (is_file("view/$theme/README")){
738 $readme = "<pre>". file_get_contents("view/$theme/README") ."</pre>";
743 $screenshot = array( get_theme_screenshot($theme), t('Screenshot'));
744 if(! stristr($screenshot[0],$theme))
747 $t = get_markup_template("admin_plugins_details.tpl");
748 return replace_macros($t, array(
749 '$title' => t('Administration'),
750 '$page' => t('Themes'),
751 '$toggle' => t('Toggle'),
752 '$settings' => t('Settings'),
753 '$baseurl' => $a->get_baseurl(true),
756 '$status' => $status,
757 '$action' => $action,
758 '$info' => get_theme_info($theme),
759 '$function' => 'themes',
760 '$admin_form' => $admin_form,
761 '$str_author' => t('Author: '),
762 '$str_maintainer' => t('Maintainer: '),
763 '$screenshot' => $screenshot,
776 foreach($themes as $th) {
777 $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
781 $t = get_markup_template("admin_plugins.tpl");
782 return replace_macros($t, array(
783 '$title' => t('Administration'),
784 '$page' => t('Themes'),
785 '$submit' => t('Submit'),
786 '$baseurl' => $a->get_baseurl(true),
787 '$function' => 'themes',
788 '$plugins' => $xthemes,
789 '$experimental' => t('[Experimental]'),
790 '$unsupported' => t('[Unsupported]')
799 function admin_page_logs_post(&$a) {
800 if (x($_POST,"page_logs")) {
802 $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
803 $debugging = ((x($_POST,'debugging')) ? true : false);
804 $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
806 set_config('system','logfile', $logfile);
807 set_config('system','debugging', $debugging);
808 set_config('system','loglevel', $loglevel);
813 info( t("Log settings updated.") );
814 goaway($a->get_baseurl(true) . '/admin/logs' );
815 return; // NOTREACHED
818 function admin_page_logs(&$a){
820 $log_choices = Array(
821 LOGGER_NORMAL => 'Normal',
822 LOGGER_TRACE => 'Trace',
823 LOGGER_DEBUG => 'Debug',
824 LOGGER_DATA => 'Data',
828 $t = get_markup_template("admin_logs.tpl");
830 $f = get_config('system','logfile');
834 if(!file_exists($f)) {
835 $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
839 $fp = fopen($f, 'r');
841 $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
845 $size = $fstat['size'];
848 if($size > 5000000 || $size < 0)
850 $seek = fseek($fp,0-$size,SEEK_END);
852 fgets($fp); // throw away the first partial line
853 $data = escape_tags(fread($fp,$size));
855 $data .= escape_tags(fread($fp,4096));
862 return replace_macros($t, array(
863 '$title' => t('Administration'),
864 '$page' => t('Logs'),
865 '$submit' => t('Submit'),
866 '$clear' => t('Clear'),
868 '$baseurl' => $a->get_baseurl(true),
869 '$logname' => get_config('system','logfile'),
871 // name, label, value, help string, extra data...
872 '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
873 '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
874 '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
878 function admin_page_remoteupdate_post(&$a) {
879 // this function should be called via ajax post
880 if(!is_site_admin()) {
885 if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
886 $remotefile = $_POST['remotefile'];
887 $ftpdata = (x($_POST['ftphost'])?$_POST:false);
888 doUpdate($remotefile, $ftpdata);
890 echo "No remote file to download. Abort!";
896 function admin_page_remoteupdate(&$a) {
897 if(!is_site_admin()) {
901 $canwrite = canWeWrite();
902 $canftp = function_exists('ftp_connect');
908 $u = array('','','');
911 $tpl = get_markup_template("admin_remoteupdate.tpl");
912 return replace_macros($tpl, array(
913 '$baseurl' => $a->get_baseurl(true),
914 '$submit' => t("Update now"),
915 '$close' => t("Close"),
916 '$localversion' => FRIENDICA_VERSION,
917 '$remoteversion' => $u[1],
918 '$needupdate' => $needupdate,
919 '$canwrite' => $canwrite,
920 '$canftp' => $canftp,
921 '$ftphost' => array('ftphost', t("FTP Host"), '',''),
922 '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
923 '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
924 '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
925 '$remotefile'=>array('remotefile','', $u['2'],'')