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/unblocked", "%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`;");
434 $total = q("SELECT count(*) as total FROM `user` where 1");
436 $a->set_pager_total($total[0]['total']);
437 $a->set_pager_itemspage(100);
441 $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`
443 (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
445 WHERE `item`.`type` = 'wall'
446 GROUP BY `item`.`uid`) AS `lastitem`
447 RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
450 `user`.`uid` = `contact`.`uid`
451 AND `user`.`verified` =1
452 AND `contact`.`self` =1
453 ORDER BY `contact`.`name` LIMIT %d, %d
455 intval($a->pager['start']),
456 intval($a->pager['itemspage'])
459 function _setup_users($e){
462 t('Soapbox Account'),
463 t('Community/Celebrity Account'),
464 t('Automatic Friend Account')
466 $e['page-flags'] = $accounts[$e['page-flags']];
467 $e['register_date'] = relative_date($e['register_date']);
468 $e['login_date'] = relative_date($e['login_date']);
469 $e['lastitem_date'] = relative_date($e['lastitem_date']);
472 $users = array_map("_setup_users", $users);
475 $t = get_markup_template("admin_users.tpl");
476 $o = replace_macros($t, array(
478 '$title' => t('Administration'),
479 '$page' => t('Users'),
480 '$submit' => t('Submit'),
481 '$select_all' => t('select all'),
482 '$h_pending' => t('User registrations waiting for confirm'),
483 '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
484 '$no_pending' => t('No registrations.'),
485 '$approve' => t('Approve'),
486 '$deny' => t('Deny'),
487 '$delete' => t('Delete'),
488 '$block' => t('Block'),
489 '$unblock' => t('Unblock'),
491 '$h_users' => t('Users'),
492 '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
494 '$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?'),
495 '$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?'),
499 '$baseurl' => $a->get_baseurl(),
501 '$pending' => $pending,
513 function admin_page_plugins(&$a){
519 $plugin = $a->argv[2];
520 if (!is_file("addon/$plugin/$plugin.php")){
521 notice( t("Item not found.") );
525 if (x($_GET,"a") && $_GET['a']=="t"){
526 // Toggle plugin status
527 $idx = array_search($plugin, $a->plugins);
529 unset($a->plugins[$idx]);
530 uninstall_plugin($plugin);
531 info( sprintf( t("Plugin %s disabled."), $plugin ) );
533 $a->plugins[] = $plugin;
534 install_plugin($plugin);
535 info( sprintf( t("Plugin %s enabled."), $plugin ) );
537 set_config("system","addon", implode(", ",$a->plugins));
538 goaway($a->get_baseurl() . '/admin/plugins' );
539 return; // NOTREACHED
541 // display plugin details
542 require_once('library/markdown.php');
544 if (in_array($plugin, $a->plugins)){
545 $status="on"; $action= t("Disable");
547 $status="off"; $action= t("Enable");
551 if (is_file("addon/$plugin/README.md")){
552 $readme = file_get_contents("addon/$plugin/README.md");
553 $readme = Markdown($readme);
554 } else if (is_file("addon/$plugin/README")){
555 $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
559 if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
560 @require_once("addon/$plugin/$plugin.php");
561 $func = $plugin.'_plugin_admin';
562 $func($a, $admin_form);
565 $t = get_markup_template("admin_plugins_details.tpl");
566 return replace_macros($t, array(
567 '$title' => t('Administration'),
568 '$page' => t('Plugins'),
569 '$toggle' => t('Toggle'),
570 '$settings' => t('Settings'),
571 '$baseurl' => $a->get_baseurl(),
573 '$plugin' => $plugin,
574 '$status' => $status,
575 '$action' => $action,
576 '$info' => get_plugin_info($plugin),
578 '$admin_form' => $admin_form,
579 '$function' => 'plugins',
591 $files = glob("addon/*/");
593 foreach($files as $file) {
595 list($tmp, $id)=array_map("trim", explode("/",$file));
596 $info = get_plugin_info($id);
597 $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
602 $t = get_markup_template("admin_plugins.tpl");
603 return replace_macros($t, array(
604 '$title' => t('Administration'),
605 '$page' => t('Plugins'),
606 '$submit' => t('Submit'),
607 '$baseurl' => $a->get_baseurl(),
608 '$function' => 'plugins',
609 '$plugins' => $plugins
613 function toggle_theme(&$themes,$th,&$result) {
614 for($x = 0; $x < count($themes); $x ++) {
615 if($themes[$x]['name'] === $th) {
616 if($themes[$x]['allowed']) {
617 $themes[$x]['allowed'] = 0;
621 $themes[$x]['allowed'] = 1;
628 function theme_status($themes,$th) {
629 for($x = 0; $x < count($themes); $x ++) {
630 if($themes[$x]['name'] === $th) {
631 if($themes[$x]['allowed']) {
644 function rebuild_theme_table($themes) {
647 foreach($themes as $th) {
663 function admin_page_themes(&$a){
665 $allowed_themes_str = get_config('system','allowed_themes');
666 $allowed_themes_raw = explode(',',$allowed_themes_str);
667 $allowed_themes = array();
668 if(count($allowed_themes_raw))
669 foreach($allowed_themes_raw as $x)
671 $allowed_themes[] = trim($x);
674 $files = glob('view/theme/*');
676 foreach($files as $file) {
677 $f = basename($file);
678 $is_experimental = intval(file_exists($file . '/experimental'));
679 $is_unsupported = 1-(intval(file_exists($file . '/unsupported')));
680 $is_allowed = intval(in_array($f,$allowed_themes));
681 $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
685 if(! count($themes)) {
686 notice( t('No themes found.'));
695 $theme = $a->argv[2];
696 if(! is_dir("view/theme/$theme")){
697 notice( t("Item not found.") );
701 if (x($_GET,"a") && $_GET['a']=="t"){
703 // Toggle theme status
705 toggle_theme($themes,$theme,$result);
706 $s = rebuild_theme_table($themes);
708 info( sprintf('Theme %s enabled.',$theme));
710 info( sprintf('Theme %s disabled.',$theme));
712 set_config('system','allowed_themes',$s);
713 goaway($a->get_baseurl() . '/admin/themes' );
714 return; // NOTREACHED
717 // display theme details
718 require_once('library/markdown.php');
720 if (theme_status($themes,$theme)) {
721 $status="on"; $action= t("Disable");
723 $status="off"; $action= t("Enable");
727 if (is_file("view/$theme/README.md")){
728 $readme = file_get_contents("view/$theme/README.md");
729 $readme = Markdown($readme);
730 } else if (is_file("view/$theme/README")){
731 $readme = "<pre>". file_get_contents("view/$theme/README") ."</pre>";
736 $t = get_markup_template("admin_plugins_details.tpl");
737 return replace_macros($t, array(
738 '$title' => t('Administration'),
739 '$page' => t('Themes'),
740 '$toggle' => t('Toggle'),
741 '$settings' => t('Settings'),
742 '$baseurl' => $a->get_baseurl(),
745 '$status' => $status,
746 '$action' => $action,
747 '$info' => get_theme_info($theme),
748 '$function' => 'themes',
749 '$admin_form' => $admin_form,
763 foreach($themes as $th) {
764 $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
768 $t = get_markup_template("admin_plugins.tpl");
769 return replace_macros($t, array(
770 '$title' => t('Administration'),
771 '$page' => t('Themes'),
772 '$submit' => t('Submit'),
773 '$baseurl' => $a->get_baseurl(),
774 '$function' => 'themes',
775 '$plugins' => $xthemes,
776 '$experimental' => t('[Experimental]'),
777 '$unsupported' => t('[Unsupported]')
786 function admin_page_logs_post(&$a) {
787 if (x($_POST,"page_logs")) {
789 $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
790 $debugging = ((x($_POST,'debugging')) ? true : false);
791 $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
793 set_config('system','logfile', $logfile);
794 set_config('system','debugging', $debugging);
795 set_config('system','loglevel', $loglevel);
800 info( t("Log settings updated.") );
801 goaway($a->get_baseurl() . '/admin/logs' );
802 return; // NOTREACHED
805 function admin_page_logs(&$a){
807 $log_choices = Array(
808 LOGGER_NORMAL => 'Normal',
809 LOGGER_TRACE => 'Trace',
810 LOGGER_DEBUG => 'Debug',
811 LOGGER_DATA => 'Data',
815 $t = get_markup_template("admin_logs.tpl");
817 $f = get_config('system','logfile');
821 if(!file_exists($f)) {
822 $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
826 $fp = fopen($f, 'r');
828 $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
832 $size = $fstat['size'];
835 if($size > 5000000 || $size < 0)
837 $seek = fseek($fp,0-$size,SEEK_END);
839 fgets($fp); // throw away the first partial line
840 $data = escape_tags(fread($fp,$size));
842 $data .= escape_tags(fread($fp,4096));
849 return replace_macros($t, array(
850 '$title' => t('Administration'),
851 '$page' => t('Logs'),
852 '$submit' => t('Submit'),
853 '$clear' => t('Clear'),
855 '$baseurl' => $a->get_baseurl(),
856 '$logname' => get_config('system','logfile'),
858 // name, label, value, help string, extra data...
859 '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
860 '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
861 '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
865 function admin_page_remoteupdate_post(&$a) {
866 // this function should be called via ajax post
867 if(!is_site_admin()) {
872 if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
873 $remotefile = $_POST['remotefile'];
874 $ftpdata = (x($_POST['ftphost'])?$_POST:false);
875 doUpdate($remotefile, $ftpdata);
877 echo "No remote file to download. Abort!";
883 function admin_page_remoteupdate(&$a) {
884 if(!is_site_admin()) {
888 $canwrite = canWeWrite();
889 $canftp = function_exists('ftp_connect');
895 $u = array('','','');
898 $tpl = get_markup_template("admin_remoteupdate.tpl");
899 return replace_macros($tpl, array(
900 '$baseurl' => $a->get_baseurl(),
901 '$submit' => t("Update now"),
902 '$close' => t("Close"),
903 '$localversion' => FRIENDICA_VERSION,
904 '$remoteversion' => $u[1],
905 '$needupdate' => $needupdate,
906 '$canwrite' => $canwrite,
907 '$canftp' => $canftp,
908 '$ftphost' => array('ftphost', t("FTP Host"), '',''),
909 '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
910 '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
911 '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
912 '$remotefile'=>array('remotefile','', $u['2'],'')