My favorites
▼
|
Sign in
wcms
wfiedler Content Management System
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
Version 1
/
install.php
‹r17
r26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
if(isset($_REQUEST['info']))
{
echo "Info:<br>";
phpinfo();
exit;
}
if($_POST['install']||$_POST['editor'])
{
install($_POST['install']);
echo "w-CMS is sucessfully installed/updated if no errors reported.</h3><br /><br />Click <a href='./'>here</a> to access the site";
exit;
}
/*if($_POST['uninstall'])
{
uninstall();
echo "w-CMS is sucessfully removed from your installation if no errors reported.";
exit;
}*/
$this_version = trim(@file_get_contents("version"));
$wcms_version = trim(@file_get_contents("http://174.121.21.2/~wfiedler/release/version"));
if($wcms_version == $this_version)
{
echo "<h2 style='color:red'>It appears that your installation of w-CMS is already up-to-date</h2>".
"<h3>Version: $this_version</h3>Click <a href='./'>here</a> to access the site<br /><hr size='1' />";
}
echo "<br /><br /><h3>w-CMS Installation</h3>
<pre>
<span style='font-size: large'>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
<a href='http://www.gnu.org/licenses/gpl-3.0.txt'>GNU General Public License</a> for more details.</span>
</pre>
<h3><span style='color: red'>DO NOT INSTALL/UPDATE</span> w-CMS <span style='color: red'>IF YOU DO NOT AGREE WITH THE ABOVE!</span></h3>
<form method='post' action='install.php'>
<input type='hidden' name='install' value='$wcms_version' />
<p><br /><input type='submit' value='Install/Update w-CMS' /> - Version $wcms_version</p></form";
if($this_version>1.00) echo "
<form method='post' action='install.php'>
<p><br />Editor: <select name='editor'>
<option value=''>SELECT</option>
<option value='ckeditor'>CKEditor</option>
<option value='tinymce'>tinyMCE</option>
</select><br /><input type='submit' value='Download' />
</form></p>";
/*if($this_version) echo "
<p><br /><input type='submit' name='uninstall' value='Uninstall w-CMS' /></p>
<font color='red'>WARNING: Uninstalling w-CMS will remove all the files and subdirectory in the current directory</font></p>";
*/
function install($version)
{
if(!is_writable("./"))
{
echo "This directory is not writable by w-CMS: <br /><br />";
echo "Please set it to 0777 or set owner to w-CMS installer and then click <a href='install.php'>here</a> to try again.";
exit;
}
if($_POST['editor'])
{
echo "Downloading... ".$_POST['editor'];
$zipfile = file_get_contents("http://wcms.googlecode.com/files/".$_POST['editor'].".zip");
echo "<br />http://wcms.googlecode.com/files/".$_POST['editor'].".zip";
}
else
{
echo "Downloading... w-CMS-$version.zip";
$zipfile = @file_get_contents("http://wcms.googlecode.com/files/wcms-$version.zip");
if(preg_match("/not found/",$zipfile))
{
echo "<h3>File not found!</h3>Click <a href='install.php'>here</a> to try again.";
exit;
}
}
$fp = fopen("temp.zip", 'w+');
if(!$fp)
{
echo "<font color='red'>Can't create files in ".getcwd();
exit;
}
fwrite($fp, $zipfile);
fclose($fp);
$num = extractZip("temp.zip","");
echo "<h3>$num files updated.</h3>";
@unlink("temp.zip");
return $num;
}
function extractZip( $zipFile = '', $dirFromZip = '' )
{
define(DIRECTORY_SEPARATOR, '/');
$zipDir = getcwd() . DIRECTORY_SEPARATOR;
$installed = 0;
if (is_dir("main"))
{
$installed++;
}
$zip = zip_open($zipDir.$zipFile);
$num = 0;
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
$completePath = $zipDir . dirname(zip_entry_name($zip_entry));
$fname = zip_entry_name($zip_entry);
$completeName = "$zipDir$fname";
if(preg_match("/^main/",$fname))
{
if ($installed) continue;
}
// Walk through path to create non existing directories
// This won't apply to empty directories ! They are created further below
if(!file_exists($completePath) && preg_match( '#^' . $dirFromZip .'.*#', dirname(zip_entry_name($zip_entry)) ) )
{
$tmp = '';
foreach(explode('/',$completePath) AS $k)
{
$tmp .= $k.'/';
if(!file_exists($tmp) )
{
@mkdir($tmp, 0777);
}
}
}
if (zip_entry_open($zip, $zip_entry, "r"))
{
if( preg_match( '#^' . $dirFromZip .'.*#', dirname(zip_entry_name($zip_entry)) ) )
{
if ($fd = @fopen($completeName, 'w+'))
{
fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
fclose($fd);
}
else
{
// We think this was an empty directory
mkdir($completeName, 0777);
}
zip_entry_close($zip_entry);
}
}
$num++;
}
zip_close($zip);
}
return $num;
}
function uninstall( )
{
removeFolder("./");
echo "Please check your w-CMS folder to make sure all the files and directories have been removed.";
exit;
}
/*--------------\
| remove folder |
\--------------*/
function removeFolder($folder)
{
$deleted = 0;
if (!is_dir($folder))
{
echo "<h3 style='color:red'>$folder not found!</h3>";
}
else
{
unlinkRecursive($folder);
$deleted++;
}
if($deleted) echo "<h3 style='color:red'>w-CMS Removed!</h3>";
}
/*------------------\
| unlink Recursive |
\------------------*/
function unlinkRecursive($dir)
{
if(!$dh = @opendir($dir))
{
return;
}
while (false !== ($obj = readdir($dh)))
{
if($obj == '.' || $obj == '..' || $obj=="install.php")
{
continue;
}
if (!@unlink($dir . '/' . $obj))
{
unlinkRecursive($dir.'/'.$obj);
}
}
closedir($dh);
@rmdir($dir);
return;
}
?>
Show details
Hide details
Change log
r26
by tomatztmlorg on Nov 26, 2011
Diff
Go to:
/Version 1/install.php
Project members,
sign in
to write a code review
Older revisions
r17
by tomatztmlorg on Jan 11, 2011
Diff
Updated with the latest changes
r3
by tomatztmlorg on Dec 2, 2010
Diff
wCMS installation
All revisions of this file
File info
Size: 6337 bytes, 222 lines
View raw file
Powered by
Google Project Hosting