Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2017, 11:43 PM
Alice Alice is offline
 
Join Date: Mar 2013
Location: Great Lakes Area
Posts: 81
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vBulletin 4 Request - Help Converting from MyBB to vBulletin

Hello,

I am looking for a little assistance with converting this code from mybb to vbulletin.

Code:
<?php
	$servername = 'localhost';
	$dbusername = 'Removed by';
	$dbpassword = 'Staff!';
	$dbname = 'mybb';
	
	$con = new mysqli($servername, $dbusername, $dbpassword, $dbname);
	
	if ($con->connect_error) {
		die("Connection failed: " . $con->connect_error);
	}
	
	echo "<body style=\"background-color:#001500;\">";

	$sqlquery = "SELECT subject, message, fid, tid, dateline FROM mybb_posts WHERE replyto = '0' ORDER BY dateline DESC";
	$sqlresult = $con->query($sqlquery);
		
	while ($row = $sqlresult->fetch_array()) {
		
		if ($row['fid'] == 2 || $row['fid'] == 5) {
			echo "<a style=\"text-decoration:none;color:orange;\" href=\"http://swghuttcartel.com/forums/showthread.php?tid=" . $row['tid'] . "\">" . "<b>" . $row['subject'] . "</b>" . "</a><br>";
			$message = preg_replace("#\s*\[.+\]\s*#U", "", explode('!', explode('.', $row['message'])[0])[0]);
			echo "<a style=\"color:#fff;\">" . $message . ".</a><br>";
			echo "<i><a style=\"color:gray;\">" . gmdate("m.d.Y", $row['dateline']) . "</a></i><br><hr><br>";
		}	
	}
	echo "</body>";
	$con->close();
?>
Basically, this is for the launcher of a computer game, its to allow the launcher to fetch threads from an announcement forum and display them on the launcher.

Thank you,
Reply With Quote
  #2  
Old 07-26-2017, 08:05 PM
Rafa-el's Avatar
Rafa-el Rafa-el is offline
 
Join Date: Feb 2010
Location: Nicaragua
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Which version of vB?
Reply With Quote
  #3  
Old 07-26-2017, 08:23 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin 4 according to the thread prefix. You can try something like below assuming you don't use a table prefix and that you want the latest 15 posts. I also moved the forumid check to the query instead of the check in the PHP code.

This is untested by the way.

PHP Code:
<?php
    $servername 
'localhost';
    
$dbusername 'Removed by';
    
$dbpassword 'Staff';
    
$dbname 'mybb';
    
    
$con = new mysqli($servername$dbusername$dbpassword$dbname);
    
    if (
$con->connect_error) {
        die(
"Connection failed: " $con->connect_error);
    }
    
    echo 
"<body style=\"background-color:#001500;\">";

    
$sqlquery "SELECT thread.title, thread.forumid, thread.dateline, post.pagetext, thread.firstpostid FROM thread INNER JOIN post ON post.postid = thread.firstpostid WHERE thread.forumid in(2,5) ORDER BY thread.dateline DESC LIMIT 0,15";
    
$sqlresult $con->query($sqlquery);
        
    while (
$row $sqlresult->fetch_array()) {
        echo 
"<a style=\"text-decoration:none;color:orange;\" href=\"http://swghuttcartel.com/forums/showthread.php?p=" $row['firstpostid'] . "\">" "<b>" $row['title'] . "</b>" "</a><br>";
        
$message preg_replace("#\s*\[.+\]\s*#U"""explode('!'explode('.'$row['pagetext'])[0])[0]);
        echo 
"<a style=\"color:#fff;\">" $message ".</a><br>";
        echo 
"<i><a style=\"color:gray;\">" gmdate("m.d.Y"$row['dateline']) . "</a></i><br><hr><br>";
    }
    echo 
"</body>";
    
$con->close();
?>
Reply With Quote
2 благодарности(ей) от:
Phillip, TheLastSuperman
  #4  
Old 07-27-2017, 05:18 PM
Alice Alice is offline
 
Join Date: Mar 2013
Location: Great Lakes Area
Posts: 81
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
vBulletin 4 according to the thread prefix. You can try something like below assuming you don't use a table prefix and that you want the latest 15 posts. I also moved the forumid check to the query instead of the check in the PHP code.

This is untested by the way.

PHP Code:
<?php
    $servername 
'localhost';
    
$dbusername 'ZLsC$x7KJ^';
    
$dbpassword '_DtVEY5bHdfKUm4x';
    
$dbname 'mybb';
    
    
$con = new mysqli($servername$dbusername$dbpassword$dbname);
    
    if (
$con->connect_error) {
        die(
"Connection failed: " $con->connect_error);
    }
    
    echo 
"<body style=\"background-color:#001500;\">";

    
$sqlquery "SELECT thread.title, thread.forumid, thread.dateline, post.pagetext, thread.firstpostid FROM thread INNER JOIN post ON post.postid = thread.firstpostid WHERE thread.forumid in(2,5) ORDER BY thread.dateline DESC LIMIT 0,15";
    
$sqlresult $con->query($sqlquery);
        
    while (
$row $sqlresult->fetch_array()) {
        echo 
"<a style=\"text-decoration:none;color:orange;\" href=\"http://swghuttcartel.com/forums/showthread.php?p=" $row['firstpostid'] . "\">" "<b>" $row['title'] . "</b>" "</a><br>";
        
$message preg_replace("#\s*\[.+\]\s*#U"""explode('!'explode('.'$row['pagetext'])[0])[0]);
        echo 
"<a style=\"color:#fff;\">" $message ".</a><br>";
        echo 
"<i><a style=\"color:gray;\">" gmdate("m.d.Y"$row['dateline']) . "</a></i><br><hr><br>";
    }
    echo 
"</body>";
    
$con->close();
?>
Do I need any file inclusions like global.php?

--------------- Added [DATE]1501184216[/DATE] at [TIME]1501184216[/TIME] ---------------

Oh also: I have the code here: https://swghope.com/forums/launcher_news.php - I'm wondering if we can either remove the url text completely or have it display the full url instead of it being cutoff, right?

Thanks,
Reply With Quote
  #5  
Old 07-30-2017, 09:44 PM
GHRake GHRake is offline
 
Join Date: Sep 2015
Location: USA
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

plz tell me that's not your actual DB username and password!
Reply With Quote
  #6  
Old 07-31-2017, 03:38 AM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Removed database username + password ^.
Reply With Quote
2 благодарности(ей) от:
MarkFL, RichieBoy67
  #7  
Old 08-01-2017, 01:38 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TheLastSuperman View Post
Removed database username + password ^.
Mike, post #4 needs to be edited as well.
Reply With Quote
  #8  
Old 08-01-2017, 12:34 PM
Alice Alice is offline
 
Join Date: Mar 2013
Location: Great Lakes Area
Posts: 81
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No no, that was the information from an old database, thats why it was posted. The myBB database was taken offline a awhile ago.
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 11:41 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08980 seconds
  • Memory Usage 2,269KB
  • 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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (4)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete