Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-18-2007, 12:19 PM
thebaldknight is offline thebaldknight
Registered User

Join Date: Aug 2007
Posts: 6

PHMailer - grab url

Hi all.

I'd like phmailer to grab the url of the page it is on and place it into the message box, so I can have it when someone is contacting me about an image.

Anyone know how to do this? I'd imagine it's just adding a little code to it.

Thanks
Reply With Quote
  #2  
Old 08-18-2007, 01:56 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

PHP Code:
$url $_SERVER['SERVER_NAME'];
$page $_SERVER['PHP_SELF'];
$send 'http://' $url $page
Then throw that into the body of the message sent...
Reply With Quote
  #3  
Old 08-18-2007, 02:01 PM
thebaldknight is offline thebaldknight
Registered User

Join Date: Aug 2007
Posts: 6

Thanks much I'll try it right away! ...
Reply With Quote
  #4  
Old 08-18-2007, 02:06 PM
thebaldknight is offline thebaldknight
Registered User

Join Date: Aug 2007
Posts: 6

ok..can't find that spot.....

can you show me here.. thanks agian


// Will get the extension of the users file. For some reason trying to get the actual type of the file caused problems with certain browsers.

function get_ext($key) {
$key=strtolower(substr(strrchr($key, "."), 1));
// Cause there the same right?
$key=str_replace("jpeg","jpg",$key);
return $key;
}

function phattach($file,$name) {
global $boundary;

$fp=@fopen($file,"r");
$str=@fread($fp, filesize($file));
$str=@chunk_split(base64_encode($str));
$message="--".$boundary."\n";
$message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
//$message.="Content-disposition: attachment\n"; Thanks goes to someone named Chris (I think, it was awhile ago) for his fix below!
$message.="Content-disposition: attachment; filename=\"".$name."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="\n";
$message.="$str\n";
$message.="\n";

return $message;
}

//Little bit of security from people forging headers. People are mean sometimes
function clean($key) {
$key=str_replace("\r", "", $key);
$key=str_replace("\n", "", $key);
$find=array(
"/bcc\:/i",
"/Content\-Type\:/i",
"/Mime\-Type\:/i",
"/cc\:/i",
"/to\:/i"
);
$key=preg_replace($find,"",$key);
return $key;
}

// Safe for register_globals=on =)

$error="";
$types="";
$sent_mail=false;

// Do some loopy stuff for the valid file types so people can see what types are valid before they try and upload invalid ones.

$ext_count=count($allowtypes);
$i=0;

foreach($allowtypes AS $extension) {

//Gets rid of the last comma

If($i <= $ext_count-2) {
$types .="*.".$extension.", ";
} Else {
$types .="*.".$extension;
}
$i++;
}
unset($i,$ext_count); // why not


// If they post the form start the mailin'!

If($_POST['submit']==true) {
extract($_POST, EXTR_SKIP);

// Check the form for errors

If(trim($yourname)=="") {
$error.="You did not enter your name!<br />";
}

If(trim($youremail)=="") {
$error.="You did not enter your email!<br />";
} Elseif(!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)) {
$error.="Invalid email address.<br />";
}

If(trim($emailsubject)=="content abuse") {
$emailsubject=$defaultsubject;
}

If(trim($yourmessage)=="") {
$error.="You did not enter a message!<br />";
}

// Verify Attchment info

If($allowattach > 0) {

//Loopish

For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['name'][$i]) {

$ext=get_ext($_FILES['attachment']['name'][$i]);
$size=$_FILES['attachment']['size'][$i];
$max_bytes=$max_file_size*1024;

//Check if the file type uploaded is a valid file type.

If(!in_array($ext, $allowtypes)) {

$error.= "Invalid extension for your file: ".$_FILES['attachment']['name'][$i].", only ".$types." are allowed.<br />";

//Check the size of each file

} Elseif($size > $max_bytes) {
$error.= "Your file: ".$_FILES['attachment']['name'][$i]." is to big. Max file size is ".$max_file_size."kb.<br />";
}

} // If Files

} // For

