server now return token after auth

This commit is contained in:
themohooks 2024-10-01 06:31:32 +03:00
parent 732c5dc854
commit 2a8ca039fc
8 changed files with 476 additions and 135 deletions

View file

@ -16,7 +16,7 @@ class Login
$username = $_POST['username']; $username = $_POST['username'];
$password = $_POST['password']; $password = $_POST['password'];
if (DB::query('SELECT email FROM users WHERE email=:username OR username=:username', array(':username' => $username))) { if (DB::query('SELECT email FROM users WHERE email=:username OR username=:username', array(':username' => $username))) {
$email = DB::query('SELECT email FROM users WHERE email=:username OR username=:username', array(':username'=>$username))[0]['email']; $email = DB::query('SELECT email FROM users WHERE email=:username OR username=:username', array(':username' => $username))[0]['email'];
if (password_verify($password, DB::query('SELECT password FROM users WHERE email=:username', array(':username' => $email))[0]['password'])) { if (password_verify($password, DB::query('SELECT password FROM users WHERE email=:username', array(':username' => $email))[0]['password'])) {
$cstrong = True; $cstrong = True;
$token = GenerateRandomStr::gen_uuid(); $token = GenerateRandomStr::gen_uuid();
@ -36,49 +36,45 @@ class Login
$ua = $parser->parse(); $ua = $parser->parse();
$ua = $parser(); $ua = $parser();
$servicekey = GenerateRandomStr::gen_uuid(); $servicekey = GenerateRandomStr::gen_uuid();
$url = 'http://ip-api.com/json/'.$ip; $url = 'http://ip-api.com/json/' . $ip;
$response = file_get_contents($url); $response = file_get_contents($url);
$data = json_decode($response, true); $data = json_decode($response, true);
$loc = $data['country'].', '.$data['city']; $loc = $data['country'] . ', ' . $data['city'];
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id)', array( DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id)', array(
':token' => $token, ':token' => $token,
':user_id' => $user_id, ':user_id' => $user_id,
)); ));
setcookie("NGALLERYSESS", $token, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); setcookie("NGALLERYSESS", $token, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
setcookie("NGALLERYSERVICE", $servicekey, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); setcookie("NGALLERYSERVICE", $servicekey, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
setcookie("NGALLERYSESS_", '1', time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); setcookie("NGALLERYSESS_", '1', time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
setcookie("NGALLERYID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); setcookie("NGALLERYID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
echo Json::return ( echo Json::return(
array( array(
'errorcode' => '0', 'errorcode' => '0',
'error' => 0 'error' => 0,
'token' => $token
) )
); );
} else { } else {
echo Json::return ( echo Json::return(
array( array(
'errorcode' => '1', 'errorcode' => '1',
'error' => 1 'error' => 1
) )
); );
} }
} else { } else {
echo Json::return ( echo Json::return(
array( array(
'errorcode' => '1', 'errorcode' => '1',
'error' => 1 'error' => 1
) )
); );
} }
} }
} }

View file

