PDA

View Full Version : VBSyndicate Hack V1


Dave#
25 Sep 2001, 15:26
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#
25 Sep 2001, 15:29
don't use the txt file

use this

Steve Machol
25 Sep 2001, 16:45
This looks really interesting Dave. I'm looking forward to trying this out. Good job! :)

Steve Machol
25 Sep 2001, 18:13
I'm doing something wrong. I get these errors when trying to run activefeed.php from the command line:

./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#
25 Sep 2001, 19:21
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
25 Sep 2001, 21:28
if you can't get that to work you can do the following

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

chrispadfield
26 Sep 2001, 00:59
Dave this is very cool. Looking forward to play with it.

DarkReaper
26 Sep 2001, 02:06
Schleet :)

Steve Machol
26 Sep 2001, 04:33
Invoking it with the path to php gives me this error now:

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
26 Sep 2001, 09:00
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
26 Sep 2001, 17:11
Nope, I'm not running PHP in cgi-mode. Any other ideas? I really want to get this one working.

Dave#
26 Sep 2001, 17:16
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
26 Sep 2001, 17:25
Dave,

/usr/bin/php is the binary.

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

Dave#
26 Sep 2001, 20:34
Steve:

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

Steve Machol
26 Sep 2001, 20:39
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#
26 Sep 2001, 20:42
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
26 Sep 2001, 20:45
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
26 Sep 2001, 21:56
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
/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
27 Sep 2001, 01:15
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
27 Sep 2001, 21:31
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

<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
27 Sep 2001, 22:51
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
28 Sep 2001, 17:43
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
29 Sep 2001, 05:31
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
29 Sep 2001, 06:43
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
03 Oct 2001, 22:53
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
06 Oct 2001, 14:34
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
06 Oct 2001, 17:39
PPN, do you know how to disable the cookie-setting?

Scott MacVicar
06 Oct 2001, 19:19
instead of

require("./global.php");

use

//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
06 Oct 2001, 19:55
Thanks, I'll give it a try!

Steve Machol
06 Oct 2001, 20:03
It didn't work. It seems to have broken the newsfeed.php script altogether.

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

Scott MacVicar
07 Oct 2001, 00:23
<?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 http://urltoyourboard/newsfeed.php
//Based on hack by Dave Campbell (www.cpfc.org)
//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($fp, 2);
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
07 Oct 2001, 00:37
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
07 Oct 2001, 03:45
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
07 Oct 2001, 03:53
Why did you change this from newsfeed.php to newsfeed.cgi? Does your PHP parse CGI files?

YourHostSucks
07 Oct 2001, 04:08
I changed it because of what PPN said..


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


:)


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
07 Oct 2001, 04:17
Ah, ok. I didn't see that. Doesn't your server have lynx installed?

YourHostSucks
07 Oct 2001, 04:21
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#
08 Oct 2001, 20:35
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
09 Oct 2001, 01:51
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
09 Oct 2001, 02:45
Originally posted by YourHostSucks
I have tried:

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

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

error:

/bin/sh: root: command not found
No, what Dave means is that you may need to be logged in as user 'root' when you run newsfeed.php. Obvisiously you would need to be on a dedicated machine in order to have root access.

Steve Machol
09 Oct 2001, 19:38
Originally posted by smachol
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.] Just a polite bump. I still can't figure out the fix to this problem. :confused:

Steve Machol
09 Oct 2001, 19:46
I temporarily 'fixed' the problem by putting a few spaces in front of 'document.write'

fputs($fp, " document.write(.........

The first line prints out correctly now, while subsequent lines have several spaces in from of them. Nonetheless the resulting .js file seems to display correctly.

I'd still be intersted in knowing why this happened.

Scott MacVicar
09 Oct 2001, 21:04
This is an odd error =/

i got it to work fine on Mandrake and Win2k systems without any problems such as this. I was using PHP4.0.6 in both cases.

Steve Machol
09 Oct 2001, 22:23
Yeah I'm running PHP 4.06 too. Interestingly enough, it is formatted correctly when run from cron. It's only when I run the exact same command from the shell that it chops off the first three characters of the first line.

Very strange!

YourHostSucks
11 Oct 2001, 03:23
*bump* help please... I do not get why this will not work! ;(

Thanks,

Steve Machol
11 Oct 2001, 03:58
Originally posted by YourHostSucks
*bump* help please... I do not get why this will not work! ;(

Thanks, Did you read my previus message? You were entering the command wrong. You need to be logged in as root.

YourHostSucks
11 Oct 2001, 04:20
So i have to mail my host and have them set up every cron job? , Why do they give me the option in the control panel to add them if
I can not? *just wondering*.. would seem like I should be able to.

Sorry, I am just very confused..... :(

Steve Machol
11 Oct 2001, 04:44
I honestly don't know why you can't run a cron job. Perhaps this is a problem with your host. All I was pointing out is why you got the error when you ran the command:

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

YourHostSucks
11 Oct 2001, 04:54
Oooo got ya.. can not run the cron job (root) unless you have root access... :) Thanks*

The cron job is running just fine.. but I get those parse errors on line 72.... :(

Steve Machol
11 Oct 2001, 05:10
I wish I could help you. I'm running this with the 'lynx -dump' cron job and it's working great. Here's what I have:

*/10 * * * * lynx -dump http://*************/newsfeed.php > latest_topics.js

Steve Machol
11 Oct 2001, 22:18
If anyone wants to see this in action, here's a site using my news feed:

http://www.iooi.co.uk/otherforums.php

Zecherieh
12 Oct 2001, 05:55
I have one that I made that is connected to the submit button, instead of cronjob - basically rebuilds the text file that the syndication comes off of everytime that a new thread is posted in the particular forum that I have syndicated.

Output is in rss and a couple of different formats for some scrollers. If there is interest I will look back and post the code - actually uses very little code.

Steve Machol
12 Oct 2001, 07:24
With absolutely no changes on my end, this just stopped working. I'm getting the error:

'Expected hexadecimal digit'

Any idea what caused this? Could it be a certain character in one of the thread titles?

Edit: Never mind - I found the problem! Someone had put a \ in one of the thread titles. Can this problem be accounted for and fixed?

Scott MacVicar
12 Oct 2001, 08:34
$title=$latest["title"];

change to

$title=addslashes($latest["title"]);

Steve Machol
12 Oct 2001, 18:16
Excellent! Works like a charm. Thanks!

Lionel
29 Dec 2001, 02:41
I tried to install activefeed.php and used the dump command with lynx with telnet. Nothing happenned. I tried newsfeed.php and when running from the browser, it writes on the .js file.

But I need to feed only certain forums (possible with activefeed but not with newsfeed)

Lionel
29 Dec 2001, 17:36
Originally posted by Zecherieh
I have one that I made that is connected to the submit button, instead of cronjob - basically rebuilds the text file that the syndication comes off of everytime that a new thread is posted in the particular forum that I have syndicated.

Output is in rss and a couple of different formats for some scrollers. If there is interest I will look back and post the code - actually uses very little code.

how did you do that?

Lionel
29 Dec 2001, 17:52
can't access start file http://sitename/newsfeed.php

Gutspiller
03 Jul 2003, 06:17
If my forumz isn't on a dedicated server, will I still be able to use a cronjob?

Kriek
03 Jul 2003, 14:56
Perchance this may facilitate your tasks Fake Cron (http://www.smarterscripts.com/cron/)
Subsequently an external alternative Cronservice (http://www.cronservice.com)