Custom Inventory Script

My store owner uploads a file containing inventory for each product. The info comes from her Great Plains accounting system. Another developer wrote a PHP script to check for this file and update the store with the data. His script is automatically run every hour via cron. It was written for 2.2, and I'm trying to adapt it to 4.1.



When I place the script in my 4.1 store and hit it directly, I get an “Access denied” error. I'm pretty sure the error is generated from this line:


require_once('config.local.php');




That pulls the database credentials needed to update the products in the store. What are the bare minimum contents the script needs in order for me to access it directly and get around the access denied issu?

Your going to have to pay someone to upgrade, can't diagnose a script without seeing it, right out of the gate your going to have to change:


if ( !defined('AREA') ) { die('Access denied'); }



to


if (!defined('BOOTSTRAP')) { die('Access denied'); }





Your going to have to go from 2 to 3, then 3 to 4, maybe the docs will help:

http://docs.cs-cart…ing_3_to_4.html

More than likely your script is using other areas of the cart. In v3/v2 every script starts with

if( !defined('AREA') ) die('Access denied');



In V4 this is changed to

if( !defined('BOOTSTRAP') ) die('Access denied');



You will need to have your script go through init.php since config.local.php is probably not seeing BOOTSTRAP being defined.

[quote name='grayloon' timestamp='1401913279' post='185095']

My store owner uploads a file containing inventory for each product. The info comes from her Great Plains accounting system. Another developer wrote a PHP script to check for this file and update the store with the data. His script is automatically run every hour via cron. It was written for 2.2, and I'm trying to adapt it to 4.1.



When I place the script in my 4.1 store and hit it directly, I get an “Access denied” error. I'm pretty sure the error is generated from this line:


require_once('config.local.php');




That pulls the database credentials needed to update the products in the store. What are the bare minimum contents the script needs in order for me to access it directly and get around the access denied issu?

[/quote]



I am not sure what files do you include and how do you include them, but try the following code:



define('BOOTSTRAP', true);
require_once('config.local.php');




And make sure what your custom script is securely protected

I have define('BOOTSTRAP', true); in my PHP script. When I hit the script from a browser, I get the following error:

Fatal error: Call to undefined function db_get_array()

Is there some other bootstrapping or initialization that must be done before my code can use that function?

You will have to port the script to V4. We are all guessing at what you have here.

Either have the original developer modify it for you or contract with myself or one of the other developers to port it for you.

V4 is quite a different beast than V3. Most everything is incompatible that was done for V2 or V3.