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)
-   -   VBSyndicate Hack V1 (https://vborg.vbsupport.ru/showthread.php?t=28872)

Dave# 09-24-2001 10:00 PM

Synopsis

This hack allows webmaster to provide syndicated VB content to other webmasters such as Latest topics, Latest Polls or calendar entries to other webmasters for inclusion on their websites. The webmasters using the feeds do NOT need PHP, PERL, MYSQL, ASP just a javascript enabled browser.

Requirements

* Crontab
* The ability to run PHP via the command line

Example

http://cpfc.org/news/newsfeed.html

Please note the documentation is sketchy and if your aren't savvy with hacking code yourself then maybe you should wait until the documentation is up to speed.

Dave# 09-25-2001 01:29 PM

don't use the txt file

use this

Steve Machol 09-25-2001 02:45 PM

This looks really interesting Dave. I'm looking forward to trying this out. Good job! :)

Steve Machol 09-25-2001 04:13 PM

I'm doing something wrong. I get these errors when trying to run activefeed.php from the command line:

Code:

./activefeed.php: ?: No such file or directory
./activefeed.php: line 2: syntax error near unexpected token `require("/home/smachol/www/forums/admin/config.php")'
./activefeed.php: line 2: `require("/home/smachol/www/forums/admin/config.php");'


Dave# 09-25-2001 05:21 PM

Steve when executing your php file from the command line (telnet/SSH) you must specify the location of php binary

Ie for me

/usr/local/php/bin/php -q /path/to/php/file

Scott MacVicar 09-25-2001 07:28 PM

if you can't get that to work you can do the following

/usr/bin/lynx -dump http://url.com/to/script.php

chrispadfield 09-25-2001 10:59 PM

Dave this is very cool. Looking forward to play with it.

DarkReaper 09-26-2001 12:06 AM

Schleet :)

Steve Machol 09-26-2001 02:33 AM

Invoking it with the path to php gives me this error now:

Code:

bash:~/www/forums$ /usr/bin/php -q activefeed.php
<br>
<b>Fatal error</b>:  Call to undefined function:  mysql_connect() in <b>activefeed.php</b> on line <
b>7</b><br>

Line 7 contains:

mysql_select_db($dbname);

mcncyo 09-26-2001 07:00 AM

you might need to add

#!/usr/local/bin/php at the top of your file. If you are running php as cgi mode.

Steve Machol 09-26-2001 03:11 PM

Nope, I'm not running PHP in cgi-mode. Any other ideas? I really want to get this one working.

Dave# 09-26-2001 03:16 PM

Quote:

Originally posted by smachol
Nope, I'm not running PHP in cgi-mode. Any other ideas? I really want to get this one working.

your on linux?

try

locate php|more

search through until you find a binary rather than a directory

Steve Machol 09-26-2001 03:25 PM

Dave,

/usr/bin/php is the binary.

Quote:

bash:/usr/bin$ ls -al ph*
-rwxr-xr-x 1 root root 1066892 Mar 3 2001 php

Dave# 09-26-2001 06:34 PM

Steve:

1) Can you run any php scripts via the command line?
2) Is your path to config.php correct?

Steve Machol 09-26-2001 06:39 PM

1. Apparently not. I tried with a couple of other scripts and got the same error. How do I get around this?

2. Yes, otherwise my forums would cease to function.

Thanks!

Dave# 09-26-2001 06:42 PM

Quote:

1. Apparently not. I tried with a couple of other scripts and got the same error. How do I get around this?
Build php4 again without Apache support in another directory on your server? What is your OS? You might be able to download a pre-compiled binary from somewhere.

Steve Machol 09-26-2001 06:45 PM

I'm running RedHat 7.1. I'm not going to take a chance on rebuilding PHP. If something went wrong my forums would stop operating and I can't run that risk. :eek:

Also I just tested a couple of other PHP scripts from the command line and they executed just fine. It's only scripts that access a database that give me this problem.

Scott MacVicar 09-26-2001 07:56 PM

use lynx its a browser that comes with nearly every linux distrib and you can just execute the script as if you just typed it in to your browser.

Just use the following
Code:

/usr/bin/lynx -dump http://url.com/to/activefeed.php
thats what i've done to get it to work as i was getting same error.

Steve Machol 09-26-2001 11:15 PM

Thanks PPN! That now works to create the latest_topics.txt file. However I now have another problem when I try to use the resulting script. You can see for yourself at:

http://www.optiboard.com/activefeed.html

Scott MacVicar 09-27-2001 07:31 PM

I rewrote nearly all of the code within this to do the following things, select latest topics from all forums that are open to users with groupid 1. It also writes to a .js file and the code should have been

Code:

