108 lines
2.9 KiB
PHP
108 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
// File sources, images & scripts
|
|
$TRANSING_FILES = [
|
|
"enby" => [
|
|
"left_arrow" => "../../../img/webrings/transfem_enby_left_arrow.png",
|
|
"button" => "../../../img/webrings/transfem_enby_button.png",
|
|
"right_arrow" => "../../../img/webrings/transfem_enby_right_arrow.png"
|
|
],
|
|
"trans" => [
|
|
"left_arrow" => "../../../img/webrings/transfem_trans_left_arrow.png",
|
|
"button" => "../../../img/webrings/transfem_trans_button.png",
|
|
"right_arrow" => "../../../img/webrings/transfem_trans_right_arrow.png"
|
|
],
|
|
"cloud" => [
|
|
"left_arrow" => "../../../img/webrings/transfem_cloud_left_arrow.png",
|
|
"button" => "../../../img/webrings/transfem_cloud_button.png",
|
|
"right_arrow" => "../../../img/webrings/transfem_cloud_right_arrow.png"
|
|
]
|
|
];
|
|
|
|
$TRANSING_SCRIPT_SOURCE = [
|
|
"selected_source" => 1,
|
|
"sources" =>
|
|
[["url" => "https://transring.neocities.org/ring.js",
|
|
"source" => "internet"],
|
|
["url" => "/transingtheinternet.js",
|
|
"source" => "local"]]
|
|
];
|
|
|
|
// Specific variables for script
|
|
$TRANSING_ROOT = "https://transring.neocities.org";
|
|
$TRANSING_VALID_WIDGET_TYPES = ["cloud", "enby", "trans","error"];
|
|
|
|
// Personal identifiers/choices
|
|
$TRANSING_WIDGET_TYPE = $TRANSING_VALID_WIDGET_TYPES[1];
|
|
$TRANSING_ID = 1;
|
|
|
|
// Functions
|
|
function transingSplit(string $array) {
|
|
$array = preg_replace('/\s+/', '', $array);
|
|
$i = 0;
|
|
while (strlen($array) !== 0) {
|
|
|
|
// Strip coma if found
|
|
if (str_starts_with($array,',')) {
|
|
$array = substr($array,1);
|
|
}
|
|
if (str_starts_with(strrev($array),',')) {
|
|
$array = substr($array,0,-1);
|
|
}
|
|
|
|
$temp = strpos($array,'/',1);
|
|
|
|
if (strpos($array,'/',1) > 1 or strpos($array,'/',1) == FALSE) {
|
|
$commented=FALSE;
|
|
} else {
|
|
$commented=TRUE;
|
|
}
|
|
|
|
|
|
if (str_starts_with($array,',')) {
|
|
$array = substr($array,1);
|
|
}
|
|
|
|
// Get substring position and length
|
|
$commented ? $start_pos=3 : $start_pos=1;
|
|
$end_pos = strpos($array,"\"",$start_pos);
|
|
$item_len = $end_pos - $start_pos;
|
|
|
|
if (!$commented){
|
|
$return_array[$i] = substr($array,$start_pos,$item_len);
|
|
} else {
|
|
$return_array[$i] = '';
|
|
}
|
|
|
|
// Save website into array, and strip array
|
|
if (!$commented) {
|
|
$item_len = $item_len +2; // +2 from " and "
|
|
} else {
|
|
$item_len = $item_len +4; // +4 from ", ", / and /
|
|
}
|
|
|
|
$array = substr($array,$item_len);
|
|
|
|
$i++;
|
|
}
|
|
|
|
return $return_array;
|
|
}
|
|
|
|
$transing_sites = scrapeWebsiteSites($TRANSING_SCRIPT_SOURCE,'sites :[',']');
|
|
$transing_sites = transingSplit($transing_sites);
|
|
|
|
for ($i = 0; $i < count($transing_sites); $i++){
|
|
if ($i == $TRANSING_ID) {
|
|
$transing_prev = 'https://' . $transing_sites[($i-1)];
|
|
$transing_current = 'https://' . $transing_sites[($i)];
|
|
$transing_next = 'https://' . $transing_sites[($i+1)];
|
|
$found = TRUE;
|
|
}
|
|
}
|
|
|
|
if (!isset($found)) {
|
|
echo ("ERROR ID NOT FOUND");
|
|
} |