HD1988 Labs

Friday, October 19, 2007

The delphi help notes extend up to page 67:

Delphi Notes

Labels:

Saturday, October 6, 2007

Delphi Help Notes

Thousands of free delphi help notes can be found here. Only for educational purposes.

Labels:

Monday, July 30, 2007

Get the last referer in PHP

The next tip allows you to simply get the url of the page that refered the user to your php script. If your script is called from within a frame, then you can extract the url of the page hosting the frame. This is why email service providers don't allow frames and sometimes images within email messages, because it's a security threat.


$Url = $_SERVER['HTTP_REFERER'];

echo 'The refering Url is: ' . $Url;

Labels:

How to extract all email addresses from a webpage in PHP

Extracting an email address from a web page or text file can always come in handy sometimes esspecially when trying to launch an email campaign. The script below will extract all emails from a specified webpage:


$log = 'http://www.yourdomain.com';
$log = str_replace(">","", $log);
$log = str_replace("<","", $log);

$site = file_get_contents("$log", "r");
$string = $site;

$string = str_replace(":", " ", $string);
$string = str_replace('"', ' ', $string);
$string = str_replace('>', ' ', $string);
$string = str_replace('<', ' ', $string);
$string = str_replace('/', ' ', $string);
$string = str_replace('(', ' ', $string);
$string = str_replace(')', ' ', $string);
$string = str_replace('{', ' ', $string);
$string = str_replace('}', ' ', $string);
$string = str_replace("'", " ", $string);
$string = str_replace('%', ' ', $string);
$string = str_replace('?', ' ', $string);

if(empty($log)){
echo "type a site to get emails";
}
else
{

$emails = ereg_replace("[[:alnum:]]+@[[:alnum:]]+[.]+[[:alnum:]]+[[:space:]]", "|| \\0 ||", $string);

$earray = explode("||" , $emails);

for ($x=3;$x<260;$x+=2)
{
echo $earray[$x] . '
';
$all .= $earray[$x] . "\n";
}

$filename = "log.txt"; // txt file to log to
$fp = fopen($filename,'a');
fwrite($fp,$all);

fclose($fp);
}

Labels:

How to extract all email addresses from a webpage in PHP

Extracting an email address from a web page or text file can always come in handy sometimes esspecially when trying to launch an email campaign. The script below will extract all emails from a specified webpage:


$log = 'http://www.yourdomain.com';
$log = str_replace(">","", $log);
$log = str_replace("<","", $log);

$site = file_get_contents("$log", "r");
$string = $site;

$string = str_replace(":", " ", $string);
$string = str_replace('"', ' ', $string);
$string = str_replace('>', ' ', $string);
$string = str_replace('<', ' ', $string);
$string = str_replace('/', ' ', $string);
$string = str_replace('(', ' ', $string);
$string = str_replace(')', ' ', $string);
$string = str_replace('{', ' ', $string);
$string = str_replace('}', ' ', $string);
$string = str_replace("'", " ", $string);
$string = str_replace('%', ' ', $string);
$string = str_replace('?', ' ', $string);

if(empty($log)){
echo "type a site to get emails";
}
else
{

$emails = ereg_replace("[[:alnum:]]+@[[:alnum:]]+[.]+[[:alnum:]]+[[:space:]]", "|| \\0 ||", $string);

$earray = explode("||" , $emails);

for ($x=3;$x<260;$x+=2)
{
echo $earray[$x] . '
';
$all .= $earray[$x] . "\n";
}

$filename = "log.txt"; // txt file to log to
$fp = fopen($filename,'a');
fwrite($fp,$all);

fclose($fp);
}

Changing PHP's default SMTP Mail Settings

By default php or your host company has already set the mail settings in the INI file. But you can change these settings by using the ini_set() function:

ini_set("SMTP","mail.yourdomain.com");
ini_set("SMTP_port","25");
ini_set("sendmail_from","info@yourdomain.com");

Labels:

Using arrays from HTML forms to PHP Scripts

Below we will take data from an html form as an array and then we'll pass it on to a php script then save it and retrieve it from a MySql database:


Red
Blue
Green
Yellow


There must be square bracket after 'colors', this alerts PHP that you're passing an array. Next we'll extract the array and then add it to the database:

$colors=serialize($_POST['colors']); //takes the data from a post operation...
$query=INSERT INTO colors VALUES('$colors');

To retrieve the array data from the database, then, you might do this:

$query=SELECT * FROM shirtColors;
$doQuery=mysql_query($query);
$numrows=mysql_num_rows($doQuery);
if($numrows>0)
{
while($colors=mysql_fetch_array($doQuery))
{
$colors=unserialize($colors['colors']);

foreach($colors as $shirt)
{
print $shirt.', ';
}
}
}
else
{
print 'No colors in database.';
}

Labels: ,