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']; }
151 $r = q("SELECT COUNT(id) as `count` FROM `register`");
152 $pending = $r[0]['count'];
158 $t = get_markup_template("admin_summary.tpl");
159 return replace_macros($t, array(
160 '$title' => t('Administration'),
161 '$page' => t('Summary'),
162 '$users' => Array( t('Registered users'), $users),
163 '$accounts' => $accounts,
164 '$pending' => Array( t('Pending registrations'), $pending),
165 '$version' => Array( t('Version'), FRIENDICA_VERSION),
166 '$build' => get_config('system','build'),
167 '$plugins' => Array( t('Active plugins'), $a->plugins )
175 function admin_page_site_post(&$a){
176 if (!x($_POST,"page_site")){
181 $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
182 $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
183 $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
184 $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
185 $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
188 $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
189 $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
191 $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
193 $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
194 $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
195 $block_public = ((x($_POST,'block_public')) ? True : False);
196 $force_publish = ((x($_POST,'publish_all')) ? True : False);
197 $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
198 $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
199 $no_openid = !((x($_POST,'no_openid')) ? True : False);
200 $no_gravatar = !((x($_POST,'no_gravatar')) ? True : False);
201 $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
202 $no_utf = !((x($_POST,'no_utf')) ? True : False);
203 $no_community_page = !((x($_POST,'no_community_page')) ? True : False);
205 $verifyssl = ((x($_POST,'verifyssl')) ? True : False);
206 $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
207 $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
208 $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
209 $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
210 $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
211 $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
214 set_config('config','sitename',$sitename);
216 // don't know why, but del_config doesn't work...
217 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
222 set_config('system','banner', $banner);
224 set_config('system','language', $language);
225 set_config('system','theme', $theme);
226 set_config('system','maximagesize', $maximagesize);
228 set_config('config','register_policy', $register_policy);
229 set_config('system','account_abandon_days', $abandon_days);
230 set_config('config','register_text', $register_text);
231 set_config('system','allowed_sites', $allowed_sites);
232 set_config('system','allowed_email', $allowed_email);
233 set_config('system','block_public', $block_public);
234 set_config('system','publish_all', $force_publish);
235 if ($global_directory==""){
236 // don't know why, but del_config doesn't work...
237 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
239 dbesc("directory_submit_url")
242 set_config('system','directory_submit_url', $global_directory);
244 set_config('system','directory_search_url', $global_search_url);
245 set_config('system','block_extended_register', $no_multi_reg);
246 set_config('system','no_openid', $no_openid);
247 set_config('system','no_gravatar', $no_gravatar);
248 set_config('system','no_regfullname', $no_regfullname);
249 set_config('system','no_community_page', $no_community_page);
250 set_config('system','no_utf', $no_utf);
251 set_config('system','verifyssl', $verifyssl);
252 set_config('system','proxyuser', $proxyuser);
253 set_config('system','proxy', $proxy);
254 set_config('system','curl_timeout', $timeout);
255 set_config('system','dfrn_only', $dfrn_only);
256 set_config('system','ostatus_disabled', $ostatus_disabled);
257 set_config('system','diaspora_enabled', $diaspora_enabled);
259 info( t('Site settings updated.') . EOL);
260 goaway($a->get_baseurl() . '/admin/site' );
261 return; // NOTREACHED
265 function admin_page_site(&$a) {
267 /* Installed langs */
268 $lang_choices = array();
269 $langs = glob('view/*/strings.php');
271 if(is_array($langs) && count($langs)) {
272 if(! in_array('view/en/strings.php',$langs))
273 $langs[] = 'view/en/';
275 foreach($langs as $l) {
276 $t = explode("/",$l);
277 $lang_choices[$t[1]] = $t[1];
281 /* Installed themes */
282 $theme_choices = array();
283 $files = glob('view/theme/*');
285 foreach($files as $file) {
286 $f = basename($file);
287 $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
288 $theme_choices[$f] = $theme_name;
294 $banner = get_config('system','banner');
296 $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>';
297 $banner = htmlspecialchars($banner);
299 //echo "<pre>"; var_dump($lang_choices); die("</pre>");
301 /* Register policy */
302 $register_choices = Array(
303 REGISTER_CLOSED => t("Closed"),
304 REGISTER_APPROVE => t("Requires approval"),
305 REGISTER_OPEN => t("Open")
308 $t = get_markup_template("admin_site.tpl");
309 return replace_macros($t, array(
310 '$title' => t('Administration'),
311 '$page' => t('Site'),
312 '$submit' => t('Submit'),
313 '$registration' => t('Registration'),
314 '$upload' => t('File upload'),
315 '$corporate' => t('Policies'),
316 '$advanced' => t('Advanced'),
318 '$baseurl' => $a->get_baseurl(),
319 // name, label, value, help string, extra data...
320 '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""),
321 '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
322 '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
323 '$theme' => array('theme', t("System theme"), get_config('system','theme'), "Default system theme (which may be over-ridden by user profiles)", $theme_choices),
325 '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), "Maximum size in bytes of uploaded images. Default is 0, which means no limits."),
327 '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
328 '$register_text' => array('register_text', t("Register text"), htmlentities($a->config['register_text'], ENT_QUOTES), "Will be displayed prominently on the registration page."),
329 '$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.')),
330 '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), "Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains"),
331 '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), "Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains"),
332 '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), "Check to block public access to all otherwise public personal pages on this site unless you are currently logged in."),
333 '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), "Check to force all profiles on this site to be listed in the site directory."),
334 '$global_directory' => array('directory_submit_url', t("Global directory update URL"), get_config('system','directory_submit_url'), "URL to update the global directory. If this is not set, the global directory is completely unavailable to the application."),
336 '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), "Disallow users to register additional accounts for use as pages."),
337 '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), "OpenID support for registration and logins."),
338 '$no_gravatar' => array('no_gravatar', t("Gravatar support"), !get_config('system','no_gravatar'), "Search new user's photo on Gravatar."),
339 '$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), "Force users to register with a space between firstname and lastname in Full name, as an antispam measure"),
340 '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), "Use PHP UTF8 regular expressions"),
341 '$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), "Display a Community page showing all recent public postings on this site."),
342 '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disable'), "Provide built-in OStatus \x28identi.ca, status.net, etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed."),
343 '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), "Provide built-in Diaspora network compatibility."),
344 '$dfrn_only' => array('dfrn_only', t('Only allow Friendica contacts'), get_config('system','dfrn_only'), "All contacts must use Friendica protocols. All other built-in communication protocols disabled."),
345 '$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), "If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites."),
346 '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
347 '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
348 '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), "Value is in seconds. Set to 0 for unlimited (not recommended)."),
359 function admin_page_users_post(&$a){
360 $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
361 $users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
363 if (x($_POST,'page_users_block')){
364 foreach($users as $uid){
365 q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
369 notice( sprintf( tt("%s user blocked", "%s users blocked/unblocked", count($users)), count($users)) );
371 if (x($_POST,'page_users_delete')){
372 require_once("include/Contact.php");
373 foreach($users as $uid){
376 notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
379 if (x($_POST,'page_users_approve')){
380 require_once("mod/regmod.php");
381 foreach($pending as $hash){
385 if (x($_POST,'page_users_deny')){
386 require_once("mod/regmod.php");
387 foreach($pending as $hash){
391 goaway($a->get_baseurl() . '/admin/users' );
392 return; // NOTREACHED
395 function admin_page_users(&$a){
398 $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
399 if (count($user)==0){
400 notice( 'User not found' . EOL);
401 goaway($a->get_baseurl() . '/admin/users' );
402 return; // NOTREACHED
407 require_once("include/Contact.php");
410 notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
413 q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
414 intval( 1-$user[0]['blocked'] ),
417 notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
420 goaway($a->get_baseurl() . '/admin/users' );
421 return; // NOTREACHED
426 $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
428 LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
429 LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
433 $total = q("SELECT count(*) as total FROM `user` where 1");
435 $a->set_pager_total($total[0]['total']);
436 $a->set_pager_itemspage(100);
439 $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`
441 (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
443 WHERE `item`.`type` = 'wall'
444 GROUP BY `item`.`uid`) AS `lastitem`
445 RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
448 `user`.`uid` = `contact`.`uid`
449 AND `user`.`verified` =1
450 AND `contact`.`self` =1
451 ORDER BY `contact`.`name` LIMIT %d, %d
453 intval($a->pager['start']),
454 intval($a->pager['itemspage'])
457 function _setup_users($e){
460 t('Soapbox Account'),
461 t('Community/Celebrity Account'),
462 t('Automatic Friend Account')
464 $e['page-flags'] = $accounts[$e['page-flags']];
465 $e['register_date'] = relative_date($e['register_date']);
466 $e['login_date'] = relative_date($e['login_date']);
467 $e['lastitem_date'] = relative_date($e['lastitem_date']);
470 $users = array_map("_setup_users", $users);
472 $t = get_markup_template("admin_users.tpl");
473 $o = replace_macros($t, array(
475 '$title' => t('Administration'),
476 '$page' => t('Users'),
477 '$submit' => t('Submit'),
478 '$select_all' => t('select all'),
479 '$h_pending' => t('User registrations waiting for confirm'),
480 '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
481 '$no_pending' => t('No registrations.'),
482 '$approve' => t('Approve'),
483 '$deny' => t('Deny'),
484 '$delete' => t('Delete'),
485 '$block' => t('Block'),
486 '$unblock' => t('Unblock'),
488 '$h_users' => t('Users'),
489 '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
491 '$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?'),
492 '$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?'),
496 '$baseurl' => $a->get_baseurl(),
498 '$pending' => $pending,
510 function admin_page_plugins(&$a){
516 $plugin = $a->argv[2];
517 if (!is_file("addon/$plugin/$plugin.php")){
518 notice( t("Item not found.") );
522 if (x($_GET,"a") && $_GET['a']=="t"){
523 // Toggle plugin status
524 $idx = array_search($plugin, $a->plugins);
526 unset($a->plugins[$idx]);
527 uninstall_plugin($plugin);
528 info( sprintf( t("Plugin %s disabled."), $plugin ) );
530 $a->plugins[] = $plugin;
531 install_plugin($plugin);
532 info( sprintf( t("Plugin %s enabled."), $plugin ) );
534 set_config("system","addon", implode(", ",$a->plugins));
535 goaway($a->get_baseurl() . '/admin/plugins' );
536 return; // NOTREACHED
538 // display plugin details
539 require_once('library/markdown.php');
541 if (in_array($plugin, $a->plugins)){
542 $status="on"; $action= t("Disable");
544 $status="off"; $action= t("Enable");
548 if (is_file("addon/$plugin/README.md")){
549 $readme = file_get_contents("addon/$plugin/README.md");
550 $readme = Markdown($readme);
551 } else if (is_file("addon/$plugin/README")){
552 $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
556 if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
557 @require_once("addon/$plugin/$plugin.php");
558 $func = $plugin.'_plugin_admin';
559 $func($a, $admin_form);
562 $t = get_markup_template("admin_plugins_details.tpl");
563 return replace_macros($t, array(
564 '$title' => t('Administration'),
565 '$page' => t('Plugins'),
566 '$toggle' => t('Toggle'),
567 '$settings' => t('Settings'),
568 '$baseurl' => $a->get_baseurl(),
570 '$plugin' => $plugin,
571 '$status' => $status,
572 '$action' => $action,
573 '$info' => get_plugin_info($plugin),
575 '$admin_form' => $admin_form,
576 '$function' => 'plugins',
588 $files = glob("addon/*/");
590 foreach($files as $file) {
592 list($tmp, $id)=array_map("trim", explode("/",$file));
593 $info = get_plugin_info($id);
594 $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
599 $t = get_markup_template("admin_plugins.tpl");
600 return replace_macros($t, array(
601 '$title' => t('Administration'),
602 '$page' => t('Plugins'),
603 '$submit' => t('Submit'),
604 '$baseurl' => $a->get_baseurl(),
605 '$function' => 'plugins',
606 '$plugins' => $plugins
610 function toggle_theme(&$themes,$th,&$result) {
611 for($x = 0; $x < count($themes); $x ++) {
612 if($themes[$x]['name'] === $th) {
613 if($themes[$x]['allowed']) {
614 $themes[$x]['allowed'] = 0;
618 $themes[$x]['allowed'] = 1;
625 function theme_status($themes,$th) {
626 for($x = 0; $x < count($themes); $x ++) {
627 if($themes[$x]['name'] === $th) {
628 if($themes[$x]['allowed']) {
641 function rebuild_theme_table($themes) {
644 foreach($themes as $th) {
660 function admin_page_themes(&$a){
662 $allowed_themes_str = get_config('system','allowed_themes');
663 $allowed_themes_raw = explode(',',$allowed_themes_str);
664 $allowed_themes = array();
665 if(count($allowed_themes_raw))
666 foreach($allowed_themes_raw as $x)
668 $allowed_themes[] = trim($x);
671 $files = glob('view/theme/*');
673 foreach($files as $file) {
674 $f = basename($file);
675 $is_experimental = intval(file_exists($file . '/experimental'));
676 $is_unsupported = 1-(intval(file_exists($file . '/unsupported')));
677 $is_allowed = intval(in_array($f,$allowed_themes));
678 $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
682 if(! count($themes)) {
683 notice( t('No themes found.'));
692 $theme = $a->argv[2];
693 if(! is_dir("view/theme/$theme")){
694 notice( t("Item not found.") );
698 if (x($_GET,"a") && $_GET['a']=="t"){
700 // Toggle theme status
702 toggle_theme($themes,$theme,$result);
703 $s = rebuild_theme_table($themes);
705 info( sprintf('Theme %s enabled.',$theme));
707 info( sprintf('Theme %s disabled.',$theme));
709 set_config('system','allowed_themes',$s);
710 goaway($a->get_baseurl() . '/admin/themes' );
711 return; // NOTREACHED
714 // display theme details
715 require_once('library/markdown.php');
717 if (theme_status($themes,$theme)) {
718 $status="on"; $action= t("Disable");
720 $status="off"; $action= t("Enable");
724 if (is_file("view/$theme/README.md")){
725 $readme = file_get_contents("view/$theme/README.md");
726 $readme = Markdown($readme);
727 } else if (is_file("view/$theme/README")){
728 $readme = "<pre>". file_get_contents("view/$theme/README") ."</pre>";
733 $t = get_markup_template("admin_plugins_details.tpl");
734 return replace_macros($t, array(
735 '$title' => t('Administration'),
736 '$page' => t('Themes'),
737 '$toggle' => t('Toggle'),
738 '$settings' => t('Settings'),
739 '$baseurl' => $a->get_baseurl(),
742 '$status' => $status,
743 '$action' => $action,
744 '$info' => get_theme_info($theme),
745 '$function' => 'themes',
746 '$admin_form' => $admin_form,
760 foreach($themes as $th) {
761 $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
765 $t = get_markup_template("admin_plugins.tpl");
766 return replace_macros($t, array(
767 '$title' => t('Administration'),
768 '$page' => t('Themes'),
769 '$submit' => t('Submit'),
770 '$baseurl' => $a->get_baseurl(),
771 '$function' => 'themes',
772 '$plugins' => $xthemes,
773 '$experimental' => t('[Experimental]'),
774 '$unsupported' => t('[Unsupported]')
783 function admin_page_logs_post(&$a) {
784 if (x($_POST,"page_logs")) {
786 $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
787 $debugging = ((x($_POST,'debugging')) ? true : false);
788 $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
790 set_config('system','logfile', $logfile);
791 set_config('system','debugging', $debugging);
792 set_config('system','loglevel', $loglevel);
797 info( t("Log settings updated.") );
798 goaway($a->get_baseurl() . '/admin/logs' );
799 return; // NOTREACHED
802 function admin_page_logs(&$a){
804 $log_choices = Array(
805 LOGGER_NORMAL => 'Normal',
806 LOGGER_TRACE => 'Trace',
807 LOGGER_DEBUG => 'Debug',
808 LOGGER_DATA => 'Data',
812 $t = get_markup_template("admin_logs.tpl");
814 $f = get_config('system','logfile');
818 if(!file_exists($f)) {
819 $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
823 $fp = fopen($f, 'r');
825 $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
829 $size = $fstat['size'];
832 if($size > 5000000 || $size < 0)
834 $seek = fseek($fp,0-$size,SEEK_END);
836 fgets($fp); // throw away the first partial line
837 $data = escape_tags(fread($fp,$size));
839 $data .= escape_tags(fread($fp,4096));
846 return replace_macros($t, array(
847 '$title' => t('Administration'),
848 '$page' => t('Logs'),
849 '$submit' => t('Submit'),
850 '$clear' => t('Clear'),
852 '$baseurl' => $a->get_baseurl(),
853 '$logname' => get_config('system','logfile'),
855 // name, label, value, help string, extra data...
856 '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
857 '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
858 '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
862 function admin_page_remoteupdate_post(&$a) {
863 // this function should be called via ajax post
864 if(!is_site_admin()) {
869 if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
870 $remotefile = $_POST['remotefile'];
871 $ftpdata = (x($_POST['ftphost'])?$_POST:false);
872 doUpdate($remotefile, $ftpdata);
874 echo "No remote file to download. Abort!";
880 function admin_page_remoteupdate(&$a) {
881 if(!is_site_admin()) {
885 $canwrite = canWeWrite();
886 $canftp = function_exists('ftp_connect');
892 $u = array('','','');
895 $tpl = get_markup_template("admin_remoteupdate.tpl");
896 return replace_macros($tpl, array(
897 '$baseurl' => $a->get_baseurl(),
898 '$submit' => t("Update now"),
899 '$close' => t("Close"),
900 '$localversion' => FRIENDICA_VERSION,
901 '$remoteversion' => $u[1],
902 '$needupdate' => $needupdate,
903 '$canwrite' => $canwrite,
904 '$canftp' => $canftp,
905 '$ftphost' => array('ftphost', t("FTP Host"), '',''),
906 '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
907 '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
908 '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
909 '$remotefile'=>array('remotefile','', $u['2'],'')