commit fb29891bb8d2c4716ed78da3bc7e33a2569172ba
parent d71ff582e1b700361de8882c4677e7080d1bf018
Author: William Lindholm <william_lindholm@outlook.com>
Date: Mon, 20 Dec 2021 13:43:10 +0100
Added anti adblock ads.
Diffstat:
3 files changed, 188 insertions(+), 38 deletions(-)
diff --git a/adcash_antiadblock-uxlgv6qq.php b/adcash_antiadblock-uxlgv6qq.php
@@ -0,0 +1,148 @@
+<?php
+
+class AdcashAntiAdblock_uxlgv6qq
+{
+ const ADCASH_ZONE_ID = 'uxlgv6qq';
+ const ADCASH_ZONE_TYPE = 'atag';
+ const ADCASH_SERVER_DOMAIN = 'onclickalgo.com';
+ const ADCASH_FALLBACK_DOMAIN = 'acscdn.com';
+
+ /**
+ * @IMPORTANT: Do not modify anything below this line
+ */
+ const CACHE_FILENAME = 'adblock_{TARGET}.cache';
+ const TIMEOUT_MS = 200;
+ const CONNECT_TIMEOUT_MS = 1000;
+ const ADBLOCK_UA_VERSION = 'Adcash Anti-AdBlock client v1.1';
+ const CACHE_TTL = 600;
+ private $response = '';
+ private $hasResponse = false;
+
+ /**
+ * @return string
+ */
+ public function run()
+ {
+ $prevErrorState = error_reporting(0);
+ $this->fallback();
+
+ $this->getFromCache();
+ if (!$this->hasResponse) {
+ $this->request();
+ $this->setCache();
+ }
+ error_reporting($prevErrorState);
+ return $this->response;
+ }
+
+ /**
+ * Call our gateway for a fresh new adblock script
+ */
+ private function request()
+ {
+ $serviceDomain = self::ADCASH_SERVER_DOMAIN;
+ $query = http_build_query(array(
+ 'zone_id' => self::ADCASH_ZONE_ID,
+ 'zone_type' => self::ADCASH_ZONE_TYPE,
+ ));
+ $targetUrl = "http://{$serviceDomain}/ad/s2sadblock.php?{$query}";
+
+ $ch = curl_init($targetUrl);
+ curl_setopt_array($ch, array(
+ CURLOPT_RETURNTRANSFER => 1,
+ CURLOPT_CONNECTTIMEOUT_MS => self::CONNECT_TIMEOUT_MS,
+ CURLOPT_TIMEOUT_MS => self::TIMEOUT_MS,
+ CURLOPT_USERAGENT => self::ADBLOCK_UA_VERSION,
+ CURLOPT_FOLLOWLOCATION => false,
+ CURLOPT_SSL_VERIFYPEER => true,
+ ));
+ $response = curl_exec($ch);
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+
+ curl_close($ch);
+ if (strlen($response) && $statusCode == '200') {
+ $this->response = $response;
+ $this->hasResponse = true;
+ }
+ }
+
+ private function fallback()
+ {
+ $patterns = array(
+ 'atag' => '<script type="text/javascript" src="//{DOMAIN_TARGET}/script/atg.js" czid="{ZONE_TARGET}" data-adel="atag"></script>',
+ 'suv4' => '<script type="text/javascript" src="//{DOMAIN_TARGET}/script/suv4.js" zid="{ZONE_TARGET}" data-adel="lwsu"></script>',
+ 'ippg' => '<script type="text/javascript" src="//{DOMAIN_TARGET}/script/ippg.js" zid="{ZONE_TARGET}" data-adel="ippg"></script>',
+ 'ippf' => '<script type="text/javascript" src="//{DOMAIN_TARGET}/script/ippf.js" zid="{ZONE_TARGET}" data-adel="inpage"></script>',
+ );
+ if (isset($patterns[self::ADCASH_ZONE_TYPE])) {
+ $this->response = strtr($patterns[self::ADCASH_ZONE_TYPE], array(
+ '{DOMAIN_TARGET}' => self::ADCASH_FALLBACK_DOMAIN,
+ '{ZONE_TARGET}' => self::ADCASH_ZONE_ID,
+ ));
+ }
+ }
+
+ private function getFromCache()
+ {
+ $this->invalidateCache();
+ $cacheFile = $this->getFullCachePath();
+ $cacheContents = '';
+ if (file_exists($cacheFile) && is_readable($cacheFile)) {
+ $cacheContents = file_get_contents($cacheFile);
+ }
+ if (strlen($cacheContents)) {
+ $this->hasResponse = true;
+ $this->response = $cacheContents;
+ }
+ }
+
+ private function setCache()
+ {
+ if (!$this->hasResponse) {
+ return;
+ }
+ $cacheFile = $this->getFullCachePath();
+ @touch($cacheFile);
+ if (file_exists($cacheFile)) {
+ file_put_contents($cacheFile, $this->response);
+ }
+ }
+
+ private function invalidateCache()
+ {
+ $cacheFile = $this->getFullCachePath();
+ if (!file_exists($cacheFile) || !is_readable($cacheFile)) {
+ return;
+ }
+ $createdTime = (int) filemtime($cacheFile);
+ if ($createdTime + self::CACHE_TTL < time()) {
+ unlink($cacheFile);
+ }
+ }
+
+ private function getFullCachePath()
+ {
+ $filename = strtr(self::CACHE_FILENAME, array('{TARGET}' => self::ADCASH_ZONE_ID));
+ $tempPath = $this->getTemporaryDirectory();
+ return $tempPath . DIRECTORY_SEPARATOR . $filename;
+ }
+
+ private function getTemporaryDirectory()
+ {
+ if (function_exists('sys_get_temp_dir')) {
+ return sys_get_temp_dir();
+ } elseif (!empty($_ENV['TMP'])) {
+ $dir = $_ENV['TMP'];
+ } elseif (!empty($_ENV['TMPDIR'])) {
+ $dir = $_ENV['TMPDIR'];
+ } elseif (!empty($_ENV['TEMP'])) {
+ $dir = $_ENV['TEMP'];
+ } else {
+ $dir = __DIR__;
+ }
+ return realpath($dir);
+ }
+}
+
+$adblock = new AdcashAntiAdblock_uxlgv6qq();
+echo $adblock->run();
+\ No newline at end of file
diff --git a/index.html b/index.html
@@ -1,38 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" >
-
- <head>
-
- <meta charset="UTF-8">
- <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
- <title>Bored Button 3</title>
- <link rel="stylesheet" href="./style.css">
- <link rel="icon" href="images/favicon.png">
- <meta name="a.validate.01" content="1abf335a434c48c0346f4f159c9baceb4b12" />
-
- </head>
-
- <body class="noselect">
- <script src="//acscdn.com/script/ippg.js" data-adel="inpage" zid="5407851" rr="0" mads="2"></script>
- <div id="banner-ad">
- <script data-cfasync="false" type="text/javascript" src="https://www.onclickalgo.com/a/display.php?r=5407855"></script>
- </div>
- <canvas id="bang" width="800" height="800"></canvas>
-
- <script src="./script.js"></script>
-
- <div class="bg">
- <p class="headline">BOREDBUTTON<sup>3</p>
- </div>
-
- <div class="main" id="main">
- <button onclick="showFact()" id="button" type="button"></button>
- </div>
-
- <p id="fact_text"></p>
-
- </body>
-
- <footer>© 2022 BoredButton3 | All rights reserved | By William ∧ Francisco</footer>
-
-</html>
diff --git a/index.php b/index.php
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang="en" >
+
+ <head>
+
+ <meta charset="UTF-8">
+ <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
+ <title>Bored Button 3</title>
+ <link rel="stylesheet" href="./style.css">
+ <link rel="icon" href="images/favicon.png">
+ <meta name="a.validate.01" content="1abf335a434c48c0346f4f159c9baceb4b12" />
+
+ </head>
+
+ <body class="noselect">
+ <?php require_once "/adcash_antiadblock-uxlgv6qq.php"; ?>
+ <script src="//acscdn.com/script/ippg.js" data-adel="inpage" zid="5407851" rr="0" mads="2"></script>
+ <div id="banner-ad">
+ <script data-cfasync="false" type="text/javascript" src="https://www.onclickalgo.com/a/display.php?r=5407855"></script>
+ </div>
+ <canvas id="bang" width="800" height="800"></canvas>
+
+ <script src="./script.js"></script>
+
+ <div class="bg">
+ <p class="headline">BOREDBUTTON<sup>3</p>
+ </div>
+
+ <div class="main" id="main">
+ <button onclick="showFact()" id="button" type="button"></button>
+ </div>
+
+ <p id="fact_text"></p>
+
+ </body>
+
+ <footer>© 2022 BoredButton3 | All rights reserved | By William ∧ Francisco</footer>
+
+</html>