]> git.mxchange.org Git - friendica.git/blob - mod/admin.php
tooltip for selecting items
[friendica.git] / mod / admin.php
1 <?php
2  /**
3   * Friendika admin
4   */
5   
6  
7 function admin_init(&$a) {
8         if(!is_site_admin()) {
9                 notice( t('Permission denied.') . EOL);
10                 return;
11         }
12 }
13
14 function admin_post(&$a){
15         if(!is_site_admin()) {
16                 return login(false);
17         }
18         
19         // urls
20         if ($a->argc > 1){
21                 switch ($a->argv[1]){
22                         case 'site':
23                                 admin_page_site_post($a);
24                                 break;
25                         case 'users':
26                                 admin_page_users_post($a);
27                                 break;                          
28                         case 'logs':
29                                 admin_page_logs_post($a);
30                                 break;
31                 }
32         }
33
34         goaway($a->get_baseurl() . '/admin' );
35         return; // NOTREACHED   
36 }
37
38 function admin_content(&$a) {
39
40         if(!is_site_admin()) {
41                 return login(false);
42         }
43
44         /**
45          * Side bar links
46          */
47
48         // array( url, name, extra css classes )
49         $aside = Array(
50                 'site'   =>     Array($a->get_baseurl()."/admin/site/", t("Site") , "site"),
51                 'users'  =>     Array($a->get_baseurl()."/admin/users/", t("Users") , "users"),
52                 'plugins'=>     Array($a->get_baseurl()."/admin/plugins/", t("Plugins") , "plugins")
53         );
54         
55         /* get plugins admin page */
56         
57         $r = q("SELECT * FROM `hook` WHERE `hook`='plugin_admin'");
58         $aside['plugins_admin']=Array();
59         foreach ($r as $h){
60                 $plugin = explode("/",$h['file']); $plugin = $plugin[1];
61                 $aside['plugins_admin'][] = Array($a->get_baseurl()."/admin/plugins/".$plugin, $plugin, "plugin");
62         }
63                 
64         $aside['logs'] = Array($a->get_baseurl()."/admin/logs/", t("Logs"), "logs");
65
66         $t = get_markup_template("admin_aside.tpl");
67         $a->page['aside'] = replace_macros( $t, array(
68                         '$admin' => $aside, 
69                         '$h_pending' => t('User registrations waiting for confirm'),
70                         '$admurl'=> $a->get_baseurl()."/admin/"
71         ));
72
73
74
75         /**
76          * Page content
77          */
78         $o = '';
79         
80         // urls
81         if ($a->argc > 1){
82                 switch ($a->argv[1]){
83                         case 'site':
84                                 $o = admin_page_site($a);
85                                 break;
86                         case 'users':
87                                 $o = admin_page_users($a);
88                                 break;
89                         case 'plugins':
90                                 $o = admin_page_plugins($a);
91                                 break;
92                         case 'logs':
93                                 $o = admin_page_logs($a);
94                                 break;                          
95                         default:
96                                 notice( t("Item not found.") );
97                 }
98         } else {
99                 $o = admin_page_summary($a);
100         }
101         return $o;
102
103
104
105 /**
106  * Admin Summary Page
107  */
108 function admin_page_summary(&$a) {
109         $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`");
110         $accounts = Array(
111                 Array( t('Normal Account'), 0),
112                 Array( t('Soapbox Account'), 0),
113                 Array( t('Community/Celebrity Account'), 0),
114                 Array( t('Automatic Friend Account'), 0)
115         );
116         $users=0;
117         foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+=$u['count']; }
118
119         
120         $r = q("SELECT COUNT(id) as `count` FROM `register`");
121         $pending = $r[0]['count'];
122         
123         
124         
125         
126         
127         $t = get_markup_template("admin_summary.tpl");
128         return replace_macros($t, array(
129                 '$title' => t('Administration'),
130                 '$page' => t('Summary'),
131                 '$users' => Array( t('Registered users'), $users),
132                 '$accounts' => $accounts,
133                 '$pending' => Array( t('Pending registrations'), $pending),
134                 '$version' => Array( t('Version'), FRIENDIKA_VERSION),
135                 '$build' =>  get_config('system','build'),
136                 '$plugins' => Array( t('Active plugins'), $a->plugins )
137         ));
138 }
139
140
141 /**
142  * Admin Site Page
143  */
144 function admin_page_site_post(&$a){
145         if (!x($_POST,"page_site")){
146                 return;
147         }
148
149         
150         $sitename                       =       ((x($_POST,'sitename'))                 ? notags(trim($_POST['sitename']))                      : '');
151         $banner                         =       ((x($_POST,'banner'))                   ? trim($_POST['banner'])                                        : false);
152         $language                       =       ((x($_POST,'language'))                 ? notags(trim($_POST['language']))                      : '');
153         $theme                          =       ((x($_POST,'theme'))                    ? notags(trim($_POST['theme']))                         : '');
154         $maximagesize           =       ((x($_POST,'maximagesize'))             ? intval(trim($_POST['maximagesize']))          :  0);
155         
156         
157         $register_policy        =       ((x($_POST,'register_policy'))  ? intval(trim($_POST['register_policy']))       :  0);
158         $register_text          =       ((x($_POST,'register_text'))    ? notags(trim($_POST['register_text']))         : '');  
159         
160         $allowed_sites          =       ((x($_POST,'allowed_sites'))    ? notags(trim($_POST['allowed_sites']))         : '');
161         $allowed_email          =       ((x($_POST,'allowed_email'))    ? notags(trim($_POST['allowed_email']))         : '');
162         $block_public           =       ((x($_POST,'block_public'))             ? True  :       False);
163         $force_publish          =       ((x($_POST,'publish_all'))              ? True  :       False);
164         $global_directory       =       ((x($_POST,'directory_submit_url'))     ? notags(trim($_POST['directory_submit_url']))  : '');
165         $global_search_url      =       ((x($_POST,'directory_search_url'))? notags(trim($_POST['directory_search_url']))       : '');
166         $no_multi_reg           =       ((x($_POST,'no_multi_reg'))             ? True  :       False);
167         $no_openid                      =       ((x($_POST,'no_openid'))                ? True  :       False);
168         $no_gravatar            =       ((x($_POST,'no_gravatar'))              ? True  :       False);
169         $no_regfullname         =       ((x($_POST,'no_regfullname'))   ? True  :       False);
170         $no_utf                         =       ((x($_POST,'no_utf'))                   ? True  :       False);
171         $rino_enc                       =       ((x($_POST,'rino_enc'))                 ? True  :       False);
172         $verifyssl                      =       ((x($_POST,'verifyssl'))                ? True  :       False);
173         $proxyuser                      =       ((x($_POST,'proxyuser'))                ? notags(trim($_POST['global_search_url']))     : '');
174         $proxy                          =       ((x($_POST,'proxy'))                    ? notags(trim($_POST['global_search_url']))     : '');
175         $timeout                        =       ((x($_POST,'timeout'))                  ? intval(trim($_POST['timeout']))               : 60);
176
177
178         set_config('config','sitename',$sitename);
179         if ($banner==""){
180                 // don't know why, but del_config doesn't work...
181                 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
182                         dbesc("system"),
183                         dbesc("banner")
184                 );
185         } else {
186                 set_config('system','banner', $banner);
187         }
188         set_config('system','language', $language);
189         set_config('system','theme', $theme);
190         set_config('system','maximagesize', $maximagesize);
191         
192         set_config('config','register_policy', $register_policy);
193         set_config('config','register_text', $register_text);
194         set_config('system','allowed_sites', $allowed_sites);
195         set_config('system','allowed_email', $allowed_email);
196         set_config('system','block_public', $block_public);
197         set_config('system','publish_all', $force_publish);
198         if ($global_directory==""){
199                 // don't know why, but del_config doesn't work...
200                 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
201                         dbesc("system"),
202                         dbesc("directory_submit_url")
203                 );
204         } else {
205                 set_config('system','directory_submit_url', $global_directory);
206         }
207         set_config('system','directory_search_url', $global_search_url);
208         set_config('system','block_extended_register', $no_multi_reg);
209         set_config('system','no_openid', $no_openid);
210         set_config('system','no_gravatar', $no_gravatar);
211         set_config('system','no_regfullname', $no_regfullname);
212         set_config('system','proxy', $no_utf);
213         set_config('system','rino_encrypt', $rino_enc);
214         set_config('system','verifyssl', $verifyssl);
215         set_config('system','proxyuser', $proxyuser);
216         set_config('system','proxy', $proxy);
217         set_config('system','curl_timeout', $timeout);
218
219
220         goaway($a->get_baseurl() . '/admin/site' );
221         return; // NOTREACHED   
222         
223 }
224  
225 function admin_page_site(&$a) {
226         
227         /* Installed langs */
228         $lang_choices = array();
229         $langs = glob('view/*/strings.php');
230         
231         if(is_array($langs) && count($langs)) {
232                 if(! in_array('view/en/strings.php',$langs))
233                         $langs[] = 'view/en/';
234                 asort($langs);
235                 foreach($langs as $l) {
236                         $t = explode("/",$l);
237                         $lang_choices[$t[1]] = $t[1];
238                 }
239         }
240         
241         /* Installed themes */
242         $theme_choices = array();
243         $files = glob('view/theme/*');
244         if($files) {
245                 foreach($files as $file) {
246                         $f = basename($file);
247                         $theme_name = ((file_exists($file . '/experimental')) ?  sprintf("%s - \x28Experimental\x29", $f) : $f);
248                         $theme_choices[$f] = $theme_name;
249                 }
250         }
251         
252         
253         /* Banner */
254         $banner = get_config('system','banner');
255         if($banner == false) 
256                 $banner = htmlspecialchars('<a href="http://project.friendika.com"><img id="logo-img" src="images/friendika-32.png" alt="logo" /></a><span id="logo-text"><a href="http://project.friendika.com">Friendika</a></span>');
257         
258         //echo "<pre>"; var_dump($lang_choices); die("</pre>");
259
260         /* Register policy */
261         $register_choices = Array(
262                 REGISTER_CLOSED => t("Closed"),
263                 REGISTER_APPROVE => t("Need approvation"),
264                 REGISTER_OPEN => t("Open")
265         ); 
266         
267         $t = get_markup_template("admin_site.tpl");
268         return replace_macros($t, array(
269                 '$title' => t('Administration'),
270                 '$page' => t('Site'),
271                 '$submit' => t('Submit'),
272                 '$baseurl' => $a->get_baseurl(),
273                                                 
274                                                                         // name, label, value, help string, extra data...
275                 '$sitename'             => array('sitename', t("Site name"), $a->config['sitename'], ""),
276                 '$banner'                       => array('banner', t("Banner/Logo"), $banner, ""),
277                 '$language'             => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
278                 '$theme'                        => array('theme', t("System theme"), get_config('system','theme'), "Default system theme (which may be over-ridden by user profiles)", $theme_choices),
279
280                 '$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."),
281
282                 '$register_policy'      => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
283                 '$register_text'        => array('register_text', t("Register text"), $a->config['register_text'], "Will be displayed prominently on the registration page."),
284                 '$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"),
285                 '$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"),
286                 '$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."),
287                 '$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."),
288                 '$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."),
289                 '$global_search_url'=> array('directory_search_url', t("Global directory search URL"), get_config('system','directory_search_url'), ""),
290                         
291                         
292                 '$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."),
293                 '$no_openid'            => array('no_openid', t("No OpenID support"), get_config('system','no_openid'), "Disable OpenID support for registration and logins."),
294                 '$no_gravatar'          => array('no_gravatar', t("No Gravatar support"), get_config('system','no_gravatar'), ""),
295                 '$no_regfullname'       => array('no_regfullname', t("No fullname check"), get_config('system','no_regfullname'), "If unchecked, force users to registrate with a space between his firsname and lastname in Full name, as an antispam measure"),
296                 '$no_utf'                       => array('no_utf', t("No UTF-8 Regular expressions"), get_config('system','proxy'), "Default is false (meaning UTF8 regular expressions are supported and working)"),
297                         
298                 '$rino_enc'                     => array('rino_enc', t("Enable Rino encrypt"), get_config('system','rino_encrypt'),""),
299                 '$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."),
300                 '$proxyuser'            => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
301                 '$proxy'                        => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
302                 '$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)."),
303
304                         
305         ));
306
307 }
308
309
310 /**
311  * Users admin page
312  */
313 function admin_page_users_post(&$a){
314         $users=array(); $pending=array();
315         foreach($_POST as $k=>$v){
316                 if (substr($k,0,5)=="user_") $users[] = substr($k,5,strlen($k)-5);
317                 if (substr($k,0,8)=="pending_") $users[] = substr($k,8,strlen($k)-8);
318         }
319         
320         if (x($_POST,'page_users_block')){
321                 foreach($users as $uid){
322                         q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
323                                 intval( $uid )
324                         );
325                 }
326                 notice( sprintf( tt("%s user blocked", "%s users blocked", count($users)), count($users)) );
327         }
328         if (x($_POST,'page_users_delete')){
329                 require_once("include/Contact.php");
330                 foreach($users as $uid){
331                         user_remove($uid);
332                 }
333                 notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
334         }
335         
336         if (x($_POST,'page_users_approve')){
337                 require_once("include/regmod.php");
338                 foreach($pending as $hash){
339                         user_allow($hash);
340                 }
341         }
342         if (x($_POST,'page_users_deny')){
343                 require_once("include/regmod.php");
344                 foreach($pending as $hash){
345                         user_deny($hash);
346                 }
347         }
348         goaway($a->get_baseurl() . '/admin/users' );
349         return; // NOTREACHED   
350 }
351  
352 function admin_page_users(&$a){
353         if ($a->argc>2) {
354                 $uid = $a->argv[3];
355                 $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
356                 if (count($user)==0){
357                         notice( 'User not found' . EOL);
358                         goaway($a->get_baseurl() . '/admin/users' );
359                         return; // NOTREACHED                                           
360                 }               
361                 switch($a->argv[2]){
362                         case "delete":{
363                                 // delete user
364                                 require_once("include/Contact.php");
365                                 user_remove($uid);
366                                 
367                                 notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
368                         }; break;
369                         case "block":{
370                                 q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
371                                         intval( 1-$user[0]['blocked'] ),
372                                         intval( $uid )
373                                 );
374                         }; break;
375                 }
376                 goaway($a->get_baseurl() . '/admin/users' );
377                 return; // NOTREACHED   
378                 
379         }
380         
381         /* get pending */
382         $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
383                                  FROM `register`
384                                  LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
385                                  LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
386         
387         /* get users */
388
389         $total = q("SELECT count(*) as total FROM `user` where 1");
390         if(count($total)) {
391                 $a->set_pager_total($total[0]['total']);
392                 $a->set_pager_itemspage(100);
393         }
394
395         $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro` , `lastitem`.`changed` AS `lastitem_date`
396                                 FROM (
397                                         SELECT `item`.`changed` , `item`.`uid`
398                                         FROM `item`
399                                         GROUP BY `uid`
400                                         ORDER BY `item`.`changed`
401                                 ) AS `lastitem` , `user`
402                                 LEFT JOIN `contact` ON `user`.`uid` = `contact`.`uid`
403                                 WHERE `user`.`verified` =1
404                                 AND `contact`.`self` =1
405                                 AND `lastitem`.`uid` = `user`.`uid`
406                                 ORDER BY `contact`.`name` LIMIT %d, %d
407                                 ",
408                                 intval($a->pager['start']),
409                                 intval($a->pager['itemspage'])
410
411                                 );
412                                         
413         function _setup_users($e){
414                 $accounts = Array(
415                         t('Normal Account'), 
416                         t('Soapbox Account'),
417                         t('Community/Celebrity Account'),
418                         t('Automatic Friend Account')
419                 );
420                 $e['page-flags'] = $accounts[$e['page-flags']];
421                 $e['register_date'] = relative_date($e['register_date']);
422                 $e['login_date'] = relative_date($e['login_date']);
423                 $e['lastitem_date'] = relative_date($e['lastitem_date']);
424                 return $e;
425         }
426         $users = array_map("_setup_users", $users);
427         
428         $t = get_markup_template("admin_users.tpl");
429         $o = replace_macros($t, array(
430                 // strings //
431                 '$title' => t('Administration'),
432                 '$page' => t('Users'),
433                 '$submit' => t('Submit'),
434                 '$select_all' => t('select all'),
435                 '$h_pending' => t('User registrations waiting for confirm'),
436                 '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
437                 '$no_pending' =>  t('No registrations.'),
438                 '$approve' => t('Approve'),
439                 '$deny' => t('Deny'),
440                 '$delete' => t('Delete'),
441                 '$block' => t('Block'),
442                 '$unblock' => t('Unblock'),
443                 
444                 '$h_users' => t('Users'),
445                 '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
446
447                 '$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?'),
448                 '$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?'),
449
450
451                 // values //
452                 '$baseurl' => $a->get_baseurl(),
453
454                 '$pending' => $pending,
455                 '$users' => $users,
456         ));
457         $o .= paginate($a);
458         return $o;
459 }
460
461
462 /*
463  * Plugins admin page
464  */
465
466 function admin_page_plugins(&$a){
467         
468         /**
469          * Single plugin
470          */
471         if ($a->argc == 3){
472                 $plugin = $a->argv[2];
473                 if (!is_file("addon/$plugin/$plugin.php")){
474                         notice( t("Item not found.") );
475                         return;
476                 }
477                 
478                 if (x($_GET,"a") && $_GET['a']=="t"){
479                         // Toggle plugin status
480                         $idx = array_search($plugin, $a->plugins);
481                         if ($idx){
482                                 unset($a->plugins[$idx]);
483                                 uninstall_plugin($plugin);
484                         } else {
485                                 $a->plugins[] = $plugin;
486                                 install_plugin($plugin);
487                         }
488                         set_config("system","addon", implode(", ",$a->plugins));
489                         goaway($a->get_baseurl() . '/admin/plugins' );
490                         return; // NOTREACHED   
491                 }
492                 // display plugin details
493                 require_once('library/markdown.php');
494
495                 if (in_array($plugin, $a->plugins)){
496                         $status="on"; $action= t("Disable");
497                 } else {
498                         $status="off"; $action= t("Enable");
499                 }
500                 
501                 $readme=Null;
502                 if (is_file("addon/$plugin/README.md")){
503                         $readme = file_get_contents("addon/$plugin/README.md");
504                         $readme = Markdown($readme);
505                 } else if (is_file("addon/$plugin/README")){
506                         $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
507                 } 
508                 
509                 $t = get_markup_template("admin_plugins_details.tpl");
510                 return replace_macros($t, array(
511                         '$title' => t('Administration'),
512                         '$page' => t('Plugins'),
513                         '$toggle' => t('Toggle'),
514                         '$baseurl' => $a->get_baseurl(),
515                 
516                         '$plugin' => $plugin,
517                         '$status' => $status,
518                         '$action' => $action,
519                         '$info' => get_plugin_info($plugin),
520                         
521                         '$readme' => $readme
522                 ));
523         } 
524          
525          
526         
527         /**
528          * List plugins
529          */
530         
531         $plugins = array();
532         $files = glob("addon/*/");
533         if($files) {
534                 foreach($files as $file) {      
535                         if (is_dir($file)){
536                                 list($tmp, $id)=array_map("trim", explode("/",$file));
537                                 $info = get_plugin_info($id);
538                                 $plugins[] = array( $id, (in_array($id,  $a->plugins)?"on":"off") , $info);
539                         }
540                 }
541         }
542         
543         $t = get_markup_template("admin_plugins.tpl");
544         return replace_macros($t, array(
545                 '$title' => t('Administration'),
546                 '$page' => t('Plugins'),
547                 '$submit' => t('Submit'),
548                 '$baseurl' => $a->get_baseurl(),
549         
550                 '$plugins' => $plugins
551         ));
552 }
553
554
555 /**
556  * Logs admin page
557  */
558  
559 function admin_page_logs_post(&$a) {
560         if (x($_POST,"page_logs")) {
561
562                 $logfile                =       ((x($_POST,'logfile'))          ? notags(trim($_POST['logfile']))       : '');
563                 $debugging              =       ((x($_POST,'debugging'))        ? true                                                          : false);
564                 $loglevel               =       ((x($_POST,'loglevel'))         ? intval(trim($_POST['loglevel']))      : 0);
565
566                 set_config('system','logfile', $logfile);
567                 set_config('system','debugging',  $debugging);
568                 set_config('system','loglevel', $loglevel);
569
570                 
571         }
572
573         goaway($a->get_baseurl() . '/admin/logs' );
574         return; // NOTREACHED   
575 }
576  
577 function admin_page_logs(&$a){
578         
579         $log_choices = Array(
580                 LOGGER_NORMAL => 'Normal',
581                 LOGGER_TRACE => 'Trace',
582                 LOGGER_DEBUG => 'Debug',
583                 LOGGER_DATA => 'Data',
584                 LOGGER_ALL => 'All'
585         );
586         
587         $t = get_markup_template("admin_logs.tpl");
588
589         $f = get_config('system','logfile');
590         $size = filesize($f);
591         if($size > 5000000)
592                 $size = 5000000;
593
594         $data = '';
595         $fp = fopen($f,'r');
596         if($fp) {
597                 $seek = fseek($fp,0-$size,SEEK_END);
598                 if($seek === 0) {
599                         fgets($fp); // throw away the first partial line
600                         $data = str_replace(array("\n","\t"),array('<br />','&nbsp;&nbsp;&nbsp;&nbsp;'),escape_tags(fread($fp,$size)));
601                         while(! feof($fp))
602                                 $data .= str_replace(array("\n","\t"),array('<br />','&nbsp;&nbsp;&nbsp;&nbsp;'),escape_tags(fread($fp,4096)));
603                 }
604                 fclose($fp);
605         }
606
607
608         return replace_macros($t, array(
609                 '$title' => t('Administration'),
610                 '$page' => t('Logs'),
611                 '$submit' => t('Submit'),
612                 '$clear' => t('Clear'),
613                 '$data' => $data,
614                 '$baseurl' => $a->get_baseurl(),
615                 '$logname' =>  get_config('system','logfile'),
616                 
617                                                                         // name, label, value, help string, extra data...
618                 '$debugging'            => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
619                 '$logfile'                      => array('logfile', t("Log file"), get_config('system','logfile'), "Must be writable by web server. Relative to your Friendika index.php."),
620                 '$loglevel'             => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
621         ));
622 }
623