Skip to content

Commit

Permalink
wrapper 2.4, changed PROXY config, docker php82
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Sep 27, 2023
1 parent 9d9207b commit 7c333b1
Show file tree
Hide file tree
Showing 7 changed files with 622 additions and 75 deletions.
6 changes: 1 addition & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
# JSON cache, used on Helpers\CacheEngines\JSONCache
# API_CACHE_JSON=/tmp/proxitok_api # Path for JSON API Cache, leave commented for ./cache/api

# Proxy Config
# PROXY_HOST=http://EXAMPLE_IP # Host to be used as proxy, make sure to type a valid protocol. Available: http:// | https:// | socks4:// | socks5://
# PROXY_PORT=8080
# PROXY_USERNAME=username
# PROXY_PASSWORD=password
# PROXY="https://user:password@host:port" # Host to be used as proxy, make sure to type a valid protocol. Available: http:// | https:// | socks4:// | socks5://

# USER_AGENT="Mozilla/5.0 (Android 12; Mobile; rv:109.0) Gecko/109.0 Firefox/109.0"
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM trafex/php-nginx:3.1.0
FROM trafex/php-nginx:3.4.0

# Add composer
COPY --from=composer /usr/bin/composer /usr/bin/composer

# Copy config
COPY ./misc/setup/docker/php.ini /etc/php81/conf.d/settings.ini
COPY ./misc/setup/docker/php.ini /etc/php82/conf.d/settings.ini

USER root
# Create cache folder
RUN mkdir /cache && chown -R nobody:nogroup /cache
# Install deps
RUN apk add --no-cache php81-redis php81-zip php81-tokenizer
RUN apk add --no-cache php82-redis php82-zip php82-tokenizer
USER nobody

# Copy source
Expand Down
4 changes: 2 additions & 2 deletions app/Helpers/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class ErrorHandler {
public static function showMeta(Meta $meta) {
http_response_code($meta->http_code);
Wrappers::latte('error', new ErrorTemplate($meta->http_code, $meta->tiktok_msg, $meta->tiktok_code));
http_response_code($meta->httpCode);
Wrappers::latte('error', new ErrorTemplate($meta->httpCode, $meta->proxitokMsg, $meta->proxitokCode));
}

public static function showText(int $code, string $msg) {
Expand Down
16 changes: 5 additions & 11 deletions app/Helpers/Wrappers.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,10 @@ public static function api(): \TikScraper\Api {
];

// -- PROXY CONFIG -- //
$proxy_host = Misc::env('PROXY_HOST', '');
$proxy_port = Misc::env('PROXY_PORT', '');

if ($proxy_host && $proxy_port) {
$options['proxy'] = [
'host' => $proxy_host,
'port' => $proxy_port,
'username' => Misc::env('PROXY_USERNAME', null),
'password' => Misc::env('PROXY_PASSWORD', null)
];
$proxy = Misc::env('PROXY', '');

if ($proxy !== '') {
$options['proxy'] = $proxy;
}

// Cache config
Expand All @@ -183,7 +177,7 @@ public static function api(): \TikScraper\Api {
$password = $url['pass'] ?? null;
} else {
$host = $_ENV['REDIS_HOST'];
$port = (int) $_ENV['REDIS_PORT'];
$port = intval($_ENV['REDIS_PORT']);
$password = isset($_ENV['REDIS_PASSWORD']) ? $_ENV['REDIS_PASSWORD'] : null;
}
$cacheEngine = new RedisCache($host, $port, $password);
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pablouser1/proxitok",
"description": "An alternative frontend for TikTok",
"version": "2.4.9.2",
"version": "2.4.9.3",
"license": "AGPL-3.0-or-later",
"type": "project",
"authors": [
Expand All @@ -19,11 +19,11 @@
},
"require": {
"php": ">=7.4|^8.0",
"ext-redis": "^5.3.2",
"ext-redis": "^5.3.2|^6.0.0",
"ext-mbstring": "*",
"latte/latte": "^2.11",
"bramus/router": "^1.6",
"pablouser1/tikscraper": "^2.3",
"pablouser1/tikscraper": "^2.4",
"josegonzalez/dotenv": "^4.0"
},
"autoload": {
Expand Down
Loading

0 comments on commit 7c333b1

Please sign in to comment.