Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Wicked Cool PHP
WICKED COOL PHP.
INTRODUCTION
1. THE FAQS OF LIFEāTHE SCRIPTS EVERY PHP PROGRAMMER WANTS (OR NEEDS) TO KNOW
#1: Including Another File as a Part of Your Script
What Can Go Wrong?
#2: Highlighting Alternate Row Colors in a Table
Hacking the Script
#3: Creating Previous/Next Links
Using the Script
#4: Printing the Contents of an Array
#5: Turning an Array into a Nonarray Variable That Can Be Restored Later
What Can Go Wrong?
#6: Sorting Multidimensional Arrays
Hacking the Script
#7: Templating Your Site with Smarty
Installing Smarty
A Brief Smarty Tutorial
What Can Go Wrong?
Hacking the Script
2. CONFIGURING PHP
Configuration Settings and the php.ini File
Locating Your php.ini File
#8: Revealing All of PHP's Settings
#9: Reading an Individual Setting
#10: Error Reporting
Common Error Messages
#11: Suppressing All Error Messages
#12: Extending the Run Time of a Script
What Can Go Wrong?
#13: Preventing Users from Uploading Large Files
#14: Turning Off Registered Global Variables
#15: Enabling Magic Quotes
What Can Go Wrong?
#16: Restricting the Files that PHP Can Access
What Can Go Wrong?
#17: Shutting Down Specific Functions
#18: Adding Extensions to PHP
Adding PHP Extensions
Checking to See If Extensions Are Already Loaded
Asking Your Hosting Company to Load Extensions
Installing Extensions with a Web-Based Control Panel
Installing an Extension Manually
Installing Libraries
What Can Go Wrong?
3. PHP SECURITY
Recommended Security Configuration Options
#19: SQL Injection Attacks
#20: Preventing Basic XSS Attacks
#21: Using SafeHTML
What Can Go Wrong?
#22: Protecting Data with a One-Way Hash
Hacking the Script
#23: Encrypting Data with Mcrypt
Hacking the Script
#24: Generating Random Passwords
Using the Script
4. WORKING WITH FORMS
Security Measures: Forms Are Not Trustworthy
Verification Strategies
Using $_POST, $_GET, $_REQUEST, and $_FILES to Access Form Data
#25: Fetching Form Variables Consistently and Safely
#26: Trimming Excess Whitespace
#27: Importing Form Variables into an Array
#28: Making Sure a Response Is One of a Set of Given Values
Hacking the Script
#29: Using Multiple Submit Buttons
#30: Validating a Credit Card
Using the Script
Hacking the Script
#31: Double-Checking a Credit Card's Expiration Date
Using the Script
#32: Checking Valid Email Addresses
#33: Checking American Phone Numbers
5. WORKING WITH TEXT AND HTML
#34: Extracting Part of a String
Hacking the Script
#35: Making a String Uppercase, Lowercase, or Capitalized
What Can Go Wrong?
#36: Finding Substrings
What Can Go Wrong?
#37: Replacing Substrings
What Can Go Wrong?
#38: Finding and Fixing Misspelled Words with pspell
Working with the Default Dictionary
Adding a Custom Dictionary to pspell
What Can Go Wrong?
#39: Regular Expressions
Regular Expression Basics
Special Character Sequences
Pattern Repeaters
Grouping
Character Classes
Putting It All Together
Matching and Extracting with Regular Expressions
Extracting All Matches
Replacing Substrings with Regular Expressions
#40: Rearranging a Table
#41: Creating a Screen Scraper
Hacking the Script
#42: Converting Plaintext into HTML-Ready Markup
#43: Automatically Hyperlinking URLs
#44: Stripping HTML Tags from Strings
6. WORKING WITH DATES
How Unix Time Works
#45: Getting the Current Timestamp
#46: Getting the Timestamp of a Date in the Past or Future
Creating Timestamps from a String
Verifying Dates with strtotime()
Creating Timestamps from Date Values
#47: Formatting Dates and Times
#48: Calculating the Day of the Week from a Given Date
#49: Finding the Difference Between Two Dates
Using the Script
Hacking the Script
MySQL Date Formats
7. WORKING WITH FILES
File Permissions
Permissions with an FTP Program
The Command Line
What Can Go Wrong?
#50: Placing a File's Contents into a Variable
Hacking the Script
What Can Go Wrong?
#51: Creating and Writing to a File
#52: Checking to See If a File Exists
#53: Deleting Files
#54: Uploading Images to a Directory
Using the Script
What Can Go Wrong?
Hacking the Script
#55: Reading a Comma-Separated File
8. USER AND SESSION TRACKING
Using Cookies and Sessions to Track User Data
Cookies
Advantages
Disadvantages
Sessions
Advantages
Disadvantages
#56: Creating a "Welcome Back, Username!" Message with Cookies
What Can Go Wrong?
#57: Using Sessions to Temporarily Store Data
What Can Go Wrong?
#58: Checking to See If a User's Browser Accepts Cookies
#59: Redirecting Users to Different Pages
#60: Forcing a User to Use SSL-Encrypted Pages
#61: Extracting Client Information
#62: Session Timeouts
#63: A Simple Login System
9. WORKING WITH EMAIL
#64: Using PHPMailer to Send Mail
Installing PHPMailer
Using the Script
Adding Attachments
What Can Go Wrong?
#65: Using Email to Verify User Accounts
10. WORKING WITH IMAGES
#66: Creating a CAPTCHA (Security) Image
#67: Creating Thumbnail Images
11. USING cURL TO INTERACT WITH WEB SERVICES
#68: Connecting to Other Websites
#69: Using Cookies
#70: Transforming XML into a Usable Form
#71: Using Mapping Web Services
#72: Using PHP and SOAP to Request Data from Amazon.com
#73: Building a Web Service
12. INTERMEDIATE PROJECTS
#74: A User Poll
Creating a Ballot Form
Processing the Ballot
Getting Poll Results
Hacking the Script
#75: Electronic Greeting Cards
Choosing a Card
Sending the Card
Viewing the Card
Hacking the Script
#76: A Blogging System
Creating Blog Entries
Displaying an Entry
Adding Comments
Creating a Blog Index
Hacking the Script
A. APPENDIX
COLOPHON
← Prev
Back
Next →
← Prev
Back
Next →