PDA

View Full Version : Last topics in phpnuke....


BramT
10-11-2001, 01:36 PM
I've been trying to use the Last XX posts script ( http://www.vbulletin.com/forum/showthread.php?threadid=12324 ) in PHP Nuke...

I've tried putting <? include("last10.php"); ?> in a block (as text)

and using a custom block with the following code:
<?php

if (eregi("block-LastPosts",$PHP_SELF)) {
Header("Location: index.php");
die();
}

$content = "<? include('www.vhvn.net/vhvn/forums/last10.php'); ?>";

?>

but none of them give any output... all paths are correct (used relative and absolute variations) and the last10.php script runs correctly as wel...

anyone knows a sollution for this? I've been searching the forums but i haven't found a decent solution yet... :(


using phpnuke 5.2

BramT
10-11-2001, 03:10 PM
I've found what's causing the problem myself...

putting <? include("last10.php"); ?> in a text-block is the correct solution....

BUT: the problem is caused by some lazy-programming in THEME.PHP file of your phpnuke's theme:

Look for/************************************************** **********/
/* Function themesidebox() */
/* */
/* Control look of your blocks. Just simple. */
/************************************************** **********/
at the end of the THEME.PHP file

there should be a statement somewhere (in the middle) saying echo $content
it might be surrounded by other code....

You'll have to issolate the "echo $content" statement and replace it with:
if (substr($content,0,2) != "<?") echo $content;
else {
$content = str_replace ("<?", "", $content);
eval($content);}
Now you can use the "<? include" statement to include ANY PHP file...

mkilty
10-11-2001, 08:04 PM
Ok I am having trouble here. Where would you put the code for it to work.

Here is the snippet of code from my themebox -
===================
function themesidebox($title, $content) {
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#eeeeee\" width=\"150\"><tr><td>\n"
."<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"150\">\n"
."<tr>\n"
."<td><img src=\"themes/Somara-Platinum/images/sideBoxTop.gif\"></td>\n"
."</tr>\n"
."</table>\n"

."<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\" width=\"100%\">\n"
."<tr><td bgcolor=\"#CACACA\" align=\"center\">\n"
."<font size=\"2\" color=\"#363636\"><b>$title</b></font>\n"
."</td></tr>\n"
."<tr>\n"
."<td bgcolor=\"#eeeeee\">$content</td>\n"
."</tr>\n"
."</table></td></tr></table>\n"
."<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"150\">\n"
."<tr>\n"
."<td><img src=\"themes/Somara-Platinum/images/sideBoxBottom.gif\"></td>\n"
."</tr>\n"
."</table>\n"
."<br>\n\n\n";
}

?>

=========================

BramT
10-11-2001, 08:18 PM
allright...

replace this

."<tr>\n"
."<td bgcolor=\"#eeeeee\">$content</td>\n"
."</tr>\n"
EXACTLY with this:

."<tr><td bgcolor=\"#eeeeee\">\n";
if (substr($content,0,2) != "<?") echo $content;
else {$content = str_replace ("<?", "", $content);
eval($content);}
echo "</td></tr>\n"


good luck! (reply here if it doesn't work.. i'll receive an e-mail automaticly...)

(you might want to check out www.vhvn.net to see my phpNuke & vBB site to see what else i've come up with in the past 4 days.. :p)

mkilty
10-11-2001, 08:39 PM
First I want to say "Thanks" for your help on this.

I applied the change to the code and it works. But I now get an error with the center of the home nuke page being blank. This is the error:

Warning: Supplied argument is not a valid MySQL result resource in /usr/local/www/html/vbportal/html/mainfile.php on line 145
1146: Table 'vbullet.nuke_stories' doesn't exist

When I put the theme.php file back to default the site works correctly again.

Idea's?

Also I would love to know if you were able to hack Nuke to use the vB database for users....I hate to have my members register twice etc...

BramT
10-11-2001, 09:09 PM
Warning: Supplied argument is not a valid MySQL result resource in /usr/local/www/html/vbportal/html/mainfile.php on line 145
1146: Table 'vbullet.nuke_stories' doesn't exist

this DOES seems like an error in the php file you are trying to include... it can't reach it's database or the name of the table is screwed somehow... (vbullet.nuke... :confused: access you sql server and see if this table really excists..)

(are you using phpnuke or vbportal btw? coz it says .../vbportal/html/... in the errormsg..)

anyways... try to run the php file your are trying to run on it's own... (by entering it's url in your browser). If it doesn't run correctly: there's your problem.. :rolleyes:

if it DOES run correctly, note this: the paths used in the php file you are trying to run should be relative to the path where the index.htm file of phpnuke resides...

dunno if you get this, so here's an example:

my phpnuke index.php is in : /vhvn
the file i'm including is in : /vhvn/forums
the file i'm including needs a file in /vhvn/forums/admin

in the file i'm including there's an include statement, pointing to the file it needs... normally this should be ./admin/file.php. If i do this, i can run the file correctly from /vhvn/forums.

But since i'm actually run this php file from /vhvn the path should be ./forums/admin/file.php. Now, if i do this, the php file i'm including does NOT run correctly (on it's own) from /vhvn/forums but it DOES run correctly from /vhvn. And that's what we want...


uhm... now i'm not sure if this example made it any clearer to you... :o You can forget about this example anywayz if both files (index.php and the file you are trying to include) are in the same dir.

so.. you should check out what i mentioned before:
try to run the php file your are trying to run on it's own... (by entering it's url in your browser). If it doesn't run correctly: there's your problem..

(don't you just love those quote tags.. :D)

note: don't expect to much from me either... i've been using mysql and php for only a few days.. (but i'm a quick learner though.. ;))


by the way.. what do you think of my site? www.vhvn.net
and post your url too... i might have some suggestions.. ;)

mkilty
10-11-2001, 09:21 PM
I'll check it out with the relative paths. I currently have the "topposters" $path variables with absolute paths as well as the "include" statement.

The URL with the vbportal in its path is just a holdover from running vbportal as a test. It really is the document root for my server. :)

Check my site out on www.clublexus.com - I have the latest posts working on the front page not thru .php but thru javascript code.

I'll post back on the results.....

Thanks,

Michael

BramT
10-11-2001, 09:29 PM
really cool intro, i must say....!!!:eek:

javascript is also an option.. ofcourse.. ;) but i wanted my site in 100% PHP this time... so... i didn't even consider it... hehe.. my fault...

