Algorithms Arrays Passwords Uncategorized
Commerce Uncategorized
Databases Abstraction Layers Informix LDAP MS SQL MySQL ODBC PostgreSQL Uncategorized
Date & Time Calculators Conversion Translation Uncategorized
Discussion Chat Forums Guestbooks Polls Uncategorized
Email Validation Uncategorized
External Uncategorized
Files and Directories Uncategorized
Games Uncategorized
Graphics 3-D Graphs Resizing Thumbnails Uncategorized
HTML Forms Menus & Navigation Source Viewers Tables Templates Uncategorized
HTTP Authentication Cookies File Uploading Uncategorized
I18N Uncategorized
Math Uncategorized
Miscellaneous Uncategorized
Searching and Trees Uncategorized
Security Uncategorized
Text Uncategorized
Utilities Calendars Counters Link Checkers Weather Uncategorized
XML Uncategorized
| php sample source codes |
|---|
|
The class can be used for manipulating unix password files, created with htpasswd. It is possible to add, remove and update users.
|
|
Creates cookies to keep track of a logged in user. A lot of md5 + server-side secret keeps normal "crackers" from forging tickets. Good for times when you don't have SSL.
UPDATE:
For added security, place secret.php outside of your web tree so that if PHP breaks they can't easily reach the hash value.
Also, forgot to add the PASSWORD into the hash! Silly me!
TODO:
Make the cookies update as the user continually checks in so that the cookies expire after X seconds of INACTIVITY vs. a flat 36000 seconds.
|
|
This is a function which will format the passed string depending of it's specified to be a number or a string, in order to avoid problems with SQL injections in scripts.
|
|
Avoid URL injection. Easy to improve the security (phising, etc..) of your site if you are calling one .php to centralize all your DB connections.
|
|
This is a piece of code to help reduce security holes at the application level.
|
|
If you need to check if the current user's IP address is either within a set range or matches a given IP use this function. Possible uses include additional security for an authentication script.
IP range needs to be in form 12.34.56.78-12.34.67.89
|
|
If you want to use PHP to display emails without fear of spambots taking them for ill-use,
when you don't have an encryption algorithm, here is a simple and usefull tool to both hide and present emails with sessions and random encoding.
This is how you can easily encode your emails on a webpage.
This works by generating a unique password to attach to each email being encoded per page in a random place.
To see a error, copy and paste a email link into a new window.
|
|
gencoder is a simple php encoder that use base64 algorithm to encode and decode the script, unlike zend encoder, this script won't solve your problem from hiding the source code from advance programmer but at least you're one step closer to making your code tougher for people to steal
|
|
Very simple functions to create a logins table in a mysql db, add hashed/encrypted usernames and passwords, and authenticate.
|
|
Keycom Version2 (production tested)- This is a class to store values in a conacated string. This string can then be passed as a post variable to a child program. As the internals of the variable are not exposed this provides the most security. A companion script securepage.php checks for the existance of this post variable. The combination of the class and script allows for completely secure (cookie-less) www programing with spider friendly clean urs's.
|
|
// ********* License COMPLETELY FREE NO GUARENTEE ********************
// keycom_class - where security is essential. Cookieless passing of post variables.
// This class will enable the user to pass all necessary variables in a
// secure fasion to the child php page.
// it accomplishes this by creating objects that search and or replace the
// variables one desires to pass in a conacated string
// This is shot # 2 on creating classes so beware
// Thanks for your interest. Ian A. Stewart
|
|
All you need is this include file and a control statement on any page you wish to authenticate users from.
|
|
If you are making a admin tool for your site you can add all the users into a table called e.g. "users" and automaticaly generate a .htpasswd file from it. This function uses MD5 encryption.
|
|
Simple code for a secure login and low over head to boot. And dammit it just plan works lol.
|
|
A Membership section for your website. It still needs the signup section. If you have any problems... shane@mics.co.za
|
|
Authentication and page permission using session variable.
|
|
Uses the .htpasswd to authenticate access to your PHP script
|
|
****************************************************************************
*** PHP Protect Plus ***
*** v 1.0 ***
*** www.phpclub.site.ir ***
****************************************************************************
To protect your html pages, first copy this file to the page's directory then rename html page to .php and add the line bellow to the first line of your html page:
[ Replace "protect.php" with the name of this file ]
Also for php files, just add the above line to the first line of code.
The first time, use "admin" for username and "phpclub" for password.
"admin" user is just for managing users. It can not be used for browsing protected pages.
If you want to make a logout link, link to : "protect.php?logout=1" or any protected .php file with "?logout=1" .
|
|
I used a html form that has a password field named password and a submit button named submit. When the submit button is clicked the page reloads with the $password variable sent back to the server. Then when php resends the html to the client it includes the appropriate javascript to redirect them to the correct protected page.
|
|
This class uses integer bitmasks to represent permissions.
This allows for easy and acurate storage of complex permissions.
To aid in ease of use the class will convert bitmasks to an associative array of boolean permissions and then convert the array back to a bitmask for easy storage.
|
|
with php function acl (facl) you can restrict function-, variable- and include/required-file-access
|
|
Filter out unwanted PHP / Javascript / HTML tags.
This class can filter input of stray or malicious PHP, Javascript or HTML tags and to prevent cross-site scripting (XSS) attacks. It should be used to filter input supplied by the user, such as an HTML code entered in form fields.
I have tried to make this class as easy as possible to use. You have control over the filter process unlike other alternatives, and can input a string or an entire array to be cleaned (such as $_POST).
|
|
Simple and relativity safe login scripts for web sites with secret contains and multiple users. All traffic is loged to MySQL database for possible latter analysis... This scrips work correctly only with PHP 4.2 and higher...
|
|
This is a bit of code that includes several tools that can be used to implement a PKI at the application level of your PHP-Javascript applications.
|
|
Ce script permet de detecter la presence
d'intrus dans le systeme grace au controle
de l'integret des fichiers.
|
|
Phrozen, The idea, you want to encode your scripts, however you don't want to have to make the end user install something to "un-encode" your script. Well, here is a poor-mans solution to that. This does real-time encoding-decoding of the files and the file is only left on disk for exactly enough time for it to be read and parsed.
This is one solution, feel free to email me if you use this in a project, I would like to see how others have used it.
|
|
Simple and raw php port scanner
|
|
A very simple yet usefull portscanner.
|
|
This simple security check ensures that a php script does not receive any unexpected rogue GET or POST vars. Just call this simple function at the top of each script to help protect it from malicious attacks.
|
|
This is describe how we can protect php include file unser directory that not protected, this is simply done using php function
|
|
If you are sure that GET/POST/COOKIE values are not modified by user, you may be able to reduce lots of overhead for checking values. This function provide means to make sure GET/POST/COOKIE values that are set by PHP programmer are not modified by users.
|
|
Simple function to remove slashes from an entire array.
|
|
CAPTCHA an acronym for completely automated public Turing test to tell computers and humans apart ". CAPTCHA technology enables you to discern human requests from computer generated requests on the Web, where such a distinction is difficult. Simply defined "Man can read machine can t!
In web available forms are always prone to attack by people who want to use your application for their own purposes. Many web sites use the CAPTCHA especially used to prevent bots from using various types of computing services.
The applications include preventing bots from taking part in online polls, registering for free email accounts, more recently, preventing bot-generated spam by requiring that the (unrecognized) sender pass a CAPTCHA test before the email message is delivered [implemented in Yahoo]. They have also been used to prevent people from using bots to assist with massive downloading of content from multimedia websites.
You have probably seen the CAPTCHA project in action at some of your Web destinations. Its principal tool is a randomly created image that contains a phrase unmentioned in computer-readable text on the rendered page. The form asks the user to provide the phrase. If the form post does not contain the correct phrase, you can safely assume either the human made a user error, or it wasn't a human at all.
Now it's time to put this code to work. A simple and often-used interface to implement this new security measure is the form on website. In this form you typically capture random number.
<code>
Please enter the string shown in the image in the form.<br>
</code>
The following code use to create random numbers and this number are embedding with existing image file, the first line used to initiate session, which use to carry the user inputs.
<code>
</code>
The second line [md5 (microtime ())] use to generate the random string, and the resultant string is trim by using third line [substr], which returns the portion of string specified by the start and length parameters.
The function imagecreatefromjpeg ("img.jpg") is use to create a image by existing image file and as back ground ,so that you need to give an image file path.
<code>
</code>
After creation of back ground image, we generate some linear line, which is use to avoid the phrasing from random numbers, the respective lines are create by the function named imageline () and imagestring () use to draw a random string horizontally.
<code>
</code>
The resultant random number [trimmed one], carry through session especially for validation purpose.
<code>
</code>
Finally above two functions are uses to display/out put the image to browser. So we can just call the particular file by through image source path, it will display the final image.
<code>
</code>
I hope you know about the above code functionality, it s about validating the user in put and actual random number, depends upon the application you may use the if and else conditions, that s all
Conclusion
CAPTCHA can be a great way to limit the amount of successful, unwanted HTTP POST requests in your application, CAPTCHAs are by definition fully automated, requiring little human maintenance or intervention in administering the test. This has obvious benefits in cost and reliability; I hope the simple code is useful to understand the concept. Happy CAPTCHA-ing!
|
|
A PHP implementation of the Secure Hash Algorithm, SHA-1, based on the JavaScript implementation by Paul Johnston.
This is basically a "translation from JavaScript to PHP, so most of the credits should go to Paul Johnston. I only re-wrote it in PHP.
See http://pajhome.org.uk/site/legal.html for details.
|
|
Simple Auth Code For PHP4
|
|
This simple log in script will password protect one or more of your pages. You can allow different users to go to different sites.
|
|
Submit to this page from a form with a hidden field. Checks that field and your ip address. Good if its static.
|
|
If you want to use this code, please link back to www.officedevils.com - you don't have to, just a comment on your blog will do!
<br><br>
These two code fragments are pretty simple. It randomly generates two numbers, and adds them as hidden variables on your site's submission or sign-up form. The user then has to do the simple sum before the submission is accepted.
<br><BR>
Yes, you could write a grep to find the numbers and add them, and submit that, but I am sure that won't happen until a LOT of people start using this, and then you can simply move the variables, or add to it, so that the numbers are turned into words, or change the variable names, or change the sign.<br><br>
You might also want to make the maths that little bit harder than adding a ten to a digit, to improve the quality of members you get!! ;-)
<br><br>
The big advantage is that this doesn't limit access to those without sight or graphics, such as disabled or WAP users, allowing you to still comply with the regs. on usage.
|
|
TransCrypt is an encrytion library. It simply uses look up tables to translate bytes. The look up tables are generated by the LFSR algorithm.
|
|
UA Blocker allows you to selectively deny specific user-agents from visiting your site. This helps to eliminate email harvesting, and various other bandwidth-sucking visitors. Some examples are included.
|
|
A complete modual for you to wrap around anything that you want secure. Wiggem uses php's new session functions and is much more secure then the average cookie login script. Md5 encryption is also used.
|
|
A very simple fuction to detect files encoded with Zend encoder.
|