Simple PHP pre-installation checklist script


/ Published in: PHP
Save to your folder(s)

Hey guys how is everything going I am currently working on my own content management system and decided I would release a little pre-installation checklist script that makes sure you have all the required functions enabled on your hosting environment and shows you what you currently have and what is required in the end. If you have all the requirements that the script requires, it shows a little button at the bottom to continue the installation, if not, an error.

You can easily change the file you want to check writing to by editing $file

It comes with some styling already and in a nice table. Enjoy and let me know how it is.


Copy this code and paste it in your HTML
  1. <?php
  2. //the file and directory you will be writing your database information to
  3. $file = 'libs/db_connect.php';
  4. //start checking
  5. if(!function_exists('mail')) { $mail_msg="No"; } else { $mail_msg="Yes"; }
  6. if (!is_writable($file)) { $file_msg="No"; } else { $file_msg="Yes"; }
  7. if (!function_exists('mysql_connect')) { $mysql_msg="No"; } else { $mysql_msg="Yes"; }
  8. if (ini_get('file_uploads') == 0) { $file_msg="No"; } else { $file_msg="Yes"; }
  9. ?>
  10.  
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html>
  13. <head>
  14. <title>Pre-Installation checklist</title
  15. </head>
  16. <style type="text/css">
  17. /*TABLE CSS*/
  18. #wrap {
  19. margin: 10px auto 0;
  20. text-align: center;
  21. width: 500px;
  22. }
  23.  
  24. .btn {
  25. font-family: Courier New;
  26. color: #ffffff;
  27. font-size: 16px;
  28. background: #3498db;
  29. padding: 10px 20px 10px 20px;
  30. text-decoration: none;
  31. }
  32.  
  33. .btn:hover {
  34. background: #3cb0fd;
  35. text-decoration: none;
  36. }
  37.  
  38. table a:link {
  39. color: #666;
  40. font-weight: bold;
  41. text-decoration:none;
  42. }
  43. table {
  44. font-family:Arial, Helvetica, sans-serif;
  45. color:#666;
  46. font-size:12px;
  47. background:#eaebec;
  48. border:#ccc 1px solid;
  49. margin-bottom: 20px;
  50. width: 100%;
  51. }
  52. table th {
  53. padding:21px 25px 22px 25px;
  54. border-top:1px solid #fafafa;
  55. border-bottom:1px solid #e0e0e0;
  56. background: #ededed;
  57. }
  58. table th:first-child {
  59. text-align: left;
  60. padding-left:20px;
  61. }
  62. table tr {
  63. text-align: center;
  64. padding-left:20px;
  65. }
  66. table td:first-child {
  67. text-align: left;
  68. padding-left:20px;
  69. border-left: 0;
  70. }
  71. table td {
  72. padding:18px;
  73. border-top: 1px solid #ffffff;
  74. border-bottom:1px solid #e0e0e0;
  75. border-left: 1px solid #e0e0e0;
  76. background: #fafafa;
  77. }
  78. table tr.even td {
  79. background: #f6f6f6;
  80. }
  81. table tr:last-child td {
  82. border-bottom:0;
  83. }
  84. </style>
  85. <body>
  86. <div id="wrap">
  87.  
  88. <!-- WEBSITE GOES HERE -->
  89.  
  90. <table cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
  91.  
  92. <!-- Table Header -->
  93. <thead>
  94. <tr>
  95. <th>Required Fuctions</th>
  96. <th>Current</th>
  97. <th>Recommended</th>
  98. </tr>
  99. </thead>
  100. <!-- Table Header -->
  101.  
  102. <!-- Table Body -->
  103. <tbody>
  104.  
  105. <tr>
  106. <td>Is the <b><?php echo $file; ?></b> file writable?</td>
  107. <td><?php echo $file_msg; ?></td>
  108. <td>Yes</td>
  109. </tr>
  110.  
  111. <tr>
  112. <td>Is the mail() function enabled?</td>
  113. <td><?php echo $mail_msg; ?></td>
  114. <td>Yes</td>
  115. </tr>
  116.  
  117.  
  118.  
  119. <tr>
  120. <td>PHP Version</td>
  121. <td><?php echo function_exists('phpversion') ? phpversion() : ''; ?></td>
  122. <td><?php echo function_exists('phpversion') ? phpversion() : ''; ?></td>
  123. </tr>
  124.  
  125. <tr>
  126. <td>Is MySQL enabled?</td>
  127. <td><?php echo $mysql_msg; ?></td>
  128. <td>Yes</td>
  129. </tr>
  130.  
  131. <tr>
  132. <td>Is file uploading enabled?</td>
  133. <td><?php echo $file_msg; ?></td>
  134. <td>Yes</td>
  135. </tr>
  136.  
  137.  
  138. </tbody>
  139. <!-- Table Body -->
  140.  
  141. </table>
  142.  
  143.  
  144. <?php
  145. if (function_exists('mail') && is_writable($file) && function_exists('mysql_connect') && ini_get('file_uploads') == 1)
  146. {
  147. echo '<a href="" class="btn">Continue Installation</a>';
  148. }
  149. else
  150. {
  151. echo 'Please enable/install extensions before continuing, otherwise, the script will not work as designed.';
  152. }
  153.  
  154. ?>
  155.  
  156.  
  157.  
  158. </div>
  159. </body>
  160. </html>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.