PHP Advanced

PHP: Deleting Files

July 14, 2015

To delete all files of a particular extension, or in fact, delete a group with any wildcard, echo `rm -f path/to/*.jpg`; # note the backquotes, not single nor double quotes or foreach (glob("*.jpg") as $filename) { echo "$filename size " . filesize($filename) . "\n"; unlink($filename); } sometimes, the function realpath() may be needed: unlink(realpath($fileName)); or $mask = "*.jpg" array_map( "unlink", glob( $mask ) );...

Read more »

Delete the Zen-Cart Store Demo files, images, and Data

October 11, 2012
Delete the Zen-Cart Store Demo files, images, and Data

How to get rid of zen-carts demo store – including version 1.5.0. “How to clean up default install and remove example store related files.” How to remove, or delete, the “Zen Cart demonstration categories and products”. Help with installing Zen-cart, help removing Zen-cart’s demo store. How to Delete all the Zen-Cart Sample Store files, images, and Data. Install Zen-Cart and choose “NO” to the...

Read more »

Stopping Website Visitor Blog Spam

April 9, 2012

Stopping Website Visitor Comment Spam. IF you have a blog and want visitors to easily add a comment to an item, you will also get spam – lots of it – unless you, traditionally, forced visitors to create a login before commenting, or you used a captcha. As one guy said, “It’s really disgusting the stuff I have to block from my blog every...

Read more »

PHP DATE and TIME Functions, warnings

March 22, 2012
PHP DATE and TIME Functions, warnings

updated 2019-09-21 The Current Date, Time today (yyyy-mm-dd): echo date("Y-m-d") ; today (mm-dd-yyyy): echo date("m-d-Y") ; this year (yyyy): echo date('Y') ; date("F jS Y, h:i:s a T", time() ) ex: October 1st 2012, 05:05:31 pm EDT (ex: USA Eastern time zone during DST) j = day of the month 1-31 without leading 0. d = day of the month 01-31 with leading 0....

Read more »

php 5.3: Speed Optimizations for Strings and Arrays

January 27, 2012

updated 2020-02-03 str, ctype, preg, explode, etc.. example: switch y-m-d to m-d-y list($YY,$mm,$dd) = explode("-",$date_stored); $displaydate = $mm."/".$dd."/".$YY; Real-World Experience Buffering A customer I contracted with had the experience of rare cases where visitors to his site would experience the computer starting to process their page request and then being sidelined while the cpu co-processed other visitors page requests – for as much as...

Read more »

PHP 5.3 Breaks “many things”

January 9, 2012

“PHP 5.3 brought many problems due to the PHP authors’ decisions to . . . break many things…” Also, they initiated the warnings of more things they intend to break in PHP 6. Be sure your error reporting is turned on: (for your testing copy or for your IP address) @ini_set('display_errors', '1'); error_reporting(E_ALL ^ E_NOTICE); # or error_reporting(E_ALL); “PHP 5.3 breaks AtMailOpen.” “I tried...

Read more »

Enhancing, expanding limits, customizing, phpMyAdmin

October 29, 2011
Enhancing, expanding limits, customizing, phpMyAdmin

The database tool, phpMyAdmin is NOT the only mysql database tool but it is and has been, the most popular and most awarded among MySQL administrators and developers. It was mentioned by the author of the first php and MySQL book I read. The administrators and developers I have met since, all use it. It is also one which can be installed on the...

Read more »

How to install and customize-personalize Zen-Cart

October 28, 2011
How to install and customize-personalize Zen-Cart

Tutorial help: how to find settings to set up, customize, Zen-Cart Fast. What Zen-Cart Won’t Tell You Running the installation program is easy. The time consuming part is removing their sample store demo files and changing ZC’s settings which are scattered all over. I made changes to the html several times because I did not know there was some setting in admin. The admin...

Read more »

Internet Hacking 101, with PHP

June 1, 2011

The point is, a web site (blog?) with an option or requirement to login before commenting (or blogging) and no captcha, may be easy to get into as an admin. Make sure your web site is secure. Micah Lee, in 2600, The Hacker Quarterly tells how to “write code that automatically loads web pages, submits forms, and [can create an admin user-id in WordPress...

Read more »

PHP Fatal error: Cannot redeclare

October 18, 2010

” Fatal error: Cannot redeclare () … ” I defined a function (fff) in the top of my pgm. (not in a loop) it spanned from line 5 to 11 and used it in the program, later. I got this error msg: Fatal error: Cannot redeclare fff() (previously declared in /…/xxx.php:5) in /…/xxx.php on line 11 clearly, I only defined it once in the...

Read more »

Function: Convert Numbers to Words

August 8, 2010

This little, recursive, script is to convert a number, an integer, to words. It has an upper limit of 999,999,999 but you can expand or reduce it from there. Put the function in your include file and try it out. /* * Function: number_to_words * Description: recursive numerics to words function * Converts a given integer (in range , inclusive) into * alphabetical format...

Read more »

PHP(6): Character encoding and other new features

April 13, 2010

The Internet is converging on UTF-8 for a common / universal character encoding. Set your apache environment to utf-8 by adding ‘AddDefaultCharset utf-8’ to your .htaccess. If you do not use apache add ‘default_charset utf-8’ to your php.ini. You have to do either of them (not both), php will use the apache setting where needed. And, of course, your html-header: ‘< meta http-equiv="Content-type" content="text/html;...

Read more »

SQL db Injection, Cross-Scripting, RFI, and LFI

March 27, 2010

It is possible for a hacker to enter the following seemingly innocuous text into the UserName textbox to gain entry to the system without having to know a valid user name and password: ‘ Or 1=1 — The hacker breaks into the system by injecting malformed SQL into the query. This particular hack works because the executed query is formed by the concatenation of...

Read more »

Comparing OOP in php, java, and C++

March 18, 2010

Sample introductory Object Oriented Programming code in php, java, and C++ showing the similarities and differences. With the possible exception of large, long-term projects, OOP, despite all the hype, is a lot more expensive to write and to maintain than clean structured code. The reality of it does not live up to the theory, and the hype is often “smoke and mirrors” unfortunately. This...

Read more »