php8 fixes

This commit is contained in:
Android 2021-11-23 15:44:40 +05:00
parent b7e87607cd
commit 4a22972afe
4 changed files with 35 additions and 15 deletions

View File

@ -267,6 +267,8 @@ try {
$db_file = DB_FILE;
if (substr($db_file, 0, 6) == '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) {
$db_file = substr($db_file, 3);
} else if (substr($db_file, 0, 5) == '..' . DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR) {
$db_file = substr($db_file, 3);
}
$config .= 'const DB_FILE = \'' . addslashes($db_file) . '\';' . "\r\n";
}
@ -320,6 +322,22 @@ try {
$defaults .= ');'."\r\n";
file_put_contents(ROOT_DIR . DIRECTORY_SEPARATOR . 'config.php', '<?php'."\r\n" . $head . "\r\n\r\n" . $info . $config . "\r\n" . $defaults, FILE_TEXT);
// clearing cache
try {
$d = @opendir(ROOT_DIR . DIRECTORY_SEPARATOR . CACHE_DIR);
if ($d) {
while(($f=readdir($d))!==false) {
if ($f=='.' || $f=='..' || !is_file(ROOT_DIR . DIRECTORY_SEPARATOR . CACHE_DIR . DIRECTORY_SEPARATOR . $f)) continue;
if (substr($f,-6)!='.cache') continue;
@chmod(ROOT_DIR . DIRECTORY_SEPARATOR . CACHE_DIR . DIRECTORY_SEPARATOR . $f, 0660);
@unlink(ROOT_DIR . DIRECTORY_SEPARATOR . CACHE_DIR . DIRECTORY_SEPARATOR . $f);
}
closedir($d);
}
} catch(\Exception $e) {
// ignore
}
}
Zira\Db\Db::close();

View File

@ -98,6 +98,8 @@ if (!$error) {
$const = strtoupper($field);
if ($field == 'db_file' && !empty($data[$field]) && substr($data[$field], 0, 3) == '..' . DIRECTORY_SEPARATOR) {
$data[$field] = '..' . DIRECTORY_SEPARATOR . $data[$field];
} else if ($field == 'db_file' && !empty($data[$field]) && substr($data[$field], 0, 2) == '.' . DIRECTORY_SEPARATOR) {
$data[$field] = '..' . DIRECTORY_SEPARATOR . $data[$field];
}
if (!defined($const)) define($const, $data[$field]);
}

View File

@ -154,20 +154,20 @@ class Helper {
}
public static function utf8Ord($c) {
if (ord($c{0}) >=0 && ord($c{0}) <= 127)
return ord($c{0});
if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
return (ord($c{0})-192)*64 + (ord($c{1})-128);
if (ord($c{0}) >= 224 && ord($c{0}) <= 239)
return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
if (ord($c{0}) >= 240 && ord($c{0}) <= 247)
return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
if (ord($c{0}) >= 248 && ord($c{0}) <= 251)
return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
if (ord($c{0}) >= 254 && ord($c{0}) <= 255) // error
return FALSE;
if (ord($c[0]) >=0 && ord($c[0]) <= 127)
return ord($c[0]);
if (ord($c[0]) >= 192 && ord($c[0]) <= 223)
return (ord($c[0])-192)*64 + (ord($c[1])-128);
if (ord($c[0]) >= 224 && ord($c[0]) <= 239)
return (ord($c[0])-224)*4096 + (ord($c[1])-128)*64 + (ord($c[2])-128);
if (ord($c[0]) >= 240 && ord($c[0]) <= 247)
return (ord($c[0])-240)*262144 + (ord($c[1])-128)*4096 + (ord($c[2])-128)*64 + (ord($c[3])-128);
if (ord($c[0]) >= 248 && ord($c[0]) <= 251)
return (ord($c[0])-248)*16777216 + (ord($c[1])-128)*262144 + (ord($c[2])-128)*4096 + (ord($c[3])-128)*64 + (ord($c[4])-128);
if (ord($c[0]) >= 252 && ord($c[0]) <= 253)
return (ord($c[0])-252)*1073741824 + (ord($c[1])-128)*16777216 + (ord($c[2])-128)*262144 + (ord($c[3])-128)*4096 + (ord($c[4])-128)*64 + (ord($c[5])-128);
if (ord($c[0]) >= 254 && ord($c[0]) <= 255) // error
return FALSE;
return 0;
}

View File

@ -679,7 +679,7 @@ class User {
return Helper::tag_short('img', $attributes);
}
public static function generateUserProfileThumbLink($id, $firstname, $secondname, $username, $rel = null, $image, $default_image = null, array $attributes = array()) {
public static function generateUserProfileThumbLink($id, $firstname, $secondname, $username, $rel = null, $image = null, $default_image = null, array $attributes = array()) {
$name = $firstname && $secondname ? trim($firstname . ' ' . $secondname) : $username;
if (!array_key_exists('alt', $attributes)) $attributes['alt'] = $name;
$attr = array('href'=>Helper::url('user/'.$id),'title'=>$name);