Format File Size
24
"Today in the news, MySQL previews..."
As a "preview" of text, this MySQL select will return the first few words out of a text field in a database. It returns entire words (doesn't cut them off in the middle) and follows the last word with an elipse "..."
In the PHP, assign $CharactersToDisplay to a number - the approximate number of characters desired (or you can hard-code it if you want).
For the example, I also use $TheID as the row identity for the record to display.
As a "preview" of text, this MySQL select will return the first few words out of a text field in a database. It returns entire words (doesn't cut them off in the middle) and follows the last word with an elipse "..."
In the PHP, assign $CharactersToDisplay to a number - the approximate number of characters desired (or you can hard-code it if you want).
For the example, I also use $TheID as the row identity for the record to display.
14
MySQL 5.x Stored Routines, PHP Session Values, a little CSS oh my! Complex to set up but easy to impliment. Geared toward security, simplicity (of use) and convenience.
2
If it's a .php page, you can simply include this file where you want a hit counter to appear.
One file - text output. Very simple, very easy. Based off the filename of the page (creates a pagename.counter file to hold the count).
(No use for it myself - made it for a friend).
One file - text output. Very simple, very easy. Based off the filename of the page (creates a pagename.counter file to hold the count).
(No use for it myself - made it for a friend).
14
Here's a basic function for debugging any kind of PHP variable. It allows for "invisible" or "visible" output--that is output in HTML comments or within visible HTML tags. It also supports customizable "containers" which lets you easily edit the look of the visible and invisible blocks. Examples in code below.
15
This is a bare-bones DB connectivity class. It's really just meant to abstract a few basic mysql_ functions so that if you ever have to change DBs you don't have to change every database function call.
I really just threw this together on a whim with no testing what-so-ever. Also, it only abstracts the most basic MySQL functions--this is intentional; please expand it as you see fit.
I really just threw this together on a whim with no testing what-so-ever. Also, it only abstracts the most basic MySQL functions--this is intentional; please expand it as you see fit.
15
This function converts a CSV file to a simple XML file.
19
inxilpro
This function creates relatively secure random passwords. It's by no means ideal, but it should work in most non-critical situations. The nice thing is the generator attempts to create passwords that people can pronounce and chooses letters that won't be mistaken for others (such as the numeral "1", an upper-case "i" and a lower-case "L"). To keep the code short much of this functionality is very rudimentary, but it's better than nothing.
14
inxilpro
This is a random password generator that produces understandable passwords based on word lists. I've only included a 3 entry world list because you should chose a list based on your password requirements and your users. If you need to generate passwords that are 14 characters in length, you will want a different list than if you're generating 8 character passwords. And depending on your users, you may want to use certain lists. The list I use is about 4000 words that are 5-7 characters long, all well-known words that have had potentially objectionable content removed. For security reasons I don't want to include this list.
A note on security: though this generates relatively strong passwords for the average user, they are particularly susceptible to brute-force attacks. This is even more an issue if somehow your word list gets compromised. I would not recommend using this function for anything where a highly secure password is needed.
A note on choosing your list: You'll also see that I've built the system to avoid generating passwords with zeros and ones in them. This is because zero and upper-case "o" can be confused as can one, lower-case "L" and upper-case "i." When choosing my word list I was also sure to strip out all words that start with the letter "o" or "i" (to prevent the optional ucfirst() from creating 0/O and I/1 confusion) and words that contain the letter "L" (to prevent l/1 confusion). I find that this greatly helps with preventing confusion, but again weakens the security of the passwords some. It's your choice.
A note on security: though this generates relatively strong passwords for the average user, they are particularly susceptible to brute-force attacks. This is even more an issue if somehow your word list gets compromised. I would not recommend using this function for anything where a highly secure password is needed.
A note on choosing your list: You'll also see that I've built the system to avoid generating passwords with zeros and ones in them. This is because zero and upper-case "o" can be confused as can one, lower-case "L" and upper-case "i." When choosing my word list I was also sure to strip out all words that start with the letter "o" or "i" (to prevent the optional ucfirst() from creating 0/O and I/1 confusion) and words that contain the letter "L" (to prevent l/1 confusion). I find that this greatly helps with preventing confusion, but again weakens the security of the passwords some. It's your choice.
13
daysBeteenDates will calculate the number of days between 2 dates in the form of 'YYYY-MM-DD'.
5
The resize_image function allows you to resize a GIF, JPEG or PNG file to any dimension you wish and put an optional black border around the image. Here's an explanation of the arguements:
$image_path: The complete path to the image to be resized
$max_width: Maximum width of the resized image. Leave 0 if you want to specify only the height and have the width auto-scale.
$max_height: Maximum height of the resized image. Leave 0 if you want to specify only the width and have the height auto-scale.
$file_prefix: This will prepend a string onto the resized image filename. If you want to create a thumbnail image and keep the original, set $file_prefix = 'thumb'.
$dir: Allows you to save the resized image to a sub directory under the $image_path directory. If you want to save thumbnail images to images/thumbs, set $dir = 'thumbs'.
$border: boolean, 1 = border, 0 = no border
$mime: Image mime type. (image/jpeg, image/gif, image/png)
$image_path: The complete path to the image to be resized
$max_width: Maximum width of the resized image. Leave 0 if you want to specify only the height and have the width auto-scale.
$max_height: Maximum height of the resized image. Leave 0 if you want to specify only the width and have the height auto-scale.
$file_prefix: This will prepend a string onto the resized image filename. If you want to create a thumbnail image and keep the original, set $file_prefix = 'thumb'.
$dir: Allows you to save the resized image to a sub directory under the $image_path directory. If you want to save thumbnail images to images/thumbs, set $dir = 'thumbs'.
$border: boolean, 1 = border, 0 = no border
$mime: Image mime type. (image/jpeg, image/gif, image/png)









