mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-15 03:31:10 +03:00
users show from transphoto
This commit is contained in:
parent
4f542c99cf
commit
2180bca050
4 changed files with 118 additions and 3 deletions
|
@ -12,7 +12,7 @@ class LoadRecent
|
||||||
{
|
{
|
||||||
$response = [];
|
$response = [];
|
||||||
|
|
||||||
if ($_POST['serverhost'] === 'transphoto.org') {
|
if ($_POST['serverhost'] != 'transphoto.org') {
|
||||||
$photos = DB::query('SELECT * FROM photos WHERE moderated=1 ORDER BY id DESC LIMIT 30');
|
$photos = DB::query('SELECT * FROM photos WHERE moderated=1 ORDER BY id DESC LIMIT 30');
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class LoadRecent
|
||||||
if (curl_errno($ch)) {
|
if (curl_errno($ch)) {
|
||||||
$response = [
|
$response = [
|
||||||
'error' => 1,
|
'error' => 1,
|
||||||
'errorcode' => 'СТТС не отвечает. Попробуйте позже'
|
'errorcode' => 'СТТС не отвечает. Попробуйте позже',
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$data = json_decode($responsed, true);
|
$data = json_decode($responsed, true);
|
||||||
|
|
111
app/Controllers/Api/Users/LoadUser.php
Normal file
111
app/Controllers/Api/Users/LoadUser.php
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers\Api\Users;
|
||||||
|
|
||||||
|
use \App\Services\{Auth, DB, Date, HTMLParser};
|
||||||
|
use DOMDocument, DOMXPath;
|
||||||
|
|
||||||
|
class LoadUser
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$id = explode('/', $_SERVER['REQUEST_URI'])[4];
|
||||||
|
$user = new \App\Models\User($id);
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
if ($_POST['serverhost'] != 'transphoto.org') {
|
||||||
|
if ($user->i('id') != null) {
|
||||||
|
$response[] = [
|
||||||
|
'id' => $user->i('id'),
|
||||||
|
'username' => $user->i('username'),
|
||||||
|
'regdate' => $user->content('regdate'),
|
||||||
|
'online' => $user->i('online'),
|
||||||
|
'photourl' => $user->i('photourl'),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$response = [
|
||||||
|
'error' => 1,
|
||||||
|
'errorcode' => 'Пользователь не найден'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$url = "https://transphoto.org/author/".$id;
|
||||||
|
|
||||||
|
// Инициализируем cURL
|
||||||
|
$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']
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
$html = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
$dom = new DOMDocument();
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
|
$dom->loadHTML($html);
|
||||||
|
libxml_clear_errors();
|
||||||
|
|
||||||
|
$xpath = new DOMXPath($dom);
|
||||||
|
$mainNode = $xpath->query('//td[@class="main"]')->item(0);
|
||||||
|
|
||||||
|
if ($mainNode) {
|
||||||
|
|
||||||
|
|
||||||
|
$titleNode = $xpath->query('.//h1', $mainNode)->item(0);
|
||||||
|
$title = $titleNode ? $titleNode->textContent : 'Не найдено';
|
||||||
|
|
||||||
|
$realNameNode = $xpath->query('.//tr[td[contains(text(),"Реальное имя:")]]/td[2]/b', $mainNode)->item(0);
|
||||||
|
$realName = $realNameNode ? $realNameNode->textContent : 'Не найдено';
|
||||||
|
|
||||||
|
// Откуда
|
||||||
|
$city = $xpath->query('.//tr[td[contains(text(),"Откуда:")]]/td[2]', $mainNode)->item(0)->textContent;
|
||||||
|
|
||||||
|
// Дата рождения
|
||||||
|
$birthDate = $xpath->query('.//tr[td[contains(text(),"Дата рождения:")]]/td[2]', $mainNode)->item(0)->textContent;
|
||||||
|
|
||||||
|
// Дата регистрации
|
||||||
|
$regDate = $xpath->query('.//tr[td[contains(text(),"Дата регистрации:")]]/td[2]/span', $mainNode)->item(0)->textContent;
|
||||||
|
|
||||||
|
// Рейтинг
|
||||||
|
$rating = $xpath->query('.//tr[td[contains(text(),"Рейтинг:")]]/td[2]/span', $mainNode)->item(0)->textContent;
|
||||||
|
|
||||||
|
// Пол
|
||||||
|
$gender = $xpath->query('.//tr[td[contains(text(),"Пол:")]]/td[2]/span', $mainNode)->item(0)->textContent;
|
||||||
|
|
||||||
|
// Владение языками
|
||||||
|
$languages = $xpath->query('.//tr[td[contains(text(),"Владение языками:")]]/td[2]/span', $mainNode)->item(0)->textContent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$response[] = [
|
||||||
|
'id' => $id,
|
||||||
|
'username' => $title,
|
||||||
|
'online' => 0,
|
||||||
|
'photourl' => 'https://transphoto.org/_update_temp/userphotos/'.$id.'.jpg'
|
||||||
|
];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
echo "Блок не найден.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ use \App\Controllers\Api\Images\Comments\Create as PhotoComment;
|
||||||
use \App\Controllers\Api\Images\Comments\Load as PhotoCommentLoad;
|
use \App\Controllers\Api\Images\Comments\Load as PhotoCommentLoad;
|
||||||
use \App\Controllers\Api\Images\Comments\Rate as PhotoCommentVote;
|
use \App\Controllers\Api\Images\Comments\Rate as PhotoCommentVote;
|
||||||
use \App\Controllers\Api\Profile\Update as ProfileUpdate;
|
use \App\Controllers\Api\Profile\Update as ProfileUpdate;
|
||||||
|
use \App\Controllers\Api\Users\LoadUser as UserLoad;
|
||||||
use \App\Controllers\Api\Admin\Images\SetVisibility as AdminPhotoSetVisibility;
|
use \App\Controllers\Api\Admin\Images\SetVisibility as AdminPhotoSetVisibility;
|
||||||
use \App\Controllers\Api\Admin\CreateNews as AdminCreateNews;
|
use \App\Controllers\Api\Admin\CreateNews as AdminCreateNews;
|
||||||
use \App\Controllers\Api\Admin\LoadNews as AdminLoadNews;
|
use \App\Controllers\Api\Admin\LoadNews as AdminLoadNews;
|
||||||
|
@ -62,6 +63,9 @@ class ApiController
|
||||||
public static function recentphotos() {
|
public static function recentphotos() {
|
||||||
return new PhotoLoadRecent();
|
return new PhotoLoadRecent();
|
||||||
}
|
}
|
||||||
|
public static function loaduser() {
|
||||||
|
return new UserLoad();
|
||||||
|
}
|
||||||
public static function photostats() {
|
public static function photostats() {
|
||||||
return new PhotoStats();
|
return new PhotoStats();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Routes
|
||||||
Router::get('/photoext', 'PhotoController@photoext');
|
Router::get('/photoext', 'PhotoController@photoext');
|
||||||
Router::get('/api/photo/compress', 'ApiController@photocompress');
|
Router::get('/api/photo/compress', 'ApiController@photocompress');
|
||||||
Router::get('/api/photo/loadrecent', 'ApiController@recentphotos');
|
Router::get('/api/photo/loadrecent', 'ApiController@recentphotos');
|
||||||
|
Router::get('/api/users/load/$id', 'ApiController@loaduser');
|
||||||
|
|
||||||
|
|
||||||
if (Auth::userid() > 0) {
|
if (Auth::userid() > 0) {
|
||||||
|
|
Loading…
Reference in a new issue