From 3a11453dd1d5d13cc30cbd50d2541565bf615f2f Mon Sep 17 00:00:00 2001 From: Rick Kuzik Date: Wed, 30 Apr 2025 09:17:36 -0600 Subject: [PATCH] Init import --- .htaccess | 10 ++++++++ .prettierrc | 17 ++++++++++++++ _footer.html | 5 ++++ _header.html | 15 ++++++++++++ _meta.html | 7 ++++++ add-site.php | 59 ++++++++++++++++++++++++++++++++++++++++++++++ app.js | 18 ++++++++++++++ config.ini | 3 +++ config.php | 3 +++ index.php | 53 +++++++++++++++++++++++++++++++++++++++++ lib/template.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ list-site.php | 48 +++++++++++++++++++++++++++++++++++++ main.css | 19 +++++++++++++++ reset.css | 55 +++++++++++++++++++++++++++++++++++++++++++ site-add.sh | 29 +++++++++++++++++++++++ site-del.sh | 16 +++++++++++++ site-list.sh | 10 ++++++++ 17 files changed, 428 insertions(+) create mode 100644 .htaccess create mode 100644 .prettierrc create mode 100644 _footer.html create mode 100644 _header.html create mode 100644 _meta.html create mode 100644 add-site.php create mode 100644 app.js create mode 100644 config.ini create mode 100644 config.php create mode 100644 index.php create mode 100644 lib/template.php create mode 100644 list-site.php create mode 100644 main.css create mode 100644 reset.css create mode 100755 site-add.sh create mode 100755 site-del.sh create mode 100755 site-list.sh diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..7dd428b --- /dev/null +++ b/.htaccess @@ -0,0 +1,10 @@ +# Remote access +Require ip 68.147.189.97 +Require ip 96.53.11.174 +Require ip 127.0.0.1 +Require ip 137.184.238.236 + +#Require all granted + + + diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..47ff1bb --- /dev/null +++ b/.prettierrc @@ -0,0 +1,17 @@ +{ + "printWidth": 100, + "proseWrap": "always", + "semi": false, + "singleQuote": true, + "braceStyle": "1tbs", + "tabWidth": 3, + "plugins": [ + "@prettier/plugin-php" + ], + "overrides": [ + { + "files": "*.php", + "options": { "parser": "html" } + } + ] +} diff --git a/_footer.html b/_footer.html new file mode 100644 index 0000000..ffa9ce5 --- /dev/null +++ b/_footer.html @@ -0,0 +1,5 @@ + + + diff --git a/_header.html b/_header.html new file mode 100644 index 0000000..16fdb64 --- /dev/null +++ b/_header.html @@ -0,0 +1,15 @@ + diff --git a/_meta.html b/_meta.html new file mode 100644 index 0000000..60823d8 --- /dev/null +++ b/_meta.html @@ -0,0 +1,7 @@ +{title} + + + + + + diff --git a/add-site.php b/add-site.php new file mode 100644 index 0000000..e76f8bc --- /dev/null +++ b/add-site.php @@ -0,0 +1,59 @@ +
+
+
+
+ + +
+
+
+
+
Append
+ +
+
+
+ +
+
+
+src = $_POST['src'] . '.tr.jit-tr.com'; + $payload->site = 'https://' . $_POST['site']; + $payload->append = $_POST['append']; + + error_log(json_encode($payload)); + + $ch = curl_init($cfg['API_ENDPOINT_REDIRECTS']); + + curl_setopt_array($ch, [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => true, + CURLOPT_HTTPHEADER => [ + 'Accept: application/json', + 'Content-Type: application/json', + "X-API-Key: $cfg[API_KEY]" + ], + CURLOPT_POSTFIELDS => json_encode($payload), + ]); + + $response = curl_exec($ch); + + if (curl_errno($ch)) { + echo 'Curl error: ' . curl_error($ch); + curl_close($ch); + exit; + } else { + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + header('Location: list-site.php'); + echo "HTTP Status Code: $httpCode\n"; + echo "Response:\n$response"; + curl_close($ch); + } + +} diff --git a/app.js b/app.js new file mode 100644 index 0000000..64f4e43 --- /dev/null +++ b/app.js @@ -0,0 +1,18 @@ +/* Add site scipts */ +((func) => { + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", func); + } else { + func(); + } +})( + ()=>{ + const input_src = document.querySelector('input[name=src]') + const em = document.querySelector('input[name=src] ~ em') + em.innerText = input_src.value + + input_src.onkeyup=(e)=>{ + em.innerText = e.target.value + } + } +) diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..a672e27 --- /dev/null +++ b/config.ini @@ -0,0 +1,3 @@ +API_KEY='24cb8ac71d5c6ee99f3da398e1234ae3dbf1cfaa86750711d9b63032caeaa164' +API_ENDPOINT_REDIRECTS="https://pr.sr.jit-tr.com/pr-admin/api/redirects" + diff --git a/config.php b/config.php new file mode 100644 index 0000000..2811839 --- /dev/null +++ b/config.php @@ -0,0 +1,3 @@ + + + + + 'Hello World' ]) ?> + + + + + + +
+ +
+ +
+
+ +
+
+ + + + + + + diff --git a/lib/template.php b/lib/template.php new file mode 100644 index 0000000..34a369d --- /dev/null +++ b/lib/template.php @@ -0,0 +1,61 @@ +'Home Page', ... ] + */ +function snippet_include($filename, $context=[]) { + $snippet = file_get_contents($filename); + + // Handle comments {* ... *} + $snippet = preg_replace('/ *{\*(.*?)\*}\n*/s','',$snippet); + + // Use regex to find {placeholders} in the template + // Note this uses a callback function to do the matches + $snippet = preg_replace_callback('/\{\s*(\w+)\s*\}/', function($matches) use ($context) { + $key = $matches[1]; + + $value = isset($context[$key]) ? $context[$key] : $key; + + return $value; + }, $snippet); + + return $snippet; +} + diff --git a/list-site.php b/list-site.php new file mode 100644 index 0000000..a39e015 --- /dev/null +++ b/list-site.php @@ -0,0 +1,48 @@ +
 true,
+    CURLOPT_FOLLOWLOCATION => false,
+    CURLOPT_RETURNTRANSFER => true,
+    CURLOPT_HTTPHEADER => [
+        'X-API-Key: ' . $cfg['API_KEY'],
+        'accept: application/json',
+    ],
+]);
+
+$response = curl_exec($ch);
+
+if (!curl_errno($ch) && curl_getinfo($ch)['http_code'] === 200) {
+  $rows = json_decode($response);
+} else {
+  var_dump(curl_getinfo($ch)['http_code']);
+  var_dump(curl_error($ch));
+}
+curl_close($ch);
+?>
+
+
+
+  
+
+
+
+safe_append = htmlentities($row->append);
+    echo "\n";
+    echo "";
+    echo "";
+    echo "";
+    echo "";
+    echo "\n";
+  }
+?>
+
+
Entry SourceRedirect toAppendActions
src}\">{$row->src}{$row->site}{$row->safe_append}
+Add another one diff --git a/main.css b/main.css new file mode 100644 index 0000000..af629e0 --- /dev/null +++ b/main.css @@ -0,0 +1,19 @@ +:root { + --theme-primary: #7952B3; +} + +nav.navbar-dark { + background-color: var(--theme-primary); +} + +body { + min-height: 100vh; + display: flex; + flex-direction: column; +} + +textarea[name='append'] { + background-color: #3b2c1d; + color: #ccc; + height: 130px; +} diff --git a/reset.css b/reset.css new file mode 100644 index 0000000..1b1902c --- /dev/null +++ b/reset.css @@ -0,0 +1,55 @@ +/* https://www.joshwcomeau.com/css/custom-css-reset/ */ +/* 1. Use a more-intuitive box-sizing model */ +*, *::before, *::after { + box-sizing: border-box; +} + +/* 2. Remove default margin */ +* { + margin: 0; +} + +/* 3. Enable keyword animations */ +@media (prefers-reduced-motion: no-preference) { + html { + interpolate-size: allow-keywords; + } +} + +body { + /* 4. Add accessible line-height */ + line-height: 1.5; + /* 5. Improve text rendering */ + -webkit-font-smoothing: antialiased; +} + +/* 6. Improve media defaults */ +img, picture, video, canvas, svg { + display: block; + max-width: 100%; +} + +/* 7. Inherit fonts for form controls */ +input, button, textarea, select { + font: inherit; +} + +/* 8. Avoid text overflows */ +p, h1, h2, h3, h4, h5, h6 { + overflow-wrap: break-word; +} + +/* 9. Improve line wrapping */ +p { + text-wrap: pretty; +} +h1, h2, h3, h4, h5, h6 { + text-wrap: balance; +} + +/* + 10. Create a root stacking context +*/ +#root, #__next { + isolation: isolate; +} diff --git a/site-add.sh b/site-add.sh new file mode 100755 index 0000000..366e9e3 --- /dev/null +++ b/site-add.sh @@ -0,0 +1,29 @@ +#!/bin/bash +if [[ -z $2 ]] +then + echo "USAGE: $0 example.com example.tr.jit-tr.com" + echo "" + exit +fi + +src=$2 +site=https://$1 + +. config.ini + +PAYLOAD=$(cat <" +} +EOF +) + +curl -s -X 'POST' \ + "$API_ENDPOINT_REDIRECTS" \ + -H 'accept: application/json' \ + -H "x-api-key: $API_KEY" \ + -H 'Content-Type: application/json' \ + -d "$PAYLOAD" + diff --git a/site-del.sh b/site-del.sh new file mode 100755 index 0000000..fe6aa5c --- /dev/null +++ b/site-del.sh @@ -0,0 +1,16 @@ +#!/bin/bash +if [[ -z $1 ]] +then + echo "USAGE: $0 {uniqueid}" + echo "" + exit +fi + +id=$1 + +. config.ini + +curl -s -X 'DEL' \ + "$API_ENDPOINT_REDIRECTS/$id" \ + -H 'accept: application/json' \ + -H "x-api-key: $API_KEY" diff --git a/site-list.sh b/site-list.sh new file mode 100755 index 0000000..87de898 --- /dev/null +++ b/site-list.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +. config.ini + +curl -s -X 'GET' \ + "$API_ENDPOINT_REDIRECTS" \ + "https://$DOMAIN/admin/api/redirects" \ + -H 'accept: application/json' \ + -H "x-api-key: $API_KEY" | jq . +