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)
-   -   news2vb - Moreover news headlines to vBulletin discussion thread (https://vborg.vbsupport.ru/showthread.php?t=36174)

fimfimfim 02-27-2003 01:25 PM

First off, very cool mod / hack! :D

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!

Cloud-Warrior 02-27-2003 02:27 PM

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.
--

fimfimfim 02-27-2003 02:36 PM

The latter is what I was looking for. I'll give it a shot. Thanks again!

fimfimfim 02-27-2003 02:46 PM

Got it! Thanks for the input. Had a problem for a while where I wasn't setting $jmessage to null after each insert.. duh :rolleyes: Anyway, its working great. Once again thanks for the mod and your help!

limey 02-28-2003 07:29 PM

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?

fimfimfim 02-28-2003 07:41 PM

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. :rolleyes: :laugh:

limey 03-01-2003 03:11 AM

fimfimfim:

Would it be possible to post your code in entirety? I lost you at
Quote:

Lastly, I moved all of this:
and down.

thanks. :D

redd 03-01-2003 02:00 PM

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:

We would like to bring to your attention that due to a change in our Terms and Conditions, your website may be in breach of our terms of service. Our Terms and Conditions were updated in August 2002 to restrict use of our public feeds to charitable organizations only, subject to approval by Moreover. (Our terms and conditions can be viewed at http://c.moreover.com/click/here.pl?q51885055).

If you wish to continue receiving these news feeds and you are not a charitable organization, then for a limited period, we can offer you a discount on the standard pricing. If you are interested in receiving product information and pricing from us please complete the form at http://gm14.com/r.html?c=177529&r=17...4982.&g=0&f=-1 Alternatively, phone our US sales department on +1 415 989 0600 or our UK sales department on +44 253 5003.

If, having reviewed our Terms & Conditions, you believe you qualify for continued use of this free service, then please complete the form at this link http://gm14.com/r.html?c=177529&r=17...84117&g=0&f=-1 giving as much detail as possible.

If we do not hear from you within two weeks, headline functionality will be disabled and access to the service will be denied.

fimfimfim 03-03-2003 12:55 PM

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;
}

limey 03-04-2003 03:33 AM

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:

find this code "xxxx" and replace with this code "xxxx"
Can you do it like this?

thanks again.


All times are GMT. The time now is 02:34 PM.

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.02334 seconds
  • Memory Usage 1,776KB
  • 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
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (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