Compare commits
2
Commits
03373bc7bb
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12fd0b11a8 | ||
|
|
3a11453dd1 |
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+17
@@ -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" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<footer>
|
||||||
|
<p>Copy © 2025</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js" integrity="sha512-ykZ1QQr0Jy/4ZkvKuqWn4iF3lqPZyij9iRv6sGqLRdTPkY69YX6+7wvVGmsdBbiIfN/8OdsI7HABjvEok6ZopQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<nav class="navbar navbar-dark navbar-expand">
|
||||||
|
<div class="container">
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-nav" aria-controls="main-nav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand">{project}</a>
|
||||||
|
<div id="main-nav" class="collapse navbar-collapse flex-grow-0">
|
||||||
|
<ul class="navbar-nav me-auto">
|
||||||
|
<li class="nav-item"><a class="nav-link active">Services</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link">News</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link">Documentation</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<title>{title}</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" integrity="sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
|
|
||||||
|
<link rel="icon" type="image/x-icon" href="/meta/favicon.ico">
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<form method="post">
|
||||||
|
<div class="row gx-3">
|
||||||
|
<div class="col-4">
|
||||||
|
<div class="p-3 border rounded-3 h-100">
|
||||||
|
<label class="form-label"><span class="form-text">Src </span> <input class="form-control" name="src" placeholder="example" required><em>example</em>.tr.jit-tr.com</label>
|
||||||
|
<label class="form-label"><span class="form-text">Site </span><input class="form-control" name="site" placeholder="example.com" required></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="p-3 border rounded-3 h-100">
|
||||||
|
<div class="form-text">Append</div>
|
||||||
|
<textarea class="form-control" name="append"><script src="https://dev.api.jit-tr.com"></script></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 mt-3">
|
||||||
|
<button class="btn btn-primary" type="submit">Add new site</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
if (count($_POST)!==0) {
|
||||||
|
require('config.php');
|
||||||
|
error_log(json_encode($_POST));
|
||||||
|
|
||||||
|
$payload= (object)[];
|
||||||
|
$payload->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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
API_KEY='24cb8ac71d5c6ee99f3da398e1234ae3dbf1cfaa86750711d9b63032caeaa164'
|
||||||
|
API_ENDPOINT_REDIRECTS="https://pr.sr.jit-tr.com/pr-admin/api/redirects"
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$cfg = parse_ini_file('config.ini');
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'config.php';
|
||||||
|
require_once 'lib/template.php';
|
||||||
|
|
||||||
|
# Necessary since I'm not using RewriteRule
|
||||||
|
$basehref = dirname($_SERVER['SCRIPT_NAME']);
|
||||||
|
|
||||||
|
if (isset($_SERVER['PATH_INFO'])) {
|
||||||
|
if ($_SERVER['PATH_INFO'] === '/' ) {
|
||||||
|
$contents = include_path('/list-site.php');
|
||||||
|
} else {
|
||||||
|
$contents = include_path($_SERVER['PATH_INFO']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header("Location: {$_SERVER['SCRIPT_NAME']}/");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head lang="en">
|
||||||
|
<?= snippet_include('_meta.html', ['title'=>'Hello World' ]) ?>
|
||||||
|
|
||||||
|
<!-- cache breaking -->
|
||||||
|
<link rel="stylesheet" href="<?= $basehref ?>/main.css?<?= time() ?>">
|
||||||
|
<style>
|
||||||
|
/*
|
||||||
|
main,footer,.container,.row { border: 1px dashed #ffab27; }
|
||||||
|
*/
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="mb-5">
|
||||||
|
<?= snippet_include('_header.html') ?>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="bg-body-tertiary flex-grow-1">
|
||||||
|
<div class="container">
|
||||||
|
<?= $contents ?>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<div class="container">
|
||||||
|
<?= snippet_include('_footer.html') ?>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- cache breaking -->
|
||||||
|
<script src="<?= $basehref ?>/app.js?<?= time() ?>"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include_path
|
||||||
|
*
|
||||||
|
* uses a partial url, eg '/foo' to locate a corresponding
|
||||||
|
* php file, eg 'foo.php', and execute it.
|
||||||
|
*
|
||||||
|
* url_fragment - a key to locating php files, no extetension
|
||||||
|
letters and hyphens are ok
|
||||||
|
*/
|
||||||
|
function include_path($url_fragment) {
|
||||||
|
if (preg_match('#^/([a-z-]+.php)$#', $url_fragment, $matches)) {
|
||||||
|
$path = __DIR__ . '/../' . $matches[1];
|
||||||
|
} else {
|
||||||
|
$path = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($path)) {
|
||||||
|
ob_start();
|
||||||
|
include $path;
|
||||||
|
$result = ob_get_clean();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
# Hard bail
|
||||||
|
http_response_code(404);
|
||||||
|
echo "404: $path not found\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* snippet_include
|
||||||
|
*
|
||||||
|
* loads non_php file for parsing.
|
||||||
|
* Uses {varname} to replace strings
|
||||||
|
*
|
||||||
|
* filename
|
||||||
|
* context - a keyed array for matching
|
||||||
|
* eg [ 'title'=>'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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<pre><?php
|
||||||
|
require('config.php');
|
||||||
|
|
||||||
|
$rows = [];
|
||||||
|
$ch = curl_init($cfg['API_ENDPOINT_REDIRECTS']);
|
||||||
|
|
||||||
|
// Set curl options
|
||||||
|
curl_setopt_array($ch, [
|
||||||
|
CURLOPT_FAILONERROR => 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);
|
||||||
|
?>
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Entry Source</th><th>Redirect to</th><th>Append</th><th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$row->safe_append = htmlentities($row->append);
|
||||||
|
echo "<tr>\n";
|
||||||
|
echo "<td><a target=\"_blank\" href=\"https://{$row->src}\">{$row->src}</a></td>";
|
||||||
|
echo "<td>{$row->site}</td>";
|
||||||
|
echo "<td>{$row->safe_append}</td>";
|
||||||
|
echo "<td><button name=\"delete\" data-id=\"{$row->_id}\">🚮</button><button name=\"edit\" data-id=\"{$row->_id}\">✎</button></td>";
|
||||||
|
echo "</tr>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<a class="btn btn-primary" href="add-site.php">Add another one</a>
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
Executable
+29
@@ -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
|
||||||
|
{
|
||||||
|
"src": "$src",
|
||||||
|
"site": "$site",
|
||||||
|
"append": "<script src=\"https://api.jit-tr.com/\"></script>"
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
|
||||||
Executable
+16
@@ -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"
|
||||||
Executable
+10
@@ -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 .
|
||||||
|
|
||||||
Reference in New Issue
Block a user