//Tally the size of all the files uploaded, check if it's over the ammount.

$total_size=array_sum($_FILES['attachment']['size']);

$max_file_total_bytes=$max_file_total*1024;

If($total_size > $max_file_total_bytes) {
$error.="The max size allowed for all your files is ".$max_file_total."kb<br />";
}

} // If Allowattach

If($error) {

$display_message=$error;

} Else {

If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
$subject_count=count($subjects);
$email_count=count($emails);

If($subject_count==$email_count) {

$myemail=$emails[$emailsubject];
$emailsubject=$subjects[$emailsubject];

}

}


$boundary=md5(uniqid(time()));

//Little bit of security from people forging headers. People are mean sometimes

$yourname=clean($yourname);
$yourmessage=clean($yourmessage);
$youremail=clean($youremail);

//Headers

$headers="From: ".$yourname." <".$youremail.">\n";
$headers.="Reply-To: ".$yourname." <".$youremail.">\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
$headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="X-Priority: ".$priority."\n";
$headers.="Return-Path: <".$youremail.">\n";
$headers.="This is a multi-part message in MIME format.\n";

//Message

$message = "--".$boundary."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";
$message.="\n";
$message.="$yourmessage";
$message.="\n";

//Lets attach to something! =)

If($allowattach > 0) {

For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['name'][$i]) {

$message.=phattach($_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]);

}

} //For

} // If


// End the message

$message.="--".$boundary."--\n";

// Send the completed message

If(!mail($myemail,$emailsubject,$message,$headers) ) {

Exit("An error has occured, please report this to the website administrator.\n");

} Else {

$sent_mail=true;

}

} // Else

} // $_POST

