vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   vBulletin 4 Request - Help Converting from MyBB to vBulletin (https://vborg.vbsupport.ru/showthread.php?t=325441)

Alice 07-25-2017 11:43 PM

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,

Rafa-el 07-26-2017 08:05 PM

Which version of vB?

Dave 07-26-2017 08:23 PM

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();
?>


Alice 07-27-2017 05:18 PM

Quote:

Originally Posted by Dave (Post 2588907)
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,

GHRake 07-30-2017 09:44 PM

plz tell me that's not your actual DB username and password!

TheLastSuperman 07-31-2017 03:38 AM

Removed database username + password ^.

MarkFL 08-01-2017 01:38 AM

Quote:

Originally Posted by TheLastSuperman (Post 2589011)
Removed database username + password ^.

Mike, post #4 needs to be edited as well. :)

Alice 08-01-2017 12:34 PM

No no, that was the information from an old database, thats why it was posted. The myBB database was taken offline a awhile ago.


All times are GMT. The time now is 02:02 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.01063 seconds
  • Memory Usage 1,761KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete