Image verification Problem, the images isnt appearing...
05-06-2007, 11:21 AM
|
************ Solved *****************
|
Posts: 6,169
Name: Dan
Location: Swindon
|
Hi all
I have image verification with the script for my contact form http://calm.dansgalaxy.co.uk/contact.php and i thought hey ill enable it...
I went into the config files blah blah balh enable it was working... then i started playing with it. changed the font and stuff.
now it isnt working on my server (as you will see) BUT, i have it on my pc (which has XAMPP) and its working Fine, i have overwritten everyfile to do with this form with a copy of what im using on my pc and still is itnt workin. on the the server
Could someone please help!
Dan
__________________
Personal UK Webhosting Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
Last edited by dansgalaxy : 05-06-2007 at 03:32 PM.
|
|
|
|
05-06-2007, 02:01 PM
|
Re: Image verification Problem, the images isnt appearing...
|
Posts: 522
Name: Gabe Solomon
Location: Romania
|
you can see why it doesnt work here
http://calm.dansgalaxy.co.uk/contact...125da5d9287401
arning: imagettfbbox() [ function.imagettfbbox]: Could not find/open font in /home/calm/public_html/contact/sec_image.php on line 31
Warning: imagettftext() [ function.imagettftext]: Could not find/open font in /home/calm/public_html/contact/sec_image.php on line 38
|
|
|
|
05-06-2007, 02:19 PM
|
Re: Image verification Problem, the images isnt appearing...
|
Posts: 6,169
Name: Dan
Location: Swindon
|
Okay...WTF?? whats does that mean?.. whast wrong.. it works perfectly fine on my system which is running php5 (like my server) and apache etc.. whats the differace?
Dan
__________________
Personal UK Webhosting Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
|
|
|
|
05-06-2007, 02:26 PM
|
Re: Image verification Problem, the images isnt appearing...
|
Posts: 522
Name: Gabe Solomon
Location: Romania
|
Could not find/open font in /home/calm/public_html/contact/sec_image.php on line 31
It can't find the font or open it ... the font name you can find it at the line 31 of the file contact/sec_image.php
|
|
|
|
05-06-2007, 03:04 PM
|
Re: Image verification Problem, the images isnt appearing...
|
Posts: 6,169
Name: Dan
Location: Swindon
|
Ok teh files which do this are...
config.php which is in http://calm.dansgalaxy.co.uk/contact/config.php
PHP Code:
<?php /********************************************************* This Free Script was downloaded at Free-php-Scripts.net (HelpPHP.net) This script is produced under the LGPL license Which is included with your download. Not like you are going to read it, but it mostly States that you are free to do whatever you want With this script! NOTE: Linkback is not required, but its more of a show of appreciation to us. *********************************************************/ //Site Options and configuration //Send Thank you confirmation -> 1=yes,2=no $SEND_THANKS = 1; //Enable File Upload -> 1=Yes,2=No $FILE_UPLOAD = 2; //File Storage Type -> 1= Store file, 2= Email the file (attachment), 3= Both $FILE_DO = 1; //File Upload Locations (if File Uplods if enabled and storage type either 1 or 3) $FILE_UPLOADS_DIR = 'uploaded'; /* Must be chmoded to 777, don't know how to chmod? Learn how: http://www.free-php-scripts.net/CHMOD */ //Allowed file extensions 1-> All //Specify: //$FILE_UPLOADS_EXT = array('gif','jpeg','bmp'); $FILE_UPLOADS_EXT = 1; //Maximum file size (Mega bytes) $FILE_UPLOAD_MAX = 5; //Enalbe Image Verification -> 1=Yes,2=No $IMAGE_VERIFICATION = 1; /* To enable image verification you need to be able to use ImageTTFText function in PHP (contact hosting provider for more info */ //Image Verification password (used to encrypt secret code) $IMAGE_VER_CODE = 'lkjhsdfo8&kksjdhf8o7yh'; //Image Verification Background $IMAGE_VER_BACK = 'extra/background_1.png'; //Image Verification Font $IMAGE_VER_FONT = 'extra/regi.TTF'; /* IMPORTANT: COOPBLA.TTF provided to testing purposes only, please insure that the fonts you are using are LEGAL and LICENSED before usage, otherwise, you can get sued */ //Image Verification Font Size $IMAGE_VER_SIZE = 12; //EMAIL OPTIONS //Admin emails (contact will be sent to those on the list $ADMIN_EMAILS = array('calm@dansgalaxy.co.uk'); //Site title $EMAIL_OPTIONS['TITLE'] = 'CALM contact form'; //Main email $EMAIL_OPTIONS['FROM'] = 'calm@dansgalaxy.co.uk'; //Charset $EMAIL_OPTIONS['CHARSET'] = 'utf-8'; //Type -> HTML=text/html | Text = text/plain $EMAIL_OPTIONS['TYPE'] = 'text/html'; //Email subjects $EMAIL_OPTIONS['USER_SUBJECT'] = 'Thank you for contacting CALM'; $EMAIL_OPTIONS['ADMIN_SUBJECT'] = 'New message'; /* For Templates you can use the following variables: $+name+$ -> User Name Sending Contact $+email+$ -> User Email Sending Contact $+message_text+$ -> Contact Message $+reason+$ -> Reason For Contact */ //EMAIL Template (Sent to User) $USER_TEMPLATE = '<b>Hi $+name+$,</b></span><br /><br /> <span align="justify"><b>Calm Charity has received your contact from '.$EMAIL_OPTIONS['TITLE'].'.</b></span><br /><br /> <span align="justify"><b>Your message was: <font color="blue">$+message_text+$</font></b></span><br /><br /> <!-- <span align="justify"><b>Reason: <font color="blue">$+reason+$</font></b></span><br /><br /> --> <span align="justify"><b>We will if appropriate email you at the email you provided <font color="blue">$+email+$</font></b></span><br /><br /> <span align="justify"><b>Thank you for contacting CALM charity.</b></span><br /><br /> <span align="justify"><b>'.$EMAIL_OPTIONS['TITLE'].'</b></span><br /><br /><br /> <span align="justify"><b><i>Support CALM, <a href="http://calm.dansgalaxy.co.uk/donate.php">Donate.</a></i></b></span><br /> <span align="justify"><b><i>If you did not contact Calmcharity.org, Please ignore this email.</i></b></span><br />'; //Email Template (Sent to Admin) $ADMIN_TEMPLATE = '<b>Hi CALM,</b></span><br /><br /> <span align="justify"><b>Someone has contacted you on '.$EMAIL_OPTIONS['TITLE'].'.</b></span><br /><br /> <span align="justify"><b>Their name was: <font color="blue">$+name+$</font></b></span><br /><br /> <span align="justify"><b>Their message was: <font color="blue">$+message_text+$</font></b></span><br /><br /> <!-- <span align="justify"><b>User contact reason was: <font color="blue">$+reason+$</font></b></span><br /><br /> --> <span align="justify"><b>If the message requires a reponse please repond.</b></span><br /><br /> <span align="justify"><b>Their email is <font color="blue">$+email+$</font></b></span><br /><br /> <span align="justify"><b>'.$EMAIL_OPTIONS['TITLE'].'</b></span><br />'; /* +++++++++++++++++++++++++++++++++++++ END FILE CONFIGURATION ---------------------------------------*/ ?>
this is sec_image.php stored in http://calm.dansgalaxy.co.uk/contact/sec_image.php
PHP Code:
<?php /********************************************************* This Free Script was downloaded at Free-php-Scripts.net (HelpPHP.net) This script is produced under the LGPL license Which is included with your download. Not like you are going to read it, but it mostly States that you are free to do whatever you want With this script! NOTE: Linkback is not required, but its more of a show of appreciation to us. *********************************************************/ //Include configuration file and function file //(default location is in the same directory) include_once('config.php'); include_once('functions.php'); $te_co = hex2bin($_GET['code']); $textstr = RC4($te_co,$IMAGE_VER_CODE); //Show Image $im = imagecreatefrompng($IMAGE_VER_BACK); //Create random size, angle, and dark color $angle = rand(-5, 5); $color = imagecolorallocate($im, rand(0, 100), rand(0, 100), rand(0, 100)); //Determine text size, and use dimensions to generate x & y coordinates $textsize = imagettfbbox($IMAGE_VER_SIZE, $angle, $IMAGE_VER_FONT, $textstr); $twidth = abs($textsize[2]-$textsize[0]); $theight = abs($textsize[5]-$textsize[3]); $x = (imagesx($im)/2)-($twidth/2)+(rand(-20, 20)); $y = (imagesy($im))-($theight/2); //Add text to image imagettftext($im, $IMAGE_VER_SIZE, $angle, $x, $y, $color, $IMAGE_VER_FONT, $textstr); //Output PNG Image header("Content-Type: image/png"); imagepng($im); //Destroy the image to free memory imagedestroy($im); //End Output exit; ?>
this is functions.php stored in http://calm.dansgalaxy.co.uk/contact/functions.php
PHP Code:
<?php //Hex to Binary Function function hex2bin($hexdata) { for ($i=0;$i<strlen($hexdata);$i+=2) { $bindata.=chr(hexdec(substr($hexdata,$i,2))); } return $bindata; } //Function to encrypt ip function RC4($data,$keyfile) { //ecncrypt $data with the key in $keyfile with an rc4 algorithm $pwd = $keyfile; $pwd_length = strlen($pwd); for ($i = 0; $i < 255; $i++) { $key[$i] = ord(substr($pwd, ($i % $pwd_length)+1, 1)); $counter[$i] = $i; } for ($i = 0; $i < 255; $i++) { $x = ($x + $counter[$i] + $key[$i]) % 256; $temp_swap = $counter[$i]; $counter[$i] = $counter[$x]; $counter[$x] = $temp_swap; } for ($i = 0; $i < strlen($data); $i++) { $a = ($a + 1) % 256; $j = ($j + $counter[$a]) % 256; $temp = $counter[$a]; $counter[$a] = $counter[$j]; $counter[$j] = $temp; $k = $counter[(($counter[$a] + $counter[$j]) % 256)]; $Zcipher = ord(substr($data, $i, 1)) ^ $k; $Zcrypt .= chr($Zcipher); } return $Zcrypt; } //Function to check for valid email function is_valid_email($string) { return preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $string); } //Function to check allowed extensions function allowed_ext($list,$is){ if($list == 1){ return true;} $temp = explode('.',$is); $extension = strtolower($temp[count($temp)-1]); return in_array($extension,$list); } ?>
as you will see in config the font is stored in http://calm.dansgalaxy.co.uk/contact/extra
the actual contact form which is stored at http://calm.dansgalaxy.co.uk/contactform.php is:
PHP Code:
<?php //Include configuration file and function file //(default location is in the same directory) include_once('contact/config.php'); include_once('contact/functions.php'); //If contact is being sent: if($_POST['submit_id'] == 1){ //Check name entered if($_POST['name'] == NULL){ $message = 'Please enter your name.';} /************************************************************************************/ //check if email is enetered if($message == NULL && is_valid_email($_POST['email']) == false ){ $message = 'Please enter a valid email.';} /*********************************************/ //check if message is entered if($_POST['message_text'] == NULL && $message == NULL){ $message = 'Please enter a comment.';} /**********************************************************/ //File Upload checks if($message == NULL && $FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ if($_FILES['user_file']['size'] > (($FILE_UPLOAD_MAX*1024)*1024)){ $message = 'File is over '.$FILE_UPLOAD_MAX.' MB in size.';} if($message == NULL && allowed_ext($FILE_UPLOADS_EXT,$_FILES['user_file']['name']) == false){$message = 'Invalid extension.';} /*********************/ $new_filename = date("G_i_s_").$_FILES['user_file']['name']; } //Image verificaiton checks if($message == NULL && $IMAGE_VERIFICATION == 1){ $te_co = hex2bin($_POST['hid_code']); $word_is = RC4($te_co,$IMAGE_VER_CODE); if($word_is != $_POST['confirm_image']){$message = 'Your verfication code is incorrect.';} /*************************************************************/ } //End verifications, start processing if($message == NULL){ //Check if file upload is needed if($FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ //Store file for keep and email move_uploaded_file($_FILES['user_file']['tmp_name'],$FILE_UPLOADS_DIR.$new_filename); } //compose admin/user message templates replaces $do_search = array('$+name+$','$+email+$','$+message_text+$','$+reason+$'); $do_replace = array($_POST['name'],$_POST['email'],$_POST['message_text'],$_POST['reason']); //Send user email? if($SEND_THANKS == 1){ $user_message = str_replace($do_search,$do_replace,$USER_TEMPLATE); //Set Headers $user_header = "Return-Path: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $user_header .= "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $user_header .= "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=".$EMAIL_OPTIONS['CHARSET'].";\n\n\r\n"; //Send Thank you mail ($_POST['email'],$EMAIL_OPTIONS['USER_SUBJECT'],$user_message,$user_header); } //Send admi email? if(count($ADMIN_EMAILS) > 0){ $admin_message = str_replace($do_search,$do_replace,$ADMIN_TEMPLATE); //Do we need to send file as attachment? if($FILE_DO != 1){ //Get file attriubtes $fileatt_type = $_FILES['user_file']['type']; $file = fopen($FILE_UPLOADS_DIR.$new_filename,'rb'); while($dat = fread($file,1025657)){ $attachment_data .= $dat; } fclose($file); // Encode file content $attachment_data = chunk_split(base64_encode($attachment_data)); //File upload headers $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $new_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=\"".$EMAIL_OPTIONS['CHARSET']."\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $admin_message . "\n\n"; // Add file attachment to the message $new_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$new_filename}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$new_filename}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $attachment_data . "\n\n" . "--{$mime_boundary}--\n"; unset($attachment_data); } else { //regular headers $headers = "Return-Path: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $headers .= "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $headers .= "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=".$EMAIL_OPTIONS['CHARSET'].";\n\n\r\n"; $new_message = $admin_message; } //Send admin emails foreach($ADMIN_EMAILS as $this_email){ mail ($this_email,$EMAIL_OPTIONS['USER_SUBJECT'],$new_message,$headers); } } //Remove file if not needed if($FILE_DO == 2){ unlink($FILE_UPLOADS_DIR.$new_filename); } $message = 'Your message has been sent! Thank you for contacting C.A.L.M.'; /**********************************************************************************/ $_POST = NULL; } } if($message != NULL){ /*******************************************************************EDIT MESSAGE SURROUNDINGS HERE!!!!*******************************************/ ?> <? /* #FF8080 */ ?> <span style="background: url('<? echo "$core" ?>/contact/extra/formbg.png'); color:#ff0000; font-weight: bold; font: MS comic sans"><?=$message;?></span> <?php } ?> <form action="<?php echo $_SERVER['contact/PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="contact" id="contact" style="display:inline;"> <table width="100%" border="0" align="left" cellpadding="5" cellspacing="0"> <tr> <td>Name:</td> <td><input name="name" type="text" id="name" value="<?php echo $_POST['name'];?>" /></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email" value="<?php echo $_POST['email'];?>" /></td> </tr> <? /*<tr> <td>Reason for contact: </td> <td><select name="reason" id="reason" style="width:154px;"> <?php if($_POST['reason'] == 'Support' || $_POST['reason'] == NULL){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Support"<?=$sel;?>>Support</option> <?php if($_POST['reason'] == 'Billing'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Billing"<?=$sel;?>>Billing</option> <?php if($_POST['reason'] == 'Complaints'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Complaints"<?=$sel;?>>Complaints</option> <?php if($_POST['reason'] == 'Other'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Other<?=$sel;?>">Other</option> </select></td> </tr> */ ?> <tr> <td>Message:</td> <td><textarea name="message_text" cols="40" rows="4" id="message_text"><?php echo $_POST['message_text'];?></textarea></td> </tr> <?php if($IMAGE_VERIFICATION == 1){?> <tr> <td>Verification code:</td> <td> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php $referenceid = md5(mktime()*rand()); //Generate the random string $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h" | |