PDA

View Full Version : News Out - posts from forum(s) on any page


Rafe
05-13-2004, 10:00 PM
This script will let you pull the first posts from threads in a forum and display them on a non-vb page anywhere on your site.

For example you can use this to pull posts from a forum and display them as news. (Each post in the forum is a news item).

Currently it will pull them on the basis of thread start date.

This is very rough and ready. But maybe someone will find it useful.

If you read the code and comments you can do things like strip out tags, snip the post off after the first para etc etc.

You can choose to write out to a file or to write to screen. You can pull stuff from one or many forums.

I'll try and answer any questions that come up, but this is a beta so....

Rafe

Boofo
05-14-2004, 04:12 PM
Any screenshots? ;)

Rafe
05-14-2004, 04:22 PM
I didn't think there was much point. It pulls the text and images (and any stuff from the post). The intention is you integrate into other pages.

I use it to power various things at my site - http://www.allaboutsymbian.com

Thew news there is done like this.

mOdEtWo
05-15-2004, 12:24 AM
Thank you Rafe, I'll try it out.

One thing tho, why don't you use the vb function to connect to mysql database, instead of putting it into this script?

Rafe
05-15-2004, 10:30 AM
Thank you Rafe, I'll try it out.

One thing tho, why don't you use the vb function to connect to mysql database, instead of putting it into this script?
I should do, but I'm not familiar enough with how to do it. If I ever move this on to a proper release that's one of the things I would do. I guess I should look at the code for some similar connections (suggestions anyone?)

GamerJunk.net
05-15-2004, 12:46 PM
Is this like VBAdvanced?

wrongful
05-15-2004, 07:33 PM
excuse me for the dumb question but what would be the best way to embed this content into a page.

mOdEtWo
05-15-2004, 08:45 PM
I should do, but I'm not familiar enough with how to do it. If I ever move this on to a proper release that's one of the things I would do. I guess I should look at the code for some similar connections (suggestions anyone?)
Well, as far as I know, you can use vB's way to connect to the mysql database, instead of having to use sql quesies yourself.

$sql_news = $DB_site->query("SELECT thread....... +++

You better look at one of the vB files or other hacks on how to use it tho. ;)

Rafe
05-15-2004, 10:34 PM
Is this like VBAdvanced?

No. This isn't a portal system. You can use it to create a portal like affect. Its more flexible in that you have more choice in what you pull, but it take more time to set up.

Rafe
05-15-2004, 10:36 PM
excuse me for the dumb question but what would be the best way to embed this content into a page.

You could either copy this code into the relevant file or include this file in another page, or you could write out to a file and include that in the relevant file.

Obviously copy / include where you want the code to appear and edit appropriately.

nicholas
05-17-2004, 10:33 AM
Thank you, Rafe. This is just right and I'll use it. I've been looking for something like this as an alternative to the portal-with-everything hacks.

gfxmods
05-17-2004, 10:33 AM
this may be the solution to my site, i have been using a portal and im thinking of creating a new layout and using somthig along these lines for a news page, that way my site is more unique then another vb portal page

Rafe
05-17-2004, 08:13 PM
this may be the solution to my site, i have been using a portal and im thinking of creating a new layout and using somthig along these lines for a news page, that way my site is more unique then another vb portal page
Remember this is a beta release. I'l try and do some tidying up and add a few features / make things a bit more elegant in the next release (need to find some time).

Geographic2
05-18-2004, 12:03 AM
This would be better as an addition to external.php rather than a seperate file.

External.php provides the functionality for XML,RSS, and the like for exactly this purpose.

The difference between what you are doing and that is you show the content of the posts whereas they show only thread titles.

Still it'd be more in line if it were an addition to external.php than a seperate file.

Rafe
05-18-2004, 09:52 AM
Perhaps so. However this is still a beta. In theory there's a lot of extra functionality I may add (depends on time etc.)

There's advantage to combing with external.php but there are also advantages in install terms of just uploading one new file.

Maybe the best approach would be to call in external2.php to make it clear what it does?

Still thanks for your feedback.

Rafe

This would be better as an addition to external.php rather than a seperate file.

External.php provides the functionality for XML,RSS, and the like for exactly this purpose.

The difference between what you are doing and that is you show the content of the posts whereas they show only thread titles.

Still it'd be more in line if it were an addition to external.php than a seperate file.

iggy123
05-18-2004, 04:14 PM
when i try and call this using the <?include ('newsout.php');?> I get the following error message:

Unable to add cookies, header already sent.

any ideas?

Draco
05-20-2004, 05:17 PM
when i try and call this using the <?include ('newsout.php');?> I get the following error message:

Unable to add cookies, header already sent.

any ideas?
I have the same problem?
any ideas what we can do?

pressoir
06-03-2004, 01:07 PM
I got a blank screen after following the instructions

jugo
06-09-2004, 01:16 PM
I get enws...only thing is that I also get this at the end....

Warning: mysql_query(): 1 is not a valid MySQL-Link resource in /home/s3/public_html/portal/includes/db_mysql.php

jugo
06-09-2004, 01:42 PM
Fixed my own issue....I commented out these two lines from the code.
//disconnect
mysql_free_result($sql_result);
mysql_close($connection);

007
06-10-2004, 04:54 AM
Very cool. I was actually planning to code this exact idea when I just now saw yours. I will definately check it out. :)

007
06-12-2004, 08:16 PM
This doesn't seem to work. I put it in my forums directory and left the change directory lines commented out. There also didn't seem to be any place to select which forum(s) to pull posts from.

I tried opening the file at forums/newsout.php directly and all I got was a white page..

FWF
06-21-2004, 10:47 AM
you should do a full release of this...it would be useful however its to "iffy" for me to test out on my site as a BETA release...but it looks promising

Rampag33
06-21-2004, 05:35 PM
I get a blank page.

specifiy news at the bottom
@writenews("50,53", "outputfile.txt","5");

-=Sniper=-
06-29-2004, 04:34 PM
it worked once for me, and now trying again doesnt work at all? any updates to the script? or can you helpout? regards

-=Sniper=-
07-17-2004, 03:28 PM
getting an error @ www.zone365.com at the bottom of the page?

-=Sniper=-
07-21-2004, 05:38 PM
anyone?

archangelsk
07-31-2004, 04:09 AM
woot, this is great. just what i needed, w/o all the excess fat of a portal system.

JunkAnime
08-24-2004, 03:39 PM
When I try to use this I get a blank page... Does anybody have a clue what I might be doing wrong?

Edit By the way I followed the directions of the script.

eLiTeGuRu
08-24-2004, 06:35 PM
I followed the directions and it says Query Could not be Executed.

AlexSFBay
09-04-2004, 06:36 PM
Wow, you've read my mind. I've been piecing together a bunch of hacks to come up with something like this. I've downloaded it and I'll give you my thoughts on how the process went for me. In any case, excellent work, and it's very much appreciated!

AlexSFBay
09-04-2004, 09:01 PM
The script works, but I'm getting errors at the end


Warning: mysql_query(): 5 is not a valid MySQL-Link resource in /home/ehomeu2/public_html/forums/includes/db_mysql.php on line 212

Warning: mysql_error(): 5 is not a valid MySQL-Link resource in /home/ehomeu2/public_html/forums/includes/db_mysql.php on line 357

Warning: mysql_errno(): 5 is not a valid MySQL-Link resource in /home/ehomeu2/public_html/forums/includes/db_mysql.php on line 358


Any thoughts on how I can resolve this?

-=Sniper=-
09-05-2004, 09:58 PM
I get the same error! if someone can do me a similar hack! which allows me to use smilies, etc etc

then please contact me!

Viruseater
09-13-2004, 06:58 PM
Wouldn't it be easier if you used

require_once("./includes/config.php");

that way you wouldn't need to use all the hard codes.

AlexSFBay
09-15-2004, 05:47 AM
I randomly get "Unable to add cookies, header already sent." Any ideas how can fix that?

AlexSFBay
09-15-2004, 06:46 AM
I figured it out! After a couple hours of tweaking my script, I finally figured out that

chdir('forums/');
require_once('./global.php');

needs to be located right at the very top (before any other additional PHP code -- ie header.php) in order to avoid the cookie error message.

eLiTeGuRu
09-16-2004, 01:18 AM
After messing around with this code, I realized that if you have a table prefix, it will not work. Therefore do this:

Find around line 45

$sql = "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid IN ($cats) AND sticky = '0' ORDER BY threadid DESC LIMIT $newsitems";

Change to:

$sql = "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM YOURTABLEPREFIX_thread WHERE forumid IN ($cats) AND sticky = '0' ORDER BY threadid DESC LIMIT $newsitems";

Find Line 67
$sql2 = "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";

Change to:

$sql2 = "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM YOURTABLEPREFIX_post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";

and

Find around line 104

$sql3 = "SELECT title FROM forum WHERE forumid = \"$forumid\" LIMIT 1";

Change to

$sql3 = "SELECT title FROM YOURTABLEPREFIX_forum WHERE forumid = \"$forumid\" LIMIT 1";

-=Sniper=-
09-21-2004, 03:09 PM
The script works, but I'm getting errors at the end


Warning: mysql_query(): 5 is not a valid MySQL-Link resource in /home/ehomeu2/public_html/forums/includes/db_mysql.php on line 212

Warning: mysql_error(): 5 is not a valid MySQL-Link resource in /home/ehomeu2/public_html/forums/includes/db_mysql.php on line 357

Warning: mysql_errno(): 5 is not a valid MySQL-Link resource in /home/ehomeu2/public_html/forums/includes/db_mysql.php on line 358


Any thoughts on how I can resolve this?


ok, I moved to a new server and its working fine! maybe its something to do with the server settings?

Dan
09-21-2004, 07:25 PM
Hmm.... interesting mod. I could use this to work on a new custom portal. thanks for sharing it!

lcryan
09-25-2004, 03:01 PM
<a href="http://www.liquid-core.net/forums/news.php" target="_blank">http://www.liquid-core.net/forums/news.php</a>

I'm getting 'Could not execute query.'

Johnny
09-25-2004, 05:43 PM
have you did any changes in the mod except the database info and the file location?

lcryan
09-25-2004, 06:49 PM
have you did any changes in the mod except the database info and the file location?
no.....

eLiTeGuRu
10-07-2004, 01:57 AM
does your vb db use a prefix? If so see my previous post.

madhouse
10-07-2004, 04:36 AM
Nice hack man but I do have one question for ya , its pulling the post thread as if it was in a forum link , and not displaying the entire post like it should.

http://ladders.modcentral.us/

which is pulling the info from http://forum.modcentral.us

You will see it has the link but the link is also pulling to the wrong page also.....

Everything else is working fine thou....

House_of_Crazed
10-07-2004, 06:12 AM
madhouse - you got this working??

*wonders* Wanna help us out? LOL

I've been trying to figure this out for days ... :( *laughs*

EDIT:

Maybe I should have explained what I'm having trouble with, lol.

I'm trying to figure out what and how exactly am I supposed to merge this file into a VB-Powered but outside the forums page... I've tried everything I could think of, lol ... $towrite, $writenews, and so on...

madhouse
10-09-2004, 03:33 PM
First did you make sure you have your paths set correctly?

Second make sure you read thru the entire script as there are certain things you need to uncomment in order for it to work.

House_of_Crazed
10-10-2004, 10:56 PM
Yes.

The custom portal is outputting the posts, but not where I want it to be outputted to. It needs to be at a specific spot, and so far, it's being a pain. :(

You got it working on your site, so it should be working fine here. I have gone over the script like 50 times.

madhouse
10-10-2004, 11:49 PM
Depends were you are inplementing the script line on your page

House_of_Crazed
10-11-2004, 12:04 AM
Question tho...

Should I have commented the echo $towrite; line ?

Then put $towrite where I want it to be at ??

Because I did try that and it just didn't do what i wanted it to do. :(

LOL

madhouse
10-11-2004, 12:16 AM
Where are you doing this at so I can look at it.

Also you using <?include ('newsout.php');?>

House_of_Crazed
10-11-2004, 12:31 AM
<a href="http://www.houseofcrazed.com/front.php" target="_blank">http://www.houseofcrazed.com/front.php</a>

It's only a page in development. It've been bugging me for a bit.

I put that in just now. It's outputting, but not in the specific spot where I want it to be at.

madhouse
10-11-2004, 12:35 AM
Looks like you have the script in the wrong location of the template...

Now how did you get the text to out put? I got everything else to work but can not get the text from the post to show.....

House_of_Crazed
10-11-2004, 12:40 AM
Uh, lol ...

I included the file at the top of front.php before along with global.php and so on...

Since we both are having problems too, guess someone else will need to help us, lol ...

But now, I just realized... The file is being declared twice now. *sigh*... Once in the front.php file and once in the template. lol ... I'm pretty sure that it's in front.php that's being declared, not the one in template.

madhouse
10-11-2004, 12:42 AM
See , you are using a templated system , I am not , so some were along the lines there is something I am missing from calling the actuall post instead of just the title and the creator of the post.

House_of_Crazed
10-11-2004, 12:45 AM
Yea...

I'm thinking of other ways to do this now... lol ...

If you link directly to the newsout.php page, does it spit out the post and stuff like it does on mine?

House_of_Crazed
10-11-2004, 06:15 AM
I finally got this to work, LOL

Oh, wait, you're not using the template system. :| Because I got mine to work by adding the require code to phpinclude_start template.

madhouse
10-11-2004, 12:31 PM
Yea mine is working but its not displaying the post text....

hkvic
10-12-2004, 12:02 PM
I've got this working fine in my index.shtml test homepage by using
"<!--#include virtual="/testvb/newsout.php"-->" command where I want it to display.

One problem though, where do I specify which forum the news is pulled from? At the moment it's pulling it from a forum I haven't specified :surprised:

Any help appreciated.

madhouse
10-12-2004, 12:25 PM
You need to look thru the newsout.php and find were its defining the forums you want to have the news pulled from , if I remeber correctly it should be close to the bottom of the script.

Truthfully Rafe has not replied on this hack since May, 2004 so I got the feeling that he may not be around or not supporting this hack any longer.

hkvic
10-12-2004, 02:43 PM
Got it working perfectly now thanks - apart from if there is a smilie in the post, it shows as a broken image in the exported output when page first loads or is refreshed. Not a major problem as I can always NOT use smilies!

Example here (please ignore the awful layout - still being worked on)
http://www.saintgeorges-hk.com/sgs/ (Example of output.)

House_of_Crazed
10-12-2004, 05:01 PM
Well, it probably is the forumspath that has not been defined correctly.

Look for $forumspath

Smilies works fine on my site. It took me awhile to figure it out, lol ... *sigh* I'm happy I'm done with figuring it out. *laughs*

hkvic
10-12-2004, 06:06 PM
Hmmm. the smilies are there if you view the newsout.php output, but disappear once the file is included into the .shtml page :confused:

dfmafia
11-18-2004, 06:10 PM
having problems...i really want this to work properly...

here goes:

http://dfmafia.net/forums/newsout.php <-- works fine

http://dfmafia.net/network1.php <--- inop (its after the text "Need to fix the News script that when it grabs the articles out of the forums we don't loose right content ")

heres the code im using to include the newsout.php:

<?php
include('/THE/DIRECTORY/TO/forums/newsout.php');
?>

(its after the text "Need to fix the News script that when it grabs the articles out of the forums we don't loose right content ")



that first NEWS block works fine but all it did was grab the titles...i want part of the text as well...


http://dfmafia.net/network.php

im using the below script and it gets what i want but i loose the right table and footer on the page...

<?php
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'news');
require_once('global.php');
require_once('./forums/includes/functions_bbcodeparse.php');
$news = mysql_query("select thread.threadid,thread.title,thread.replycount,thr ead.postusername,thread.dateline,post.postid,post. pagetext from thread,post where thread.forumid=3 and post.postid=thread.firstpostid group by thread.firstpostid order by threadid desc limit 10;");
$n = 0;
while($newsitem = mysql_fetch_row($news)){
$n++;
$newstitle[$n]=$newsitem["1"];
$newsreply[$n]=$newsitem["2"];
$newsuser[$n]=$newsitem["3"];
$newsdate[$n]=vbdate("D j M Y, g:i A",$newsitem["4"]);
$newsthread[$n]=$newsitem["5"];
$limittext[$n] = substr($newsitem["6"], 0, 200) . "...";
$newstext[$n]=parse_bbcode($limittext[$n]);
$newsavatar[$n]=$newsitem["7"];
}
eval('$newstables = "' . fetch_template('news_table_s') . '";');
eval('$newstablem = "' . fetch_template('news_table_m') . '";');
eval('$newstablee = "' . fetch_template('news_table_e') . '";');
eval('print_output("' . fetch_template('news') . '");');
?>


heres how the page is suspose to look: http://dfmafia.net/network_A.php

minus the news...it has the right and footer content

Sean S
12-31-2004, 11:08 PM
Thank you for this hack, but could you explain why I get this error by any chance?


Warning: mysql_query(): 6 is not a valid MySQL-Link resource in /home/static/public_html/forums/includes/db_mysql.php on line 212

Warning: mysql_error(): 6 is not a valid MySQL-Link resource in /home/static/public_html/forums/includes/db_mysql.php on line 357

Warning: mysql_errno(): 6 is not a valid MySQL-Link resource in /home/static/public_html/forums/includes/db_mysql.php on line 358

Warning: mysql_query(): 6 is not a valid MySQL-Link resource in /home/static/public_html/forums/includes/db_mysql.php on line 212

Warning: mysql_error(): 6 is not a valid MySQL-Link resource in /home/static/public_html/forums/includes/db_mysql.php on line 357

Warning: mysql_errno(): 6 is not a valid MySQL-Link resource in /home/static/public_html/forums/includes/db_mysql.php on line 358

everything else works fine, but at the bottom I get these errors.

eLiTeGuRu
01-16-2005, 12:13 AM
Put a @ in front of the mysql queries.

i-Symbian.Com
01-25-2005, 12:55 PM
eLITeGuRu,

I experienced the same as above. All working fine but I received these errors in the bottom of the page:

Warning: mysql_query(): 6 is not a valid MySQL-Link resource in usrlocalpsahomevhostsi-symbian.comhttpdocsforumincludesdb_mysql.php on line 212

Warning: mysql_error(): 6 is not a valid MySQL-Link resource in usrlocalpsahomevhostsi-symbian.comhttpdocsforumincludesdb_mysql.php on line 357

Warning: mysql_errno(): 6 is not a valid MySQL-Link resource in usrlocalpsahomevhostsi-symbian.comhttpdocsforumincludesdb_mysql.php on line 358

Warning: mysql_query(): 6 is not a valid MySQL-Link resource in usrlocalpsahomevhostsi-symbian.comhttpdocsforumincludesdb_mysql.php on line 212

Warning: mysql_error(): 6 is not a valid MySQL-Link resource in usrlocalpsahomevhostsi-symbian.comhttpdocsforumincludesdb_mysql.php on line 357

Warning: mysql_errno(): 6 is not a valid MySQL-Link resource in usrlocalpsahomevhostsi-symbian.comhttpdocsforumincludesdb_mysql.php on line 358

I have tried to put @ in front of mysql_query (there are 3 of them) like you suggested but still the same errors. It looks like this :

@mysql_query

Please advice. All appreciated.

Thanks and best regards

EH-Jay
03-10-2005, 06:47 PM
Can anyone help me with this 1? I get the common 3 errors at the bottom of the page, and everything is setup as it should be.

Thanks

rikku3978
04-26-2005, 10:01 AM
anyone getting the three lines of text at the bottom, remove:

//disconnect
mysql_free_result($sql_result);
mysql_close($connection);

From your newsout.php file and it should resolve it. ^^

-=Sniper=-
04-26-2005, 01:08 PM
thaks dude it fixed it!

greenhybrid
04-30-2005, 12:51 AM
Looks to be nice when it's finished. Thanks.

greenhybrid
05-23-2005, 11:08 PM
Here's what I was able to achieve with some creative modification of the code:
http://www.greenhybrid.com/

AlexSFBay
05-24-2005, 04:14 AM
Here's what I was able to achieve with some creative modification of the code:
http://www.greenhybrid.com/
Nice work on the greenhybrid site! Would you mind sharing your PHP parse code -- I'm guessing you used preg_replace() -- to format the source link on the front page?

