Instalator fixes and lots and lots of other bugfixes

This commit is contained in:
Vojtěch Sajdl
2018-01-12 21:35:31 +01:00
parent e19fd0d3c2
commit c25e8bcae8
16 changed files with 434 additions and 170 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ class Constellation
{
if ($offset)
{
echo '<noscript><div class="centered"><a href="?offset='.($offset-$limit+1).'&timestamp='.$timestamp.'" class="btn btn-default">'._("Back").'</a></div></noscript>';
echo '<noscript><div class="centered"><a href="'.WEB_URL.'/?offset='.($offset-$limit+1).'&timestamp='.$timestamp.'" class="btn btn-default">'._("Back").'</a></div></noscript>';
}
echo "<h3>"._("Past incidents")."</h3>";
}
@@ -59,7 +59,7 @@ class Constellation
}
if ($show)
{
echo '<div class="centered"><a href="?offset='.($offset).'&timestamp='.$timestamp.'" id="loadmore" class="btn btn-default">'._("Load more").'</a></div>';
echo '<div class="centered"><a href="'.WEB_URL.'/?offset='.($offset).'&timestamp='.$timestamp.'" id="loadmore" class="btn btn-default">'._("Load more").'</a></div>';
}
}
}
+4 -4
View File
@@ -49,7 +49,7 @@ class Incident
$stmt->bind_param("i", $id);
$stmt->execute();
$query = $stmt->get_result();
header("Location: /admin");
header("Location: ".WEB_URL."/admin");
}
/**
@@ -132,7 +132,7 @@ class Incident
$stmt->execute();
$query = $stmt->get_result();
}
header("Location: /admin");
header("Location: ".WEB_URL."/admin");
}
}
@@ -154,7 +154,7 @@ class Incident
<div class="panel-heading clearfix">
<h2 class="panel-title"><?php echo $this->title; ?></h2>
<?php if ($admin){
echo '<a href="?delete='.$this->id.'" class="pull-right delete"><i class="fa fa-trash"></i></a>';
echo '<a href="'.WEB_URL.'/?delete='.$this->id.'" class="pull-right delete"><i class="fa fa-trash"></i></a>';
}?>
<time class="pull-right timeago" datetime="<?php echo $this->date; ?>"><?php echo $this->date; ?></time>
</div>
@@ -165,7 +165,7 @@ class Incident
<small><?php echo _("Posted by");?>: <?php echo $this->username;
if (isset($this->end_date)){?>
<span class="pull-right"><?php echo strtotime($this->end_date)>time()?_("Ending"):_("Ended");?>:&nbsp;<time class="pull-right timeago" datetime="<?php echo $this->end_date; ?>"><?php echo $this->end_date; ?></time></span>
<?}?>
<?php } ?>
</small>
</div>
</article>
+213 -11
View File
@@ -7,6 +7,218 @@ class LocaleNegotiator
{
private $accepted_langs = [];
private $default_language;
private $all_locales = array(
'af_ZA' => 'Afrikaans',
'am_ET' => 'አማርኛ',
'ar_AE' => 'العربية',
'ar_BH' => 'العربية',
'ar_DZ' => 'العربية',
'ar_EG' => 'العربية',
'ar_IQ' => 'العربية',
'ar_JO' => 'العربية',
'ar_KW' => 'العربية',
'ar_LB' => 'العربية',
'ar_LY' => 'العربية',
'ar_MA' => 'العربية',
'arn_CL' => 'Mapuche',
'ar_OM' => 'العربية',
'ar_QA' => 'العربية',
'ar_SA' => 'العربية',
'ar_SY' => 'العربية',
'ar_TN' => 'العربية',
'ar_YE' => 'العربية',
'as_IN' => 'অসমীয়া',
'az_Cyrl_AZ' => 'Азәрбајҹан',
'az_Latn_AZ' => 'Azərbaycan',
'ba_RU' => 'Bashkir',
'be_BY' => 'Беларуская',
'bg_BG' => 'Български',
'bn_BD' => 'বাংলা',
'bn_IN' => 'বাংলা',
'bo_CN' => 'བོད་སྐད་',
'br_FR' => 'Brezhoneg',
'bs_Cyrl_BA' => 'Босански',
'bs_Latn_BA' => 'Bosanski',
'ca_ES' => 'Català',
'co_FR' => 'Corsican',
'cs_CZ' => 'Čeština',
'cy_GB' => 'Cymraeg',
'da_DK' => 'Dansk',
'de_AT' => 'Deutsch',
'de_CH' => 'Deutsch',
'de_DE' => 'Deutsch',
'de_LI' => 'Deutsch',
'de_LU' => 'Deutsch',
'dsb_DE' => 'Dolnoserbšćina',
'dv_MV' => 'Divehi',
'el_GR' => 'Ελληνικά',
'en_029' => 'English',
'en_AU' => 'English',
'en_BZ' => 'English',
'en_CA' => 'English',
'en_GB' => 'English',
'en_IE' => 'English',
'en_IN' => 'English',
'en_JM' => 'English',
'en_MY' => 'English',
'en_NZ' => 'English',
'en_PH' => 'English',
'en_SG' => 'English',
'en_TT' => 'English',
'en_US' => 'English',
'en_ZA' => 'English',
'en_ZW' => 'English',
'es_AR' => 'Español',
'es_BO' => 'Español',
'es_CL' => 'Español',
'es_CO' => 'Español',
'es_CR' => 'Español',
'es_DO' => 'Español',
'es_EC' => 'Español',
'es_ES' => 'Español',
'es_GT' => 'Español',
'es_HN' => 'Español',
'es_MX' => 'Español',
'es_NI' => 'Español',
'es_PA' => 'Español',
'es_PE' => 'Español',
'es_PR' => 'Español',
'es_PY' => 'Español',
'es_SV' => 'Español',
'es_US' => 'Español',
'es_UY' => 'Español',
'es_VE' => 'Español',
'et_EE' => 'Eesti',
'eu_ES' => 'Euskara',
'fa_IR' => 'فارسی',
'fi_FI' => 'Suomi',
'fil_PH' => 'Filipino',
'fo_FO' => 'Føroyskt',
'fr_BE' => 'Français',
'fr_CA' => 'Français',
'fr_CH' => 'Français',
'fr_FR' => 'Français',
'fr_LU' => 'Français',
'fr_MC' => 'Français',
'fy_NL' => 'West_frysk',
'ga_IE' => 'Gaeilge',
'gd_GB' => 'Gàidhlig',
'gl_ES' => 'Galego',
'gsw_FR' => 'Schwiizertüütsch',
'gu_IN' => 'ગુજરાતી',
'ha_Latn_NG' => 'Hausa',
'he_IL' => 'עברית',
'hi_IN' => 'हिन्दी',
'hr_BA' => 'Hrvatski',
'hr_HR' => 'Hrvatski',
'hsb_DE' => 'Hornjoserbšćina',
'hu_HU' => 'Magyar',
'hy_AM' => 'Հայերեն',
'id_ID' => 'Bahasa indonesia',
'ig_NG' => 'Igbo',
'ii_CN' => 'ꆈꌠꉙ',
'is_IS' => 'Íslenska',
'it_CH' => 'Italiano',
'it_IT' => 'Italiano',
'iu_Cans_CA' => 'Inuktitut',
'iu_Latn_CA' => 'Inuktitut',
'ja_JP' => '日本語',
'ka_GE' => 'ქართული',
'kk_KZ' => 'Қазақ тілі',
'kl_GL' => 'Kalaallisut',
'km_KH' => 'ខ្មែរ',
'kn_IN' => 'ಕನ್ನಡ',
'kok_IN' => 'कोंकणी',
'ko_KR' => '한국어',
'ky_KG' => 'Кыргызча',
'lb_LU' => 'Lëtzebuergesch',
'lo_LA' => 'ລາວ',
'lt_LT' => 'Lietuvių',
'lv_LV' => 'Latviešu',
'mi_NZ' => 'Maori',
'mk_MK' => 'Македонски',
'ml_IN' => 'മലയാളം',
'mn_MN' => 'Монгол',
'mn_Mong_CN' => 'Монгол',
'moh_CA' => 'Mohawk',
'mr_IN' => 'मराठी',
'ms_BN' => 'Bahasa melayu',
'ms_MY' => 'Bahasa melayu',
'mt_MT' => 'Malti',
'nb_NO' => 'Norsk bokmål',
'ne_NP' => 'नेपाली',
'nl_BE' => 'Nederlands',
'nl_NL' => 'Nederlands',
'nn_NO' => 'Nynorsk',
'nso_ZA' => 'Northern sotho',
'oc_FR' => 'Occitan',
'or_IN' => 'ଓଡ଼ିଆ',
'pa_IN' => 'ਪੰਜਾਬੀ',
'pl_PL' => 'Polski',
'prs_AF' => 'Prs',
'ps_AF' => 'پښتو',
'pt_BR' => 'Português',
'pt_PT' => 'Português',
'qut_GT' => 'Qut',
'quz_BO' => 'Quz',
'quz_EC' => 'Quz',
'quz_PE' => 'Quz',
'rm_CH' => 'Rumantsch',
'ro_RO' => 'Română',
'ru_RU' => 'Русский',
'rw_RW' => 'Kinyarwanda',
'sah_RU' => 'Саха тыла',
'sa_IN' => 'Sanskrit',
'se_FI' => 'Davvisámegiella',
'se_NO' => 'Davvisámegiella',
'se_SE' => 'Davvisámegiella',
'si_LK' => 'සිංහල',
'sk_SK' => 'Slovenčina',
'sl_SI' => 'Slovenščina',
'sma_NO' => 'Southern sami',
'sma_SE' => 'Southern sami',
'smj_NO' => 'Lule sami',
'smj_SE' => 'Lule sami',
'smn_FI' => 'Anarâškielâ',
'sms_FI' => 'Skolt sami',
'sq_AL' => 'Shqip',
'sr_Cyrl_BA' => 'Српски',
'sr_Cyrl_CS' => 'Српски',
'sr_Cyrl_ME' => 'Српски',
'sr_Cyrl_RS' => 'Српски',
'sr_Latn_BA' => 'Srpski',
'sr_Latn_CS' => 'Srpski',
'sr_Latn_ME' => 'Srpski',
'sr_Latn_RS' => 'Srpski',
'sv_FI' => 'Svenska',
'sv_SE' => 'Svenska',
'sw_KE' => 'Kiswahili',
'syr_SY' => 'Syriac',
'ta_IN' => 'தமிழ்',
'te_IN' => 'తెలుగు',
'tg_Cyrl_TJ' => 'Tajik',
'th_TH' => 'ไทย',
'tk_TM' => 'Turkmen',
'tn_ZA' => 'Tswana',
'tr_TR' => 'Türkçe',
'tt_RU' => 'Tatar',
'tzm_Latn_DZ' => 'Tamaziɣt',
'ug_CN' => 'ئۇيغۇرچە',
'uk_UA' => 'Українська',
'ur_PK' => 'اردو',
'uz_Cyrl_UZ' => 'Ўзбек',
'uz_Latn_UZ' => 'Oʻzbekcha',
'vi_VN' => 'Tiếng việt',
'wo_SN' => 'Wolof',
'xh_ZA' => 'Xhosa',
'yo_NG' => 'Èdè yorùbá',
'zh_CN' => '中文',
'zh_HK' => '中文',
'zh_MO' => '中文',
'zh_SG' => '中文',
'zh_TW' => '中文',
'zu_ZA' => 'Isizulu',
);
/**
* This method scans for languages and creates a list of language and its name (localized ofc.)
@@ -20,7 +232,7 @@ class LocaleNegotiator
//This basically means $accepted_langs[<lang_code>] = "<lang name>";
foreach ($tmp as $key => $value) {
$lang = basename($value);
$this->accepted_langs[$lang] = self::mb_ucfirst(locale_get_display_language($lang, $lang));
$this->accepted_langs[$lang] = $this->all_locales[$lang];
}
}
@@ -31,16 +243,6 @@ class LocaleNegotiator
return $this->accepted_langs;
}
/**
* This methid does ucfirst() on multibyte encodings like UTF-8 - good for edge cases when locale starts with Č or similar.
* @param String $string string
* @return String string with first char uppercase
*/
private static function mb_ucfirst($string)
{
return mb_strtoupper(mb_substr($string, 0, 1)).mb_strtolower(mb_substr($string, 1));
}
/**
* This method does the actual negotiation. It has override parameter in case user wants to switch
* languages.
+3 -2
View File
@@ -75,7 +75,7 @@ class Service
$stmt->bind_param("s", $name);
$stmt->execute();
$query = $stmt->get_result();
header("Location: /admin/?do=settings");
header("Location: ".WEB_URL."/admin/?do=settings");
}else
{
$message = _("You don't have the permission to do that!");
@@ -116,7 +116,7 @@ class Service
$stmt->execute();
$query = $stmt->get_result();
header("Location: /admin/?do=settings");
header("Location: ".WEB_URL."/admin/?do=settings");
}
else
{
@@ -133,6 +133,7 @@ class Service
global $all, $some, $classes;
$statuses = array(0,0,0,0);
$worst = 5;
foreach ($array as $service) {
if ($service->status<$worst)
{
+1 -1
View File
@@ -6,7 +6,7 @@ class Token
{
/**
* Generates a new token from user id and randomly generated salt.
* @param int $user ID
* @param int $id user ID
* @param String $data associated with token that are important
* @param timestamp $expire expiration time
* @return String token
+46 -23
View File
@@ -97,7 +97,7 @@ class User
$stmt->bind_param("i", $this->id);
$stmt->execute();
$stmt->close();
header("Location: /admin/?do=user&id=".$id);
header("Location: ".WEB_URL."/admin/?do=user&id=".$id);
}else{
$message = _("You don't have the permission to do that!");
}
@@ -115,10 +115,24 @@ class User
global $user, $message, $mysqli;
if (INSTALL_OVERRIDE || $user->get_rank()==0)
{
if (strlen(trim($_POST['name']))==0 || strlen(trim($_POST['surname']))==0 || strlen(trim($_POST['email']))==0 || strlen(trim($_POST['password']))==0 || !isset($_POST['permission']))
if (strlen(trim($_POST['name']))==0) {
$messages[] = _("name");
}
if(strlen(trim($_POST['surname']))==0) {
$messages[] = _("surname");
}
if(strlen(trim($_POST['email']))==0) {
$messages[] = _("email");
}
if(strlen(trim($_POST['password']))==0) {
$messages[] = _("password");
}
if(!isset($_POST['permission']))
{
$message = _("Please enter all data!");
}else{
$messages[] = _("rank");
}
if (!isset($messages)){
$name = $_POST['name'];
$surname = $_POST['surname'];
$username = $_POST['username'];
@@ -159,19 +173,25 @@ class User
{
$to = $email;
$subject = _('User account created').' - '.NAME;
$message = sprintf(_("Hi %s!<br>"."Your account has been created. You can login with your email address at <a href=\"%s\">%s</a> with password %s - please change it as soon as possible."), $name." ".$surname,WEB_URL."/admin", WEB_URL."/admin", $pass);
$msg = sprintf(_("Hi %s!<br>"."Your account has been created. You can login with your email address at <a href=\"%s\">%s</a> with password %s - please change it as soon as possible."), $name." ".$surname,WEB_URL."/admin", WEB_URL."/admin", $pass);
$headers = "Content-Type: text/html; charset=utf-8 ".PHP_EOL;
$headers .= "MIME-Version: 1.0 ".PHP_EOL;
$headers .= "From: ".MAILER_NAME.' <'.MAILER_ADDRESS.'>'.PHP_EOL;
$headers .= "Reply-To: ".MAILER_NAME.' <'.MAILER_ADDRESS.'>'.PHP_EOL;
mail($to, $subject, $message, $headers);
header("Location: /admin/?do=settings");
mail($to, $subject, $msg, $headers);
if (!INSTALL_OVERRIDE)
{
header("Location: ".WEB_URL."/admin/?do=settings");
}
}
else{
$message = _("Username or email already used");
}
}
else{
$message = "Please enter ".implode(", ", $messages);
}
}
else {
$message = _("You don't have the permission to do that!");
@@ -229,7 +249,7 @@ class User
setcookie('user', $id, $year, "/");
}
$_SESSION['user'] = $id;
header("Location: /admin");
header("Location: ".WEB_URL."/admin");
}
}
}
@@ -290,14 +310,14 @@ class User
<div class="col-md-2 col-md-offset-2"><strong><?php echo _("Username");?></strong></div>
<div class="col-md-6"><?php echo $this->username."&nbsp;"; if ($this->id!=$_SESSION['user'] && $user->get_rank()<=1 && ($user->get_rank()<$this->rank))
{
echo "<a href='/admin/?do=user&id=".$this->id."&what=toggle'>";
echo "<a href='".WEB_URL."/admin/?do=user&id=".$this->id."&what=toggle'>";
echo "<i class='fa fa-".($this->active?"check success":"times danger")."'></i></a>";
}else{
echo "<i class='fa fa-".($this->active?"check success":"times danger")."'></i>";
}?></div>
</div>
<form action="/admin/?do=user&id=<?php echo $this->id; ?>" method="POST">
<form action="<?php echo WEB_URL;?>/admin/?do=user&id=<?php echo $this->id; ?>" method="POST">
<div class="row">
<div class="col-md-2 col-md-offset-2"><strong><?php echo _("Role");?></strong></div>
<div class="col-md-6"><?php if ($user->get_rank() == 0 && $this->id != $_SESSION['user']){?> <div class="input-group"><select class="form-control" name="permission"><?php foreach ($permissions as $key => $value) {
@@ -306,13 +326,13 @@ class User
</select><span class="input-group-btn">
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Change role");?></button>
</span>
</div><?}else{ echo $permissions[$this->rank];}?></div>
</div><?php }else{ echo $permissions[$this->rank];}?></div>
</div>
</form>
<?php if($this->id==$_SESSION['user'])
{?>
<form action="/admin/?do=user" method="POST">
<form action="<?php echo WEB_URL;?>/admin/?do=user" method="POST">
<div class="row">
<div class="col-md-2 col-md-offset-2"><strong>Email</strong></div>
<div class="col-md-6">
@@ -325,7 +345,7 @@ class User
</div>
</div>
</form>
<form action="/admin/?do=user" method="POST">
<form action="<?php echo WEB_URL;?>/admin/?do=user" method="POST">
<div class="row">
<div class="col-md-2 col-md-offset-2"><strong><?php echo _("Password");?></strong></div>
<div class="col-md-6">
@@ -517,7 +537,7 @@ class User
$stmt->execute();
$query = $stmt->get_result();
Token::delete($token);
header("Location: /admin/");
header("Location: ".WEB_URL."/admin/");
}
else
{
@@ -535,14 +555,17 @@ class User
public static function logout(){
global $mysqli;
session_unset();
$token = $_COOKIE['token'];
$time = time();
Token::delete($token);
unset($_COOKIE['user']);
unset($_COOKIE['token']);
setcookie('user', null, -1, '/');
setcookie('token', null, -1, '/');
header("Location: /admin");
if (isset($_COOKIE['token']))
{
$token = $_COOKIE['token'];
$time = time();
Token::delete($token);
unset($_COOKIE['user']);
unset($_COOKIE['token']);
setcookie('user', null, -1, '/');
setcookie('token', null, -1, '/');
}
header("Location: ".WEB_URL."/admin");
}
/**
@@ -558,7 +581,7 @@ class User
$stmt = $mysqli->prepare("UPDATE users SET permission=? WHERE id=?");
$stmt->bind_param("si", $permission, $id);
$stmt->execute();
header("Location: /admin/?do=user&id=".$id);
header("Location: ".WEB_URL."/admin/?do=user&id=".$id);
}
else{
$message = _("You don't have permission to do that!");