forked from loadedcommerce/loaded7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.php
87 lines (77 loc) · 3.78 KB
/
rpc.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
@package catalog
@author Loaded Commerce
@copyright Copyright 2003-2014 Loaded Commerce, LLC
@copyright Portions Copyright 2003 osCommerce
@license https://github.com/loadedcommerce/loaded7/blob/master/LICENSE.txt
@version $Id: rpc.php v1.0 2013-08-08 datazen $
*/
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
$_SERVER['SCRIPT_FILENAME'] = 'index.php';
require('includes/application_top.php');
$lC_Language->load('index');
$lC_Template = lC_Template::setup('index');
define('RPC_STATUS_SUCCESS', 1);
define('RPC_STATUS_NO_SESSION', -10);
define('RPC_STATUS_NO_MODULE', -20);
define('RPC_STATUS_NO_ACCESS', -50);
define('RPC_STATUS_CLASS_NONEXISTENT', -60);
define('RPC_STATUS_METHOD_NONEXISTENT', -65);
define('RPC_STATUS_NO_ACTION', -70);
define('RPC_STATUS_ACTION_NONEXISTENT', -71);
$class = 'rpc';
$first_array = array_slice($_GET, 0, 1);
$module = lc_sanitize_string(basename(key($first_array)));
if ($module == 'action') $module = strtolower($lC_Template->getCode());
$action = (isset($_GET['action']) && !empty($_GET['action'])) ? lc_sanitize_string(basename($_GET['action'])) : '';
$addon = (isset($_GET['addon']) && !empty($_GET['addon'])) ? lc_sanitize_string(basename($_GET['addon'])) : NULL;
if ($addon != NULL) {
if ( file_exists('addons/' . $addon . '/templates/' . $module . '/classes/' . $class . '.php')) {
include($lC_Vqmod->modCheck('addons/' . $addon . '/templates/' . $module . '/classes/' . $class . '.php'));
if ( method_exists('lC_' . ucfirst($module) . '_' . $class, $action) ) {
call_user_func(array('lC_' . ucfirst($module) . '_' . $class, $action));
exit;
} else {
echo json_encode(array('rpcStatus' => RPC_STATUS_METHOD_NONEXISTENT . ': lC_' . ucfirst($module) . '_' . $class . ' ' . $stat));
exit;
}
} else if ( file_exists('addons/' . $addon . '/rpc/' . $module . '/' . $class . '.php')) {
include($lC_Vqmod->modCheck('addons/' . $addon . '/rpc/' . $module . '/' . $class . '.php'));
if ( method_exists('lC_' . ucfirst($module) . '_' . $class, $action) ) {
call_user_func(array('lC_' . ucfirst($module) . '_' . $class, $action));
exit;
} else {
echo json_encode(array('rpcStatus' => RPC_STATUS_METHOD_NONEXISTENT . ': Addon: ' . $addon . ': lC_' . ucfirst($module) . '_' . $class . ' ' . $stat));
exit;
}
} else {
echo json_encode(array('rpcStatus' => RPC_STATUS_CLASS_NONEXISTENT . ': addons/' . $addon . '/templates/' . $module . '/classes/' . $class . '.php'));
exit;
}
} else {
if ( file_exists('templates/' . $module . '/classes/' . $class . '.php')) {
include($lC_Vqmod->modCheck('templates/' . $module . '/classes/' . $class . '.php'));
if ( method_exists('lC_' . ucfirst($module) . '_' . $class, $action) ) {
call_user_func(array('lC_' . ucfirst($module) . '_' . $class, $action));
exit;
} else {
echo json_encode(array('rpcStatus' => RPC_STATUS_METHOD_NONEXISTENT . ': lC_' . ucfirst($module) . '_' . $class . ' ' . $stat));
exit;
}
} else if ( file_exists('includes/rpc/' . $module . '/' . $class . '.php')) {
include($lC_Vqmod->modCheck('includes/rpc/' . $module . '/' . $class . '.php'));
if ( method_exists('lC_' . ucfirst($module) . '_' . $class, $action) ) {
call_user_func(array('lC_' . ucfirst($module) . '_' . $class, $action));
exit;
} else {
echo json_encode(array('rpcStatus' => RPC_STATUS_METHOD_NONEXISTENT . ': lC_' . ucfirst($module) . '_' . $class . ' ' . $stat));
exit;
}
} else {
echo json_encode(array('rpcStatus' => RPC_STATUS_CLASS_NONEXISTENT . ': templates/' . $module . '/classes/' . $class . '.php'));
exit;
}
}
?>