Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
domain names
dropshippers
dvd information
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Current directory browser


Current directory browser

This example shows how you can list all of the files in a directory , one note of warning is that this displays ALL of the files in the directory , even files which you do not wish a user to see .

 

Code :

<?php
//open the current directory
$directory = opendir('.');
while ($file = readdir($directory))
{
$filenames[] = $file;
}
foreach ($filenames as $file)
{
echo "$file<br>";
}
?>

.
..
2002.gif
onion.php
digclock.php
27th.gif
ping1.php
cnnsports1.php
phplogo.php
mysql3.gif
misc.php
test123
phpsoftware.php
ffalinks.txt
web.log
ajax.php
images
10th.gif
Quick-Intro-to-PHP-Development.php
appwatch.php
metagen.php
sendmail1.php
dirviewer1.php
randomnumbers.php
moreoverfeed1.php
2nd.gif
randomxml.php
21st.gif
specialchar.php
cosource.php
tutad.php
phptutforeach.php
yahoochart.php
thankyou.php
createnews3.php
7th.gif
tetsinggb2.php
gdemailaddress.php
createnews1.php
countimages.php
more.zip
newads.php
1861002963.01.TZZZZZZZ.jpg
12th.gif
bbcnews.php
displayaccess.php
flaquotes.swf
palmpower1.php
test.csv
tutorials.php
markets.php
lastaccessed.php
ip2long.php
dbquote1.gif
metasearcher1.php
template.php
adsense
qotd.php
example5.php
file.txt
javabout.php
myfile.txt
ASP-CGI-and-PHP-Scripts-and-Record-Locking-What-Every-Webmaster-Needs-To-Know.php
createnews3.gif
clickbank.txt
manuals
PHP-Auto-surf-Websites.php
076454716X.01.TZZZZZZZ.jpg
digitalclock.php
cjrotator1.php
moreover.php
parsefreshmeat.php
8th.gif
ourimages.php
dayimage.php
displaystats.php
addingtoadb1.php
0764535374.01.TZZZZZZZ.jpg
simplestats.php
code.php
newfont.php
linweeknews.php
testingjokes2.php
oriellynews.php
findurls.php
statspay.php
metagen.zip
netgeo.php
tetsinggb1.php
tutorialreadfile.php
newtemplate.php
sitereview1.php
mar.gif
mysql.php
PHP-Redirect.php
odp.php
rnddownload.php
samplecode.txt
azlinks.php
addtodb.php
createnews2.php
downpage.php
createatable.php
software.txt
browserver.php
bannedwords.php
PHP-Email.php
improvedmore.php
product
weekimage.php
weathercom1.php
120600file.php
topads.php
cj_88x31_02.gif
allcode.php
showlinks.php
createword.php
More-Autoresponders-With-PHP.php
odp.pl
codecats.php
Maguma-has-integrated-support-for-the-eBay-Acellerator-Toolkit-for-PHP-PHP-AT-in-their-PHP-IDE-Maguma-Workbench.php
25th.gif
deletingfromadb.php
clickbankinc.txt
randstring.php
gallery.php
gdemail.php
ipvisitors.php
sitemap.xml
oddoreven.php
1861003730.01.TZZZZZZZ.jpg
createagb3.php
blog
gdfontcount.php
Password-Protection-with-PHP-MySQL-and-Session-Variables.php
portscan.php
viewzip.php
tutorialopenfile.php
news1.gif
weatherani.php
mozillanews.php
samplecontent.php
apr.gif
bebmysql1.php
timegreet.php
countrycode.php
testingnews1.php
webpage.pl
rndcode.php
11th.gif
simplequiz.php
lincentop.php
500.shtml
testcode.php
image-701800-1489263.gif
phptutswitch.php
phpe.php
moreover1.php
counter2.dat
aspbanner1.gif
oswars.php
aspbanner5.gif
rssfiles.php
highlighted.php
mysql4.gif
bookstore.php
phparticle1.php
counter1.dat
1.gif
searchengine1.php
dieimages.zip
morev.txt
mysqlhandler.php
testing.php
config
example2.php
appcounter.php
searchmeta.php
ourlinks.php
deletingfromadb1.php
showarticles.php
15th.gif
Autoresponders-With-PHP.php
PHP-Dynamic-Content.php
createagb2.php
wordcount.php
404.shtml
multistock.txt
pear_manual_en.zip
robots.txt
6.gif
ffaaddlink.php
multiticker.php
month.csv
rnddownload1.php
processorinfo.php
lottery.php
oursites.php
serverinfo.php
mysqljoin.php
ipaddress1.php
error_log
cj.txt
0672317842.01.TZZZZZZZ.jpg
quizeasy.htm
footer.php
exchangerate.php
testingnews.php
news.php
gdtype.php
4th.gif
rnddownload3.php
ads
amazonukcontextual.php
technobits.php
begmysql1.php
aug.gif
image1.php
CyberCrawl_0.1alpha-preview.zip
quotes2.php
phpcurl.php
logipsmysql.php
Password-Protection-and-File-Inclusion-With-PHP.php
076152729X.01.TZZZZZZZ.jpg
fileatts.php
PHP-Form-Series-Part-1-Validators-Client-side-Validation.php
vtcphp1.php
yahooquotes.php
PHP-Pear-Packages-Why-they-are-so-important-to-php-developers.php
php-small-white.gif
books.php
gdsizeimage.php
PHP-is-10-years-old.php
uksearch.zip
randtitle.php
network.php
example4.php
admin
Victoryvisions-The-PHP-Mysql-Company-Complete-website-development-company.php
wdvl1.php
qotd1.php
moreover3.php
sponsors2.php
weathercom.php
mp3searcher.htm
2004.gif
img
0735709971.gif
feb.gif
PHP-Scripts-Dont-Have-to-End-in-PHP.php
validlink1.txt
4.gif
browserdet.php
checkdollars.php
sample1.png
linuxcentral.php
counter1.php
Creating-Dynamic-Website-Content-with-PHP-MySQL.php
software1.txt
createnews.php
ONLINE-the-eBay-Accelerator-Toolkit-for-PHP-PHP-AT-for-the-PHP-IDE-Maguma-Workbench-is-available.php
javabnews.php
randomletter.php
0735709971.01.TZZZZZZZ.jpg
javascript.php
0672319144.01.TZZZZZZZ.jpg
javable.php
ihsample.php
myscripting.xml
createagb.php
mathoptut.php
phpresizer1.php
faq
chitikalinx0.2.zip
resizefunction.php
sampledb.dsn
0130893986.01.TZZZZZZZ.jpg
mysqlselect.php
cjrotator.php
uksearchframes.zip
mymp3.php
ranomdbimage.php.txt
dbcounter.php
adsabove.php
storeimagedb3.php
moreover.txt
PHP-On-The-Fly.php
testingnews2.php
pearrss.php
morev2.php
scripts
template
20011211.jpeg
googleres.php
displayadb.php
oct.gif
Mastering-Regular-Expressions-in-PHP.php
logstats1.gif
os.gif
dictionary1.php
20th.gif
phpweekdaycolor.php
news1.php
usingincludes.php
076153055X.01.TZZZZZZZ.jpg
testingourdb.php
directory.gif
buy.php
abcfeeds.php
addtoadb.gif
codebar.php
validlink1.php
formsample.php
3rd.gif
imageresizing.php
upgrade.txt
31st.gif
phptutcomments.php
tickerfind1.php
076152729x.gif
Serialize-this-Saving-Objects-in-PHP.php
chitikalinx.php
words.php
mysqlfetcharray.php
currency.php
dbimages2.gif
sampledb.mdb
wordcount1.php
ihmusic2.gif
testingjokes.php
Simple-Solution-for-Php-Includes-IFrames.php
addtodb.htm
Make-a-Search-Engine-For-Your-Website-With-PHP.php
atomictime.php
9th.gif
phpcreatemysql.php
dbquote2.gif
parse_freshmeat.php
phhpocket.gif
dbquote3.gif
ihcomputing2.gif
cgi-bin
httpuseragent.htm
ipaddress.php
readme.txt
rssfeeds.php
.htaccess
aspbanner3.gif
strlen.php
linux1.php
taskbar.zip
PHP-Account-Activation.php
newsforge.php
phpe1.php
randimages.php
testingnews1.pjhp
fornext.php
mysqldelete.php
topbar.php
wordpress.php
tla.php
hosting.php
PHP-Sessions-Cookies.php
javable1.php
phparticles.php
quotes.zip
0672318040.01.TZZZZZZZ.jpg
includes
testingjokes1.php
mysql2.gif
ihmusic1.gif
26th.gif
metagen.txt
30th.gif
adoconn.php
news.gif
simple-cms-system.php
createnews2.gif
postFilter.zip
How-to-make-a-simple-form-mailer-with-PHP.php
createagb.gif
rss2.php
gdexist.php
logstats1.php
1893115852.01.TZZZZZZZ.jpg
palmstation.php
randomemails.php
mp3searcher2.php
gcounter.php
index.php
mp3search.htm
strreplace.php
ih3.php
phpcounter1.txt
Apache-MySQL-PHP-for-Windows.php
currentdir.php
PHP-General-Scripting.php
sponsors1.php
HTACCESS-Wrappers-with-PHP.php
23rd.gif
createnews1.gif
checknochars.php
vtcmysql.php
grcount.php
phpgtk1.php
chitikalinx.zip
gdbutton.php
mysqlreplace.php
randpassword.php
javascript1.php
28th.gif
2005.gif
19th.gif
example3.php
20011210.jpeg
redirection.htm
mycount.txt
testrss.php
phparticle5.php
jan.gif
PHP-Encryption.php
16th.gif
postfilter.php
3.gif
wired1.php
randompass.php
showdownloads.php
stockchart.php
may.gif
stopips.txt
font.jpeg
grcalendar.php
filesize.php
randomfeeds.php
dbbanners1.gif
variabletut1.php
php-password-function.php
validmail.php
stockchart.txt
ffalinks.zip
mysqlinsert.php
degtorad.php
Bring-Your-Web-Site-to-Life-With-PHP.php
2003.gif
graphicyear.php
changecase.php
php-small-trans-light.gif
rndarticle.php
dnsfunctions.php
lotto.php
countdowndates.php
PIM-Team-Case-Study-Creating-Text-Effects-With-PHP-and-GD.php
dbbanners3.gif
PHP-Databases.php
adsbelow.php
paypal.test.php
myscripting.rss
For-Automated-Sites-PHP-and-MySQL-are-A-Perfect-Match.php
facebook
banned.txt
Developing-a-Login-System-with-PHP-and-MySQL.php
uspop.php
espnsoccer.php
antileech.php
mysqlinsertdelayed.php
logip.php
addtoadb1.gif
createagb1.php
weatherde.php
PHP-in-the-Command-Line.php
daycolors.php
gdexists.php
0672317842.gif
quotes.csv
formatsize.php
atozlinks.php
showcode.php
PHP-and-Cookies-a-Good-Mix.php
perl.php
browserver.htm
randamaztext.php
mp3searcher.zip
How-PHP-Can-Help-Save-You-Time-And-Mistakes.php
Jun.gif
linuktodaynews.php
shellcity.php
14th.gif
coloredcode.php
test.php
phparticle7.php
lincennew.php
logstats2.php
images.sql
monthimages.zip
0672319241.01.TZZZZZZZ.jpg
tutorialcreatfile.php
javabout1.php
integratednews1.txt
randimage1.php
phparticle6.php
forum
whois.php
randombanner.php
phod.php
vtcphp.php
PHP-Image-Gallery.php
example1.php
phpclock1.php
userinfo.php
Site-Personalization-With-PHP.php
userinfo1.php
loancalc.htm
gdcalendar.txt
1565927699.01.TZZZZZZZ.jpg
clock1.php
perl1.php
linux3.php
amazoncontextual.php
linkbanner2.gif
links.sql
gcounter2.php
trim.php
cjrotator.htm
createpaycounter.php
samplemails.txt
bubblesort.php
0672319144.gif
counter3.dat
timesnews.php
clickbank1.php
craps.php
split.php
date.php
netping.php
paycounter.php
metagen.htm
dbbanners2.gif
dbquote.php
AGS001.GIF
AGS002.GIF
phpmodified.php
dbimages.php
upload
quotes.htm
PHP-Server-to-Client-with-No-Refresh.php
extractzip.php
ihcomputing1.gif
dat
parseslashdot.php
paycounter.txt
ipaddress.txt
multicount.php
httpuseragent.txt
nov.gif
buildacounter1.php
paypal.ipn.php
wiicheat.php
rndcode1.php
2.gif
graphicyear.pjhp
46860file.php
13th.gif
bbcscience.php
newstyle.css
22nd.gif
cnn.php
tetsingjokes1.php
showip.zip
showhosting.php
style.css
dispno.php
0764535617.01.TZZZZZZZ.jpg
17th.gif
displayingadb.php
hamweather.php
vtcphp2.php
wired.php
imageresizer.php
loancalc.php
6th.gif
stats.gif
mysql1.gif
PHP-User-Login-Authentication.php
cookiecount.php
simplequiz.htm
weeklink.php
logstats2.gif
mysqlcount.php
reversesort.php
Scounterfile
count.txt
mysqlinsertselect.php
randomurl.php
css
createzip.php
sampledb.zip
visitors.txt
mysqlloaddata.php
logstats3.php
addlink.php
webref1.php
downloads.php
quoteofthe.php
amazon.php
variabletut2.php
0789724405.gif
logbrowsers.php
yahoocurrency.php
linux2.php
javabout2.txt
tickerfind.php
phppear.php
counter1.txt
logstats3.gif
wdvl.php
jokes2go1.php
2001.gif
sampledb.ldb
rad2degrees.php
calendarimages.zip
PHP-Error-Pages.php
convpounds.php
phpextensions.php
logo.php
29th.gif
manuals.php
1st.gif
400.shtml
mysql5.gif
dbbanners.php
createnews.gif
graphicmonth.php
newsforge1.php
showarticle.php
Create-a-Simple-Effective-PHP-Form-for-Your-Web-Site.php
gpl.txt
docjs.php
sky01_120x600.gif
sep.gif
integratenews.php
Developing-State-enabled-Applications-With-PHP.php
example6.php
phparticle3.php
TEXT.CSS
createword1.php
randomemailaddress.php
Track-Your-Visitors-Using-PHP.php
mysql6.gif
displayaccess1.php
phpbyexamples.php
logipmysql.php
multitick.php
metatag.php
dbcountergr.php
PHP-my-favorite-Server-side-Programming-Technology.php
moreoverfeed.php
websites.txt
sitereview.php
tutorialcreatefile.php
mxrecords.php
yahoocsv1.php
flaquotes.fla
Getting-your-Visitors-Details-Using-PHP.php
.DS_Store
monthpic.php
phptutorials.php
createnews4.php
button1.swf
codeigniter
phptutifstatement.php
AGS003.GIF
common.inc.php
cartoongasp.php
randomamaztext.php
GOOGLE2bab86146e593aae.html
local_195489.xml
storeimagedb.php
openads.php
5th.gif
Clickbank-Security-Using-PHP.php
botbar.php
ih2.php
yahoocsv.php
linenumbers.php
showtables.php
example.php
5.gif
newrss.php
dlir.gif
randamazimg.php
sponsors.php
Some-PHP-functions-you-must-know.php
rdfread.php
vikings.php
wpipwidget.php
jokesadmin.php
js
quotes.php
buildacounter.php
logo.png
envvars.pl
aspbanner2.gif
phpodp.php
testinggb.php
googlesearch.php
rss.php
dec.gif
browserwars.php
marketcsv.php
18th.gif
morev1.php
phptutarrays.php
mysqldo.php
icqstatus.php
24th.gif
getage.php
Get-PHP-pages-indexed-in-the-Search-engines.php
moreover2.php
jul.gif
tellfriend.php
metasearch.php
ihcomputing3.gif
1565924347.01.TZZZZZZZ.jpg
lintodnews.php
palmstation1.php
dayimages.zip
403.shtml
allthefeeds.php.txt
randomdice.php
createadb.php
links.php
useragent.php
addingtoadb.php
emailme.php
cakephp
count1.php
begmysql2.php
testingjokes3.php
storeimagedb2.php
fibonacci.php
phpodp.gif
jokes2go.php
multistock.php
script
aspbanner4.gif
training.php
dirviewer.php
AGS004.GIF
1893115569.01.TZZZZZZZ.jpg
amazoninline.zip
gdbarchart.php
year.php
paystats.php
cj.csv
PHP-Templates.php
worldpop.php
PHP-Files.php
dbimages1.gif
0735709211.01.TZZZZZZZ.jpg
shellcity1.php
AGS005.GIF
gdcounter.php
freediskspace.php
amazonuk.zip
calendargd.php
dictionary.php
lib
stockindex.txt
clickbank.zip
mycounter.php
pagehits.txt
templatephp.php
validemail.php
filepattern.php
phptutforloop.php
tutorialwritefile.php
Apache-MySQL-and-PHP-for-Windows.php
yahooweather.php
mp3searcher1.php
ipcount.php
MySQL-Database-Handling-in-PHP.php
info.php
phpinfo.php
1861002963.gif
phparticle4.php
emailverify.php
navbar.php
bookmark.php
Protecting-your-HTML-and-PHP-Source-Code.php
palmpower.php
gdtext.php
phppocketref.htm