/*
//================================================== ==============================
* Start the form layout
//================================================== ==============================
:- Please know what your doing before editing below. Sorry for the stop and start php.. people requested that I use only html for the form..
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $websitename; ?> - Powered By phMailer</title>

<style type="text/css">
body{
background-color:#FFFFFF;
font-family: Verdana, Arial, sans-serif;
font-size: 12pt;
color: #000000;
}

.error_message{
font-family: Verdana, Arial, sans-serif;
font-size: 11pt;
color: #FF0000;
}

.thanks_message{
font-family: Verdana, Arial, sans-serif;
font-size: 11pt;
color: #000000;
}

a:link{
text-decoration:none;
color: #000000;
}
a:visited{
text-decoration:none;
color: #000000;
}
a:hover{
text-decoration:none;
color: #000000;
}


.table {
border-collapse:collapse;
border:1px solid #000000;
width:500px;
}

.table_header{
border:1px solid #070707;
background-color:#cbd7e2;
font-family: Verdana, Arial, sans-serif;
font-size: 11pt;
font-weight:bold;
color: #000000;
text-align:center;
padding:2px;
}

.attach_info{
border:1px solid #070707;
background-color:#EBEBEB;
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
color: #000000;
padding:4px;
}


.table_body{
border:1px solid #070707;
background-color:#EBEBEB;
font-family: Verdana, Arial, sans-serif;
font-size: 10pt;
color: #000000;
padding:2px;
}


.table_footer{
border:1px solid #070707;
background-color:#cbd7e2;
text-align:center;
padding:2px;
}


input,select,textarea {
font-family: Verdana, Arial, sans-serif;
font-size: 10pt;
color: #000000;
background-color:#AFAEAE;
border:1px solid #000000;
}

.copyright {
border:0px;
font-family: Verdana, Arial, sans-serif;
font-size: 9pt;
color: #000000;
text-align:right;
}

form{
padding:0px;
margin:0px;
}
</style>


<script type="text/javascript">
var error="";
e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;

function Checkit(theform) {

if(theform.yourname.value=="") {
error+="You did not enter your name\n";
}

if(theform.youremail.value=="") {
error+="You did not enter your email\n";
} else if(!e_regex.test(theform.youremail.value)) {
error+="Invalid email address\n";
}

if(theform.yourmessage.value=="") {
error+="You did not enter your message\n";
}

if(error) {
alert('**The form returned the following errors:**\n\n' + error);
error="";
return false;
} else {
return true;
}
}
</script>


</head>
<body>
<?If($display_message) {?>

<div align="center" class="error_message"><b><?=$display_message;?></b></div>
<br />

<?}?>

<?If($sent_mail!=true) {?>

<form method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data" name="phmailer" onsubmit="return Checkit(this);">
<table align="center" class="table">
<tr>
<td colspan="2" class="table_header" width="100%"><?=$websitename;?></td>
</tr>
<?If($allowattach > 0) {?>
<tr>
<td width="100%" class="attach_info" colspan="2">
<b>Valid Attachment Types:</b> <?=$types?><br />
<b>Max size per file:</b> <?=$max_file_size?>kb.<br />
<b>Max combined file size:</b> <?=$max_file_total?>kb.
</td>
</tr>
<?}?>

<tr>
<td width="30%" class="table_body">Your Name:<br> use porndoddle to remain anonymous</td>
<td width="70%" class="table_body"><input name="yourname" type="text" size="30" value="<?=stripslashes(htmlspecialchars($yourname) );?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="30%" class="table_body">Your Email:<br> Use porndoddle@yahoo.ca to remain anonymous
</td>
<td width="70%" class="table_body"><input name="youremail" type="text" size="30" value="<?=stripslashes(htmlspecialchars($youremail ));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="30%" class="table_body">Subject:</td>
<td width="70%" class="table_body">

<?If($use_subject_drop AND is_array($subjects)) {?>
<select name="emailsubject" size="1">
<?while(list($key,$val)=each($subjects)) {?>

<option value="<?=intval($key);?>"><?=htmlspecialchars(str ipslashes($val));?></option>

<?}?>
</select>


<?} Else {?>

<input name="emailsubject" type="text" size="30" value="<?=stripslashes(htmlspecialchars($emailsubj ect));?>" />

<?}?>

</td>
</tr>

<?For($i=1;$i <= $allowattach; $i++) {?>
<tr>
<td width="30%" class="table_body">Attach File:</td>
<td width="70%" class="table_body"><input name="attachment[]" type="file" size="30" /></td>
</tr>
<?}?>

<tr>
<td colspan="2" width="100%" class="table_body">Your Message:<br>Copy and past url here<span class="error_message">*</span><br />
<div align="center">
<textarea name="yourmessage" rows="8" cols="60"><?=stripslashes(htmlspecialchars($yourme ssage));?></textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2" width="100%" class="table_footer">
<input type="hidden" name="submit" value="true" />
<input type="submit" value="<?=$submitvalue;?>" /> &nbsp;
<input type="reset" value="<?=$resetvalue;?>" />
</td>
</tr>
</table>
</form>

<?} Else {?>

<div align="center" class="thanks_message"><?=$thanksmessage;?></div>
<br />
<br />

<?}?>

<?//Please leave this here.. it really dosen't make people hate you or make your site look bad.. ?>
<table class="table" style="border:0px;" align="center">
<tr>
<td><div class="copyright">&copy;<a href="http://www.phphq.net?script=phMailer" target="_blank" title="Form Mailer Powered By phMailer &lt;www.phphq.net&gt;">phMailer</a></div></td>
</tr>
</table>
</body>
</html>
Reply With Quote
  #5  
Old 08-18-2007, 02:22 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

PHP Code:

//My code here:
$url $_SERVER['SERVER_NAME'];
$page $_SERVER['PHP_SELF'];
$send 'http://' $url $page;

//back to his:  

 
$message "--".$boundary."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";
$message.="\n";
//add the url to this:  
$message.="$yourmessage'<br />' $send;
$message.="\n"
Reply With Quote
  #6  
Old 08-18-2007, 02:47 PM
thebaldknight is offline thebaldknight
Registered User

Join Date: Aug 2007
Posts: 6

This is what I did.. but no luck. Oh my I am not good at this...lol

function get_ext($key) {
$key=strtolower(substr(strrchr($key, "."), 1));
// Cause there the same right?
$key=str_replace("jpeg","jpg",$key);
return $key;
}

function phattach($file,$name) {
global $boundary;

$fp=@fopen($file,"r");
$str=@fread($fp, filesize($file));
$str=@chunk_split(base64_encode($str));
$message="--".$boundary."\n";
$message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
//$message.="Content-disposition: attachment\n"; Thanks goes to someone named Chris (I think, it was awhile ago) for his fix below!
$message.="Content-disposition: attachment; filename=\"".$name."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="\n";
$message.="$str\n";
$message.="\n";

return $message;
}

//Little bit of security from people forging headers. People are mean sometimes
function clean($key) {
$key=str_replace("\r", "", $key);
$key=str_replace("\n", "", $key);
$find=array(
"/bcc\:/i",
"/Content\-Type\:/i",
"/Mime\-Type\:/i",
"/cc\:/i",
"/to\:/i"
);
$key=preg_replace($find,"",$key);
return $key;
}

// Safe for register_globals=on =)

$error="";
$types="";
$sent_mail=false;

// Do some loopy stuff for the valid file types so people can see what types are valid before they try and upload invalid ones.

$ext_count=count($allowtypes);
$i=0;

foreach($allowtypes AS $extension) {

//Gets rid of the last comma

If($i <= $ext_count-2) {
$types .="*.".$extension.", ";
} Else {
$types .="*.".$extension;
}
$i++;
}
unset($i,$ext_count); // why not


// If they post the form start the mailin'!

If($_POST['submit']==true) {
extract($_POST, EXTR_SKIP);

// Check the form for errors

If(trim($yourname)=="") {
$error.="You did not enter your name!<br />";
}

If(trim($youremail)=="") {
$error.="You did not enter your email!<br />";
} Elseif(!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)) {
$error.="Invalid email address.<br />";
}

If(trim($emailsubject)=="content abuse") {
$emailsubject=$defaultsubject;
}

If(trim($yourmessage)=="") {
$error.="You did not enter a message!<br />";
}

// Verify Attchment info

If($allowattach > 0) {

//Loopish

For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['name'][$i]) {

$ext=get_ext($_FILES['attachment']['name'][$i]);
$size=$_FILES['attachment']['size'][$i];
$max_bytes=$max_file_size*1024;

//Check if the file type uploaded is a valid file type.

If(!in_array($ext, $allowtypes)) {

$error.= "Invalid extension for your file: ".$_FILES['attachment']['name'][$i].", only ".$types." are allowed.<br />";

//Check the size of each file

} Elseif($size > $max_bytes) {
$error.= "Your file: ".$_FILES['attachment']['name'][$i]." is to big. Max file size is ".$max_file_size."kb.<br />";
}

} // If Files

} // For

//Tally the size of all the files uploaded, check if it's over the ammount.

$total_size=array_sum($_FILES['attachment']['size']);

$max_file_total_bytes=$max_file_total*1024;

If($total_size > $max_file_total_bytes) {
$error.="The max size allowed for all your files is ".$max_file_total."kb<br />";
}

} // If Allowattach

If($error) {

$display_message=$error;

} Else {

If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
$subject_count=count($subjects);
$email_count=count($emails);

If($subject_count==$email_count) {

$myemail=$emails[$emailsubject];
$emailsubject=$subjects[$emailsubject];

}

}


$boundary=md5(uniqid(time()));

//Little bit of security from people forging headers. People are mean sometimes

$yourname=clean($yourname);
$yourmessage=clean($yourmessage);
$youremail=clean($youremail);

//Headers

$headers="From: ".$yourname." <".$youremail.">\n";
$headers.="Reply-To: ".$yourname." <".$youremail.">\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
$headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="X-Priority: ".$priority."\n";
$headers.="Return-Path: <".$youremail.">\n";
$headers.="This is a multi-part message in MIME format.\n";

//Message

$message = "--".$boundary."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";
$message.="\n";
$url = $_SERVER['SERVER_NAME'];
$page = $_SERVER['PHP_SELF'];
$send = 'http://' . $url . $page;
$message.="$yourmessage";
$message.="\n";

//Lets attach to something! =)

If($allowattach > 0) {

For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['name'][$i]) {

$message.=phattach($_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]);

}

} //For

} // If


// End the message

$message.="--".$boundary."--\n";

// Send the completed message

If(!mail($myemail,$emailsubject,$message,$headers) ) {

Exit("An error has occured, please report this to the website administrator.\n");

} Else {

$sent_mail=true;

}

} // Else

} // $_POST
Reply With Quote
  #7  
Old 08-18-2007, 02:51 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

Your getting closer

PHP Code:
 $message "--".$boundary."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";
$message.="\n";
$url $_SERVER['SERVER_NAME'];
$page $_SERVER['PHP_SELF'];
$send 'http://' $url $page;
$message.="$yourmessage";
$message.="\n"
Notice the:
PHP Code:
$message .= "$yourmessage"
make it look like this:
PHP Code:
$message .= "$yourmessage'<br />' $send
Reply With Quote
  #8  
Old 08-18-2007, 03:46 PM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
And please dont post the full code.. Just the part you are editing...
And place it between the code tags (code) text (/code) Replace ( and ) with [ and ]



________________


Scott, i cant edit the posts here... Can you update my permits?
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #9  
Old 08-18-2007, 03:47 PM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
dam doublepost..
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here

Last edited by katana*GFR*; 08-19-2007 at 03:34 AM.
Reply With Quote
  #10  
Old 08-18-2007, 05:13 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

Also, if the solutions/ideas that I've presented work, please say so. This helps others who might have a similar problem solve it quicker. Thanks!
Reply With Quote
  #11  
Old 08-18-2007, 06:46 PM
thebaldknight is offline thebaldknight
Registered User

Join Date: Aug 2007
Posts: 6

Hi there,

Sorry, I got busy with my kids.

The code works, only it gave the url of phmailer not the actual url page.

You see I placed a link on my pages that say "contact" whenwhe you click contact its taken to the phmailer page... leaving the orinnal page that I wanted to grab the url from. so in the end I get the phpmailer url.

Thanks
Reply With Quote
  #12  
Old 08-18-2007, 06:57 PM
thebaldknight is offline thebaldknight
Registered User

Join Date: Aug 2007
Posts: 6

I am guessing that some code would have to be placed in the html page it's self
Reply With Quote
  #13  
Old 09-08-2007, 06:15 AM
Lakie is offline Lakie

Join Date: Mar 2002
Posts: 5,540

On each page you could define a variable, either with the url or some other identifying characteristic and echo the variable in the message body so it will use the time is was the most recently set..
Reply With Quote
  #14  
Old 09-08-2007, 02:46 PM
SilentTrigger is offline SilentTrigger
-1PARA-

Join Date: Sep 2002
Location: Sweden
Posts: 3,972

Quote:
Originally posted by katana*GFR*
And please dont post the full code.. Just the part you are editing...
And place it between the code tags (code) text (/code) Replace ( and ) with [ and ]



________________


Scott, i cant edit the posts here... Can you update my permits?
You can actually edit them elsewhere?`
__________________
-1PARA-AlexKall

My photography website



Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab a seat in my car and take a trip thorugh Sweden! SilentTrigger General Chat 13 02-19-2011 03:48 PM
URL error Patron Feedback / Novahq.net Support 5 12-29-2008 07:29 PM
Software to grab pics off of home videos DevilDog#1 Hardware and Software 11 09-23-2005 08:54 PM
URL Invalid!!!!! .DareDevil. Feedback / Novahq.net Support 1 06-30-2005 04:21 PM
Ivalid URL? Steele Feedback / Novahq.net Support 6 06-14-2005 07:36 PM


All times are GMT -5. The time now is 12:35 PM.




Powered by vBulletin®