...

View Full Version : Vbulletin/Rssposter.php Need it to run without Cronimage,



lukescotty
04-23-2012, 04:41 PM
Hiya

I've been at this for days, posting on vbulletin.org & vbulletin.com trying to get a resolution, but theres no joy.

Heres what I'm after
On vbulletin, I have a rssposter which pulls rss feeds and automatically posts them as a thread. This is brilliant but it only runs the task when a user enters the forum and triggers the cronimage file. I want it to run without the need of a user to trigger it. I would like it to run say every 30min indefinite.

So i've set up a cron job on my server, to run this cron file, which runs the rssposter, but it still doesn't work. I don't know whether its the cron coding, or my server messing things up. Heres the code:


// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
ignore_user_abort(1);
@set_time_limit(0);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('SKIP_SESSIONCREATE', 1);
define('NOCOOKIES', 1);
define('THIS_SCRIPT', 'cron');
define('CSRF_PROTECTION', true);

// #################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_cron.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$filedata = vb_base64_decode('R0lGODlhAQABAIAAAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
$filesize = strlen($filedata);

// browser will think there is no more data if content-length is what is returned
// regardless of how long the script continues to execute, apart from IIS + CGI

header('Content-type: image/gif');

if (!(strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false AND strpos(SAPI_NAME, 'cgi') !== false))
{
header('Content-Length: ' . $filesize);
header('Connection: Close');
}

if (!$vbulletin->options['crontab'])
{
echo $filedata;
flush();
}

($hook = vBulletinHook::fetch_hook('cron_start')) ? eval($hook) : false;

exec_cron(17);
$db->close();
}
}


If anyone could help me out, i would much appreciate it. Or if anyone else could give me a solution to the task I want to create. I would be most greatful

Thanks for reading

Lukescotty

angst
04-23-2012, 04:54 PM
how are you executing the file in the cron job config?

lukescotty
04-23-2012, 04:58 PM
am using cpanel, and i've got the cron job like this

"php /home/sheffiel/public_html/talknightlife.co.uk/runrssposter.php"

and its selected to run every 5mins until i can get it working, then i'll change it to like once every 30min or per hour.

angst
04-23-2012, 05:00 PM
did you try running the file manually to ensure there are no errors?

alternatively, you can execute the file via 'wget' or 'lynx' and just hit the page url.

lukescotty
04-23-2012, 05:17 PM
did you try running the file manually to ensure there are no errors?

It works fine when I manually select "run now" in the vbulletin admincp


alternatively, you can execute the file via 'wget' or 'lynx' and just hit the page url.

i'm abit oblivious to this wget and/or lynx, is it some kind of software i can use to retieve data? sorry for the incompetence

angst
04-23-2012, 05:20 PM
yes, thats exactly what it is.

lynx is a text based web browser.
wget will fetch remote content.

usage: "lynx http://google.com"

lukescotty
04-23-2012, 05:38 PM
oooo i can't use that according to my host, because i'm on a shared server

going back to the code, can you see anything in there, whats causing it not to function ?

angst
04-23-2012, 05:41 PM
script looks ok, and if you able to manually run it, than I would say the script is fine. you'll need to make sure that the user you've set to execute the job has the correct permissions to access and execute the file.

lukescotty
04-23-2012, 06:07 PM
if you able to manually run it, than I would say the script is fine.
how could i manually run the cron file?


you'll need to make sure that the user you've set to execute the job has the correct permissions to access and execute the file.

I did have a user set up on the forum, with no permissions, i've changed the permissions to be able to access everything. is that what you mean regarding to "the user you've set to...."

lukescotty
04-23-2012, 07:28 PM
just had a chat with my host, and they sed I can use wget in my cron file as they've added me to the wget group. Is there anything I could apply the coding with wget to achieve this pain in the arse task, nearly a week, I've spent on this beginning to give up now

angst
04-23-2012, 07:42 PM
ok, try altering your code so that it will run via a web browser, once that is working you can use wget to hit the page in your cron job.

wget http://SomeSite.com/SomePage.php

lukescotty
04-23-2012, 08:04 PM
without sounding totally dense how do i alter the php so it can run in web browser?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum