Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Vbulletin/Rssposter.php Need it to run without Cronimage,

    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

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    how are you executing the file in the cron job config?

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    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.

  • #5
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by angst View Post
    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

    Quote Originally Posted by angst View Post
    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

  • #6
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    yes, thats exactly what it is.

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

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

  • #7
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ?

  • #8
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    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.

  • #9
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by angst View Post
    if you able to manually run it, than I would say the script is fine.
    how could i manually run the cron file?

    Quote Originally Posted by angst View Post
    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...."

  • #10
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #11
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    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

  • #12
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    without sounding totally dense how do i alter the php so it can run in web browser?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •