Skip to content

Commit

Permalink
Merge pull request #33 from inwx/chore_replace_deprecated_maysql_query
Browse files Browse the repository at this point in the history
Chore replace deprecated maysql query
  • Loading branch information
ddmler authored May 24, 2024
2 parents 824b0dc + c513e82 commit 3f8e277
Show file tree
Hide file tree
Showing 7 changed files with 2,958 additions and 2,181 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
version: 9
- name: Setup Node LTS
uses: actions/setup-node@v4
cache: 'pnpm'
with:
cache: 'pnpm'
node-version: "lts/*"
- name: Install dependencies
run: pnpm install
- name: Release
env:
WHMCSMP_LOGIN: ${{ variables.WHMCSMP_LOGIN }}
WHMCSMP_LOGIN: ${{ vars.WHMCSMP_LOGIN }}
WHMCSMP_PASSWORD: ${{ secrets.WHMCSMP_PASSWORD }}
WHMCSMP_PRODUCTID: ${{ variables.WHMCSMP_PRODUCTID }}
WHMCSMP_PRODUCTID: ${{ vars.WHMCSMP_PRODUCTID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm semantic-release
- name: Generate checksum
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.env
*.env
vendor
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pnpm dlx commitlint --edit $1
pnpm commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
53 changes: 28 additions & 25 deletions modules/registrars/inwx/inwx.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use WHMCS\Domains\DomainLookup\ResultsList;
use WHMCS\Domains\DomainLookup\SearchResult;
use WHMCS\Carbon;
use WHMCS\Database\Capsule;

include_once 'helpers.php';

Expand Down Expand Up @@ -942,54 +943,56 @@ function inwx_SyncDomain($params) {

$response = $domrobot->call('domain', 'info', inwx_InjectCredentials($params, $pDomain));

$synclog = '[$domain] INWX Sync Domain:';

if ($response['code'] === 2303) {
//UPDATE BBDD
$sql = 'UPDATE tbldomains SET status = \'Cancelled\'';
$sql .= ' WHERE id=\''.$params['domainid'].'\'';
$res = mysql_query($sql);
return ['error' => inwx_GetApiResponseErrorMessage($response)];
try {
Capsule::table('tbldomains')
->where('id', $params['domainid'])
->update([
'status' => 'Cancelled'
]);

return ['error' => inwx_GetApiResponseErrorMessage($response)];
} catch (Exception $e) {
return ['error' => "Couldn't update domain. {$e->getMessage()}"];
}
}

if ($response['code'] === 1000 && isset($response['resData']['domain'])) {
$exDate = (isset($response['resData']['exDate']) ? date('Y-m-d', $response['resData']['exDate']['timestamp']) : null);
$crDate = (isset($response['resData']['crDate']) ? date('Y-m-d', $response['resData']['crDate']['timestamp']) : null);
$reDate = (isset($response['resData']['reDate']) ? date('Y-m-d', $response['resData']['reDate']['timestamp']) : null);
$status = (isset($response['resData']['status']) ?: null);
$sql = 'UPDATE tbldomains SET';

if ($status === 'OK') {
$synclog .= ' status=active';
$newstatus = 'Active';
$sql .= ', `status` = \'Active\'';
$updateDetails = [];

if ($status === 'OK') {
$updateDetails['status'] = 'Active';
} else if (startsWith($status, 'TRANSFER') && !endsWith($status, 'SUCCESSFUL')) {
$synclog .= ' status=pending_transfer';
$newstatus = 'Pending Transfer';
$sql .= ' AND `status` = \'Pending Transfer\'';
$updateDetails['status'] = 'Pending Transfer';
}

// set expiration date if available
if (!is_null($exDate)) {
$synclog .= ' expirydate=$exDate';
$sql .= 'expirydate = \'' . $exDate . '\'';
$updateDetails['expirydate'] = $exDate;
}

if (!is_null($crDate)) {
$synclog .= ' registrationdate=$crDate';
$sql .= 'registrationdate = \'' . $crDate . '\'';
$updateDetails['registrationdate'] = $crDate;
}

if (!is_null($reDate)) {
$synclog .= ' nextduedate=$reDate';
$sql .= 'nextduedate = \'' . $reDate . '\'';
$updateDetails['nextduedate'] = $reDate;
}

//UPDATE BBDD
$sql .= ' WHERE id=\''.$params['domainid'].'\'';
$res = mysql_query($sql);
try {
$updatedDomain = Capsule::table('tbldomains')
->where('id', $params['domainid'])
->update($updateDetails);

return ['message' => 'success'];
return ['message' => "Updated ${updatedDomain} domain(s)."];
} catch (Exception $e) {
return ['error' => "Couldn't update domain. {$e->getMessage()}"];
}
}

return ['error' => ''];
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "WHMCS",
"name": "whmcs",
"description": "INWX WHMCS Registrar Module",
"version": "0.0.0-semantic-release",
"private": true,
"scripts": {
"semantic-release": "dotenv -- semantic-release",
"prepare": "husky"
"prepare": "bash -c 'mkdir -p ./vendor/bin ; bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) latest ./vendor/bin/' ; husky"
},
"keywords": [],
"author": {},
Expand All @@ -19,6 +19,7 @@
"cz-conventional-changelog": "^3.3.0",
"dotenv-cli": "^7.4.2",
"husky": "^9.0.11",
"lint-staged": "^15.2.4",
"semantic-release": "^23.1.1"
},
"release": {
Expand All @@ -44,5 +45,12 @@
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"volta": {
"node": "20.13.1",
"pnpm": "9.1.2"
},
"lint-staged": {
".github/workflows/**/*.yml": "./vendor/bin/actionlint"
}
}
Loading

0 comments on commit 3f8e277

Please sign in to comment.