Skip to content

Instantly share code, notes, and snippets.

@KartikTalwar
Created August 18, 2012 20:24
Show Gist options
  • Save KartikTalwar/3389600 to your computer and use it in GitHub Desktop.
Save KartikTalwar/3389600 to your computer and use it in GitHub Desktop.
Twitter Followers Prereq Check
<?php
/*
Usage:
- Save this file as check.php and upload it to your server.
- Run this script by vising the file from your browser
- You will then be informed if the server is capable
*/
$url = "https://raw.github.com/gist/3389446/7a46bf0ef2d7948d06068f500e6f680702e3a35f/phptest.xml";
$get = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test><case>42</case></test>";
$b1 = $b2 = true;
if(function_exists('file_get_contents'))
{
try
{
$get = file_get_contents($url);
$b1 = true;
echo "Function file_get_contents() exists! <br>";
}
catch(Exception $e)
{
echo "Function file_get_contents() is not configured to load https URLs <br>";
$b1 = false;
}
}
else
{
echo "Function file_get_contents() is not enabled <br>";
$b1 = false;
}
if(function_exists('simplexml_load_string'))
{
if(extension_loaded('SimpleXML'))
{
$xml = simplexml_load_string($get);
$test = $xml->case;
if($test == 42)
{
echo "Function simplexml_load_string() exists! <br>";
$b2 = true;
}
else
{
echo "Function simplexml_load_string() was not able to open the file <br>";
$b2 = false;
}
}
}
else
{
echo "Function simplexml_load_string() is not enabled <br>";
$b2 = false;
}
if($b1 && $b2)
{
echo "This script will run fine on your server!";
}
else
{
echo "The server doesn't have the prerequisites to run this script";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment