Skip to content

Instantly share code, notes, and snippets.

@gnh1201
Created March 24, 2023 08:39
Show Gist options
  • Save gnh1201/5e65db0ba7286fc06b3bc331ef08605b to your computer and use it in GitHub Desktop.
Save gnh1201/5e65db0ba7286fc06b3bc331ef08605b to your computer and use it in GitHub Desktop.
Extract all environment data from PHP runtime
<?php
// Extract all environment data from PHP runtime
// Go Namhyeon <abuse@catswords.net>
echo "Extracting...<br/><br/>";
$extracted_data = array();
// Extracting all defined functions
echo "Extracting all defined functions...<br/><br/>";
$my_functions = get_defined_functions();
foreach($my_functions["internal"] as $name) {
$extracted_data[] = array(
'type' => 'function',
'scope' => 'global',
'value' => $name
);
}
// Extracting all defined constants
echo "Extracting all defined constants...<br/><br/>";
$my_constants = get_defined_constants(true);
foreach($my_constants as $scope=>$functions) {
foreach($functions as $name=>$_) {
$extracted_data[] = array(
'type' => 'constant',
'scope' => $scope,
'value' => $name
);
}
}
// Extracting all defined classes
echo "Extracting all defined classes...<br/><br/>";
$my_classes = get_declared_classes();
foreach($my_classes as $name) {
$extracted_data[] = array(
'type' => 'class',
'scope' => 'global',
'value' => $name
);
}
// Extracting all loaded extensions
echo "Extracting all defined extensions...<br/><br/>";
$my_extensions = get_loaded_extensions();
foreach($my_extensions as $name) {
$extracted_data[] = array(
'type' => 'extension',
'scope' => 'global',
'value' => $name
);
}
echo "All done.<br/><br/>";
// Show all extected data
echo "type,scope,value<br>";
foreach($extracted_data as $item) {
echo implode(',', array($item['type'], $item['scope'], $item['value'])) . '<br/>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment