source: trunk/install/php5_apache_configuration.php @ 15224

Last change on this file since 15224 was 12922, checked in by mistic100, 12 years ago

update Piwigo headers to 2012, last change before the expected (or not) apocalypse

File size: 5.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die('Hacking attempt!');
27}
28
29$script = script_basename();
30
31if (($script != 'install' and $script != 'upgrade')
32  or version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '>='))
33{
34  die('Nothing to do here...');
35}
36
37function initPHP5()
38{
39  include(PHPWG_ROOT_PATH.'install/hosting.php');
40  $htaccess = PHPWG_ROOT_PATH.'.htaccess';
41 
42  if ((file_exists($htaccess) and (!is_readable($htaccess) or !is_writable($htaccess)))
43    or !($my_hostname = @gethostbyaddr($_SERVER['SERVER_ADDR'])))
44  {
45    return false;
46  }
47
48  foreach ($hosting as $hostname => $rule)
49  {
50    if (preg_match('!'.preg_quote($hostname).'$!',$my_hostname))
51    {
52      if (false !== ($fh = @fopen($htaccess,"ab")))
53      {
54        fwrite($fh,"\n".$rule);
55        fclose($fh);
56        return true;
57      }
58    }
59  }
60  return false;
61}
62
63function openPage()
64{
65  global $script;
66
67  $title = 'Piwigo '.PHPWG_VERSION.' - '.l10n(ucwords($script));
68
69  header('Content-Type: text/html; charset=UTF-8');
70
71  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
72"http://www.w3.org/TR/html4/strict.dtd">
73<html>
74<head>
75<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
76<meta http-equiv="Content-script-type" content="text/javascript">
77<meta http-equiv="Content-Style-Type" content="text/css">
78<link rel="shortcut icon" type="image/x-icon" href="themes/default/icon/favicon.ico">
79<link rel="stylesheet" type="text/css" href="admin/themes/roma/default-colors.css">
80<link rel="stylesheet" type="text/css" href="admin/themes/roma/theme.css">
81<style type="text/css">
82body {
83  background:url("admin/themes/roma/images/bottom-left-bg.jpg") no-repeat fixed left bottom #111111;
84}
85
86.content {
87 background:url("admin/themes/roma/images/fillet.png") repeat-x scroll left top #222222;
88 width: 800px;
89 min-height: 0px !important;
90 margin: auto;
91 text-align: left;
92 padding: 25px;
93}
94
95#headbranch  {
96  background:url("admin/themes/roma/images/top-left-bg.jpg") no-repeat scroll left top transparent;
97}
98
99#theHeader {
100  display: block;
101  background:url("admin/themes/roma/images/piwigo_logo_sombre_214x100.png") no-repeat scroll 245px top transparent;
102}
103
104.content h2 {
105  display:block;
106  font-size:28px;
107  height:104px;
108  width:54%;
109  color:#666666;
110  letter-spacing:-1px;
111  margin:0 30px 3px 20px;
112  overflow:hidden;
113  position:absolute;
114  right:0;
115  text-align:right;
116  top:0;
117  width:770px;
118  text-align:right;
119  text-transform:none;
120}
121
122table { margin: 0 0 15px 0; }
123td {  padding: 3px 10px; }
124h1 { text-align: left; }
125</style>
126<title>'.$title.'</title>
127</head>
128
129<body>
130<div id="headbranch"></div>
131<div id="the_page">
132<div id="theHeader"></div>
133<div id="content" class="content">
134
135<h2>'.$title.'</h2>';
136}
137
138function closePage()
139{
140  echo '
141</div>
142<div style="text-align: center">'.sprintf(l10n('Need help ? Ask your question on <a href="%s">Piwigo message board</a>.'), PHPWG_URL.'/forum').'</div>
143</div>
144</body>
145</html>';
146}
147
148if (isset($_GET['setphp5']))
149{
150  // Try to configure php5
151  if (initPHP5())
152  {
153    header('Location: '.$script.'.php?language='.$language);
154  }
155  else
156  {
157    openPage();
158    echo '
159<h1>'.l10n('Sorry!').'</h1>
160<p>
161'.l10n('Piwigo was not able to configure PHP 5.').'<br>
162'.l10n("You may referer to your hosting provider's support and see how you could switch to PHP 5 by yourself.").'<br>
163'.l10n('Hope to see you back soon.').'
164</p>';
165    closePage();
166  }
167}
168else
169{
170  openPage();
171  echo '
172  <table>
173  <tr>
174    <td>'.l10n('Language').'</td>
175    <td>
176      <select name="language" onchange="document.location = \''.$script.'.php?language=\'+this.options[this.selectedIndex].value;">';
177  foreach ($languages->fs_languages as $code => $fs_language)
178  {
179    echo '
180      <option label="'.$fs_language['name'].'" value="'.$code.'" '.($code == $language ? 'selected="selected"' : '') .'>'.$fs_language['name'].'</option>';
181  }
182  echo '
183      </select>
184    </td>
185  </tr>
186</table>
187
188<h1>'.l10n('PHP 5 is required').'</h1>
189<p>
190'.sprintf(l10n('It appears your webhost is currently running PHP %s.'), PHP_VERSION).'<br>
191'.l10n('Piwigo may try to switch your configuration to PHP 5 by creating or modifying a .htaccess file.').'<br>
192'.l10n('Note you can change your configuration by yourself and restart Piwigo after that.').'<br>
193</p>
194<p style="text-align: center;"><br>
195<input type="button" value="'.l10n('Try to configure PHP 5').'" onClick="document.location = \''.$script.'.php?language='.$language.'&amp;setphp5=\';">
196</p>';
197  closePage();
198}
199
200exit();
201?>
Note: See TracBrowser for help on using the repository browser.