Project

General

Profile

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          WebsiteBaker Project
35
 * @copyright       2004-2009, Ryan Djurovich
36
 * @copyright       2009-2010, Website Baker Org. e.V.
37
 * @link			http://www.websitebaker2.org/
38
 * @license         http://www.gnu.org/licenses/gpl.html
39
 * @platform        WebsiteBaker 2.8.x
40
 * @requirements    PHP 4.3.4 and higher
41
 * @version         $Id: upgrade.php 1268 2010-01-22 17:21:02Z Luisehahne $
42
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/upgrade.php $
43
 * @lastmodified    $Date: 2010-01-22 18:21:02 +0100 (Fri, 22 Jan 2010) $
44
 *
45
 */
46

    
47
if(defined('WB_URL')) {
48

    
49
    function create_new_post($filename, $filetime=NULL, $content )
50
    {
51
    global $page_id, $section_id, $post_id;
52
	// The depth of the page directory in the directory hierarchy
53
	// '/pages' is at depth 1
54
	$pages_dir_depth = count(explode('/',PAGES_DIRECTORY))-1;
55
	// Work-out how many ../'s we need to get to the index page
56
	$index_location = '../';
57
	for($i = 0; $i < $pages_dir_depth; $i++)
58
    {
59
		$index_location .= '../';
60
	}
61

    
62
	// Write to the filename
63
	$content .='
64
define("POST_SECTION", $section_id);
65
define("POST_ID", $post_id);
66
require("'.$index_location.'config.php");
67
require(WB_PATH."/index.php");
68
?>';
69
    	if($handle = fopen($filename, 'w+'))
70
        {
71
        	fwrite($handle, $content);
72
        	fclose($handle);
73
            if($filetime)
74
            {
75
                touch($filename, $filetime);
76
            }
77
        	change_mode($filename);
78
        }
79
    }
80

    
81
    // read files from /pages/posts/
82
    if( !function_exists('scandir') )
83
    {
84
        function scandir($directory, $sorting_order = 0)
85
        {
86
            $dh  = opendir($directory);
87
            while( false !== ($filename = readdir($dh)) )
88
            {
89
                $files[] = $filename;
90
            }
91
            if( $sorting_order == 0 )
92
            {
93
                sort($files);
94
            } else
95
            {
96
                rsort($files);
97
            }
98
            return($files);
99
        }
100
    }
101

    
102
    $target_dir = WB_PATH . PAGES_DIRECTORY.'/posts/';
103
	$files = scandir($target_dir);
104
	natcasesort($files);
105

    
106
		// All files in /pages/posts/
107
		foreach( $files as $file )
108
        {
109
            if( file_exists($target_dir.$file)
110
                AND ($file != '.')
111
                    AND ($file != '..')
112
                        AND ($file != 'index.php') )
113
            {
114
                clearstatcache();
115
                $timestamp = filemtime ( $target_dir.$file );
116
                $lines = file($target_dir.$file);
117
                $content = '';
118
                // read lines until first define
119
                foreach ($lines as $line_num => $line) {
120
                    if(strstr($line,'define'))
121
                    {
122
                      break;
123
                    }
124
                    $content .= $line;
125
                }
126

    
127
                create_new_post($target_dir.$file, $timestamp, $content);
128
            }
129

    
130
        }
131
// Print admin footer
132
$admin->print_footer();
133
}
134
?>
(30-30/31)