Home > PHP > Three Quick Php Scripts & Mods

Three Quick Php Scripts & Mods

September 8th, 2009

Hi there,

Thanks for looking at my project. This should be a very quick one. It’s a set of 4 very small PHP scripts or mods to existing scripts.
In all cases, we are talking about PHP4 on a Linux server.

1.) Simple “write 1 line” script:
I have a tab-delineated flat text database on my server. I want a script that will check to see if a specific record is in the database (match of recordID). If it is, the script can end. If not, the script should add the record, which I will provide pre-formatted and ready to go … we’re talking about just adding 1 line of text to a database.

Question? Why don’t I just add the text manually?
Answer: Because I intend to set it up as a daily cron job, always adding this line.

2.) Simple URL rewrite to text file:
I have a script named “list_missing_autobase_urls.txt” which checks a directory of images against a set of URLs in a database, and makes a text file list of any images whose filenames are not yet in the directory.

I need a modification to this script. Currently, it writes all the URLS exactly as they are. What I want is this:

If a URL contains the text “overlays”, followed by a “/” and a 4-digit number, it should replace this with the text “large/”

So, for example, if a photo image URL to be written is:
http://www.autobase.com/photos/overlay/0408/04084886.jpg

the script should actually write:
http://www.autobase.com/photos/large/04084886.jpg

Does that make sense? I am attaching the download_missing_autobase_images.php script for reference.

3.) Mod to record loading script
I have a very simple script called video.php. This script receives a record ID through the URL that calls it. It then loads a second script in the middle of the page, inserting that record ID into the URL that loads the second script. You can see it at work here: http://www.autopages.com/watch/video.php?id=twf_X5310 As you can see, the first script is simply a way to have a page background for the second script.

What I need is this:
A modification to this first script that puts four text links on this page, just below the Flash window that is created by the second script.

The four links need to be populated with information from that record, which is in the same tab-delineated text flat file database I mentioned in part #1.

The links should be as follows:

View All Our Inventory “http://www.autopages.com/showinventory/[dealerID]
Visit Our Website “http://www.autopages.com/redirects/[dealerID]
AutoPages.com Home “http://www.autopages.com/”
View Full Listing “http://www.autopages.com/listings/[recordID]

It’s very simple. The recordID is simply column 8 of the record, and the dealerID is simply column 11 of the record.


Three Quick Php Scripts & Mods

Comments are closed.
Bear