Added possibility for the client environment
parent
13795e4fd1
commit
d02983408c
|
@ -11,4 +11,5 @@ auth/certs/
|
||||||
auth/js/auth.js.map
|
auth/js/auth.js.map
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
web/*-environment/
|
web/*-environment/
|
||||||
|
client-api/environment
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: WolverinDEV
|
||||||
|
* Date: 04.10.18
|
||||||
|
* Time: 16:42
|
||||||
|
*/
|
||||||
|
|
||||||
|
$BASE_PATH = "files/";
|
||||||
|
|
||||||
|
if(!isset($_SERVER['REQUEST_METHOD'])) {
|
||||||
|
error_log("This is a web only script!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_dir($base_dir, &$results = array(), $dir = "") {
|
||||||
|
$files = scandir($base_dir . $dir);
|
||||||
|
|
||||||
|
foreach($files as $key => $value){
|
||||||
|
$path = $base_dir.$dir.DIRECTORY_SEPARATOR.$value;
|
||||||
|
if(!is_dir($path)) {
|
||||||
|
$results[] = ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value;
|
||||||
|
} else if($value != "." && $value != "..") {
|
||||||
|
list_dir($base_dir, $results, ($dir ? $dir.DIRECTORY_SEPARATOR : "").$value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function endsWith($haystack, $needle) {
|
||||||
|
// search forward starting from end minus needle length characters
|
||||||
|
if ($needle === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$diff = \strlen($haystack) - \strlen($needle);
|
||||||
|
return $diff >= 0 && strpos($haystack, $needle, $diff) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fdump($name) {
|
||||||
|
if(endsWith($name, ".php")) {
|
||||||
|
global $CLIENT;
|
||||||
|
$CLIENT = true;
|
||||||
|
|
||||||
|
include $name;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$file = fopen($name, "r") or die(json_encode([
|
||||||
|
"success" => false,
|
||||||
|
"error" => "missing file (" . $name . ")"
|
||||||
|
]));
|
||||||
|
|
||||||
|
echo (fread($file, filesize($name)));
|
||||||
|
fclose($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_develop_web_request() {
|
||||||
|
global $BASE_PATH;
|
||||||
|
|
||||||
|
if($_GET["type"] === "files") {
|
||||||
|
header("Content-Type: text/plain");
|
||||||
|
header("info-version: 1");
|
||||||
|
/* header("mode: develop"); */
|
||||||
|
|
||||||
|
echo ("type\thash\tpath\tname\n");
|
||||||
|
foreach (list_dir($BASE_PATH) as $file) {
|
||||||
|
$type_idx = strrpos($file, ".");
|
||||||
|
$type = substr($file, $type_idx + 1);
|
||||||
|
if($type == "php") $type = "html";
|
||||||
|
|
||||||
|
$name_idx = strrpos($file, "/");
|
||||||
|
$name = $name_idx > 0 ? substr($file, $name_idx + 1) : $file;
|
||||||
|
$path = $name_idx > 0 ? substr($file, 0, $name_idx) : ".";
|
||||||
|
|
||||||
|
$name_idx = strrpos($name, ".");
|
||||||
|
$name = substr($name, 0, $name_idx);
|
||||||
|
|
||||||
|
echo $type . "\t" . sha1_file($BASE_PATH . $file) . "\t" . $path . "\t" . $name . "." . $type . "\n";
|
||||||
|
}
|
||||||
|
die;
|
||||||
|
} else if($_GET["type"] === "file") {
|
||||||
|
header("Content-Type: text/plain");
|
||||||
|
|
||||||
|
$path = realpath($BASE_PATH . $_GET["path"]);
|
||||||
|
$name = $_GET["name"];
|
||||||
|
if($path === False || strpos($path, realpath(".")) === False || strpos($name, "/") !== False) die(json_encode([
|
||||||
|
"success" => false,
|
||||||
|
"error" => "invalid file!"
|
||||||
|
]));
|
||||||
|
|
||||||
|
if(!is_file( $path . DIRECTORY_SEPARATOR . $name)) {
|
||||||
|
if(endsWith($name, ".html")) {
|
||||||
|
$name = substr($name, 0, strlen($name) - 4);
|
||||||
|
$name .= "php";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!is_file( $path . DIRECTORY_SEPARATOR . $name))
|
||||||
|
die(json_encode([
|
||||||
|
"success" => false,
|
||||||
|
"error" => "missing file!"
|
||||||
|
]));
|
||||||
|
|
||||||
|
fdump( $path . DIRECTORY_SEPARATOR . $name);
|
||||||
|
die();
|
||||||
|
} else die(json_encode([
|
||||||
|
"success" => false,
|
||||||
|
"error" => "invalid action!"
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_develop_web_request();
|
|
@ -1,54 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: WolverinDEV
|
|
||||||
* Date: 04.10.18
|
|
||||||
* Time: 16:42
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(!isset($_SERVER['REQUEST_METHOD'])) {
|
|
||||||
error_log("This is a web only script!");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
include "../files.php";
|
|
||||||
function handle_develop_web_request() {
|
|
||||||
if($_GET["type"] === "files") {
|
|
||||||
header("Content-Type: text/plain");
|
|
||||||
header("info-version: 1");
|
|
||||||
header("mode: develop");
|
|
||||||
|
|
||||||
echo ("type\thash\tpath\tname\n");
|
|
||||||
foreach (find_files(0b10, "../") as $file) {
|
|
||||||
echo $file->type . "\t" . $file->hash . "\t" . $file->path . "\t" . $file->name . "\n";
|
|
||||||
}
|
|
||||||
echo "html\t".sha1("main")."\t.\tindex.html\n";
|
|
||||||
die;
|
|
||||||
} else if($_GET["type"] === "file") {
|
|
||||||
header("Content-Type: text/plain");
|
|
||||||
|
|
||||||
$available_files = find_files(0b10, "../");
|
|
||||||
foreach ($available_files as $entry) {
|
|
||||||
if(($entry->path == $_GET["path"]) && ($entry->name == $_GET["name"])) {
|
|
||||||
fdump($entry->local_path);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($_GET["name"] == "index.html") {
|
|
||||||
global $CLIENT;
|
|
||||||
$CLIENT = true;
|
|
||||||
include "../index.php";
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
die(json_encode([
|
|
||||||
"success" => false,
|
|
||||||
"error" => "missing file!"
|
|
||||||
]));
|
|
||||||
} else die(json_encode([
|
|
||||||
"success" => false,
|
|
||||||
"error" => "invalid action!"
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_develop_web_request();
|
|
44
files.php
44
files.php
|
@ -107,7 +107,7 @@
|
||||||
"local-path" => "./web/html/"
|
"local-path" => "./web/html/"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"web-only" => true,
|
/* "web-only" => true, */ //Currently client as well
|
||||||
"type" => "html",
|
"type" => "html",
|
||||||
"search-pattern" => "/.*\.(php|html)/",
|
"search-pattern" => "/.*\.(php|html)/",
|
||||||
"search-exclude" => "/(files.php)/",
|
"search-exclude" => "/(files.php)/",
|
||||||
|
@ -202,16 +202,6 @@
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fdump($name) {
|
|
||||||
$file = fopen($name, "r") or die(json_encode([
|
|
||||||
"success" => false,
|
|
||||||
"error" => "missing file (" . $name . ")"
|
|
||||||
]));
|
|
||||||
|
|
||||||
echo (fread($file, filesize($name)));
|
|
||||||
fclose($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($_SERVER["argv"])) { //Executed by command line
|
if(isset($_SERVER["argv"])) { //Executed by command line
|
||||||
if(strpos(PHP_OS, "Linux") == -1) {
|
if(strpos(PHP_OS, "Linux") == -1) {
|
||||||
error_log("Invalid operating system! Help tool only available under linux!");
|
error_log("Invalid operating system! Help tool only available under linux!");
|
||||||
|
@ -251,7 +241,7 @@
|
||||||
$environment = "web/dev-environment";
|
$environment = "web/dev-environment";
|
||||||
} else if ($_SERVER["argv"][2] == "client") {
|
} else if ($_SERVER["argv"][2] == "client") {
|
||||||
$flagset = 0b10;
|
$flagset = 0b10;
|
||||||
$environment = "client/dev-environment";
|
$environment = "client-api/environment/files";
|
||||||
} else {
|
} else {
|
||||||
error_log("Invalid type!");
|
error_log("Invalid type!");
|
||||||
goto help;
|
goto help;
|
||||||
|
@ -263,7 +253,7 @@
|
||||||
$environment = "web/rel-environment";
|
$environment = "web/rel-environment";
|
||||||
} else if ($_SERVER["argv"][2] == "client") {
|
} else if ($_SERVER["argv"][2] == "client") {
|
||||||
$flagset = 0b10;
|
$flagset = 0b10;
|
||||||
$environment = "client/rel-environment";
|
$environment = "client-api/environment/files";
|
||||||
} else {
|
} else {
|
||||||
error_log("Invalid type!");
|
error_log("Invalid type!");
|
||||||
goto help;
|
goto help;
|
||||||
|
@ -275,9 +265,10 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
exec($command = "rm -r " . $environment, $output, $state);
|
exec($command = "rm -r " . $environment, $output, $state);
|
||||||
exec($command = "mkdir " . $environment, $output, $state); if($state) goto handle_error;
|
exec($command = "mkdir -p " . $environment, $output, $state); if($state) goto handle_error;
|
||||||
|
|
||||||
$files = find_files(0b01, "./", $type);
|
$files = find_files($flagset, "./", $type);
|
||||||
|
$original_path = realpath(".");
|
||||||
if(!chdir($environment)) {
|
if(!chdir($environment)) {
|
||||||
error_log("Failed to enter directory " . $environment . "!");
|
error_log("Failed to enter directory " . $environment . "!");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -289,22 +280,35 @@
|
||||||
if($state) goto handle_error;
|
if($state) goto handle_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = substr_count(realpath($file->path), DIRECTORY_SEPARATOR) - substr_count(realpath('.'), DIRECTORY_SEPARATOR);
|
$parent_base = substr_count(realpath($file->path), DIRECTORY_SEPARATOR) - substr_count(realpath('.'), DIRECTORY_SEPARATOR);
|
||||||
|
$parent_file = substr_count(realpath("."), DIRECTORY_SEPARATOR) - substr_count($original_path, DIRECTORY_SEPARATOR); //Current to parent
|
||||||
|
$parent = $parent_base + $parent_file;
|
||||||
|
|
||||||
$path = "../../";
|
$path = "";
|
||||||
for($index = 0; $index < $parent; $index++)
|
for($index = 0; $index < $parent; $index++)
|
||||||
$path = $path . "../";
|
$path = $path . "../";
|
||||||
exec($command = "ln -s " . $path . $file->local_path . " " . $file->path, $output, $state);
|
exec($command = "ln -s " . $path . $file->local_path . " " . $file->path, $output, $state);
|
||||||
if($state) goto handle_error;
|
if($state) goto handle_error;
|
||||||
echo $command . PHP_EOL;
|
echo $command . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
if(!chdir($original_path)) {
|
||||||
|
error_log("Failed to reset directory!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
echo "Generated!" . PHP_EOL;
|
echo "Generated!" . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($_SERVER["argv"][2] == "client") {
|
||||||
|
if(!chdir("client-api/environment")) {
|
||||||
|
error_log("Failed to enter directory client-api/environment!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
exec($command = "ln -s ../api.php ./", $output, $state);
|
||||||
|
if($state) goto handle_error;
|
||||||
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
handle_error:
|
handle_error:
|
||||||
error_log("Failed to execute command '" . $command . "'!");
|
error_log("Failed to execute command '" . $command . "'!");
|
||||||
error_log("Command returned code " . $state . ". Output: " . PHP_EOL);
|
error_log("Command returned code " . $state . ". Output: " . PHP_EOL);
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logged_in() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$localhost = true;
|
$localhost = true;
|
||||||
}
|
}
|
||||||
$localhost |= gethostname() == "WolverinDEV";
|
$localhost |= gethostname() == "WolverinDEV";
|
||||||
|
@ -88,6 +92,7 @@
|
||||||
</div>
|
</div>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<?php if(!$CLIENT) { ?>
|
||||||
<!-- No javascript error -->
|
<!-- No javascript error -->
|
||||||
<div style="display: block; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color: gray; z-index: 1000; text-align: center;" class="no-js">
|
<div style="display: block; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color: gray; z-index: 1000; text-align: center;" class="no-js">
|
||||||
<div style="position: relative; display: inline-block; top: 30%">
|
<div style="position: relative; display: inline-block; top: 30%">
|
||||||
|
@ -102,6 +107,7 @@
|
||||||
while (elements.length > 0) //Removing these elements (even self)
|
while (elements.length > 0) //Removing these elements (even self)
|
||||||
elements.item(0).remove();
|
elements.item(0).remove();
|
||||||
</script>
|
</script>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<!-- Loading screen -->
|
<!-- Loading screen -->
|
||||||
<div class="loader">
|
<div class="loader">
|
||||||
|
@ -140,13 +146,11 @@
|
||||||
<div style="align-self: center;">TeaSpeak Web client by WolverinDEV</div>
|
<div style="align-self: center;">TeaSpeak Web client by WolverinDEV</div>
|
||||||
<div style="align-self: center; position: fixed; right: 5px;">
|
<div style="align-self: center; position: fixed; right: 5px;">
|
||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
if(logged_in()) {
|
if(logged_in()) {
|
||||||
echo '<a href="' . authPath() . '"auth.php?type=logout>logout</a>';
|
echo '<a href="' . authPath() . '"auth.php?type=logout>logout</a>';
|
||||||
} else {
|
} else {
|
||||||
echo '<a href="' . authPath() . '"login.php>Login</a> via the TeaSpeak forum.';
|
echo '<a href="' . authPath() . '"login.php>Login</a> via the TeaSpeak forum.';
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -245,7 +245,7 @@ function loadSide() {
|
||||||
console.log("Loading node specific things");
|
console.log("Loading node specific things");
|
||||||
const app = require('electron').remote.app;
|
const app = require('electron').remote.app;
|
||||||
module.paths.push(app.getAppPath());
|
module.paths.push(app.getAppPath());
|
||||||
window.$ = require("jquery");
|
window.$ = require("assets/jquery.min.js");
|
||||||
require("native/loader_adapter.js");
|
require("native/loader_adapter.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,12 +264,12 @@ function loadSide() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Load the general scripts and required scripts
|
//Load the general scripts and required scripts
|
||||||
awaitLoad(loadScripts([
|
(window.require !== undefined ? Promise.resolve(true) : awaitLoad(loadScripts([
|
||||||
["vendor/jquery/jquery.min.js", /*"https://code.jquery.com/jquery-latest.min.js"*/],
|
["vendor/jquery/jquery.min.js"],
|
||||||
|
]))).then(() => awaitLoad(loadScripts([
|
||||||
["vendor/bbcode/xbbcode.js"],
|
["vendor/bbcode/xbbcode.js"],
|
||||||
["https://webrtc.github.io/adapter/adapter-latest.js"]
|
["https://webrtc.github.io/adapter/adapter-latest.js"]
|
||||||
])).then(() => {
|
]))).then(() => awaitLoad(loadScripts([
|
||||||
}).then(() => awaitLoad(loadScripts([
|
|
||||||
//["https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"]
|
//["https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"]
|
||||||
["vendor/jsrender/jsrender.min.js"]
|
["vendor/jsrender/jsrender.min.js"]
|
||||||
]))).then(() => {
|
]))).then(() => {
|
||||||
|
|
Loading…
Reference in New Issue