The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
news2vb - Moreover news headlines to vBulletin discussion thread Details »» | |||||||||||||||||||||||||||
news2vb - Moreover news headlines to vBulletin discussion thread
Developer Last Online: Apr 2010
Hope the instructions at the top are clear, if not please post here.
To install this utility, copy the single PHP file to your vB dir. Edit it and change the password to whatever you wish. Change the yourvbdir variable to the URL pointing to your vB directory. As demo - here are some sample output threads: http://www.boards.ie/vbulletin/showt...threadid=44475 http://www.boards.ie/vbulletin/showt...threadid=44522 Also, have a look at the menu here: http://www.boards.ie/vbulletin/news2...ion=picksource This script will generate messages of the following form in whatever forum you wish, using any of the Moreover newsfeeds.
Changelog 1.1 - "Post News" output now shows BB code parsed message, URL to thread 1.1 - Fixed missing references to $yourvburl Show Your Support
|
Comments |
#32
|
|||
|
|||
First off, very cool mod / hack!
I was wodnering if there was an easy way to make each headline a thread with a link to the story vs putting all the days news into a thread as posts. Any help is appreciated. TIA! |
#33
|
||||
|
||||
Do you mean, instead of a thread, you'd create a pseudo-thread that would actually link to the news story?
That'd involve some hacking of vB I think, more than just an add-on Or do you just mean having a new thread for each news item, with the subject = headline and posttext = link to article? That'd be easy enough to do I'd say, in the loop where it says: if ($jitemheadline != "") { ... } you'd post a new thread and post for each headline instead of one big thread and post with all headlines after the loop. John. -- |
#34
|
|||
|
|||
The latter is what I was looking for. I'll give it a shot. Thanks again!
|
#35
|
|||
|
|||
Got it! Thanks for the input. Had a problem for a while where I wasn't setting $jmessage to null after each insert.. duh Anyway, its working great. Once again thanks for the mod and your help!
|
#36
|
||||
|
||||
Can you post how you did the new thread per story listing?
Aside from queries and keywords, can you limit the number of stories pulled? |
#37
|
|||
|
|||
Sure here's what I did:
In the section that Could-Warrior mentioned: if ($jitemheadline != "") { I added this to limit the headlines to within one hour of the script executing: $currenttime=time(); $articletime=strtotime($jitemextractiontime); if ($articletime < ($currenttime - 3600)) continue; I added this to limit the duplicate headlines: $result=$DB_site->query("SELECT threadid FROM thread WHERE title LIKE '".addslashes($jitemheadline)."' "); if ($DB_site->num_rows($result) > 0) continue; Lastly, I moved all of this: (which is all Cloud-Warrior's original code with a small change to the VALUES list to make the title of the article appear as the thread subject) else { $jmessage .= "[*] ".$jitemheadline."\n"; $jmessage .= "($jitemsource, $jitemextractiontime) \n"; $jsubject = urlencode($jitemheadline); $jmessage = ereg_replace("INSERTTITLE", "$jsubject", $jmessage); $DB_site->query("INSERT INTO thread (threadid,title,lastpost,forumid,open,replycount,p ostusername,postuserid,lastposter,dateline,iconid, visible,attach) VALUES (NULL,'".addslashes($jitemheadline)."','".time()." ','$jforum','1','0','".addslashes($jfromwho)."','0 ','".addslashes($jfromwho)."','".time()."','$jicon id','1','0')"); $jthreadid=$DB_site->insert_id(); $jmessage = ereg_replace("INSERTTHREADID", "$jthreadid", $jmessage); $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,at tachmentid,pagetext,allowsmilie,showsignature,ipad dress,iconid,visible) VALUES (NULL,'$jthreadid','".addslashes(htmlspecialchars( "$jusername"))."','".addslashes($jfromwho)."','0', '".time()."','0','".addslashes($jmessage)."','0',' ','','0','1')"); $jmessage = NULL; $jforuminfo=getforuminfo($jforum); $DB_site->query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1, lastpost='".time()."',lastposter='".addslashes($jf romwho)."' WHERE forumid IN ($jforuminfo[parentlist])"); } } Changes Summary: Bascially added "$jmessage=NULL;" to force only one link per thread. I commented out all the code right below the "foreach" loop since I've moved it into the loop. Added the $jitemheadline as the threadtitle vs the one that is created by Cloud-Warriors original. Well, that's what I did. It should be pretty easy to limit headlines to a set number. Just add a counter and increment each time the loop goes and check for a conditon where it has reached your number of headlines and break ouyt of the loop. I hope this makes sense. I haven't coded since my college days. The good old days of double pointers, malloc, etc. :laugh: |
#38
|
||||
|
||||
fimfimfim:
Would it be possible to post your code in entirety? I lost you at Quote:
thanks. |
#39
|
|||
|
|||
Just an FYI before you all get too used to this hack... Moreover stopped offering free newsfeeds last August. They contacted me last week and told me that I had to stop using Moreover unless I was willing to sign up for their paid service.
Quote:
|
#40
|
|||
|
|||
Considering the current economic situation, not many things are free these days anymore... :cry:
In any case, here's what it looks like. You can just replace everything from the starting point. FROM THE TOP: // news2vb.php, post Moreover news headlines to your vBulletin forum // Cloud Internet, www.cloud.ie, Version 1.1, 19 March 2002 // Please read the Moreover Terms and Conditions before using this script: // http://w.moreover.com/site/about/ter...onditions.html // More information on Moreover at http://w.moreover.com/dev/ // 1.1 - "Post News" output now shows BB code parsed message, URL to thread // 1.1 - Fixed missing references to $yourvburl // 1.0 - First version of script ... CHANGES START HERE foreach ($jrebrokennewsfeed as $array_id => $jnewsfeedline) { list($jitemarticleurl, $jitemheadline, $jitemsource, $jitemmediatype, $jitemcategory, $jitemtagline, $jitemcategoryurl, $jitemextractiontime, $jitemaccessstatus, $jitemregistrationurl) = split ("\t", $jnewsfeedline); if ($jitemheadline != "") { $currenttime=time(); $articletime=strtotime($jitemextractiontime); if (if ($jitemheadline != "") {$articletime < ($currenttime - 3600)) continue; $result=$DB_site->query("SELECT threadid FROM thread WHERE title LIKE '".addslashes($jitemheadline)."' "); if ($DB_site->num_rows($result) > 0) continue; else { $jmessage .= "[*] ".$jitemheadline."\n"; $jmessage .= "($jitemsource, $jitemextractiontime) \n"; $jsubject = urlencode($jitemheadline); $jmessage = ereg_replace("INSERTTITLE", "$jsubject", $jmessage); $DB_site->query("INSERT INTO thread (threadid,title,lastpost,forumid,open,replycount,p ostusername,postuserid,lastposter,dateline,iconid, visible,attach) VALUES (NULL,'".addslashes($jitemheadline)."','".time()." ','$jforum','1','0','".addslashes($jfromwho)."','0 ','".addslashes($jfromwho)."','".time()."','$jicon id','1','0')"); $jthreadid=$DB_site->insert_id(); $jmessage = ereg_replace("INSERTTHREADID", "$jthreadid", $jmessage); $DB_site->query("INSERT_INTO_post_(postid,threadid,title,us ername,userid,dateline,attachmentid,pagetext,allow smilie,showsignature,ipaddress,iconid,visible)_VAL UES_(NULL,'$jthreadid','".addslashes(htmlspecialch ars("$jusername"))."','".addslashes($jfromwho)."', '0','".time()."','0','".addslashes($jmessage)."',' 0','','','0','1')"); $jmessage = NULL; $jforuminfo=getforuminfo($jforum); $DB_site->query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1, lastpost='".time()."',lastposter='".addslashes($jf romwho)."'_WHERE_forumid_IN_($jforuminfo[parentlist])"); } } } $jmessage .= "[/list]\n"; $jthreadurl = "$yourvburl/showthread.php?s=&threadid=$jthreadid"; $jbbcodeparsed = bbcodeparse2($jmessage, 1, 1, 1, 1); $jcheckhtml = "<html> <head> <title>news2vb - Post News</title> </head> <body> <h1>news2vb - Post News</h1> <h5>Thread created - <a href=\"$jthreadurl\">$jthreadurl</a></h5> <h5>Moreover query - <a href=\"$jnewsfeedurl\">$jnewsfeedurl</a></h5> <h5>Autocreate URL - $jgenerateurl</h5> <h3>$jtitle</h3> $jbbcodeparsed </body> </html>"; print $jcheckhtml; } function infile($infile) { $in = fopen($infile, "r"); if(!$in) { echo "error: could not open the url: $requesturl<br>\n"; } else { $contents = ""; while(!feof($in)) { $contents .= fgets($in,256); } } fclose($in); return $contents; } |
#41
|
||||
|
||||
fimfimfim: thanks for posting the code. However, where does this code go between? What does this code replace?
The standard practice here@ vb.org seems to be: Quote:
thanks again. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|