@ -13,33 +13,251 @@ class Register
{ {
private static function checkforb($nickname, $nicknames) { private static function checkforb($nickname, $nicknames)
{
$replacements = [ $replacements = [
'1' => 'i', '!' => 'i', '|' => 'i', 'l' => 'i', 'í' => 'i', 'ì' => 'i', 'î' => 'i', 'ï' => 'i', 'İ' => 'i', '¡' => 'i', '1' => 'i',
'0' => 'o', '@' => 'a', '$' => 's', '5' => 's', '§' => 's', '2' => 'z', '3' => 'e', '7' => 't', '4' => 'a', '8' => 'b', '!' => 'i',
'6' => 'b', '9' => 'g', 'ß' => 'ss', 'µ' => 'u', 'æ' => 'ae', 'œ' => 'oe', 'z' => '2', 'x' => '%', 'w' => 'vv', 'v' => 'u', '|' => 'i',
'ñ' => 'n', 'á' => 'a', 'à' => 'a', 'â' => 'a', 'ä' => 'a', 'ã' => 'a', 'å' => 'a', 'é' => 'e', 'è' => 'e', 'ê' => 'e', 'l' => 'i',
'ë' => 'e', 'í' => 'i', 'ó' => 'o', 'ò' => 'o', 'ô' => 'o', 'ö' => 'o', 'õ' => 'o', 'ú' => 'u', 'ù' => 'u', 'û' => 'u', 'í' => 'i',
'ü' => 'u', 'ç' => 'c', 'ć' => 'c', 'č' => 'c', 'đ' => 'd', 'š' => 's', 'ž' => 'z', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'ì' => 'i',
'д' => 'd', 'е' => 'e', 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'i', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'î' => 'i',
'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'kh', 'ц' => 'ts', 'ï' => 'i',
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shch', 'ы' => 'y', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', 'ѣ' => 'e', 'і' => 'i', 'ѳ' => 'f', 'İ' => 'i',
'ѵ' => 'i', 'қ' => 'k', 'ғ' => 'g', 'ң' => 'n', 'ү' => 'u', 'ұ' => 'u', 'ө' => 'o', 'ә' => 'a', 'җ' => 'zh', 'һ' => 'h', '¡' => 'i',
'ү' => 'u', 'ұ' => 'u', 'ҙ' => 'z', 'ӣ' => 'i', 'ӯ' => 'u', 'ҷ' => 'ch', 'ҳ' => 'h', 'ѯ' => 'ks', 'ѱ' => 'ps', 'ѝ' => 'i', '0' => 'o',
'ѫ' => 'u', 'ѭ' => 'yu', 'ў' => 'u', 'џ' => 'dz', 'є' => 'e', 'і' => 'i', 'ї' => 'i', 'ґ' => 'g', 'є' => 'e', 'і' => 'i', '@' => 'a',
'ї' => 'i', 'ґ' => 'g', 'ä' => 'a', 'ö' => 'o', 'ü' => 'u', 'ß' => 'ss', 'ā' => 'a', 'ē' => 'e', 'ī' => 'i', 'ō' => 'o', '$' => 's',
'ū' => 'u', 'ç' => 'c', 'ğ' => 'g', 'ş' => 's', 'ÿ' => 'y', 'œ' => 'oe', 'æ' => 'ae', 'å' => 'a', 'ø' => 'o', 'ē' => 'e', '5' => 's',
'ş' => 's', 'ū' => 'u', 'ž' => 'z', 'ž' => 'z', 'ł' => 'l', 'đ' => 'd', 'č' => 'c', 'ć' => 'c', 'ś' => 's', 'ź' => 'z', '§' => 's',
'ń' => 'n', 'á' => 'a', 'é' => 'e', 'í' => 'i', 'ó' => 'o', 'ú' => 'u', 'ý' => 'y', 'ř' => 'r', 'ě' => 'e', 'ů' => 'u', '2' => 'z',
'ű' => 'u', 'ő' => 'o', 'ě' => 'e', 'ň' => 'n', 'ď' => 'd', 'ť' => 't', 'ĺ' => 'l', 'ľ' => 'l', 'ŕ' => 'r', 'ă' => 'a', '3' => 'e',
'ș' => 's', 'ț' => 't', 'ā' => 'a', 'ē' => 'e', 'ī' => 'i', 'ō' => 'o', 'ū' => 'u', 'ė' => 'e', 'į' => 'i', 'ų' => 'u', '7' => 't',
'ţ' => 't', 'ș' => 's', 'ä' => 'a', 'ö' => 'o', 'ü' => 'u', 'ß' => 'ss', 'ā' => 'a', 'ē' => 'e', 'ī' => 'i', 'ō' => 'o', '4' => 'a',
'ū' => 'u', 'ç' => 'c', 'ğ' => 'g', 'ş' => 's', 'ÿ' => 'y', 'œ' => 'oe', 'æ' => 'ae', 'å' => 'a', 'ø' => 'o', 'ē' => 'e', '8' => 'b',
'ş' => 's', 'ū' => 'u', 'ž' => 'z', 'ž' => 'z', 'ł' => 'l', 'đ' => 'd', 'č' => 'c', 'ć' => 'c', 'ś' => 's', 'ź' => 'z', '6' => 'b',
'ń' => 'n', 'á' => 'a', 'é' => 'e', 'í' => 'i', 'ó' => 'o', 'ú' => 'u', 'ý' => 'y', 'ř' => 'r', 'ě' => 'e', 'ů' => 'u', '9' => 'g',
'ű' => 'u', 'ő' => 'o', 'ě' => 'e', 'ň' => 'n', 'ď' => 'd', 'ť' => 't', 'ĺ' => 'l', 'ľ' => 'l', 'ŕ' => 'r', 'ă' => 'a', 'ß' => 'ss',
'ș' => 's', 'ț' => 't', 'ā' => 'a', 'ē' => 'e', 'ī' => 'i', 'ō' => 'o', 'ū' => 'u', 'ė' => 'e', 'į' => 'i', 'ų' => 'u', 'µ' => 'u',
'ţ' => 't', 'ș' => 's' 'æ' => 'ae',
'œ' => 'oe',
'z' => '2',
'x' => '%',
'w' => 'vv',
'v' => 'u',
'ñ' => 'n',
'á' => 'a',
'à' => 'a',
'â' => 'a',
'ä' => 'a',
'ã' => 'a',
'å' => 'a',
'é' => 'e',
'è' => 'e',
'ê' => 'e',
'ë' => 'e',
'í' => 'i',
'ó' => 'o',
'ò' => 'o',
'ô' => 'o',
'ö' => 'o',
'õ' => 'o',
'ú' => 'u',
'ù' => 'u',
'û' => 'u',
'ü' => 'u',
'ç' => 'c',
'ć' => 'c',
'č' => 'c',
'đ' => 'd',
'š' => 's',
'ž' => 'z',
'б' => 'b',
'в' => 'v',
'г' => 'g',
'д' => 'd',
'е' => 'e',
'ё' => 'e',
'ж' => 'zh',
'з' => 'z',
'и' => 'i',
'й' => 'i',
'к' => 'k',
'л' => 'l',
'м' => 'm',
'н' => 'n',
'о' => 'o',
'п' => 'p',
'р' => 'r',
'с' => 's',
'т' => 't',
'у' => 'u',
'ф' => 'f',
'х' => 'kh',
'ц' => 'ts',
'ч' => 'ch',
'ш' => 'sh',
'щ' => 'shch',
'ы' => 'y',
'э' => 'e',
'ю' => 'yu',
'я' => 'ya',
'ѣ' => 'e',
'і' => 'i',
'ѳ' => 'f',
'ѵ' => 'i',
'қ' => 'k',
'ғ' => 'g',
'ң' => 'n',
'ү' => 'u',
'ұ' => 'u',
'ө' => 'o',
'ә' => 'a',
'җ' => 'zh',
'һ' => 'h',
'ү' => 'u',
'ұ' => 'u',
'ҙ' => 'z',
'ӣ' => 'i',
'ӯ' => 'u',
'ҷ' => 'ch',
'ҳ' => 'h',
'ѯ' => 'ks',
'ѱ' => 'ps',
'ѝ' => 'i',
'ѫ' => 'u',
'ѭ' => 'yu',
'ў' => 'u',
'џ' => 'dz',
'є' => 'e',
'і' => 'i',
'ї' => 'i',
'ґ' => 'g',
'є' => 'e',
'і' => 'i',
'ї' => 'i',
'ґ' => 'g',
'ä' => 'a',
'ö' => 'o',
'ü' => 'u',
'ß' => 'ss',
'ā' => 'a',
'ē' => 'e',
'ī' => 'i',
'ō' => 'o',
'ū' => 'u',
'ç' => 'c',
'ğ' => 'g',
'ş' => 's',
'ÿ' => 'y',
'œ' => 'oe',
'æ' => 'ae',
'å' => 'a',
'ø' => 'o',
'ē' => 'e',
'ş' => 's',
'ū' => 'u',
'ž' => 'z',
'ž' => 'z',
'ł' => 'l',
'đ' => 'd',
'č' => 'c',
'ć' => 'c',
'ś' => 's',
'ź' => 'z',
'ń' => 'n',
'á' => 'a',
'é' => 'e',
'í' => 'i',
'ó' => 'o',
'ú' => 'u',
'ý' => 'y',
'ř' => 'r',
'ě' => 'e',
'ů' => 'u',
'ű' => 'u',
'ő' => 'o',
'ě' => 'e',
'ň' => 'n',
'ď' => 'd',
'ť' => 't',
'ĺ' => 'l',
'ľ' => 'l',
'ŕ' => 'r',
'ă' => 'a',
'ș' => 's',
'ț' => 't',
'ā' => 'a',
'ē' => 'e',
'ī' => 'i',
'ō' => 'o',
'ū' => 'u',
'ė' => 'e',
'į' => 'i',
'ų' => 'u',
'ţ' => 't',
'ș' => 's',
'ä' => 'a',
'ö' => 'o',
'ü' => 'u',
'ß' => 'ss',
'ā' => 'a',
'ē' => 'e',
'ī' => 'i',
'ō' => 'o',
'ū' => 'u',
'ç' => 'c',
'ğ' => 'g',
'ş' => 's',
'ÿ' => 'y',
'œ' => 'oe',
'æ' => 'ae',
'å' => 'a',
'ø' => 'o',
'ē' => 'e',
'ş' => 's',
'ū' => 'u',
'ž' => 'z',
'ž' => 'z',
'ł' => 'l',
'đ' => 'd',
'č' => 'c',
'ć' => 'c',
'ś' => 's',
'ź' => 'z',
'ń' => 'n',
'á' => 'a',
'é' => 'e',
'í' => 'i',
'ó' => 'o',
'ú' => 'u',
'ý' => 'y',
'ř' => 'r',
'ě' => 'e',
'ů' => 'u',
'ű' => 'u',
'ő' => 'o',
'ě' => 'e',
'ň' => 'n',
'ď' => 'd',
'ť' => 't',
'ĺ' => 'l',
'ľ' => 'l',
'ŕ' => 'r',
'ă' => 'a',
'ș' => 's',
'ț' => 't',
'ā' => 'a',
'ē' => 'e',
'ī' => 'i',
'ō' => 'o',
'ū' => 'u',
'ė' => 'e',
'į' => 'i',
'ų' => 'u',
'ţ' => 't',
'ș' => 's'
]; ];
$normalized_nickname = strtr(strtolower($nickname), $replacements); $normalized_nickname = strtr(strtolower($nickname), $replacements);
@ -57,7 +275,7 @@ class Register
public function __construct() public function __construct()
{ {
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
$lockFile = $_SERVER['DOCUMENT_ROOT'].'/lock/request_lock_' . $ip; $lockFile = $_SERVER['DOCUMENT_ROOT'] . '/lock/request_lock_' . $ip;
file_put_contents($lockFile, 'lock'); file_put_contents($lockFile, 'lock');
$ch = curl_init('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['username']); $ch = curl_init('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['username']);
@ -79,81 +297,90 @@ class Register
if (!self::checkforb($_POST['username'], $forbusernames)) { if (!self::checkforb($_POST['username'], $forbusernames)) {
if (!strcasecmp(DB::query('SELECT username FROM users WHERE (LOWER(username) LIKE :username)', array(':username' => '%' . $username . '%'))[0]['username'], $username) === false) { if (!strcasecmp(DB::query('SELECT username FROM users WHERE (LOWER(username) LIKE :username)', array(':username' => '%' . $username . '%'))[0]['username'], $username) === false) {
if (Word::strlen(ltrim($username)) >= 2 && Word::strlen(ltrim($username)) <= 20) { if (Word::strlen(ltrim($username)) >= 2 && Word::strlen(ltrim($username)) <= 20) {
if (Word::strlen(ltrim($password)) >= 5 && Word::strlen(ltrim($password)) <= 120) { if (Word::strlen(ltrim($password)) >= 5 && Word::strlen(ltrim($password)) <= 120) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
if (!DB::query('SELECT email FROM users WHERE email=:email', array(':email' => $email))) { if (!DB::query('SELECT email FROM users WHERE email=:email', array(':email' => $email))) {
$content = Json::return( $content = Json::return(
array( array(
'route' => 'NONE', 'route' => 'NONE',
'regdate' => time() 'regdate' => time()
) )
); );
DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password, :photourl, 5, :online, 0, 0, :content)', array(':username' => ltrim($username), ':password' => password_hash(ltrim($password), PASSWORD_BCRYPT), ':photourl'=>'/static/img/avatar.png', ':email' => $email, ':content' => $content, ':online'=>time())); DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password, :photourl, 5, :online, 0, 0, :content)', array(':username' => ltrim($username), ':password' => password_hash(ltrim($password), PASSWORD_BCRYPT), ':photourl' => '/static/img/avatar.png', ':email' => $email, ':content' => $content, ':online' => time()));
$cstrong = True; $cstrong = True;
$token = GenerateRandomStr::gen_uuid(); $token = GenerateRandomStr::gen_uuid();
$user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id']; $user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id'];
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP']; $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$parser = new UserAgentParser();
$ua = $parser->parse();
$ua = $parser();
$servicekey = GenerateRandomStr::gen_uuid();
$url = 'http://ip-api.com/json/'.$ip;
$response = file_get_contents($url);
$data = json_decode($response, true);
$loc = $data['country'].', '.$data['city'];
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id)', array(
':token' => $token,
':user_id' => $user_id,
));
setcookie("NGALLERYSESS", $token, time() + 120 * 180 * 240 * 720, '/', NULL, NULL, TRUE);
setcookie("NGALLERYSESS_", '1', time() + 120 * 180 * 240 * 360, '/', NULL, NULL, TRUE);
setcookie("NGALLERYID", $user_id, time() + 10 * 10 * 24 * 72, '/', NULL, NULL, TRUE);
echo json_encode(
array(
'errorcode' => '0',
'error' => 0
)
);
} else { } else {
echo json_encode( $ip = $_SERVER['REMOTE_ADDR'];
array(
'errorcode' => '2',
'errortitle' => 'Пользователь с такой почтой уже существует!',
'error' => 1
)
);
} }
$parser = new UserAgentParser();
$ua = $parser->parse();
$ua = $parser();
$servicekey = GenerateRandomStr::gen_uuid();
$url = 'http://ip-api.com/json/' . $ip;
$response = file_get_contents($url);
$data = json_decode($response, true);
$loc = $data['country'] . ', ' . $data['city'];
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id)', array(
':token' => $token,
':user_id' => $user_id,
));
setcookie("NGALLERYSESS", $token, time() + 120 * 180 * 240 * 720, '/', NULL, NULL, TRUE);
setcookie("NGALLERYSESS_", '1', time() + 120 * 180 * 240 * 360, '/', NULL, NULL, TRUE);
setcookie("NGALLERYID", $user_id, time() + 10 * 10 * 24 * 72, '/', NULL, NULL, TRUE);
echo json_encode(
array(
'errorcode' => '0',
'error' => 0,
'token' => $token
)
);
} else {
echo json_encode(
array(
'errorcode' => '2',
'errortitle' => 'Пользователь с такой почтой уже существует!',
'error' => 1
)
);
}
} else {
echo json_encode(
array(
'errorcode' => '3',
'errortitle' => 'Почта некорректного формата!',
'error' => 1
)
);
}
} else { } else {
echo json_encode( echo json_encode(
array( array(
'errorcode' => '3', 'errorcode' => '4',
'errortitle' => 'Почта некорректного формата!', 'errortitle' => ароль меньше 5 символов!',
'error' => 1 'error' => 1
) )
); );
@ -161,8 +388,8 @@ class Register
} else { } else {
echo json_encode( echo json_encode(
array( array(
'errorcode' => '4', 'errorcode' => '5',
'errortitle' => 'Пароль меньше 5 символов!', 'errortitle' => 'Никнейм некорректный!',
'error' => 1 'error' => 1
) )
); );
@ -170,8 +397,8 @@ class Register
} else { } else {
echo json_encode( echo json_encode(
array( array(
'errorcode' => '5', 'errorcode' => '6',
'errortitle' => 'Никнейм некорректный!', 'errortitle' => 'Никнейм уже существует!',
'error' => 1 'error' => 1
) )
); );
@ -179,21 +406,12 @@ class Register
} else { } else {
echo json_encode( echo json_encode(
array( array(
'errorcode' => '6', 'errorcode' => '7',
'errortitle' => 'Никнейм уже существует!', 'errortitle' => 'Никнейм ' . $_POST['username'] . ' запрещён на сервере.',
'error' => 1 'error' => 1
) )
); );
} }
} else {
echo json_encode(
array(
'errorcode' => '7',
'errortitle' => 'Никнейм '.$_POST['username'].' запрещён на сервере.',
'error' => 1
)
);
}
unlink($lockFile); unlink($lockFile);
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace App\Models; namespace App\Models;
use \App\Services\{DB, Date}; use \App\Services\{DB, Date, Auth};
use \App\Models\{User, Photo, Vote}; use \App\Models\{User, Photo, Vote};
class Comment { class Comment {
@ -50,9 +50,46 @@ class Comment {
<div class="rank">Фото: '.Photo::fetchAll($this->c['user_id']).' '.$admintype.'</div> <div class="rank">Фото: '.Photo::fetchAll($this->c['user_id']).' '.$admintype.'</div>
<div class="message-text">'.preg_replace("~(?:[\p{M}]{1})([\p{M}])+?~uis","", htmlspecialchars($this->c['body'])).'</div> <div class="message-text">'.preg_replace("~(?:[\p{M}]{1})([\p{M}])+?~uis","", htmlspecialchars($this->c['body'])).'</div>
<div class="comment-votes-block"> <div class="comment-votes-block">
';
echo '<style>
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
</style>';
if ($this->c['user_id'] === Auth::userid()) {
echo '
<div class="dropdown">
<a style="color: #000" class="compl" href="/lk/ticket.php?action=add&amp;wid=3252565">...</a>
<div class="dropdown-content">'; ?>
<a href="#" onclick="createModal(100, 'EDIT_COMMENT'); return false;">Редактировать</a><br>
<a href="#" onclick="createModal(100, 'DELETE_COMMENT'); return false;">Удалить</a>
<?php
echo '
</div>
</div>
';
}
echo '
<div class="wvote" wid="'.$this->c['id'].'"> <div class="wvote" wid="'.$this->c['id'].'">
<a href="#" vote="1" class="w-btn s2"><span>+</span></a> <a href="#" vote="1" class="w-btn s2"><span>+</span></a>
<div class="w-rating '.$commclass.' active">'.$symb.Vote::countcommrates($this->c['id'], -1).'</div> <div class="w-rating '.$commclass.' active">'.$symb.Vote::countcommrates($this->c['id'], -1).'</div>
<div class="w-rating-ext"> <div class="w-rating-ext">
<div><span class="pro">+'.Vote::countcommrates($this->c['id'], 1).'</span> / <span class="con">'.Vote::countcommrates($this->c['id'], 0).'</span></div> <div><span class="pro">+'.Vote::countcommrates($this->c['id'], 1).'</span> / <span class="con">'.Vote::countcommrates($this->c['id'], 0).'</span></div>
</div> </div>

View file

@ -38,3 +38,44 @@ ul.mm { margin:0 8px; width:100%; }
.mm-wide > .mm-item > .mm-label { display: none; } .mm-wide > .mm-item > .mm-label { display: none; }
.mm-wide > div > ul { right: 8px; left: auto; } .mm-wide > div > ul { right: 8px; left: auto; }
} }
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1000; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}

