HuasoFoundries /
jpgraph
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * JPGraph v4.0.3 |
||||
| 5 | */ |
||||
| 6 | |||||
| 7 | namespace Amenadiel\JpGraph\Util; |
||||
| 8 | |||||
| 9 | // |
||||
| 10 | // First of all set up a default error handler |
||||
| 11 | // |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * The default trivial text error handler. |
||||
| 15 | */ |
||||
| 16 | class JpGraphErrObject |
||||
| 17 | { |
||||
| 18 | protected $iTitle = 'JpGraph error: '; |
||||
| 19 | protected $iDest = false; |
||||
| 20 | |||||
| 21 | public function __construct() |
||||
| 22 | { |
||||
| 23 | // Empty. Reserved for future use |
||||
| 24 | } |
||||
| 25 | |||||
| 26 | public function SetTitle($aTitle) |
||||
| 27 | { |
||||
| 28 | $this->iTitle = $aTitle; |
||||
| 29 | } |
||||
| 30 | |||||
| 31 | public function SetStrokeDest($aDest) |
||||
| 32 | { |
||||
| 33 | $this->iDest = $aDest; |
||||
| 34 | } |
||||
| 35 | |||||
| 36 | // If aHalt is true then execution can't continue. Typical used for fatal errors |
||||
| 37 | public function Raise($aMsg, $aHalt = false) |
||||
| 38 | { |
||||
| 39 | if ($this->iDest != '') { |
||||
| 40 | if ($this->iDest == 'syslog') { |
||||
| 41 | error_log($this->iTitle . $aMsg); |
||||
| 42 | } else { |
||||
| 43 | $str = '[' . date('r') . '] ' . $this->iTitle . $aMsg . "\n"; |
||||
| 44 | $f = @fopen($this->iDest, 'a'); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 45 | if ($f) { |
||||
|
0 ignored issues
–
show
|
|||||
| 46 | @fwrite($f, $str); |
||||
|
0 ignored issues
–
show
It seems like you do not handle an error condition for
fwrite(). This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||||
| 47 | @fclose($f); |
||||
|
0 ignored issues
–
show
It seems like you do not handle an error condition for
fclose(). This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||||
| 48 | } |
||||
| 49 | } |
||||
| 50 | } else { |
||||
| 51 | $aMsg = $this->iTitle . $aMsg; |
||||
| 52 | // Check SAPI and if we are called from the command line |
||||
| 53 | // send the error to STDERR instead |
||||
| 54 | if (PHP_SAPI == 'cli') { |
||||
| 55 | fwrite(STDERR, $aMsg); |
||||
| 56 | } else { |
||||
| 57 | echo $aMsg; |
||||
| 58 | } |
||||
| 59 | } |
||||
| 60 | if ($aHalt) { |
||||
| 61 | exit(1); |
||||
|
0 ignored issues
–
show
|
|||||
| 62 | } |
||||
| 63 | } |
||||
| 64 | } |
||||
| 65 |