Advertisement
Guest User

Untitled

a guest
May 8th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. <?php
  2. include("wp-config.php");
  3.  
  4. main();
  5.  
  6. function main()
  7. {
  8.  
  9. showRuntimeEnvironment();
  10. tryDatabaseConnection();
  11.  
  12. tryHostResolve(gethostname());
  13. tryHostResolve($_SERVER["SERVER_NAME"]);
  14. tryHostResolve("api.wordpress.org");
  15. tryHostResolve("wordpress.org");
  16.  
  17. tryAddressLoad("http://" . $_SERVER["SERVER_NAME"]);
  18. tryAddressLoad("http://api.wordpress.org/core/version-check/1.7/");
  19. tryAddressLoad("https://api.wordpress.org/plugins/update-check/1.1/");
  20. tryAddressLoad("https://wordpress.org/");
  21.  
  22. print "<br><hr><br>";
  23.  
  24. phpinfo();
  25. }
  26.  
  27. function showRuntimeEnvironment()
  28. {
  29. print "Back-end host name: " . gethostname() . "<br>";
  30. print "Working directory: " . getcwd() . "<br>";
  31. print "Executing user: " . posix_getuid() . "<br>";
  32. print "Memory limit: " . ini_get("memory_limit") . "<br>";
  33. print "Memory used: " . round((memory_get_usage() / 1048576)) . "M<br>";
  34. print "Memory peak: " . round((memory_get_peak_usage() / 1048576)) .
  35. "M<br>";
  36. }
  37.  
  38. function tryDatabaseConnection()
  39. {
  40. $dbHost = DB_HOST;
  41. $dbName = DB_NAME;
  42. $dbPassword = DB_PASSWORD;
  43.  
  44. $conn = new PDO('mysql:host=' . $dbHost .';dbname=' . $dbName .
  45. ';charset=utf8mb4;', $dbName, $dbPassword);
  46.  
  47. if($conn == null) {
  48. echo "** Could not connect to '" . $dbName . "'<br>";
  49. return;
  50. } else {
  51. echo "Was able to successfully connect to '" . $dbName . "' on '" .
  52. $dbHost . "'<br>";
  53. }
  54.  
  55. $statement = $conn->prepare("SELECT * FROM wp_options");
  56. $result = $statement->execute();
  57.  
  58. if($result != null) {
  59. echo "Successfully retrieved rows from wp_options table<br>";
  60. }
  61.  
  62. $conn = null;
  63. }
  64.  
  65. function tryHostResolve($host)
  66. {
  67. $addresses = gethostbynamel($host);
  68.  
  69. if($addresses == null) {
  70. echo "** Could not resolve host '" . $host . "'<br>";
  71. return;
  72. }
  73.  
  74. asort($addresses);
  75.  
  76. print "Successfully resolved host '" . $host . "' to '" .
  77. implode(", ", $addresses) . "'<br>";
  78. }
  79.  
  80. function tryAddressLoad($address)
  81. {
  82. $ch = curl_init($address);
  83. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  84.  
  85. $result = '';
  86. if( ($result = curl_exec($ch) ) === false)
  87. {
  88. echo "Curl error for '" . $address . "': " . curl_error($ch);
  89. }
  90. else
  91. {
  92. echo "Successfully connected to, and retrieved data from, '" . $address .
  93. "' via CURL; result length: " . strlen($result) . "<br>";
  94. }
  95.  
  96. curl_close($ch);
  97. }
  98.  
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement