Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("wp-config.php");
- main();
- function main()
- {
- showRuntimeEnvironment();
- tryDatabaseConnection();
- tryHostResolve(gethostname());
- tryHostResolve($_SERVER["SERVER_NAME"]);
- tryHostResolve("api.wordpress.org");
- tryHostResolve("wordpress.org");
- tryAddressLoad("http://" . $_SERVER["SERVER_NAME"]);
- tryAddressLoad("http://api.wordpress.org/core/version-check/1.7/");
- tryAddressLoad("https://api.wordpress.org/plugins/update-check/1.1/");
- tryAddressLoad("https://wordpress.org/");
- print "<br><hr><br>";
- phpinfo();
- }
- function showRuntimeEnvironment()
- {
- print "Back-end host name: " . gethostname() . "<br>";
- print "Working directory: " . getcwd() . "<br>";
- print "Executing user: " . posix_getuid() . "<br>";
- print "Memory limit: " . ini_get("memory_limit") . "<br>";
- print "Memory used: " . round((memory_get_usage() / 1048576)) . "M<br>";
- print "Memory peak: " . round((memory_get_peak_usage() / 1048576)) .
- "M<br>";
- }
- function tryDatabaseConnection()
- {
- $dbHost = DB_HOST;
- $dbName = DB_NAME;
- $dbPassword = DB_PASSWORD;
- $conn = new PDO('mysql:host=' . $dbHost .';dbname=' . $dbName .
- ';charset=utf8mb4;', $dbName, $dbPassword);
- if($conn == null) {
- echo "** Could not connect to '" . $dbName . "'<br>";
- return;
- } else {
- echo "Was able to successfully connect to '" . $dbName . "' on '" .
- $dbHost . "'<br>";
- }
- $statement = $conn->prepare("SELECT * FROM wp_options");
- $result = $statement->execute();
- if($result != null) {
- echo "Successfully retrieved rows from wp_options table<br>";
- }
- $conn = null;
- }
- function tryHostResolve($host)
- {
- $addresses = gethostbynamel($host);
- if($addresses == null) {
- echo "** Could not resolve host '" . $host . "'<br>";
- return;
- }
- asort($addresses);
- print "Successfully resolved host '" . $host . "' to '" .
- implode(", ", $addresses) . "'<br>";
- }
- function tryAddressLoad($address)
- {
- $ch = curl_init($address);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $result = '';
- if( ($result = curl_exec($ch) ) === false)
- {
- echo "Curl error for '" . $address . "': " . curl_error($ch);
- }
- else
- {
- echo "Successfully connected to, and retrieved data from, '" . $address .
- "' via CURL; result length: " . strlen($result) . "<br>";
- }
- curl_close($ch);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement