vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   CronJob / Execute PHP file question? (https://vborg.vbsupport.ru/showthread.php?t=177176)

PhilMcKrackon 04-25-2008 09:27 PM

CronJob / Execute PHP file question?
 
I have a very simple php file I have created that dumps some table data to a file on my server. Can some one point me to some instructions on what needs to be added to the PHP file and what I should do in the scheduled tasks section of VBulletin to run the file automatically? I just need a nudge in the right direction...

If I direct my browser to the PHP page the script runs correctly and the dump file is created, but I am unsure on what to do to get VB to execute it automatically for me.

Thanks,

Code:

<?php
$host = "localhost";
$mysql_user = "????";
$mysql_password = "?????";
$sdatabase = "????";
$slink = mysql_connect("$host", "$mysql_user", "$mysql_password") or die('Database Connection Failed. Wait a moment.');
mysql_select_db ("$sdatabase", $slink);
$file = fopen("linkimages.pvc", "w");
fwrite($file,"/cmp=90 \n");
fwrite($file,"/bts=1200 \n");
fwrite($file,"/cdo=IvFxjSUmbcorg \n");
fwrite($file,"/irp=15 \n");
fwrite($file,"/ift=JPEG \n");
$urls = mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC");
while ($urlrow = mysql_fetch_array($urls)) {
fwrite($file,"| URL=");
fwrite($file, $urlrow[1]);
fwrite($file, " | ");
fwrite($file,"ifn=");
fwrite($file, $urlrow[0]);
fwrite($file,"_t.jpg |\n");
}
fclose($file);
?>


Lynne 04-25-2008 11:07 PM

This is the basic form I use for my cron jobs:

PHP Code:

<?php

// ########### SET PHP ENVIRONMENT ##################
error_reporting(E_ALL & ~E_NOTICE);

if (!
is_object($vbulletin->db))
{
    exit;
}

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

all your php goes here.  Use standard vbulletin calls for your queries.  ie:
$mysquery $vbulletin->db->query_read("
    SELECT this, that
    FROM " 
TABLE_PREFIX "table
    WHERE whatever
"
);



?>


PhilMcKrackon 04-26-2008 05:53 PM

Thanks for the reply, I still had a fit trying to get this to run inside of VB but I was able to get it to run by setting up a cronjob inside the web cpanel. The syntax was php -q /home/name/forums/.../filename.php as the GET statement is disabled on my server.

I had to add the path to php.exe on my server wich happened to be #!/usr/lib/php

Now it executes perfectly.

Thanks for the help.


All times are GMT. The time now is 08:24 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.01062 seconds
  • Memory Usage 1,721KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete