PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/4.6/installation/index.php

http://miacms.googlecode.com/
PHP | 437 lines | 46 code | 7 blank | 384 comment | 5 complexity | 5221d3a9c4895646a5f7ddbdf442361a MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /**
  3. * Install instructions
  4. * @package MiaCMS
  5. * @author MiaCMS see README.php
  6. * @copyright see README.php
  7. * See COPYRIGHT.php for copyright notices and details.
  8. * @license GNU/GPL Version 2, see LICENSE.php
  9. * MiaCMS is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; version 2 of the License.
  12. */
  13. if (!defined('_VALID_MOS')) define( '_VALID_MOS', 1 );
  14. if (file_exists( '../configuration.php' ) && filesize( '../configuration.php' ) > 10) {
  15. header( "Location: ../index.php" );
  16. exit();
  17. }
  18. require_once( '../includes/version.php' );
  19. $_VERSION = new version();
  20. $version = $_VERSION->PRODUCT .' '. $_VERSION->RELEASE .'.'. $_VERSION->DEV_LEVEL .' '
  21. . $_VERSION->DEV_STATUS
  22. .' [ '.$_VERSION->CODENAME .' ] '. $_VERSION->RELDATE .' '
  23. . $_VERSION->RELTIME .' '. $_VERSION->RELTZ;
  24. /** Include common.php */
  25. include_once( 'common.php' );
  26. list($tmp_lang,$directions) = getLanguages();
  27. $lang = trim( mosGetParam( $_POST, 'lang', '' ) );
  28. $charset="utf-8";
  29. $text_direction="ltr";
  30. if($lang=='') {
  31. $lang="en";
  32. }else
  33. {
  34. $str_charset = explode(" ",$tmp_lang[$lang]);
  35. $charset = $str_charset[1];
  36. $text_direction = $directions[$lang];
  37. }
  38. $filename = "langconfig.php";
  39. if(is_writable($filename)) {
  40. $handle = fopen($filename,'w+');
  41. $content = "<?php\n";
  42. $content.="defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );\n";
  43. $content .= "\$lang = \"$lang\";\n";
  44. $content .= "\$charset = \"$charset\";\n";
  45. $content .= "\$text_direction = \"$text_direction\";\n";
  46. $content .= "\$gettext =& phpgettext();\n";
  47. $content .= "\$gettext->debug = '0';\n";
  48. $content .= "\$gettext->has_gettext = '0';\n";
  49. $content .= "\$gettext->setlocale(\$lang);\n";
  50. $content .= "\$gettext->bindtextdomain(\$lang, 'language/');\n";
  51. $content .= "\$gettext->textdomain(\$lang);\n";
  52. $content .= "?>";
  53. fwrite($handle,$content);
  54. fclose($handle);
  55. }
  56. include_once( 'langconfig.php' );
  57. function getLanguages() {
  58. $langfiles = glob("language/*.xml");
  59. $langs = array();
  60. foreach($langfiles as $xml) {
  61. if(is_readable($xml)) {
  62. $source = file_get_contents($xml);
  63. $encoding = "UTF-8";
  64. if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
  65. $encoding = strtoupper($m[1]);
  66. }
  67. $parser = xml_parser_create();
  68. xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
  69. xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  70. xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  71. if (!xml_parse_into_struct($parser,$source,$values)) {
  72. die(sprintf("XML error: %s at ".$xml." in line %d",
  73. xml_error_string(xml_get_error_code($parser)),
  74. xml_get_current_line_number($parser)));
  75. }
  76. xml_parser_free($parser);
  77. $flag = true;
  78. $title = "English";
  79. foreach($values as $key=>$val) {
  80. $tag = strtolower($val['tag']);
  81. if($flag) {
  82. if($tag=="locale") {
  83. $title = $val['attributes']['title'];
  84. $text_direction = $val['attributes']['text_direction'];
  85. $flag = false;
  86. }
  87. }
  88. }
  89. $name = str_replace("language/","",$xml);
  90. $name = str_replace(".xml","",$name);
  91. $langs[$name] = $title." ".strtolower($encoding);
  92. $directions[$name]=$text_direction;
  93. }
  94. }
  95. return Array($langs,$directions);
  96. }
  97. function get_php_setting($val) {
  98. $r = (ini_get($val) == '1' ? 1 : 0);
  99. return $r ? T_('ON') : T_('OFF');
  100. }
  101. function writableCell( $folder ) {
  102. echo '<tr>';
  103. echo '<td class="item">' . $folder . '/</td>';
  104. echo '<td align="left">';
  105. echo is_writable( "../$folder" ) ? '<strong><span class="green">'.T_('Writeable').'</span></strong></td>' : '<strong><span class="red">'.T_('Unwriteable').'</span></strong>'.'</td>';
  106. echo '</tr>';
  107. }
  108. echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?".">";
  109. ?>
  110. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  111. <html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $text_direction;?>">
  112. <head>
  113. <title><?php echo T_('MiaCMS - Web Installer') ?></title>
  114. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
  115. <link rel="shortcut icon" href="../images/favicon.ico" />
  116. <link rel="stylesheet" href="install<?php if($text_direction=='rtl') echo '_'.$text_direction ?>.css" type="text/css" />
  117. <script type="text/javascript">
  118. <!--
  119. var checkobj
  120. function agreesubmit(el){
  121. checkobj=el
  122. if (document.all||document.getElementById){
  123. for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
  124. var tempobj=checkobj.form.elements[i]
  125. if(tempobj.type.toLowerCase()=="submit")
  126. tempobj.disabled=!checkobj.checked
  127. }
  128. }
  129. }
  130. function defaultagree(el){
  131. if (!document.all&&!document.getElementById){
  132. if (window.checkobj&&checkobj.checked)
  133. return true
  134. else{
  135. alert("<?php echo T_('Please read/accept license to continue installation')?>")
  136. return false
  137. }
  138. }
  139. }
  140. //-->
  141. </script>
  142. </head>
  143. <body>
  144. <div id="wrapper">
  145. <div id="header">
  146. </div>
  147. </div>
  148. <div id="ctr" align="center">
  149. <div class="install">
  150. <div id="stepbar">
  151. <div class="step-on"><?php echo T_('pre-installation check') ?></div>
  152. <div class="step-off"><?php echo T_('step 1') ?></div>
  153. <div class="step-off"><?php echo T_('step 2') ?></div>
  154. <div class="step-off"><?php echo T_('step 3') ?></div>
  155. <div class="step-off"><?php echo T_('step 4') ?></div>
  156. <div class="far-right">
  157. <input name="Button2" type="submit" class="button" value="<?php echo T_('Next') ?> >>" onclick="window.location='install1.php';" />
  158. </div>
  159. </div>
  160. <div id="right">
  161. <div id="step"><?php echo T_('pre-installation check') ?></div>
  162. <div id="steposi"></div>
  163. <div class="clr"></div>
  164. <h1><?php echo T_('Pre-installation check for:') ?><!-- <br /> --> <?php echo $version; ?></h1>
  165. <form action="index.php" method="post" name="Langue">
  166. <h1><?php echo T_('MiaCMS installation language') ?>:</h1>
  167. <div class="install-text"> <?php echo T_('The installer automatically detects your browser language preferences. However, you can select one of the available languages.') ?>
  168. <div class="ctr"></div>
  169. </div>
  170. <div class="install-form">
  171. <div class="form-block">
  172. <table class="content">
  173. <tr>
  174. <td class="item"> <?php echo T_('Installation language') ?> </td>
  175. <td align="left">
  176. <?php
  177. echo '<select size="1" name="lang" onchange="this.form.submit();">';
  178. foreach ( $tmp_lang as $key=>$lang_found ){
  179. if( $key == $lang ){
  180. echo '<option value ="'.$key.'" selected="selected">'.ucfirst($lang_found)."</option>\n";
  181. }else{
  182. echo '<option value ="'.$key.'">'.ucfirst($lang_found)."</option>\n";
  183. }
  184. }
  185. echo '</select>';
  186. ?>
  187. </td>
  188. </tr>
  189. </table>
  190. </div>
  191. </div>
  192. <div class="install-form">
  193. <div class="form-block">
  194. <table class="content">
  195. <tr>
  196. <td colspan="2"><strong><?php echo T_('Language check') ?></strong></td>
  197. </tr>
  198. <tr>
  199. <td><?php echo T_('Installation language') ?></td>
  200. <td>
  201. <font color="green"><strong><?php echo ucfirst( $tmp_lang[$lang] ); ?></strong></font>
  202. </td>
  203. </tr>
  204. <tr>
  205. <td>ISO</td>
  206. <td>
  207. <font color="green"><strong><?php echo $charset; ?></strong></font>
  208. </td>
  209. </tr>
  210. </table>
  211. </div>
  212. </div>
  213. </form>
  214. <div class="clr"></div>
  215. <div class="install-text">
  216. <?php echo T_('If any of these items are highlighted in red then please take actions to correct them. Failure to do so could lead to your MiaCMS installation not functioning correctly.') ?>
  217. <div class="ctr"></div>
  218. </div>
  219. <div class="install-form">
  220. <div class="form-block">
  221. <table class="content">
  222. <tr>
  223. <td class="item">
  224. <?php echo T_('PHP version') ?> >= 4.3.2
  225. </td>
  226. <td align="left">
  227. <?php echo phpversion() < '4.3.2' ? '<strong><span class="red">'.T_('No').'</span></strong>' : '<strong><span class="green">'.T_('Yes').'</span></strong>';?>
  228. </td>
  229. </tr>
  230. <tr>
  231. <td>
  232. &nbsp; - <?php echo T_('zlib compression support') ?>
  233. </td>
  234. <td align="left">
  235. <?php echo extension_loaded('zlib') ? '<strong><span class="green">'.T_('Available').'</span></strong>' : '<strong><span class="red">'.T_('Unavailable').'</span></strong>';?>
  236. </td>
  237. </tr>
  238. <tr>
  239. <td>
  240. &nbsp; - <?php echo T_('XML support') ?>
  241. </td>
  242. <td align="left">
  243. <?php echo extension_loaded('xml') ? '<strong><span class="green">'.T_('Available').'</span></strong>' : '<strong><span class="red">'.T_('Unavailable').'</span></strong>';?>
  244. </td>
  245. </tr>
  246. <tr>
  247. <td>
  248. &nbsp; - <?php echo T_('MySQL support') ?>
  249. </td>
  250. <td align="left">
  251. <?php echo function_exists( 'mysql_connect' ) ? '<strong><span class="green">'.T_('Available').'</span></strong>' : '<strong><span class="red">'.T_('Unavailable').'</span></strong>';?>
  252. </td>
  253. </tr>
  254. <tr>
  255. <td>
  256. &nbsp; - <span class="red"><?php echo T_('Note:') ?></span>
  257. </td>
  258. <td align="left">
  259. <?php echo T_('MySQL Strict Mode is not supported') ?>
  260. </td>
  261. </tr>
  262. <tr>
  263. <td valign="top" class="item">
  264. configuration.php
  265. </td>
  266. <td align="left">
  267. <?php
  268. if (@file_exists('../configuration.php') && @is_writable( '../configuration.php' )){
  269. echo '<strong><span class="green">'.T_('Writeable').'</span></strong>';
  270. } else if (is_writable( '..' )) {
  271. echo '<strong><span class="green">'.T_('Writeable').'</span></strong>';
  272. } else {
  273. echo '<strong><span class="red">'.T_('Unwriteable').'</span></strong><br /><span class="small">'.T_('You can still continue the install as the configuration will be displayed at the end, just copy & paste this and upload.').'</span>';
  274. } ?>
  275. </td>
  276. </tr>
  277. <tr>
  278. <td class="item">
  279. <?php echo T_('Session save path') ?>
  280. </td>
  281. <td align="left">
  282. <strong><?php echo (($sp=ini_get('session.save_path'))?$sp:'Not set'); ?></strong>,
  283. <?php echo is_writable( $sp ) ? '<strong><span class="green">'.T_('Writeable').'</span></strong>' : '<strong><span class="red">'.T_('Unwriteable').'</span></strong>';?>
  284. </td>
  285. </tr>
  286. </table>
  287. </div>
  288. </div>
  289. <div class="clr"></div>
  290. <h1><?php echo T_('Recommended settings:') ?></h1>
  291. <div class="install-text">
  292. <?php echo T_('These settings are recommended for PHP in order to ensure full compatibility with MiaCMS. However, MiaCMS will still operate if your settings do not quite match the recommended.') ?>
  293. <br />
  294. <div class="ctr"></div>
  295. </div>
  296. <div class="install-form">
  297. <div class="form-block">
  298. <table class="content">
  299. <tr>
  300. <td class="toggle">
  301. <?php echo T_('Directive') ?>
  302. </td>
  303. <td class="toggle">
  304. <?php echo T_('Recommended') ?>
  305. </td>
  306. <td class="toggle">
  307. <?php echo T_('Actual') ?>
  308. </td>
  309. </tr>
  310. <?php
  311. $php_recommended_settings = array(array ('Safe Mode','safe_mode',T_('OFF')),
  312. array ('Display Errors','display_errors',T_('ON')),
  313. array ('File Uploads','file_uploads',T_('ON')),
  314. array ('Magic Quotes GPC','magic_quotes_gpc',T_('ON')),
  315. array ('Magic Quotes Runtime','magic_quotes_runtime',T_('OFF')),
  316. array ('Register Globals','register_globals',T_('OFF')),
  317. array ('Output Buffering','output_buffering',T_('OFF')),
  318. array ('Session auto start','session.auto_start',T_('OFF')),
  319. );
  320. foreach ($php_recommended_settings as $phprec) {
  321. ?>
  322. <tr>
  323. <td class="item"><?php echo $phprec[0]; ?>:</td>
  324. <td class="toggle"><?php echo $phprec[2]; ?>:</td>
  325. <td>
  326. <?php
  327. if ( get_php_setting($phprec[1]) == $phprec[2] ) {
  328. ?>
  329. <span class="green"><strong>
  330. <?php
  331. } else {
  332. ?>
  333. <span class="red"><strong>
  334. <?php
  335. }
  336. echo get_php_setting($phprec[1]);
  337. ?>
  338. </strong></span>
  339. </td>
  340. </tr>
  341. <?php
  342. }
  343. ?>
  344. </table>
  345. </div>
  346. </div>
  347. <div class="clr"></div>
  348. <h1><?php echo T_('Directory and File Permissions:') ?></h1>
  349. <div class="install-text">
  350. <?php echo T_('In order for MiaCMS to function correctly it needs to be able to access or write to certain files or directories. If you see "Unwriteable" you need to change the permissions on the file or directory to allow MiaCMS to write to it.') ?>
  351. <div class="clr">&nbsp;&nbsp;</div>
  352. <div class="ctr"></div>
  353. </div>
  354. <div class="install-form">
  355. <div class="form-block">
  356. <table class="content">
  357. <?php
  358. writableCell( 'administrator/backups' );
  359. writableCell( 'administrator/components' );
  360. writableCell( 'administrator/modules' );
  361. writableCell( 'administrator/templates' );
  362. writableCell( 'cache' );
  363. writableCell( 'components' );
  364. writableCell( 'images' );
  365. writableCell( 'images/banners' );
  366. writableCell( 'images/stories' );
  367. ?>
  368. <tr>
  369. <td valign="top" class="item">
  370. installation/langconfig.php
  371. </td>
  372. <td align="left">
  373. <?php
  374. if (@file_exists('../installation/langconfig.php') && @is_writable( '../installation/langconfig.php' )){
  375. echo '<strong><span class="green">'.T_('Writeable').'</span></strong>';
  376. } else if (is_writable( '..' )) {
  377. echo '<strong><span class="green">'.T_('Writeable').'</span></strong>';
  378. } else {
  379. echo '<strong><span class="red">'.T_('Unwriteable').'</span></strong>';
  380. } ?>
  381. </td>
  382. </tr>
  383. <?php
  384. writableCell( 'language' );
  385. writableCell( 'mambots' );
  386. writableCell( 'mambots/content' );
  387. writableCell( 'mambots/editors' );
  388. writableCell( 'mambots/editors-xtd' );
  389. writableCell( 'mambots/search' );
  390. writableCell( 'media' );
  391. writableCell( 'modules' );
  392. writableCell( 'templates' );
  393. writableCell( 'uploadfiles' );
  394. ?>
  395. </table>
  396. </div>
  397. <div class="clr"></div>
  398. </div>
  399. <div class="clr"></div>
  400. </div>
  401. <div class="clr"></div>
  402. </div>
  403. </div>
  404. <div class="ctr">
  405. <?php echo T_('<a href="http://www.miacms.org" target="_blank">MiaCMS </a> is Free Software released under the <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">GNU/GPL License</a>.') ?>
  406. </div>
  407. </body>
  408. </html>