good luck!

if anyone still has problems with this, reply here and i'll come to the rescue.... LOL :rolleyes:

mkilty
10-11-2001, 10:16 PM
Hmmm...

I am still getting that error. The code works great. I've created a page called test3.php - http://www.clublexus.com/html/test3.php

Which works great on it's own. It will work on my nuke site as well but the error call is referencing to the wrong database. vbullet is my forum database but the nuke database is called chr so the "mainfile.php" seems to be getting the wrong database in it's $db variable after running the include file.

I'll try out other code but this is frustrating...

BramT
10-11-2001, 10:49 PM
i think something in your php file (test3.php) is making a "relative" call to your database... allowing phpnuke to add it's own tag in front of it...

i think you should try to look for the call in the test3.php file and see if there are any variables in front of it... and remove them.. making it an "absolute" call...

if you know what i mean... :confused:

apollyon
10-12-2001, 12:31 AM
i just put the last XX posts in the index file right above where the news pasts go

look here it works fina and looks good
http://www.darkdimensionsonline.com/test/

but i need help on another front for php-nuke: is there any way to add more categories to php-nuke downloads and link sections?

like right now it only supports 2 layers like MP3's > Techno

but i want more layers like this MP3's > Heavy > Tool > CDS

since i have sooo many downloads to add i need to categorize them into many different and specialized categories.

mkilty
10-12-2001, 04:19 AM
Originally posted by BramT
i think something in your php file (test3.php) is making a "relative" call to your database... allowing phpnuke to add it's own tag in front of it...

i think you should try to look for the call in the test3.php file and see if there are any variables in front of it... and remove them.. making it an "absolute" call...

if you know what i mean... :confused:

The only way I was able to fix it was to put the block on the right-hand side of the page. I figure since whatever variable was playing havac with the center page it should bypass it with the block on the rightside.

Michael

BramT
10-12-2001, 03:33 PM
you must be joking... :eek:

the solution i gave (the second post) ONLY works for the 'blocks'... left or right doesn't matter.... i haven't looked at the php code for the 'center page' at all.. :p

but anyways... you've got it fixed... so... enjoy! :D

mkilty
10-12-2001, 03:55 PM
Originally posted by BramT
you must be joking... :eek:

the solution i gave (the second post) ONLY works for the 'blocks'... left or right doesn't matter.... i haven't looked at the php code for the 'center page' at all.. :p

but anyways... you've got it fixed... so... enjoy! :D

Thanks for your help in this. If you ever find out how to implement PHP in the message section let me know.

I found a hack that seems to integrate the registration of users with vB and phpNuke at this thread:
http://www.vbulletin.com/forum/showthread.php?threadid=27932

Have not tried it out et as their seems to be some question to it working but thought you might want to see it.

Michael

BramT
10-12-2001, 04:10 PM
i've looked at the code, yes...

but i'm not sure if it is what i want... i'd like people to sing up @ my nuke site... not at vbb...

i'm going to take a look at this soon.... but it's going to take a while (got a lot of work to do...)

but when i find a solution.. it's going to be a better one... :D LOL

c u next time!

jasoncorn
10-13-2001, 02:32 PM
Hey, my PHP-Nuke theme is this:
function themesidebox($title, $content) {
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"150\">\n"
."<tr><td width=\"150\" colspan=\"3\">\n"
."<img border=\"0\" src=\"themes/UltraSteel_NoFlash/images/menu2_01.gif\" width=\"150\"></td>\n"
."</tr><tr><td width=\"17\" background=\"themes/UltraSteel_NoFlash/images/menu2_02.gif\">&nbsp;</td>\n"
."<td width=\"114\" bgcolor=\"#FFFFFF\" valign=\"top\">\n"
."<b>.: $title</b><br>\n"
."$content"
."</td>\n"
."<td width=\"19\" background=\"themes/UltraSteel_NoFlash/images/menu2_04.gif\">&nbsp;</td>\n"
."</tr><tr><td width=\"150\" colspan=\"3\">\n"
."<img border=\"0\" src=\"themes/UltraSteel_NoFlash/images/menu2_06.gif\" width=\"150\"></td>\n"
."</tr></table><br>\n";
}
?> What should I edit?

mkilty
10-14-2001, 09:48 AM
Originally posted by BramT
i've looked at the code, yes...

but i'm not sure if it is what i want... i'd like people to sing up @ my nuke site... not at vbb...

i'm going to take a look at this soon.... but it's going to take a while (got a lot of work to do...)

but when i find a solution.. it's going to be a better one... :D LOL

c u next time!

I figured out the solution to why I kept getting errors when I had a PHP block on the right-hand side.

What I did was combine the two databases (phpNuke and vB) into one database which solved the problem. It seemed that the php code in nuke was referencing the wrong database so causing the script to break.

Instead of looking thru the code for the problem it was easier to combine both databases into one.

Thanks,

Michael

dadymac
10-22-2001, 04:20 PM
bringing this back from the grave, i too got errors for the center page, looking closely its cuz the code we replace screws up the tables in relation to what is in sql.

moving it to the right at the bottom of the color DOES fix it, why?

because there are no more tables below it to screw up. try moving it towards the top, errors galore.

oh well, it works, using it for online.php for who is online.

BramT
10-22-2001, 09:38 PM
mkilty:

yes.. i also used a single database to for PHPnuke and VB... works great... (no overlapping tables etc..)

daymac:

i think you made an error with replacing the php code for the ThemeSideBox function. The solution i gave should work. It works with me... ;) Make sure you didn't make any 'typos'....

BramT
10-22-2001, 09:43 PM
jasoncorn:

your solution is pretty simple:

replace

."<b>.: $title</b><br>\n"
."$content"
."</td>\n"

with

."<b>.: $title</b><br>\n";
if (substr($content,0,2) != "<?") echo $content;
else {
$content = str_replace ("<?", "", $content);
eval($content);}
echo "<td>\n"

like i told ya in my second post... :p

sorry for the late reply btw.... i've been away for a while...

post here again if anyone needs help with phpnuke (and vb integration).

c-ya!

dadymac
10-23-2001, 06:30 PM
here is the original code:
."<tr valign=\"top\"><td bgcolor=\"#000000\">\n"
."$content\n"
."</td></tr></table>\n"

here is what i changed it to:

."<tr valign=\"top\"><td bgcolor=\"#000000\">\n";
if (substr($content,0,2) != "<?")
echo $content; else { $content = str_replace ("<?", "", $content);
eval($content);}
echo "</td></tr></table>\n"


here is what I am trying to include:


<?php

if (eregi("block-LastPosts",$PHP_SELF)) {
Header("Location: index.php");
die();
}

$content = "<? include('forum/admin/online.php'); ?>";

?>


and here is online.php:


<?
//...........Who's Online v0.0.2...........\\
//......by Kevin (kevin@tubescan.com)......\\

// For vBulletin version 2, beta 3
// (c) 2001 Jelsoft Enterprises, Ltd.

// vbulletin.com thread: http://www.vbulletin.com/forum/showthread.php?threadid=12010

///////////// CHANGE LOG /////////////
//
// New in version 0.0.2
// -- Option to display either usernames or just a number of registered members online
//
// New in version 0.0.1
// -- Released! :)
//
/////////// END CHANGE LOG ///////////

