I guess, @Hypolite will still find something to change ...

This commit is contained in:
Michael 2017-03-13 17:23:02 +00:00
parent 0dbc72c4ea
commit eaf93dc041

View file

@ -60,7 +60,9 @@ function admin_post(App $a) {
break;
case 'themes':
if ($a->argc < 2) {
if(is_ajax()) return;
if (is_ajax()) {
return;
}
goaway('admin/');
return;
}
@ -77,7 +79,9 @@ function admin_post(App $a) {
$init = $theme."_init";
if(function_exists($init)) $init($a);
if (function_exists($init)) {
$init($a);
}
if (function_exists("theme_admin_post")) {
$admin_form = theme_admin_post($a);
}
@ -90,8 +94,9 @@ function admin_post(App $a) {
__call_theme_admin_post($a, $theme);
}
info(t('Theme settings updated.'));
if(is_ajax()) return;
if (is_ajax()) {
return;
}
goaway('admin/themes/'.$theme);
return;
break;
@ -317,13 +322,15 @@ function admin_page_federation(App $a) {
$newVC = $vv['total'];
$newVV = $vv['version'];
$posDash = strpos($newVV, '-');
if($posDash)
if ($posDash) {
$newVV = substr($newVV, 0, $posDash);
if(isset($newV[$newVV]))
}
if (isset($newV[$newVV])) {
$newV[$newVV] += $newVC;
else
} else {
$newV[$newVV] = $newVC;
}
}
foreach ($newV as $key => $value) {
array_push($newVv, array('total'=>$value, 'version'=>$key));
}
@ -341,13 +348,15 @@ function admin_page_federation(App $a) {
$newVV = $vv['version'];
$lastDot = strrpos($newVV,'.');
$len = strlen($newVV)-1;
if(($lastDot == $len-4) && (!strrpos($newVV,'-rc')==$len-3))
if (($lastDot == $len-4) && (!strrpos($newVV,'-rc') == $len-3)) {
$newVV = substr($newVV, 0, $lastDot);
if(isset($newV[$newVV]))
}
if (isset($newV[$newVV])) {
$newV[$newVV] += $newVC;
else
} else {
$newV[$newVV] = $newVC;
}
}
foreach ($newV as $key => $value) {
array_push($newVv, array('total'=>$value, 'version'=>$key));
}
@ -455,7 +464,10 @@ function admin_page_summary(App $a) {
);
$users=0;
foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
foreach ($r as $u) {
$accounts[$u['page-flags']][1] = $u['count'];
$users+= $u['count'];
}
logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
@ -670,12 +682,12 @@ function admin_page_site_post(App $a) {
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
if($a->get_path() != "")
if ($a->get_path() != "") {
$diaspora_enabled = false;
if(!$thread_allow)
}
if (!$thread_allow) {
$ostatus_disabled = true;
}
if ($ssl_policy != intval(get_config('system','ssl_policy'))) {
if ($ssl_policy == SSL_POLICY_FULL) {
q("UPDATE `contact` SET
@ -695,8 +707,7 @@ function admin_page_site_post(App $a) {
`thumb` = REPLACE(`thumb` , 'http:' , 'https:')
WHERE 1 "
);
}
elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
} elseif ($ssl_policy == SSL_POLICY_SELFSIGN) {
q("UPDATE `contact` SET
`url` = REPLACE(`url` , 'https:' , 'http:'),
`photo` = REPLACE(`photo` , 'https:' , 'http:'),
@ -819,7 +830,7 @@ function admin_page_site_post(App $a) {
set_config('system','worker_fastlane', $worker_fastlane);
set_config('system','frontend_worker', $worker_frontend);
if($rino==2 and !function_exists('mcrypt_create_iv')) {
if (($rino == 2) and !function_exists('mcrypt_create_iv')) {
notice(t("RINO2 needs mcrypt php extension to work."));
} else {
set_config('system','rino_encrypt', $rino);
@ -924,8 +935,9 @@ function admin_page_site(App $a) {
/* Banner */
$banner = get_config('system','banner');
if($banner == false)
if ($banner == false) {
$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>';
}
$banner = htmlspecialchars($banner);
$info = get_config('config','info');
$info = htmlspecialchars($info);
@ -950,9 +962,9 @@ function admin_page_site(App $a) {
SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
);
if($a->config['hostname'] == "")
if ($a->config['hostname'] == "") {
$a->config['hostname'] = $a->get_hostname();
}
$diaspora_able = ($a->get_path() == "");
$optimize_max_tablesize = Config::get('system','optimize_max_tablesize', 100);
@ -1094,8 +1106,9 @@ function admin_page_dbsync(App $a) {
if ($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
set_config('database', 'update_'.intval($a->argv[3]), 'success');
$curr = get_config('system','build');
if(intval($curr) == intval($a->argv[3]))
if (intval($curr) == intval($a->argv[3])) {
set_config('system','build',intval($curr) + 1);
}
info(t('Update has been marked successful').EOL);
goaway('admin/dbsync');
}
@ -1106,12 +1119,14 @@ function admin_page_dbsync(App $a) {
if (!$retval) {
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION)."<br />";
set_config('database', 'dbupdate_'.DB_UPDATE_VERSION, 'success');
} else
} else {
$o .= sprintf(t("Executing of database structure update %s failed with error: %s"),
DB_UPDATE_VERSION, $retval)."<br />";
if($a->argv[2] === 'check')
}
if ($a->argv[2] === 'check') {
return $o;
}
}
if ($a->argc > 2 && intval($a->argv[2])) {
require_once('update.php');
@ -1124,9 +1139,9 @@ function admin_page_dbsync(App $a) {
elseif ($retval === UPDATE_SUCCESS) {
$o .= sprintf(t('Update %s was successfully applied.', $func));
set_config('database',$func, 'success');
}
else
} else {
$o .= sprintf(t('Update %s did not return a status. Unknown if it succeeded.'), $func);
}
} else {
$o .= sprintf(t('There was no additional update function %s that needed to be called.'), $func)."<br />";
set_config('database',$func, 'success');
@ -1139,8 +1154,9 @@ function admin_page_dbsync(App $a) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$upd = intval(substr($rr['k'],7));
if($upd < 1139 || $rr['v'] === 'success')
if ($upd < 1139 || $rr['v'] === 'success') {
continue;
}
$failed[] = $upd;
}
}
@ -1285,22 +1301,22 @@ function admin_page_users(App $a) {
return ''; // NOTREACHED
}
switch($a->argv[2]) {
case "delete":{
case "delete":
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
// delete user
require_once("include/Contact.php");
user_remove($uid);
notice(sprintf(t("User '%s' deleted"), $user[0]['username']).EOL);
}; break;
case "block":{
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)
);
notice(sprintf(($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']).EOL);
}; break;
break;
}
goaway('admin/users');
return ''; // NOTREACHED
@ -1396,8 +1412,7 @@ function admin_page_users(App $a) {
}
if ($new_user['deleted']) {
array_push($deleted, $new_user);
}
else {
} else {
array_push($tmp_users, $new_user);
}
}
@ -1658,8 +1673,9 @@ function rebuild_theme_table($themes) {
if (count($themes)) {
foreach ($themes as $th) {
if ($th['allowed']) {
if(strlen($o))
if (strlen($o)) {
$o .= ',';
}
$o .= $th['name'];
}
}
@ -1689,10 +1705,13 @@ function admin_page_themes(App $a) {
$allowed_themes_str = get_config('system','allowed_themes');
$allowed_themes_raw = explode(',',$allowed_themes_str);
$allowed_themes = array();
if(count($allowed_themes_raw))
foreach($allowed_themes_raw as $x)
if(strlen(trim($x)))
if (count($allowed_themes_raw)) {
foreach ($allowed_themes_raw as $x) {
if (strlen(trim($x))) {
$allowed_themes[] = trim($x);
}
}
}
$themes = array();
$files = glob('view/theme/*');
@ -1712,10 +1731,11 @@ function admin_page_themes(App $a) {
$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"))
if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) {
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
}
}
}
if (! count($themes)) {
notice(t('No themes found.'));
@ -1743,8 +1763,7 @@ function admin_page_themes(App $a) {
if ($result) {
install_theme($theme);
info(sprintf('Theme %s enabled.',$theme));
}
else {
} else {
uninstall_theme($theme);
info(sprintf('Theme %s disabled.',$theme));
}
@ -1783,7 +1802,9 @@ function admin_page_themes(App $a) {
$init = $theme."_init";
if(function_exists($init)) $init($a);
if (function_exists($init)) {
$init($a);
}
if (function_exists("theme_admin")) {
$admin_form = theme_admin($a);
}
@ -1797,9 +1818,9 @@ function admin_page_themes(App $a) {
}
$screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
if(! stristr($screenshot[0],$theme))
if (! stristr($screenshot[0],$theme)) {
$screenshot = null;
}
$t = get_markup_template("admin_plugins_details.tpl");
return replace_macros($t, array(
@ -1972,25 +1993,25 @@ function admin_page_viewlogs(App $a) {
if (!file_exists($f)) {
$data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is readable.");
}
else {
} else {
$fp = fopen($f, 'r');
if (!$fp) {
$data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
}
else {
} else {
$fstat = fstat($fp);
$size = $fstat['size'];
if ($size != 0) {
if($size > 5000000 || $size < 0)
if ($size > 5000000 || $size < 0) {
$size = 5000000;
}
$seek = fseek($fp,0-$size,SEEK_END);
if ($seek === 0) {
$data = escape_tags(fread($fp,$size));
while(! feof($fp))
while (! feof($fp)) {
$data .= escape_tags(fread($fp,4096));
}
}
}
fclose($fp);
}
}
@ -2022,18 +2043,20 @@ function admin_page_features_post(App $a) {
$feature_state = 'feature_'.$feature;
$featurelock = 'featurelock_'.$feature;
if(x($_POST[$feature_state]))
if (x($_POST[$feature_state])) {
$val = intval($_POST['feature_'.$feature]);
else
} else {
$val = 0;
}
set_config('feature',$feature,$val);
if(x($_POST[$featurelock]))
if (x($_POST[$featurelock])) {
set_config('feature_lock',$feature,$val);
else
} else {
del_config('feature_lock',$feature);
}
}
}
goaway('admin/features');
return; // NOTREACHED
@ -2065,8 +2088,9 @@ function admin_page_features(App $a) {
foreach (array_slice($fdata,1) as $f) {
$set = get_config('feature',$f[0]);
if($set === false)
if ($set === false) {
$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')))