Last active
November 14, 2017 05:46
-
-
Save bastman/c1ea9d203d89f8dfc3fee5b3bded34f1 to your computer and use it in GitHub Desktop.
drupal7 mess utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dumpGlobalVars() { | |
// usage: echo "<pre>".json_encode(dumpGlobalVars())."</pre>"; | |
// you may want to base64_encode($json) | |
// !!! WARNING: the result may contain sensitive data. prefer logging over echo to stdout !!! | |
$d=(array)$GLOBALS; | |
$removedFromSerializationText="***REMOVED_FROM_SERIALIZATION***"; | |
$d["_GET"]=$removedFromSerializationText; | |
$d["_POST"]=$removedFromSerializationText; | |
$d["_REQUEST"]=$removedFromSerializationText; | |
$d["_SERVER"]=$removedFromSerializationText; | |
$d["_COOKIE"]=$removedFromSerializationText; | |
$d["_FILES"]=$removedFromSerializationText; | |
$d["GLOBALS"]=$removedFromSerializationText; | |
$d["timers"]=$removedFromSerializationText; | |
$r=[]; | |
foreach ($d as $k=>$v) { | |
$encoded = json_encode($v); | |
if($encoded!==false) { | |
$r[$k]=$v; | |
}else { | |
$r[$k]=$removedFromSerializationText; | |
} | |
} | |
// remove stuff | |
$r['databases']=$removedFromSerializationText; | |
$r['conf']['404_fast_html']=$removedFromSerializationText; | |
return $r; | |
} | |
echo "<pre>".json_encode(dumpGlobalVars())."</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment