1 |
1425
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category modules
|
5 |
|
|
* @package news
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
1918
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker.org/
|
9 |
1425
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.x
|
11 |
|
|
* @requirements PHP 5.2.2 and higher
|
12 |
|
|
* @version $Id$
|
13 |
1918
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1425
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
1950
|
darkviper
|
error_reporting(E_ALL);
|
18 |
1457
|
Luisehahne
|
require('../../config.php');
|
19 |
|
|
require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
|
20 |
|
|
// Get post_id
|
21 |
|
|
if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) {
|
22 |
|
|
header("Location: ".ADMIN_URL."/pages/index.php");
|
23 |
|
|
exit( 0 );
|
24 |
|
|
}else {
|
25 |
|
|
$post_id = intval($_POST['post_id']);
|
26 |
|
|
}
|
27 |
1425
|
Luisehahne
|
|
28 |
1457
|
Luisehahne
|
$admin_header = false;
|
29 |
|
|
// Tells script to update when this page was last updated
|
30 |
|
|
$update_when_modified = true;
|
31 |
|
|
// Include WB admin wrapper script
|
32 |
|
|
require(WB_PATH.'/modules/admin.php');
|
33 |
1425
|
Luisehahne
|
|
34 |
1457
|
Luisehahne
|
if (!$admin->checkFTAN()) {
|
35 |
|
|
$admin->print_header();
|
36 |
|
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],
|
37 |
|
|
ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
|
38 |
1425
|
Luisehahne
|
}
|
39 |
1457
|
Luisehahne
|
$admin->print_header();
|
40 |
1425
|
Luisehahne
|
|
41 |
|
|
// Validate all fields
|
42 |
1918
|
Luisehahne
|
$title = $admin->StripCodeFromText($admin->get_post('title'));
|
43 |
|
|
$commenting = $admin->StripCodeFromText($admin->get_post('commenting'));
|
44 |
|
|
$active = intval($admin->get_post('active'));
|
45 |
|
|
$old_link = $admin->StripCodeFromText($admin->get_post('link'));
|
46 |
|
|
$group_id = intval($admin->get_post('group'));
|
47 |
|
|
|
48 |
1457
|
Luisehahne
|
if($admin->get_post('title') == '' AND $admin->get_post('url') == '') {
|
49 |
1918
|
Luisehahne
|
$recallUrl = WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.
|
50 |
1457
|
Luisehahne
|
'§ion_id='.$section_id.'&post_id='.$admin->getIDKEY($post_id);
|
51 |
1868
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_FILL_IN_ALL'], $recallUrl);
|
52 |
1918
|
Luisehahne
|
} else {
|
53 |
|
|
$short = $admin->get_post('short');
|
54 |
|
|
$long = $admin->get_post('long');
|
55 |
|
|
$short = $admin->ReplaceAbsoluteMediaUrl($short);
|
56 |
|
|
$long = $admin->ReplaceAbsoluteMediaUrl($long);
|
57 |
1457
|
Luisehahne
|
}
|
58 |
1918
|
Luisehahne
|
|
59 |
1425
|
Luisehahne
|
// Include WB functions file
|
60 |
1457
|
Luisehahne
|
require(WB_PATH.'/framework/functions.php');
|
61 |
1425
|
Luisehahne
|
// Work-out what the link should be
|
62 |
1950
|
darkviper
|
$sNewFile = page_filename($title).PAGE_SPACER.$post_id;
|
63 |
|
|
$newLink = '/posts/'.$sNewFile;
|
64 |
|
|
$sPagesPath = WB_PATH.PAGES_DIRECTORY;
|
65 |
|
|
$sBackUrl = ADMIN_URL.'/pages/modify.php?page_id='.$page_id;
|
66 |
|
|
$sNewFilename = $sPagesPath.$newLink.PAGE_EXTENSION;
|
67 |
|
|
$sOldFilename = $sPagesPath.$old_link.PAGE_EXTENSION;
|
68 |
|
|
|
69 |
1425
|
Luisehahne
|
// get publisedwhen and publisheduntil
|
70 |
1457
|
Luisehahne
|
$publishedwhen = jscalendar_to_timestamp($admin->get_post_escaped('publishdate'));
|
71 |
|
|
if($publishedwhen == '' || $publishedwhen < 1) { $publishedwhen=0; }
|
72 |
|
|
$publisheduntil = jscalendar_to_timestamp($admin->get_post_escaped('enddate'), $publishedwhen);
|
73 |
|
|
if($publisheduntil == '' || $publisheduntil < 1) { $publisheduntil=0; }
|
74 |
1425
|
Luisehahne
|
// Update row
|
75 |
1457
|
Luisehahne
|
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
|
76 |
|
|
$sql .= 'SET `group_id`='.(int)$group_id.', ';
|
77 |
|
|
$sql .= '`title`=\''.$title.'\', ';
|
78 |
|
|
$sql .= '`link`=\''.$newLink.'\', ';
|
79 |
|
|
$sql .= '`content_short`=\''.$short.'\', ';
|
80 |
|
|
$sql .= '`content_long`=\''.$long.'\', ';
|
81 |
|
|
$sql .= '`commenting`=\''.$commenting.'\', ';
|
82 |
|
|
$sql .= '`active`='.(int)$active.', ';
|
83 |
|
|
$sql .= '`published_when`='.(int)$publishedwhen.', ';
|
84 |
|
|
$sql .= '`published_until`='.(int)$publisheduntil.', ';
|
85 |
|
|
$sql .= '`posted_when`='.time().', ';
|
86 |
|
|
$sql .= '`posted_by`='.(int)$admin->get_user_id().' ';
|
87 |
|
|
$sql .= 'WHERE `post_id`='.(int)$post_id;
|
88 |
1950
|
darkviper
|
if( $database->query($sql) ) {
|
89 |
1868
|
Luisehahne
|
// create new accessfile
|
90 |
1950
|
darkviper
|
$sDoWhat = (($newLink == $old_link) && (file_exists($sNewFilename))) ? "nothing" : "action";
|
91 |
|
|
if($sDoWhat == "action") {
|
92 |
|
|
$sDoWhat = (($sDoWhat == "action") && file_exists($sOldFilename)) ? "update" : "create";
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
switch($sDoWhat)
|
96 |
|
|
{
|
97 |
|
|
case "update":
|
98 |
|
|
try {
|
99 |
|
|
$oAF = new AccessFile($sOldFilename, $page_id);
|
100 |
|
|
$oAF->rename($sNewFile);
|
101 |
|
|
unset($oAF);
|
102 |
|
|
}catch(AccessFileException $e) {
|
103 |
|
|
$admin->print_error($e,$sBackUrl);
|
104 |
|
|
}
|
105 |
|
|
break;
|
106 |
|
|
case "create":
|
107 |
|
|
try {
|
108 |
|
|
$oAF = new AccessFile($sNewFilename, $page_id);
|
109 |
|
|
$oAF->addVar('section_id', $section_id, AccessFile::VAR_INT);
|
110 |
|
|
$oAF->addVar('post_id', $post_id, AccessFile::VAR_INT);
|
111 |
|
|
$oAF->addVar('post_section', $section_id, AccessFile::VAR_INT);
|
112 |
|
|
$oAF->write();
|
113 |
|
|
unset($oAF);
|
114 |
|
|
}catch(AccessFileException $e) {
|
115 |
|
|
$admin->print_error($e,$sBackUrl);
|
116 |
|
|
}
|
117 |
|
|
break;
|
118 |
|
|
}
|
119 |
1868
|
Luisehahne
|
}
|
120 |
1425
|
Luisehahne
|
// Check if there is a db error, otherwise say successful
|
121 |
1457
|
Luisehahne
|
if($database->is_error()) {
|
122 |
|
|
$recallUrl = WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.
|
123 |
|
|
'§ion_id='.$section_id.'&post_id='.$admin->getIDKEY($post_id);
|
124 |
|
|
$admin->print_error($database->get_error(), $recallUrl);
|
125 |
|
|
}else {
|
126 |
|
|
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
127 |
|
|
}
|
128 |
1425
|
Luisehahne
|
// Print admin footer
|
129 |
1950
|
darkviper
|
$admin->print_footer();
|