Compare commits

..

3 commits

Author SHA1 Message Date
whotookelburg
aaa9eb154c Merge branch 'master' of https://basedwa.re/elburg/sts
oops i need to do shit
2023-02-24 08:29:42 +00:00
whotookelburg
8f0b94bd6c sorry im too tired to write a git log so just know that i did some shit to sts okay? thanks! <3 2023-02-24 08:28:19 +00:00
whotookelburg
b201dbfc75 some stuff :3
adding support for text / terminal browsers
redone some strings
2023-02-24 05:20:09 +00:00
21 changed files with 293 additions and 69 deletions

0
about.php Normal file
View file

View file

@ -2,6 +2,18 @@ body {
background-color: #262631; background-color: #262631;
color: white; color: white;
} }
div.header{
top: 0%;
}
div.header.left{
left: 0%;
}
div.header.right{
right: 0%;
}
hr{
width: 100%;
}
a:link { a:link {
color: cyan; color: cyan;
} }

View file

View file

@ -1,15 +1,20 @@
locale_en_native = "English" interactions_adv_aboutx = "About $"
locale_en_this = "English" interactions_basic_about = "About"
region_us_native = "United States"
region_us_this = "United States"
misc_stslogohover = "sts logo"
meta_project_name = "super tiny search"
meta_project_desc = "a super lightweight and privacy-centered search engine!"
interactions_basic_cancel = "Cancel" interactions_basic_cancel = "Cancel"
interactions_basic_no = "No" interactions_basic_no = "No"
interactions_basic_okay = "OK" interactions_basic_okay = "OK"
interactions_basic_yes = "Yes"
interactions_basic_search = "Search" interactions_basic_search = "Search"
interactions_basic_about = "About" interactions_basic_yes = "Yes"
interactions_adv_aboutx = "About $" interactions_choose_tp_acceptnew = "Accept"
interactions_searcharea_hint = "Search query" interactions_searcharea_hint = "Search query"
locale_en_native = "English"
locale_en_this = "English"
meta_project_desc = "a super lightweight and privacy-centered search engine!"
meta_project_name = "super tiny search"
misc_stslogohover = "sts logo"
region_br = "Brazil"
region_ca = "Canada"
region_us = "United States"
results_found = "found %n results"
results_foundonlyone = "found 1 result"
results_none = "no results found"

View file

@ -1,5 +0,0 @@
a = '<hr><a href="%s">%s</a>: %s'
b = 'running v%s'
ca = 'if there are problems with this page or any other page, contact'
cb = 'if there are problems with this page or any other page, contact either'
d = '&emsp;%s&emsp;(<a href="mailto:%s">email</a>)'

View file

@ -1,3 +0,0 @@
results_found = "found $ results"
results_foundonlyone = "found 1 result"
results_none = "no results found"

View file

@ -1 +0,0 @@
interactions_choose_tp_acceptnew = "Accept"

View file

@ -0,0 +1 @@
/^w3m/

View file

@ -1,6 +1,7 @@
<?php <?php require 'src/loadEnv.php';
if(!$_GET && !$_POST){ if(!$_GET && !$_POST){
http_response_code(400); http_response_code(400);
include 'src/debug/dumpSuperGlobals.php';
die; die;
} }
if($_GET['content']=='aboutserver'){ if($_GET['content']=='aboutserver'){
@ -12,5 +13,7 @@
echo $out; echo $out;
echo '</body></html>'; echo '</body></html>';
die; die;
}else{
include 'src/debug/dumpSuperGlobals.php';
} }
?> ?>

View file

