Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Writing a piece of code... Details »»
Writing a piece of code...
Version: , by Radon3k Radon3k is offline
Developer Last Online: Feb 2009 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 01-21-2003 Last Update: Never Installs: 0
 
No support by the author.

Hi there,

I'm developing something and now I'm stuck on it. This may sound weird, but I do have a point behind it, so please bare with me. For right now, I just want the simple procedure, and if that's successful, then I'll take it to the next step.

I have a text file that contains several thousand company names in it. What I want to be able to do, using the "add forum" section from /admin/forum.php, is have it read each line of the text file and create a category name for each company listed there.

Example:

Microsoft
Circuit City
Best Buy

When the script is executed, a category for Microsoft, a category for Circuit City, and a category for Best Buy would be created. To add onto that, with each category created, 4 forums would be added as well, all having the same names.

Example:

Category names:
Microsoft
Circuit City
Best Buy

Forum names:
General talk
What To Buy
What's On Sale

When the script is executed:

Microsoft
--General Talk
--What To Buy
--What's On Sale

Circuit City
--General Talk
--What To Buy
--What's On Sale

Best Buy
--General Talk
--What To Buy
--What's On Sale

You get the idea. I know that I need to use a loop (probably going to use a "for" loop) for this, but I'm unsure of how to import the file. To add onto that, I'm having trouble figuring out how to add it to the forums with the code from /admin/forum.php.

I've tried adding just one forum using an HTML form, but that did not work.

I'm thinking that I need to make the text file into a PHP file and make the company names an array. Though, that sounds like a lot of work for several thousand companies. If this were 10 companies, I'd add them manually via the Admin CP in vBulletin, but several thousand companies is a lot of work.

I know you're probably asking, "Why on Earth would you want to do that?". Please just bare with me.

Any guidance in the right direction would be most appreciative. Thanks!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 01-21-2003, 09:55 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

couldn't you do it with just a query to the db, to get it from the text file explode it into an array then count the array and do for($i=0;$i<array;$i++) then a query to make a forum, look at what query vb does when you tell it to create one and use that
Reply With Quote
  #3  
Old 01-21-2003, 10:08 PM
Radon3k's Avatar
Radon3k Radon3k is offline
 
Join Date: Nov 2001
Posts: 245
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I did look at that, but there's a few there and I'm not sure which one to use.
Reply With Quote
  #4  
Old 01-21-2003, 10:54 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you could try this to open the file, just make sure each entry is seperated by a space

PHP Code:
$file file_get_contents ("file.txt");
$filearray explode (" "$file);

$i 0;
for (
$i=0;$i<$filearray-1;$i++) {
    
RUN QUERY HERE

i think that'll work, but im no php guru or anything
Reply With Quote
  #5  
Old 01-21-2003, 11:07 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

then for the query i think this'll work

PHP Code:
$pid $i 1;
$DB_site->query("INSERT INTO forum
               (forumid,styleid,title,description,active,displayorder,parentid,
               parentlist,allowposting,cancontainthreads,daysprune,newpostemail,newthreademail,
               moderatenew,allowhtml,allowbbcode,allowimages,allowsmilies,allowicons,
               styleoverride,allowratings,countposts,moderateattach)
               VALUES
               (NULL,'YOUR DEFAULT STYLE','
$filearray[$i]','','1','$i','$pid',
               '
$i,-1','0','0','0','','','0','0','1','1','1','1','0','1',
               '1','0')"
);
               
$DB_site->query("INSERT INTO forum
               (forumid,styleid,title,description,active,displayorder,parentid,
               parentlist,allowposting,cancontainthreads,daysprune,newpostemail,newthreademail,
               moderatenew,allowhtml,allowbbcode,allowimages,allowsmilies,allowicons,
               styleoverride,allowratings,countposts,moderateattach)
               VALUES
               (NULL,'YOUR DEFAULT STYLE','General Talk','','1','
$i','-1',
               '
$i,-1','1','1','30','','','0','0','1','1','1','1','0','1',
               '1','0')"
);
               
$DB_site->query("INSERT INTO forum
               (forumid,styleid,title,description,active,displayorder,parentid,
               parentlist,allowposting,cancontainthreads,daysprune,newpostemail,newthreademail,
               moderatenew,allowhtml,allowbbcode,allowimages,allowsmilies,allowicons,
               styleoverride,allowratings,countposts,moderateattach)
               VALUES
               (NULL,'YOUR DEFAULT STYLE','What to Buy','','1','
$i','-1',
               '
$i,-1','1','1','30','','','0','0','1','1','1','1','0','1',
               '1','0')"
);
               
$DB_site->query("INSERT INTO forum
               (forumid,styleid,title,description,active,displayorder,parentid,
               parentlist,allowposting,cancontainthreads,daysprune,newpostemail,newthreademail,
               moderatenew,allowhtml,allowbbcode,allowimages,allowsmilies,allowicons,
               styleoverride,allowratings,countposts,moderateattach)
               VALUES
               (NULL,'YOUR DEFAULT STYLE','What's on Sale','','1','
$i','-1',
               '
$i,-1','1','1','30','','','0','0','1','1','1','1','0','1',
               '1','0')"
); 
the only thing i can't get to work is the parent list thing so i dont know if this will even work until you get those working, but i haven't tested this
Reply With Quote
  #6  
Old 01-21-2003, 11:29 PM
Radon3k's Avatar
Radon3k Radon3k is offline
 
Join Date: Nov 2001
Posts: 245
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I had a hard time with the parent ID thing too. Ok well lemme mess around with this code and I'll get back to you. Thanks a bunch, sir!
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 12:44 AM.


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.04735 seconds
  • Memory Usage 2,267KB
  • Queries Executed 19 (?)
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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (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_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
  • 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