Code Monkey home page Code Monkey logo

Comments (2)

jbremer avatar jbremer commented on July 22, 2024

Ok, I worked on some more testing. It appears that some stuff messes up when initializing the array's in ExecutorGlobals.php. However, we can cheat by adding some hacky stuff to Zval/Variable.php. The following patch atleast allows one to use $_GET['cmd'] and similar. However, var_dump($_GET); doesn't seem to work.

I'd do a pull request, but I'm pretty sure this is not code you'll want in your code base, as you'll probably want a proper fix.
For me, the following seems to be good enough. Also, do note that for some reason I couldn't just use $$varName (the variable variable names thingy.) Not sure what's up with that, but oh well.

From <some-revision> Mon Sep 17 00:00:00 2001
From: Jurriaan Bremer <[email protected]>
Date: Mon, 18 Mar 2013 19:49:59 +0100
Subject: [PATCH] hacky fix for global php superglobals

---
 .../PHPPHP/lib/PHPPHP/Engine/Zval/Variable.php | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/PHPPHP/lib/PHPPHP/Engine/Zval/Variable.php b/PHPPHP/lib/PHPPHP/Engine/Zval/Variable.php
index 7210b1b..9bf261a 100644
--- a/PHPPHP/lib/PHPPHP/Engine/Zval/Variable.php
+++ b/PHPPHP/lib/PHPPHP/Engine/Zval/Variable.php
@@ -48,10 +48,23 @@ class Variable extends Zval {
             $this->zval = $ci->fetchStaticVariable($varName);
         } else if (self::SCOPE_GLOBAL === $this->scope) {
             $symbolTable = $this->executor->executorGlobals->symbolTable;
-            if (!isset($symbolTable[$varName])) {
-                $this->zval = Zval::ptrFactory();
+            $tbl = array(
+                '_GET' => $_GET,
+                '_POST' => $_POST,
+                '_SERVER' => $_SERVER,
+                '_REQUEST' => $_REQUEST,
+                '_FILES' => $_FILES,
+                '_COOKIE' => $_COOKIE,
+                '_SESSION' => $_SESSION,
+                '_ENV' => $_ENV,
+            );
+            if (isset($symbolTable[$varName])) {
+                $this->zval = Zval::ptrFactory($symbolTable[$varName]);
+            } else if(isset($tbl[$varName])) {
+                $symbolTable[$varName] = $tbl[$varName];
+                $this->zval = Zval::ptrFactory($tbl[$varName]);
             } else {
-                $this->zval = $symbolTable[$varName];
+                $this->zval = Zval::ptrFactory();
             }
         } else if ($varName == 'this') {
             $this->zval = Zval::lockedPtrFactory($this->executor->getCurrent()->ci);
-- 
1.8.0.msysgit.0

from phpphp.

wujunze avatar wujunze commented on July 22, 2024

You're terrific

from phpphp.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.