vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Last XX Posts on non-vB page (https://vborg.vbsupport.ru/showthread.php?t=12324)

alderwazeh 02-13-2005 07:19 PM

How can I make this great hack work as well in VBadvance portal CMPS... what variables should I set in the default setting their for enabling this hach to work as well in my Poratl vbadvanced CMPS ?

gator777 03-12-2005 09:42 PM

Quote:

Originally Posted by Brad.loo

I got this error message when viewing the last10.php

PHP Code:

MySQL reported this error while trying to retreive the infoYou have an error in your SQL syntaxCheck the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT' at line 1 

Also, I have a dbprefix of "vb3_", so would that effect it also?

slinky 03-13-2005 03:52 AM

I'm trying to put this hack into a templated CMS. Unfortunately it doesn't allow you to simply paste PHP code into the template and suffice it to say that putting it into the PHP is an incredible pain like you cannot believe. What I need to do is create an output stream that is the HTML captured so that I can put it into a templating system in a CMS like evoarticles like Miraserver has instructions to do. Has anyone been able to do this with the use of a few simple lines so that the output could be captured to a variable that is in HTML format?

torcida 03-13-2005 07:56 AM

I was trying to put this hack work for 3.0.7. but i can't manage to do that.. Do anyone have done this?

Meirion 03-15-2005 11:04 AM

Quote:

Originally Posted by gator777
I got this error message when viewing the last10.php

PHP Code:

MySQL reported this error while trying to retreive the infoYou have an error in your SQL syntaxCheck the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT' at line 1 

Also, I have a dbprefix of "vb3_", so would that effect it also?


Hmm I get that too....grrr
But only with the 'security bugfixed' version of the last10.php file that was posted on the previous page by someone. Using last10.php from the ZIP file works fine, but is it safe to use?

Meirion 03-15-2005 11:07 AM

Quote:

Originally Posted by Grethe
Dummy Inc. here. This php stuff is killing me :(

The simpletest.shtml I'm running to test is situated in the localhost/vbulletin directory and looks like this:

<HTML>
<HEAD>
<TITLE>Untitled Page</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<!--#include file="http://localhost/vbulletin/last10.php"-->

</BODY>
</HTML>



What do I do wrong???????? PS. Running vBulletin 3.0.5 (will update to 3.0.6 when or if I get this working)

Thanking bunches in advance for any help!!!!!

<!--#include file="http://localhost/vbulletin/last10.php"-->
that is what you are doing wrong

As far as I know you need to put the absolute path to the file you want to include, not a web address.

ie something like "/home/username/www/vbulletin/last10.php"
but will obviously depend on your server

Meirion 03-15-2005 11:16 AM

Quote:

Originally Posted by Brad.loo

This patched version didn't work for me unfortunately.
It gave my the "error in mysql near LIMIT 1" error.

Here's how to fix it... in last10.php change this....

Code:

// let's get connected
require("last10config.php");
require("$path/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");

// destroy some var's to prevent SQL injection (patch by Brad.loo, added 11/16/04)
unset($fsel, $ftitle, $wheresql, $ob, $obdir, $maxthreads);

$hfs = $fs+2;

to this....

Code:

// destroy some var's to prevent SQL injection (patch by Brad.loo, added 11/16/04)
unset($fsel, $ftitle, $wheresql, $ob, $obdir, $maxthreads);

// let's get connected
require("last10config.php");
require("$path/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");

$hfs = $fs+2;

should work now. The unset needs to come first else it destroys some of the required variables that were set up in last10config.php
Hope that hasn't defeated the point of the security fix, correct me if I am wrong please, Brad.loo or someone else!

Meza

gator777 03-16-2005 02:56 AM

This worked, but I am still having the issue with the fact that it is not allowing for the DBprefix I added (vb3_). It cannot find the tables. I wish someone could tell me a workaround for this. :)

LamBras 03-19-2005 12:08 PM

I have a problem showing the original author of the thread. Sort by dateline instead of lastpost is working fine. MySQL queries for original author is looking fine to me. :ermm:
Script is located at http://www.dvdboard.de/news.php

I used the code provided in this thread and attached my files below (removed all comments so it's easier to read).

Thank you for any kind of help.


configfile:
PHP Code:

<?
$path = "forum/admin"; // path to your config.php file (usually in the /admin directory) - NO TRAILING SLASH! Do not include "config.php"
$url = "http://www.dvdboard.de/forum"; // URL to your board - NO TRAILING SLASH!
$urlimg = "http://images.dvdboard.de"; // URL to your board's images - NO TRAILING SLASH!
$maxthreads = "20"; // max threads to show. will show less if $last24 or $last7 limits it to less results than this number
$ob = "dateline"; // set to one of the following: replycount , views , lastposter , title , lastpost (lastpost is most popular. it's the thread most recently replied to, then the second-to-last most recent, etc.)
$obdir = "desc"; // which direction to sort? "desc" goes from bottom to top (9 to 1, z to a, etc.). "asc" goes top to bottom (1 to 9, a to z, etc.). if you use lastpost for $ob, leave this set to desc or it will not work correctly!
$last24 = "0"; // 1 = last 24 hours; 0 = all (must set this to 0 if $last7 is set to 1)
$last7 = "1"; // 1 = last 7 days; 0 = all (must set this to 0 if $last24 is set to 1)
$bc1 = "#DCDCDC"; // first alt color
$bc2 = "#CDCDCD"; // second alt color
$hc = "#A3B9D0"; // head background color
$lc = "#000020"; // link color
$tc = "#000000"; // text color
$f = "Verdana"; // font face
$fs = "8"; // font size in points - 8 is normal, 6 is on the small side, 10 on the large side. play around with it. :)
$lastposter = "1"; // show last poster? 1 = yes; 0 = no
$views = "0"; // show view count? 1 = yes; 0 = no
$replies = "1"; // show reply count? 1 = yes; 0 = no
$lastpostdate = "1"; // show last post date and time? 1 = yes; 0 = no
$len = 150; // maximum number of characters of the title to show. e.g. if the title is 60 characters and this is set to 25, only the first 25 characters of the title will be shown (followed by ...)
$excludeforums = ""; // if you want to exclude a forum, put it's ID here. more than one, seperate them with commas, NO SPACES! e.g. 1,2,3,4
$includeforums = "109"; // if you only want to include certain forums, put their ids here. separate more than one with commas, NO SPACES! e.g. 1,2,3,4
$showmessages = "0"; // show the text of the last post too? 1 = yes; 0 = no
$lplen = "300"; // character length of last post text (if $showmessages is set to 0 this won't do anything).
$tw = ""; // width of the table that shows the info, in either a percent ( e.g. 95% ) or in pixels ( e.g. 300 ). leave blank if you want the table to be sized naturally
$showdate = "1"; // show the date, as well as the time? if the posts that show up in the list are likely to all be from today (or you set $last24 to "1"), you can set this to 0. if the posts are spread over multiple days, you probably want this set to 1.
$cs = "0"; // this is the cellspacing. 1 makes a thin line around the cells. 0 makes no line.
$showicon = "0"; // shows the posts' icon next to the post
$showforumtitle = "0"; // shows the forum title (linked to that forum) next to the thread title
$nb = "0"; // do you want breaks in text to appear as such? this may cause problems if there are large breaks in the text
?>

getnews:
PHP Code:

<?
unset($fsel, $ftitle, $wheresql, $ob, $obdir, $maxthreads);

require("getnewsconfig.php");
require("$path/config.php");

$db=mysql_connect($servername,$dbusername,$dbpassword) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");

$boarddown1 = mysql_query("SELECT value FROM setting WHERE varname='bbactive'");
$boarddown = mysql_result($boarddown1,0,0);
if ($boarddown == "0") { echo("Die dvdboard.de News befinden sich aktuell im Wartungsmodus. Bitte versuchen Sie es wieder in ein paar Minuten."); exit; }

$hfs = $fs+2;
$fs .= "pt";
$hfs .= "pt";
if ($tw == "") {
        $twt = "";
} else {
        $twt = "width=\"$tw\"";
}
if ($cs == "") {
        $cs = 0;
}
// start up our table, decide whether to show
echo("<table border=0 cellpadding=4 cellspacing=$cs $twt><tr bgcolor=\"$hc\">\n");
if ($showicon == "1") {
        echo("<td>&nbsp;</td>");
}
echo("<td style=\"font-family:$f; font-size:$hfs; color:$tc;\"><b><nobr>Titel:</nobr></b></td>\n");
// the last poster column,
if ($lastposter == "1") {
        echo("<td style=\"font-family:$f; font-size:$hfs; color:$tc;\" align=\"center\"><b><nobr>Autor:</nobr></b></td>\n");
}
// the last post date & time column,
if ($lastpostdate == "1") {
        echo("<td style=\"font-family:$f; font-size:$hfs; color:$tc;\" align=\"center\"><b><nobr>Datum:</nobr></b></td>\n");
}
// the views column,
if ($views == "1") {
        echo("<td style=\"font-family:$f; font-size:$hfs; color:$tc;\" align=\"center\"><b>angesehen:</b></td>\n");
}
// and/or the replies column
if ($replies == "1") {
        echo("<td style=\"font-family:$f; font-size:$hfs; color:$tc;\" align=\"center\"><b>Kommentare:</b></td>\n");
}
echo("</tr>\n");

// the base WHERE statement
$wheresql = "WHERE thread.postusername=user.username AND thread.open!='10'"; 

// we can't have both the last 24 hours *and* the last 7 days, so error out if needed
if ($last24 == "1" && $last7 == "1") {
        print("Error: \$last24 and \$last7 are both set to 1. Please change one of them to 0.");
        exit;
}
// otherwise we're gonna find out which one it is
// last 24
if ($last24 == "1") {
        $time = time()-86400;
        $wheresql .= " AND thread.dateline>'$time'";
}
// last 7
if ($last7 == "1") {
        $time = time()-2419200;
        $wheresql .= " AND thread.dateline>'$time'";
}
// are we trying to exclude *and* include forums? if so, error out
if ($excludeforums != "" && $includeforums != "") {
        print("Error: \$includeforums and \$excludeforums are both set with numbers. Please remove the numbers from <b>one</b> of these two to proceed.");
        exit;
}
// otherwise figure out which one we're using
// include forums
if ($includeforums == "" or $includeforums <= "0") {
        $quarter = "no";
} else {
        $incfid = explode(",",$includeforums); $i = 0; $a = count($incfid);
        if ($a > 1) {
                $wheresql .= " AND (thread.forumid='$incfid[0]'";
                ++$i;
                while ($i < $a) {
                        $wheresql .= " OR thread.forumid='$incfid[$i]'"; ++$i;
                }
                $wheresql .= ")";
        } else {
                $wheresql .= " AND thread.forumid='$incfid[$i]'";
        }
}
// or exclude forums
if ($excludeforums == "" or $excludeforums <= "0") {
        $quarter = "no";
} else {
        $excfid = explode(",",$excludeforums); $i = 0; $a = count($excfid);
        while ($i < $a) {
                $wheresql .= " AND thread.forumid!='$excfid[$i]'";      ++$i;
        }
}
if ($showforumtitle == "1") {
        $ftitle = ",forum";
        $fsel = ",forum.title AS ftitle";
        $wheresql .= " AND thread.forumid=forum.forumid";
}
// ooh a query!
//$query = "SELECT thread.dateline,thread.title,thread.postusername,thread.replycount,thread.views,user.userid,thread.threadid,thread.forumid$fsel,thread.iconid FROM thread,user$ftitle $wheresql ORDER BY thread.$ob $obdir LIMIT $maxthreads";
$query = "SELECT
thread.dateline,thread.title,thread.postuserid,thread.replycount,thread.views,user.userid,thread.threadid,thread.forumid$fsel,thread.iconid 
FROM thread,user$ftitle $wheresql ORDER BY thread.$ob $obdir LIMIT $maxthreads"; 

// let's get the info
$tr = mysql_query($query) or die("MySQL reported this error while trying to retreive the info: ".mysql_error());
$dtf = mysql_query("SELECT value FROM setting WHERE varname='dateformat' OR varname='timeformat' OR varname='timeoffset' ORDER BY varname");
$df = mysql_result($dtf,0,0);
$tf = mysql_result($dtf,1,0);
$tof = mysql_result($dtf,2,0);
if ($showdate == "1") {
        $fdt = "$df $tf";
} else {
        $fdt = "$tf";
}
$cols = 1;
// let's display the info
while ($threads = mysql_fetch_array($tr)) {
        // are we going to show the message too?
        if ($showmessages == "1") {
                $query0 = "SELECT pagetext,postid,dateline,iconid FROM post WHERE threadid='$threads[threadid]' ORDER BY dateline DESC LIMIT 1";
                $lastpost = mysql_query($query0) or die("MySQL reported this error while trying to retrieve the last post info: ".mysql_error());
                while ($lastpost1 = mysql_fetch_array($lastpost)) {
                        $lastpostshort = $lastpost1[pagetext];
                        $postii = $lastpost1[iconid];
                }
                if (strlen($lastpostshort) > $lplen) {
                        $lastpostshort = substr($lastpostshort,0,$lplen);
                        $lastpostshort .= "...";
                }
                $smilies = mysql_query("SELECT smilietext,smiliepath FROM smilie");
                while ($smiles = mysql_fetch_array($smilies)) {
                        $lastpostshort = str_replace($smiles[smilietext],"<img src=\"".$url."/".$smiles[smiliepath]."\" border=0>",$lastpostshort);
                }
                if ($nb == "1") {
                        $lastpostshort = nl2br($lastpostshort);
                }
                $lastpostshort = str_replace("[i]","<i>",$lastpostshort);
                $lastpostshort = str_replace("[/i]","</i>",$lastpostshort);
                $lastpostshort = str_replace("[u]","<u>",$lastpostshort);
                $lastpostshort = str_replace("[/u]","</u>",$lastpostshort);
                $lastpostshort = str_replace("[b]","<b>",$lastpostshort);
                $lastpostshort = str_replace("[/b]","</b>",$lastpostshort);
                $lastpostshort = str_replace("[quote]","<br>quote:<br><hr> ",$lastpostshort);
                $lastpostshort = str_replace("[/quote]"," <hr><br>\n",$lastpostshort);
                $lastpostshort = str_replace("[I]","<i>",$lastpostshort);
                $lastpostshort = str_replace("[/I]","</i>",$lastpostshort);
                $lastpostshort = str_replace("[U]","<u>",$lastpostshort);
                $lastpostshort = str_replace("[/U]","</u>",$lastpostshort);
                $lastpostshort = str_replace("[B]","<b>",$lastpostshort);
                $lastpostshort = str_replace("[/B]","</b>",$lastpostshort);
                $lastpostshort = str_replace("[QUOTE]","<br>quote:<br><hr> ",$lastpostshort);
                $lastpostshort = str_replace("[/QUOTE]"," <hr><br>\n",$lastpostshort);
                $lastpostshort = str_replace("[CODE]","<br>code:<br><hr> ",$lastpostshort);
                $lastpostshort = str_replace("[/CODE]"," <hr><br>\n",$lastpostshort);
                $lastpostshort = str_replace("[code]","<br>code:<br><hr> ",$lastpostshort);
                $lastpostshort = str_replace("[/code]"," <hr><br>\n",$lastpostshort);
                $lastpostshort = str_replace("[img]","",$lastpostshort);
                $lastpostshort = str_replace("[/img]","",$lastpostshort);
                $lastpostshort = str_replace("[img]https://vborg.vbsupport.ru/[/img]","",$lastpostshort);
                $lastpostshort = str_replace("[url]","",$lastpostshort);
                $lastpostshort = str_replace("[/url]","",$lastpostshort);
                $lastpostshort = str_replace("[URL]","",$lastpostshort);
                $lastpostshort = str_replace("[/URL]","",$lastpostshort);
        }
        // thanks to kier for this idea to do the alternating row colors
        if (($counter++ % 2) != 0) {
                $bc=$bc1;
        } else {
                $bc=$bc2;
        }
        // if the title is more than $len characters, we need to cut it off and add ... to the end
        if (strlen($threads[title]) > $len) { 
                $title = substr($threads[title],0,$len);
                $title .= "...";
        } else { 
                $title = $threads[title];
        }
        // convert the date to a format readable by non-unix geeks :)
        $fd = date($fdt,$threads[dateline]); 
        // display everything in a nice table. in the future we're gonna try to do this so others can format the data, but this is sufficient for now
        echo("<tr>");
        if ($showicon == "1") {
                echo("<td bgcolor=\"$bc\">");
                if ($postii != "0" && $postii != "") {
                        echo("<img src=\"$urlimg/icons/icon$postii.gif\" border=\"0\">");
                }
                if (($postii == "0" || $postii == "") && $threads[iconid] != "0" && $threads[iconid] != "") {
                        echo("<img src=\"$urlimg/icons/icon$threads[iconid].gif\" border=\"0\">");
                }
                if (($postii == "0" || $postii == "") && ($threads[iconid] == "0" || $threads[iconid] == "")) {
                        echo("&nbsp;");
                }
                echo("</td>");
                ++$cols;
        }
        echo("<td bgcolor=\"$bc\" style=\"font-family:$f; font-size:$fs; color:$tc;\"><nobr>");
        if ($showforumtitle == "1") {
                echo("<a href=\"$url/forumdisplay.php?forumid=$threads[forumid]\" style=\"color: $lc;\">$threads[ftitle]</a>: ");
        }
        echo("<a href=\"$url/showthread.php?threadid=$threads[threadid]\" style=\"color: $lc;\" title=\"$threads[title]\">$title</a></nobr></td>\n");
        // last poster column?
        if ($lastposter == "1") {
                echo("<td bgcolor=\"$bc\" style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"center\"><a href=\"$url/member.php?action=getinfo&userid=$threads[userid]\" style=\"color: $lc;\">$threads[lastposter]</a></td>\n");
                ++$cols;
        }
        // the last post date & time column,
        if ($lastpostdate == "1") {
                echo("<td bgcolor=\"$bc\" style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"center\">$fd</td>\n");
                ++$cols;
        }
        // views column?
        if ($views == "1") {
                echo("<td bgcolor=\"$bc\" style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"center\">$threads[views]</td>\n");
                ++$cols;
        }
        // replies column?
        if ($replies == "1") {
                echo("<td bgcolor=\"$bc\" style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"center\">$threads[replycount]</td>\n");
                ++$cols;
        }
        echo("</tr>");
        // are we showing the last post?
        if ($showmessages == "1") {
                echo("<tr bgcolor=\"$bc\"><td colspan=\"$cols\" style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"left\">\n");
                echo("<table border=0 cellpadding=4 cellspacing=0 width=\"100%\">\n");
                echo("<tr bgcolor=\"$bc\"><td style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"right\" valign=\"top\"><b><nobr>Last Post:</nobr></b></td>\n");
                echo("<td style=\"font-family:$f; font-size:$fs; color:$tc;\" align=\"left\" width=\"100%\">$lastpostshort</td></tr>\n");
                echo("</table></td>\n");
        }
        $fd = "";
}
echo("</tr></table>");
?>



Edit: To answer myself, look for $threads[lastposter] and replace it with $threads[postusername]. Stupid me. :)

knirketusken 04-14-2005 03:58 AM

Quote:

Originally Posted by gator777
This worked, but I am still having the issue with the fact that it is not allowing for the DBprefix I added (vb3_). It cannot find the tables. I wish someone could tell me a workaround for this. :)

I have the same issue with the DB prefix. I have tried to edit last10.php, but have not had any luck yet. I suppose it would be an idea for the developer to make a "DBprefix"-choice in last10config.php so that all of us that where "stupid" enough to choose a prefix during install can use this very useful hack


All times are GMT. The time now is 10:14 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.01597 seconds
  • Memory Usage 1,875KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete