/[web]/planet/common/install.php
ViewVC logotype

Contents of /planet/common/install.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1619 - (show annotations) (download)
Mon Aug 13 10:45:23 2012 UTC (11 years, 8 months ago) by dams
File size: 5879 byte(s)
- Import moonmoon
- Create repo per langs

1 <?php
2
3 require_once dirname(__FILE__) . '/app/app.php';
4
5 // This is an helper function returning an html table row to avoid code duplication
6 function installStatus($str, $msg, $result) {
7 $class = ($result) ? 'ok' : 'fail';
8 return '<tr><td>' . $str . '</td><td class="' . $class . '">' . $msg . '</td></tr>';
9 }
10
11 // If the password and config files exist, moonmoon is already installed
12 if (file_exists(dirname(__FILE__) . '/custom/config.yml')
13 && file_exists(dirname(__FILE__) . '/admin/inc/pwd.inc.php')) {
14 $status = 'installed';
15 } elseif (isset($_REQUEST['url'])) {
16 $save = array();
17 //Save config file
18 $config = array(
19 'url' => filter_var($_REQUEST['url'], FILTER_SANITIZE_ENCODED),
20 'name' => filter_var($_REQUEST['title'], FILTER_SANITIZE_SPECIAL_CHARS),
21 'locale' => filter_var($_REQUEST['locale'], FILTER_SANITIZE_SPECIAL_CHARS),
22 'items' => 10,
23 'shuffle' => 0,
24 'refresh' => 240,
25 'cache' => 10,
26 'nohtml' => 0,
27 'postmaxlength' => 0,
28 'cachedir' => './cache'
29 );
30
31 $CreatePlanetConfig = new PlanetConfig($config);
32 $save['config'] = file_put_contents(dirname(__FILE__).'/custom/config.yml', $CreatePlanetConfig->toYaml());
33
34 //Save password
35 $save['password'] = file_put_contents(dirname(__FILE__).'/admin/inc/pwd.inc.php', '<?php $login="admin"; $password="'.md5($_REQUEST['password']).'"; ?>');
36
37 if (0 != ($save['config'] + $save['password'])) {
38 $status = 'installed';
39 }
40 } else {
41
42 // We start by malking sure we have PHP5 as a base requirement
43 if(phpversion() >= 5) {
44 $strInstall = installStatus('Server is running PHP5', 'OK',true);
45 $strRecommendation = '';
46 } else {
47 $strInstall = installStatus('Server is running PHP5', 'FAIL',false);
48 $strRecommendation = '<li>Check your server documentation to activate PHP5</li>';
49 }
50
51 // Writable file requirements
52 $tests = array(
53 '/custom',
54 '/custom/people.opml',
55 '/admin/inc/pwd.inc.php',
56 '/cache',
57 );
58
59 // We now test that all required files are writable
60 foreach ($tests as $v) {
61 if(is_writable(dirname(__FILE__) . $v)) {
62 $strInstall .= installStatus("<code>$v</code> is writable", 'OK', true);
63 } else {
64 $strInstall .= installStatus("<code>$v</code> is writable", 'FAIL',false);
65 $strRecommendation .= "<li>Make <code>$v</code> writable with CHMOD</li>";
66 }
67 }
68
69 // We can now decide if we install moonmoon or not
70 $status = ($strRecommendation != '') ? 'error' : 'install';
71
72 }
73 ?>
74 <!DOCTYPE html>
75 <html lang="en">
76 <meta charset="utf-8">
77 <head>
78 <title><?=_g('moonmoon installation')?></title>
79 <style>
80 body {
81 font: normal 1em sans-serif;
82 width: 500px;
83 margin: 0 auto;
84 }
85
86 /* Error */
87 td.ok {
88 color: #090;
89 }
90
91 td.fail {
92 color: #900;
93 font-weight: bold;
94 }
95 th {
96 text-align: left;
97 }
98
99 /* Install */
100 .field label {
101 display: block;
102 }
103
104 .submit {
105 font-size: 2em;
106 }
107
108 </style>
109 </head>
110
111 <body>
112 <h1><?=_g('moonmoon installation')?></h1>
113
114 <?php if ($status == 'error') : ?>
115 <div id="compatibility">
116 <h2>Sorry, your server is not compatible with moonmoon.</h2>
117
118 <h3>Your server does not fulfill the requirements</h3>
119 <table>
120 <thead>
121 <tr>
122 <th>Test</th>
123 <th>Result</th>
124 </tr>
125 </thead>
126 <tbody>
127 <?php echo $strInstall ?>
128 </tbody>
129 </table>
130
131 <h3>Troubleshooting</h3>
132 <p>To install moonmoon, try the following changes:</p>
133 <ul>
134 <?php echo $strRecommendation; ?>
135 </ul>
136 </div>
137
138 <?php elseif ($status == 'install') : ?>
139 <div>
140 <form method="post" action="">
141 <fieldset>
142 <input type="hidden" id="url" name="url" value="" readonly="readonly"/>
143 <script>
144 <!--
145 document.forms[0].elements[1].value = document.URL.replace('install.php','');
146 -->
147 </script>
148
149 <p class="field">
150 <label for="title">Title:</label>
151 <input type="text" id="title" name="title" value="My website"/>
152 </p>
153 <!--
154 <p class="field">
155 <label>Administrator login:</label> <code>admin</code>
156 </p>
157 -->
158 <p class="field">
159 <label for="password">Administrator password:</label>
160 <input type="text" id="password" name="password" class="text password" value="admin" />
161 </p>
162 <p class="field">
163 <label for="locale">Language:</label>
164 <select name="locale" id="locale">
165 <option selected="selected" value="en">English</option>
166 <option value="fr">Français</option>
167 </select>
168 </p>
169 <p>
170 <input type="submit" class="submit" value="Install"/>
171 </p>
172 </fieldset>
173 </form>
174 </div>
175
176 <?php elseif ($status =='installed'): ?>
177
178 <p><?=_g('Congratulations! Your moonmoon is ready.')?></p>
179 <h3><?=_g("What's next?")?></h3>
180 <ol>
181 <li>
182 <?=_g('<strong>Delete</strong> <code>install.php</code> with your FTP software.')?>
183 </li>
184 <li>
185 <?=_g('Use your password to go to the <a href="./admin/">administration panel</a>')?>
186 </li>
187 </ol>
188 <?php endif; ?>
189 </body>
190 </html>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30