PDA

View Full Version : VBSyndicate Hack V1


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:

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

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

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

<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

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

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


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

Steve Machol
10-09-2001, 05:38 PM
[QUOTE]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.]

Steve Machol
10-09-2001, 05:46 PM
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
10-09-2001, 07:04 PM
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
10-09-2001, 08:23 PM
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
10-11-2001, 01:23 AM
*bump* help please... I do not get why this will not work! ;(

Thanks,

Steve Machol
10-11-2001, 01:58 AM
[QUOTE]Originally posted by YourHostSucks
*bump* help please... I do not get why this will not work! ;(

Thanks,

YourHostSucks
10-11-2001, 02:20 AM
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
10-11-2001, 02:44 AM
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
10-11-2001, 02:54 AM
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
10-11-2001, 03:10 AM
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
10-11-2001, 08:18 PM
If anyone wants to see this in action, here's a site using my news feed:

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

Zecherieh
10-12-2001, 03:55 AM
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
10-12-2001, 05:24 AM
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
10-12-2001, 06:34 AM
$title=$latest["title"];

change to

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

Steve Machol
10-12-2001, 04:16 PM
Excellent! Works like a charm. Thanks!

Lionel
12-29-2001, 12:41 AM
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
12-29-2001, 03:36 PM
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
12-29-2001, 03:52 PM
can't access start file http://sitename/newsfeed.php

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

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