@ -1,40 +1,5 @@
<?php <?php require 'src/loadEnv.php';?>
libxml_use_internal_errors(true); <!--<?php $_SERVER['HTTP_USER_AGET'];?>-->
// load config
$cfg=parse_ini_file("serve.ini", true);
// load locale
#$lang=locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lang="en_US";
$strings=parse_ini_file("data/locale/".$lang."/strings/main.ini");
// cookies
if(!isset($_COOKIE['sts_theme'])){
setcookie('sts_theme','default');
$_COOKIE['sts_theme'] = 'default';
}
if(!isset($_COOKIE['sts_scripting'])){
setcookie('sts_scripting','none');
$_COOKIE['sts_scripting'] = 'none';
}
if(!isset($_COOKIE['sts_flags'])){
setcookie('sts_flags',file_get_contents('data/xml/default.flags.xml'));
$_COOKIE['sts_flags'] = simplexml_load_file('data/xml/default.flags.xml') or die('failed loading an xml file!');
}else{
$_COOKIE['sts_flags'] = simplexml_load_string($_COOKIE['sts_flags']);
}
if ($_COOKIE['sts_flags'] === false) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo "An error occured within superTinySearch!\n\nWhat happened:\tfailed to parse cookie 'sts_flags'!\n\nAdditional info:\n";
foreach(libxml_get_errors() as $error) {
echo "\n\t", $error->message;
}
die(sprintf("\n\ncontact %s @ %s",$cfg['MAINTAINERS_0']['name'],$cfg['MAINTAINERS_0']['email']));
}
?>
<html> <html>
<head> <head>
<title><?php echo $cfg['META']['name']; ?></title> <title><?php echo $cfg['META']['name']; ?></title>
@ -46,18 +11,11 @@
</head> </head>
<body> <body>
<?php <?php
echo "<h1 title=\"".$strings['misc_stslogohover']."\">".file_get_contents("data/misc/icon/html.html")."</h1><br>"; if ($_GET['fpage']==="text"){
require 'src/pages/text/index.php';
}else{
require 'src/pages/modern/index.php';
}
?> ?>
<?php
echo "<div class=\"searchbox\"><form id=\"searchbox\">\n";
echo "<input class=\"sbox\" type=\"".$_COOKIE['sts_flags']['index']['sbox_type']."\" placeholder=\"".$strings['interactions_searcharea_hint']."\" name=\"query\">";
echo "<input type=\"submit\" value=\"".$strings['interactions_basic_search']."\">\n";
echo "</form></div>"
?>
<iframe style="position:absolute;bottom:30px;right:10px;" src="dynamicGen.php?content=aboutserver" width="376" height="276"></iframe>
<div class="footer">
<div class="footeri right">
<a
</body> </body>
</html> </html>

View file

@ -0,0 +1,52 @@
<?php
libxml_use_internal_errors(true);
// load config
$cfg=parse_ini_file("serve.ini", true);
// load locale
#$lang=locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lang="en_US";
$strings=array_merge(
parse_ini_file("data/locale/".$lang."/strings/main.ini"),
parse_ini_file("data/locale/".$lang."/strings/search.ini")
);
// cookies
if(!isset($_COOKIE['sts_theme'])){
setcookie('sts_theme','default');
$_COOKIE['sts_theme'] = 'default';
}
if(!isset($_COOKIE['sts_scripting'])){
setcookie('sts_scripting','none');
$_COOKIE['sts_scripting'] = 'none';
}
if(!isset($_COOKIE['sts_flags'])){
setcookie('sts_flags',file_get_contents('data/xml/default.flags.xml'));
$_COOKIE['sts_flags'] = simplexml_load_file('data/xml/default.flags.xml') or die('failed loading an xml file!');
}else{
$_COOKIE['sts_flags'] = simplexml_load_string($_COOKIE['sts_flags']);
}
if ($_COOKIE['sts_flags'] === false) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo "An error occured within superTinySearch!\n\nWhat happened:\tfailed to parse cookie 'sts_flags'!\n\nAdditional info:\n";
foreach(libxml_get_errors() as $error) {
echo "\n\t", $error->message;
}
die(sprintf("\n\ncontact %s @ %s",$cfg['MAINTAINERS_0']['name'],$cfg['MAINTAINERS_0']['email']));
}else{
require 'src/validateSTSXML.php';
validateXML($_COOKIE['sts_flags'],'flags');
}
?>
<html>
<head>
<title><?php echo sprintf('%s - %s',$_GET['query'],$cfg['META']['name']); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
echo "<link rel=\"stylesheet\" href=\"assets/themes/".$_COOKIE['sts_theme']."/main.css\">";
echo "<link rel=\"stylesheet\" href=\"assets/themes/".$_COOKIE['sts_theme']."/search.css\">";
?>
</head>
</html>

View file

@ -0,0 +1,118 @@
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Value</th>
</tr>
<?php
$femboysAreCute=true;
$_SERVER;$_REQUEST;$_SESSION;$_ENV;
function calcRows($str){
return preg_match_all("/\n/",$str)+1;
}
function calcCols($str){
$cur=0;
$top=0;
foreach(mb_str_split($str) as $char){
if ($char=="\n"){
$cur=0;
}else{
$cur++;
if ($cur>=$top){
$top=$cur;
}
}
}
return $top;
}
function row($k,$v){
// echo "<!--\trow() called!\t\$k:\t$k\t\t\$v:\t$v\t-->\n";
echo "<tr>\n";
echo "\t<td>$k</td>\n";
echo sprintf("\t<td>%s</td>\n",gettype($v));
echo "\t<td>";
if (gettype($v)=="string"){
echo "<textarea rows=\"".calcRows($v)."\" cols=\"".calcCols($v)."\" readonly=\"true\">$v</textarea>";
}elseif (gettype($v)=="array"){
echo "";
}elseif (gettype($v)=="boolean"){
echo "<font style=\"color:";
if ($v){
echo "green\">True";
}else{
echo "red\">False";
}
echo "</font>";
}else{
echo $v;
}
echo "</td>\n</tr>\n";
}
function loop($kn,$a){
// echo "<!--\tloop() called!\t\$kn:\t$kn\t\t\$a:\t$a\t-->\n";
foreach ($a as $key => $val) {
// echo "<!--\tforeach() called!\t\$key:\t$key\t\t\t\$val:\t$val\t-->\n";
if($key!="GLOBALS"){
row($kn."/$".$key,$val);
if(gettype($val)=="array"){
loop($kn."/\$".$key,$val);
}
}else{
echo "";
}
}
}
loop("\$GLOBALS",$GLOBALS);
// foreach ($_SERVER as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_SERVER".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
// foreach ($_GET as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_GET".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
// foreach ($_POST as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_POST".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
// foreach ($_FILES as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_FILES".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
// foreach ($_COOKIE as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_COOKIE".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
// foreach ($_REQUEST as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_REQUEST".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
// foreach ($_ENV as $key => $val) {
// echo "\t<tr>";
// echo $b."\$_ENV".$c."td>";
// echo $b.$key.$c."td>";
// echo $b.$val.$c."td>\n";
// echo "\t".$c."tr>\n";
// }
?>
</table>

