Skip to content

Commit

Permalink
Fix deprecation notices under PHP 8.1. Fixes #114
Browse files Browse the repository at this point in the history
  • Loading branch information
dapphp committed Jul 31, 2023
1 parent 680b1f5 commit 864ba75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions example_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@
<div class="success">The captcha was correct and the message has been sent! The captcha was solved in <?php echo $_SESSION['ctform']['timetosolve'] ?> seconds.</div><br />
<?php endif; ?>

<form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']) ?>" id="contact_form">
<form method="post" action="<?= htmlspecialchars($_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ?? '')) ?>" id="contact_form">
<input type="hidden" name="do" value="contact">

<p>
<label for="ct_name">Name*:</label>
<?php echo @$_SESSION['ctform']['name_error'] ?>
<input type="text" id="ct_name" name="ct_name" size="35" value="<?php echo htmlspecialchars(@$_SESSION['ctform']['ct_name']) ?>">
<input type="text" id="ct_name" name="ct_name" size="35" value="<?= htmlspecialchars($_SESSION['ctform']['ct_name'] ?? '') ?>">
</p>

<p>
<label for="ct_email">Email*:</label>
<?php echo @$_SESSION['ctform']['email_error'] ?>
<input type="text" id="ct_email" name="ct_email" size="35" value="<?php echo htmlspecialchars(@$_SESSION['ctform']['ct_email']) ?>">
<input type="text" id="ct_email" name="ct_email" size="35" value="<?= htmlspecialchars($_SESSION['ctform']['ct_email'] ?? '') ?>">
</p>

<p>
<label for="ct_URL">URL:</label>
<?php echo @$_SESSION['ctform']['URL_error'] ?>
<input type="text" id="ct_URL" name="ct_URL" size="35" value="<?php echo htmlspecialchars(@$_SESSION['ctform']['ct_URL']) ?>">
<input type="text" id="ct_URL" name="ct_URL" size="35" value="<?= htmlspecialchars($_SESSION['ctform']['ct_URL'] ?? '') ?>">
</p>

<p>
<label for="ct_message">Message*:</label>
<?php echo @$_SESSION['ctform']['message_error'] ?>
<textarea id="ct_message" name="ct_message" rows="12" cols="60"><?php echo htmlspecialchars(@$_SESSION['ctform']['ct_message']) ?></textarea>
<?= $_SESSION['ctform']['message_error'] ?? '' ?>
<textarea id="ct_message" name="ct_message" rows="12" cols="60"><?= htmlspecialchars($_SESSION['ctform']['ct_message'] ?? '') ?></textarea>
</p>

<div>
Expand Down
8 changes: 4 additions & 4 deletions securimage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ protected function distortedCopy()
$maxX = $this->image_width - $x; // maximum x coordinate of a pole
$dx = mt_rand($x / 10, $x); // horizontal distance between poles
$y = mt_rand(20, $this->image_height - 20); // random y coord
$dy = mt_rand(20, $this->image_height * 0.7); // y distance
$dy = mt_rand(20, round($this->image_height * 0.7, 0)); // y distance
$minY = 20; // minimum y coordinate
$maxY = $this->image_height - 20; // maximum y cooddinate

Expand Down Expand Up @@ -2023,7 +2023,7 @@ protected function distortedCopy()
$x *= $this->iscale;
$y *= $this->iscale;
if ($x >= 0 && $x < $width2 && $y >= 0 && $y < $height2) {
$c = imagecolorat($this->tmpimg, $x, $y);
$c = imagecolorat($this->tmpimg, round($x, 0), round($y, 0));
}
if ($c != $bgCol) { // only copy pixels of letters to preserve any background image
imagesetpixel($this->im, $ix, $iy, $c);
Expand All @@ -2040,7 +2040,7 @@ protected function drawLines()
for ($line = 0; $line < $this->num_lines; ++ $line) {
$x = $this->image_width * (1 + $line) / ($this->num_lines + 1);
$x += (0.5 - $this->frand()) * $this->image_width / $this->num_lines;
$y = mt_rand($this->image_height * 0.1, $this->image_height * 0.9);
$y = mt_rand(floor($this->image_height * 0.1), floor($this->image_height * 0.9));

$theta = ($this->frand() - 0.5) * M_PI * 0.33;
$w = $this->image_width;
Expand All @@ -2064,7 +2064,7 @@ protected function drawLines()
for ($i = 0; $i < $n; ++ $i) {
$x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi);
$y = $y0 + $i * $dy - $amp * $dx * sin($k * $i * $step + $phi);
imagefilledrectangle($this->im, $x, $y, $x + $lwid, $y + $lwid, $this->gdlinecolor);
imagefilledrectangle($this->im, round($x, 0), round($y, 0), round($x + $lwid, 0), round($y + $lwid, 0), $this->gdlinecolor);
}
}
}
Expand Down

0 comments on commit 864ba75

Please sign in to comment.