Issues (663)

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.

class/review.php (7 issues)

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
3
/**
4
 *
5
 * @access    public
6
 * @return void
7
 * @copyright 1997-2010 The Lap Group
8
 * @author    Martin <[email protected]>
9
 * @created   time :2010-07-22 16:27:07
10
 * */
11
class MartinReview extends XoopsObject
12
{
13
}
14
15
/**
16
 *
17
 * @access    public
18
 * @return void
19
 * @copyright 1997-2010 The Lap Group
20
 * @author    Martin <[email protected]>
21
 * @created   time :2010-07-22 16:27:25
22
 * */
23
class MartinReviewHandler extends XoopsObjectHandler
24
{
25
    /**
26
     * @create    cart object
27
     * @license   http://www.blags.org/
28
     * @created   :2010年07月04日 12时59分
29
     * @copyright 1997-2010 The Martin Group
30
     * @author    Martin <[email protected]>
31
     * */
32
    public function &create()
33
    {
34
        $obj =& new MartinReview;
35
36
        return $obj;
37
    }
38
39
    /**
40
     * insert review for hotel
41
     * @access    public
42
     * @param $Data
43
     * @copyright 1997-2010 The Lap Group
44
     * @author    Martin <[email protected]>
45
     * @created   time :2010-07-22 16:28:18
46
     */
47
    public function SaveReview($Data)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
48
    {
49
        global $xoopsDB;
50
        if (!$Data) {
51
            return $Data;
52
        }
53
        $table = $xoopsDB->prefix('martin_user_review');
54
        $exist = $this->CheckReviewExist($Data['hotel_id'], $Data['uid']);
55
        if (is_array($Data)) {
56
            foreach ($Data as $key => $value) {
57
                $v .= $prefix . $value;
0 ignored issues
show
The variable $v does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
The variable $prefix does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
58
                $k .= $prefix . $key;
0 ignored issues
show
The variable $k does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
59
                $updateStr .= $prefix . "$key = $value";
0 ignored issues
show
The variable $updateStr does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
60
                $prefix = ',';
61
            }
62
        }
63
        $sql = $exist ? "UPDATE $table SET %s WHERE hotel_id = {$Data['hotel_id']} AND uid = {$Data['uid']}" : "INSERT INTO $table (%s) VALUES (%s)";
64
        $sql = $exist ? sprintf($sql, $updateStr) : sprintf($sql, $k, $v);
65
66
        //echo $sql;
67
        return $xoopsDB->query($sql);
68
    }
69
70
    /**
71
     *
72
     * @access    public
73
     * @param $hotel_id
74
     * @param $uid
75
     * @return bool
76
     * @copyright 1997-2010 The Lap Group
77
     * @author    Martin <[email protected]>
78
     * @created   time :2010-07-22 16:43:23
79
     */
80 View Code Duplication
    public function CheckReviewExist($hotel_id, $uid)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
    {
82
        global $xoopsDB;
83
        $sql = "SELECT * FROM {$xoopsDB->prefix('martin_user_review')} WHERE hotel_id = $hotel_id AND uid = $uid ";
84
85
        return is_array($xoopsDB->fetchArray($xoopsDB->query($sql)));
86
    }
87
88
    /**
89
     *
90
     * @access    public
91
     * @param $hotel_id
92
     * @copyright 1997-2010 The Lap Group
93
     * @author    Martin <[email protected]>
94
     * @created   time :2010-07-22 16:49:41
95
     */
96
    public function GetReview($hotel_id)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
97
    {
98
        global $xoopsDB, $xoopsUser;
99
        $uid = $xoopsUser->uid();
100
        $sql = "SELECT * FROM {$xoopsDB->prefix('martin_user_review')} WHERE hotel_id = $hotel_id AND uid = $uid ";
101
102
        return $xoopsDB->fetchArray($xoopsDB->query($sql));
103
    }
104
105
    /**
106
     * get hotel review
107
     * @access    public
108
     * @param $hotel_id
109
     * @copyright 1997-2010 The Lap Group
110
     * @author    Martin <[email protected]>
111
     * @created   time :2010-07-22 17:03:32
112
     */
113
    public function GetHotelReview($hotel_id)
114
    {
115
        global $xoopsDB;
116
        $table                  = $xoopsDB->prefix('martin_user_review');
117
        $sql                    = "SELECT avg(review_type_avg) as review_type_avg , count(uid) as count FROM $table WHERE hotel_id = $hotel_id GROUP BY hotel_id ";
118
        $row                    = ($xoopsDB->fetchArray($xoopsDB->query($sql)));
119
        $row['review_type_avg'] = round($row['review_type_avg'], 2);
120
        $row['score']           = (int)(($row['review_type_avg'] / 5) * 100);
121
122
        //var_dump($row);
123
        return $row;
124
    }
125
}
126