WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP / FTP Web Authentication Scrip! Please visit WWW.FLACCESS.COM
Categories : Apache, Ecommerce, FTP, Linux, Sockets Click here to Update Your Picture
John Jolly
Date : Oct 23rd 2001
Grade : 2 of 5 (graded 2 times)
Viewed : 5908
File : ftplogin.doc
Images : No Images for this code example.
Search : More code by John Jolly
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

First you need to create a file called ftplogin.php. Note in order to run this
script you must
have an ftp server with a valid account.

Paste the following in ftplogin.php
-------------------------------------------------------------------------------------
----
<?
function checkftplogin($server, $user, $pass) {
$sck = fsockopen($server, 21);
if ($sck) {
$data = fgets($sck, 1024);
fputs($sck, "USER $user\n");
$data = fgets($sck, 1024);
fputs($sck, "PASS $pass\n");
$data = fgets($sck, 1024);
if (ereg("230", $data)) {
# User logged in
return 1;
} else {
# Login failed
return 0;
}
fclose($sck);
} else {
return 0;
}
}
function authenticate() {
Header("WWW-Authenticate: Basic realm=\"Secure Login\"");
echo "Authentication Failed!";
exit();
}
if(!isset($PHP_AUTH_USER)) {
authenticate();
exit;
echo "Authorisation Failed\n";
} else {

$tmp = checkftplogin("localhost", "$PHP_AUTH_USER", "$PHP_AUTH_PW");
if ($tmp != "1") {
authenticate();
}
}
?>

-------------------------------------------------------------------------------------
---------

Now you should have a file called ftplogin.php with a few lines of code.
Go to the bottom of the script and look for the line that starts with $tmp. You
should see
localhost. This is where you enter your ftp server address. You shouldn't have to
edit anything
else. Now if you want to password a file such as index.php then just paste the
following code
at the top of the file.

------------------------------
<?include"ftplogin.php";?>
------------------------------

Now you should be able to view your index.php and have it pop up the user name and
password box. Enter your user name and password of the account you own on the ftp
server.
It should display your index.php if authenticated.
Here is a index.php sample.

----------------------------------
<?include"ftplogin.php";?>
<html>
<center>Hello there Welcome</center>
</html>
----------------------------------


This should work with any ftp server as long as you have an account and the
webserver's ip is allowed to the ftp server's ip address.


John L. Jolly III
john@flaccess.com
www.flaccess.com



uaa
Categories : Apache, Apache, Browsers, Calendar
Check if a file exists on a remote FTP server with PHP
Categories : PHP, FTP, Regexps
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
phpAds, a complete banner and ad management system with detailled tracking and stats.
Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
open source online php shop project ecommerce commerce
Categories : PHP, Ecommerce
ECHO-Java Class Credit Card and Check / ACH Transaction Processor
Categories : Java, Cybercash, Classes and Objects, Ecommerce, Java Servlets
Why do i get a "Save As" dialog box when I type in the url of a php3 file
Categories : PHP Configuration, PHP, Apache, Web Servers
Add a linux user from php
Categories : Linux, PHP
accept_connect -- Accepts a connection on a socket
Categories : PHP, PHP Functions, Sockets
an example of the cyberlib payment class
Categories : PHP, PHP Classes, Ecommerce, Credit Cards
PHPCatalog
Categories : Ecommerce, PHP, Complete Programs
Amazon book cover handling
Categories : HTML and PHP, PHP, MySQL, Ecommerce
PostgreSQL and apache web authentication source.
Categories : Authentication, PostgreSQL, Apache, Web Servers
gpg encryption. 99% of it will apply to PGP.
Categories : Credit Cards, Authentication, Ecommerce, Misc