Do you use PHP from the command line and need a password prompt? This is how you do.
Windows:
$scriptpw = new Com('ScriptPW.Password');
$password = $scriptpw->getPassword();
The Windows version requires the file scriptpw.dll. This comes with some versions of Windows, such as XP, but not others, such as 2000, Vista, or 7. If you don't have the file, simply copy scriptpw.dll from the system32 folder of another machine to the system32 folder of your machine. Then, from a Command Prompt window (running as Administrator for Vista and 7) enter the command
regsvr32 scriptpw.dll
Linux:
system('stty -echo');
$password = trim(fgets(STDIN));
system('stty echo');
echo "\n";
The latest techniques we've been playing with involve using a PHP script on our server in Michigan to print to a remote printer at our office in Vancouver. In the past we've done this by generating an
XHTML document with high-resolution images and simply prompting the user to print it. This worked, but if any sort of precision was required, the user had to configure their browser's page setup just so, and to make things even more difficult, different browsers required different settings.
Enter PostScript, a language understood by many laser printers. With PostScript, we can go directly from our script to the printer, (pipe the finished PostScript document to the printer on port 9100) eliminating the stop off at the browser. And, we can position things on our page with as much precision as necessary.
Read more...
Alternate title: "Help! My Quotes Appear as Question Marks or Other Strange Characters!"
The "Smart quotes" feature in Microsoft Office transforms straight quotes into curly quotes. It also transforms hyphens into em-dashes and three periods into ellipses. While one might think, "How lovely! My document looks almost as if I'm educated!" readers of said document may not. Microsoft, in its infinite wisdom, decided to assign special characters such as the ones I just mentioned to a range of codes above 128. Problem: these codes were already assigned to other characters, resulting in frustrating incompatibility with non-Microsoft systems.
Keep reading for some PHP and MySQL code to help out with this issue, as well as a Joomla! plugin.
Read more...
I wrote two date/time functions in PHP that I was really pleased with so thought I'd post them.
- string friendlydate ( numeric or string $input )
Return value is a day in relation to today in the format "Today", "Yesterday", "Wednesday", "March 2", or "November 7, 2007".
- string howlong ( numeric or string $a, numeric or string $b )
Return value is the approximate length of time between two dates, $a and $b. Examples are "4 seconds ago", "1 minute from now", "1 hour ago", "yesterday", "2 months ago", "1 year ago".
Read more...