Jump to content

Recommended Posts

Parse error: syntax error, unexpected $end in /home/runnerse/public_html/include/register.inc.php on line 191

 

thats what i get here is my code

 

<?php
if($_SERVER[php_SELF]=="/include/register.inc.php")
{
   header("Location: /index.php");
   exit;
}
$ipaddr = $_SERVER['REMOTE_ADDR'];

$connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");

$sql = "SELECT * FROM $tbl_banned WHERE bip = \"$ipaddr\"";

$result = @mysql_query($sql,$connection) or die("Couldn't execute ban lookup query.");
$num=mysql_num_rows($result);
if($num > 0) {
while ($row = mysql_fetch_array($result)) {
$bcomment = $row['bcomment'];
}
if(empty($bcomment)) { $bcomment = "no reason given."; }
echo "<p>Sorry, you cannot register at this time. You have been banned because:</p>
<p align=\"center\"><i>$bcomment</i></p>";
include("include/footer.inc.php");
exit;
}

if (empty($_POST)) { ?>
<p> </p>
<form method="POST">
<table align="center" cellpadding="4" cellspacing="0" width="60%">
    <tr>
        <td width="973" align="center" valign="top">
            <p><?echo "$txt_reg1"; ?></p>
        </td>
    </tr>
    <tr>
        <td width="973" align="center" valign="top">
            <p><img src="securimage_show.php"></p>
        </td>
    </tr>
    <tr>
        <td width="973" align="center" valign="top">
            <p><input type="text" name="code" maxlength="5" size="5" style="font-size:10pt;"> </p>
        </td>
    </tr>
    <tr>
        <td width="973" align="center" valign="top">
            <p><input type="submit" value="Continue ->>"> </p>
        </td>
    </tr>
</table>
</form>

<?php
} else { //form is posted
  include("securimage.php");
  $img = new securimage();
  $valid = $img->check($_POST['code']);

  if($valid == FALSE) {
  echo "<center>Sorry, the code you entered was invalid.
  <a href=\"register.php\">Go back</a> to try again.</center>";

  } else { ?>
<?php

if($_SERVER[php_SELF]=="/include/register.inc.php")
{
   header("Location: /index.php");
   exit;
}
$ipaddr = $_SERVER['REMOTE_ADDR'];

$connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");

$sql = "SELECT * FROM $tbl_banned WHERE bip = \"$ipaddr\"";

$result = @mysql_query($sql,$connection) or die("Couldn't execute ban lookup query.");
$num=mysql_num_rows($result);
if($num > 0) {
while ($row = mysql_fetch_array($result)) {
$bcomment = $row['bcomment'];
}
if(empty($bcomment)) { $bcomment = "no reason given."; }
echo "<p>Sorry, you cannot register at this time. You have been banned because:</p>
<p align=\"center\"><i>$bcomment</i></p>";
include("include/footer.inc.php");
exit;
}

if (empty($_POST)) { ?>

<div align="center">
  <h1><strong><u>Registration Instructions</u></strong></h1>
  Please ensure that you   complete all the fields fully, taking particular care over the password   fields.<br />
You will be sent an email to the email address you give after   registering. Please read the email carefully, you will need to validate your   account by clicking on a link in the email.</h1>
</div>
<form action="do_reg.php" method="post">
  <div align="center">
    <table align="center" width="100%" cellpadding="5" cellspacing="0" summary="register" class="register_tbl">
      <tr>
        <td align="left" valign="top" class="reg_cell">
          <p align="left">Choose Username:</p>          </td>
          <td align="left" valign="top" class="reg_cell">
            <div align="left">
              <input name="login" type="text" size="20" maxlength="20">
              </input>     
          </div></td>
          <td align="left" valign="top" class="reg_cell">
            <p align="left"><em><span class="help">Your Username may be 3-20 characters, letters
          and or numbers only.</span></em></p>          </td>
      </tr>
      <tr>
        <td align="left" valign="top" class="reg_cell">
          <p align="left">Password:</p>          </td>
          <td align="left" valign="top" class="reg_cell">
            <div align="left">
              <input type="password" name="pass1" maxlength="20" size="20">
              </input>        
           </div></td>
          <td align="left" valign="top" class="reg_cell">
            <p align="left"><em><span class="help">Your Password may be 3-20 characters, letters
          and or numbers only.</span></em></p>          </td>
      </tr>
      <tr>
        <td align="left" valign="top" class="reg_cell">
          <p align="left">Repeat Password:</p>          </td>
          <td align="left" valign="top" class="reg_cell">
            <div align="left">
              <input type="password" name="pass2" maxlength="20" size="20">
              </input>          
            </div></td>
          <td align="left" valign="top">
          <p align="left"><em><span class="help">Please verify your password.</span></em></p>          </td>
      </tr>
      <tr>
        <td align="left" valign="top" class="reg_cell">
          <p align="left">Email Address:</p>          </td>
          <td align="left" valign="top" class="reg_cell">
            <div align="left">
              <input type="text" name="email" maxlength="150" size="25">
              </input>           
        </div></td>
          <td align="left" valign="top" class="reg_cell">
            <p align="left"><em><span class="help">Your email address is used to retrieve lost
          password. It is not displayed to the public.</span></em></p>          </td>
      </tr>
      <tr>
        <td align="left" valign="top" class="reg_cell">
          <p align="left">Display Name:</p>          </td>
          <td align="left" valign="top" class="reg_cell">
            <div align="left">
              <input type="text" name="displayname" maxlength="25" size="25">
              </input>          
            </div></td>
          <td align="left" valign="top" class="reg_cell">
            <p align="left"><em><span class="help">This is your nickname or the name you want
          the system to refer to you by. No spaces!</span></em></p>          </td>
      </tr>
      <tr>
        <td width="901" height="70" colspan="3" valign="bottom">
          <p align="center"><input type="checkbox" name="agreestoterms" value="agreestoterms"></input> 
            I have read the <a href="aup.php" target="_blank">Acceptable Use
            Policy</a> and agree to the terms.</p>          </td>
      </tr>
      <tr>
        <td valign="top" width="901" colspan="3">
          <p align="center"> <input type="checkbox" name="newsletter" value="yes" checked></input> Subscribe
            to Newsletter updates (occasional updates regarding the site).</p>          </td>
      </tr>
      
      <tr>
        <td width="901" height="33" colspan="3" valign="top">
          <p align="center">Registration will take a few moments.</p>          </td>
      </tr>
      
      <tr>
        <td height="38" colspan="3" align="center" valign="top">
          <div align="center">
            
            <input type="submit" name="register" value="Register!">          
            </input>         
              </div></td>
      </tr>
    </table>
  </div>
</form>
  <? }} ?>

Link to comment
https://forums.phpfreaks.com/topic/42496-solved-error-with-image-validator/
Share on other sites

that worked thanks but now my secure image does not show http://www.runnerselite.com/register.php

<?php

include("securimage.php");

$img = new securimage();
//$img->show("trees.jpg");
$img->show();

?>

<?
class securimage {
  //USER CONFIGURATION OF IMAGE
  //See included README.txt for detailed descriptions

  var $image_width = 160;
  //heigh of security image

  var $image_height = 35;
  //width of security image

  var $code_length = 5;
  //how many letters in the code

  var $ttf_file = "BLATANT.TTF";
  //path to ttf font to use

  var $font_size = 16;
  //size of the font

  var $text_angle_minimum = -20;
  //minimum angle in degress of letter. counter-clockwise direction

  var $text_angle_maximum = 20;
  //maximum angle in degrees of letter. clockwise direction

  var $text_x_start = 9;
  //position (in pixels) on the x axis where text starts

  var $text_minimum_distance = 30;
  //the shortest distance in pixels letters can be from eachother (a very small value will cause overlapping)

  var $text_maximum_distance = 33;
  //the longest distance in pixels letters can be from eachother

  var $image_bg_color = array("red" => 64, "green" => 64, "blue" => 64);
  //images background color.  set each red, green, and blue to a 0-255 value

  var $text_color = array("red" => 255, "green" => 255, "blue" => 255);
  //the color of the text

  var $shadow_text = false;
  //draw a shadow for the text (gives a 3d raised bolder effect)

  var $use_transparent_text = false;
  //true for the ability to use transparent text, false for normal text

  var $text_transparency_percentage = 15;
  //0 to 100, 0 being completely opaque, 100 being completely transparent

  var $draw_lines = TRUE;
  //set to true to draw horizontal and vertical lines on the image
  //the following 3 options will have no effect if this is set to false

  var $line_color = array("red" => 128, "green" =>128, "blue" => 128);
  //color of the horizontal and vertical lines through the image

  var $line_distance = 12;
  //distance in pixels the lines will be from eachother.
  //the smaller the value, the more "cramped" the lines will be, potentially making
  //the text harder to read for people

  var $draw_angled_lines = TRUE;
  //set to true to draw lines at 45 and -45 degree angles over the image  (makes x's)

  var $draw_lines_over_text = true;
  //set to true to draw the lines on top of the text, otherwise the text will be on the lines

  var $data_directory = "image_data";
  //path of directory to store code data in.  make sure this is either outside of the webroot or unreadable

  var $prune_minimum_age = 15;
  //age (in minutes) of files containing unused codes to be deleted

  var $hash_salt = "Pirye4t3r";
  //set this to a unique string, this prevents users guessing filenames and make data more secure


  //END USER CONFIGURATION
  //There should be no need to edit below unless you really know what you are doing



  var $im;
  var $bgimg;
  var $code;
  var $code_entered;
  var $correct_code;

  function show($background_image = "")
  {
    if($background_image != "" && is_readable($background_image)) {
      $this->bgimg = $background_image;
    }

    $this->doImage();
  }

  function prune()
  {
    $this->pruneOld();
  }

  function check($code)
  {
    $this->code_entered = $code;
    $this->validate();
    return $this->correct_code;
  }

  function doImage()
  {
    if($this->use_transparent_text == TRUE || $this->bgimg != "") {
      $this->im = imagecreatetruecolor($this->image_width, $this->image_height);
      $bgcolor = imagecolorallocate($this->im, $this->image_bg_color['red'], $this->image_bg_color['green'],
      $this->image_bg_color['blue']);
      imagefilledrectangle($this->im, 0, 0, imagesx($this->im), imagesy($this->im), $bgcolor);
    } else { //no transparency
      $this->im = imagecreate($this->image_width, $this->image_height);
      $bgcolor = imagecolorallocate($this->im, $this->image_bg_color['red'], $this->image_bg_color['green'],
      $this->image_bg_color['blue']);
    }

    if($this->bgimg != "") { $this->setBackground(); }

    $this->code = $this->generateCode($this->code_length);

    if (!$this->draw_lines_over_text && $this->draw_lines) $this->drawLines();

    $this->drawWord();

    if ($this->draw_lines_over_text && $this->draw_lines) $this->drawLines();

    $this->saveData();
    $this->output();

  }

  function setBackground()
  {
    $dat = @getimagesize($this->bgimg);
    if($dat == FALSE) { return; }

    switch($dat[2]) {
      case 1: $newim = @imagecreatefromgif($this->bgimg); break;
      case 2: $newim = @imagecreatefromjpeg($this->bgimg); break;
      case 3: $newim = @imagecreatefrompng($this->bgimg); break;
      case 15: $newim = @imagecreatefromwbmp($this->bgimg); break;
      case 16: $newim = @imagecreatefromxbm($this->bgimg); break;
      default: return;
    }

    if(!$newim) return;

    imagecopy($this->im, $newim, 0, 0, 0, 0, $this->image_width, $this->image_height);
  }

  function drawLines()
  {
    $linecolor = imagecolorallocate($this->im, $this->line_color['red'], $this->line_color['green'],
    $this->line_color['blue']);

    //vertical lines
    for($x = 1; $x < $this->image_width; $x += $this->line_distance) {
      imageline($this->im, $x, 0, $x, $this->image_height, $linecolor);
    }

    //horizontal lines
    for($y = 11; $y < $this->image_height; $y += $this->line_distance) {
      imageline($this->im, 0, $y, $this->image_width, $y, $linecolor);
    }

    if ($this->draw_angled_lines == TRUE) {
      for ($x = -($this->image_height); $x < $this->image_width; $x += $this->line_distance) {
        imageline($this->im, $x, 0, $x + $this->image_height, $this->image_height, $linecolor);
      }

      for ($x = $this->image_width + $this->image_height; $x > 0; $x -= $this->line_distance) {
        imageline($this->im, $x, 0, $x - $this->image_height, $this->image_height, $linecolor);
      }
    }
  }

  function drawWord()
  {
    if($this->use_transparent_text == TRUE) {
      $alpha = floor($this->text_transparency_percentage / 100 * 127);
      $font_color = imagecolorallocatealpha($this->im, $this->text_color['red'], $this->text_color['green'],
      $this->text_color['blue'], $alpha);
    } else { //no transparency
      $font_color = imagecolorallocate($this->im, $this->text_color['red'], $this->text_color['green'],
      $this->text_color['blue']);
    }

    $x = $this->text_x_start;
    $strlen = strlen($this->code);
    $y_min = ($this->image_height / 2) + ($this->font_size / 2) - 2;
    $y_max = ($this->image_height / 2) + ($this->font_size / 2) + 2;
    for($i = 0; $i < $strlen; ++$i) {
      $angle = rand($this->text_angle_minimum, $this->text_angle_maximum);
      $y = rand($y_min, $y_max);
      imagettftext($this->im, $this->font_size, $angle, $x, $y, $font_color, $this->ttf_file, $this->code{$i});
      if($this->shadow_text == TRUE) {
        imagettftext($this->im, $this->font_size, $angle, $x + 2, $y + 2, $font_color, $this->ttf_file,
        $this->code{$i});
      }
      $x += rand($this->text_minimum_distance, $this->text_maximum_distance);
    }
  }



  function generateCode($len)
  {
    $code = "";
    for($i = 1; $i <= $len; ++$i) {
      $code .= chr(rand(65, 90));
    }
    return $code;
  }

  function output()
  {
    header("Expires: Sun, 1 Jan 2000 12:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Content-Type: image/jpeg");
    imagejpeg($this->im);
    imagedestroy($this->im);
  }

  function saveData()
  {
    $filename = md5($this->hash_salt . $_SERVER['REMOTE_ADDR']);
    $fp = fopen($this->data_directory . "/" . $filename, "w+");
    fwrite($fp, md5( $this->hash_salt . strtolower($this->code) )  );
    fclose($fp);
  }

  function validate()
  {
    $filename = md5($this->hash_salt . $_SERVER['REMOTE_ADDR']);

    $enced_code = trim(@file_get_contents($this->data_directory . "/" . $filename));

    $check = md5($this->hash_salt . strtolower($this->code_entered));

    if($check == $enced_code) {
      $this->correct_code = TRUE;
      @unlink($this->data_directory . "/" . $filename);
    } else {
      $this->correct_code = FALSE;
    }
  }

  function checkCode()
  {
    return $this->correct_code;
  }

  function pruneOld()
  {
    if ($handle = @opendir($this->data_directory)) {
      while (($filename = readdir($handle)) !== false) {
        if(time() - filemtime($this->data_directory . "/" . $filename) > $this->prune_minimum_age * 60) {
          @unlink($this->data_directory . "/" . $filename);
        }
      }
      closedir($handle);
    }
  }

} //end class

?>

When I access directly to your image generator (over here), I get the following error:

Fatal error: Call to undefined function: imagettftext() in /home/runnerse/public_html/securimage.php on line 202

 

Since the other GD functions you got do work, that means GD is installed. So I believe you don't have the FreeType library installed, which is required for imagettftext(). If you can't install that library, you should look into imagestring() and imageloadfont().

 

 

Orio.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.