-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhooks.php
54 lines (49 loc) · 1.56 KB
/
hooks.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
<?php
/**
* @package WHMCS openAPI
* @version 3.0.8
* @author Stergios Zgouletas | WEB EXPERT SERVICES LTD <[email protected]>
* @link http://www.web-expert.gr
* @copyright Copyright (C) 2010-2021 Web-Expert.gr All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
**/
if(!defined("WHMCS")) die("This file cannot be accessed directly");
if(isset($_REQUEST["module"]) && $_REQUEST["module"]=='openAPI' && (int)$_SESSION["adminid"]>0 && strpos($_SERVER["REQUEST_URI"],'addonmodules.php?')!==false && @$_REQUEST["task"]=="ajax")
{
require_once('init.php');
$api=WOAAPI::getInstance();
$response=array('error'=>null,'data'=>null);
$format=(isset($_REQUEST["format"]) && !empty($_POST['format']))?strtolower($_POST['format']):'json';
if(count($_POST) && !empty($_POST['addon']))
{
$addonName=filter_var($_POST['addon'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$page=(isset($_POST['page']) && !empty($_POST['page']))?filter_var($_POST['page'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH):'ajax';
$filePath=ROOTDIR.'/modules/addons/'.$addonName.'/'.$page.'.php';
if(file_exists($filePath))
{
require($filePath);
}
else
{
$response['error']='File '.$filePath.' not exists!';
}
}
else
{
$response['error']='"addon" parameter is empty!';
}
if($format=='json')
{
$api->printJSON($response);
}
else
{
header('Content-Type: text/plain');
foreach($response as $key=>$data)
{
$data=is_array($data)?json_encode($response):$data;
echo $key.'='.$data."\n";
}
exit();
}
}