[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 <?php 2 3 /* Reminder: always indent with 4 spaces (no tabs). */ 4 // +---------------------------------------------------------------------------+ 5 // | Geeklog 1.4 | 6 // +---------------------------------------------------------------------------+ 7 // | check.php | 8 // | | 9 // | Geeklog check installation script | 10 // +---------------------------------------------------------------------------+ 11 // | Copyright (C) 2002-2006 by the following authors: | 12 // | | 13 // | Authors: Dirk Haun - dirk AT haun-online DOT de | 14 // +---------------------------------------------------------------------------+ 15 // | | 16 // | This program is free software; you can redistribute it and/or | 17 // | modify it under the terms of the GNU General Public License | 18 // | as published by the Free Software Foundation; either version 2 | 19 // | of the License, or (at your option) any later version. | 20 // | | 21 // | This program is distributed in the hope that it will be useful, | 22 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 23 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 24 // | GNU General Public License for more details. | 25 // | | 26 // | You should have received a copy of the GNU General Public License | 27 // | along with this program; if not, write to the Free Software Foundation, | 28 // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 29 // | | 30 // +---------------------------------------------------------------------------+ 31 // 32 // $Id: check.php,v 1.8 2006/01/28 17:48:49 dhaun Exp $ 33 34 /** 35 * This script tests the file and directory permissions, thus addressing the 36 * most common errors / omissions when setting up a new Geeklog site ... 37 * 38 * @author Dirk Haun <dirk AT haun-online DOT de> 39 * 40 */ 41 42 require_once ('../../lib-common.php'); 43 44 $numTests = 7; // total number of tests to perform 45 $successful = 0; // number of successful tests 46 $failed = 0; // number of failed tests 47 $notTested = 0; // number of tests that were skipped (for disabled features) 48 49 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' . LB; 50 echo '<html>' . LB; 51 echo '<head>' . LB; 52 echo '<title>Geeklog installation check</title>' . LB; 53 echo '</head>' . LB; 54 echo '<body text="#000000" bgcolor="#ffffff">' . LB; 55 echo '<h2>Testing your Geeklog installation ...</h2>' . LB; 56 57 echo '<p>Testing <b>logs</b> directory ' . $_CONF['path_log'] . ' ...<br>' . LB; 58 $errfile = @fopen ($_CONF['path_log'] . 'error.log', 'a'); 59 if ($errfile) fclose ($errfile); 60 $accfile = @fopen ($_CONF['path_log'] . 'access.log', 'a'); 61 if ($accfile) fclose ($accfile); 62 63 if (!$errfile || !$accfile) { 64 echo '<font color="#ff0000">Could not open '; 65 if (!$errfile) { 66 echo '<b>error.log</b> '; 67 } 68 if (!$errfile && !$accfile) { 69 echo 'and '; 70 } 71 if (!$accfile) { 72 echo '<b>access.log</b> '; 73 } 74 echo 'for writing.</font><br>Please check that you have set the <b>logs</b> directory <em>and</em> the files <b>error.log</b> and <b>access.log</b> in that directory to <b>chmod 775</b>.' . LB; 75 $logPerms = sprintf ("%3o", @fileperms ($_CONF['path_log']) & 0777); 76 $errPerms = sprintf ("%3o", @fileperms ($_CONF['path_log'] . 'error.log') & 0777); 77 $accPerms = sprintf ("%3o", @fileperms ($_CONF['path_log'] . 'access.log') & 0777); 78 echo '<table cellspacing="0" cellpadding="0" border="0">' . LB; 79 echo "<tr><td>Current permissions for <b>logs</b>: </td><td>$logPerms</td></tr>" . LB; 80 echo "<tr><td>Current permissions for <b>error.log</b>: </td><td>$errPerms</td></tr>" . LB; 81 echo "<tr><td>Current permissions for <b>access.log</b>: </td><td>$accPerms</td></tr>" . LB; 82 echo '</table>' . LB; 83 $failed++; 84 } else { 85 echo '<b>logs</b> directory and the <b>error.log</b> and <b>access.log</b> files are okay.' . LB; 86 $successful++; 87 } 88 89 echo '<p>Testing <b>backend</b> directory ' . SYND_getFeedPath() . ' ...<br>' . LB; 90 if ($_CONF['backend'] > 0) { 91 if (!$file = @fopen ($_CONF['rdf_file'], 'w')) { 92 echo '<font color="#ff0000">Could not open the RSS file ' . $_CONF['rdf_file'] . ' for writing.</font><br>Please check that you have set both the <b>backend</b> directory <em>and</em> the <b>geeklog.rss</b> file in that directory to <b>chmod 775</b>.' . LB; 93 $endPerms = sprintf ("%3o", @fileperms (SYND_getFeedPath()) & 0777); 94 $rdfPerms = sprintf ("%3o", @fileperms ($_CONF['rdf_file']) & 0777); 95 echo '<table cellspacing="0" cellpadding="0" border="0">' . LB; 96 echo "<tr><td>Current permissions for <b>backend</b>: </td><td>$endPerms</td></tr>" . LB; 97 echo "<tr><td>Current permissions for <b>geeklog.rss</b>: </td><td>$rdfPerms</td></tr>" . LB; 98 echo '</table>' . LB; 99 $failed++; 100 } else { 101 fclose ($file); 102 echo '<b>backend</b> directory and the <b>geeklog.rss</b> file are okay.' . LB; 103 $successful++; 104 } 105 } else { 106 echo '<p>Export of Geeklog headlines is switched off - <b>backend</b> directory not tested.</p>' . LB; 107 $notTested++; 108 } 109 110 if ($_CONF['allow_user_photo'] > 0) { 111 echo '<p>Testing <b>userphotos</b> directory ' . $_CONF['path_images'] . 'userphotos/ ...<br>' . LB; 112 if (!$file = @fopen ($_CONF['path_images'] . 'userphotos/test.gif', 'w')) { 113 echo '<font color="#ff0000">Could not write to <b>' . $_CONF['path_images'] . 'userphotos/</b>.</font><br>Please make sure this directory exists and is set to <b>chmod 775</b>.<br>' . LB; 114 echo 'Current permissions for <b>userphotos</b>: ' . sprintf ("%3o", @fileperms ($_CONF['path_images'] . 'userphotos/') & 0777); 115 $failed++; 116 } else { 117 fclose ($file); 118 unlink ($_CONF['path_images'] . 'userphotos/test.gif'); 119 echo '<b>userphotos</b> directory is okay.' . LB; 120 $successful++; 121 } 122 } else { 123 echo '<p>User photos are disabled - <b>userphotos</b> directory not tested.' . LB; 124 $notTested++; 125 } 126 127 if ($_CONF['maximagesperarticle'] > 0) { 128 echo '<p>Testing <b>articles</b> directory ' . $_CONF['path_images'] . 'articles/ ...<br>' . LB; 129 if (!$file = @fopen ($_CONF['path_images'] . 'articles/test.gif', 'w')) { 130 echo '<font color="#ff0000">Could not write to <b>' . $_CONF['path_images'] . 'articles/</b>.</font><br>Please make sure this directory exists and is set to <b>chmod 775</b>.<br>' . LB; 131 echo 'Current permissions for <b>articles</b>: ' . sprintf ("%3o", @fileperms ($_CONF['path_images'] . 'articles/') & 0777); 132 $failed++; 133 } else { 134 fclose ($file); 135 unlink ($_CONF['path_images'] . 'articles/test.gif'); 136 echo '<b>articles</b> directory is okay.' . LB; 137 $successful++; 138 } 139 } else { 140 echo '<p>Images in articles are disabled - <b>articles</b> directory not tested.' . LB; 141 $notTested++; 142 } 143 144 echo '<p>Testing <b>topics</b> directory ' . $_CONF['path_images'] . 'topics/ ...<br>' . LB; 145 if (!$file = @fopen ($_CONF['path_images'] . 'topics/test.gif', 'w')) { 146 echo '<font color="#ff0000">Could not write to <b>' . $_CONF['path_images'] . 'topics/</b>.</font><br>Please make sure this directory exists and is set to <b>chmod 775</b>.<br>' . LB; 147 echo 'Current permissions for <b>topics</b>: ' . sprintf ("%3o", @fileperms ($_CONF['path_images'] . 'articles/') & 0777); 148 $failed++; 149 } else { 150 fclose ($file); 151 unlink ($_CONF['path_images'] . 'topics/test.gif'); 152 echo '<b>topics</b> directory is okay.' . LB; 153 $successful++; 154 } 155 156 /* 157 158 if ($_CONF['pdf_enabled'] != 0) { 159 echo '<p>Testing <b>pdfs</b> directory ' . $_CONF['path_pdf'] . ' ...<br>' . LB; 160 if (!$file = @fopen ($_CONF['path_pdf'] . 'test.pdf', 'w')) { 161 echo '<font color="#ff0000">Could not write to <b>' . $_CONF['path_pdf'] . '</b>.</font><br>Please make sure this directory exists and is set to <b>chmod 775</b>.<br>' . LB; 162 echo 'Current permissions for <b>pdfs</b>: ' . sprintf ("%3o", @fileperms ($_CONF['path_pdf']) & 0777); 163 $failed++; 164 } else { 165 fclose ($file); 166 unlink ($_CONF['path_pdf'] . 'test.pdf'); 167 echo '<b>pdfs</b> directory is okay.' . LB; 168 $successful++; 169 } 170 } else { 171 echo '<p>PDF support is disabled - <b>pdfs</b> directory not tested.' . LB; 172 $notTested++; 173 } 174 175 */ 176 177 if ($_CONF['allow_mysqldump'] == 1) { 178 echo '<p>Testing <b>backups</b> directory ' . $_CONF['backup_path'] . ' ...<br>' . LB; 179 if (!$file = @fopen ($_CONF['backup_path'] . 'test.txt', 'w')) { 180 echo '<font color="#ff0000">Could not write to <b>' . $_CONF['backup_path'] . '</b>.</font><br>Please make sure this directory exists and is set to <b>chmod 775</b>.<br>' . LB; 181 echo 'Current permissions for <b>backups</b>: ' . sprintf ("%3o", @fileperms ($_CONF['backup_path']) & 0777); 182 $failed++; 183 } else { 184 fclose ($file); 185 unlink ($_CONF['backup_path'] . 'test.txt'); 186 echo '<b>backups</b> directory is okay.' . LB; 187 $successful++; 188 } 189 } else { 190 echo '<p>Database backups are disabled - <b>backups</b> directory not tested.' . LB; 191 $notTested++; 192 } 193 194 echo '<p>Testing <b>data</b> directory ' . $_CONF['path_data'] . ' ...<br>' . LB; 195 if (!$file = @fopen ($_CONF['path_data'] . 'test.txt', 'w')) { 196 echo '<font color="#ff0000">Could not write to <b>' . $_CONF['path_data'] . '</b>.</font><br>Please make sure this directory exists and is set to <b>chmod 775</b>.<br>' . LB; 197 echo 'Current permissions for <b>data</b>: ' . sprintf ("%3o", @fileperms ($_CONF['path_data']) & 0777); 198 $failed++; 199 } else { 200 fclose ($file); 201 unlink ($_CONF['path_data'] . 'test.txt'); 202 echo '<b>data</b> directory is okay.' . LB; 203 $successful++; 204 } 205 206 echo "<p><strong>Results:</strong> " . ($numTests - $notTested) . " of $numTests tests performed: $successful successful, "; 207 if ($failed > 0) { 208 echo "<font color=\"#ff0000\">$failed failed</font>.</p>" . LB; 209 } else { 210 echo "$failed failed.</p>" . LB; 211 } 212 213 if ($failed > 0) { 214 echo '<h2>Test failed!</h2>'; 215 echo '<p><font color="#ff0000"><strong>Warning!</strong> Your Geeklog site is not set up properly. Please fix the errors listed above!</font></p>'; 216 echo '<p><strong>Note:</strong> If the above instructions tell you to chmod files and/or directories to 775 but they already are at 775, try <b>chmod 777</b> instead.</p>'; 217 } else { 218 echo '<h2>Test passed</h2>'; 219 echo '<p><strong>Congratulations!</strong> Your Geeklog site is set up properly and ready to go.</p>'; 220 } 221 222 echo '</body>' . LB; 223 echo '</html>' . LB; 224 225 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |