This commit is contained in:
themohooks 2024-10-03 21:34:50 +03:00
parent 545af281eb
commit 24b3ef9726
4 changed files with 144 additions and 15 deletions

View file

@ -2,6 +2,7 @@
namespace App\Models;
use \App\Services\DB;
use DOMDocument, DOMXPath;
use PHPHtmlParser\Dom;
class UserCTTC {
@ -10,13 +11,12 @@ class UserCTTC {
function __construct(int $user_id) {
$this->userid = $user_id;
$url = "https://transphoto.org/author/".$user_id;
$dataarray = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Cookie: '.NGALLERY['transphoto']['cookie']
'Cookie: '.NGALLERY['transphotoapi']['cookie']
));
@ -31,6 +31,10 @@ class UserCTTC {
$xpath = new DOMXPath($dom);
$mainNode = $xpath->query('//td[@class="main"]')->item(0);
$dom = new Dom;
$dom->loadStr($html);
$contents = $dom->find('.p20');
if ($mainNode) {
@ -60,14 +64,24 @@ class UserCTTC {
$dataarray['username'] = $title;
$dataarray['realname'] = $realName;
$dataarray['birthdate'] = $birthDate;
$dataarray['city'] = $city;
$dataarray['regdate'] = $regDate;
$dataarray['photourl'] = "https://transphoto.org/_update_temp/userphotos/".$user_id.".jpg";
$dataarray['about'] = $contents[1];
$this->dataarray = $dataarray;
}
}
public function i($table) {

View file

@ -19,6 +19,7 @@
"symfony/yaml": "^7.1",
"donatj/phpuseragentparser": "^1.8",
"php-ffmpeg/php-ffmpeg": "^1.2",
"chriskonnertz/bbcode": "^1.1"
"chriskonnertz/bbcode": "^1.1",
"paquettg/php-html-parser": "^2.2"
}
}

110
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a512719e60bd14a5a6c28c6f0ea14e46",
"content-hash": "31de33165b326f2edef27c1fc9ae5b08",
"packages": [
{
"name": "aws/aws-crt-php",
@ -716,6 +716,114 @@
},
"time": "2023-08-25T10:54:48+00:00"
},
{
"name": "paquettg/php-html-parser",
"version": "2.2.1",
"source": {
"type": "git",
"url": "https://github.com/paquettg/php-html-parser.git",
"reference": "668c770fc5724ea3f15b8791435f054835be8d5e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paquettg/php-html-parser/zipball/668c770fc5724ea3f15b8791435f054835be8d5e",
"reference": "668c770fc5724ea3f15b8791435f054835be8d5e",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-mbstring": "*",
"ext-zlib": "*",
"paquettg/string-encode": "~1.0.0",
"php": ">=7.1"
},
"require-dev": {
"infection/infection": "^0.13.4",
"mockery/mockery": "^1.2",
"phan/phan": "^2.4",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^7.5.1"
},
"type": "library",
"autoload": {
"psr-4": {
"PHPHtmlParser\\": "src/PHPHtmlParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gilles Paquette",
"email": "paquettg@gmail.com",
"homepage": "http://gillespaquette.ca"
}
],
"description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.",
"homepage": "https://github.com/paquettg/php-html-parser",
"keywords": [
"dom",
"html",
"parser"
],
"support": {
"issues": "https://github.com/paquettg/php-html-parser/issues",
"source": "https://github.com/paquettg/php-html-parser/tree/2.2.1"
},
"time": "2020-01-20T12:59:15+00:00"
},
{
"name": "paquettg/string-encode",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/paquettg/string-encoder.git",
"reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
"reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.5.1"
},
"type": "library",
"autoload": {
"psr-0": {
"stringEncode": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gilles Paquette",
"email": "paquettg@gmail.com",
"homepage": "http://gillespaquette.ca"
}
],
"description": "Facilitating the process of altering string encoding in PHP.",
"homepage": "https://github.com/paquettg/string-encoder",
"keywords": [
"charset",
"encoding",
"string"
],
"support": {
"issues": "https://github.com/paquettg/string-encoder/issues",
"source": "https://github.com/paquettg/string-encoder/tree/1.0.1"
},
"time": "2018-12-21T02:25:09+00:00"
},
{
"name": "php-ffmpeg/php-ffmpeg",
"version": "v1.2.0",

View file

@ -8,15 +8,19 @@ use \App\Models\{User, UserCTTC};
if (explode('@', $_SERVER['REQUEST_URI'])[1] === 'transphoto.org') {
$userprofile = new UserCTTC((int)explode('/', explode('@', $_SERVER['REQUEST_URI'])[0])[2]);
$usercttc = True;
$city = htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutlive']['value']);
$city = $userprofile->i('city');
$regdate = $userprofile->i('regdate');
$photourl = $userprofile->i('photourl');
$about = $userprofile->i('about');
$birthdate = $userprofile->i('birthdate');
} else {
$userprofile = new User(explode('/', $_SERVER['REQUEST_URI'])[2]);
$usercttc = False;
$city = htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutlive']['value']);
$photourl = $userprofile->i('photourl');
$regdate = Date::zmdate($userprofile->content('regdate'));
$about = json_decode($userprofile->i('content'), true)['aboutmemo']['value'];
$birthdate = json_decode($userprofile->i('content'), true)['aboutbirthday']['value'];
}
?>
<!DOCTYPE html>
@ -43,7 +47,7 @@ if (explode('@', $_SERVER['REQUEST_URI'])[1] === 'transphoto.org') {
<?php
if ($usercttc === True) {
echo '<div style="float:left; border:solid 1px #3b7dc1; padding:6px 10px 7px; margin-bottom:13px; background-color:#0199ff44"><b>Профиль на transphoto.org</b><br>Пользователь не зарегистрирован на сервере '.NGALLERY['root']['title'].'. Информация может быть неполной.<br><a href="https://transphoto.org/author/'.$id.'" target="_blank">Открыть на transphoto.org</a></div>';
echo '<div style="float:left; border:solid 1px #3b7dc1; padding:6px 10px 7px; margin-bottom:13px; background-color:#0199ff44"><b>Профиль на transphoto.org</b><br>Пользователь не зарегистрирован на сервере '.NGALLERY['root']['title'].'. Информация может быть неполной.<br><a href="https://transphoto.org/author/'.(int)explode('/', explode('@', $_SERVER['REQUEST_URI'])[0])[2].'" target="_blank">Открыть на transphoto.org</a></div>';
}
if ($userprofile->i('admin') === 1) {
echo 'Администратор сервера';
@ -73,11 +77,12 @@ if (explode('@', $_SERVER['REQUEST_URI'])[1] === 'transphoto.org') {
<td><?= $city ?></td>
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutbirthday']['value'] != null) { ?>
if ($birthdate != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">День рождения:</td>
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutbirthday']['value']) ?></td>
<td><?= $birthdate ?></td>
</tr>
<?php } ?>
</col></table>
@ -224,17 +229,18 @@ if (explode('@', $_SERVER['REQUEST_URI'])[1] === 'transphoto.org') {
</table>
</div>
<?php
if (json_decode($userprofile->i('content'), true)['aboutmemo']['value'] != null) { ?>
if (($about != null) && $usercttc === False) { ?>
<div class="p20" style="margin-top: 8px; background-color: white !important;">
<h4>О себе</h4>
<?php
$bbcode= new ChrisKonnertz\BBCode\BBCode();
$rendered = $bbcode->render(nl2br(htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutmemo']['value'])));
echo $rendered;
<?=
$about
?>
</div>
<?php } ?>
<?php } else if ($usercttc === True) {
echo $about;
} ?>
<div style="margin-top: 25px;"><b><a href="/search?id=<?=$userprofile->i('id')?>">Найти все фотографии, сделанные этим пользователем</a></b></div>