X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fadmin.php;h=ecd08bbe00743b546f869a75d64f355cc2725f69;hb=08a780211211c79053a710866fa2057f648a6d51;hp=ff17c0b8c44b510f294f9e2322ea1cf68a13149a;hpb=9330a6994c1b9aee49a482efe32e84ca1a944c9b;p=friendica.git diff --git a/mod/admin.php b/mod/admin.php index ff17c0b8c4..ecd08bbe00 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -2,7 +2,7 @@ /** * @file mod/admin.php - * + * * @brief Friendica admin */ @@ -23,7 +23,6 @@ require_once("include/text.php"); * @param App $a * */ -if(! function_exists('admin_post')) { function admin_post(&$a){ @@ -56,13 +55,13 @@ function admin_post(&$a){ $func($a); } } - goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] ); + goaway('admin/plugins/'.$a->argv[2]); return; // NOTREACHED break; case 'themes': if($a->argc < 2) { if(is_ajax()) return; - goaway($a->get_baseurl(true) . '/admin/' ); + goaway('admin/'); return; } @@ -93,7 +92,7 @@ function admin_post(&$a){ info(t('Theme settings updated.')); if(is_ajax()) return; - goaway($a->get_baseurl(true) . '/admin/themes/' . $theme ); + goaway('admin/themes/'.$theme); return; break; case 'features': @@ -108,10 +107,9 @@ function admin_post(&$a){ } } - goaway($a->get_baseurl(true) . '/admin' ); + goaway('admin'); return; // NOTREACHED } -} /** * @brief Generates content of the admin panel pages @@ -130,7 +128,6 @@ function admin_post(&$a){ * @param App $a * @return string */ -if(! function_exists('admin_content')) { function admin_content(&$a) { if(!is_site_admin()) { @@ -153,17 +150,17 @@ function admin_content(&$a) { * Side bar links */ $aside_tools = array(); - // array( url, name, extra css classes ) + // array(url, name, extra css classes) // not part of $aside to make the template more adjustable $aside_sub = array( - 'site' => array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"), - 'users' => array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"), - 'plugins'=> array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), - 'themes' => array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), - 'features' => array($a->get_baseurl(true)."/admin/features/", t("Additional features") , "features"), - 'dbsync' => array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"), - 'queue' => array($a->get_baseurl(true)."/admin/queue/", t('Inspect Queue'), "queue"), - 'federation' => array($a->get_baseurl(true)."/admin/federation/", t('Federation Statistics'), "federation"), + 'site' => array("admin/site/", t("Site") , "site"), + 'users' => array("admin/users/", t("Users") , "users"), + 'plugins'=> array("admin/plugins/", t("Plugins") , "plugins"), + 'themes' => array("admin/themes/", t("Themes") , "themes"), + 'features' => array("admin/features/", t("Additional features") , "features"), + 'dbsync' => array("admin/dbsync/", t('DB updates'), "dbsync"), + 'queue' => array("admin/queue/", t('Inspect Queue'), "queue"), + 'federation' => array("admin/federation/", t('Federation Statistics'), "federation"), ); /* get plugins admin page */ @@ -172,18 +169,18 @@ function admin_content(&$a) { $aside_tools['plugins_admin']=array(); foreach ($r as $h){ $plugin =$h['name']; - $aside_tools['plugins_admin'][] = array($a->get_baseurl(true)."/admin/plugins/".$plugin, $plugin, "plugin"); + $aside_tools['plugins_admin'][] = array("admin/plugins/".$plugin, $plugin, "plugin"); // temp plugins with admin $a->plugins_admin[] = $plugin; } - $aside_tools['logs'] = array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs"); - $aside_tools['viewlogs'] = array($a->get_baseurl(true)."/admin/viewlogs/", t("View Logs"), 'viewlogs'); - $aside_tools['diagnostics_probe'] = array($a->get_baseurl(true).'/probe/', t('probe address'), 'probe'); - $aside_tools['diagnostics_webfinger'] = array($a->get_baseurl(true).'/webfinger/', t('check webfinger'), 'webfinger'); + $aside_tools['logs'] = array("admin/logs/", t("Logs"), "logs"); + $aside_tools['viewlogs'] = array("admin/viewlogs/", t("View Logs"), 'viewlogs'); + $aside_tools['diagnostics_probe'] = array('probe/', t('probe address'), 'probe'); + $aside_tools['diagnostics_webfinger'] = array('webfinger/', t('check webfinger'), 'webfinger'); $t = get_markup_template("admin_aside.tpl"); - $a->page['aside'] .= replace_macros( $t, array( + $a->page['aside'] .= replace_macros($t, array( '$admin' => $aside_tools, '$subpages' => $aside_sub, '$admtxt' => t('Admin'), @@ -191,7 +188,7 @@ function admin_content(&$a) { '$logtxt' => t('Logs'), '$diagnosticstxt' => t('diagnostics'), '$h_pending' => t('User registrations waiting for confirmation'), - '$admurl'=> $a->get_baseurl(true)."/admin/" + '$admurl'=> "admin/" )); @@ -234,7 +231,7 @@ function admin_content(&$a) { $o = admin_page_federation($a); break; default: - notice( t("Item not found.") ); + notice(t("Item not found.")); } } else { $o = admin_page_summary($a); @@ -248,7 +245,6 @@ function admin_content(&$a) { return $o; } } -} /** * @brief Subpage with some stats about "the federation" network @@ -264,7 +260,6 @@ function admin_content(&$a) { * @param App $a * @return string */ -if(! function_exists('admin_page_federation')) { function admin_page_federation(&$a) { // get counts on active friendica, diaspora, redmatrix, hubzilla, gnu // social and statusnet nodes this node is knowing @@ -289,7 +284,7 @@ function admin_page_federation(&$a) { // what versions for that platform do we know at all? // again only the active nodes $v = q('SELECT count(*) AS total, version FROM gserver - WHERE last_contact > last_failure AND platform LIKE "%s" + WHERE last_contact > last_failure AND platform LIKE "%s" GROUP BY version ORDER BY version;', $p); @@ -306,12 +301,12 @@ function admin_page_federation(&$a) { $newVC = $vv['total']; $newVV = $vv['version']; $posDash = strpos($newVV, '-'); - if($posDash) + if($posDash) $newVV = substr($newVV, 0, $posDash); if(isset($newV[$newVV])) - $newV[$newVV] += $newVC; + $newV[$newVV] += $newVC; else - $newV[$newVV] = $newVC; + $newV[$newVV] = $newVC; } foreach ($newV as $key => $value) { array_push($newVv, array('total'=>$value, 'version'=>$key)); @@ -366,7 +361,6 @@ function admin_page_federation(&$a) { '$baseurl' => $a->get_baseurl(), )); } -} /** * @brief Admin Inspect Queue Page @@ -381,7 +375,6 @@ function admin_page_federation(&$a) { * @param App $a * @return string */ -if(! function_exists('admin_page_queue')) { function admin_page_queue(&$a) { // get content from the queue table $r = q("SELECT c.name,c.nurl,q.id,q.network,q.created,q.last from queue as q, contact as c where c.id=q.cid order by q.cid, q.created;"); @@ -401,7 +394,6 @@ function admin_page_queue(&$a) { '$entries' => $r, )); } -} /** * @brief Admin Summary Page @@ -414,22 +406,21 @@ function admin_page_queue(&$a) { * @param App $a * @return string */ -if(! function_exists('admin_page_summary')) { function admin_page_summary(&$a) { $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`"); $accounts = array( - array( t('Normal Account'), 0), - array( t('Soapbox Account'), 0), - array( t('Community/Celebrity Account'), 0), - array( t('Automatic Friend Account'), 0), - array( t('Blog Account'), 0), - array( t('Private Forum'), 0) + array(t('Normal Account'), 0), + array(t('Soapbox Account'), 0), + array(t('Community/Celebrity Account'), 0), + array(t('Automatic Friend Account'), 0), + array(t('Blog Account'), 0), + array(t('Private Forum'), 0) ); $users=0; foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; } - logger('accounts: ' . print_r($accounts,true),LOGGER_DATA); + logger('accounts: '.print_r($accounts,true),LOGGER_DATA); $r = q("SELECT COUNT(id) as `count` FROM `register`"); $pending = $r[0]['count']; @@ -442,7 +433,7 @@ function admin_page_summary(&$a) { // We can do better, but this is a quick queue status - $queues = array( 'label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue ); + $queues = array('label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue); $t = get_markup_template("admin_summary.tpl"); @@ -450,25 +441,23 @@ function admin_page_summary(&$a) { '$title' => t('Administration'), '$page' => t('Summary'), '$queues' => $queues, - '$users' => array( t('Registered users'), $users), + '$users' => array(t('Registered users'), $users), '$accounts' => $accounts, - '$pending' => array( t('Pending registrations'), $pending), - '$version' => array( t('Version'), FRIENDICA_VERSION), + '$pending' => array(t('Pending registrations'), $pending), + '$version' => array(t('Version'), FRIENDICA_VERSION), '$baseurl' => $a->get_baseurl(), '$platform' => FRIENDICA_PLATFORM, '$codename' => FRIENDICA_CODENAME, '$build' => get_config('system','build'), - '$plugins' => array( t('Active plugins'), $a->plugins ) + '$plugins' => array(t('Active plugins'), $a->plugins) )); } -} /** * @brief Process send data from Admin Site Page - * + * * @param App $a */ -if(! function_exists('admin_page_site_post')) { function admin_page_site_post(&$a) { if(!x($_POST,"page_site")) { return; @@ -484,7 +473,7 @@ function admin_page_site_post(&$a) { $parsed = @parse_url($new_url); if(!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) { notice(t("Can not parse base url. Must have at least ://")); - goaway($a->get_baseurl(true) . '/admin/site' ); + goaway('admin/site'); } /* steps: @@ -512,8 +501,8 @@ function admin_page_site_post(&$a) { $q = sprintf("UPDATE %s SET %s;", $table_name, $upds); $r = q($q); if(!$r) { - notice( "Failed updating '$table_name': " . $db->error ); - goaway($a->get_baseurl(true) . '/admin/site' ); + notice("Failed updating '$table_name': ".$db->error); + goaway('admin/site'); } } @@ -537,7 +526,7 @@ function admin_page_site_post(&$a) { info("Relocation started. Could take a while to complete."); - goaway($a->get_baseurl(true) . '/admin/site' ); + goaway('admin/site'); } // end relocate @@ -706,12 +695,12 @@ function admin_page_site_post(&$a) { set_config('system','language', $language); set_config('system','theme', $theme); - if( $theme_mobile === '---' ) { + if($theme_mobile === '---') { del_config('system','mobile-theme'); } else { set_config('system','mobile-theme', $theme_mobile); } - if( $singleuser === '---' ) { + if($singleuser === '---') { del_config('system','singleuser'); } else { set_config('system','singleuser', $singleuser); @@ -776,12 +765,11 @@ function admin_page_site_post(&$a) { set_config('system','embedly', $embedly); - info( t('Site settings updated.') . EOL); - goaway($a->get_baseurl(true) . '/admin/site' ); + info(t('Site settings updated.').EOL); + goaway('admin/site'); return; // NOTREACHED } -} /** * @brief Generate Admin Site subpage @@ -791,7 +779,6 @@ function admin_page_site_post(&$a) { * @param App $a * @return string */ -if(! function_exists('admin_page_site')) { function admin_page_site(&$a) { /* Installed langs */ @@ -810,12 +797,12 @@ function admin_page_site(&$a) { $files = glob('view/theme/*'); if($files) { foreach($files as $file) { - if(intval(file_exists($file . '/unsupported'))) + if(intval(file_exists($file.'/unsupported'))) continue; $f = basename($file); - $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f); - if(file_exists($file . '/mobile')) { + $theme_name = ((file_exists($file.'/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f); + if(file_exists($file.'/mobile')) { $theme_choices_mobile[$f] = $theme_name; } else { $theme_choices[$f] = $theme_name; @@ -996,7 +983,7 @@ function admin_page_site(&$a) { '$form_security_token' => get_form_security_token("admin_site") )); -} + } /** @@ -1011,18 +998,17 @@ function admin_page_site(&$a) { * @param App $a * @return string **/ -if(! function_exists('admin_page_dbsync')) { function admin_page_dbsync(&$a) { $o = ''; if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') { - set_config('database', 'update_' . intval($a->argv[3]), 'success'); + set_config('database', 'update_'.intval($a->argv[3]), 'success'); $curr = get_config('system','build'); if(intval($curr) == intval($a->argv[3])) set_config('system','build',intval($curr) + 1); - info( t('Update has been marked successful') . EOL); - goaway($a->get_baseurl(true) . '/admin/dbsync'); + info(t('Update has been marked successful').EOL); + goaway('admin/dbsync'); } if(($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) { @@ -1040,7 +1026,7 @@ function admin_page_dbsync(&$a) { if($a->argc > 2 && intval($a->argv[2])) { require_once('update.php'); - $func = 'update_' . intval($a->argv[2]); + $func = 'update_'.intval($a->argv[2]); if(function_exists($func)) { $retval = $func(); if($retval === UPDATE_FAILED) { @@ -1087,28 +1073,27 @@ function admin_page_dbsync(&$a) { } return $o; -} + } /** * @brief Process data send by Users admin page - * + * * @param App $a */ -if(! function_exists('admin_page_users_post')) { function admin_page_users_post(&$a){ - $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); - $users = ( x($_POST, 'user') ? $_POST['user'] : array() ); - $nu_name = ( x($_POST, 'new_user_name') ? $_POST['new_user_name'] : ''); - $nu_nickname = ( x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : ''); - $nu_email = ( x($_POST, 'new_user_email') ? $_POST['new_user_email'] : ''); + $pending = (x($_POST, 'pending') ? $_POST['pending'] : array()); + $users = (x($_POST, 'user') ? $_POST['user'] : array()); + $nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : ''); + $nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : ''); + $nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : ''); check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); if(!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) { require_once('include/user.php'); - $result = create_user( array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1) ); + $result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1)); if(! $result['success']) { notice($result['message']); return; @@ -1149,7 +1134,7 @@ function admin_page_users_post(&$a){ notification(array( 'type' => "SYSTEM_EMAIL", 'to_email' => $nu['email'], - 'subject'=> sprintf( t('Registration details for %s'), $a->config['sitename']), + 'subject'=> sprintf(t('Registration details for %s'), $a->config['sitename']), 'preamble'=> $preamble, 'body' => $body)); @@ -1158,17 +1143,17 @@ function admin_page_users_post(&$a){ if(x($_POST,'page_users_block')) { foreach($users as $uid){ q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s", - intval( $uid ) + intval($uid) ); } - notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) ); + notice(sprintf(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users))); } if(x($_POST,'page_users_delete')) { require_once("include/Contact.php"); foreach($users as $uid){ user_remove($uid); } - notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) ); + notice(sprintf(tt("%s user deleted", "%s users deleted", count($users)), count($users))); } if(x($_POST,'page_users_approve')) { @@ -1183,10 +1168,9 @@ function admin_page_users_post(&$a){ user_deny($hash); } } - goaway($a->get_baseurl(true) . '/admin/users' ); + goaway('admin/users'); return; // NOTREACHED } -} /** * @brief Admin panel subpage for User management @@ -1200,14 +1184,13 @@ function admin_page_users_post(&$a){ * @param App $a * @return string */ -if(! function_exists('admin_page_users')) { function admin_page_users(&$a){ if($a->argc>2) { $uid = $a->argv[3]; $user = q("SELECT username, blocked FROM `user` WHERE `uid`=%d", intval($uid)); if(count($user)==0) { - notice( 'User not found' . EOL); - goaway($a->get_baseurl(true) . '/admin/users' ); + notice('User not found'.EOL); + goaway('admin/users'); return ''; // NOTREACHED } switch($a->argv[2]){ @@ -1217,18 +1200,18 @@ function admin_page_users(&$a){ require_once("include/Contact.php"); user_remove($uid); - notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL); + notice(sprintf(t("User '%s' deleted"), $user[0]['username']).EOL); }; break; case "block":{ check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s", - intval( 1-$user[0]['blocked'] ), - intval( $uid ) + intval(1-$user[0]['blocked']), + intval($uid) ); - notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL); + notice(sprintf(($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']).EOL); }; break; } - goaway($a->get_baseurl(true) . '/admin/users' ); + goaway('admin/users'); return ''; // NOTREACHED } @@ -1247,7 +1230,7 @@ function admin_page_users(&$a){ $a->set_pager_itemspage(100); } - $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired` + $users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired` FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid` FROM `item` @@ -1294,7 +1277,7 @@ function admin_page_users(&$a){ while(count($users)) { $new_user = array(); - foreach( array_pop($users) as $k => $v) { + foreach(array_pop($users) as $k => $v) { $k = str_replace('-','_',$k); $new_user[$k] = $v; } @@ -1320,7 +1303,7 @@ function admin_page_users(&$a){ '$select_all' => t('select all'), '$h_pending' => t('User registrations waiting for confirm'), '$h_deleted' => t('User waiting for permanent deletion'), - '$th_pending' => array( t('Request date'), t('Name'), t('Email') ), + '$th_pending' => array(t('Request date'), t('Name'), t('Email')), '$no_pending' => t('No registrations.'), '$approve' => t('Approve'), '$deny' => t('Deny'), @@ -1332,8 +1315,8 @@ function admin_page_users(&$a){ '$h_users' => t('Users'), '$h_newuser' => t('New User'), - '$th_deleted' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since') ), - '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ), + '$th_deleted' => array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since')), + '$th_users' => array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account')), '$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?'), '$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?'), @@ -1353,7 +1336,7 @@ function admin_page_users(&$a){ $o .= paginate($a); return $o; } -} + /** * @brief Plugins admin page @@ -1371,7 +1354,6 @@ function admin_page_users(&$a){ * @param App $a * @return string */ -if(! function_exists('admin_page_plugins')) { function admin_page_plugins(&$a){ /* @@ -1380,7 +1362,7 @@ function admin_page_plugins(&$a){ if($a->argc == 3) { $plugin = $a->argv[2]; if(!is_file("addon/$plugin/$plugin.php")) { - notice( t("Item not found.") ); + notice(t("Item not found.")); return ''; } @@ -1392,14 +1374,14 @@ function admin_page_plugins(&$a){ if($idx !== false) { unset($a->plugins[$idx]); uninstall_plugin($plugin); - info( sprintf( t("Plugin %s disabled."), $plugin ) ); + info(sprintf(t("Plugin %s disabled."), $plugin)); } else { $a->plugins[] = $plugin; install_plugin($plugin); - info( sprintf( t("Plugin %s enabled."), $plugin ) ); + info(sprintf(t("Plugin %s enabled."), $plugin)); } set_config("system","addon", implode(", ",$a->plugins)); - goaway($a->get_baseurl(true) . '/admin/plugins' ); + goaway('admin/plugins'); return ''; // NOTREACHED } @@ -1497,19 +1479,17 @@ function admin_page_plugins(&$a){ '$baseurl' => $a->get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, - '$pcount' => count($plugins), - '$noplugshint' => sprintf( t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s'), 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'), + '$pcount' => count($plugins), + '$noplugshint' => sprintf(t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s'), 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'), '$form_security_token' => get_form_security_token("admin_themes"), )); } -} /** * @param array $themes * @param string $th * @param int $result */ -if(! function_exists('toggle_theme')) { function toggle_theme(&$themes,$th,&$result) { for($x = 0; $x < count($themes); $x ++) { if($themes[$x]['name'] === $th) { @@ -1524,14 +1504,12 @@ function toggle_theme(&$themes,$th,&$result) { } } } -} /** * @param array $themes * @param string $th * @return int */ -if(! function_exists('theme_status')) { function theme_status($themes,$th) { for($x = 0; $x < count($themes); $x ++) { if($themes[$x]['name'] === $th) { @@ -1545,13 +1523,12 @@ function theme_status($themes,$th) { } return 0; } -} + /** * @param array $themes * @return string */ -if(! function_exists('rebuild_theme_table')) { function rebuild_theme_table($themes) { $o = ''; if(count($themes)) { @@ -1565,7 +1542,7 @@ function rebuild_theme_table($themes) { } return $o; } -} + /** * @brief Themes admin page @@ -1583,7 +1560,6 @@ function rebuild_theme_table($themes) { * @param App $a * @return string */ -if(! function_exists('admin_page_themes')) { function admin_page_themes(&$a){ $allowed_themes_str = get_config('system','allowed_themes'); @@ -1599,8 +1575,8 @@ function admin_page_themes(&$a){ if($files) { foreach($files as $file) { $f = basename($file); - $is_experimental = intval(file_exists($file . '/experimental')); - $is_supported = 1-(intval(file_exists($file . '/unsupported'))); + $is_experimental = intval(file_exists($file.'/experimental')); + $is_supported = 1-(intval(file_exists($file.'/unsupported'))); $is_allowed = intval(in_array($f,$allowed_themes)); if($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) @@ -1609,7 +1585,7 @@ function admin_page_themes(&$a){ } if(! count($themes)) { - notice( t('No themes found.')); + notice(t('No themes found.')); return ''; } @@ -1620,7 +1596,7 @@ function admin_page_themes(&$a){ if($a->argc == 3) { $theme = $a->argv[2]; if(! is_dir("view/theme/$theme")) { - notice( t("Item not found.") ); + notice(t("Item not found.")); return ''; } @@ -1633,15 +1609,15 @@ function admin_page_themes(&$a){ $s = rebuild_theme_table($themes); if($result) { install_theme($theme); - info( sprintf('Theme %s enabled.',$theme)); + info(sprintf('Theme %s enabled.',$theme)); } else { uninstall_theme($theme); - info( sprintf('Theme %s disabled.',$theme)); + info(sprintf('Theme %s disabled.',$theme)); } set_config('system','allowed_themes',$s); - goaway($a->get_baseurl(true) . '/admin/themes' ); + goaway('admin/themes'); return ''; // NOTREACHED } @@ -1687,7 +1663,7 @@ function admin_page_themes(&$a){ $admin_form = __get_theme_admin_form($a, $theme); } - $screenshot = array( get_theme_screenshot($theme), t('Screenshot')); + $screenshot = array(get_theme_screenshot($theme), t('Screenshot')); if(! stristr($screenshot[0],$theme)) $screenshot = null; @@ -1758,14 +1734,13 @@ function admin_page_themes(&$a){ '$form_security_token' => get_form_security_token("admin_themes"), )); } -} + /** * @brief Prosesses data send by Logs admin page - * + * * @param App $a */ -if(! function_exists('admin_page_logs_post')) { function admin_page_logs_post(&$a) { if(x($_POST,"page_logs")) { check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs'); @@ -1779,11 +1754,10 @@ function admin_page_logs_post(&$a) { set_config('system','loglevel', $loglevel); } - info( t("Log settings updated.") ); - goaway($a->get_baseurl(true) . '/admin/logs' ); + info(t("Log settings updated.")); + goaway('admin/logs'); return; // NOTREACHED } -} /** * @brief Generates admin panel subpage for configuration of the logs @@ -1801,7 +1775,6 @@ function admin_page_logs_post(&$a) { * @param App $a * @return string */ -if(! function_exists('admin_page_logs')) { function admin_page_logs(&$a){ $log_choices = array( @@ -1830,10 +1803,9 @@ function admin_page_logs(&$a){ '$form_security_token' => get_form_security_token("admin_logs"), '$phpheader' => t("PHP logging"), '$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."), - '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE );\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');", + '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');", )); } -} /** * @brief Generates admin panel subpage to view the Friendica log @@ -1853,7 +1825,6 @@ function admin_page_logs(&$a){ * @param App $a * @return string */ -if(! function_exists('admin_page_viewlogs')) { function admin_page_viewlogs(&$a){ $t = get_markup_template("admin_viewlogs.tpl"); $f = get_config('system','logfile'); @@ -1890,19 +1861,17 @@ function admin_page_viewlogs(&$a){ '$logname' => get_config('system','logfile') )); } -} /** * @brief Prosesses data send by the features admin page - * + * * @param App $a */ -if(! function_exists('admin_page_features_post')) { function admin_page_features_post(&$a) { check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features'); - logger('postvars: ' . print_r($_POST,true),LOGGER_DATA); + logger('postvars: '.print_r($_POST,true),LOGGER_DATA); $arr = array(); $features = get_features(false); @@ -1910,11 +1879,11 @@ function admin_page_features_post(&$a) { foreach($features as $fname => $fdata) { foreach(array_slice($fdata,1) as $f) { $feature = $f[0]; - $feature_state = 'feature_' . $feature; - $featurelock = 'featurelock_' . $feature; + $feature_state = 'feature_'.$feature; + $featurelock = 'featurelock_'.$feature; if(x($_POST[$feature_state])) - $val = intval($_POST['feature_' . $feature]); + $val = intval($_POST['feature_'.$feature]); else $val = 0; set_config('feature',$feature,$val); @@ -1926,28 +1895,26 @@ function admin_page_features_post(&$a) { } } - goaway($a->get_baseurl(true) . '/admin/features' ); + goaway('admin/features'); return; // NOTREACHED } -} /** * @brief Subpage for global additional feature management - * + * * This functin generates the subpage 'Manage Additional Features' * for the admin panel. At this page the admin can set preferences - * for the user settings of the 'additional features'. If needed this + * for the user settings of the 'additional features'. If needed this * preferences can be locked through the admin. - * + * * The returned string contains the HTML code of the subpage 'Manage * Additional Features' - * + * * @param App $a * @return string */ -if(! function_exists('admin_page_features')) { function admin_page_features(&$a) { - + if((argc() > 1) && (argv(1) === 'features')) { $arr = array(); $features = get_features(false); @@ -1962,11 +1929,11 @@ function admin_page_features(&$a) { $set = $f[3]; $arr[$fname][1][] = array( array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))), - array('featurelock_' .$f[0],sprintf( t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'),t('On'))) + array('featurelock_' .$f[0],sprintf(t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'),t('On'))) ); } } - + $tpl = get_markup_template("admin_settings_features.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("admin_manage_features"), @@ -1978,4 +1945,3 @@ function admin_page_features(&$a) { return $o; } } -}