Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Saturday, August 17, 2013

Advertise your products worlwide for free through 99localads.com - Free Ad Posting

99localads is platform for people to advertise their products, business or anything for free. You can display your ads by selecting specific country and city so that people from that city will contact you.
Follow on facebook : Click Here
Its a place for free classifieds.

  • you can easily design ads with pictures and control your selling, buying, or any other activity by your profile.

  • Free and easy ad posting within 5 seconds.

  • Manage your ads easily by profile.

  • Add you favorite ads in one list.

  • Sorting by city and categories.


Read more

Friday, January 11, 2013

high level workflow for secure password reset


When user asks to reset their password, make them enter their email address Don't indicate if that email address was valid or not (just tell them that an email was dispatched).

This is open for debate as it lowers usability (i.e. I have no idea which email I registered with) but it offers less information to people trying to gather information on which emails are actually registered on your site.

Generate a token (maybe hash a timestamp with a salt) and store it into the database in the user's record.

Send an email to the user along with a link to your http*s* reset page (token and email address in the url).

Use the token and email address to validate the user. Let them choose a new password, replacing the old one. Additionally, it's a good idea to expire those tokens after a certain time frame, usually 24 hours.

Optionally, record how many "forgot" attempts have happened, and perhaps implement more complex functionality if people are requesting a ton of emails.

Optionally, record (in a separate table) the IP address of the individual requesting the reset. Increment a count from that IP. If it ever reaches more than, say, 10... Ignore their future requests.

To give you a little more detail into hashing...

When you hash a value like a password using the md5() function in PHP, the final value is going to be the same for that password no matter which server you run it on. (So there's one difference we can see right away between hashing and encryption... There's no private/public key involved).

So this is where you'll see people mention a vulnerability to rainbow tables. A very basic explanation of a rainbow table is... You md5() hash a bunch of dictionary words (weak passwords) in order to get their md5() hashed values. Put those in a database table (rainbow table).

Now, if you compromise a web site's database, you can run the users' hashed passwords against your rainbow table to (in essence) "reverse" the hash back to a password. (You're not really "reversing" the hash... But you get the idea).

That's where "salting" your passwords is best practice. This means (again, very basic idea here) that you append a random value to the users' passwords before you hash it. Now, when the rainbow table is run against your database, it's not as easily "reversed" because the md5() hash of "password" is different than "password384746".
Read more

Tuesday, October 09, 2012

Signup form javascript validation with regular expressions - demo and coding

Demo form with validation
* click submit to check validation

Name : *
Email : *
Subject : *
Contact : *
Message :  
   
Javascript code for signup form <script type="text/javascript"> var ck_name = /^[A-Za-z0-9 ]{1,20}$/; var ck_email= /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ; var ck_subject = /^[A-Za-z0-9!@#,$%^&* -.+()_]{1,150}$/; var ck_phone = /^[0-9]{8,20}$/; function validate(form){ var name = form.name.value; var email = form.email.value; var subject = form.subject.value; var phone = form.phone.value; var errors = []; if (!ck_name.test(name)) { errors[errors.length] = "Enter Valid name"; } if (!ck_email.test(email)) { errors[errors.length] = "Enter valid email-id"; } if (!ck_subject.test(subject)) { errors[errors.length] = "Enter subject"; } if (!ck_phone.test(phone)) { errors[errors.length] = "Enter phone number"; } if (errors.length > 0) { reportErrors(errors); return false; } return true; } function reportErrors(errors){ var msg = "Please Enter Valid Data...\n"; for (var i = 0; i<errors.length; i++) { var numError = i + 1; msg += "\n" + numError + ". " + errors[i]; } alert(msg); } </script> Signup form html code <form method="post" name="form" onSubmit="return validate(this);"> <table width="100%" border="0" cellpadding="5"> <tr> <td width="32%" align="right"> Name :</td> <td width="4%">*</td> <td width="64%"><input class="tb6" type="text" name="name"></td> </tr> <tr> <td align="right">Email :</td> <td>*</td> <td><input class="tb6" type="text" name="email" /></td> </tr> <tr> <td align="right">Subject :</td> <td>*</td> <td><input class="tb6" type="text" name="subject" /></td> </tr> <tr> <td align="right">Contact :</td> <td>*</td> <td><input class="tb6" type="text" name="phone" /></td> </tr> <tr> <td valign="top" align="right">Message :</td> <td>&nbsp;</td> <td><textarea name="message" id="message" class="tb6" cols="30" rows="3"></textarea></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" value="Submit" name="submit" id="submit"></td> </tr> </table> </form>
Read more

Wednesday, September 21, 2011

Multiple Attachment php script--Attach any file type like images, pdf, word document, excel, txt etc



Multiple file attachment in single script.
Just include the files to be sent in array and send it.
the script is working all fine.
you can edit the script and make some changes if only one file is attached.




// Read POST request params into global vars
// FILL IN YOUR EMAIL
$fileatt="";
$fileatt1="";
$fileatt = $_FILES['attachment']['tmp_name'];
$fileatt_type = $_FILES['attachment']['type'];
$fileatt_name = $_FILES['attachment']['name'];

$fileatt1 = $_FILES['attachment2']['tmp_name'];
$fileatt_type1 = $_FILES['attachment2']['type'];
$fileatt_name1 = $_FILES['attachment2']['name'];


$to="rakeshroy02@gmail.com";
$files = array("$fileatt","$fileatt1");
$filenames = array("$fileatt_name","$fileatt_name1");

// email fields: to, from, subject, and so on
$from = "rakeshroy02@gmail.com";
$subject="File attachment";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";

// multipart boundary
$message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
// preparing attachments
for($x=0;$x $file = fopen($files[$x],"rb");
$data = fread($file,filesize($files[$x]));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {$fileatt_type};\n". " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$filenames[$x]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}

$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
$errorMsg="Your email has been sent, we will respond shortly.";
} else {
$errorMsg ="Mail was not sent.Please try again.";
}


Enjoy the script.
Read more

Sunday, September 18, 2011

Script for Image Resizing / Image Rescaling / Image Cropping or creating Image Thumbnail in php



The script is very simple to use.I have researched lot for this and i got one perfect script for resizing/rescaling/cropping images.

This script Image Thumbnail will allow you to create thumbnail of any size image by resizing image or rescaling image or by cropping it.

You have the option of cropping it or to just make a normal thumbnail to cover all pixels of image by changing the value of zc=0 for normal thumbnail or zc=1 for cropping it.

How to use it ?

step 1) Download the script Image Thumbnail

