Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi,

 

I already use this script to once a week choose at random some new specials for my website. However, I would like to set up a cron job on my server to make this script run automatically once a week, so I don't have to do it manually. The problem is that the script has to be run from the admin directory, which is ofcourse password protected. Cron jobs can't be run on scripts that are inside a password protected directory. Is there anyway I can modify the script to make it run from outside of the admin directory? I have posted the code below:

 

<?php
/*
 Filename: specials_random.php
 Created/Last Edit: 29/12/2003 8:15PM

 Created by Advis Network Systems
 http://www.advisns.com/

 Using osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com/

 Copyright (c) 2003 osCommerce & Advis Network Systems
*/



$non_count = 0;
$count = 0;

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 $expires_date = strftime("%Y-%m-%d",mktime(0,0,0,date("m"),date("d")+NUMBER_SPECIAL_DAYS,date("Y")));  

 echo $end_date;

 $random_products_query = tep_db_query("SELECT products_id, products_model, products_price from " . TABLE_PRODUCTS . " WHERE products_status ='1' and products_price > '". SPECIAL_PRODUCT_MIN_PRICE ."' order by rand() DESC limit " . NUMBER_SPECIALS);

while ($random_products=tep_db_fetch_array($random_products_query)){
  $special_product_query = tep_db_query("select products_id from " . TABLE_SPECIALS . " where products_id = " . $random_products['products_id']);
  if (tep_db_num_rows($special_product_query ) == 0 ){
	$specials_price = ($random_products['products_price'] - ((SPECIAL_PERCENTAGE / 100) * $random_products['products_price']));
	tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status) values ('" . (int)$random_products['products_id'] . "', '" . tep_db_input($specials_price) . "', '" . $date_time . "', '" . tep_db_input($expires_date) . "', '1')");	
	$count++;
  } else {
	$non_count++;
  }
}


echo "Special Products added: " . $count . "<br>";
echo "Special Products not added due to duplicates: " . $non_count . "<br>";

 

 

Any help that you can give me will be much appreciated.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...