5
src/determineBrowser.php Normal file
View file

@ -0,0 +1,5 @@
<?php
function &parseUserAgent(ua_string): ?string {
}
?>

0
src/error.php Normal file
View file

40
src/loadEnv.php Normal file
View file

@ -0,0 +1,40 @@
<?php
libxml_use_internal_errors(true);
// load config
$cfg=parse_ini_file("serve.ini", true);
// load locale
#$lang=locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lang="en_US";
$strings=parse_ini_file("data/locale/".$lang.".ini");
// cookies
if(!isset($_COOKIE['sts_theme'])){
setcookie('sts_theme','default');
$_COOKIE['sts_theme'] = 'default';
}
if(!isset($_COOKIE['sts_scripting'])){
setcookie('sts_scripting','none');
$_COOKIE['sts_scripting'] = 'none';
}
if(!isset($_COOKIE['sts_flags'])){
setcookie('sts_flags',file_get_contents('data/xml/default.flags.xml'));
$_COOKIE['sts_flags'] = simplexml_load_file('data/xml/default.flags.xml') or die('failed loading an xml file!');
}else{
$_COOKIE['sts_flags'] = simplexml_load_string($_COOKIE['sts_flags']);
}
if ($_COOKIE['sts_flags'] === false) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo "An error occured within superTinySearch!\n\nWhat happened:\tfailed to parse cookie 'sts_flags'!\n\nAdditional info:\n";
foreach(libxml_get_errors() as $error) {
echo "\n\t", $error->message;
}
die(sprintf("\n\ncontact %s @ %s",$cfg['MAINTAINERS_0']['name'],$cfg['MAINTAINERS_0']['email']));
}else{
require 'src/validateSTSXML.php';
validateXML($_COOKIE['sts_flags'],'flags');
}
?>

View file

@ -1,3 +1,8 @@
# aboutpage_a = '<hr><a href="%s">%s</a>: %s'
# aboutpage_b = 'running v%s'
# aboutpage_ca = 'if there are problems with this page or any other page, contact'
# aboutpage_cb = 'if there are problems with this page or any other page, contact either'
# aboutpage_d = '&emsp;%s&emsp;(<a href="mailto:%s">email</a>)'
<?php <?php
function &genAbout($language): ?string{ function &genAbout($language): ?string{
$strings=array_merge( $strings=array_merge(

View file

@ -0,0 +1,15 @@
<?php
echo "<h1 title=\"".$strings['misc_stslogohover']."\">".file_get_contents("data/misc/icon/html.html")."</h1><br>";
?>
<?php
echo "<div class=\"searchbox\"><form id=\"searchbox\">\n";
echo "<input class=\"sbox\" type=\"".$_COOKIE['sts_flags']['index']['sbox_type']."\" placeholder=\"".$strings['interactions_searcharea_hint']."\" name=\"query\">";
echo "<input type=\"submit\" action=\"search.php\" formmethod=\"get\" value=\"".$strings['interactions_basic_search']."\">\n";
echo "</form></div>"
?>
<iframe style="position:absolute;bottom:30px;right:10px;" src="dynamicGen.php?content=aboutserver" width="376" height="276"></iframe>
<div class="footer">
<div class="footeri right">
</div>
</div>

0
src/pages/text/about.php Normal file
View file

View file

@ -0,0 +1,9 @@
<hr>
<footer>
<div class="footer left">
</div>
<div class="footer right">
</div>
</footer>

View file

@ -0,0 +1,9 @@
<header>
<div class="header left">
<a href="index.php">[sts]</a>
</div>
<div class="header right">
<a href="about.php">About</a>
</div>
</header>
<hr>

1
src/pages/text/index.php Normal file
View file

@ -0,0 +1 @@
<?php include 'header.php'; ?>