1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Quickie PHP Script Needed - 10 Minutes Work (or less)

Discussion in 'Programming' started by mikem79, Sep 27, 2007.

  1. #1
    Here is what I do by hand (stupid, by definition).

    - Have a list of file names in a folder on my server.

    - The names are meaningless, but they are in a consistent format, like this:

    - _Scar10_Phtml.static
    - _Scar11_Phtml.static .....and so on

    - These are the only files in this folder.

    - Every file in the folder needs to be renamed as follows:

    - Open the file
    - Grab what is between the <title> tags
    - Remove Extraneous spaces, make it all lower case, then add dashes between the words
    - Copy the file using the cleaned up stuff found between the <title> tags as the name
    - Change the file extension to .php

    For example:

    If the file called " _Scar10_Phtml.static " has this title info:

    <title> Antique Kookoo Clock for sale </title>

    then the file gets copied and renamed this: " antique-kookoo-clock-for-sale.php ".

    So, if the folder starts with 500 meaningless file names it would end up with 1,000 files total in it (500 with the original whacky name and 500 with the new, sexy names derived from the title tags.)

    That is it.

    Must run on steam powered php version 4 dot old. Don't use any fancy php 5 syntax, most of my $5 per month servers have the old stuff.

    Please PM me with a fixed price and time frame for completion.
    Once I accept your offer I will send you some files for you to work with. Payment immediately follows successful install by me on one of my cheapie servers.

    This would take me all freaking day poking around my "PHP for Dumbasses" book...or one of you pros can bang it out in no time.

    Thanks for having a look.
     
    mikem79, Sep 27, 2007 IP
  2. SoniCute

    SoniCute Active Member

    Messages:
    585
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Send you PM
     
    SoniCute, Sep 27, 2007 IP
  3. petronel

    petronel Peon

    Messages:
    113
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    use this: (but you'll need to have write permission to that folder.)
    
    <?php
    echo "<pre>";
    if ($handle = opendir('.')) {
        echo "Directory handle: $handle\n";
        echo "Files:\n";
    
        // List all the files
        while (false !== ($file = readdir($handle))) {
            //if ($file != "." && $file != ".."){
            if (substr($file,-7) == ".static"){
        		echo "$file";
        		$content = file_get_contents($file);
        		if (eregi('<title>(.*)</title>', $content, $results)) {
    				$result = $results[1];
    				$filename = strip($result).".php";
    				echo " => ". $filename ."\n";
    				if (!$h = fopen($filename, 'w')) {
    			         echo "Cannot open file ($filename)";
    			         exit;
    			    }
    				fwrite($h,$content);
    				fclose($h);
    			}
            }
        }
    
        closedir($handle);
    }
    
    	function strip($string){
    		$pattern = 	"([[:punct:]])+";
    		$anchor = ereg_replace($pattern, '', strtolower($string));
    		//echo $anchor;
    		$pattern = "([[:space:]]|[[:blank:]])+";
    		$anchor = ereg_replace($pattern, '-', $anchor);
    		return $anchor;
    	} # end function
    ?>
    PHP:
     
    petronel, Sep 28, 2007 IP
  4. undir

    undir Peon

    Messages:
    696
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    I am interested. Please PM me or post here if I can start.
     
    undir, Sep 28, 2007 IP
  5. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Nice and free :)

     
    phantom, Sep 28, 2007 IP
  6. petronel

    petronel Peon

    Messages:
    113
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    I like to help people :)
     
    petronel, Sep 28, 2007 IP