-
Posts
20 -
Joined
-
Last visited
Profile Information
-
Real Name
Michael
meschu's Achievements
-
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
I am going to go ahead and post my final working solution. First, I copied noise.png and arial.ttf to the root. Then I put image.php in the root and post_job.php in includes/boxes/post_job.php Here is the code for the .php files: image.php <?php include_once('includes/application_top.php'); $rand_str=substr(sha1(rand()),0,5); $character1=substr($rand_str,0,1); $character2=substr($rand_str,1,1); $character3=substr($rand_str,2,1); $character4=substr($rand_str,3,1); $character5=substr($rand_str,4,1); $image = imagecreatefrompng('noise.png'); $font = 'arial.ttf'; // Tells the script where our font is located and it's name. $black = imagecolorallocate($image, 0,0,0); // Sets color to black imagettftext($image, 30, -10, 10, 35, $black, $font, $character1); imagettftext($image, 26, 15, 40, 35, $black, $font, $character2); imagettftext($image, 30, -20, 65, 35, $black, $font, $character3); imagettftext($image, 28, 18, 100, 35, $black, $font, $character4); imagettftext($image, 30, -15, 120, 35, $black, $font, $character5); imagepng($image); imagedestroy($image); $image_value = md5($rand_str); tep_session_register('image_value'); ?> post_job.php <?php /* $Id: information.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url] Copyright © 2003 osCommerce Released under the GNU General Public License */ //session_start(); if (isset($_POST['submit'])) { $fromname = trim(stripslashes($_POST['sendername'])); $fromemail = trim(stripslashes($_POST['senderemail'])); $sendermsg = trim(stripslashes($_POST['sendermsg'])); //job details $subject = trim(stripslashes($_POST['subject'])); //job title $phone = trim(stripslashes($_POST['senderphone'])); $billing_address = trim(stripslashes($_POST['billing_address'])); $location = trim(stripslashes($_POST['location'])); $dates = trim(stripslashes($_POST['dates'])); $number = $_POST['number']; $ivv = $_SESSION['image_value']; if(md5($number) != $ivv) { // image verification failed $_SESSION['ii']=1; $err=1; } if (validateEmail($fromemail) == 0) { // not valid email address $_SESSION['ie']=1; $err=1; } if ($fromname == "") { $_SESSION['in']=1; $err=1; } if ($subject == "") { $_SESSION['is']=1; $err=1; } if ($location == "") { $_SESSION['il']=1; $err=1; } if ($phone == "") { $_SESSION['ip']=1; $err=1; } if ($billing_address == "") { $_SESSION['ib']=1; $err=1; } if ($sendermsg == "") { $_SESSION['im']=1; $err=1; } if ($err==1) { $_SESSION['p'] = $_POST; } else { $msg = "Sender's Name: " . $fromname . "\n"; $msg .= "Phone: " . $phone . "\n"; $msg .= "Billing Address: " . $billing_address . "\n\n"; $msg .= "Job Title Being Posted: " . $subject . "\n"; $msg .= "Location: " . $location . "\n"; $msg .= "Desired Posting Dates: " . $dates . "\n"; $msg .= "Job Description: " . str_replace("\r",'',$sendermsg); $subject = "WFS Job Posting Request: ".$subject; $headers = "From: " . $fromname . " <" . $fromemail . ">\n"; // $headers .= "Bcc: [email protected]\n"; //for testing purposes // $headers .= "MIME-Version: 1.0\r\n"; // $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; //$toemail = "Terese Floren <[email protected]>"; $success = mail('[email protected]', $subject, $msg, $headers); if ($success) $_SESSION['s']=1; } } function validateEmail($addr) { list($name, $domain) = explode("@", $addr); $pattern_name = '^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$'; $pattern_domain = '^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$'; $match_name = eregi($pattern_name, $name); $match_domain = eregi($pattern_domain, $domain); if ($match_name && $match_domain) return 1; else return 0; } ?> <!-- post job //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => 'Post a Job'); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); if (isset($_SESSION['p'])) { $link_list .= '<p class="err">Please correct error(s):</p>'; } if (isset($_SESSION['in'])) { $link_list .= '<div class="err">Missing Name</div>'; } if (isset($_SESSION['ie'])) { $link_list .= '<div class="err">Missing or Invalid Email</div>'; } if (isset($_SESSION['ip'])) { $link_list .= '<div class="err">Missing Phone Number</div>'; } if (isset($_SESSION['ib'])) { $link_list .= '<div class="err">Missing Billing Address</div>'; } if (isset($_SESSION['is'])) { $link_list .= '<div class="err">Missing Job Title Being Posted</div>'; } if (isset($_SESSION['il'])) { $link_list .= '<div class="err">Missing Location</div>'; } if (isset($_SESSION['im'])) { $link_list .= '<div class="err">Missing Job Details</div>'; } if (isset($_SESSION['ii'])) { $link_list .= '<div class="err">Invalid Image Verification ' . $_SESSION['image_value'] . '</div>'; } if (isset($_SESSION['s'])) { $link_list .= '<p class="err">Your posting has been sent.</p>'; } $link_list .= '<form class="sm" name="board" action="' . $PHP_SELF . '" method="post" id="board"><p class="label">Your Name:</p><input type="text" name="sendername" value="'; if (isset($_SESSION['p']['sendername'])) { $link_list .= $_SESSION['p']['sendername']; } $link_list .= '">'; $link_list .= '<p class="label">Your Email:</p><input type="text" name="senderemail" value="'; if (isset($_SESSION['p']['senderemail'])) { $link_list .= $_SESSION['p']['senderemail']; } $link_list .= '">'; $link_list .= '<p class="label">Your Phone:</p><input type="text" name="senderphone" value="'; if (isset($_SESSION['p']['senderphone'])) { $link_list .= $_SESSION['p']['senderphone']; } $link_list .= '">'; $link_list .= '<p class="label">Your <b>Complete</b> Billing Address:</p><input type="text" name="billing_address" value="'; if (isset($_SESSION['p']['billing_address'])) { $link_list .= $_SESSION['p']['billing_address']; } $link_list .= '">'; $link_list .= '<p class="label">Job Title Being Posted:</p><input id="subject" type="text" name="subject" value="'; if (isset($_SESSION['p']['subject'])) { $link_list .= $_SESSION['p']['subject']; } else { if (!empty($row_subject['subject'])) { $link_list .= 'RE: ' . $row_subject['subject']; } } $link_list .= '">'; $link_list .= '<p class="label">Location:</p><input type="text" name="location" value="'; if (isset($_SESSION['p']['location'])) { $link_list .= $_SESSION['p']['location']; } $link_list .= '">'; $link_list .= '<p class="label">Desired Posting Dates:</p><input type="text" name="dates" value="'; if (isset($_SESSION['p']['dates'])) { $link_list .= $_SESSION['p']['dates']; } $link_list .= '">'; $link_list .= '<p class="label">Details:</p><textarea rows="8" name="sendermsg">'; if (isset($_SESSION['p']['sendermsg'])) { $link_list .= $_SESSION['p']['sendermsg']; } $link_list .= '</textarea>'; $test = 'Just testing'; $link_list .= '<img src="'; $link_list .= tep_href_link('image.php'); $link_list .= '" alt=""><input type="hidden" name="ivv" value="'; $link_list .= $_SESSION['image_value']; $link_list .= '">'; $link_list .= '<p class="label">Enter Text From Image Above:</p><input type="text" name="number" value="'; if (isset($_SESSION['number'])) { $link_list .= $_SESSION['number']; } $link_list .= '">'; $link_list .= '<p>We will contact you upon receiving your post regarding posting options and payment.</p>'; $link_list .= '<input type="submit" name="submit" value="Send Message" id="submit"></form>'; $info_box_contents[] = array('text' => $link_list); new infoBox($info_box_contents); ?> <br /> </td> </tr> <!-- post job eof //--> THANKS to everyone for all the help. -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
Thanks to everyone for their help. I put the image.php in the root and added the include('./includes/application_top.php') and now everything is happy. Finally!!!! Thanks again everyone. -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
Well, post job is in includes/boxes now. Doesn't it have to stay there? I did move it to the root, but it didn't show anything when I tried to hit it directly. -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
Gotcha... So. I would think this (see code) would echo out the session variable, but it doesn't the way my other script does. <?php include_once('../includes/application_top.php'); //include_once('../includes/functions/sessions.php'); $rand_str=substr(sha1(rand()),0,5); $character1=substr($rand_str,0,1); $character2=substr($rand_str,1,1); $character3=substr($rand_str,2,1); $character4=substr($rand_str,3,1); $character5=substr($rand_str,4,1); $image = imagecreatefrompng('noise.png'); $font = 'arial.ttf'; // Tells the script where our font is located and it's name. $black = imagecolorallocate($image, 0,0,0); // Sets color to black imagettftext($image, 30, -10, 10, 35, $black, $font, $character1); imagettftext($image, 26, 15, 40, 35, $black, $font, $character2); imagettftext($image, 30, -20, 65, 35, $black, $font, $character3); imagettftext($image, 28, 18, 100, 35, $black, $font, $character4); imagettftext($image, 30, -15, 120, 35, $black, $font, $character5); imagepng($image); imagedestroy($image); $image_value = md5($rand_str); tep_session_register('image_value'); echo $_SESSION['image_value']; ?> -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
Ok here is all the code. This is in /includes/boxes/post_job.php <?php /* $Id: information.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url] Copyright © 2003 osCommerce Released under the GNU General Public License */ //session_start(); if (isset($_POST['submit'])) { $fromname = trim(stripslashes($_POST['sendername'])); $fromemail = trim(stripslashes($_POST['senderemail'])); $sendermsg = trim(stripslashes($_POST['sendermsg'])); //job details $subject = trim(stripslashes($_POST['subject'])); //job title $phone = trim(stripslashes($_POST['senderphone'])); $billing_address = trim(stripslashes($_POST['billing_address'])); $location = trim(stripslashes($_POST['location'])); $dates = trim(stripslashes($_POST['dates'])); $number = $_POST['number']; $ivv = $_SESSION['image_value']; if(md5($number) != $ivv) { // image verification failed $_SESSION['ii']=1; $err=1; } if (validateEmail($fromemail) == 0) { // not valid email address $_SESSION['ie']=1; $err=1; } if ($fromname == "") { $_SESSION['in']=1; $err=1; } if ($subject == "") { $_SESSION['is']=1; $err=1; } if ($location == "") { $_SESSION['il']=1; $err=1; } if ($phone == "") { $_SESSION['ip']=1; $err=1; } if ($billing_address == "") { $_SESSION['ib']=1; $err=1; } if ($sendermsg == "") { $_SESSION['im']=1; $err=1; } if ($err==1) { $_SESSION['p'] = $_POST; } else { $msg = "Sender's Name: " . $fromname . "\n"; $msg .= "Phone: " . $phone . "\n"; $msg .= "Billing Address: " . $billing_address . "\n\n"; $msg .= "Job Title Being Posted: " . $subject . "\n"; $msg .= "Location: " . $location . "\n"; $msg .= "Desired Posting Dates: " . $dates . "\n"; $msg .= "Job Description: " . str_replace("\r",'',$sendermsg); $subject = "WFS Job Posting Request: ".$subject; $headers = "From: " . $fromname . " <" . $fromemail . ">\n"; // $headers .= "Bcc: [email protected]\n"; //for testing purposes // $headers .= "MIME-Version: 1.0\r\n"; // $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; //$toemail = "Terese Floren <[email protected]>"; $success = mail('[email protected]', $subject, $msg, $headers); if ($success) $_SESSION['s']=1; } } function validateEmail($addr) { list($name, $domain) = explode("@", $addr); $pattern_name = '^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$'; $pattern_domain = '^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$'; $match_name = eregi($pattern_name, $name); $match_domain = eregi($pattern_domain, $domain); if ($match_name && $match_domain) return 1; else return 0; } ?> <!-- post job //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => 'Post a Job'); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); if (isset($_SESSION['p'])) { $link_list .= '<p class="err">Please correct error(s):</p>'; } if (isset($_SESSION['in'])) { $link_list .= '<div class="err">Missing Name</div>'; } if (isset($_SESSION['ie'])) { $link_list .= '<div class="err">Missing or Invalid Email</div>'; } if (isset($_SESSION['ip'])) { $link_list .= '<div class="err">Missing Phone Number</div>'; } if (isset($_SESSION['ib'])) { $link_list .= '<div class="err">Missing Billing Address</div>'; } if (isset($_SESSION['is'])) { $link_list .= '<div class="err">Missing Job Title Being Posted</div>'; } if (isset($_SESSION['il'])) { $link_list .= '<div class="err">Missing Location</div>'; } if (isset($_SESSION['im'])) { $link_list .= '<div class="err">Missing Job Details</div>'; } if (isset($_SESSION['ii'])) { $link_list .= '<div class="err">Invalid Image Verification ' . $_SESSION['image_value'] . '</div>'; } if (isset($_SESSION['s'])) { $link_list .= '<p class="err">Your posting has been sent.</p>'; } $link_list .= '<form class="sm" name="board" action="' . $PHP_SELF . '" method="post" id="board"><p class="label">Your Name:</p><input type="text" name="sendername" value="'; if (isset($_SESSION['p']['sendername'])) { $link_list .= $_SESSION['p']['sendername']; } $link_list .= '">'; $link_list .= '<p class="label">Your Email:</p><input type="text" name="senderemail" value="'; if (isset($_SESSION['p']['senderemail'])) { $link_list .= $_SESSION['p']['senderemail']; } $link_list .= '">'; $link_list .= '<p class="label">Your Phone:</p><input type="text" name="senderphone" value="'; if (isset($_SESSION['p']['senderphone'])) { $link_list .= $_SESSION['p']['senderphone']; } $link_list .= '">'; $link_list .= '<p class="label">Your <b>Complete</b> Billing Address:</p><input type="text" name="billing_address" value="'; if (isset($_SESSION['p']['billing_address'])) { $link_list .= $_SESSION['p']['billing_address']; } $link_list .= '">'; $link_list .= '<p class="label">Job Title Being Posted:</p><input id="subject" type="text" name="subject" value="'; if (isset($_SESSION['p']['subject'])) { $link_list .= $_SESSION['p']['subject']; } else { if (!empty($row_subject['subject'])) { $link_list .= 'RE: ' . $row_subject['subject']; } } $link_list .= '">'; $link_list .= '<p class="label">Location:</p><input type="text" name="location" value="'; if (isset($_SESSION['p']['location'])) { $link_list .= $_SESSION['p']['location']; } $link_list .= '">'; $link_list .= '<p class="label">Desired Posting Dates:</p><input type="text" name="dates" value="'; if (isset($_SESSION['p']['dates'])) { $link_list .= $_SESSION['p']['dates']; } $link_list .= '">'; $link_list .= '<p class="label">Details:</p><textarea rows="8" name="sendermsg">'; if (isset($_SESSION['p']['sendermsg'])) { $link_list .= $_SESSION['p']['sendermsg']; } $link_list .= '</textarea>'; $test = 'Just testing'; $link_list .= '<img src="'; $link_list .= tep_href_link('images/image.php'); $link_list .= '" alt=""><input type="hidden" name="ivv" value="'; $link_list .= $_SESSION['image_value']; $link_list .= '">'; $link_list .= '<p class="label">Enter Text From Image Above' . $_SESSION['image_value'] . ':</p><input type="text" name="number" value="'; if (isset($_SESSION['number'])) { $link_list .= $_SESSION['number']; } $link_list .= '">'; $link_list .= '<p>We will contact you upon receiving your post regarding posting options and payment.</p>'; $link_list .= '<input type="submit" name="submit" value="Send Message" id="submit"></form>'; $info_box_contents[] = array('text' => $link_list); new infoBox($info_box_contents); ?> <br /> </td> </tr> <!-- post job eof //--> This is in /images/image.php <?php session_start(); //include_once('../includes/classes/http_client.php'); include_once('../includes/functions/sessions.php'); $rand_str=substr(sha1(rand()),0,5); $character1=substr($rand_str,0,1); $character2=substr($rand_str,1,1); $character3=substr($rand_str,2,1); $character4=substr($rand_str,3,1); $character5=substr($rand_str,4,1); $image = imagecreatefrompng('noise.png'); $font = 'arial.ttf'; // Tells the script where our font is located and it's name. $black = imagecolorallocate($image, 0,0,0); // Sets color to black imagettftext($image, 30, -10, 10, 35, $black, $font, $character1); imagettftext($image, 26, 15, 40, 35, $black, $font, $character2); imagettftext($image, 30, -20, 65, 35, $black, $font, $character3); imagettftext($image, 28, 18, 100, 35, $black, $font, $character4); imagettftext($image, 30, -15, 120, 35, $black, $font, $character5); imagepng($image); imagedestroy($image); $image_value = md5($rand_str); tep_session_register('image_value'); //echo $_SESSION['image_value']; ?> -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
No luck. I can't even echo out the session variable when I do that. Arghhh...this is getting frustrating. This is my first time working with osC. -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
Ok, here is what I have. A form and this is how I am referencing my captcha image: $link_list .= '<img src="'; $link_list .= tep_href_link('images/image.php'); $link_list .= '" alt=""><input type="hidden" name="ivv" value="'; $link_list .= $_SESSION['image_value']; $link_list .= '">'; then, in my captcha image script: <?php session_start(); include_once('../includes/classes/http_client.php'); include_once('../includes/functions/sessions.php'); $rand_str=substr(sha1(rand()),0,5); $character1=substr($rand_str,0,1); $character2=substr($rand_str,1,1); $character3=substr($rand_str,2,1); $character4=substr($rand_str,3,1); $character5=substr($rand_str,4,1); $image = imagecreatefrompng('noise.png'); $font = 'arial.ttf'; // Tells the script where our font is located and it's name. $black = imagecolorallocate($image, 0,0,0); // Sets color to black imagettftext($image, 30, -10, 10, 35, $black, $font, $character1); imagettftext($image, 26, 15, 40, 35, $black, $font, $character2); imagettftext($image, 30, -20, 65, 35, $black, $font, $character3); imagettftext($image, 28, 18, 100, 35, $black, $font, $character4); imagettftext($image, 30, -15, 120, 35, $black, $font, $character5); imagepng($image); imagedestroy($image); $image_value = md5($rand_str); tep_session_register('image_value'); ?> If i echo out the image_value session variable with echo $_SESSION['image_value']; I verify that it is being sent. The problem is, it is NOT being passed back to my form to populate the ivv value. -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
Sorry, I don't follow. By FWR? I have been pulling my hair out with this one for a while. I know how to access a session variable. My problem is that I am trying to register one and it is not registering properly and being passed back to my form that is in osCommerce. Thanks for your help! -
How to declare and access a session variable in osC ?
meschu replied to brij_theinvader's topic in General Add-Ons Support
I am having the exact same problem. Did you ever find a solution to this...Thanks.