Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         news
6
 * @author          WebsiteBaker Project
7
 * @copyright       Website Baker Org. e.V.
8
 * @link            http://websitebaker.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.3
11
 * @requirements    PHP 5.3.6 and higher
12
 * @version         $Id: save_comment.php 2 2017-07-02 15:14:29Z Manuela $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/news/save_comment.php $
14
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
15
 *
16
 */
17

    
18
// Include config file
19
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
20
if ( !class_exists('admin')) { require(WB_PATH.'/framework/class.admin.php');  }
21
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
22
$aRequestVars  = (isset(${$requestMethod}) ? ${$requestMethod} : null);
23

    
24
// Get id
25
if(!isset($_POST['comment_id']) || !is_numeric($_POST['comment_id']) || !isset($_POST['post_id']) || !is_numeric($_POST['post_id']))
26
{
27
    header("Location: ".ADMIN_URL."/pages/index.php");
28
    exit( 0 );
29
}
30
else
31
{
32
    $comment_id = (int)$_POST['comment_id'];
33
}
34

    
35
$admin_header = false;
36
// Tells script to update when this page was last updated
37
$update_when_modified = true;
38
// show the info banner
39
// $print_info_banner = true;
40
// Include WB admin wrapper script
41
require(WB_PATH.'/modules/admin.php');
42

    
43
if (!$admin->checkFTAN())
44
{
45
    $admin->print_header();
46
    $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
47
}
48

    
49
$id = intval($admin->getIDKEY($comment_id));
50

    
51
// Validate all fields
52
if($admin->get_post('title') == '' AND $admin->get_post('comment') == '')
53
{
54
    $admin->print_header();
55
    $admin->print_error($MESSAGE['GENERIC_FILL_IN_ALL'], WB_URL.'/modules/news/modify_comment.php?page_id='.$page_id.'&section_id='.$section_id.'comment_id='.$id);
56
}
57
else
58
{
59
    $title = strip_tags($admin->get_post('title'));
60
    $comment = strip_tags($admin->get_post('comment'));
61
    $post_id = $admin->getIDKEY($admin->get_post('post_id'));
62

    
63
    // do not allow droplets in user input!
64
    $title = $admin->StripCodeFromText( $title);
65
    $comment = $admin->StripCodeFromText( $comment);
66
}
67

    
68
// Update row
69
$sql  = 'UPDATE '.TABLE_PREFIX.'mod_news_comments SET '
70
      . '`title`=\''.$database->escapeString($title).'\', '
71
      . '`comment`=\''.$database->escapeString($comment).'\' '
72
      . ' WHERE `comment_id`=\''.$database->escapeString($comment_id).'\'';
73
$database->query($sql);
74

    
75
$admin->print_header();
76
// Check if there is a db error, otherwise say successful
77
if($database->is_error())
78
{
79
    $admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_comment.php?page_id='.$page_id.'&section_id='.$section_id.'&comment_id='.$id);
80
}
81
else
82
{
83
    $admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
84
}
85

    
86
// Print admin footer
87
$admin->print_footer();
(28-28/36)