//////// CONFIG EXPLANATION //////////
//
// There are only two config options in this script.
// First is whether or not you want usernames displayed for registered members who are on the board. If you opt to not display
// usernames, it will simply display the number of members. Guests are unaffected by this. If you want usernames displayed, set
// $usernames to "on" in the CONFIG section below. If you want a simple number, set it to "off".
// The second is the path to config.php (in the /admin directory of your forums). It MUST NOT include a leading *or* trailing slash.
// So, for example: Your config.php is in
// /home/mysite/public_html/board/admin/
// and you are putting this file into
// /home/mysite/public_html/directory/
// So your path is
// /home/mysite/public_html/board/admin
// Make sure you set this correctly. You can refer to the General Options in your Admin Control Panel if you need a refresher on
// your path.
//
////// END CONFIG EXPLANATION ////////

/////////////// CONFIG ///////////////
//
$usernames = "on"; // if you would like it to display the names of registered members who are on, leave this set to "on".
// if you want just a number of members, change it to "off".
$path = "/home/dadymac/public_html/forums/forum/admin"; // set the path to your admin directory. see above for info about this.
//
///////////// END CONFIG /////////////

require("$path/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);

$cookievalue = mysql_query("SELECT value FROM setting WHERE varname = 'cookietimeout'") or die("oops1");
$cookietimeout = mysql_result($cookievalue, 0, 0);
$datecut = time()-$cookietimeout;

$invisibleregmember = "0";

if ($usernames == "on") {
$regmembers = mysql_query("SELECT DISTINCT username,invisible FROM user,session WHERE session.userid=user.userid AND session.lastactivity>$datecut AND invisible='0' ORDER BY username ASC") or die("oops2");
while($regmember = mysql_fetch_array($regmembers)):
++$regmembercomma;
if ($regmember[invisible] == 0) {
$regmemberson .= $regmember[username];
} else {
++$regmembercomma;
}
if ($regmembercomma < mysql_num_rows($regmembers)):
$regmemberson .= ", ";
endif;
endwhile;
} else {
$regmembers = mysql_query("SELECT DISTINCT COUNT(userid) AS membersonline FROM session WHERE userid>0 AND session.lastactivity>$datecut") or die("oops2");
while($members = mysql_fetch_array($regmembers)) {
$regmemberson = number_format($members[membersonline]);
}
}

$guests = mysql_query("SELECT COUNT(userid) AS guestsonline FROM session WHERE userid=0 AND session.lastactivity>$datecut") or die("oops3");
while($guest = mysql_fetch_array($guests)):
$guestson = number_format($guest[guestsonline]);
endwhile;

echo("<B>Member(s) currently in the forums:</B><br><br><font color=\"#CCCCFF\">$regmemberson</font><br><br><B>Number of Guest(s) in the forums:</B> $guestson.");
?>


is there a conflict somewhere? in the left colum, it will mess up the center.

in the right, it works, but i cant have it above certain blocks.

i guess its ok, i have it i the right bottom, at least it is there

BramT
10-23-2001, 06:58 PM
here is what I am trying to include:


quote:
--------------------------------------------------------------------------------

<?php

if (eregi("block-LastPosts",$PHP_SELF)) {
Header("Location: index.php");
die();
}

$content = "<? include('forum/admin/online.php'); ?>";

?>


don't use a seperate block.... just include

<? include('forum/admin/online.php'); ?>

as text in a textblock (when adding a new custom block). you don't have to use modules/blocks...

dadymac
10-23-2001, 07:19 PM
same, still get:

Warning: Supplied argument is not a valid MySQL result resource in /home/dadymac/public_html/forums/admin/modules/blocks.php on line 43

dadymac
10-23-2001, 07:22 PM
actually, it doesnt work on the left....but yes it works on the right.

lol, oh well, maybe all my includes will be the right side, at least it (sorta) works for me

BramT
10-23-2001, 07:34 PM
strange....

cant find whats causing this.... let me know if u do!

kontrabass
07-09-2002, 08:17 PM
There's a MUCH easier way of doing this. Go back to the original post's idea of making a custom block, and put this in it:

<?
if (eregi("block-Sample_Block.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}

$file = fopen ("http://www.path_to.your/last10.php", "r");
while (!feof ($file)) {
$content = fread ($file, 20000);
}

?>

VOILLA! just save that as block-whatever.php in your blocks folder, then include it as a phpnuke block. The 20000 is a number I picked - it has to do with how far php reads the file (how many bytes). If the number is too low it'll cut off the output.

wooolF[RM]
07-24-2002, 11:18 PM
using your replacement BramT in theme, then using your way of including a php file, then I get error:
Parse error: parse error, unexpected T_IF in /home/wooolf/WWW/phpnuke/themes/OceanBlue/theme.php(358) : eval()'d code on line 3
where line 358 is:
eval($content);}
Any ideas? I'm lost... :(

PS: the php page which I include works fine when I use direct access to it...

PSS: vBB 2.2.6 | phpNuke 5.5