PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/install/troubleshooter.php

https://gitlab.com/jiyath/pligg-cms
PHP | 292 lines | 58 code | 12 blank | 222 comment | 17 complexity | 150dac4eea88189992a4554c83da691f MD5 | raw file
Possible License(s): CC-BY-3.0, GPL-2.0, Apache-2.0
  1. <?php
  2. error_reporting(E_ALL^E_NOTICE);
  3. $page = 'troubleshooter';
  4. $include='header.php'; if (file_exists($include)) { include_once($include); }
  5. $include='functions.php'; if (file_exists($include)) { require_once($include); }
  6. ?>
  7. <style type="text/css">
  8. .popover-inner {
  9. width:500px;
  10. }
  11. </style>
  12. <script type="text/javascript" language="JavaScript"><!--
  13. function InsertContent(tid) {
  14. if(document.getElementById(tid).style.display == "none") {
  15. document.getElementById(tid).style.display = "";
  16. }
  17. else {
  18. document.getElementById(tid).style.display = "none";
  19. }
  20. }
  21. //--></script>
  22. <?php
  23. // MySQL Version
  24. // No easy way to determine the version without having established a connection to the database. This method reads the phpinfo data.
  25. ob_start();
  26. phpinfo();
  27. $info = ob_get_contents();
  28. ob_end_clean();
  29. $start = explode("<h2><a name=\"module_mysql\">mysql</a></h2>",$info,1000);
  30. if(count($start) < 2){
  31. $mysqlversion = '0';
  32. }else{
  33. $again = explode("<tr><td class=\"e\">Client API version </td><td class=\"v\">",$start[1],1000);
  34. $last_time = explode(" </td></tr>",$again[1],1000);
  35. $mysqlversion = $last_time[0];
  36. }
  37. $pattern = '/[^0-9-.]/i';
  38. $replacement = '';
  39. $mysqlversion = preg_replace($pattern, $replacement, $mysqlversion);
  40. // Tally up how many items are fulfilled.
  41. $required = 23; // This should be the number of checks being performed
  42. $tally = 0;
  43. if (glob("../languages/*.conf")) { $tally = $tally+1;}
  44. if (phpversion() > 4) { $tally = $tally+1; }
  45. if ($mysqlversion > 4) { $tally = $tally+1; }
  46. if (function_exists('curl_version')){ $tally = $tally+1; }
  47. if (function_exists('fopen')){ $tally = $tally+1; }
  48. if (function_exists('fwrite')){ $tally = $tally+1; }
  49. if (file_get_contents(__FILE__)){ $tally = $tally+1; }
  50. if (function_exists('gd_info')){ $tally = $tally+1; }
  51. if (file_exists('../settings.php')) { $tally = $tally+1; }
  52. if (file_exists('../libs/dbconnect.php')) { $tally = $tally+1; }
  53. if (file_exists('../logs/bannedips.log')) { $tally = $tally+1; }
  54. if (is_writable('../logs/bannedips.log')) { $tally = $tally+1; }
  55. if (file_exists('../logs/domain-blacklist.log')) { $tally = $tally+1; }
  56. if (is_writable('../logs/domain-blacklist.log')) { $tally = $tally+1; }
  57. if (file_exists('../logs/domain-whitelist.log')) { $tally = $tally+1; }
  58. if (is_writable('../logs/domain-whitelist.log')) { $tally = $tally+1; }
  59. if (is_writable('../admin/backup/')) { $tally = $tally+1; }
  60. if (is_writable('../avatars/groups_uploaded/')) { $tally = $tally+1; }
  61. if (is_writable('../avatars/user_uploaded/')) { $tally = $tally+1; }
  62. if (is_writable('../cache/')) { $tally = $tally+1; }
  63. if (is_writable('../languages/')) { $tally = $tally+1; }
  64. foreach (glob("../languages/*.conf") as $filename) { $required = $required+1; if (is_writable($filename)) {$tally = $tally+1;} }
  65. if (is_writable('../libs/dbconnect.php')) { $tally = $tally+1; }
  66. if (is_writable('../settings.php')) { $tally = $tally+1; }
  67. $percent = percent($tally,$required);
  68. if ($tally < $required ){
  69. echo '<div class="alert alert-warning">
  70. <p><strong>Warning:</strong> Your server has only met <strong>'.$tally.'</strong> of the <strong>'.$required.'</strong> requirements to run Pligg CMS. While not all of the items on this page are required to run Pligg, we suggest that you try to comply with the suggestions made on this page. Please see the list below to discover what issues need to be addressed.</p><br />';
  71. echo '<div class="progress" style="margin-bottom: 9px;">
  72. <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$percent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$percent.'%;">
  73. <span class="sr-only">'.$percent.'% Complete</span>
  74. </div>
  75. </div>';
  76. } else {
  77. echo '<div class="alert alert-success">
  78. <p>Your server met all of the requirements needed to run Pligg CMS. See the information below for a detailed report.</p><br />';
  79. echo '<div class="progress" style="margin-bottom: 9px;">
  80. <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$percent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$percent.'%;">
  81. <span class="sr-only">'.$percent.'% Complete</span>
  82. </div>
  83. </div>';
  84. }
  85. ?>
  86. </div>
  87. <?php
  88. echo '<table class="table table-bordered table-striped">';
  89. echo '<thead><tr><th colspan="2">Checking for files need to be renamed</th></tr></thead>';
  90. echo '<tbody>';
  91. // Start Language Check
  92. $rename = " must be renamed to ";
  93. $language_file_count = 0;
  94. foreach (glob("../languages/*.conf") as $filename) { $language_file_count = $language_file_count+1;}
  95. if (!glob("../languages/*.conf")) {
  96. echo '<tr><td style="width:20px;" class="bad"><i class="fa fa-times"></i></td><td>No Language file has been detected! You will need to remove the .default extension from one of these language files:<ul style="margin:0px 0 5px 15px;padding:0;">';
  97. getfiles("../languages"); // List language files
  98. echo '</ul></td></tr>';
  99. }else{
  100. echo "<tr><td style='width:20px;' class='good'><i class='fa fa-check'></i></td><td>You have renamed ";
  101. echo '<a id="langfiles" data-trigger="hover" data-html="true" data-content="<ul>';
  102. foreach (glob("../languages/*.conf") as $filename) {
  103. echo "<li>$filename</li>";
  104. }
  105. echo '</ul>" rel="popover" href="#" data-original-title="Renamed Language Files">'.$language_file_count.' language file(s)</a>, which are ready to be used</td></tr>'."\n";
  106. }
  107. $settings = '../settings.php';
  108. $settingsdefault = '../settings.php.default';
  109. if (file_exists($settings)) {
  110. echo '<tr><td ckass="good"><i class="fa fa-check" ></i></td><td>'.$settings.'</td></tr>';
  111. } else {
  112. if (file_exists($settingsdefault)) {
  113. echo '<tr><td class="bad"><i class="fa fa-times"></i></td><td>'.$settingsdefault.$rename.$settings.'.</td></tr>';
  114. }
  115. }
  116. $dbconnect = '../libs/dbconnect.php';
  117. $dbconnectdefault = '../libs/dbconnect.php.default';
  118. if (file_exists($dbconnect)) {
  119. echo '<tr><td><i class="fa fa-check"></i></td><td>'.$dbconnect.'</td></tr>';
  120. } else {
  121. if (file_exists($dbconnectdefault)) {
  122. echo '<tr><td><i class="fa fa-times"></i></td><td>'.$dbconnectdefault.$rename.$dbconnect.'.</td></tr>';
  123. }
  124. }
  125. $bannedips = '../logs/bannedips.log';
  126. $bannedipsdefault = '../logs.default/bannedips.log';
  127. if (file_exists($bannedips)) {
  128. echo '<tr><td><i class="fa fa-check"></i></td><td>'.$bannedips.'</td></tr>';
  129. } else {
  130. if (file_exists($bannedipsdefault)) {
  131. echo '<tr><td><i class="fa fa-times"></i></td><td>'.$bannedipsdefault.$rename.$bannedips.'.</td></tr>';
  132. }
  133. }
  134. $localantispam = '../logs/domain-blacklist.log';
  135. $localantispamdefault = '../logs.default/domain-blacklist.log';
  136. if (file_exists($localantispam)) {
  137. echo '<tr><td><i class="fa fa-check"></i></td><td>'.$localantispam.'</td></tr>';
  138. } else {
  139. if (file_exists($localantispamdefault)) {
  140. echo '<tr><td><i class="fa fa-times"></i></td><td>'.$localantispamdefault.$rename.$localantispam.'.</td></tr>';
  141. }
  142. }
  143. $localwhitelist = '../logs/domain-whitelist.log';
  144. $localwhitelistdefault = '../logs.default/domain-whitelist.log';
  145. if (file_exists($localwhitelist)) {
  146. echo '<tr><td><i class="fa fa-check"></i></td><td>'.$localwhitelist.'</td></tr>';
  147. } else {
  148. if (file_exists($localwhitelistdefault)) {
  149. echo '<tr><td><i class="fa fa-times"></i></td><td>'.$localwhitelistdefault.$rename.$localwhitelist.'.</td></tr>';
  150. }
  151. }
  152. echo '</tbody></table>';
  153. /* This causes a conflict if there is no lang_english.conf language file. */
  154. /*
  155. include_once('../config.php');
  156. if ($URLMethod == 2 && !file_exists('../.htaccess')) { echo '<tr><td><i class="fa fa-times"></i></td><td>URL Method 2 is enabled in your Admin Panel, but the file .htaccess does not exist! Please rename the file "htaccess.default" to ".htaccess"</td></tr>'; }
  157. if ((!$my_base_url) || ($my_base_url == '')) { echo '<tr><td><i class="fa fa-times"></i></td><td>Your Base URL is not set - Visit <a href = "../admin/admin_config.php?page=Location%20Installed">Admin > Config > Location Installed</a> to change your settings. You can also temporarily change the value from ../settings.php if you aren\'t able to access the Admin Panel.</td></tr>'; }
  158. */
  159. echo '<table class="table table-bordered table-striped">';
  160. echo '<thead><tr><th colspan="2">Checking <a id="chmod" data-trigger="hover" data-html="true" data-content="<span style=\'font-weight:normal;\'>CHMOD represents the read, write, and execute permissions given to files and directories. Pligg CMS requires that certain files and directories are given a CHMOD status of 0777, allowing Pligg to have access to make changes to files. Any lines that return as an error represent files that need to be updated to CHMOD 0777.<span>" rel="popover" href="http://en.wikipedia.org/wiki/Chmod" data-original-title="CHMOD">CHMOD Settings</a></th></tr></thead>';
  161. echo '<tbody>';
  162. $file='../admin/backup/';
  163. if (!is_writable($file)) { echo '<tr><td style="width:20px;"><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this directory to 777.</span></td></tr>'; }
  164. if (is_writable($file)) { echo '<tr><td style="width:20px;"><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  165. $file='../avatars/groups_uploaded/';
  166. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this directory to 777.</span></td></tr>'; }
  167. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  168. $file='../avatars/user_uploaded/';
  169. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this directory to 777.</span></td></tr>'; }
  170. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  171. $file='../cache/';
  172. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this directory to 777.</span></td></tr>'; }
  173. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  174. $file='../languages/';
  175. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this directory and all contained files to 777.</span></td></tr>'; }
  176. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  177. foreach (glob("../languages/*.conf") as $filename) {
  178. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$filename.' is not writable! Please chmod this file to 777.</span></td></tr>'; }
  179. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$filename.'</span></td></tr>'; }
  180. }
  181. $file='../logs/bannedips.log';
  182. if (file_exists($file)) {
  183. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this file to 666.</span></td></tr>'; }
  184. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  185. }
  186. $file='../logs/domain-blacklist.log';
  187. if (file_exists($file)) {
  188. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this file to 666.</span></td></tr>'; }
  189. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  190. }
  191. $file='../logs/domain-whitelist.log';
  192. if (file_exists($file)) {
  193. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this file to 666.</span></td></tr>'; }
  194. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  195. }
  196. $file='../libs/dbconnect.php';
  197. if (file_exists($file)) {
  198. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this file to 666.</span></td></tr>'; }
  199. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  200. }
  201. $file='../settings.php';
  202. if (file_exists($file)) {
  203. if (!is_writable($file)) { echo '<tr><td><i class="fa fa-times"></i></td><td>'.$file.' is not writable! Please chmod this file to 666.</span></td></tr>'; }
  204. if (is_writable($file)) { echo '<tr><td><i class="fa fa-check"></i></td><td>'.$file.'</span></td></tr>'; }
  205. }
  206. echo '<table class="table table-bordered table-striped">';
  207. echo '<thead><tr><th colspan="2">Checking Server Settings</th></tr></thead>';
  208. echo '<tbody>';
  209. // PHP
  210. $phpversion = phpversion();
  211. echo '<tr><td>';
  212. if ($phpversion < 5) {
  213. echo '<i class="fa fa-times"></i>';
  214. } else if ($phpversion > 4) {
  215. echo '<i class="fa fa-check"></i>';
  216. }
  217. echo '</td><td><a id="phpversion" data-trigger="hover" data-content="Pligg has been tested on both PHP versions 4 and 5. We have designed the content management system based on PHP 5 technologies, so certain problems may occur when using older versions of PHP. We suggest that your server runs a mininum of PHP 5." rel="popover" href="http://us3.php.net/tut.php" data-original-title="PHP Version">PHP Version ('.$phpversion.')</a></td>';
  218. echo '</tr>';
  219. echo '<tr><td>';
  220. if ($mysqlversion < 5) {
  221. echo '<i class="fa fa-times"></i>';
  222. } else if ($mysqlversion > 4) {
  223. echo '<i class="fa fa-check"></i>';
  224. }
  225. echo '</td><td><a id="mysqlversion" data-trigger="hover" data-content="Pligg has been tested on both MySQL versions 4 and 5, during that process we have discovered that bugs will occassionally pop up is you are running MySQL 4. For this reason we suggest that you use a server with MySQL 5 or later to run a Pligg CMS website. MySQL 5 has been available for some time now and we hope that most major web hosts now support it. It offers features that are not built into MySQL 4, which we may have used when writing code for Pligg CMS." rel="popover" href="http://dev.mysql.com/doc/" data-original-title="MySQL Version">MySQL Version ('.$mysqlversion.')</a></td>';
  226. echo '</tr>';
  227. echo '<tr><td style="width:20px;">', function_exists('curl_version') ? '<i class="fa fa-check"></i></td>' : '<i class="fa fa-times"></i></td>';
  228. echo '<td><a id="curlwarning" data-trigger="hover" data-content="cURL is a PHP library that allows Pligg to connect to external websites." rel="popover" href="http://php.net/manual/en/book.curl.php" data-original-title="cURL PHP Extension">cURL</a></td></tr>';
  229. echo '<tr><td>', function_exists('fopen') ? '<i class="fa fa-check"></i></td>' : '<i class="fa fa-times"></i></td>';
  230. echo '<td><a id="fopenwarning" data-trigger="hover" data-content="The fopen function for PHP allows us to create, read, and manipulate local files." rel="popover" href="http://www.w3schools.com/php/func_filesystem_fopen.asp" data-original-title="fopen PHP Function">fopen</a></td></tr>';
  231. echo '<tr><td>', function_exists('fwrite') ? '<i class="fa fa-check"></i></td>' : '<i class="fa fa-times"></i></td>';
  232. echo '<td><a id="fwritewarning" data-trigger="hover" data-content="The fwrite function is used in conjunction with the fopen function. It allows PHP to write to an opened file." rel="popover" href="http://www.w3schools.com/php/func_filesystem_fwrite.asp" data-original-title="fwrite PHP Function">fwrite</td></tr>';
  233. echo '<tr><td>', file_get_contents(__FILE__) ? '<i class="fa fa-check"></i></td>' : '<i class="fa fa-times"></i></td>';
  234. echo '<td><a id="fgetwarning" data-trigger="hover" data-content="The file_get_contents() function for PHP reads a file into a string." rel="popover" href="http://www.w3schools.com/php/func_filesystem_file_get_contents.asp" data-original-title="fgetwarning PHP Function">file_get_contents</a></td></tr>';
  235. echo '<tr><td>', function_exists('gd_info') ? '<i class="fa fa-check"></i></td>' : '<i class="fa fa-times"></i></td>';
  236. echo '<td><a id="gdwarning" data-trigger="hover" data-content="The GD Graphics Library is a graphics software library for dynamically manipulating images. Any images handled by Pligg, like user avatar or group images, use GD to manipulate the file." rel="popover" href="http://php.net/manual/en/book.image.php" data-original-title="GD Graphics Library">GD Graphics Library</a></td></tr>';
  237. echo '</tbody></table>';
  238. echo '<div class="jumbotron" style="padding:25px 10px;"><p style="text-align:center">Please continue to the <a href="./install.php">Installation Page</a>, the <a href="./upgrade.php">Upgrade Page</a>, or the <a href="../readme.html">Pligg Readme</a>.</p></div>';
  239. ?>
  240. <?php $include='footer.php'; if (file_exists($include)) { include_once($include); } ?>
  241. <script>
  242. $(function ()
  243. {
  244. $("#langfiles").popover();
  245. $("#chmod").popover();
  246. $("#phpversion").popover();
  247. $("#mysqlversion").popover();
  248. $("#curlwarning").popover();
  249. $("#fopenwarning").popover();
  250. $("#fwritewarning").popover();
  251. $("#fgetwarning").popover();
  252. $("#gdwarning").popover();
  253. });
  254. </script>