42
static/js/act.js Normal file
View file

@ -0,0 +1,42 @@
function createModal(id, type) {
if (type === 'EDIT_COMMENT') {
var modal = `
<div id="modal`+id+`" class="modal" style="display: block;">
<div class="modal-content">
<span data-modal-id="`+id+`" class="close">&times;</span>
<p>Some text in the Modal..</p>
</div>
</div>`;
}
document.body.innerHTML += modal;
}
var modals = document.querySelectorAll(".modal");
// Loop through each modal
modals.forEach(function(modal) {
// Get the unique ID of the modal
var modalId = modal.id;
// Get the close button within the modal
var closeButton = modal.querySelector(".close[data-modal-id='" + modalId + "']");
// Set up event listener for the close button
closeButton.addEventListener("click", function() {
// Hide the modal with the matching ID
document.getElementById(modalId).style.display = "none";
});
// Set up event listener for click outside the modal
window.addEventListener("click", function(event) {
// Check if the user clicked outside of the modal
if (event.target == modal) {
// Hide the modal with the matching ID
document.getElementById(modalId).style.display = "none";
}
});
});

View file

@ -23,6 +23,7 @@
<script src="/static/js/photo.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script> <script src="/static/js/photo.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/comments.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script> <script src="/static/js/comments.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/newcore.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script> <script src="/static/js/newcore.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="/static/js/act.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<div class="progress-container fixed-top"> <div class="progress-container fixed-top">

