Issues (4714)

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.

src/Intraface/Pdf.php (21 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
 * PdfMaker for Intraface
4
 *
5
 * @author Sune Jensen <[email protected]>
6
 */
7
class Intraface_Pdf extends Intraface_LegacyCpdf
8
{
9
    protected $value;
10
    protected $page;
11
    protected $page_height;
12
    protected $page_width;
13
14 3
    public function __construct()
15
    {
16 3
        $this->page_width = 595;
17 3
        $this->page_height = 841;
18
19
        // Predefined values.
20 3
        $this->value['margin_top'] = 50;
21 3
        $this->value['margin_right'] = 42;
22 3
        $this->value['margin_left'] = 42; // From 0 to the edge in the left side
23 3
        $this->value['margin_bottom'] = 50;
24
25 3
        $this->value['header_height'] = 51;
26 3
        $this->value['header_margin_top'] = 20;
27 3
        $this->value['header_margin_bottom'] = 20;
28
29 3
        $this->value['font_size'] = 11;
30 3
        $this->value['font_padding_top'] = 1;
31 3
        $this->value['font_padding_bottom'] = 4;
32
33 3
        $this->page = 1;
34
35
        // Creates a new A4 document
36 3
        parent::__construct(array(0, 0, $this->page_width, $this->page_height));
37
38
        // Rewrites the placement of Danish characters æ, ø, å, Æ, Ø, Å
39
        // After the Cpdf documentation
40
        // Table for the characters placements can be found here: http://www.fingertipsoft.com/3dkbd/ansitable.html
41
        // Table for their names is found here: http://www.gust.org.pl/fonty/qx-table2.htm
42
        // Notice that the placement of the characters are different in the two tables. Placement is correct in the first.
43
44 3
        $diff = array(230 => 'ae',
45 3
                      198 => 'AE',
46 3
                      248 => 'oslash',
47 3
                      216 => 'Oslash',
48 3
                      229 => 'aring',
49 3
                      197 => 'Aring');
50
51 3
        parent::selectFont('Helvetica.afm', array('differences' => $diff));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (selectFont() instead of __construct()). Are you sure this is correct? If so, you might want to change this to $this->selectFont().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
array('differences' => $diff) is of type array<string,array<integ...\"197\":\"string\"}>"}>, 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...
52
53 3
        $this->calculateDynamicValues();
54 3
    }
55
56
    /**
57
     * Calculates all the dynamic values
58
     * Notice that X and Y are reset.
59
     *
60
     * @return void
61
     */
62 3
    private function calculateDynamicValues()
63
    {
64
        // Sets values based on the predefined values.
65 3
        $this->value['right_margin_position'] = $this->page_width - $this->value['margin_right']; // content_width from 0 to right margen
66 3
        $this->value['top_margin_position'] = $this->page_height - $this->value['margin_top']; // content_height
67
68 3
        $this->value['content_width'] = $this->page_width - $this->value['margin_right'] - $this->value['margin_left']; // content_width fom 0 to right margen
69 3
        $this->value['content_height'] = $this->page_height - $this->value['margin_bottom'] - $this->value['margin_top']; // content_height
70
71 3
        $this->value['font_spacing'] = $this->value['font_size'] + $this->value['font_padding_top'] + $this->value['font_padding_bottom'];
72
73
        // X and Y are need to be reset, if the margins are changed.
74 3
        $this->setX(0);
75 3
        $this->setY(0);
76 3
    }
77
78
    /**
79
     * Sets value
80
     *
81
     * @param integer $key   The key to set
82
     * @param integer $value The value to put in the key
83
     *
84
     * @return void
85
     */
86 1
    public function setValue($key, $value)
87
    {
88 1
        $this->value[$key] = $value;
89
        // Every time we change a fixed value we need to update the dynamic values
90 1
        if (in_array($key, array('margin_right', 'margin_left', 'margin_top', 'margin_bottom', 'font_size', 'font_padding_top', 'font_padding_bottom'))) {
91 1
            $this->calculateDynamicValues();
92 1
        }
93 1
    }
94
95
    /**
96
     * Sets the x
97
     *
98
     * @param integer $value The x for the page
99
     *
100
     * @return void
101
     */
102 3 View Code Duplication
    public function setX($value)
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...
103
    {
104 3
        if (is_int($value)) {
105 3
            $this->value['x'] = $this->get('margin_left') + $value;
106 3
        } elseif (is_string($value) && substr($value, 0, 1) == "+") {
107
            $this->value['x'] +=  intval(substr($value, 1));
108
        } elseif (is_string($value) && substr($value, 0, 1) == "-") {
109
            $this->value['x'] -= intval(substr($value, 1));
110
        } else {
111
            throw new Exception('Ugyldig værdi i setX: '.$value);
112
        }
113 3
    }
114
115
    /**
116
     * Sets the y
117
     *
118
     * @param integer $value The y for the page
119
     *
120
     * @return void
121
     */
122 3 View Code Duplication
    public function setY($value)
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...
123
    {
124 3
        if (is_int($value)) {
125 3
            $this->value['y'] = $this->page_height - $this->get('margin_top') - $value;
126 3
        } elseif (is_string($value) && substr($value, 0, 1) == "+") {
127
            $this->value['y'] += intval(substr($value, 1));
128
        } elseif (is_string($value) && substr($value, 0, 1) == "-") {
129
            $this->value['y'] -= intval(substr($value, 1));
130
        } else {
131
            throw new Exception("Ugyldig værdi i setY: ".$value);
132
        }
133 3
    }
134
135
    /**
136
     * Adds the header to the document
137
     *
138
     * @param string $headerImg The filepath for the header image
139
     *
140
     * @return void
141
     */
142
    public function addHeader($headerImg = '')
143
    {
144
        if (!file_exists($headerImg)) {
145
            return false;
146
        }
147
148
        $header = parent::openObject();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (openObject() instead of addHeader()). Are you sure this is correct? If so, you might want to change this to $this->openObject().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
149
        $size = getImageSize($headerImg); // array(0 => width, 1 => height)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
150
151
        $height = $this->get('header_height');
152
        ;
153
        $width = $size[0] * ($height/$size[1]);
154
155
        if ($width > $this->get('content_width')) {
156
            $width = $this->get('content_width');
157
            $height = $size[1] * ($width/$size[0]);
158
        }
159
        parent::addJpegFromFile($headerImg, $this->get('right_margin_position') - $width, $this->page_height - $this->get('header_margin_top') - $height, $width, $height); // , ($this->value["page_width"] - $this->value["margin_left"])/10
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (addJpegFromFile() instead of addHeader()). Are you sure this is correct? If so, you might want to change this to $this->addJpegFromFile().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
160
        parent::closeObject();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (closeObject() instead of addHeader()). Are you sure this is correct? If so, you might want to change this to $this->closeObject().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
161
        parent::addObject($header, "all");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (addObject() instead of addHeader()). Are you sure this is correct? If so, you might want to change this to $this->addObject().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
162
        $this->setValue('margin_top', $height + $this->get('header_margin_top') + $this->get('header_margin_bottom'));
163
        $this->setY(0);
164
    }
165
166
   /**
167
     * create a round rectangle
168
     *
169
     * @param integer $x      The starting x point
170
     * @param integer $y      The starting y point
171
     * @param integer $width  The width of the rectangle
172
     * @param integer $height The height of the rectangle
173
     * @param integer $round  How much to round the rectangle
174
     *
175
     * @return void
176
     */
177
    public function roundRectangle($x, $y, $width, $height, $round)
178
    {
179
        parent::setLineStyle(1);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setLineStyle() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->setLineStyle().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
180
        parent::line($x, $y+$round, $x, $y+$height-$round);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (line() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->line().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
181
        parent::line($x+$round, $y+$height, $x+$width-$round, $y+$height);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (line() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->line().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
182
        parent::line($x+$width, $y+$height-$round, $x+$width, $y+$round-1);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (line() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->line().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
183
        parent::line($x+$width-$round, $y, $x+$round, $y);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (line() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->line().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
184
185
        parent::partEllipse($x+$round, $y+$round, 180, 270, $round);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (partEllipse() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->partEllipse().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
186
        parent::partEllipse($x+$round, $y+$height-$round, 90, 180, $round);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (partEllipse() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->partEllipse().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
187
        parent::partEllipse($x+$width-$round, $y+$height-$round, 0, 90, $round);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (partEllipse() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->partEllipse().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
188
        parent::partEllipse($x+$width-$round, $y+$round, 270, 360, $round);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (partEllipse() instead of roundRectangle()). Are you sure this is correct? If so, you might want to change this to $this->partEllipse().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
189
    }
190
191
   /**
192
     * write the document to a file
193
     *
194
     * @param string $data The data to write
195
     *
196
     * @return void
197
     */
198
    public function writeDocument($data, $filnavn)
199
    {
200
        $file = fopen($filnavn, 'wb');
201
        fwrite($file, $data);
202
        fclose($file);
203
    }
204
205
    function addText($x, $y, $size, $text, $angle = 0, $wordSpaceAdjust = 0)
206
    {
207
        $text = utf8_decode($text);
208
        parent::addText($x, $y, $size, $text, $angle = 0, $wordSpaceAdjust = 0);
209
    }
210
211
    /**
212
     * Changes to next page
213
     *
214
     * @param boolean $sub_text What is the sub text
215
     *
216
     * @return integer the new y
217
     */
218
    public function nextPage($sub_text = false)
219
    {
220
        if ($sub_text == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
221
            $this->addText($this->value['right_margin_position'] - $this->getTextWidth($this->value['font_size'], "<i>Fortsættes på næste side...</i>") - 30, $this->value["margin_bottom"] - $this->value['font_padding_top'] - $this->value['font_size'], $this->value['font_size'], "<i>Fortsættes på næste side...</i>");
222
        }
223
        parent::newPage();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (newPage() instead of nextPage()). Are you sure this is correct? If so, you might want to change this to $this->newPage().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
224
        $this->setY(0);
225
        $this->page++;
226
        return $this->get('y');
227
    }
228
229
    /**
230
     * Get values
231
     *
232
     * @param string $key Which string to get
233
     *
234
     * @return mixed
235
     */
236 3
    public function get($key = '')
237
    {
238 3
        if (!empty($key)) {
239 3
            return($this->value[$key]);
240
        } else {
241
            return $this->value;
242
        }
243
    }
244
}
245