Skip to content

Commit

Permalink
Update Addressing
Browse files Browse the repository at this point in the history
  • Loading branch information
mimfa committed Dec 31, 2024
1 parent 515c95e commit 71fd181
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ To create a new subdomain, with all accessibility and equipment, for an aseqbase
2. Copy and replace all files and folders to the home directory (public_html) of the website
### To make the Sub Domain of aseqbase website
2. Copy and replace all files and folders to your subdomain directory (public_html/[my-subdomain-name]/)
3. Change the value of `$GLOBALS["ASEQ"]` located on `/initialize.php`, to the current subdomains sequence (like [my-subdomain-name]) or if this file is in the root address, leave null for that
3. Change the value of `$GLOBALS["ASEQ"]` located on `/index.php`, to the current subdomains sequence (like [my-subdomain-name]) or if this file is in the root address, leave null for that
4. Use it through its special link (http://[my-domain-name].com or http://[my-subdomain-name].[my-domain-name].com)
5. Enjoy...
24 changes: 0 additions & 24 deletions global.php

This file was deleted.

25 changes: 23 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
<?php
require_once(__DIR__."/initialize.php");
<?php /* MiMFa aseqbase http://aseqbase.ir */
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//ini_set('display_startup_errors', E_ALL);

/*
* Change the value, to the current subdomains sequence (like [my-subdomain-name])
* or if this file is in the root address, leave null for that
*/
$relativePath = str_replace(str_replace(["\\","/"], DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT']), "", subject: __DIR__);
$dirs = preg_split("/[\/\\\]/", trim($relativePath, "/\\"));
$GLOBALS["ASEQ"] = join(".", $dirs);/* Change it to null if the file is in the root directory */
$GLOBALS["BASE"] = ".aseq";/* Change it to the base directory if deferents */

/*
Change \_::$SEQUENCES
newdirectory, newaseq;// Add new directory to the \_::$SEQUENCES
directory, newaseq;// Update directory in the \_::$SEQUENCES
directory, null;// Remove thw directory from the \_::$SEQUENCES
*/
$GLOBALS["SEQUENCES_PATCH"] = array();

require_once("initialize.php");
require_once($GLOBALS["BASE_DIR"]."index.php");
?>
59 changes: 36 additions & 23 deletions initialize.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
<?php
/*
* Change the value, to the current subdomains sequence (like [my-subdomain-name])
* or if this file is in the root address, leave null for that
*/
$dirs = explode("/", __DIR__);
$GLOBALS["ASEQ"] = end($dirs);//join(".", array_slice($dirs,3));/*Change it to null if the file is in the root directory*/
$GLOBALS["BASE"] = ".aseq";

$GLOBALS["NEST"] = !empty($GLOBALS["ASEQ"])?preg_match_all("/(?<=\S|\s)\.(?=\S|\s)/",$ASEQ)+1:0;
/* Don't change the codes below: */
$GLOBALS["NEST"] = empty($GLOBALS["ASEQ"])?0:preg_match_all("/(?<=\S|\s)\.(?=\S|\s)/",$ASEQ)+1;
if(!isset($GLOBALS["HOST"])){
$GLOBALS["HOST"] = (isset($_SERVER['HTTPS'])?"https://":"http://");
if($NEST > 0){
$host_parts = explode(".", strtolower(trim($_SERVER["HTTP_HOST"])));
if(preg_match("/(\d+\.)+$/",$_SERVER["HTTP_HOST"]))
$host_parts = explode(".", strtolower(trim($_SERVER["HTTP_HOST"])));
elseif(preg_match("/localhost$/", $_SERVER["HTTP_HOST"]))
$host_parts = [...explode(".", strtolower(trim($_SERVER["HTTP_HOST"]))), ""];
else $host_parts = explode(".", strtolower(trim($_SERVER["HTTP_HOST"])));
$hpc = count($host_parts);
$GLOBALS["HOST"] .= $host_parts[$hpc-(1+$NEST)];
for ($i = $NEST; $i > 0; $i--) $GLOBALS["HOST"] .=".".$host_parts[$hpc-$i];
for ($i = $NEST; $i > 0; $i--) $GLOBALS["HOST"] .= ".".$host_parts[$hpc-$i];
}
else $GLOBALS["HOST"] .= strtolower(trim($_SERVER["HTTP_HOST"]));
}

$GLOBALS["BASE_ROOT"] = $GLOBALS["HOST"]."/".$GLOBALS["BASE"]."/";
$GLOBALS["BASE_DIR"] = __DIR__."/";
for ($i = $NEST; $i > 0; $i--) $GLOBALS["BASE_DIR"] .= "../";
$GLOBALS["BASE_DIR"] .= $GLOBALS["BASE"]."/";
$directory = __DIR__.DIRECTORY_SEPARATOR;

///$SequencesMode:
/// =1;//White Listed
/// =0;//Not Action
/// =-1;//Black Listed
$GLOBALS["ASEQ_Limitation"] = 0;
$GLOBALS["ASEQ_Patterns"] = array();
$GLOBALS["BASE_ROOT"] = $GLOBALS["HOST"]."/".$GLOBALS["BASE"]."/";
$GLOBALS["BASE_DIR"] = $directory;
for ($i = $NEST; $i > 0; $i--) $GLOBALS["BASE_DIR"] .= "..".DIRECTORY_SEPARATOR;
$GLOBALS["BASE_DIR"] .= $GLOBALS["BASE"].DIRECTORY_SEPARATOR;

/* Convert sub domains to sub directories */
$aseq = $GLOBALS["NEST"]>0?preg_replace("/(?<=\S|\s)\.(?=\S|\s)/", "/", $GLOBALS["ASEQ"])."/":"";
if(isset($GLOBALS["DIR"])) $GLOBALS["SEQUENCES"][$directory] = $GLOBALS["HOST"]."/".$aseq;
else {
$GLOBALS["ASEQBASE"] = $GLOBALS["ASEQ"];
$GLOBALS["SEQUENCES"] = array();
$GLOBALS["ROOT"] = $GLOBALS["HOST"]."/".$aseq;
$GLOBALS["DIR"] = $directory;
}

//Don't change the codes below:
require_once(__DIR__."/global.php");
/* Filter the sequences */
if(count($GLOBALS["SEQUENCES_PATCH"]) > 0){
$sequences = $GLOBALS["SEQUENCES"];
foreach($GLOBALS["SEQUENCES_PATCH"] as $newdir=>$newaseq) {
$notFind = true;
foreach($sequences as $dir => $aseq)
if($newdir === $dir) {
$notFind = false;
if(empty($newaseq)) unset($GLOBALS["SEQUENCES"][$newdir]);
else $GLOBALS["SEQUENCES"][$newdir] = $newaseq;
}
if($notFind) $GLOBALS["SEQUENCES"][$newdir] = $newaseq;
}
}
?>
2 changes: 1 addition & 1 deletion private.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
require_once(__DIR__."/initialize.php");
require_once("initialize.php");
require_once($GLOBALS["BASE_DIR"]."private.php");
?>
2 changes: 1 addition & 1 deletion public.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
require_once(__DIR__."/initialize.php");
require_once("initialize.php");
require_once($GLOBALS["BASE_DIR"]."public.php");
?>

0 comments on commit 71fd181

Please sign in to comment.