source: branches/gettext/install/php5_apache_configuration.php @ 23090

Last change on this file since 23090 was 5123, checked in by plg, 15 years ago

feature 1502: based on Dotclear model, P@t has reorganized the way Piwigo
manages template/theme in a simpler "theme only level" architecture. It
supports multiple level inheritance.

File size: 5.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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">
82.content {
83  width: 800px;
84  min-height: 0px !important;
85  margin: auto;
86  padding: 25px;
87  text-align: left;
88}
89
90table { margin: 0 0 15px 0; }
91td {  padding: 3px 10px; }
92h1 { text-align: left; }
93</style>
94<title>'.$title.'</title>
95</head>
96
97<body>
98<div id="headbranch"></div>
99<div id="the_page">
100<div id="theHeader"></div>
101<div id="content" class="content">
102
103<h2>'.$title.'</h2>';
104}
105
106function closePage()
107{
108  echo '
109</div>
110<div style="text-align: center">'.sprintf(l10n('Need help ? Ask your question on <a href="%s">Piwigo message board</a>.'), PHPWG_URL.'/forum').'</div>
111</div>
112</body>
113</html>';
114}
115
116if (isset($_GET['setphp5']))
117{
118  // Try to configure php5
119  if (initPHP5())
120  {
121    header('Location: '.$script.'.php?language='.$language);
122  }
123  else
124  {
125    openPage();
126    echo '
127<h1>'.l10n('Sorry!').'</h1>
128<p>
129'.l10n('Piwigo was not able to configure PHP 5.').'<br>
130'.l10n("You may referer to your hosting provider's support and see how you could switch to PHP 5 by yourself.").'<br>
131'.l10n('Hope to see you back soon.').'
132</p>';
133    closePage();
134  }
135}
136else
137{
138  openPage();
139  echo '
140  <table>
141  <tr>
142    <td>'.l10n('Language').'</td>
143    <td>
144      <select name="language" onchange="document.location = \''.$script.'.php?language=\'+this.options[this.selectedIndex].value;">';
145  foreach (get_languages('utf-8') as $code => $name)
146  {
147    echo '
148      <option label="'.$name.'" value="'.$code.'" '.($code == $language ? 'selected="selected"' : '') .'>'.$name.'</option>';
149  }
150  echo '
151      </select>
152    </td>
153  </tr>
154</table>
155
156<h1>'.l10n('PHP 5 is required').'</h1>
157<p>
158'.sprintf(l10n('It appears your webhost is currently running PHP %s.'), PHP_VERSION).'<br>
159'.l10n('Piwigo may try to switch your configuration to PHP 5 by creating or modifying a .htaccess file.').'<br>
160'.l10n('Note you can change your configuration by yourself and restart Piwigo after that.').'<br>
161</p>
162<p style="text-align: center;"><br>
163<input type="button" value="'.l10n('Try to configure PHP 5').'" onClick="document.location = \''.$script.'.php?language='.$language.'&amp;setphp5=\';">
164</p>';
165  closePage();
166}
167
168exit();
169?>
Note: See TracBrowser for help on using the repository browser.