step 2) Put that script in your server directory where other files are located

step 3)change image tag img src="thumb.php?src=products/images/&h=150&w=150&zc=0" alt="Image not available"

step 4) Now in image tag, you can see zc=0, this is for normal image thumbnail covering all pixel of image of any size, you can change it to zc=1, and then check the changes, it will resize for perfect fit.

Explanation : In image tag h is for height and w is for width and z is for cropping for auto fit in given width and height.

A Script from tim-thumb
Read more

Friday, September 09, 2011

Sql Injection-How to hack non secured websites





This post will show you how to hack projects/websites which are not secured and which are not using any encryption / Dycrytion algorithm to save password in database.

In place of login details enter
anything' OR 'x'='x

If website is not secured you will be logged in as admin.

IF website is secured by using MD5 algorithm,
you can try

1234 ' AND 1=0 UNION ALL SELECT 'admin', '81dc9bdb52d04dc20036dbd8313ed055

By using this , you can hack in any new project or website on web without any risk.
You can also try it on your own project to check if it is secured or not.
Read more

Wednesday, August 24, 2011

HACK : Simple encryption-decryption algorithm in php



HACK : Simple encryption-decryption algorithm in php

For those peoples who want to save their passwords encrypted.


//function to encrypt the string
function encode5t($str)
{
for($i=0; $i<5;$i++)
{
$str=strrev(base64_encode($str)); //apply base64 first and then reverse the string
}
return $str;
}

//function to decrypt the string
function decode5t($str)
{
for($i=0; $i<5;$i++)
{
$str=base64_decode(strrev($str)); //apply base64 first and then reverse the string}
}
return $str;
}
Read more

Thursday, August 18, 2011

PHP Mailer Form with File Attachment



Simple to implement in your web page. Allows one file to be attached to the email.For multifile aatchment code go to this link : Multifile Attachment Performs validation of: name, email, subject and message. Also validates certain file types and maximum size. No need for PHP knowledge. The script is well commented. Form is styled using CSS.

This script is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This script is distributed in the hope that it will be useful, but without any warranty. I hope you find it useful.

Form Installation Instructions:

You need to include (or require) the fns.php at the top of your page. Basically copy/paste the top and bottom of the index.php to your page (whatever is within the php tags) and adjust the path/to/fns.php

Copy/paste the code within the #uploadform div to where you want it to be on your page

Change the email address in the fns.php. There are a few other variables you can adjust if you wish around the same place as the email variable
Download

Download Php Mailer Script

Read more

Monday, August 15, 2011

Send image as attachment or an other file with email in php

Send image as attachment or an other file with email in php


This script is very useful if you thinking to send files as attachment to any email
in php.




// array with filenames to be sent as attachment
$files = array("file_1.ext","file_2.ext","file_3.ext",……);

// email fields: to, from, subject, and so on
$to = "mail@mail.com";
$from = "mail@mail.com";
$subject ="My subject";
$message = "My message";
$headers = "From: $from";

// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";

// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "–{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";

// preparing attachments
for($x=0;$x$message .= "–{$mime_boundary}\n";
$file = fopen($files[$x],"rb");
$data = fread($file,filesize($files[$x]));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
}

// send

$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "mail sent to $to!”;
} else {
echo “mail could not be sent!”;
}

?>
Read more