Books
 Sponsors
 Random Code
gethostbynamel function(functions)
getprotobynumber function(functions)
check a file exists(file system)
 Random Article

So, you have a submission form on your website and need to prevent spam by auto-submitters. The most common way to do this is to implement CAPTCHA - an image with randomly generated string (quote from Wikipedia, free online enciclopedia: “A CAPTCHA is a type of challenge-response test used in computing to determine whether the user is human. "CAPTCHA" is an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart", trademarked by Carnegie Mellon University.”)

Simple, quick and efficient PHP solution for implement CAPTCHA:

the advantage of this solution: it is easy to read symbols by human and automated captcha processor software, but hard to process the image by computer because common CAPTCHA processors can't understand which one of the outputted symbols it must ignore!

obviously you need PHP engine enabled for your webserver, for execute PHP scripts, and GD (PHP graphics library) for generate the image. Webserver, PHP and GD versions are no matter, the solution below is tested for Apache(Windows and Unix), IIS(Windows), PHP-4, PHP-5, GD, GD2

1) Make a PHP script (separate file captcha.php) which will generate the CAPTCHA image:
[?php
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function _generateRandom($length=6){
$_rand_src = array(
array(48,57) //digits
, array(97,122) //lowercase chars
// , array(65,90) //uppercase chars
);
srand ((double) microtime() * 1000000);
$random_string = "";
for($i=0;$i<$length;$i++){
$i1=rand(0,sizeof($_rand_src)-1);
$random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
}
return $random_string;
}
$im = @imagecreatefromjpeg("captcha.jpg");
$rand = _generateRandom(3);
$_SESSION['captcha'] = $rand;
ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));
$rand = _generateRandom(3);
ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0));
Header ('Content-type: image/jpeg');
imagejpeg($im,NULL,100);
ImageDestroy($im);
?]

2) Add the following line at the top of the page where you need to implement the CAPTCHA (there should not be any output before this line, except you use php functions ob_start() and ob_end_flush() to turn on output buffering):
[?php session_start(); ?]

3) Add the following line for check is CAPTCHA entered by visitor valid, before the line where you will proceed submitted message:
[?php if($_SESSION["captcha"]==$_POST["captcha"])
{
//CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
echo 'CAPTHCA is valid; proceed the message';
}
else {

echo 'CAPTHCA is not valid; ignore submission'; }?]

4) Finaly add the CAPTCHA to the form:
[img src="captcha.php" alt="captcha image"][input type="text" name="captcha" size="3" maxlength="3"]

P.S.
notice:
- the tags "[?" and "?]" in code samples above should be replaced to the "", you may download original article and code sample here: free download php captcha demo

- requirements: a webserver (windows or linux no matter) with PHP engine, with GD (graphic library) support, you may check your php settings with phpinfo() function

- you need some blank jpg image for use it as background for CAPTCHA string

By Andrew Ivanov
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.