Regular expression to move legacy array index PHP code to PHP 5.4.x

 This was a bit of  headache; after we upgraded our servers to use php 5.4 we had a few clients who’s sites that went down.  For the most part it was a simple fix, of prepending a globalizer file to all page requests via htaccess, or just updating the session handling routines as various functions like session_register(), session_destroy().  However one of the sites was heavily relying on old style array syntax so things like unquoted associative array keys such as $var[index] (instead of the proper $var["index"] were very...

read more

Supporting legacy code, using global variables and register_globals with PHP 5.4.x

 Recently we ran into some issues with some of our old sites that are relying on the register_globals  for variable access after upgrading to PHP 5.4 which wisely no longer supports this kind of setup.  Using globals in this fashion  is a horrible practice, but sometimes you gotta maintain some legacy code. To use global variables you can add a line of code to htaccess that will run a “globalizer” file before loading the main page on every page load and extract the required variables. globalizer.php file <!--?php...

read more

Restart Backup Exec Services Script

 cd C:\Program Files\VERITAS\Backup Exec\NT\ bemcmd -o503 timeout 60 bemcmd -o502 exit

read more

MS DOS script to rename, append date, delete files older than 30 or N days

 If you use Windows Server 2003 built-in NTBackup, you may need to move daily backup files into an archive folder, and delete old files.  Here is a script to rename and append time/date to backup file, move it to an archive directory, and search and delete all files older than 30 days. ren E:\ntbackup\backup2.bkf backup1_%date:~4,2%%date:~7,2%%date:~10,4%_.bkf move E:\ntbackup\backup?_* E:\ntbackup\archive forfiles /P “E:\ntbackup\archive” /S /M *.bkf /D -30 /C “cmd /c del @PATH” Set this as a scheduled task after...

read more

Scripting – check if process or program is running and start it

 Sometimes you have to have a program running for other programs to work. If this program does not run as a Windows service, use this script to check for program’s process name, and start it if it’s not running. Use your own process name instead of ‘calc.exe’ and you can take out the ‘wscript.echo’ line. Then, run this script under Scheduled Tasks every 15 minutes or so. You may have to run the scheduled task with elevated privileges, or using a Local Administrator or Domain Administrator...

read more

MS robocopy backup and syntax usage

 Starting in Windows Vista, Microsoft introduced robocopy command to replace xcopy from Windows XP. Robocopy can be downloaded and installed on any Windows XP or even older Windows Server computer. I use this simple robocopy script that runs as a scheduled task every day to backup “My Documents” folder to the file server: @echo off net use K: /delete net use K: \\192.168.1.116\backup @echo on robocopy "C:\Users\user-name-here" "K:" /E /A /V /NDL /NP /LOG:"C:\backupLog.txt" /XF *.mp3...

read more