mirror of
https://github.com/ellite/Wallos.git
synced 2026-07-31 02:05:54 -04:00
feat: option for the week to start on sunday feat: redesign login / registration pages feat: more statistics feat: declarative oidc settings feat: grid view for subscriptions feat: subscription details popup feat: translate categories with ai feat: google image search with serpapi feat: selfh.st image search feat: dashboard icons image search fix: improve background removal feature for logos feat: v2.0 api - write endpoints fix: include todays subscriptions on amount due this month fix: calendar occurrences to respect subscription start date fix: honor configured outbound proxy for logo search without reopening httpoxy SSRF bypass fix: remove hardcode string from the admin page fix: ssrf via http proxy env var in payments logo search fix: require cron auth guard on storetotalyearlycost.php fix: validate per-user smtp host against ssrf fix: escape iCal property values to prevent crlf injection
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
require_once '../../includes/connect_endpoint.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
|
die(json_encode(["success" => false]));
|
|
}
|
|
|
|
$apiKey = '';
|
|
if ($db->querySingle("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='google_search'") > 0) {
|
|
$stmt = $db->prepare("SELECT api_key FROM google_search WHERE user_id = :userId");
|
|
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
|
$result = $stmt->execute();
|
|
if ($result && ($row = $result->fetchArray(SQLITE3_ASSOC))) {
|
|
$apiKey = $row['api_key'];
|
|
}
|
|
}
|
|
|
|
if ($apiKey === '') {
|
|
die(json_encode(["success" => false]));
|
|
}
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, 'https://serpapi.com/account?api_key=' . urlencode($apiKey));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Wallos');
|
|
$response = curl_exec($ch);
|
|
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
|
unset($ch);
|
|
|
|
$data = json_decode($response ?: '', true);
|
|
|
|
if ($status !== 200 || !is_array($data) || isset($data['error'])) {
|
|
die(json_encode(["success" => false]));
|
|
}
|
|
|
|
die(json_encode([
|
|
"success" => true,
|
|
"used" => (int) ($data['this_month_usage'] ?? 0),
|
|
"total" => (int) ($data['searches_per_month'] ?? 0),
|
|
"left" => (int) ($data['plan_searches_left'] ?? 0),
|
|
]));
|