/
import_products.php
56 lines (50 loc) · 1.68 KB
/
import_products.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env php
<?php
##################################################
#
# Copyright (c) 2004-2018 OIC Group, Inc.
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
/**
* This is meant to be called from cron to import products from a text tile.
*/
include_once('../exponent.php');
$code = 'abc123';
$code_in = '';
$filename = new stdClass();
if (php_sapi_name() == 'cli') {
$nl = "\n";
if (!empty($_SERVER['argc'])) for ($ac = 1; $ac < $_SERVER['argc']; $ac++) {
if ($_SERVER['argv'][$ac] == '-c') {
$ac++;
$code_in = $_SERVER['argv'][$ac];
} elseif (!empty($_SERVER['argv'][$ac])) {
$filename->path = BASE . $_SERVER['argv'][$ac];
}
}
} else {
$nl = '<br>';
if (!empty($_GET['code'])) {
$code_in = $_GET['code'];
}
if (!empty($_GET['filename'])) {
$filename->path = BASE . $_GET['filename'];
}
}
if ($code_in !== $code || empty($filename->path) || !file_exists($filename->path)) {
print $nl . gt('Import Products Script Error') . $nl;
exit(); //NOTE security code MUST be correct and file must exist
}
$store = new storeController();
$store->importProduct($filename);
?>