PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
plugins
/
vxcash
/
admin
<?php class Vxcash_Visitx_Graphql_Client { const URL_GRAPHQL = 'https://graphql.api.visit-x.net/vxql?language=DE'; /** * @var Vxcash_Config */ public $config; private $amount = 30; private $offset = 0; public function __construct(Vxcash_Config $config) { $this->config = $config; } /** * @param array $filter * @param array $knownVideos * @param int $fsk * @param int $maxLoad * * @return array */ public function getVideos($filter = [], $knownVideos = [], $fsk = 18, $maxLoad = 30) { $this->offset = 0; $found = []; $filter = array_filter( $filter, function ($item) { return $item !== null; } ); do { $query = $this->createVideoQuery($filter); $result = $this->postQuery($query); if ($result instanceof WP_Error) { return array_slice($found, 0, $maxLoad); } $data = json_decode($result['body'], true); $new = $data['data']['videos_v2']['items']; $filtered = array_filter( $new, function ($item) use ($knownVideos, $fsk) { if (in_array($item['id'], $knownVideos, true)) { return false; } return $fsk >= $item['preview']['ageRating']; } ); $found = array_merge($found, $filtered); $this->offset += $this->amount; } while (count($found) < $maxLoad && count($new) !== 0 && $this->offset / $this->amount < 10); return array_slice($found, 0, $maxLoad); } public function createFilter($type, $value) { switch ($type) { case 'geschlecht': return 'actingGroups:' . $value; case 'darsteller': return 'modelIds:[' . $value . ']'; case 'tag': return 'tags:"' . $value . '"'; case 'preis': return 'types:{' . $value . ':true}'; case 'alter': $now = new DateTime(); switch ($value) { case '1d': $interval = new DateInterval('P1D'); break; case '1w': $interval = new DateInterval('P1W'); break; case '1m': $interval = new DateInterval('P1M'); break; case '3m': $interval = new DateInterval('P3M'); break; case '6m': $interval = new DateInterval('P6M'); break; case '1y': $interval = new DateInterval('P1Y'); break; case '2y': default: $interval = new DateInterval('P2Y'); break; } return 'releasedFrom:"' . $now->sub($interval) ->format(DATE_ATOM) . '"'; } return null; } public function getOnlineHostIds() { $limit = 50; $offset = 0; $ids = []; do { $query = "query{models(first:$limit,offset:$offset,filter:{online:true}){id}}"; $result = $this->postQuery($query); if ($result instanceof WP_Error) { return $ids; } $data = json_decode($result['body'], true); $currentIds = array_map(function($item) { return $item['id']; }, $data['data']['models']); $ids = array_merge($ids, $currentIds); $offset += $limit; } while (count($currentIds) > 0); return $ids; } private function createVideoQuery($filter) { $q = sprintf( "query{videos_v2(first:%d,offset:%d %s){items{id title description duration(format:min)released ageRating price{value currency}preview{url(size:w800)ageRating}previewVideo{url mimeType}model{id name}tags audio rating{likes dislikes}viewCount linkVX}}}", $this->amount, $this->offset, count($filter) > 0 ? ' filter:{' . implode(' ', $filter) . '}' : '' ); $q = $this->cleanQuery($q); return $q; } private function createModelQuery($modelId) { $q = "query { model(id:$modelId) { id name linkVX avatar { url(size:w800) } profile { age hairColor size weight city country cupSize sexuality female male couple texts { questionJob { answer } questionRelationshipStatus { answer } questionLookingFor { answer } questionHobbiesText { answer } questionWomanPubicHair { answer } } showText(language:\"DE\") } } } "; $q = $this->cleanQuery($q); return $q; } /** * @param int $modelId * * @return array */ public function getModel($modelId) { $query = $this->createModelQuery($modelId); $result = $this->postQuery($query); if ($result instanceof WP_Error) { return []; } $data = json_decode($result['body'], true); return $data['data']['model']; } /** * @return array('modelIds' => int[], 'albumIds' => int[]) */ public function getDeletedHostAndAlbumIds() { $query = 'query { recentlyDeleted { modelIds albumIds } }'; $query = $this->cleanQuery($query); $result = $this->postQuery($query); if ($result instanceof WP_Error) { return ['modelIds' => [], 'albumIds' => []]; } $data = json_decode($result['body'], true); return $data['data']['recentlyDeleted']; } /** * @param int[] $hostIds * * @return int[] */ public function getReturnedHostIds($hostIds) { $reinstated = array(); $chunked = array_chunk($hostIds, 30); foreach ($chunked as $chunk) { $q = 'query{'; $count = 1; foreach ($chunk as $hostId) { $q .= sprintf( ' u%s: model(id: %s){ id } ', $count, $hostId ); $count++; } $q .= '}'; $q = $this->cleanQuery($q); $result = $this->postQuery($q); if ($result instanceof WP_Error) { return []; } $data = json_decode($result['body'], true); foreach ($data['data'] as $name => $value) { if (is_array($value) && isset($value['id']) && is_numeric($value['id'])) { $reinstated[] = $value['id']; } } } return $reinstated; } /** * @param $videoIds * * @return int[] */ public function getReturnedVideoIds($videoIds) { $reinstated = array(); $chunked = array_chunk($videoIds, 30); foreach ($chunked as $chunk) { $q = 'query{'; $count = 1; foreach ($chunk as $videoId) { $q .= sprintf( ' v%s: video(id: %s){ id } ', $count, $videoId ); $count++; } $q .= '}'; $q = $this->cleanQuery($q); $result = $this->postQuery($q); if ($result instanceof WP_Error) { return []; } $data = json_decode($result['body'], true); foreach ($data['data'] as $name => $value) { if (is_array($value) && isset($value['id']) && is_numeric($value['id'])) { $reinstated[] = $value['id']; } } } return $reinstated; } /** * @param string $query * * @return array|WP_Error */ private function postQuery($query) { return wp_safe_remote_post( self::URL_GRAPHQL, [ 'headers' => ['Authorization' => 'Bearer ' . $this->config->getVisitxApiKey()], 'body' => json_encode(['query' => $query]), ] ); } /** * @param string $q * * @return string */ private function cleanQuery($q) { return preg_replace('/[\r\n\t ]+/', ' ', $q); } }
[-] index.php
[edit]
[+]
js
[-] class-vxcash-debug-admin.php
[edit]
[-] class-vxcash-visitx-video-admin.php
[edit]
[-] class-vxcash-auto-import-dataprovider.php
[edit]
[-] class-vxcash-config.php
[edit]
[+]
partials
[-] class-vxcash-admin.php
[edit]
[-] class-vxcash-host-category-handler.php
[edit]
[-] class-vxcash-notifier.php
[edit]
[+]
..
[+]
css
[-] class-vxcash-visitx-host-admin.php
[edit]
[-] class-vxcash-visitx-graphql-client.php
[edit]
[-] class-vxcash-pornme-video-admin.php
[edit]
[-] class-vxcash-vx-dataprovider.php
[edit]