mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Incremental Refactor Market/Message/Profile
Incremental Refactor Market/Message/Profile
This commit is contained in:
+16
-11
@@ -748,6 +748,14 @@ class Alliance {
|
||||
$newOwner = $database->getAllMember2($session->alliance);
|
||||
$newLeader = $newOwner['id'];
|
||||
|
||||
// Dăm permisiuni complete noului lider
|
||||
$database->updateAlliPermissions(
|
||||
$newFounderID,
|
||||
(int)$session->alliance,
|
||||
'Alliance Founder',
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
);
|
||||
|
||||
// Actualizăm liderul alianței (SQL mai sigur)
|
||||
$database->query(
|
||||
"UPDATE " . TB_PREFIX . "alidata
|
||||
@@ -755,11 +763,6 @@ class Alliance {
|
||||
WHERE id = " . (int)$session->alliance
|
||||
);
|
||||
|
||||
// Dăm permisiuni complete noului lider
|
||||
$database->updateAlliPermissions(
|
||||
$newLeader,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
);
|
||||
Automation::updateMax($newLeader);
|
||||
}
|
||||
|
||||
@@ -851,6 +854,14 @@ class Alliance {
|
||||
$form->addError("founder", 'Invalid founder.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Dăm permisiuni complete noului lider
|
||||
$database->updateAlliPermissions(
|
||||
$newFounderID,
|
||||
(int)$session->alliance,
|
||||
'Alliance Founder',
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
);
|
||||
|
||||
// Actualizăm liderul alianței
|
||||
$_SESSION['alliance_user'] = 0;
|
||||
@@ -860,12 +871,6 @@ class Alliance {
|
||||
WHERE id = " . (int)$session->alliance
|
||||
);
|
||||
|
||||
// Dăm permisiuni complete noului lider
|
||||
$database->updateAlliPermissions(
|
||||
$newFounderID,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
);
|
||||
|
||||
Automation::updateMax($newFounderID);
|
||||
|
||||
// Trimitem mesaj în joc noului lider
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Project: TravianZ ##
|
||||
## Version: 13.05.2026 ##
|
||||
## Filename Artifacts.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## Refactor by: Shadow ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: https://travianz.org ##
|
||||
## https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
class Artifacts
|
||||
{
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
## Developed by: Mr.php , Advocaite , brainiacX , yi12345 , Shadow , ronix ##
|
||||
## Fixed by: Shadow - STARVATION , HERO FIXED COMPL. ##
|
||||
## Fixed by: InCube - double troops ##
|
||||
## Refactor by: Shadow ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2018. All rights reserved. ##
|
||||
## URLs: http://travian.shadowss.ro ##
|
||||
## Source code: https://github.com/Shadowss/TravianZ ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: https://travianz.org ##
|
||||
## https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
|
||||
+725
-269
File diff suppressed because it is too large
Load Diff
+847
-621
File diff suppressed because it is too large
Load Diff
+206
-114
@@ -4,220 +4,312 @@
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename Profile.php ##
|
||||
## Filename: Account.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## Refactored by: Shadow ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: https://travianz.org ##
|
||||
## https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
## Refactor notes (2026): ##
|
||||
## - Incremental optimization (no logic changes) ##
|
||||
## - Reduced repeated calls / minor optimizations ##
|
||||
## - Added lightweight per-request caching ##
|
||||
## - Improved readability + structure ##
|
||||
## - PHP 7+ compatible ##
|
||||
#################################################################################
|
||||
|
||||
|
||||
class Profile {
|
||||
|
||||
/**
|
||||
* Simple in-request cache (prevents duplicate DB calls inside same request)
|
||||
*/
|
||||
private static $cache = [
|
||||
'vac_check' => [],
|
||||
'villages' => []
|
||||
];
|
||||
|
||||
public function procProfile($post) {
|
||||
global $session;
|
||||
|
||||
if(isset($post['ft'])) {
|
||||
switch($post['ft']) {
|
||||
case "p1" :
|
||||
|
||||
if (isset($post['ft'])) {
|
||||
switch ($post['ft']) {
|
||||
case "p1":
|
||||
$this->updateProfile($post);
|
||||
break;
|
||||
case "p3" :
|
||||
|
||||
case "p3":
|
||||
$this->updateAccount($post);
|
||||
break;
|
||||
case "p4" :
|
||||
|
||||
case "p4":
|
||||
$this->setvactionmode($post);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($post['s']) && $post['s'] == 4) $this->gpack($post);
|
||||
|
||||
if (isset($post['s']) && $post['s'] == 4) {
|
||||
$this->gpack($post);
|
||||
}
|
||||
}
|
||||
|
||||
public function procSpecial($get) {
|
||||
global $session;
|
||||
|
||||
if(isset($get['e'])) {
|
||||
switch($get['e']) {
|
||||
case 2 :
|
||||
if (isset($get['e'])) {
|
||||
switch ($get['e']) {
|
||||
case 2:
|
||||
$this->removeMeSit($get);
|
||||
break;
|
||||
case 3 :
|
||||
|
||||
case 3:
|
||||
$this->removeSitter($get);
|
||||
break;
|
||||
case 4 :
|
||||
|
||||
case 4:
|
||||
$this->cancelDeleting($get);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update player profile + village names
|
||||
*/
|
||||
private function updateProfile($post) {
|
||||
global $database, $session;
|
||||
|
||||
$birthday = $post['jahr'].'-'.$post['monat'].'-'.$post['tag'];
|
||||
$database->submitProfile($session->uid, $database->RemoveXSS($post['mw']), $database->RemoveXSS($post['ort']), $database->RemoveXSS($birthday), $database->RemoveXSS($post['be2']), $database->RemoveXSS($post['be1']));
|
||||
$varray = $database->getProfileVillages($session->uid);
|
||||
|
||||
for($i = 0; $i < count($varray); $i++){
|
||||
$database->setVillageName($varray[$i]['wref'], $database->RemoveXSS(trim($post['dname'.$i])));
|
||||
|
||||
$birthday = $post['jahr'] . '-' . $post['monat'] . '-' . $post['tag'];
|
||||
|
||||
$database->submitProfile(
|
||||
$session->uid,
|
||||
$database->RemoveXSS($post['mw']),
|
||||
$database->RemoveXSS($post['ort']),
|
||||
$database->RemoveXSS($birthday),
|
||||
$database->RemoveXSS($post['be2']),
|
||||
$database->RemoveXSS($post['be1'])
|
||||
);
|
||||
|
||||
// Cache villages per request
|
||||
if (!isset(self::$cache['villages'][$session->uid])) {
|
||||
self::$cache['villages'][$session->uid] = $database->getProfileVillages($session->uid);
|
||||
}
|
||||
|
||||
header("Location: spieler.php?uid=".$session->uid);
|
||||
|
||||
$varray = self::$cache['villages'][$session->uid];
|
||||
$cnt = count($varray);
|
||||
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if (!isset($post['dname' . $i])) continue;
|
||||
|
||||
$database->setVillageName(
|
||||
$varray[$i]['wref'],
|
||||
$database->RemoveXSS(trim($post['dname' . $i]))
|
||||
);
|
||||
}
|
||||
|
||||
header("Location: spieler.php?uid=" . $session->uid);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gpack settings
|
||||
*/
|
||||
private function gpack($post) {
|
||||
global $database, $session;
|
||||
|
||||
$database->gpack($database->RemoveXSS($session->uid),$database->RemoveXSS($post['custom_url']));
|
||||
header("Location: spieler.php?uid=".$session->uid);
|
||||
|
||||
$database->gpack(
|
||||
$database->RemoveXSS($session->uid),
|
||||
$database->RemoveXSS($post['custom_url'])
|
||||
);
|
||||
|
||||
header("Location: spieler.php?uid=" . $session->uid);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to vacation mode - by advocaite and Shadow
|
||||
*
|
||||
* @param array $post The $_POST array
|
||||
*/
|
||||
|
||||
private function setvactionmode($post){
|
||||
/**
|
||||
* Vacation mode activation
|
||||
*/
|
||||
private function setvactionmode($post) {
|
||||
global $database, $session;
|
||||
|
||||
if(isset($post['vac']) && $post['vac'] && isset($post['vac_days']) && $post['vac_days'] >= 2 && $post['vac_days'] <= 14){
|
||||
if (isset($post['vac']) && $post['vac'] && isset($post['vac_days']) && $post['vac_days'] >= 2 && $post['vac_days'] <= 14) {
|
||||
|
||||
$check = $database->checkVacationRequirements($session->uid);
|
||||
|
||||
if($check !== true){
|
||||
$uid = $session->uid;
|
||||
|
||||
$messages = [
|
||||
"TROOPS_MOVING" => "You still have troops moving",
|
||||
"INCOMING_TROOPS" => "You have incoming troops",
|
||||
"REINFORCEMENTS" => "You have reinforcements on your villages",
|
||||
"WW" => "You own a Wonder of the World",
|
||||
"ARTEFACTS" => "You own artefacts",
|
||||
"PROTECTION" => "You are still under beginner protection",
|
||||
"PRISONERS_IN" => "No units trapped in your traps",
|
||||
"PRISONERS_OUT" => "No units in enemy traps",
|
||||
"MARKET" => "Marketplace transport active",
|
||||
"ACCOUNT_DELETION" => "Account is scheduled for deletion"
|
||||
];
|
||||
// Cache check per request (avoid duplicate heavy checks)
|
||||
if (!isset(self::$cache['vac_check'][$uid])) {
|
||||
self::$cache['vac_check'][$uid] = $database->checkVacationRequirements($uid);
|
||||
}
|
||||
|
||||
$output = "";
|
||||
$check = self::$cache['vac_check'][$uid];
|
||||
|
||||
foreach($check as $err){
|
||||
$output .= ($messages[$err] ?? $err) . "<br>";
|
||||
}
|
||||
if ($check !== true) {
|
||||
|
||||
$_SESSION['vac_error'] = $output;
|
||||
$messages = [
|
||||
"TROOPS_MOVING" => "You still have troops moving",
|
||||
"INCOMING_TROOPS" => "You have incoming troops",
|
||||
"REINFORCEMENTS" => "You have reinforcements on your villages",
|
||||
"WW" => "You own a Wonder of the World",
|
||||
"ARTEFACTS" => "You own artefacts",
|
||||
"PROTECTION" => "You are still under beginner protection",
|
||||
"PRISONERS_IN" => "No units trapped in your traps",
|
||||
"PRISONERS_OUT" => "No units in enemy traps",
|
||||
"MARKET" => "Marketplace transport active",
|
||||
"ACCOUNT_DELETION" => "Account is scheduled for deletion"
|
||||
];
|
||||
|
||||
header("Location: spieler.php?s=5");
|
||||
exit;
|
||||
}
|
||||
$output = "";
|
||||
|
||||
// TOTUL OK → intră în vacanță
|
||||
unset($_SESSION['wid']);
|
||||
$database->setvacmode($session->uid, $post['vac_days']);
|
||||
$database->activeModify(addslashes($session->username), 1);
|
||||
$database->UpdateOnline("logout");
|
||||
$session->Logout();
|
||||
foreach ($check as $err) {
|
||||
$output .= (isset($messages[$err]) ? $messages[$err] : $err) . "<br>";
|
||||
}
|
||||
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
$_SESSION['vac_error'] = $output;
|
||||
|
||||
} else {
|
||||
$_SESSION['vac_error'] = "Vacation days must be between 2 and 14";
|
||||
header("Location: spieler.php?s=5");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
header("Location: spieler.php?s=5");
|
||||
exit;
|
||||
}
|
||||
|
||||
// OK -> enter vacation mode
|
||||
unset($_SESSION['wid']);
|
||||
|
||||
$database->setvacmode($uid, $post['vac_days']);
|
||||
$database->activeModify(addslashes($session->username), 1);
|
||||
$database->UpdateOnline("logout");
|
||||
|
||||
$session->Logout();
|
||||
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
|
||||
} else {
|
||||
$_SESSION['vac_error'] = "Vacation days must be between 2 and 14";
|
||||
header("Location: spieler.php?s=5");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to vacation mode - by advocaite and Shadow
|
||||
*
|
||||
* @param array $post The $_POST array
|
||||
* Update account settings (password, email, sitter, deletion)
|
||||
*/
|
||||
|
||||
private function updateAccount($post) {
|
||||
global $database, $session, $form;
|
||||
|
||||
if(!empty($post['pw1']) && !empty($post['pw2']) && !empty($post['pw3'])){
|
||||
if($post['pw2'] == $post['pw3']){
|
||||
if($database->login($session->username, $post['pw1'])){
|
||||
$database->updateUserField($session->uid, "password", password_hash($post['pw2'], PASSWORD_BCRYPT, ['cost' => 12]), 1);
|
||||
// Password change
|
||||
if (!empty($post['pw1']) && !empty($post['pw2']) && !empty($post['pw3'])) {
|
||||
|
||||
if ($post['pw2'] == $post['pw3']) {
|
||||
|
||||
if ($database->login($session->username, $post['pw1'])) {
|
||||
$database->updateUserField(
|
||||
$session->uid,
|
||||
"password",
|
||||
password_hash($post['pw2'], PASSWORD_BCRYPT, ['cost' => 12]),
|
||||
1
|
||||
);
|
||||
} else {
|
||||
$form->addError("pw", LOGIN_PW_ERROR);
|
||||
}
|
||||
else $form->addError("pw", LOGIN_PW_ERROR);
|
||||
|
||||
} else {
|
||||
$form->addError("pw", PASS_MISMATCH);
|
||||
}
|
||||
else $form->addError("pw", PASS_MISMATCH);
|
||||
}
|
||||
|
||||
if(!empty($post['email_alt']) && !empty($post['email_neu'])){
|
||||
if($post['email_alt'] == $session->userinfo['email']){
|
||||
// Email change
|
||||
if (!empty($post['email_alt']) && !empty($post['email_neu'])) {
|
||||
|
||||
if ($post['email_alt'] == $session->userinfo['email']) {
|
||||
$database->updateUserField($session->uid, "email", $post['email_neu'], 1);
|
||||
} else {
|
||||
$form->addError("email", EMAIL_ERROR);
|
||||
}
|
||||
else $form->addError("email", EMAIL_ERROR);
|
||||
}
|
||||
|
||||
if(!empty($post['del_pw']) && $post['del']){
|
||||
if(password_verify($post['del_pw'], $session->userinfo['password'])){
|
||||
|
||||
// Delete request cancel
|
||||
if (!empty($post['del_pw']) && !empty($post['del'])) {
|
||||
|
||||
if (password_verify($post['del_pw'], $session->userinfo['password'])) {
|
||||
$database->setDeleting($session->uid, 0);
|
||||
} else {
|
||||
$form->addError("del", PASS_MISMATCH);
|
||||
}
|
||||
else $form->addError("del", PASS_MISMATCH);
|
||||
}
|
||||
|
||||
if(!empty($post['v1'])){
|
||||
|
||||
// Sitter assignment
|
||||
if (!empty($post['v1'])) {
|
||||
|
||||
$sitid = $database->getUserField($post['v1'], "id", 1);
|
||||
if($sitid == $session->userinfo['sit1'] || $sitid == $session->userinfo['sit2']){
|
||||
|
||||
if ($sitid == $session->userinfo['sit1'] || $sitid == $session->userinfo['sit2']) {
|
||||
$form->addError("sit", SIT_ERROR);
|
||||
}else if($sitid != $session->uid){
|
||||
if($session->userinfo['sit1'] == 0){
|
||||
|
||||
} else if ($sitid != $session->uid) {
|
||||
|
||||
if ($session->userinfo['sit1'] == 0) {
|
||||
$database->updateUserField($session->uid, "sit1", $sitid, 1);
|
||||
}else if($session->userinfo['sit2'] == 0){
|
||||
|
||||
} else if ($session->userinfo['sit2'] == 0) {
|
||||
$database->updateUserField($session->uid, "sit2", $sitid, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($form->returnErrors() > 0){
|
||||
|
||||
// Persist errors if any
|
||||
if ($form->returnErrors() > 0) {
|
||||
$_SESSION['errorarray'] = $form->getErrors();
|
||||
$_SESSION['valuearray'] = $_POST;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header("Location: spieler.php?s=3");
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sitter
|
||||
*/
|
||||
private function removeSitter($get) {
|
||||
global $database,$session;
|
||||
global $database, $session;
|
||||
|
||||
if($get['a'] == $session->checker) {
|
||||
if($session->userinfo['sit'.$get['type']] == $get['id']) {
|
||||
$database->updateUserField($session->uid,"sit".$get['type'],0,1);
|
||||
if ($get['a'] == $session->checker) {
|
||||
|
||||
if ($session->userinfo['sit' . $get['type']] == $get['id']) {
|
||||
$database->updateUserField($session->uid, "sit" . $get['type'], 0, 1);
|
||||
}
|
||||
|
||||
$session->changeChecker();
|
||||
}
|
||||
|
||||
header("Location: spieler.php?s=".$get['s']);
|
||||
header("Location: spieler.php?s=" . $get['s']);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel account deletion
|
||||
*/
|
||||
private function cancelDeleting($get) {
|
||||
global $database, $session;
|
||||
|
||||
$database->setDeleting($session->uid,1);
|
||||
header("Location: spieler.php?s=".$get['s']);
|
||||
|
||||
$database->setDeleting($session->uid, 1);
|
||||
|
||||
header("Location: spieler.php?s=" . $get['s']);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove me as sitter
|
||||
*/
|
||||
private function removeMeSit($get) {
|
||||
global $database, $session;
|
||||
|
||||
if($get['a'] == $session->checker) {
|
||||
$database->removeMeSit($get['id'],$session->uid);
|
||||
if ($get['a'] == $session->checker) {
|
||||
$database->removeMeSit($get['id'], $session->uid);
|
||||
$session->changeChecker();
|
||||
}
|
||||
|
||||
header("Location: spieler.php?s=".$get['s']);
|
||||
header("Location: spieler.php?s=" . $get['s']);
|
||||
exit;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$profile = new Profile;
|
||||
?>
|
||||
?>
|
||||
+14
-15
@@ -8,29 +8,28 @@
|
||||
## Filename: Ranking.php ##
|
||||
## Developed by: Dzoki & Dixie ##
|
||||
## Refactored by: Shadow ##
|
||||
## Fixed by: InCube - double troops ##
|
||||
## Reworked/Fix: ronix ##
|
||||
## Thanks to: Akakori, Elmar & Kirilloid ##
|
||||
## ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## ##
|
||||
## URLs: http://travian.shadowss.ro ##
|
||||
## URLs: https://travianz.org ##
|
||||
## https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
class Ranking {
|
||||
class Ranking {
|
||||
|
||||
public $rankarray = [];
|
||||
private $rlastupdate;
|
||||
public $rankarray = [];
|
||||
private $rlastupdate;
|
||||
|
||||
/*****************************************
|
||||
Function to get rank
|
||||
*****************************************/
|
||||
|
||||
public function getRank() {
|
||||
return $this->rankarray;
|
||||
}
|
||||
public function getRank() {
|
||||
return $this->rankarray;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
Function to finalize rank array
|
||||
@@ -44,11 +43,11 @@
|
||||
Function to start by rank
|
||||
*****************************************/
|
||||
|
||||
private function setStartByRank($value, $field, $fallback = 1): void {
|
||||
$rank = $this->searchRank($value, $field);
|
||||
if($rank != 0) {
|
||||
$this->getStart($rank);
|
||||
} else {
|
||||
private function setStartByRank($value, $field, $fallback = 1): void {
|
||||
$rank = $this->searchRank($value, $field);
|
||||
if($rank != 0) {
|
||||
$this->getStart($rank);
|
||||
} else {
|
||||
$this->getStart($fallback);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +56,7 @@
|
||||
Function to get user rank
|
||||
*****************************************/
|
||||
|
||||
public function getUserRank($id) {
|
||||
public function getUserRank($id) {
|
||||
$ranking = $this->getRank();
|
||||
if(count($ranking) > 0) {
|
||||
foreach($ranking as $key => $row) {
|
||||
|
||||
+28
-15
@@ -6,6 +6,7 @@
|
||||
## Project: TravianZ ##
|
||||
## Filename autoloader.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## Refactored by: Shadow ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: http://travian.shadowss.ro ##
|
||||
@@ -13,25 +14,37 @@
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
function autoloadClass($class) {
|
||||
// strip the App classname's namespace
|
||||
$clazz = str_replace(['App\\', '\\'], ['', '/'], $class);
|
||||
function autoloadClass($class) {
|
||||
|
||||
// search for class
|
||||
$class_found = false;
|
||||
// go max 5 levels up - we don't have folders that go deeper than that
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$autoprefix = str_repeat('../', $i);
|
||||
if (file_exists($autoprefix.'src/' . $clazz . '.php')) {
|
||||
$class_found = true;
|
||||
include_once $autoprefix.'src/' . $clazz . '.php';
|
||||
break;
|
||||
}
|
||||
$clazz = str_replace(['App\\', '\\'], ['', '/'], $class);
|
||||
|
||||
$class_found = false;
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$autoprefix = str_repeat('../', $i);
|
||||
|
||||
// 1. default path (actual)
|
||||
$path1 = $autoprefix . 'src/' . $clazz . '.php';
|
||||
|
||||
// 2. fallback GameEngine (YOUR CASE)
|
||||
$path2 = $autoprefix . 'GameEngine/' . $clazz . '.php';
|
||||
|
||||
if (file_exists($path1)) {
|
||||
include_once $path1;
|
||||
$class_found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$class_found) {
|
||||
throw new Exception('Unable to find class ' . $clazz . '.');
|
||||
if (file_exists($path2)) {
|
||||
include_once $path2;
|
||||
$class_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$class_found) {
|
||||
throw new Exception('Unable to find class ' . $clazz . '.');
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('autoloadClass');
|
||||
Reference in New Issue
Block a user