<!DOCTYPE html PUBLIC "--W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Content Farmer Professional Edition&trade;</title>
    <style type="text/css">
      #page_body p {
        padding-left:25px;
        padding-right:25px;
        font-size:110%;
        text-align:justify;
      }
      #page_body {        
        min-height:300px;
        width:720px;
        margin-left:auto;
        margin-right:auto;
        padding-bottom:20px;
        padding-top:10px;
        font-size:10pt;
        background-image:url('http://www.contentfarmerpro.com/newsletter/images/fixed_bg.gif');
        display:block;
        position:relative;
        top:-5px;
      }
      body {
        font-family:"Segoe UI";
        font-size:9pt;
        background-color: #F7F5F5;
        background-image: url('http://www.contentfarmerpro.com/newsletter/images/bg.gif');
        margin:0px;
        padding:0px;
        text-align:center;
      }
      #footer {
        background-image:url('http://www.contentfarmerpro.com/newsletter/images/footer.gif');
        width:625px;
        height:45px;
        margin-left:auto;
        margin-right:auto;
        padding-left:95px;
        padding-top:10px;
        position:relative;
        top:-5px;
      }
      #footer a {
        color:#000000;
        padding-left:1em;
        padding-right:1em;  
      }
      a:hover {
        text-decoration: none;
      }
      #left_column {
        float:left; width:200px;
        min-height:315px;
        padding:.5em;
        border-right:3px #0348a5 solid;
        margin-right:.5em;
      }
      #left_column h2 {
        font-size:12pt;
        text-decoration:underline;        
        color:#ff0000;
      }
      #left_column p {
        font-size:9pt;
      }
      #page_body h2 {
        font-style:italic;
        margin-top:0px;
      }
      .column_2 {
        width:325px;
        float:left;
        text-align:center;
        margin-left:25px;
      }
      .column_2 p {
        text-align:justify;
      }
      .column_2 li {
        text-align:left;
        font-size:11pt;
      }
    </style>
  </head>
  <body>
  <img src="http://www.contentfarmerpro.com/images/header.png"/>
  <div id="page_body">  
   
          <h3>Server Configuration Test Script</h3>
            <p>Thank you for your interest in Content Farmer Professional Edition&trade;.  This script has been designed to test a server for all the features currently known to be required by Content Farmer Professional Edition&trade;.  If you see any red boxes, be sure to examine that item for any instructions.</p>
            <p><b>Please note:</b>  While this script checks for all known issues, no errors from this script <b><u>does not</u></b> imply or guarantee that there will be no errors.</p>
            <div style="display:block;clear:both;width:90%;border-top:3px #0348a5 solid;margin-left:2em;margin-right:2em;"></div>
            <div style="text-align:left;margin-left:2em;margin-right:2em;">
<?php   
echo '<center><table align="center" width="100%">
              <tr>
                <th>Fail/Pass</th>                
                <th>Requirement</th>
                <th>Required Version</th>
                <th>Your Version</th>
              </tr>';
$instruction_line = "<tr><td></td><td align=\"left\">Your browser does not meet the minimum requirements for Content Farmer Professional Edition&trade; and may not work with the administration interface.  Please use IE 7+ or Firefox 2+.</td><td></td><td></td></tr>";
// $instruction_line = "<tr><td></td><td> </td><td></td><td></td></tr>";
$browser = "Unknown";
$user_agent = $_SERVER["HTTP_USER_AGENT"].' ';
$browser_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
if (strpos($user_agent,'Firefox') > -1) {
  list ($g,$ff_data) = explode('Firefox',$user_agent);
  list ($ff_version,$g) = explode (' ',trim($ff_data,'/'));
  $browser_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
  $browser = "Firefox ".$ff_version;
  $instruction_line = "";
} else if (strpos($user_agent,'MSIE') != -1) {
  list ($g,$ie_data) = explode('MSIE',$user_agent);
  list ($ie_version,$g) = explode (';',trim($ie_data,'/'));
  $browser = "Internet Explorer ".trim($ie_version);
  $browser_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
  $instruction_line = "";
}
echo '              <tr>
                <td align="center">'.$browser_image.'</td>
                <td>Browser</td>
                <td align="center">IE 7+ or FireFox 2+</td>
                <td align="center">'.$browser.'</td>
              </tr>'.$instruction_line;
$instruction_line = "<tr><td></td><td align=\"left\">Your version of PHP does not meet the minimum requirements for Content Farmer Professional Edition&trade;.  You must be on a PHP 5 server for Content Farmer Professional Edition&trade; to work.</td><td></td><td></td></tr>";
$version_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
if (version_compare ( phpversion(),'5.0.0') >= 0) {
  $version_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
  $instruction_line = "";
}
              
echo '              <tr>
                <td align="center">'.$version_image.'</td>
                <td>PHP</td>
                <td align="center">5+</td>
                <td align="center">'.phpversion().'</td>
              </tr>'.$instruction_line;

$instruction_line = '<tr><td></td><td align="left">IONCube loaders not detected.  To install IONCube loaders, please see the <a href="http://www.ioncube.com/loaders.php" target="blank">IONCube site</a>.</td><td></td><td></td></tr>';
$ic_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
if (@extension_loaded('ioncube') || @extension_loaded('ionCube Loader')) {
    if (ioncube_loader_version() >= '3.1') {
      $ic_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
      $instruction_line = "";
    }
}
                           
echo '              <tr>
                <td align="center">'.$ic_image.'</td>
                <td>IONCube Loaders</td>
                <td align="center">3.1</td>
                <td align="center">'.((@extension_loaded('ioncube') || @extension_loaded('ionCube Loader'))?@ioncube_loader_version():'Undetected').'</td>
              </tr>'.$instruction_line;

