mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-22 16:41:04 +03:00
server now return token after auth
This commit is contained in:
parent
732c5dc854
commit
2a8ca039fc
8 changed files with 476 additions and 135 deletions
|
@ -16,7 +16,7 @@ class Login
|
|||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
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'])) {
|
||||
$cstrong = True;
|
||||
$token = GenerateRandomStr::gen_uuid();
|
||||
|
@ -30,55 +30,51 @@ class Login
|
|||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
|
||||
$parser = new UserAgentParser();
|
||||
|
||||
|
||||
$ua = $parser->parse();
|
||||
$ua = $parser();
|
||||
|
||||
$servicekey = GenerateRandomStr::gen_uuid();
|
||||
$url = 'http://ip-api.com/json/'.$ip;
|
||||
$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,
|
||||
));
|
||||
$response = file_get_contents($url);
|
||||
|
||||
setcookie("NGALLERYSESS", $token, 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("NGALLERYID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
||||
$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,
|
||||
));
|
||||
|
||||
echo Json::return (
|
||||
setcookie("NGALLERYSESS", $token, 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("NGALLERYID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
||||
|
||||
echo Json::return(
|
||||
array(
|
||||
'errorcode' => '0',
|
||||
'error' => 0
|
||||
'error' => 0,
|
||||
'token' => $token
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
echo Json::return (
|
||||
echo Json::return(
|
||||
array(
|
||||
'errorcode' => '1',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
echo Json::return (
|
||||
echo Json::return(
|
||||
array(
|
||||
'errorcode' => '1',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,33 +13,251 @@ class Register
|
|||
{
|
||||
|
||||
|
||||
private static function checkforb($nickname, $nicknames) {
|
||||
private static function checkforb($nickname, $nicknames)
|
||||
{
|
||||
$replacements = [
|
||||
'1' => 'i', '!' => 'i', '|' => 'i', 'l' => 'i', 'í' => 'i', 'ì' => 'i', 'î' => 'i', 'ï' => 'i', 'İ' => 'i', '¡' => 'i',
|
||||
'0' => 'o', '@' => 'a', '$' => 's', '5' => 's', '§' => 's', '2' => 'z', '3' => 'e', '7' => 't', '4' => 'a', '8' => 'b',
|
||||
'6' => 'b', '9' => 'g', 'ß' => 'ss', 'µ' => 'u', 'æ' => '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'
|
||||
'1' => 'i',
|
||||
'!' => 'i',
|
||||
'|' => 'i',
|
||||
'l' => 'i',
|
||||
'í' => 'i',
|
||||
'ì' => 'i',
|
||||
'î' => 'i',
|
||||
'ï' => 'i',
|
||||
'İ' => 'i',
|
||||
'¡' => 'i',
|
||||
'0' => 'o',
|
||||
'@' => 'a',
|
||||
'$' => 's',
|
||||
'5' => 's',
|
||||
'§' => 's',
|
||||
'2' => 'z',
|
||||
'3' => 'e',
|
||||
'7' => 't',
|
||||
'4' => 'a',
|
||||
'8' => 'b',
|
||||
'6' => 'b',
|
||||
'9' => 'g',
|
||||
'ß' => 'ss',
|
||||
'µ' => 'u',
|
||||
'æ' => '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);
|
||||
|
@ -57,14 +275,14 @@ class Register
|
|||
public function __construct()
|
||||
{
|
||||
$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');
|
||||
|
||||
$ch = curl_init('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['username']);
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['username']);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYSTATUS, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
||||
|
@ -77,83 +295,92 @@ class Register
|
|||
$email = $_POST['email'];
|
||||
$forbusernames = explode(',', NGALLERY['root']['registration']['prohibited_usernames']);
|
||||
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 (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(
|
||||
array(
|
||||
'route' => 'NONE',
|
||||
'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()));
|
||||
$cstrong = True;
|
||||
$token = GenerateRandomStr::gen_uuid();
|
||||
$user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id'];
|
||||
$content = Json::return(
|
||||
array(
|
||||
'route' => 'NONE',
|
||||
'regdate' => time()
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
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;
|
||||
$token = GenerateRandomStr::gen_uuid();
|
||||
$user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id'];
|
||||
|
||||
$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
|
||||
)
|
||||
);
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '2',
|
||||
'errortitle' => 'Пользователь с такой почтой уже существует!',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
$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,
|
||||
'token' => $token
|
||||
)
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '2',
|
||||
'errortitle' => 'Пользователь с такой почтой уже существует!',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '3',
|
||||
'errortitle' => 'Почта некорректного формата!',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '3',
|
||||
'errortitle' => 'Почта некорректного формата!',
|
||||
'errorcode' => '4',
|
||||
'errortitle' => 'Пароль меньше 5 символов!',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
|
@ -161,8 +388,8 @@ class Register
|
|||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '4',
|
||||
'errortitle' => 'Пароль меньше 5 символов!',
|
||||
'errorcode' => '5',
|
||||
'errortitle' => 'Никнейм некорректный!',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
|
@ -170,8 +397,8 @@ class Register
|
|||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '5',
|
||||
'errortitle' => 'Никнейм некорректный!',
|
||||
'errorcode' => '6',
|
||||
'errortitle' => 'Никнейм уже существует!',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
|
@ -179,21 +406,12 @@ class Register
|
|||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '6',
|
||||
'errortitle' => 'Никнейм уже существует!',
|
||||
'errorcode' => '7',
|
||||
'errortitle' => 'Никнейм ' . $_POST['username'] . ' запрещён на сервере.',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(
|
||||
array(
|
||||
'errorcode' => '7',
|
||||
'errortitle' => 'Никнейм '.$_POST['username'].' запрещён на сервере.',
|
||||
'error' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
unlink($lockFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
use \App\Services\{DB, Date};
|
||||
use \App\Services\{DB, Date, Auth};
|
||||
use \App\Models\{User, Photo, Vote};
|
||||
|
||||
class Comment {
|
||||
|
@ -50,9 +50,46 @@ class Comment {
|
|||
<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="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&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'].'">
|
||||
<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-ext">
|
||||
<div><span class="pro">+'.Vote::countcommrates($this->c['id'], 1).'</span> / <span class="con">'.Vote::countcommrates($this->c['id'], 0).'</span></div>
|
||||
</div>
|
||||
|
|
|
@ -38,3 +38,44 @@ ul.mm { margin:0 8px; width:100%; }
|
|||
.mm-wide > .mm-item > .mm-label { display: none; }
|
||||
.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
42
static/js/act.js
Normal 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">×</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";
|
||||
}
|
||||
});
|
||||
});
|
|
@ -23,6 +23,7 @@
|
|||
<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/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>
|
||||
<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">
|
||||
|
|
|
@ -269,7 +269,7 @@ if ($photo->i('id') !== null) {
|
|||
<td id="pp-main-col">
|
||||
<div id="pp-item-vdata">
|
||||
<?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">
|
||||
<h4 class="pp-item-header">Параметры съёмки</h4>
|
||||
|
|
|
@ -805,8 +805,14 @@ $user = new User(Auth::userid());
|
|||
<option value="8">Передача в общественное достояние (Zero)</option>
|
||||
<option value="9">Нет авторских прав (Mark)</option>
|
||||
</select> <a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a>
|
||||
</td>
|
||||
</td><br>
|
||||
|
||||
</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>
|
||||
.w3-green, .w3-hover-green:hover {
|
||||
color: #fff !important;
|
||||
|
|
Loading…
Reference in a new issue