1
|
<?php
|
2
|
/*
|
3
|
*
|
4
|
* About WebsiteBaker
|
5
|
*
|
6
|
* Website Baker is a PHP-based Content Management System (CMS)
|
7
|
* designed with one goal in mind: to enable its users to produce websites
|
8
|
* with ease.
|
9
|
*
|
10
|
* LICENSE INFORMATION
|
11
|
*
|
12
|
* WebsiteBaker is free software; you can redistribute it and/or
|
13
|
* modify it under the terms of the GNU General Public License
|
14
|
* as published by the Free Software Foundation; either version 2
|
15
|
* of the License, or (at your option) any later version.
|
16
|
*
|
17
|
* WebsiteBaker is distributed in the hope that it will be useful,
|
18
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
20
|
* See the GNU General Public License for more details.
|
21
|
*
|
22
|
* You should have received a copy of the GNU General Public License
|
23
|
* along with this program; if not, write to the Free Software
|
24
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25
|
*
|
26
|
* WebsiteBaker Extra Information
|
27
|
*
|
28
|
*
|
29
|
*/
|
30
|
/**
|
31
|
*
|
32
|
* @category modules
|
33
|
* @package news
|
34
|
* @author Ryan Djurovich
|
35
|
* @copyright 2004-2009, Ryan Djurovich
|
36
|
* @copyright 2009-2010, Website Baker Org. e.V.
|
37
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/upgrade.php $
|
38
|
* @author Ryan Djurovich
|
39
|
* @copyright 2004-2009, Ryan Djurovich
|
40
|
*
|
41
|
* @author WebsiteBaker Project
|
42
|
* @link http://www.websitebaker2.org/
|
43
|
* @copyright 2009-2010, Website Baker Org. e.V.
|
44
|
* @link http://start.websitebaker2.org/impressum-datenschutz.php
|
45
|
* @license http://www.gnu.org/licenses/gpl.html
|
46
|
* @version $Id: upgrade.php 1258 2010-01-21 02:26:08Z Luisehahne $
|
47
|
* @platform WebsiteBaker 2.8.x
|
48
|
* @requirements PHP 4.3.4 and higher
|
49
|
* @lastmodified $Date: 2010-01-21 03:26:08 +0100 (Thu, 21 Jan 2010) $
|
50
|
*
|
51
|
*/
|
52
|
|
53
|
if(defined('WB_URL')) {
|
54
|
|
55
|
function create_new_post($filename, $filetime=NULL, $content )
|
56
|
{
|
57
|
global $page_id, $section_id, $post_id;
|
58
|
// The depth of the page directory in the directory hierarchy
|
59
|
// '/pages' is at depth 1
|
60
|
$pages_dir_depth = count(explode('/',PAGES_DIRECTORY))-1;
|
61
|
// Work-out how many ../'s we need to get to the index page
|
62
|
$index_location = '../';
|
63
|
for($i = 0; $i < $pages_dir_depth; $i++)
|
64
|
{
|
65
|
$index_location .= '../';
|
66
|
}
|
67
|
|
68
|
// Write to the filename
|
69
|
$content .='
|
70
|
define("POST_SECTION", $section_id);
|
71
|
define("POST_ID", $post_id);
|
72
|
require("'.$index_location.'config.php");
|
73
|
require(WB_PATH."/index.php");
|
74
|
?>';
|
75
|
if($handle = fopen($filename, 'w+'))
|
76
|
{
|
77
|
fwrite($handle, $content);
|
78
|
fclose($handle);
|
79
|
if($filetime)
|
80
|
{
|
81
|
touch($filename, $filetime);
|
82
|
}
|
83
|
change_mode($filename);
|
84
|
}
|
85
|
}
|
86
|
|
87
|
// read files from /pages/posts/
|
88
|
if( !function_exists('scandir') )
|
89
|
{
|
90
|
function scandir($directory, $sorting_order = 0)
|
91
|
{
|
92
|
$dh = opendir($directory);
|
93
|
while( false !== ($filename = readdir($dh)) )
|
94
|
{
|
95
|
$files[] = $filename;
|
96
|
}
|
97
|
if( $sorting_order == 0 )
|
98
|
{
|
99
|
sort($files);
|
100
|
} else
|
101
|
{
|
102
|
rsort($files);
|
103
|
}
|
104
|
return($files);
|
105
|
}
|
106
|
}
|
107
|
|
108
|
$target_dir = WB_PATH . PAGES_DIRECTORY.'/posts/';
|
109
|
$files = scandir($target_dir);
|
110
|
natcasesort($files);
|
111
|
|
112
|
// All files in /pages/posts/
|
113
|
foreach( $files as $file )
|
114
|
{
|
115
|
if( file_exists($target_dir.$file)
|
116
|
AND ($file != '.')
|
117
|
AND ($file != '..')
|
118
|
AND ($file != 'index.php') )
|
119
|
{
|
120
|
clearstatcache();
|
121
|
$timestamp = filemtime ( $target_dir.$file );
|
122
|
$lines = file($target_dir.$file);
|
123
|
$content = '';
|
124
|
// read lines until first define
|
125
|
foreach ($lines as $line_num => $line) {
|
126
|
if(strstr($line,'define'))
|
127
|
{
|
128
|
break;
|
129
|
}
|
130
|
$content .= $line;
|
131
|
}
|
132
|
|
133
|
create_new_post($target_dir.$file, $timestamp, $content);
|
134
|
}
|
135
|
|
136
|
}
|
137
|
// Print admin footer
|
138
|
$admin->print_footer();
|
139
|
}
|
140
|
?>
|