Issues (431)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

include/classes/news.class.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3
4
class News extends Base {
5
  protected $table = 'news';
6
7
  /**
8
   * We allow changing the database for shared accounts across pools
9
   * Load the config on construct so we can assign the DB name
10
   * @param config array MPOS configuration
11
   * @return none
12
   **/
13
  public function __construct($config) {
14
    $this->setConfig($config);
15
    $this->table = $this->config['db']['shared']['news'] . '.' . $this->table;
16
  }
17
18
  /**
19
   * Get activation status of post
20
   * @param id int News ID
21
   * @return bool true or false
22
   **/
23
  public function getActive($id) {
24
    $this->debug->append("STA " . __METHOD__, 5);
25
    return $this->getSingle($id, 'active', 'id');
26
  }
27
28
  /**
29
   * Switch activation status
30
   * @param id int News ID
31
   * @return bool true or false
32
   **/
33
  public function toggleActive($id) {
34
    $this->debug->append("STA " . __METHOD__, 5);
35
    $field = array('name' => 'active', 'type' => 'i', 'value' => !$this->getActive($id));
36
    return $this->updateSingle($id, $field);
0 ignored issues
show
$field is of type array<string,string|bool...ng","value":"boolean"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37
  }
38
39
  /**
40
   * Get all active news
41
   **/
42 View Code Duplication
  public function getAllActive() {
43
    $this->debug->append("STA " . __METHOD__, 4);
44
    $stmt = $this->mysqli->prepare("SELECT n.*, a.username AS author FROM $this->table AS n LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = n.account_id WHERE active = 1 ORDER BY time DESC");
45
    if ($stmt && $stmt->execute() && $result = $stmt->get_result())
46
      return $result->fetch_all(MYSQLI_ASSOC);
47
    return $this->sqlError('E0040');
48
  }
49
50
  /**
51
   * Get all news
52
   **/
53 View Code Duplication
  public function getAll() {
54
    $this->debug->append("STA " . __METHOD__, 4);
55
    $stmt = $this->mysqli->prepare("SELECT n.*, a.username AS author FROM $this->table AS n LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = n.account_id ORDER BY time DESC");
56
    if ($stmt && $stmt->execute() && $result = $stmt->get_result())
57
      return $result->fetch_all(MYSQLI_ASSOC);
58
    return $this->sqlError('E0039');
59
  }
60
61
  /**
62
   * Get a specific news entry
63
   **/
64
  public function getEntry($id) {
65
    $this->debug->append("STA " . __METHOD__, 4);
66
    $stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE id = ?");
67
    if ($stmt && $stmt->bind_param('i', $id) && $stmt->execute() && $result = $stmt->get_result())
68
      return $result->fetch_assoc();
69
    return $this->sqlError('E0038');
70
  }
71
72
  /**
73
   * Update a news entry
74
   **/
75
  public function updateNews($id, $header, $content, $active=0) {
76
    $this->debug->append("STA " . __METHOD__, 4);
77
    $stmt = $this->mysqli->prepare("UPDATE $this->table SET content = ?, header = ?, active = ? WHERE id = ?");
78
    if ($stmt && $stmt->bind_param('ssii', $content, $header, $active, $id) && $stmt->execute() && $stmt->affected_rows == 1)
79
      return true;
80
    return $this->sqlError('E0037');
81
  }
82
83 View Code Duplication
  public function deleteNews($id) {
84
    $this->debug->append("STA " . __METHOD__, 4);
85
    if (!is_int($id)) return false;
86
    $stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE id = ?");
87
    if ($this->checkStmt($stmt) && $stmt->bind_param('i', $id) && $stmt->execute() && $stmt->affected_rows == 1)
88
      return true;
89
    return $this->sqlError('E0036');
90
  }
91
92
  /**
93
   * Add a new mews entry to the table
94
   * @param type string Type of the notification
95
   * @return bool
96
   **/
97
  public function addNews($account_id, $aData, $active=false) {
98
    $this->debug->append("STA " . __METHOD__, 4);
99
    if (empty($aData['header'])) return false;
100
    if (empty($aData['content'])) return false;
101
    if (!is_int($account_id)) return false;
102
    if (@$aData['active']) $active = true;
103
    $stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, header, content, active) VALUES (?,?,?,?)");
104
    if ($stmt && $stmt->bind_param('issi', $account_id, $aData['header'], $aData['content'], $active) && $stmt->execute())
105
      return true;
106
    return $this->sqlError('E0035');
107
  }
108
}
109
110
$news = new News($config);
111
$news->setDebug($debug);
112
$news->setMysql($mysqli);
113
$news->setUser($user);
114
$news->setErrorCodes($aErrorCodes);
115