Hi javascriptians,
You will have at some stage come across a piece of Javascript code that has been packed to compress as well as to obfusicate the code. If you want to get the original code from the compressed files you can use the another unpacking javascript code. I am getting this code from http://matthewfl.com/unPacker.html writen by mathew. I got this and used very much, so I wanted to share with my friends.
Thanks to Mathew
unpacker.js
-----------
//////////////////////////////////////////
// Un pack the code from the /packer/ //
// By matthew@matthewfl.com //
// http://matthewfl.com/unPacker.html //
//////////////////////////////////////////
// version 1.2
function unPack (code) {
function indent (code) {
try {
var tabs = 0, old=-1, add='';
for(var i=0;i<code.length;i++) {
if(code[i].indexOf("{") != -1) tabs++;
if(code[i].indexOf("}") != -1) tabs--;
if(old != tabs) {
old = tabs;
add = "";
while (old > 0) {
add += "\t";
old--;
}
old = tabs;
}
code[i] = add + code[i];
}
} finally {
tabs = null;
old = null;
add = null;
}
return code;
}
var env = {
eval: function (c) {
code = c;
},
window: {},
document: {}
};
eval("with(env) {" + code + "}");
code = (code+"").replace(/;/g, ";\n").replace(/{/g, "\n{\n").replace(/}/g, "\n}\n").replace(/\n;\n/g, ";\n").replace(/\n\n/g, "\n");
code = code.split("\n");
code = indent(code);
code = code.join("\n");
return code;
}
Save this file in unpacker.js
Example how to use
include the javascript file in a html page using
<script src="unpacker.js" ></script>
and call the function unPack() to unpack the code like following
<script>
code = "<unpacked file contents>"
var unpackedcontent = unPack(code);
document.write(unpackedcontent); // optional, to show the unpacked content.
</script>
If you have any issues, please feel free to contact me at codesmokers@gmail.com
Php codes snippet added by tom to help our php developers to find some codes easily without spending more time on googling.
Sunday, September 19, 2010
Send attachment mail using php
Hi php folks,
If you would like to send a mail thru php, it is very easy,
You can send mail from online,
but If you want to send an attachment in php mail function, its somewhat difficult.
I have added some sample code to send an attachment in php mail
Create a file attachment.pdf which is going to be attached with the mail
And then use the following code in a php file
mailattachment.php
~~~~~~~~~~~~
<?php
$to = "toaddress@domain.com";
$subject = "Subject for mail attachment";
$random_hash = md5(date('r', time()));
$headers = "From: fromemail@domain.com\r\nReply-To: noreply@domain.com";
$headers .= "\r\nMIME-Version: 1.0";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents("attachment.pdf")));
$output = "--PHP-mixed-$random_hash;
Content-Type: text/plain; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
Hello World!
This is the simple text version of the email message.
--PHP-mixed-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is the <b>HTML</b> version of the email message.</p>
--PHP-mixed-$random_hash
Content-Type: application/pdf; name=attachment.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
echo @mail($to, $subject, $output, $headers);
?>
Change the content type to appropriate file type and make sure the attachment file is in correct location
example: for pdf Content-Type: application/pdf;
for gif : Content-Type: application/gif;
for text: Content-Type: application/plain;
Save the code in a file mailattachment.php and run it from the php server,
and check the inbox to see the attachment.
If you have any queries, please contact me thru mail
codesmokers@gmail.com
If you would like to send a mail thru php, it is very easy,
You can send mail from online,
but If you want to send an attachment in php mail function, its somewhat difficult.
I have added some sample code to send an attachment in php mail
Create a file attachment.pdf which is going to be attached with the mail
And then use the following code in a php file
mailattachment.php
~~~~~~~~~~~~
<?php
$to = "toaddress@domain.com";
$subject = "Subject for mail attachment";
$random_hash = md5(date('r', time()));
$headers = "From: fromemail@domain.com\r\nReply-To: noreply@domain.com";
$headers .= "\r\nMIME-Version: 1.0";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents("attachment.pdf")));
$output = "--PHP-mixed-$random_hash;
Content-Type: text/plain; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
Hello World!
This is the simple text version of the email message.
--PHP-mixed-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is the <b>HTML</b> version of the email message.</p>
--PHP-mixed-$random_hash
Content-Type: application/pdf; name=attachment.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
echo @mail($to, $subject, $output, $headers);
?>
Change the content type to appropriate file type and make sure the attachment file is in correct location
example: for pdf Content-Type: application/pdf;
for gif : Content-Type: application/gif;
for text: Content-Type: application/plain;
Save the code in a file mailattachment.php and run it from the php server,
and check the inbox to see the attachment.
If you have any queries, please contact me thru mail
codesmokers@gmail.com
Subscribe to:
Comments (Atom)