diff --git a/cp/app/Controllers/SystemController.php b/cp/app/Controllers/SystemController.php index 7c07ce6..8c26eee 100644 --- a/cp/app/Controllers/SystemController.php +++ b/cp/app/Controllers/SystemController.php @@ -582,6 +582,13 @@ class SystemController extends Controller if ($args) { $args = trim($args); + + if (!empty($_SESSION['u_tld_extension'])) { + $tld_extension = $_SESSION['u_tld_extension'][0]; + } else { + $this->container->get('flash')->addMessage('error', 'No TLD specified for update'); + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } if (!preg_match('/^\.(xn--[a-zA-Z0-9-]+|[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)?)$/', $args)) { $this->container->get('flash')->addMessage('error', 'Invalid TLD format'); @@ -589,7 +596,6 @@ class SystemController extends Controller } $validators = [ - 'extension' => v::stringType()->notEmpty()->length(2, 64), 'createm0' => v::numericVal()->between(0.00, 9999999.99, true), 'createm12' => v::numericVal()->between(0.00, 9999999.99, true), 'createm24' => v::numericVal()->between(0.00, 9999999.99, true), @@ -683,7 +689,7 @@ class SystemController extends Controller $errorText = rtrim($errorText, '; '); $this->container->get('flash')->addMessage('error', $errorText); - return $response->withHeader('Location', '/registry/tld/'.$data['extension'])->withStatus(302); + return $response->withHeader('Location', '/registry/tld/'.$tld_extension)->withStatus(302); } try { @@ -691,7 +697,7 @@ class SystemController extends Controller $tld_id = $db->selectValue( 'SELECT id FROM domain_tld WHERE tld = ?', - [$data['extension']] + [$tld_extension] ); $db->update( @@ -809,13 +815,13 @@ class SystemController extends Controller // Check if the upload was successful if ($file->getError() !== UPLOAD_ERR_OK) { $this->container->get('flash')->addMessage('error', 'Upload failed with error code ' . $file->getError()); - return $response->withHeader('Location', '/registry/tld/'.$data['extension'])->withStatus(302); + return $response->withHeader('Location', '/registry/tld/'.$tld_extension)->withStatus(302); } // Validate file type and size if ($file->getClientMediaType() !== 'text/csv' || $file->getSize() > 5 * 1024 * 1024) { $this->container->get('flash')->addMessage('error', 'Invalid file type or size'); - return $response->withHeader('Location', '/registry/tld/'.$data['extension'])->withStatus(302); + return $response->withHeader('Location', '/registry/tld/'.$tld_extension)->withStatus(302); } // Process the CSV file @@ -845,20 +851,23 @@ class SystemController extends Controller ); } else { $this->container->get('flash')->addMessage('error', 'Premium names category ' . $categoryName . ' not found'); - return $response->withHeader('Location', '/registry/tld/'.$data['extension'])->withStatus(302); + return $response->withHeader('Location', '/registry/tld/'.$tld_extension)->withStatus(302); } } } } $db->commit(); - - $this->container->get('flash')->addMessage('success', 'TLD ' . $data['extension'] . ' has been updated successfully'); + + unset($_SESSION['u_tld_id']); + unset($_SESSION['u_tld_extension']); + + $this->container->get('flash')->addMessage('success', 'TLD ' . $tld_extension . ' has been updated successfully'); return $response->withHeader('Location', '/registry/tlds')->withStatus(302); } catch (Exception $e) { $db->rollBack(); $this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage()); - return $response->withHeader('Location', '/registry/tld/'.$data['extension'])->withStatus(302); + return $response->withHeader('Location', '/registry/tld/'.$tld_extension)->withStatus(302); } } else { // Redirect to the tlds view @@ -922,6 +931,9 @@ class SystemController extends Controller $tld_u = $tld['tld']; } + $_SESSION['u_tld_id'] = [$tld['id']]; + $_SESSION['u_tld_extension'] = [$tld['tld']]; + return view($response,'admin/system/manageTld.twig', [ 'tld' => $tld, 'tld_u' => $tld_u, @@ -1062,11 +1074,25 @@ class SystemController extends Controller // Retrieve POST data $data = $request->getParsedBody(); $db = $this->container->get('db'); + + if (!empty($_SESSION['u_tld_id'])) { + $tld_id = $_SESSION['u_tld_id'][0]; + } else { + $this->container->get('flash')->addMessage('error', 'No TLD specified for promotions'); + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } + + if (!empty($_SESSION['u_tld_extension'])) { + $tld_extension = $_SESSION['u_tld_extension'][0]; + } else { + $this->container->get('flash')->addMessage('error', 'No TLD specified for promotions'); + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } $sData = array(); - $sData['tldid'] = filter_var($data['tldid'], FILTER_SANITIZE_NUMBER_INT); - $sData['extension'] = substr(trim($data['extension']), 0, 10); + $sData['tldid'] = filter_var($tld_id, FILTER_SANITIZE_NUMBER_INT); + $sData['extension'] = substr(trim($tld_extension), 0, 10); $sData['promotionName'] = substr(trim($data['promotionName']), 0, 255); $sData['promotionStart'] = str_replace('T', ' ', $data['promotionStart']) . ':00'; $sData['promotionEnd'] = str_replace('T', ' ', $data['promotionEnd']) . ':00'; @@ -1115,6 +1141,9 @@ class SystemController extends Controller $db->commit(); + unset($_SESSION['u_tld_id']); + unset($_SESSION['u_tld_extension']); + $this->container->get('flash')->addMessage('success', 'Promotion updates for the ' . $sData['extension'] . ' TLD have been successfully applied'); return $response->withHeader('Location', '/registry/tlds')->withStatus(302); } catch (Exception $e) { @@ -1140,11 +1169,25 @@ class SystemController extends Controller // Retrieve POST data $data = $request->getParsedBody(); $db = $this->container->get('db'); + + if (!empty($_SESSION['u_tld_id'])) { + $tld_id = $_SESSION['u_tld_id'][0]; + } else { + $this->container->get('flash')->addMessage('error', 'No TLD specified for promotions'); + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } + + if (!empty($_SESSION['u_tld_extension'])) { + $tld_extension = $_SESSION['u_tld_extension'][0]; + } else { + $this->container->get('flash')->addMessage('error', 'No TLD specified for promotions'); + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } $sData = array(); - $sData['tldid'] = filter_var($data['tldid'], FILTER_SANITIZE_NUMBER_INT); - $sData['extension'] = substr(trim($data['extension']), 0, 10); + $sData['tldid'] = filter_var($tld_id, FILTER_SANITIZE_NUMBER_INT); + $sData['extension'] = substr(trim($tld_extension), 0, 10); $sData['phaseName'] = substr(trim($data['phaseName']), 0, 255); $sData['phaseCategory'] = substr(trim($data['phaseCategory']), 0, 255); $sData['phaseType'] = substr(trim($data['phaseType']), 0, 255); @@ -1216,6 +1259,9 @@ class SystemController extends Controller $db->commit(); + unset($_SESSION['u_tld_id']); + unset($_SESSION['u_tld_extension']); + $this->container->get('flash')->addMessage('success', 'Launch phase updates for the ' . $sData['extension'] . ' TLD have been successfully applied'); return $response->withHeader('Location', '/registry/tlds')->withStatus(302); } catch (Exception $e) { diff --git a/cp/resources/views/admin/system/createTld.twig b/cp/resources/views/admin/system/createTld.twig index 0817858..1267c30 100644 --- a/cp/resources/views/admin/system/createTld.twig +++ b/cp/resources/views/admin/system/createTld.twig @@ -150,7 +150,7 @@
-
{{ __('Set Premium Name Price Categories') }}
+
{{ __('Set Premium Name Price Categories') }}
diff --git a/cp/resources/views/admin/system/manageTld.twig b/cp/resources/views/admin/system/manageTld.twig index 0b3a082..3b2692d 100644 --- a/cp/resources/views/admin/system/manageTld.twig +++ b/cp/resources/views/admin/system/manageTld.twig @@ -32,24 +32,27 @@
{{ __('General Details') }}
-
- -
{{ tld_u }}
- -
-
- -
-
- -
{{ tld_u|length == 3 ? 'ccTLD' : (tld_u|length > 3 ? 'gTLD' : (tld_u|length == 2 ? 'Test TLD' : '')) }}
-
-
- -
{{ scriptName }}
+
+
+
{{ __('TLD Extension') }}
+
{{ tld_u }}
+
+
+
{{ __('TLD Type') }}
+
{{ tld_u|length == 3 ? 'ccTLD' : (tld_u|length > 3 ? 'gTLD' : (tld_u|length == 2 ? 'Test TLD' : '')) }}
+
+
+
{{ __('Supported Script') }}
+
{{ scriptName }}
+
+
+
DNSSEC
+
+ + {{ __('Manual') }} + +
+
@@ -147,7 +150,7 @@
-
{{ __('Set Premium Name Price Categories') }}
+
{{ __('Set Premium Name Price Categories') }}
@@ -226,10 +229,9 @@
-

{{ __('Create New Promotion') }}

+
{{ __('Create New Promotion') }}
{{ csrf.field | raw }} -
@@ -319,10 +321,9 @@
-

{{ __('Create New Phase') }}

+
{{ __('Create New Phase') }}
{{ csrf.field | raw }} -