View file

@ -269,7 +269,7 @@ if ($photo->i('id') !== null) {
<td id="pp-main-col"> <td id="pp-main-col">
<div id="pp-item-vdata"> <div id="pp-item-vdata">
<?php <?php
if ($photo->content('type') != 'none') { if ($photo->content('type') != 'none' && json_decode($photo->i('exif'), true)['type'] != 'none') {
?> ?>
<div class="p0" id="pp-item-exif"> <div class="p0" id="pp-item-exif">
<h4 class="pp-item-header">Параметры съёмки</h4> <h4 class="pp-item-header">Параметры съёмки</h4>

View file

@ -805,8 +805,14 @@ $user = new User(Auth::userid());
<option value="8">Передача в общественное достояние (Zero)</option> <option value="8">Передача в общественное достояние (Zero)</option>
<option value="9">Нет авторских прав (Mark)</option> <option value="9">Нет авторских прав (Mark)</option>
</select> &nbsp; &nbsp;<a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a> </select> &nbsp; &nbsp;<a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a>
</td> </td><br>
</tr> </tr>
<tr>
<td style="padding:7px 2px">
<input type="checkbox" name="nomap" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Отключить комментарии</label>
</td>
</tr>
<style> <style>
.w3-green, .w3-hover-green:hover { .w3-green, .w3-hover-green:hover {
color: #fff !important; color: #fff !important;