$instruction_line = "<tr><td></td><td align=\"left\">Safe mode has been enabled on this server and will likely cause problems.  Safe mode should not be on on a production server.  Please contact your host and ask them to disable safe mode on your account.</td><td></td><td></td></tr>";
$safe_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
$safe_status = "On";
if(!ini_get("safe_mode")) {
  $safe_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
  $safe_status = "Off";
  $instruction_line = "";
}
echo '              <tr>
                <td align="center">'.$safe_image.'</td>
                <td>Safe Mode</td>
                <td align="center">Off</td>
                <td align="center">'.$safe_status.'</td>
              </tr>'.$instruction_line;
              
$instruction_line = "";
$url_status = "Enabled";
$url_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';

//Should change this line to attempt the connection via cURL

$fp = CurlGet("www.contentfarmerpro.com");
if ($fp === false) {
  $url_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
  $url_status = "Disabled";
  $instruction_line = "<tr><td></td><td align=\"left\">cURL does not appear to be working correctly on your server.  Please ask your site admin to enable cURL support.</td><td></td><td></td></tr>";
} else if (!ini_get('allow_url_fopen')) {
  $url_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
  $url_status = "Disabled";
  $instruction_line = "<tr><td></td><td align=\"left\">Unable to communicate to outside websites.  Please ask your host to enable the PHP allow_url_fopen option in the server configuration.</td><td></td><td></td></tr>";
}
echo '              <tr>
                <td align="center">'.$url_image.'</td>
                <td>Able to Access Outside Websites (URL Wrappers &amp; cURL)</td>
                <td align="center">Enabled</td>
                <td align="center">'.$url_status.'</td>
              </tr>'.$instruction_line;

$instruction_line = "";
$err_status = "No";
$err_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
if (error_reporting() & E_NOTICE) {
  $err_status = "Yes";
  $err_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
  $instruction_line = "<tr><td></td><td align=\"left\">Your server is set to display notices.  Please contact your host and ask them to turn off displaying notices.  Dispalying notices is not appropriate for a production server.</td><td></td><td></td></tr>";
}              
echo '              <tr>
                  <td align="center">'.$err_image.'</td>
                <td>Report Notices</td>
                <td align="center">No</td>
                <td align="center">'.$err_status.'</td>
              </tr>'.$instruction_line;
              
//$sql_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
$sql_image = '<img src="http://www.contentfarmerpro.com/images/checks/unknown.jpg" alt="Unknown" title="Unknown" />';
$sql_version = '?';
if (isset($_POST['db_username'])) {
  $link = @mysql_connect($_POST['host'], $_POST['db_username'], $_POST['db_password']);
  if (!$link) {
    $sql_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
    $instruction_line = "<tr><td></td><td align=\"left\">Unable to connect to the database with the information provided.</td><td></td><td></td></tr>";
  } else {
    $sql_version = @mysql_get_server_info();
    if ($sql_version < '4.1') {
      $sql_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
      $instruction_line = "<tr><td></td><td>MySQL version 4.1+ is required to use Content Farmer Professional Edition&trade;.  Version 5+ is recommended for maximum performance.</td><td></td><td></td></tr>";
    } else {
      $sql_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
      $instruction_line = "";
    }
  }
} else {
  $instruction_line = '<tr><td></td><td align="left"><form method="post" action="server_test.php">
    <p>Please enter your database information so that the MySQL version can be tested.</p>
      Host: <input type="text" name="db_host" id="db_host" value="localhost" /><br />
      Username: <input type="text" name="db_username" id="db_username"  /><br />
      Password: <input type="text" name="db_password" id="db_password"  /><br />
      <input type="submit" value="Test Server" />
  </form></td><td></td><td></td></tr>';
}
echo '              <tr>
                <td align="center">'.$sql_image.'</td>
                <td>MySQL Version</td>
                <td align="center">4.1+</td>
                <td align="center">'.$sql_version.'</td>
              </tr>'.$instruction_line;
$instruction_line = "<tr><td></td><td>Ability to connect to secure webpages not available.  Please ask your host to enable OpenSSL on your server.</td><td></td><td></td></tr>";
$ssl_image = '<img src="http://www.contentfarmerpro.com/images/checks/fail.jpg" alt="Fail" title="Fail" />';
$ssl_status = "No";
if (extension_loaded('openssl')) {
  $ssl_image = '<img src="http://www.contentfarmerpro.com/images/checks/pass.jpg" alt="Pass" title="Pass" />';
  $instruction_line = "";
  $ssl_status = "Yes";
}
echo '              <tr>
                <td align="center">'.$ssl_image.'</td>
                <td>SSL Connections Allowed (OpenSSL Installed)</td>
                <td align="center">Yes</td>
                <td align="center">'.$ssl_status.'</td>
              </tr>
            </table></center>';
                
             echo '</div>
             <div style="display:block;clear:both;width:90%;border-top:3px #0348a5 solid;margin-left:2em;margin-right:2em;"></div>
</div><div id="footer"></div>
  </body>
</html>';

function CurlGet($URL) {
  $ch = curl_init();    // initialize curl handle

  curl_setopt($ch, CURLOPT_URL,$URL); // set url to post to
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
  curl_setopt($ch, CURLOPT_TIMEOUT, 20); // times out after 10s - change to whatever you want the timeout to be.

  $result = @curl_exec($ch); // run the whole process
  curl_close($ch);

  return $result;
}
?>