Kei Kurono
05-25-2005, 02:21 PM
i need to know the name of the table to extract the info.

How do i find out plz :]

aspen0
05-26-2005, 12:19 AM
I'm having a big bug with this hack.

Apparently calling global.php, as this hack does, is erasing all other variables in the php defined before it.

I've associated pages on my site with forums and have stored a forumid for each page in my db. I wanted to pull that forumid, pass it to this script, and have it print out topics.

However upon calling global.php the variable holding my forumid is erased. I don't know why, I can't explain it, but I tested it and its happening.

So, there is no way to dynamically feed this script information, for god knows what reason...

Marco van Herwaarden
05-26-2005, 05:13 AM
This is how global.php does work. It will reset all variables to protect against abuse.

Try to place global.php at the top of your script before you fill any other var's.

AlexSFBay
09-05-2005, 06:11 AM
Quote: Originally Posted by greenhybrid
Here's what I was able to achieve with some creative modification of the code:
http://www.greenhybrid.com/

Nice work on the greenhybrid site! Would you mind sharing your PHP parse code -- I'm guessing you used preg_replace() -- to format the source link on the front page?

I figured it out... in case anybody was curious. See PHP function parse_url (http://us3.php.net/function.parse-url).


<?php
$myDomain = parse_url("http://www.yahoo.com/index.php#examples");
echo "Scheme: " . $myDomain["scheme"] . "<br>";
echo "Domain: " . $myDomain["host"] . "<br>";
echo "Path: " . $myDomain["path"] . "<br>";
echo "Anchor: " . $myDomain["fragment"] . "<br>";
?>

RESULT:
Scheme: http
Domain: www.yahoo.com
Path: /index.php
Anchor: examples


You can tweak it from there. Have fun!

AlexSFBay
09-07-2005, 09:47 PM
I figured it out... in case anybody was curious. See PHP function parse_url (http://us3.php.net/function.parse-url).


<?php
$myDomain = parse_url("http://www.yahoo.com/index.php#examples");
echo "Scheme: " . $myDomain["scheme"] . "<br>";
echo "Domain: " . $myDomain["host"] . "<br>";
echo "Path: " . $myDomain["path"] . "<br>";
echo "Anchor: " . $myDomain["fragment"] . "<br>";
?>

RESULT:
Scheme: http
Domain: www.yahoo.com
Path: /index.php
Anchor: examples


You can tweak it from there. Have fun!

I just realized there's more to the "Source" link function. Your script needs to be able to scan the text output and capture the URL. Anyone wanna take a stab on how to do that.

AlexSFBay
09-07-2005, 09:51 PM
I was also wondering how one can have an excerpted post for news threads that links back to your custom CMS page. See example in action here (http://www.internettablettalk.com/forums/showthread.php?t=105). (I figured out that this site is using the vBulletin-WordPress Bridge (https://vborg.vbsupport.ru/showthread.php?t=94443) hack)

joeMJ
10-01-2005, 03:59 AM
can anyone please help me with that problem?

I just upgraded to 3.5 (this script worked without any problems in 3.0.9 - sorry I know that it is not written for 3.5)

I'm getting mad because of no idea / brain on the bbcode parser.

Original does not work (in 3.5):
require_once("./includes/functions_bbcodeparse.php");
$outxt=parse_bbcode2($ptext,"1","1","1","1","1");
prints now following error after upgrade to vb3.5
Fatal error: Call to a member function on a non-object in D:\server\mobilejoe\joeforums\includes\functions_b bcodeparse.php on line 398
This one looks better using old bbcode function but far away from how it should be (see screenshot below) because it still shows ****** bbcode. How can I fix this?
require_once("./includes/functions_bbcodeparse.php");
$outxt=parse_bbcode2($ptext,"1","1","","","");

oOoops - This thing does not exist in 3.5 - https://vborg.vbsupport.ru/showthread.php?t=82693 This is way to much for me.

joeMJ
10-02-2005, 04:09 AM
Oups?

Problem: You cannot use old parser, connect dies within script.

I finally got this to work. A friend of mine found out, that the db connect was broken and the new parser didn't work because of that issue. Here's what I did on my page to get this working in 3.5 including new Parser and Fix within db connect (including advertising after 3 news):

See this line:
$xdb = mysql_select_db("$dbname", $connection) or die ("Could not select database.");

<?php
require_once("./global.php");
require_once('./includes/class_bbcode.php');

$splitval="lest mehr hier";
$cats="19"; //"2,3,4,5,6";
$newsitems=10;
$forumspath="http://www.tralala.de/tralala";

$servername="localhost";
$dbusername="tralala";
$dbpassword="tralala";
$dbname="tralalatabelle";

//************************************************** ************************************************** **********//

$iidx = 0;

$bbparser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

$connection = mysql_connect("$servername","$dbusername","$dbpassword") or die ("Cannot connect to server.");
$xdb = mysql_select_db("$dbname", $connection) or die ("Could not select database.");

$sql = "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid IN ($cats) AND sticky = '0' ORDER BY threadid DESC LIMIT $newsitems";
$sql_result = mysql_query($sql, $connection) or die ("Could not execute query.".mysql_error());

if (!$sql_result)
echo "Could not get news.";
else
{
while ($row = mysql_fetch_array($sql_result))
{
$threadid = $row["threadid"];
$title = $row["title"];
$forumid = $row["forumid"];
$replycount = $row["replycount"];
$postusername = $row["postusername"];
$postuserid = $row["postuserid"];
$lastposter = $row["lastposter"];
$iconid = $row["iconid"];
$dateline = $row["dateline"];

$sql2 = "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";
$sql_result2 = mysql_query($sql2, $connection) or die ("Could not execute query in second sql statement.".mysql_error());

if (!$sql_result2)
echo "Could not get news.";
else
{
while ($row2 = mysql_fetch_array($sql_result2))
{
$ptext = $row2["pagetext"];
$dateposted = date("j.n.Y G:i",$dateline);
$commenttext = "Kommentar";

if( $replycount!=1 )
$commenttext .= "e";

$outxt=$bbparser->do_parse($ptext, true, true, true, true, true, true);

$trimmed = explode($splitval, $outxt);
$outxt=$trimmed[0];

$sql3 = "SELECT title FROM forum WHERE forumid = \"$forumid\" LIMIT 1";
$sql_result3 = mysql_query($sql3, $connection) or die ("Could not execute query in second sql statement.");
$row3 = mysql_fetch_array($sql_result3);
$forumname = $row3["title"];

$towrite .= "<div>$outxt</div>";

$towrite .= "<hr size='1'>";

$towrite .= "<div align='center'>";
$towrite .= "Geschrieben von <a href=\"$forumspath/member.php?s=&amp;action=getinfo&amp;userid=$postuserid\"><b>$postusername</b></a> am <i>$dateposted</i><br>";
$towrite .= "Kategorie: <a href=\"$forumspath/forumdisplay.php?s=&amp;forumid=$forumid\">$forumname</a><br>";
$towrite .= "<a href=\"$forumspath/showthread.php?s=&amp;threadid=$threadid\">$replycount $commenttext</a>";
$towrite .= "</div>";

$towrite .= "<hr size='1'>";

if( $iidx++ % 3 == 0 )
$towrite .= "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#f7f7f7'><tr><td align='center'><iframe src='http://tralala.com/werbung.tralala' width='470' height='68' scrolling='no' marginheight='0' marginwidth='0' frameborder='0'></iframe></td></tr></table>";

$towrite .= "<hr size='1'>";


}
}
}
}

echo $towrite;

?>

2shae
10-24-2005, 10:06 PM
i use the script above
is there anyway to add title name and description?

2shae
10-25-2005, 09:14 AM
OK,
i need help with the following html i try to use in the template bit

<td class="latestnews-storygraphic"><img src="" alt=""></td>
<td class="latestnews-story"><p><strong>Title</strong></p>
<p class="latestnews-fixwidth">Text</p>
<hr class="latestnews-line" />
<p>Posted By <a href=\"$forumspath/member.php?s=&amp;action=getinfo&amp;userid=$postuserid\">$postusername</a> on October 23rd, 2005 | <a href=\"$forumspath/showthread.php?s=&amp;threadid=$threadid\">Discuss This Topic</a> | $replycount $commenttext</p> </td>