Code: Select all
Parse error: parse error, unexpected $ in /home/content/h/o/w/howardmergler/html/contact.php on line 312The pieces of PHP code that I am using are as follows. I have not altered any of the code except for the paths listed and also a slight modifcation to the table layout in the last piece of code. I have unfortunately not been able to get any response from the original author of the code, but he does use this code successfully on his site.
The very top of the web page:
Code: Select all
<?php
session_start();
session_register('majik_string');
require '/contact/scfconfig.php'; // Get our config
?>Code: Select all
<?php
// Web form spammers frequently either leave HTTP_REFERER empty, set it
// equal to the form's own URL, or make something up out of thin air.
// We don't do this "is it our own server" if it's blank, as the "is it
// blank" check will get that one
$selfChkStr = $_SERVER['PHP_SELF'];
$serverChkStr = "http://" . $_SERVER['SERVER_NAME'];
if(($chkFormRefNotBlank && !$_SERVER['HTTP_REFERER']) ||
($chkFormRefNotSelf && preg_match("#$selfChkStr$#i", $_SERVER['HTTP_REFERER'])) ||
($chkFormRefOwnServer && $_SERVER['HTTP_REFERER'] &&
!preg_match("#^$serverChkStr#i", $_SERVER['HTTP_REFERER'])))
{
// Almost certainly web form spammers - let 'em wait for it
sleep(10);
// Crude, very crude (gracefully "terminate" the page early)
print("<div align=\"center\"><font color=\"red\">Disallowed HTTP Referer! ("" .
$_SERVER['HTTP_REFERER'] .
"")</font></div>");
print("</body></html>");
exit;
}
// if($requireVerify)
// print("<div align=\"center\"><font color=\"red\">Cookies must be enabled to use this form.</font></div><p />");
?>Code: Select all
<?php
// Get a pseudo-random alpha-numeric string (no zeros and O's)
function pseudo_random_string($length) {
$string = "";
while($length--) {
for($indx = rand(49, 90);
($indx > 57 && $indx < 65) || $indx == 79;
$indx = rand(49, 90))
;
$string .= chr($indx);
}
return($string);
}
// Read a line from a config file, stripping comments
// and blank lines
function read_file_line($fp) {
while(($inString = fgets($fp, 2048)) != false) {
$inString = rtrim(preg_replace('/\s*#.*/', '',
$inString));
if(!empty($inString))
break;
}
return $inString;
}
if(!$HTTP_SESSION_VARS['majik_string'])
$HTTP_SESSION_VARS['majik_string'] = pseudo_random_string(5);
// Read the contact list keys and descriptions into hash
if(($fp = fopen($recipientFile, "r")) == false) {
die("Can't open data file '$recipientFile'.\n");
}
while($inString = read_file_line($fp)) {
list($key, $description, $value) =
explode(':', $inString);
$options[$key] = $description;
}
fclose($fp);
// If we've more than one choice: present a menu
if(count($options) > 1) {
// If we were given a single arg, that'll be the
// selected menu item.
if(count($_GET) == 1)
$selected = strtolower(key($_GET));
print("<select name=\"whoto\">\n");
foreach($options as $key => $description) {
print("<option ");
if(strtolower($key) == $selected)
print("selected ");
print("value=\"" . trim($key) . "\">" .
trim($description) . "\n");
}
print("</select>\n");
} else {
// There'll be only one...
foreach($options as $key => $description) {
print("<input type=\"hidden\" name=\"whoto\" value=\"" .
trim($key) . "\">" . trim($description) . "\n");
}
}
// Used by the form processor acknowledgment to create a
// "take me back" link.
if(!empty($_SERVER['HTTP_REFERER'])) {
print("<input type=\"hidden\" name=\"orig_referer\" value=\"" .
$_SERVER['HTTP_REFERER'] . "\">\n");
}
?>Located in a table in the body:
Code: Select all
<?php
// Are we requiring CAPTCHA-style "is a human" verification?
if($requireVerify) {
print <<<End_Of_Data
<tr><td> </td></tr>
<tr>
<td colspan="2">
Please enter the verification string on the right into the box on the left.
</td>
</tr>
<tr>
<td align="right">
Verification:
</td>
<td align="left">
<input type="text" name="verify" size=10>
<img src="/contact/scfgenimg.php" width="60" height="20" align="top" alt="Verification string image"/>
</td>
</tr>
End_Of_Data;
}
?>Thanks in advance,
The Merg