Issues (762)

plugins/facebookfeed/classes/settingspage.php (1 issue)

Severity
1
<?php
2
3
/**
4
 * Copyright (c) 2018 Justin Kuenzel (jukusoft.com)
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
20
/**
21
 * Project: RocketCMS
22
 * License: Apache 2.0 license
23
 * User: Justin
24
 * Date: 30.04.2018
25
 * Time: 02:10
26
 */
27
28
namespace Plugin\FacebookFeed;
29
30
use PageType;
31
use DwooTemplate;
32
use Preferences;
33
use DomainUtils;
34
use Security;
35
use Validator_String;
36
use Translator;
37
38
class SettingsPage extends PageType {
39
40
	public function getContent(): string {
41
		$template = new DwooTemplate("plugin_facebookfeed_settings");
42
43
		$template->assign("form_action", DomainUtils::generateURL($this->getPage()->getAlias()));
44
45
		$prefs = new Preferences("plugin_facebookfeed");
46
47
		if (isset($_REQUEST['submit'])) {
48
			//first check csrf token
49
			if (!Security::checkCSRFToken()) {
50
				$template->assign("error_message", "Wrong CSRF token!");
51
			} else {
52
				//check values
53
				if (!isset($_POST['pageID']) || empty($_POST['pageID'])) {
54
					$template->assign("error_message", "Please complete form! Field pageID is missing!");
55
				} else {
56
					$pageID = $_POST['pageID'];
57
58
					//validate values
59
					$validator_string = new Validator_String();
60
61
					if (!$validator_string->isValide($pageID)) {
62
						$template->assign("error_message", "pageID is invalide!");
63
					} else {
64
						//save values
65
						$prefs->put("pageID", $pageID);
66
						$prefs->save();
67
68
						$template->assign("success_message", Translator::translate("pageID saved successfully!"));
69
					}
70
				}
71
			}
72
		}
73
74
		$template->assign("pageID", $prefs->get("pageID", ""));
75
76
		return $template->getCode();
77
	}
78
79
}
80
81
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
82