Jump to content
MakeWebGames

Recommended Posts

Posted

I am trying to avoid creating a new IF statement and use a one time go-to statement. Which it just ignores. 

 

<?php

    $start = microtime();

    session_start();
   
if(count($_POST) > 0 && empty($_GET['action']))
{
  foreach($_SESSION['lastPage'] as $key => $val)
  {
    $_GET[$key] = $val;
  }
 print(var_dump($_GET));// . "<br><br><br><br>" . var_dump($_SESSION['lastPage']));//. "....") ;//var_dump($_POST));
}
else{
  $_SESSION['lastPage'] = $_GET;//$_SERVER["QUERY_STRING"];
}

    if (file_exists("install/")) {
        header("Location: install/");
        exit;
    }

    require 'class/hooks.php';
    include 'dbconn.php';
    require "class/ItemHelperFunctions.php";
    $helper = new ItemHelperFunctions();
  
    require 'class/settings.php'; 
    require 'class/template.php';
    require 'class/templateRender.php';
    require 'class/page.php';
    require 'class/image.php';
    require 'class/user.php';
    require 'class/gang.php';
    require 'class/property.php';

    $settings = new settings();

    $page->loadModuleMetaData();

    if (!isset($_GET['page'])) {
       $_GET['page'] = $page->landingPage;
       //$_GET['page'] = "news";
    }

    $pageToLoad = $_GET['page'];
    $exclude = array(
    "banned",
    "login",
    "logout",
    "forgotpassword",
    );

    if (!empty($_SESSION['userID']))
    {
      $user = new user($_SESSION['userID']);
      $user->updateTimer('laston', time());
      $user->checkRank();
    
    debug($user->info->US_charID);
      if($user->info->U_userLevel != 3 && !$user->info->US_charID ==0)
      {
        $page->loadPage("createCharacter");
        goto quickCheat;
      }
    }
    debug("test");
    if (!isset($page->modules[$pageToLoad])) {
        if (!empty($_SESSION['userID'])) {
            $user = new user($_SESSION['userID']);
            $user->updateTimer('laston', time());
            $user->checkRank();
        }
        $page->loadPage("pageNotFound");
    } else {

        $jailPageCheck = $page->modules[$pageToLoad];

        if (!empty($_SESSION['userID'])) {
            
            $user = new user($_SESSION['userID']);
            $user->updateTimer('laston', time());
            $user->checkRank();


            if ($_GET["page"] == "logout") {
                $page->loadPage('logout');
            } else if ($user->info->U_status == 0) {
                $deadPage = "dead";
                $hook = new Hook("deadPage");
                $deadPage = $hook->run($deadPage, true);
                $page->loadPage($deadPage);
            } else if ($user->info->U_status == 2 && $jailPageCheck["requireLogin"]) {
                $page->loadPage('users');
            } else if ($user->info->U_userLevel == 3) {
                $bannedPage = "banned";
                $hook = new Hook("bannedPage");
                $bannedPage = $hook->run($bannedPage, true);
                $page->loadPage($bannedPage);
            } else if (!$user->checkTimer('jail')) {
                if ($jailPageCheck["accessInJail"]) {
                    $page->loadPage($pageToLoad);
                } else {
                    $jailPage = "jail";
                    $hook = new Hook("jailPage");
                    $jailPage = $hook->run($jailPage, true);
                    $page->loadPage($jailPage);
                }
            } else {
                $page->loadPage($pageToLoad);
            }
                
        } else if (!$jailPageCheck["requireLogin"]) {
            $page->loadPage($_GET['page']);
        } else {
            
            $page->loadPage("login");
            
        }
    
    }
  quickCheat:
    
    $page->printPage();

    $page->success = true;
    
?>

 

 

My go-to statement is the second if after the includes and the quick cheat: is almost at the bottom of the file. So not much searching is needed.

 

The problem is it ignores the go-to execution and proceeds instead of jumping to quick cheat maybe this is purposely done in php7, but I seen no documentation that girl is no longer supported. @Dave will love this post 

 

The question should have been. The best and easiest way to load my create character page until a character was created. But I overlooked the simplicity of it.

if($user->info->U_userLevel != 3 && $user->info->US_charID ==0)
      {
        $page->loadPage("createCharacter");
        $page->printPage();
        $page->success = true;
        exit();
      }

Edit #2: I still would love to know why the go-to statement did not work

Posted (edited)

There should be a hook within init that you can use to alter what module to go to

I’ve made a module for GL like this before and this was the hook.

new hook("moduleLoad", function ($page) {
    	global $user;
    	if ($user) {
    		if (!$user->info->US_setup) {
    			return "createCharacter";
    		}
    	}
    	return $page;
    });

 

Edited by Dayo
  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...