Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-22-2003, 06:39 PM
SloppyGoat's Avatar
SloppyGoat SloppyGoat is offline
 
Join Date: Feb 2002
Posts: 339
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Convert php3 to php

I found this code that will convert php3 to php, but I can't get it to work. I'm no expert on this stuff, but I'd love for this to work. I'm thinking I may just have to change the top line, but what do I change it to, if so? Can someone take a look and tell me what you think? Is that top line supposed to map to my php folder? Maybe I just need to change the path? But what's "#!" mean? I'm running a IIS server, so if that's Apache stuff, I'm not real familiar with it.

PHP Code:
#!/usr/bin/php -q
<?php
        
// Convert .php3 to .php
        // ( and internal refs )
        //
function doFile($var) {
        if (
substr($var,strlen($var)-4,4) == "php3") {
                
$orig $var;
                
$new substr($orig,0,strlen($orig)-1);
                
$cmd "sed 's/php3/php/g' $orig > $new;rm -f $orig";
                
$res exec($cmd,$res);
                echo 
"Orig: $orig\\tNew: $new\\n";
        } else {
                echo 
"--Skipping: $var\\n";
        }
}
        
$dir=(is_array($argv) && $argv[1]) ? $argv[1] : ".";
        
$a = `find $dir -depth -type f -print`;
        
$files explode ("\\n"$a);
        echo 
"Files: ".count($files)."\\n";
        foreach(
$files as $item) {
                
doFile($item);
        }
        echo 
"Done.\\n";
?>
USAGE:
save this code as phpconvert
chmod 700 phpconvert

* put in topmost directory of entire structure to be converted ie:
if when you extracted test.zip, it made a structure like this:
/home/myname/www/test
/home/myname/www/test/admin
/home/myname/www/test/configs
/home/myname/www/test/configs/lang
/home/myname/www/test/configs/lang/english
/home/myname/www/test/configs/lang/german
/home/myname/www/test/includes

put phpconvert into your /home/myname/www/test directory:
(cp phpconvert /home/myname/www/test)
change into that directory:
cd /home/myname/www/test

run it, sit back & enjoy the show:
./phpconvert .

It will recurse through all child directories & convert all references
to .php3 inside the files, to .php. Then save the new file as .php
and finally delete the original .php3 file.

If you ever need to be able to do this, at least now you have an easier way to handle it.
Don't know about you, but I sure could've used a script like this YEARS ago...
NOTE For some reason, it won't work correctly if you put this file in your path & try to call it from there ( ie /sbin/phpconvert)... instead, it tries to do it to all files in /sbin.
I'll fix it when I have time... For now, I'm just glad it saves me hours of unnecessary work.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03104 seconds
  • Memory Usage 2,217KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete