source: trunk/install/php5_apache_configuration.php @ 3464

Last change on this file since 3464 was 3203, checked in by patdenice, 16 years ago

Move template class inclusion to common.inc.php.
Add forum link in upgrade page.
Install and upgrade try to configure PHP5.

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