Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
fix(init.php): path detection and IDNA Converter dep-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Mar 14, 2019
1 parent eaae144 commit 0710b74
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 43 deletions.
6 changes: 5 additions & 1 deletion backend/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
$root_path .= $script_path;
}
$init_path = implode(DIRECTORY_SEPARATOR, array($root_path,"init.php"));
if (isset($GLOBALS["customadminpath"])) {
$init_path = preg_replace("/(\/|\\\)" . $GLOBALS["customadminpath"] . "(\/|\\\)init.php$/", DIRECTORY_SEPARATOR . "init.php", $init_path);
}
if (file_exists($init_path)) {
require_once($init_path);
} else {
exit("cannot find init.php");
}

require_once dirname(__FILE__).'/../vendor/autoload.php';
require_once dirname(__FILE__)."/helper.php"; //HELPER WHICH CONTAINS HELPER FUNCTIONS
use WHMCS\Database\Capsule;
use Mso\IdnaConvert\IdnaConvert;
use Algo26\IdnaConvert\IdnaConvert;

//############################
//HELPER FUNCTIONS
Expand Down
46 changes: 23 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"type": "library",
"description": "The ISPAPI Backorder Module for WHMCS.",
"keywords": [
"whmcs",
"web host automation platform",
"backorder module",
"domain backorder module",
"whmcs",
"web host automation platform",
"backorder module",
"domain backorder module",
"hexonet",
"ispapi",
"domain",
"isp",
"ssl",
"domain",
"isp",
"ssl",
"cert",
"dns",
"backorder",
Expand All @@ -25,37 +25,37 @@
"license": "MIT",
"authors": [
{
"name": "Anthony Schneider",
"homepage": "https://github.com/anthonyschn",
"name": "Anthony Schneider",
"homepage": "https://github.com/anthonyschn",
"role": "Developer"
},
{
"name": "Kai Schwarz",
"homepage": "https://github.com/papakai",
"name": "Kai Schwarz",
"homepage": "https://github.com/papakai",
"role": "Developer"
},
{
"name": "Tulasi Seelamkurthi",
"homepage": "https://github.com/tulsi91",
"name": "Tulasi Seelamkurthi",
"homepage": "https://github.com/tulsi91",
"role": "Developer"
}
],
"support": {
"email": "support@hexonet.net",
"issues": "https://github.com/hexonet/whmcs-ispapi-backorder/issues",
"source": "https://github.com/hexonet/whmcs-ispapi-backorder"
},
],
"support": {
"email": "support@hexonet.net",
"issues": "https://github.com/hexonet/whmcs-ispapi-backorder/issues",
"source": "https://github.com/hexonet/whmcs-ispapi-backorder"
},
"require": {
"php": ">=5.6.0",
"mso/idna-convert": "^1.1 || ^2.0"
"algo26-matthias/idna-convert": "^1.1 || ^2.1"
},
"require-dev": {
"phpunit/phpunit": "@stable",
"squizlabs/php_codesniffer": "^3.3"
},
"scripts": {
"codeCheck": "./vendor/bin/phpcs --standard=PSR2 -q -n --colors *.php api backend controller crons lang tests",
"codeFix": "./vendor/bin/phpcbf --standard=PSR2 -q *.php api backend controller crons lang tests",
"test": "./vendor/bin/phpunit"
"codeFix": "./vendor/bin/phpcbf --standard=PSR2 -q *.php api backend controller crons lang tests",
"test": "./vendor/bin/phpunit"
}
}
}
4 changes: 0 additions & 4 deletions controller/_language.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php
require_once dirname(__FILE__)."/../../../../init.php";

if (isset($_SESSION["Language"])) {
$language = $_SESSION["Language"];
}

if (!isset($language)) {
$language = "english";
}

$file_backorder = dirname(__FILE__)."/../lang/".$language.".php";
if (file_exists($file_backorder)) {
include($file_backorder);
Expand Down
14 changes: 13 additions & 1 deletion controller/backend.pricing.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<?php
require_once dirname(__FILE__).'/../../../../init.php';
$root_path = $_SERVER["DOCUMENT_ROOT"];
$script_path = preg_replace("/.modules.addons..+$/", "", dirname($_SERVER["SCRIPT_NAME"]));
if (!empty($script_path)) {
$root_path .= $script_path;
}
$init_path = implode(DIRECTORY_SEPARATOR, array($root_path,"init.php"));
$init_path = preg_replace("/(\/|\\\)" . $GLOBALS["customadminpath"] . "(\/|\\\)init.php$/", DIRECTORY_SEPARATOR . "init.php", $init_path);
if (file_exists($init_path)) {
require_once($init_path);
} else {
exit("cannot find init.php");
}

use WHMCS\Database\Capsule;

//INSERT ALL MISSING PRICES - NEEDED WHEN RESELLER ADDS NEW CURRENCIES
Expand Down
6 changes: 3 additions & 3 deletions controller/manage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
//inlude this _language file in all controllers
include(dirname(__FILE__)."/_language.php");
require_once implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'backend', 'api.php'));
include dirname(__FILE__) . DIRECTORY_SEPARATOR . "_language.php";

$vars["breadcrumb"][] = array("last" => false, "link" => "", "label" => "Backorder" );
$vars["breadcrumb"][] = array("last" => true, "link" => "", "label" => $_LANG["managebackorders"]);
Expand Down Expand Up @@ -32,8 +33,6 @@
$mypost[$postname]= $postvalue;
}
}

require_once '../backend/api.php';
$command = array_change_key_case($mypost, CASE_UPPER);
$result = backorder_api_query_list($command);

Expand All @@ -50,6 +49,7 @@
$datatableobject["recordsFiltered"] = $result['TOTAL'];
$datatableobject["data"] = array();
$newitem = array();

foreach ($result["ITEMS"] as $cnt => $item) {
$newitem = array();#
foreach ($fields as $field) {
Expand Down
1 change: 0 additions & 1 deletion crons/batch_active_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

date_default_timezone_set('UTC');
$cronname = "BATCH_ACTIVE_PROCESSING";
require_once dirname(__FILE__)."/../../../../init.php";
require_once dirname(__FILE__)."/../backend/api.php";

use WHMCS\Database\Capsule;
Expand Down
1 change: 0 additions & 1 deletion crons/batch_polling.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
date_default_timezone_set('UTC');
$cronname = "BATCH_POLLING";
require_once dirname(__FILE__)."/../../../../init.php";
require_once dirname(__FILE__)."/../backend/api.php";

use WHMCS\Database\Capsule;
Expand Down
3 changes: 1 addition & 2 deletions crons/batch_processing_application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

date_default_timezone_set('UTC');
$cronname = "BATCH_PROCESSING_APPLICATION";
require_once dirname(__FILE__)."/../../../../init.php";
require_once dirname(__FILE__)."/../backend/api.php";


use WHMCS\Database\Capsule;

try {
Expand Down
3 changes: 1 addition & 2 deletions crons/batch_requested_active.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

date_default_timezone_set('UTC');
$cronname = "BATCH_REQUESTED_ACTIVE";
require_once dirname(__FILE__)."/../../../../init.php";
require_once dirname(__FILE__)."/../backend/api.php";
use WHMCS\Database\Capsule;


try {
$pdo = Capsule::connection()->getPdo();
$could_not_be_set_to_active = array();
Expand Down
1 change: 0 additions & 1 deletion crons/batch_test.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
date_default_timezone_set('UTC');
$cronname = "BATCH_TEST";
require_once dirname(__FILE__)."/../../../../init.php";
require_once dirname(__FILE__)."/../backend/api.php";

// $command = array(
Expand Down
1 change: 0 additions & 1 deletion crons/daily_dropdate_synch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

date_default_timezone_set('UTC');
$cronname = "DAILY_DROPDATE_SYNCH";
require_once dirname(__FILE__)."/../../../../init.php";
require_once dirname(__FILE__)."/../backend/api.php";

use WHMCS\Database\Capsule;
Expand Down
16 changes: 13 additions & 3 deletions ispapibackorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
//if (!defined("WHMCS"))
// die("This file cannot be accessed directly");

$filename = dirname(__FILE__).'/../../../init.php';
if (file_exists($filename)) {
require_once($filename);
$root_path = $_SERVER["DOCUMENT_ROOT"];
$script_path = preg_replace("/.modules.addons..+$/", "", dirname($_SERVER["SCRIPT_NAME"]));
if (!empty($script_path)) {
$root_path .= $script_path;
}
$init_path = implode(DIRECTORY_SEPARATOR, array($root_path,"init.php"));
if (isset($GLOBALS["customadminpath"])) {
$init_path = preg_replace("/(\/|\\\)" . $GLOBALS["customadminpath"] . "(\/|\\\)init.php$/", DIRECTORY_SEPARATOR . "init.php", $init_path);
}
if (file_exists($init_path)) {
require_once($init_path);
} else {
exit("cannot find init.php");
}

use WHMCS\Database\Capsule;
Expand Down

0 comments on commit 0710b74

Please sign in to comment.