0.9.0 - the ZapV version updated to current php standards. Brave search used, while Bing and Google search api are deprecated

This commit is contained in:
Fabian de Boer 2026-07-15 13:57:05 +02:00
commit 4ddaddda3d
31 changed files with 1778 additions and 1 deletions

28
utils/Log.class.php Executable file
View file

@ -0,0 +1,28 @@
<?php
/**
* Puts log information on images in two files
*/
class Log {
private $folder;
private $logFileName;
private $logFileXmlName;
function __construct($imgFolder) {
$this->folder = $imgFolder;
$this->logFileName = $imgFolder . DIRECTORY_SEPARATOR . 'log.txt';
$this->logFileXmlName = $imgFolder . DIRECTORY_SEPARATOR . 'log.xml';
}
public function addToLog($type, $head, $addString) {
$addToLog = "$head $addString" . PHP_EOL;
$addToXmlLog = "<div class=\"$type\">" . PHP_EOL . "\t<strong>$head</strong>" . PHP_EOL;
$addToXmlLog .= "\t<p>$addString</p>" . PHP_EOL . "</div>" . PHP_EOL;
$txtOk = @file_put_contents($this->logFileName, $addToLog, FILE_APPEND);
$xmlOk = @file_put_contents($this->logFileXmlName, $addToXmlLog, FILE_APPEND);
}
}
?>

63
utils/Session.class.php Executable file
View file

@ -0,0 +1,63 @@
<?php
/**
* Basic session wrapper / adapter
*/
class Session {
/**
* Start session
* @param string $name name of session
* @param string $path override ini directive session.save_path
*/
public static function start($name, $path = null) {
$started = false;
if (!$started) {
session_name($name);
if ($path !== null) {
session_save_path($path);
}
session_start();
$started = true;
}
Session::setCacheControl('private');
}
/**
* Set cache control
* @param string $value sets the http cache control value
*/
public static function setCacheControl($value) {
header('Cache-Control: ' . $value);
}
/**
* reset session array
*/
public static function reset() {
$_SESSION = array();
}
/**
* delete client's cookie
*/
public static function deleteCookie() {
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
}
/**
* Destroy session completely
* @return boolean
*/
public static function destroy() {
self::reset();
self::deleteCookie();
if (session_destroy()) {
return true;
} else {
return false;
}
}
}
?>

64
utils/ZAPCurl.class.php Executable file
View file

@ -0,0 +1,64 @@
<?php
class ZAPCurl {
private $url;
private $binary;
private $referer;
private $headers = array();
public $error = null;
public $httpCode = null;
//private $proxyIp = '127.0.0.1:81';
public function __construct($url, $binary = false) {
$this->url = $url;
$this->binary = $binary;
}
/**
* Set a custom header for the request
* @param string $key Header name
* @param string $value Header value
*/
public function setHeader($key, $value) {
$this->headers[] = $key . ': ' . $value;
}
/**
* Curl wrapper
* @param string $url
* @param boolean $binary
* @return mixed $curlData
*/
public function fetchCurlData() {
$cUrl = curl_init();
curl_setopt($cUrl, CURLOPT_URL, $this->url);
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cUrl, CURLOPT_TIMEOUT, ZAP_CURL_TIMEOUT);
if (isset($this->referer)) {
curl_setopt($cUrl, CURLOPT_REFERER, $this->referer);
}
if (!empty($this->headers)) {
curl_setopt($cUrl, CURLOPT_HTTPHEADER, $this->headers);
}
//curl_setopt($cUrl, CURLOPT_PROXY, $this->proxyIp);
$curlData = curl_exec($cUrl);
$this->error = curl_error($cUrl);
$this->httpCode = curl_getinfo($cUrl, CURLINFO_HTTP_CODE);
// curl_close() is deprecated as of PHP 8.5 (no effect since PHP 8.0)
if ($this->error) {
error_log('ZAPCurl error: ' . $this->error . ' URL: ' . $this->url);
} elseif ($this->httpCode >= 400) {
error_log('ZAPCurl HTTP ' . $this->httpCode . ' URL: ' . $this->url);
}
return $curlData;
}
}
?>