<script language="JavaScript" src="http://yourdomain/forums/latest_topics.js"></script>
the language was missed out
also the ? needs escaped for both php and javascript so you need \\?

i done this in my version and also made it work with ./global.php instead of connected within the file.

New attachment two posts below.

Steve Machol 09-27-2001 08:51 PM

This works great except for one problem - it only pulls threads from my first forum (with forumid 24.) How do I get it to pull the last 10 threads from all my open forums?

http://www.optiboard.com/newsfeed.html

Scott MacVicar 09-28-2001 03:43 PM

em bah i made a mistake with the forum permissions, it only worked if you had access masks on. Reworked it and it now takes it from all forums. See attachment below.

Updated to connect to the database a different way.

mkilty 09-29-2001 03:31 AM

Hmmm.....I am getting a blank page except one time when it did work.

When I /usr/bin/lynx -dump http://url.com/to/activefeed.php it had NO error code and the .js script was touch with a new date but the page came up empty. This is after it worked the first time.

I am using your latest version of the script as well. Any idea's?

Thanks,

Michael
www.clublexus.com

Steve Machol 09-29-2001 04:43 AM

Thanks PPN! Works perfectly now.

One question though. Is there anyway to disable the cookie-setting when newsfeed.php is run? Running it even shows up in Who's Online.

smartboyinuk 10-03-2001 08:53 PM

Looks quite interesting.

But is this possible without the cron facility ?
Without the facility to run php from command line ?

Any clues ?

Thanks

Scott MacVicar 10-06-2001 12:34 PM

if you can't use lynx use this

change newsfeed.php to newsfeed.cgi and at the top add #!/usr/bin/php

this is my presuming the path to your PHP

then add the following cronjob

/usr/bin/php -q /path/to/htdocs/newsfeed.cgi

an alternative to cronjob would involve editing the vb php files, It shouldn't be to hard to do, all you would need to do it include the newsfeed.php where you want it to execute.

Steve Machol 10-06-2001 03:39 PM

PPN, do you know how to disable the cookie-setting?

Scott MacVicar 10-06-2001 05:19 PM

instead of

PHP Code:

require("./global.php"); 

use

PHP Code:

//load config
require("./admin/config.php");

// init db **********************
// load db class
$dbclassname="./admin/db_$dbservertype.php";
require(
$dbclassname);

$DB_site=new DB_Sql_vb;

$DB_site->appname="vBulletin Control Panel";
$DB_site->appshortname="vBulletin (cp)";
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;

$DB_site->connect();

$dbpassword="";
$DB_site->password="";
// end init db 

this is the simple way to do it, there must be an easy way to do it but I would have to search through all the functions.

Steve Machol 10-06-2001 05:55 PM

Thanks, I'll give it a try!

Steve Machol 10-06-2001 06:03 PM

It didn't work. It seems to have broken the newsfeed.php script altogether.

http://www.optiboard.com/newsfeed.html

Scott MacVicar 10-06-2001 10:23 PM

PHP Code:

<?php

//Offer somewhere on your site for users to get the following code
//<script language="JavaScript" src="http://yourdomain/forums/latest_topics.js"></script>
//Crontab? i recommend using lynx as it will always work
//10 * * * * /usr/bin/lynx -dump [url]http://urltoyourboard/newsfeed.php[/url]
//Based on hack by Dave Campbell ([url]www.cpfc.org[/url])
//Modified by Scott MacVicar (software@pp-network.com)
//
//Note you made need to create a latest_topics.js file in your forums directory and chmod to 666.

$bburl="http://url.com/to/forums";

//load config
require("./admin/config.php");

// init db **********************
// load db class
$dbclassname="./admin/db_$dbservertype.php";
require(
$dbclassname);

$DB_site=new DB_Sql_vb;

$DB_site->appname="vBulletin Control Panel";
$DB_site->appshortname="vBulletin (cp)";
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;

$DB_site->connect();
// end init db
//below is the variable for number of topics to show
$num_active 10;

//Get forums which normal users can view
$forums=$DB_site->query("SELECT forumid FROM forum");
while (
$forum=$DB_site->fetch_array($forums)) {
  
$fperms=$DB_site->fetch_array($DB_site->query("SELECT canview,forumid FROM forumpermission WHERE usergroupid='1' AND forumid='$forum[forumid]'"));
  if(
$fperms["canview"] == 1) {
    
//can view forum
    
$forumperms[]=$forum["forumid"];
  }
  elseif(!isset(
$fperms["canview"])) {
    
$forumperms[]=$forum["forumid"];
    
//forumpermission doesn't exist for this forum
  
}
}
$DB_site->free_result($forums);
unset(
$forum);
unset(
$fperms);

if(!empty(
$forumperms)) {
  
$forumperms='AND forumid='.implode(' OR forumid=',$forumperms);
}

//Get the latest threads which are open
$query=$DB_site->query("SELECT * FROM thread WHERE open='1' $forumperms ORDER BY lastpost DESC LIMIT $num_active");

$fp fopen("latest_topics.js""w");
@
flock($fp2);
while (
$latest=$DB_site->fetch_array($query)) {
  
$threadid=$latest["threadid"];
  
$title=$latest["title"];
  
$date=date("h:i A"$latest["lastpost"]);
  
$replys=$latest["replycount"];
  if (
$replys==1) {
    
$replytext "reply \\?";
  }
  else {
    
$replytext "replies \\?";
  }
  
fputs($fp"document.write(\"<font face='Verdana, arial' size='1'><B><font color='#FF0000'>\\?</FONT><a href='$bburl/showthread.php?threadid=$threadid'>$title</B><br></a>$replys $replytext <a href='$bburl/showthread.php?threadid=$threadid'>Read more</a><BR>Last Updated: $date<br></font>\");\n");
}
@
fclose($fp);

?>

the above code is working fine on the version of vBulletin i administor. It was taken straight from the file couple minutes ago and we're using it without problems.

Steve Machol 10-06-2001 10:37 PM

Thanks but I'm still having the same problem. The latest_topics.js file is messed up. After running this, the first line always begins with:

ument.write

...instead of:

document.write

I'm going to check the code again.

[Edit: I checked but can't find any reason for this to happen. Again it's the first line only. All subsequent lines print out fine.]

YourHostSucks 10-07-2001 01:45 AM

I tried to use: /usr/bin/php -q /path/to/htdocs/newsfeed.cgi

It seems to execute the file now, but I get a parse error...
---------
<br>
<b>Parse error</b>: parse error in <b>/home/********/********/******/newsfeed.cgi</b> on line <b>73</b><br>
---------

Line 72, 73, 74:
}
else {
$replytext = "replies \\?;

----------

Thanks for your help.

Steve Machol 10-07-2001 01:53 AM

Why did you change this from newsfeed.php to newsfeed.cgi? Does your PHP parse CGI files?

YourHostSucks 10-07-2001 02:08 AM

I changed it because of what PPN said..

Quote:

if you can't use lynx use this

change newsfeed.php to newsfeed.cgi and at the top add #!/usr/bin/php

this is my presuming the path to your PHP

then add the following cronjob

/usr/bin/php -q /path/to/htdocs/newsfeed.cgi
:)

Quote:

Does your PHP parse CGI files?
I hope it does.. It does not have a problem until line 73..
*shrug*


<- feeling sad, finally get cron to do something.. now this error(hehe)


Thanks for your fast reply.. ;)

Steve Machol 10-07-2001 02:17 AM

Ah, ok. I didn't see that. Doesn't your server have lynx installed?

YourHostSucks 10-07-2001 02:21 AM

Yes it does, but when I use it.. (lynx - dump or lynx)
I get this error:

Your terminal lacks the ability to clear the screen or position the cursor.


:(

Dave# 10-08-2001 06:35 PM

Quote:

Originally posted by YourHostSucks
Yes it does, but when I use it.. (lynx - dump or lynx)
I get this error:

Your terminal lacks the ability to clear the screen or position the cursor.


:(

You might have to run it as root

PPN - Good work :)

YourHostSucks 10-08-2001 11:51 PM

I have tried:

--------------------------------------------------------------------------------

root /home/********/*******l/******/newsfeed.php

error:

/bin/sh: root: command not found

-------------------------------------------------------------------------------

I have no clue why but I tried:

GET http://forums.yourhostsucks.com/newsfeed.php

Error:

<br>
<b>Parse error</b>: parse error in <b>/home/yourhost/public_html/forums/newsfeed.php</b> on line <b>72</b><br>

-------------------------------------------------------------------------------

/usr/bin/php -q /home/******/*********/*******/newsfeed.cgi

Error:

<br>
<b>Parse error</b>: parse error in <b>/home/********/********/******/newsfeed.cgi</b> on line <b>73</b><br>

Note: it is line 73 because I added #!/usr/bin/php at the top.

---------------------------------------------------------------------------------

I tried a couple others with no luck as well.. :)

EX: GET http://forums.yourhostsucks.com/newsfeed.php > /dev/null

Tried to use nice, etc..




Any Ideas? :)

Thanks!

Steve Machol 10-09-2001 12:45 AM

[QUOTE]Originally posted by YourHostSucks
I have tried:

--------------------------------------------------------------------------------

root /home/********/*******l/******/newsfeed.php

error:

/bin/sh: root: command not found


All times are GMT. The time now is 03:13 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.01327 seconds
  • Memory Usage 1,854KB
  • 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
  • (4)bbcode_code_printable
  • (3)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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