opensrs-client-3.0.0/ 0000755 0177776 0177776 00000000000 10770014366 015544 5 ustar nobody nogroup 0000000 0000000 opensrs-client-3.0.0/diffs/ 0000755 0177776 0177776 00000000000 10770014370 016632 5 ustar nobody nogroup 0000000 0000000 opensrs-client-3.0.0/diffs/opensrs-client_2.9.8to3.0.0.patch 0000644 0177776 0177776 00000163350 10770014364 024313 0 ustar nobody nogroup 0000000 0000000 diff -r -c opensrs-client-2.9.8/ChangeLog opensrs-client-3.0.0/ChangeLog
*** opensrs-client-2.9.8/ChangeLog Wed Jul 25 15:55:37 2007
--- opensrs-client-3.0.0/ChangeLog Tue Mar 18 14:31:14 2008
***************
*** 1,3 ****
--- 1,17 ----
+ 2008/02/28 v3.0.0
+ - Added ability for .ASIA TLD (all configurations, scripts, and
+ templates)
+ 2007/08/21 v2.9.9
+ - cgi/manage.cgi
+ * whois privacy is no longer a paid service
+
+ - templates/manage/whois_privacy_form.html
+ * whois privacy is no longer a paid service
+ * typo fixed
+
+ - templates/reg_system/reg_period_hints.html
+ * updated .mobi min/max registration period
+
2007/05/30 v2.9.8
- lib/OpenSRS/Languamge.pm
* added language codes for .org .info .biz
diff -r -c opensrs-client-2.9.8/cgi/manage.cgi opensrs-client-3.0.0/cgi/manage.cgi
*** opensrs-client-2.9.8/cgi/manage.cgi Wed Jul 25 12:56:59 2007
--- opensrs-client-3.0.0/cgi/manage.cgi Tue Mar 18 14:31:14 2008
***************
*** 63,68 ****
--- 63,70 ----
use OpenSRS::Util::America qw(build_app_purpose_list);
use OpenSRS::Util::Common qw(make_navbar locale_build_country_list build_select_menu);
use OpenSRS::Util::Europe qw(build_eu_countries_list build_eu_languages_list build_be_languages_list);
+ use OpenSRS::Util::Asia qw(build_ced_locality_select_list build_ced_entity_type_select_list
+ build_ced_contact_type_select_list build_ced_identification_type_select_list);
# initialize global defines
$cgi = $ENV{SCRIPT_NAME};
***************
*** 962,967 ****
--- 964,988 ----
escape_hash_values( $rsp_nexus_info );
}
+ my $rsp_ced_info;
+ if ($capabilities->{ced_info}) {
+ my $xcp_ced_info = {
+ action => "get",
+ object => "domain",
+ cookie => $cookie,
+ attributes => {
+ type => "ced_info",
+ }
+ };
+ $rsp_ced_info = $XML_Client->send_cmd( $xcp_ced_info );
+ if (not $rsp_ced_info->{is_success}) {
+ $error = "Failed attempt: $rsp_ced_info->{response_text}
\n";
+ error_out($error);
+ exit;
+ }
+ escape_hash_values( $rsp_ced_info );
+ }
+
my $rsp_trademark;
if ($capabilities->{trademark}) {
my $xcp_trademark = {
***************
*** 1033,1039 ****
$HTML{old_nexus_validator} =~ tr/a-z/A-Z/;
$HTML{"category_" . $HTML{old_nexus_category}} = "checked";
}
!
if ($HTML{forwarding_email}) {
$HTML{text_comment} = '!-- ';
$HTML{text_comment_close} = ' --';
--- 1054,1072 ----
$HTML{old_nexus_validator} =~ tr/a-z/A-Z/;
$HTML{"category_" . $HTML{old_nexus_category}} = "checked";
}
!
! if ($rsp_ced_info) {
! $HTML{old_contact_type} = $rsp_ced_info->{attributes}->{ced_info}->{contact_type};
! $HTML{old_locality_country} = $rsp_ced_info->{attributes}->{ced_info}->{locality_country};
! $HTML{old_locality_city} = $rsp_ced_info->{attributes}->{ced_info}->{locality_city};
! $HTML{old_locality_state_prov} = $rsp_ced_info->{attributes}->{ced_info}->{locality_state_prov};
! $HTML{old_legal_entity_type} = $rsp_ced_info->{attributes}->{ced_info}->{legal_entity_type};
! $HTML{old_legal_entity_type_info} = $rsp_ced_info->{attributes}->{ced_info}->{legal_entity_type_info};
! $HTML{old_id_type} = $rsp_ced_info->{attributes}->{ced_info}->{id_type};
! $HTML{old_id_type_info} = $rsp_ced_info->{attributes}->{ced_info}->{id_type_info};
! $HTML{old_id_number} = $rsp_ced_info->{attributes}->{ced_info}->{id_number};
! }
!
if ($HTML{forwarding_email}) {
$HTML{text_comment} = '!-- ';
$HTML{text_comment_close} = ' --';
***************
*** 1106,1111 ****
--- 1139,1153 ----
$HTML{us_nexus_form} = get_content("$path_templates/us_nexus_form.html", \%HTML);
}
+ # include ced data form in the main html page if it is capable for .asia ced data modification
+ if ($rsp_ced_info) {
+ $HTML{contact_type_menu} = build_ced_contact_type_select_list($HTML{old_contact_type});
+ $HTML{locality_country_menu} = build_ced_locality_select_list($HTML{old_locality_country});
+ $HTML{legal_entity_type_menu} = build_ced_entity_type_select_list($HTML{old_legal_entity_type});
+ $HTML{id_type_menu} = build_ced_identification_type_select_list($HTML{old_id_type});
+ $HTML{asia_ced_form} = get_content("$path_templates/asia_ced_form.html", \%HTML);
+ }
+
# include domain whois_privacy form in the main html page if domain whois_privacy state is enabled or disabled
if ($rsp_whois_privacy->{attributes}->{changeable}) {
$HTML{whois_privacy_state} = $rsp_whois_privacy->{attributes}->{state} if ($rsp_whois_privacy);
***************
*** 1115,1131 ****
$HTML{wp_state_change_to} = 'Disable';
$HTML{whois_privacy_radio_button}='
';
- $HTML{whois_privacy_refund_notice} = '
-
--- 1687,1721 ---- | YES | NO | All UNLOCKED Domains ($domain_count) | ! ! | ! EOF ! } ! my $table_end = " |
--- 1756,1790 ---- | YES | NO | All UNLOCKED Domains ($domain_count) | ! EOF ! } ! my $table_end = " |
--- 1687,1721 ---- | YES | NO | All UNLOCKED Domains ($domain_count) | ! ! | ! EOF ! } ! my $table_end = " |
--- 1756,1790 ---- | YES | NO | All UNLOCKED Domains ($domain_count) | ! EOF ! } ! my $table_end = " |
" where code is the result code.
2000/04/11
Only require 'state' field if country is US or CA.
2000/04/10
Fields prefixed with p_ (p for private) will not be sent to the OpenSRS
server. This should help with custom client installs where there might
be sensitive data being passed through the client cgis.
Involved in this change was the renaming of the credit card fields in
reg_system.cgi.
2000/04/07
Gave manage.cgi the ability to delete unused nameservers.
2000/04/06
Enhanced client library to optionally use Crypt::Blowfish instead of
Crypt::DES.
2000/04/04
Reworked encryption system to be compatible with newer versions of
Crypt:CBC. Future versions of the client will include CBC.pm to avoid
version conflicts and confusion.
Gave manage.cgi the ability to rename a nameserver's hostname as well
as change its ip address.
2000/03/31
Enhance reg_system.cgi to optionally allow clients to provide custom
tech contact and nameserver information.
2000/03/30
Store and display the last login time and ip for manage.cgi
2000/03/29
Allow phone numbers to begin with a '+'.
2000/03/28
Converted client library into a module. Cleaned up interface between
cgis and module. Only export subs and vars if the cgis ask.
2000/03/27 - CLIENT RELEASE
Reworked client conf file to ensure that all required fields are passed
directly to OpenSRS.pl during OPENSRS_LOGIN(). This avoids having to
reach into main's namespace to get the data we need and should silence
a few complaints. :) This means that OPENSRS_LOGIN() should be passed
%OPENSRS instead of just the username and private key.
Renamed $PATH_HOME to $PATH_SOURCE in conf file for clarity.
2000/03/22
Cleaned up reg_system.cgi:
enhanced standard methods to handle bulk orders
enhanced standard templates to handle bulk orders
removed obsolete templates and methods
Adjusted reg_system.cgi register() to do lookups on domains before it
sends down the request to register them.
2000/03/20
New feature: domain transfers.
2000/03/17
Cleaned up profile setup flow in reg_system.cgi
2000/03/14
Fixed an oversight when doing domain lookups which caused the reseller
username to not get passed properly. This was causing problems
with lookup statistics.
2000/02/22
New feature: domain ownership changes.
Restructured manage.cgi templates a bit.
2000/02/17
Only require postal code for United States and Canada.
2000/02/09
Update client library and cgis to handle problems connecting to the
server more gracefully. Parse the message coming back from the server
and return the error if one is given. This should help in debugging
problem clients.
2000/02/06
Enhanced reg_system to return available domains with other tld extensions.
E.g., if test.com is queried and test.org and test.net are also available,
they will show as available.
2000/02/05
Fixed error in countries template. Thailand should be TH, not TM.
2000/01/13
Configuration file change: $PRIVATE_KEY replaces $PASSWORD.
$USERNAME and $PRIVATE_KEY can be passed through new OPENSRS_LOGIN()
method, or will be read directly from conf file for backward
compatibility.
$AUTH_TYPE is now obsolete. DES encryption is required on all versions
greater than 2.0.
2000/01/13
Changed field name master_domain to reg_domain in templates/register/
register.html for consistency. This is a backwards compatible
change.
2000/01/12
Changed manage.cgi to use a maxlength of 20 for the account password.
2000/01/12
Documentation enhancements
2000/01/11
Move debugging defines into conf file.
2000/01/10
Generate credit card expiration years dynamically in reg_system.cgi.
2000/01/07
Remove control characters from a few of the templates.
New feature: registration period, which specifies the number
of years for which to register a domain.
Fixed bulk_verify.html template which had named owner_first_name,
owner_last_name, owner_org_name without the owner_ prefix.
##################################################################
## Since pre-release 1
Fields changed:
firstname => first_name
lastname => last_name
telephone => phone
zip => postal_code
organization => org_name
Moved permission defines into hash %PERMISSIONS.
SEND_COMMAND parses response code and text, and returns the resultant
data with:
$data{_is_success} indicating a successful command.
$data{_response_code} storing the numeric code returned.
$data{_response_text} storing the response text returned.
get_nameservers returns the fqdn's of the nameserver's joined by \0.
E.g., @nameservers = split /\0/, $data{fqdn}
get_domains returns the domain_names's of the domains's joined by \0.
E.g., @domains = split /\0/, $data{domain}
Split up templates under different subdirectories.
Update conf file:
Renamed template variables.
Moved remote_host/remote_port into hashes.
Change client/server communication slightly:
We no longer prepend data with a space.
Merged in registration management client sources and templates.
New features:
deleting subuser
paging implemented when viewing domains
top navbar and secure_menu.html are generated dymanically
per the user's permission level
registration management integration
modifying a nameserver's ip address
client can change profile password
Cleaned up handling of user permissions.
Encryption system added. Controlled via OpenSRS.conf file.
New required perl modules: Digest::MD5, Crypt::CBC, Crypt::DES
Optomize client/server interaction so we only open the socket and
authenticate the reseller once per session. This allows for multiple
commands to be sent and parsed without opening a new socket each time.
Flags "billing_use_admin_info" and "tech_use_admin_info" are handled
via the client now and not the server.
opensrs-client-3.0.0/LICENSE 0000644 0177776 0177776 00000063476 10770014202 016556 0 ustar nobody nogroup 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
opensrs-client-3.0.0/README 0000644 0177776 0177776 00000000375 10770014202 016416 0 ustar nobody nogroup 0000000 0000000 Installation:
-------------
Please see documents at:
https://rrc.tucows.com/documentation
New features:
-------------
Please see ChangeLog.
For extra information on the client API, please see the documents at:
https://rrc.tucows.com/documentation
opensrs-client-3.0.0/bin/ 0000755 0177776 0177776 00000000000 10770014215 016305 5 ustar nobody nogroup 0000000 0000000 opensrs-client-3.0.0/bin/bulk_lock.pl 0000755 0177776 0177776 00000007475 10770014202 020623 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
BEGIN
{
do "/OpenSRS.conf";
# when running against live system, this must go through batch pool, rather
# than the normal one
$OPENSRS{ REMOTE_HOST } = "horizon.opensrs.net"; # TEST
# $OPENSRS{ REMOTE_HOST } = "batch.opensrs.net"; # LIVE
}
use strict;
use lib $PATH_LIB;
use OpenSRS::XML_Client;
use Getopt::Long;
my ( $lock, $unlock, $infile, $csvfile );
GetOptions(
"lock" => \$lock,
"unlock" => \$unlock,
"infile=s" => \$infile,
"csvfile=s" => \$csvfile,
) or usage();
if ( not $lock xor $unlock ) {
usage( "One of --lock or --unlock must be specified" );
}
my $lock_state = $lock ? 1 : 0;
if ( $infile and $csvfile ) {
usage( "Only one of --infile and --csvfile can be specified");
}
my @domain_list = get_domain_list();
if ( not scalar @domain_list ) {
usage( "No domains specified" );
}
my $XML_Client = OpenSRS::XML_Client->new( %OPENSRS );
$XML_Client->login;
open GOOD, ">logfile.good" or die "Can't open logfile.good for writing: $!";
open BAD, ">logfile.bad" or die "Can't open logfile.bad for writing: $!";
open SKIP, ">logfile.skip" or die "Can't open logfile.skip for writing: $!";
foreach my $fh ( \*GOOD, \*BAD, \*SKIP ) {
my $oldfh = select $fh;
$| = 1;
select $oldfh;
}
foreach my $domain ( @domain_list ) {
my $resp = $XML_Client->send_cmd(
{
action => 'modify',
object => 'domain',
attributes => {
data => 'status',
domain_name => $domain,
lock_state => $lock_state,
},
}
);
print "$domain: $resp->{ response_text }\n";
if ( not $resp->{ is_success } ) {
if ( $resp->{ response_code } == 450 ) {
# tld doesn't support locking, or status can't be updated
print SKIP "$domain: $resp->{ response_text }\n";
} else {
# domain info not found, or invalid request
print BAD "$domain: $resp->{ response_text }\n";
}
} else {
print GOOD "$domain: $resp->{ response_text }\n";
}
sleep 1;
}
$XML_Client->logout;
print "\nCompleted\n";
sub get_domain_list {
my $fh;
my $file = $infile || $csvfile || undef;
if ( defined $file ) {
open $fh, $file or usage( "Can't open $file for reading: $!" );
} else {
$fh = \*STDIN;
};
my @domain_list = <$fh>;
# for csv-files, a bit of mangling is required.
if ( defined $csvfile ) {
# the first item in list is a field specifier. Ignore it.
shift @domain_list;
# for the remainder of the file, the domain name is the 3rd field.
@domain_list = map { (split /,/)[2] } @domain_list;
}
@domain_list =
map { s/(^\s+)|(\s+$)//g; /^(\S+)/; $1 }
grep { /\S/ }
@domain_list;
return @domain_list;
}
sub usage {
my $message = shift;
print < [--infile=|--csvfile=]
where:
- one of --lock or --unlock must be specified. Domain status will be set
to this state.
- if --infile is specified, file given should contain a list of
domains to lock/unlock, one per line.
- if --csvfile is specified, the file given should contain a CSV format
list of domains, as supplied through RWI 'Search domains->Results to
File'.
- if neither --infile nor --csvfile are specified, the domain list will be
accepted on standard input, and should consist of only a single domain
per line
the following logfiles will be created
logfile.good
list of domains for which lock status successfully updated
logfile.bad
list of domains for which lock status could not be set due to internal
problem (usually bad command, or domain not found)
logfile.skip
list of domains for which the lock status could not be set due to
non-error condition (usually if the domain is with another reseller,
TLD does not support domain locking, or the domain is locked at the
registry level)
EOF
exit;
}
opensrs-client-3.0.0/cgi/ 0000755 0177776 0177776 00000000000 10770014215 016277 5 ustar nobody nogroup 0000000 0000000 opensrs-client-3.0.0/cgi/Punycode.cgi 0000755 0177776 0177776 00000011274 10770014202 020555 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
# .Copyright (C) 2004 Tucows Inc.
# .Created: 04/02/2004
# .Contactid:
# .Url: http://www.opensrs.org
# .Authors: Vlad Jebelev, Tom Lovasic, Steve Knipe, Vedran Vego
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use vars qw($cgi $path_templates %in $flag_header_sent %strings);
BEGIN {
$path_to_config = "";
do "$path_to_config/OpenSRS.conf";
}
use warnings;
use strict;
use lib $PATH_LIB;
use CGI ':cgi-lib';
use HTML::Template;
use RACE;
use OpenSRS::Util::Common;
use OpenSRS::Language qw/native_to_puny puny_to_native/;
RACE::Initialise(%RACESETTINGS);
$cgi = $ENV{SCRIPT_NAME};
$path_templates = "$PATH_TEMPLATES/PUNYCODE";
$flag_header_sent = 0;
%strings = ();
%in = ();
ReadParse(\%in);
foreach (keys %in) {
$in{$_} =~ s/(^\s+)|(\s+$)//g;
}
start_up();
my $type = $in{type};
my $text = $in{input};
if ( $text ) {
if ($type eq 'NATIVE') {
$strings{native} = $text;
eval { $strings{race} = native_to_race($text)};
if ( $@ ) { $strings{race} = undef; $strings{error_race} = $@; }
eval { $strings{punycode} = native_to_puny($text, \%OPENSRS)};
if ( $@ ) { $strings{punycode} = undef; $strings{error_punycode} = $@; }
} elsif ($type eq 'RACE') {
eval { $strings{native} = race_to_native($text)};
if ( $@ ) { $strings{native} = undef; $strings{error_native} = $@; }
$strings{race} = $text;
eval { my $native = race_to_native($text);
$strings{punycode} = native_to_puny($native, \%OPENSRS)};
if ( $@ ) { $strings{punycode} = undef; $strings{error_punycode} = $@; }
} elsif ($type eq 'PUNYCODE') {
eval { $strings{native} = puny_to_native($text, \%OPENSRS)};
if ( $@ ) { $strings{native} = undef; $strings{error_native} = $@; }
eval { my $native = puny_to_native($text, \%OPENSRS);
$strings{race} = native_to_race($native)};
if ( $@ ) { $strings{race} = undef; $strings{error_race} = $@; }
$strings{punycode} = $text;
}
}
main_menu();
exit;
sub native_to_race {
my ( $str ) = @_;
my $conv = RACE::DoRACE( Domain => $str, EncodingType => $OPENSRS{IDN_ENCODING_TYPE});
if ($conv->{Error}){
die $conv->{Error}."\n";
}
return $conv->{ConvertedDomain};
}
sub race_to_native {
my ( $str ) = @_;
my $conv = RACE::UndoRACE( Domain => $str, EncodingType => $OPENSRS{IDN_ENCODING_TYPE});
if ($conv->{Error}){
die $conv->{Error}."\n";
}
return $conv->{OriginalDomain};
}
sub main_menu {
my (%HTML);
print_form(template => "$path_templates/base.html",
data => {
%in,
%strings,
encoding => uc $OPENSRS{IDN_ENCODING_TYPE},
show_results => (scalar(keys %strings) > 0 ? 1 : 0),
show_race => ($in{type} ne 'RACE' && exists $strings{race}),
show_native => ($in{type} ne 'NATIVE' && exists $strings{native}),
show_punycode => ($in{type} ne 'PUNYCODE' && exists $strings{punycode}),
});
}
sub print_form {
my %args = @_;
$args{title} = $args{title} || 'IDN Converter';
my $template = HTML::Template->new(
cache => 1,
filename => $args{template},
die_on_bad_params => 0,
);
$template->param(
CGI => $cgi,
%{ $args{data} },
);
if (not $args{not_framed}) {
my $content = $template->output;
$template = HTML::Template->new(
cache => 1,
filename => "$path_templates/base.html",
die_on_bad_params => 0,
);
$template->param(CONTENT => $content);
}
$template->param(
CGI => $cgi,
%{ $args{data} },
);
print_header();
print $template->output;
}
# print html header
sub print_header {
my %cookies = @_;
return if $flag_header_sent;
print "Content-type: text/html\r\n";
foreach my $key (keys %cookies) {
printf "Set-Cookie: %s=%s; PATH=;\r\n", $key, $cookies{$key};
}
print "\r\n";
$flag_header_sent = 1;
}
sub start_up {
OpenSRS::Util::Common::initialize(
path_templates => $PATH_TEMPLATES,
mail_settings => \%MAIL_SETTINGS
);
}
opensrs-client-3.0.0/cgi/ca_reg.cgi 0000755 0177776 0177776 00000111003 10770014202 020176 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
# .Copyright (C) 1999-2002 TUCOWS.com Inc.
# .Created: 11/19/1999
# .Contactid:
# .Url: http://www.opensrs.org
# .Originally Developed by:
# Tucows/OpenSRS
# .Authors: Evgeniy Pirogov
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# pull in conf file with defined values
# XXX NOTE XXX Update this configuration file
use vars qw/$path_to_config $q $session %in $path_templates $error/;
BEGIN {
$path_to_config = '';
do "$path_to_config/OpenSRS.conf";
}
use lib $PATH_LIB;
use OpenSRS::Util::ConfigJar "$path_to_config/OpenSRS.conf";
use strict;
use CGI qw();
use HTML::Template;
use Core::Exception;
use OpenSRS::XML_Client;
use OpenSRS::Util::Common qw/locale_build_country_list build_select_menu CODE_2_Country send_email/;
use OpenSRS::Util::Error;
use OpenSRS::Util::Canada qw/@municipal_prefix legal_type_list %canada_legal_types %legal_types %lang_pref %legal_type_groups help_icon %canada_province/;
use OpenSRS::Util::Logger '$Log';# => "$PATH_LOG/ca_reg.txt", qw/info error debug/;
use OpenSRS::Util::Logger '$Billing';# => "$PATH_LOG/billing_ca.txt", qw/info/;
use OpenSRS::Util::Session;
use Data::Dumper;
use constant CC_TYPES => {
visa => "Visa",
mastercard => "Mastercard",
amex => "American Express",
discover => "Discover",
};
use constant ACTION_MAP => {
show_lookup => \&show_lookup,
lookup => \&lookup,
blocker_ok => \&blocker_ok,
legal_type_quiz => \&legal_type_quiz,
legal_type_quiz2 => \&legal_type_quiz2,
verify_legal_type => \&verify_legal_type,
setup_contact => \&setup_contact,
setup_contact2 => \&setup_contact2,
setup_profile => \&setup_profile,
create_new_profile => \&create_new_profile,
link_osrs_profile => \&link_osrs_profile,
how_to_link_ca => \&how_to_link_ca,
link_ca_domain => \&link_ca_domain,
link_ca_domain2 => \&link_ca_domain2,
verify_order => \&verify_order,
submit_order => \&submit_order,
help => \&help,
help_icon => \&help_icon,
};
$q = new CGI;
try {
%in = $q->Vars;
undef $error;
$session = OpenSRS::Util::Session->restore(
$in{session},
$in{sign},
$OPENSRS{private_key});
$Log->debug('restored session %s', Dumper($session));
$session->{history} = [] unless ref $session->{history} eq 'ARRAY';
delete $in{session};
delete $in{sign};
$Log->debug('got from web %s', Dumper(\%in));
$path_templates = "$PATH_TEMPLATES/ca_reg";
local $ENV{HTML_TEMPLATE_ROOT} = "$PATH_TEMPLATES/ca_reg";
my $action = $in{action};
delete $in{action};
my $back = $in{back}||0;
delete $in{back};
if ($back){
$Log->debug('back buton pressed');
shift @{$session->{history}};
my $state = shift @{$session->{history}};
if ($state) {
$action = $state->{action};
%in = %{$state->{in}};
} else {
$action = '';
$in{affiliate_id} = $session->{affiliate_id};
}
}
$action ||= 'show_lookup';
$Log->debug('try to process action %s with %s', $action, Dumper(\%in));
unless (ACTION_MAP->{$action}){
throw 'web',"Invalid Action '%s'",$action;
}
my ($template,@ret_data) = &{ACTION_MAP->{$action}}();
if (defined $error){
my $state = ${$session->{history}}[0];
my %error_in = (%in);
if ($state){
$action = $state->{action};
%in = %{$state->{in}};
} else {
$action = 'show_lookup';
$in{affiliate_id} = $session->{affiliate_id};
}
($template,@ret_data) = &{ACTION_MAP->{$action}}();
push @ret_data,%error_in,%$error;
} else {
unshift @{$session->{history}},{action => $action, in=>{%in}};
}
my %data = (cgi => $q->url,@ret_data) ;
if ($template) {
$template = HTML::Template->new(
filename => $template,
die_on_bad_params => 0);
$template->param(%data);
$template->param($session->dump($OPENSRS{private_key}));
# if ($REG_SYSTEM{debug}){
# $template->param(dumper => scalar Dumper(\%data,$session));
# }
print $q->header;
print $template->output;
}
} catch {
dev => sub {
my $E = shift;
$Log->fatal("dev error %s",$E->dump);
print $q->header;
error_output($E->info);
},
_other => sub {
my $E = shift;
$Log->error("other %s",$E->dump);
print $q->header;
error_output();
},
};
exit;
sub show_lookup {
$session->{history} = [];
return 'lookup.html',
municipality_list => [ map { {prefix=>$_} } @municipal_prefix],
@_;
}
sub lookup {
$session->{affiliate_id} = $in{affiliate_id};
my $client = new OpenSRS::XML_Client( %OPENSRS,
lookup_all_tlds => 0);
$client->login;
#do lookup and see
my @parts = ();
push @parts => $in{prefix} if $in{prefix};
push @parts => $in{root};
push @parts => $in{suffix};
my $domain = join (".",@parts);
$session->add( domain => $domain);
$session->add( prefix => $in{prefix});
my $response = $client->send_cmd({
action => 'lookup',
object => 'domain',
attributes => {
domain => $domain,
affiliate_id => $in{affiliate_id}
}
});
$Log->debug('Got this lookup %s',Dumper($response));
#problem with is_success and noserice
#has to check for noservice before is_success
if ( $response->{attributes}{status} eq 'invalid' and
$response->{attributes}{noservice} and
$F_QUEUE_SUPPLIER_UNAVAILABLE) {
#it may be blocker or municipal - we don't know here because of outage
#let's pray it will be regular domain without addinional headache
#if you don't want to deal with .ca when CIRA is out -
#just comment out following return
$session->add(
ca_reg_type => 'regular',
);
return 'new_ca_domain.html',
domain => $session->{domain},
period => $session->{period},
linked => $session->{linked},
allow_auto_renew => $REG_SYSTEM{allow_auto_renew},
auto_renew => $session->{auto_renew},
isa_trademark => $session->{isa_trademark};
}
#error
unless ($response->{is_success} or $F_QUEUE_SUPPLIER_UNAVAILABLE ){
throw 'comm','Communication error %s',Dumper($response);
}
if ($response->{attributes}{status} eq 'available'){
#available
if ($response->{response_code} == 247){
#municipal
$session->add(
ca_reg_type => 'municipal',
);
return 'new_municipal_domain.html',
domain => $session->{domain},
period => $session->{period},
linked => $session->{linked},
auto_renew => $session->{auto_renew},
allow_auto_renew => $REG_SYSTEM{allow_auto_renew};
} elsif ($response->{response_code} == 246){
#blocker
my $blockers = $client->send_cmd({
action => 'get_ca_blocker_list',
object => 'domain',
attributes => {
domain => $domain,
}
});
$Log->debug('Blocker list %s',Dumper($blockers));
my @blockers = ();
if ( $blockers->{is_success} and
ref $blockers->{attributes}{blocker_list} eq 'HASH'){
@blockers = map {{name => $_ }} keys %{$blockers->{attributes}{blocker_list}};
}
return 'blocked_domain.html',
domain => $domain,
blockers => \@blockers;
} else {
#regular domain;
$session->add(
ca_reg_type => 'regular',
);
return 'new_ca_domain.html',
domain => $session->{domain},
period => $session->{period},
linked => $session->{linked},
allow_auto_renew => $REG_SYSTEM{allow_auto_renew},
auto_renew => $session->{auto_renew},
isa_trademark => $session->{isa_trademark};
}
}
#invalid
$error->{error} = $response->{response_text};
}
sub blocker_ok{
if ($in{has_permission} =~ /yes/i){
$session->add(ca_reg_type => 'blocker');
return 'new_ca_domain.html',
domain => $session->{domain},
period => $session->{period},
linked => $session->{linked},
allow_auto_renew => $REG_SYSTEM{allow_auto_renew},
auto_renew => $session->{auto_renew},
isa_trademark => $session->{isa_trademark};
}
return show_lookup( error => qq/
Sorry,
You may not register this domain unless you are able
to obtain permission from the owner(s) of the
blocking domain(s)
/);
}
sub legal_type_quiz {
$session->add(period => $in{period});
$session->add(isa_trademark => $in{isa_trademark});
$session->add(linked => $in{linked});
$session->add(auto_renew => $REG_SYSTEM{allow_auto_renew} && $in{auto_renew});
unless ($in{period}){
$error->{error} = q/Invalid period specified/;
$error->{error_period} = 1;
return;
}
if ($in{linked}){
return how_to_link_ca();
}
if ($session->{ca_reg_type} eq 'municipal'){
my %legal_type_group = legal_type_list('government');
return 'government_org_name.html',
reg_name => $session->{reg_name},
reg_desc => $session->{reg_desc},
legal_type_list => $legal_type_group{list};
}
return 'legal_type_questionnaire.html', $session->{legal_t}.'_legal_t' => 1;
}
sub legal_type_quiz2 {
unless ($in{legal_t}){
$error->{error} = qq/You haven't selected legal type group/;
return;
}
if ($in{legal_t} ne $session->{legal_t}){
$session->add(legal_type => undef);
}
$session->add(legal_t => $in{legal_t});
my %legal_type_group = legal_type_list($in{legal_t});
my $Choose_Legal_Type = $legal_type_group{'choose_legal_type'} || 'Choose Legal Type';
my $legal_type_list = $legal_type_group{'list'};
return 'choose_legal_type.html',
Choose_Legal_Type => $Choose_Legal_Type,
legal_type_list => $legal_type_list,
legal_type => $session->{legal_type},
long => $canada_legal_types{$session->{legal_type}},
reg_name => $session->{reg_name},
reg_desc => $session->{reg_desc},
legal_t => $in{legal_t},
intro => $legal_type_groups{$in{legal_t}}{intro};
}
sub verify_legal_type {
$in{reg_name} =~ s/^\s+//;
$in{reg_name} =~ s/\s+$//;
$in{reg_desc} =~ s/^\s+//;
$in{reg_desc} =~ s/\s+$//;
$session->add(reg_name => $in{reg_name});
$session->add(reg_desc => $in{reg_desc});
$session->add(legal_type => $in{legal_type});
my %error;
if ($in{reg_name} eq ''){
$error{error} = "Registrant name can't be empty";
$error{error_reg_name} = 1;
}
if (!exists $canada_legal_types{$in{legal_type}}){
$error{error} .= "
\nYou haven't specified legal type";
$error{error_legal_type} = 1;
}
if (keys %error){
$error = \%error;
return;
}
return 'verify_reg_name.html',
reg_name => $in{reg_name},
legal_t => $session->{legal_t},
%{$legal_types{$in{legal_type}}};
}
sub setup_contact {
$in{reg_name} =~ s/^\s+//;
$in{reg_name} =~ s/\s+$//;
$session->add(reg_name => $in{reg_name});
$session->add(data_source => 'manual') unless $session->{data_source};
if ($in{reg_name} eq ''){
$error->{error} = "Registrant name can't be empty";
$error->{error_reg_name} = 1;
return;
}
return 'ret_domain_info.html',
source_domain => $session->{source_domain},
source_username => $session->{source_username},
source_password => $session->{souce_password},
"data_source_".$session->{data_source} => 1;
}
sub get_info_from_osrs {
my ($domain,$username,$password) = @_;
my $client = new OpenSRS::XML_Client( %OPENSRS);
$client->login;
my $response = $client->send_cmd({
action => "get",
object => "domain",
attributes => {
type => "all_info",
reg_username => $username,
reg_password => $password,
domain => $domain,
}
});
$Log->debug('got from opensrs %s',Dumper($response));
if (not $response->{is_success}) {
return (is_success => 0, error => "Failed attempt: ".
$response->{response_text});
}
my %hash = (is_success => 1, reg_name => $response->{attributes}{contact_set}{owner}{org_name});
foreach my $field (qw/ org_name first_name last_name address1 address2 city country state postal_code phone fax email/){
$hash{"admin_$field"} = $response->{attributes}{contact_set}{admin}{$field};
$hash{"tech_$field"} = $response->{attributes}{contact_set}{tech}{$field};
}
my $fqdnCounter = 1;
foreach my $nameserver ( @{$response->{attributes}{nameserver_list}}) {
$hash{"fqdn$fqdnCounter"} = $nameserver->{name};
$fqdnCounter++;
}
if ($domain =~ /\.ca/){
$hash{'legal_type'} = $response->{attributes}{legal_type};
$hash{'cira_member'} = ($response->{attributes}{member} eq 'Y'?1:0);
$hash{'reg_desc'} = $response->{attributes}{domain_description};
$hash{'reg_name'} = $response->{attributes}{contact_set}{owner}{org_name};
$hash{"admin_pref_language"} = $response->{attributes}{contact_set}{admin}{lang_pref};
$hash{"tech_pref_language"} = $response->{attributes}{contact_set}{tech}{lang_pref};
}
return %hash;
}
sub setup_contact2{
my %HTML = (custom_dns => $REG_SYSTEM{custom_nameservers},
custom_tech => $REG_SYSTEM{custom_tech_contact});
$session->add(data_source => $in{data_source});
if ($in{data_source} eq 'domain'){
#retreive info from OpenSRS
unless ($in{source_domain} and
$in{source_username} and
$in{source_password}){
$error->{error} = 'Domain, username and password are required to retreive information ';
$error->{error_source_domain} = !$in{source_domain};
$error->{error_source_username} = !$in{source_username};
$error->{error_source_password} = !$in{source_password};
return;
}
$session->add(source_domain => $in{source_domain});
$session->add(source_username => $in{source_username});
$session->add(source_password => $in{source_password});
my %data = get_info_from_osrs( $in{source_domain},
$in{source_username},
$in{source_password});
unless ($data{is_success}){
$error->{error} = $data{error};
return;
}
foreach my $field (qw/ org_name first_name last_name address1 address2 city country state postal_code phone fax pref_language email/){
$HTML{"admin_$field"} = $data{"admin_$field"};
}
if ($REG_SYSTEM{custom_tech_contact}){
foreach my $field (qw/ org_name first_name last_name address1 address2 city country state postal_code phone fax pref_language email/){
$HTML{"tech_$field"} = $data{"tech_$field"};
}
}
if ($REG_SYSTEM{custom_nameservers}){
foreach my $i (1..6){
$HTML{"fqdn$i"} = $data{"fqdn$i"};
}
}
}
$HTML{tech_country_list} = locale_build_country_list($session->{tech_country}||$HTML{tech_country}||'CA');
$HTML{admin_country_list} = locale_build_country_list($session->{admin_country}||$HTML{admin_country}||'CA');
$HTML{tech_pref_language} ||= 'EN';
$HTML{admin_pref_language} ||= 'EN';
$HTML{tech_lang_long} = $lang_pref{ $session->{tech_pref_language}||
$HTML{tech_pref_language}||'EN'};
$HTML{admin_lang_long} = $lang_pref{$session->{admin_pref_language}||
$HTML{admin_pref_language}||'EN'};
return 'domain_info.html',%HTML,%$session;
}
sub setup_profile {
$session->add(existing_profile => $in{existing_profile});
$session->add(rant_no => 0); #not existing CIRA's profile
$session->add(ca_link_domain => 0); #not linked to CIRA's profile of
#existing .ca opensrs domain
$session->add(cira_member => $in{cira_member});
$session->add(tec_as_admin => $in{tec_as_admin});
my %error = (error => '');
#save contact info into session
#save dns info into session
foreach my $field (qw/ org_name first_name last_name address1 address2 city country state postal_code phone fax pref_language email/){
$session->add("admin_$field" => $in{"admin_$field"});
if ($REG_SYSTEM{custom_tech_contact}){
if ($in{tec_as_admin}){
$session->add("tech_$field" => $in{"admin_$field"});
} else {
$session->add("tech_$field" => $in{"tech_$field"});
}
}
}
if ($REG_SYSTEM{custom_nameservers}){
my $webfqdnCounter = 1;
my $fqdnCounter = 1;
while ($webfqdnCounter <= 6){
if ($in{"fqdn$webfqdnCounter"}){
$session->add("fqdn$fqdnCounter" => $in{"fqdn$webfqdnCounter"});
$fqdnCounter++;
}
$webfqdnCounter++;
}
}
#now check contact and DNS
if ($REG_SYSTEM{custom_nameservers}){
unless ($session->{'fqdn1'}){
$error{error} .= 'First DNS is mandatory parameter
';
$error{error_fqdn1} = 1;
}
unless ($session->{'fqdn2'}){
$error{error} .= 'Second DNS is mandatory parameter
';
$error{error_fqdn2} = 1;
}
}
#now check admin
unless ($session->{admin_first_name}){
$error{error} .= 'Admin First name is mandatory parameter
';
$error{error_admin_first_name} = 1;
}
unless ($session->{admin_last_name}){
$error{error} .= 'Admin Last name is mandatory parameter
';
$error{error_admin_last_name} = 1;
}
unless ($session->{admin_pref_language}){
$error{error} .= 'Admin Preferred Language is mandatory parameter
';
$error{error_admin_pref_language} =1;
}
unless ($session->{admin_org_name}){
$error{error} .= 'Admin Organization name is mandatory parameter
';
$error{error_admin_org_name} = 1;
}
unless ($session->{admin_address1}){
$error{error} .= 'Admin Street address is mandatory parameter
';
$error{error_admin_address1} = 1;
}
unless ($session->{admin_city}){
$error{error} .= 'Admin City is mandatory parameter
';
$error{error_admin_city} = 1;
}
unless ($session->{admin_state}){
$error{error} .= 'Admin Province is mandatory parameter
';
$error{error_admin_state} = 1;
}
unless ($session->{admin_country}){
$error{error} .= 'Admin Country is mandatory parameter
';
$error{error_admin_country} = 1;
}
if ($session->{admin_country} eq 'CA' and
not exists $canada_province{$session->{admin_state}}){
$error{error} .= 'Invalid Canadian Province for Admin contact
';
$error{error_admin_state} = 1;
}
unless ($session->{admin_postal_code}){
$error{error} .= 'Admin Postal Code is mandatory parameter
';
$error{error_admin_postal_code} = 1;
}
if ($session->{admin_phone}) {
unless (OpenSRS::Syntax::PhoneSyntax($session->{"admin_phone"})){
$error{error} .= 'Invalid Admin Phone format
';
$error{error_admin_phone} = 1;
}
} else {
$error{error} .= 'Admin Phone is mandatory parameter
' ;
$error{error_admin_phone} = 1;
}
if ($session->{admin_email}) {
unless (OpenSRS::XML_Client::check_email_syntax($session->{admin_email})){
$error{error} .= 'Invalid Admin Email format
';
$error{error_admin_email} = 1;
}
} else {
$error{error} .= 'Admin Email is mandatory parameter
';
$error{error_admin_email} = 1;
}
#check tech if custom
if ( $REG_SYSTEM{custom_tech_contact} and
not $in{tec_as_admin}){
unless ($session->{tech_first_name}){
$error{error} .= 'Tech First name is mandatory parameter
';
$error{error_tech_first_name} = 1;
}
unless ($session->{tech_last_name}){
$error{error} .= 'Tech Last name is mandatory parameter
';
$error{error_tech_last_name} = 1;
}
unless ($session->{tech_pref_language}){
$error{error} .= 'Tech Preferred Language is mandatory parameter
';
$error{error_tech_pref_language} =1;
}
unless ($session->{tech_org_name}){
$error{error} .= 'Tech Organization name is mandatory parameter
';
$error{error_tech_org_name} = 1;
}
unless ($session->{tech_address1}){
$error{error} .= 'Tech Street address is mandatory parameter
';
$error{error_tech_address1} = 1;
}
unless ($session->{tech_city}){
$error{error} .= 'Tech City is mandatory parameter
';
$error{error_tech_city} = 1;
}
unless ($session->{tech_state}){
$error{error} .= 'Tech Province is mandatory parameter
';
$error{error_tech_state} = 1;
}
unless ($session->{tech_country}){
$error{error} .= 'Tech Country is mandatory parameter
';
$error{error_tech_country} = 1;
}
if ($session->{tech_country} eq 'CA' and
not exists $canada_province{$session->{tech_state}}){
$error{error} .= 'Invalid Canadian Province for Tech contact
';
$error{error_tech_state} = 1;
}
unless ($session->{tech_postal_code}){
$error{error} .= 'Tech Postal Code is mandatory parameter
';
$error{error_tech_postal_code} = 1;
}
if ($session->{tech_phone}) {
unless (OpenSRS::Syntax::PhoneSyntax($session->{"tech_phone"})){
$error{error} .= 'Invalid Tech Phone format
';
$error{error_tech_phone} = 1;
}
} else {
$error{error} .= 'Tech Phone is mandatory parameter
' ;
$error{error_tech_phone} = 1;
}
if ($session->{tech_email}) {
unless (OpenSRS::XML_Client::check_email_syntax($session->{tech_email})){
$error{error} .= 'Invalid Tech Email format
';
$error{error_tech_email} = 1;
}
} else {
$error{error} .= 'Admin Tech is mandatory parameter
';
$error{error_tech_email} = 1;
}
}
if ($error{error} ){
$error = \%error;
return;
}
#now let see what we need to do with profile
if ($in{existing_profile}){
return 'link_osrs_profile.html',
reg_username => $session->{reg_username},
reg_domain => $session->{reg_domain},
reg_password => $session->{reg_password} ;
} else {
return 'new_profile.html',
reg_username => $session->{reg_username},
reg_password => $session->{reg_password} ;
}
}
sub create_new_profile{
my %error = (error => '');
if (not $in{reg_username}) {
$error{error} .= "No username supplied
";
$error{error_reg_username} = 1;
}
$session->add(reg_username => $in{reg_username});
if (not $in{reg_password}) {
$error{error} .= "No password supplied
";
$error{error_reg_password} = 1;
}
if ($in{reg_password} ne $in{verify_password}){
$error{error} .= "Password mismatch
";
}
if ($in{reg_password} !~ /^[A-Za-z0-9\[\]\(\)!@\$\^,\.~\|=\-\+_\{\}\#]+$/) {
$error{error} .= "Invalid password syntax: The only allowed characters are all alphanumerics (A-Z, a-z, 0-9) and symbols []()!@\$^,.~|=-+_{}#
";
$error{error_reg_password} = 1;
}
if (length $in{reg_password} < 3 || length $in{reg_password} > 20) {
$error{error} = "Invalid password length: Password should contain at least 3 and at most 20 characters.
";
$error{error_reg_password} = 1;
}
if ($error{error}){
$error = \%error;
return;
}
$session->add(reg_password => $in{reg_password});
$session->add(reg_domain => undef);
if ( $F_SHOW_CC_FIELDS ) {
return show_payment_info();
} else {
return verify_order();
}
}
sub link_osrs_profile{
my %error = (error => '');
if (not $in{reg_username}) {
$error{error} .= "No username supplied
";
$error{error_reg_username} = 1;
}
$session->add(reg_username => $in{reg_username});
if (not $in{reg_password}) {
$error{error} .= "No password supplied
";
$error{error_reg_password} = 1;
}
$session->add(reg_password => $in{reg_password});
if (not $in{reg_domain}) {
$error{error} .= "No Domain name supplied
";
$error{error_reg_domain} = 1;
}
$session->add(reg_domain => $in{reg_domain});
if ($session->{ca_link_domain} and
$in{reg_domain} !~ /\.ca$/){
$error{error} .= 'Existing domain has to be .ca domain
';
$error{error_reg_domain} = 1;
}
if ($error{error}){
$error = \%error;
return;
}
my $client = new OpenSRS::XML_Client( %OPENSRS);
$client->login;
my $response = $client->send_cmd({
action => "set",
object => "cookie",
attributes => {
domain => $in{reg_domain},
reg_username => $in{reg_username},
reg_password => $in{reg_password},
}
});
$Log->debug('Got from OpenSRS on set cookie %s', Dumper($response));
if (not $response->{is_success}) {
$error->{error} = "$response->{response_text}
\n";
return;
}
if (not $response->{attributes}->{cookie}){
$error->{error} = "Invalid username/password given.
\n";
return;
}
if ($session->{ca_link_domain}){
my %data = get_info_from_osrs( $in{reg_domain},
$in{reg_username},
$in{reg_password});
unless ($data{is_success}){
$error->{error} = $data{error};
return;
}
foreach my $field (qw/ org_name first_name last_name address1 address2 city country state postal_code phone fax pref_language email/){
$session->add("admin_$field" => $data{"admin_$field"});
$session->add("tech_$field" => $data{"tech_$field"});
}
$session->add('legal_type' => $data{legal_type});
$session->add('cira_member' => $data{cira_member});
$session->add('reg_desc' => $data{reg_desc});
$session->add('reg_name' => $data{reg_name});
$session->add("admin_pref_language" => $data{admin_pref_language});
$session->add("tech_pref_language" => $data{tech_pref_language});
}
if ( $F_SHOW_CC_FIELDS ) {
return show_payment_info();
} else {
return verify_order();
}
}
sub how_to_link_ca {
return 'how_to_link_to_ca.html',
($session->{link_rant}?(link_to_rant => 1):(link_to_domain => 1));
}
sub link_ca_domain {
if ($in{link_to} eq 'rant'){
$session->add(link_rant => 1);
$session->add(link_ca_domain => 0);
return 'cira_rant_profile.html',
%$session,
custom_dns => $REG_SYSTEM{custom_nameservers};
}
$session->add(link_rant => 0);
$session->add(link_ca_domain => 1);
$session->add(existing_profile => 1);
return 'cira_reg_profile.html',
%$session,
custom_dns => $REG_SYSTEM{custom_nameservers};
}
sub link_ca_domain2 {
my %error = (error => '');
if ($session->{link_ca_domain}){
$session->add(rant_no => 0);
$session->add(ca_link_domain => 1);
} else {
unless ($in{rant_no}) {
$error{error} .= "No Registrant Number supplied
";
$error{error_rant_no} = 1;
}
$session->add(rant_no => $in{rant_no});
$session->add(ca_link_domain => 0);
#check that registrant exists
my $client = new OpenSRS::XML_Client( %OPENSRS);
$client->login;
my $response = $client->send_cmd({
action => "query_registrant",
object => "ca",
attributes => {
domain => '.ca', #not gonna work for other TLDs
rant_no => $in{rant_no},
}
});
unless ($response->{is_success}){
$error->{error} .= $response->{response_text}."
\n";
$error{error_rant_no} = 1;
} else {
my %data = %{$response->{attributes}};
$session->add(%data);
$session->add(reg_name => $data{owner_org_name});
$session->add(admin_pref_language => $data{admin_lang_pref});
$session->add(tech_pref_language => $data{tech_lang_pref});
}
}
if ($REG_SYSTEM{custom_nameservers}){
my $webfqdnCounter = 1;
my $fqdnCounter = 1;
while ($webfqdnCounter <= 6){
if ($in{"fqdn$webfqdnCounter"}){
$session->add("fqdn$fqdnCounter" => $in{"fqdn$webfqdnCounter"});
$fqdnCounter++;
}
$webfqdnCounter++;
}
#now check contact and DNS
if ($REG_SYSTEM{custom_nameservers}){
unless ($session->{'fqdn1'}){
$error{error} .= 'First DNS is mandatory parameter
';
$error{error_fqdn1} = 1;
}
unless ($session->{'fqdn2'}){
$error{error} .= 'Second DNS is mandatory parameter
';
$error{error_fqdn2} = 1;
}
}
}
if ($error{error}){
$error = \%error;
return;
}
if ($session->{ca_link_domain}){
return link_osrs_profile();
}
$session->add(existing_profile => $in{existing_profile});
#reset contact informatino from session
# just to show that OSRS don't need it from us
foreach my $field (qw/ org_name first_name last_name address1 address2 city country state postal_code phone fax pref_language email/){
delete $session->{"admin_$_"};
delete $session->{"tech_$_"};
}
if ($in{existing_profile}){
return 'link_osrs_profile.html',
reg_username => $session->{reg_username},
reg_domain => $session->{reg_domain},
reg_password => $session->{reg_password} ;
} else {
return 'new_profile.html',
reg_username => $session->{reg_username},
reg_password => $session->{reg_password} ;
}
}
sub show_payment_info{
my %cc_months = map {$_ = sprintf('%02d',$_); $_ => $_ } (0..12);
$cc_months{'00'} = '--';
my $year = (localtime)[5];
#Y2K
$year -= 100;
my %cc_year = map { sprintf('%02d',$_) => 2000+$_} ($year .. $year+5);
$year = sprintf('02d%',$year);
return 'cc_info.html',
p_cc_type => $session->{p_cc_type},
p_cc_num => $session->{p_cc_num},
p_cc_exp_month_list => build_select_menu(\%cc_months,$session->{p_cc_exp_month}||'00'),
p_cc_exp_year_list => build_select_menu(\%cc_year,$session->{p_cc_exp_year}|| $year);
}
sub verify_order{
my %error = (error => '');
if ($REG_SYSTEM{F_VERIFY_CC}) {
if (not $in{p_cc_type}){
$error{error} .= "Invalid credit card type.
\n";
$error{error_p_cc_type} = 1;
}
if (not cc_verify($in{p_cc_num})) {
$error{error} .= "Invalid credit card number.
\n";
$error{error_p_cc_num} = 1 ;
}
if (not cc_exp_verify($in{p_cc_exp_month},$in{p_cc_exp_year})) {
$error{error} .= "Invalid credit card expiration: $in{p_cc_exp_month}/$in{p_cc_exp_year}.
\n";
$error{error_p_cc_exp} = 1;
}
if ($error{error}){
$error = \%error;
return;
}
}
$session->add(p_cc_type => $in{p_cc_type});
$session->add(p_cc_num => $in{p_cc_num});
$session->add(p_cc_exp_month => $in{p_cc_exp_month});
$session->add(p_cc_exp_year => $in{p_cc_exp_year});
return 'verify_order.html',%$session,
custom_dns => $REG_SYSTEM{custom_nameservers},
custom_tech => $REG_SYSTEM{custom_tech_contact},
admin_country => CODE_2_Country($session->{admin_country}),
tech_country => CODE_2_Country($session->{tech_country}),
legal_type => $legal_types{$session->{legal_type}}->{long},
p_cc_type => CC_TYPES->{$in{p_cc_type}},
show_cc_fields => $F_SHOW_CC_FIELDS;
}
sub cc_exp_verify {
my ($cc_exp_mon,$cc_exp_yr) = @_;
my ($month,$year) = (localtime)[4,5];
$month++;
$year += 1900;
my $current_month = sprintf("%04d%02d",$year,$month);
my $cc_exp = sprintf("%04d%02d",2000+$cc_exp_yr,$cc_exp_mon);
if ($current_month > $cc_exp) {
return 0;
}
return 1;
}
sub cc_verify {
my ($number) = @_;
my ($i, $sum, $weight);
return 0 if $number =~ /[^\d\s\-]/;
$number =~ s/\D//g;
return 0 unless length($number) >= 13 && 0+$number;
for ($i = 0; $i < length($number) - 1; $i++) {
$weight = substr($number, -1 * ($i + 2), 1) * (2 - ($i % 2));
$sum += (($weight < 10) ? $weight : ($weight - 9));
}
return 1 if substr($number, -1) == (10 - $sum % 10) % 10;
return 0;
}
sub submit_order {
#now the game begin
#prepare xcp_Request
my $xcp_request = {
action => 'sw_register',
object => 'domain',
attributes => {
reg_type => 'new',
domain => $session->{domain},
auto_renew => ($session->{auto_renew}?1:0),
period => $session->{period},
affiliate_id => $session->{affiliate_id},
reg_username => $session->{reg_username},
reg_password => $session->{reg_password},
isa_trademark => $session->{isa_trademark},
ca_link_domain => $session->{ca_link_domain},
rant_no => $session->{rant_no}, #attribute
#if value 0, '', undef or
#not mentioned at all
#then new CIRA profile to be creatd,
#otherwise we will try register
# domain for that registrant
nameserver_list => [],
contact_set => {
owner => {
org_name => $session->{reg_name},
},
admin => {
lang_pref => $session->{admin_pref_language},
first_name => $session->{admin_first_name},
last_name => $session->{admin_last_name},
org_name => $session->{admin_org_name},
address1 => $session->{admin_address1},
address2 => $session->{admin_address2},
city => $session->{admin_city},
state => $session->{admin_state},
country => $session->{admin_country},
postal_code => $session->{admin_postal_code},
phone => $session->{admin_phone},
fax => $session->{admin_fax},
email => $session->{admin_email},
},
},
custom_tech_contact => $REG_SYSTEM{custom_tech_contact},
custom_nameservers => $REG_SYSTEM{custom_nameservers},
}
};
if ($session->{reg_domain}) {
$xcp_request->{attributes}{reg_domain} = $session->{reg_domain};
}
if ($session->{rant_no} or $session->{ca_link_domain}){
#existing CIRA profile, OSRS gets info from cira and put into an order
$xcp_request->{attributes}{domain_description} = 'Existing CIRA profile';
$xcp_request->{attributes}{legal_type} = 'CCT';
$xcp_request->{attributes}{cira_member} = 'Y';
} else {
$xcp_request->{attributes}{domain_description} = $session->{reg_desc},
$xcp_request->{attributes}{legal_type} = $session->{'legal_type'};
$xcp_request->{attributes}{cira_member} = ($session->{cira_member}?'Y':'N');
}
if ($REG_SYSTEM{custom_tech_contact}){
my $tech_contact = {
lang_pref => $session->{tech_pref_language},
first_name => $session->{tech_first_name},
last_name => $session->{tech_last_name},
org_name => $session->{tech_org_name},
address1 => $session->{tech_address1},
address2 => $session->{tech_address2},
city => $session->{tech_city},
state => $session->{tech_state},
country => $session->{tech_country},
postal_code => $session->{tech_postal_code},
phone => $session->{tech_phone},
fax => $session->{tech_fax},
email => $session->{tech_email},
};
$xcp_request->{attributes}{contact_set}{tech} = $tech_contact;
}
$xcp_request->{attributes}{contact_set}{billing} = $xcp_request->{attributes}{contact_set}{admin}; #cause CIRA doesn't have it, and we need this section just to by-pass opensrs validation
if ($REG_SYSTEM{custom_nameservers}) {
my $sortorder = 1;
foreach (1..6){
next unless $session->{"fqdn$_"};
push @{$xcp_request->{attributes}{nameserver_list}},
{ name => $session->{"fqdn$_"},
sortorder=> $sortorder++ };
}
}
$Log->debug('XCP request is prepared %s',Dumper($xcp_request));
#
#
# charge/authorize here
#
$Billing->info("CC Type: %s\n CC #: %s\n CC Exp: %s/%s\n Request: %s ",
$session->{p_cc_type},
$session->{p_cc_num},
$session->{p_cc_exp_month},
$session->{p_cc_exp_year},
Dumper($xcp_request));
my $client = new OpenSRS::XML_Client( %OPENSRS);
$client->login;
my $response = $client->send_cmd($xcp_request);
$Log->debug('got from OSRS %s',Dumper($response));
my $status = '';
if ($response->{is_success}) {
my $id = $response->{attributes}->{id};
my $admin_email = $response->{attributes}->{admin_email};
$session->add(admin_email => $admin_email);
if ($REG_SYSTEM{F_SEND_ORDERS}) {
send_email("$path_templates/message.txt",
{
%$session,
mailfrom => $session->{admin_email}||
$ADMIN_EMAIL,
mailto => $ADMIN_EMAIL,
id => $id,
reg_type => 'New Domain',
});
}
if ($REG_SYSTEM{F_SEND_THANKYOU}) {
send_email("$path_templates/thankyou.txt",
{
%$session,
mailto => $session->{admin_email},
mailfrom => $ADMIN_EMAIL,
id => $id,
});
}
if ($session->{ca_reg_type} eq 'municipal'){
return 'complete_municipal.html',%$session,order_id => $id;
}
return 'complete.html',%$session,order_id => $id;
} elsif ( $F_QUEUE_SUPPLIER_UNAVAILABLE and
$response->{attributes}->{queue_request_id}){
return 'complete_queued.html', %$session;
}
return 'error.html', error => sprintf ("Domain: %s Registration attempt failed: %s.", $session->{domain}, $response->{response_text}."
".$response->{attributes}{error});
}
sub help {
unless ($in{legal_t}) {
throw 'web_error' => 'Legal type group must be specififed';
}
unless (exists $legal_type_groups{$in{legal_t}}){
throw 'web_error' => 'Invalid Legal Type group';
}
return 'legal_type_help.html', %{$legal_type_groups{$in{legal_t}}};
}
1;
opensrs-client-3.0.0/cgi/cert.css 0000644 0177776 0177776 00000000432 10770014202 017741 0 ustar nobody nogroup 0000000 0000000
opensrs-client-3.0.0/cgi/dns_manage.cgi 0000755 0177776 0177776 00000125645 10770014202 021073 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
# .Copyright (C) 2002 TUCOWS.com Inc.
# .Created: 2003/10/30
# .Contactid:
# .Url: http://opensrs.org
# .Authors: Vedran Vego
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# $Id: dns_manage.cgi,v 1.15 2005/09/02 23:01:23 ygumerova Exp $
use vars qw(
%in $cgi $path_templates %actions $action $TPP_Client
$user_id $user_name $COOKIE_NAME $flag_header_sent %cookies
$error_msg $info_msg $path_to_config
);
# Null these things out for mod_perl users
(%in, $cgi, $path_templates, %actions, $action,
$TPP_Client, $info_msg, $error_msg, $path_to_config) = ();
# pull in conf file with defined values
BEGIN {
$path_to_config = "";
# first "do" the major config file
do "$path_to_config/OpenSRS.conf";
# now load up the config for Dns service
do "$path_to_config/Dns_manage.conf";
}
use strict;
use lib $PATH_LIB;
use CGI ':cgi-lib';
use HTML::Template;
use Data::Dumper;
use Core::Checksum qw(calculate compare);
use OpenSRS::TPP_Client;
use OpenSRS::ResponseConverter;
use OpenSRS::Util::ConfigJar "$path_to_config/OpenSRS.conf";
use OpenSRS::Util::Common qw(make_navbar_dns);
# global defines
$user_id = 0;
$user_name = '';
$COOKIE_NAME = "OPENSRS_TPP_CLIENT";
$flag_header_sent = 0;
$cgi = $ENV{SCRIPT_NAME};
$path_templates = "$PATH_TEMPLATES/dns_manage";
%in = ();
$error_msg = '';
$info_msg = '';
# list of valid actions to execute
%actions = (
login => undef,
do_login => undef,
main => undef,
dns_list_inventory_items => undef,
dns_manage_zone => undef,
dns_manage_domain_forwarding => undef,
dns_do_update_zone => undef,
dns_update_domain_forwarding => undef,
dns_retrieve_zone => undef,
dns_restore_zone_defaults => undef,
edit_for_sale_template => undef,
update_for_sale_template => undef,
logout => undef,
);
# start things up
start_up();
# create a client object which we will use to connect to the Tucows server
$TPP_Client = new OpenSRS::TPP_Client(
%OPENSRS,
response_converter => new OpenSRS::ResponseConverter(),
);
$TPP_Client->login;
# read in the form data
ReadParse(\%in);
delete $in{error_message};
%cookies = GetCookies();
$action = $in{action};
# perform necessary action
if (not $action) {
# if no action was supplied, use the defaults
validate() ? main() : login();
} elsif (exists $actions{$action}) {
# they passed a valid action
if (($action eq 'do_login') or validate()) {
no strict "refs";
&$action();
use strict;
} else {
login();
}
} else {
# they passed an invalid action
error_out("Invalid action: $action");
exit;
}
# close connection to the server
$TPP_Client->logout;
exit;
##########################################################################
sub start_up {
if ($DNS_MANAGE{debug}) {
# print error to the page
select (STDOUT); $| = 1;
open (STDERR, ">&STDOUT") or die "Can't dump stdout: $!\n";
select (STDERR); $| = 1;
select (STDOUT);
}
OpenSRS::Util::Common::initialize(
path_templates => $PATH_TEMPLATES,
mail_settings => \%MAIL_SETTINGS
);
}
# get cookies from the client
sub GetCookies {
my %cookies = ();
foreach my $cookie (split /\; /, $ENV{HTTP_COOKIE}) {
my ($key, $value) = (split /=/, $cookie)[0,1];
$value =~ s/\\0/\n/g;
$cookies{$key} = $value;
}
return %cookies;
}
sub error_out {
my %HTML = (ERROR => shift);
print_form(template => "$path_templates/error.html", data => \%HTML);
}
# print html header
sub print_header {
my %cookies = @_;
return if $flag_header_sent;
print "Content-type: text/html\n";
foreach my $key (keys %cookies) {
printf "Set-Cookie: %s=%s; PATH=;\n", $key, $cookies{$key};
}
print "\n";
$flag_header_sent = 1;
}
# Substitute values on the specified template and print it to the client an
# optional 'type' arg can be passed: 'framed' specifies to pull in base.html
# as the outer frame and the given template as the inner frame 'single'
# specifies to use the given template alone the default behavior is 'framed'.
sub print_form {
my %args = @_;
$args{title} = $args{title} || 'DNS Service Management';
my $template = HTML::Template->new(
cache => 1,
filename => $args{template},
die_on_bad_params => 0,
);
$template->param(
CGI => $cgi,
%{ $args{data} },
);
if (not $args{not_framed}) {
my $content = $template->output;
$template = HTML::Template->new(
cache => 1,
filename => "$path_templates/base.html",
die_on_bad_params => 0,
);
$template->param(CONTENT => $content);
}
$template->param(
CGI => $cgi,
%{ $args{data} },
user_id => $user_id,
);
print_header();
print $template->output;
}
sub validate {
my $ok = 0;
if ($cookies{$COOKIE_NAME}) {
my ($csum, $uid) = split /:/, $cookies{$COOKIE_NAME};
if ($csum) {
$ok = compare($csum, $OPENSRS{private_key}, $uid);
$user_id = $uid if $ok;
}
}
if ($cookies{user_name}) {
$user_name = $cookies{user_name};
}
return $ok;
}
sub login {
my $error_message = shift;
my %HTML = ();
$HTML{error_message} = $error_message;
$HTML{cgi} = $cgi;
$HTML{username} = $in{username} if $in{username};
$HTML{title} = "DNS Service Management";
$HTML{password_recovery} = $DNS_MANAGE{password_recovery};
print_form(template => "$path_templates/login.html", data => \%HTML);
}
sub do_login {
my $result;
if (not $in{username} or not $in{password}) {
login('Authentication failed.');
return;
}
# check if user exists
$result = $TPP_Client->login_user(
$in{username}, $in{password}, $OPENSRS{username}
);
if (not defined $result or not $result->{is_success}) {
my $err = sprintf 'Failed to authenticate user: %s',
$result->{response_text} || 'Empty response from server';
login($err);
return;
}
$user_id = $result->{attributes}{user_id};
if (not $user_id) {
login('Unable to get user ID.');
return;
}
# sign user_id and set the cooke.
my $csum = calculate($OPENSRS{private_key}, $user_id);
print_header($COOKIE_NAME => "$csum:$user_id", user_name => $in{username});
$user_name = $in{username};
main();
}
sub logout {
# reset global user_id and a cookie
$user_id = 0;
print_header($COOKIE_NAME => '', user_name => '');
login();
}
##########################################################################
sub main {
dns_list_inventory_items();
}
sub get_inventory_items {
my ($start_page,$page_size) = @_;
my $start_index = ($start_page * $page_size) + 1;
my $TPP_request = {
protocol => 'TPP',
version => '1.3.0',
action => 'execute',
object => 'query',
requestor => {
username => $OPENSRS{username},
},
attributes => {
user_id => $user_id,
page_size => $page_size,
start_index => $start_index,
query_name => 'inventory_items.created.by_user_id',
conditions => [
{
type => 'simple',
field => 'user_id',
operand => {
'eq' => $user_id,
},
},
{
type => 'link',
link => 'and',
},
{
type => 'simple',
field => 'service',
operand => {
'eq' => 'dns',
},
},
],
}
};
my $TPP_response =
$TPP_Client->send_cmd($TPP_request);
if ( not $TPP_response->{is_success}) {
error_out('Unable to retrieve products: ' .
$TPP_response->{response_text});
exit;
}
return ($TPP_response->{attributes}{result},
$TPP_response->{attributes}{result_control}{record_count});
}
sub dns_list_inventory_items {
my %HTML = ();
my $page = $in{page} || 0;
my $limit = 20;
my ($items, $total_records) = get_inventory_items($page,$limit);
$items = [ grep $_->{service} eq 'dns', @{$items} ];
my $counter = 0;
foreach my $item (@{$items}) {
$item->{class} = $counter++ % 2 ? "accent" : "soft";
$item->{object_type} = ucfirst $item->{object_type}." DNS";
$item->{creation_date} = (split(/\s/,$item->{creation_date}))[0];
$item->{cgi} = $cgi;
}
my $num_page_links = 10;
my $f_navpage = make_navbar_dns(
"dns_list_inventory_items",
$total_records, $limit,
$num_page_links, $page
);
my @f_navbar = (
{
external => 1,
title => 'PASSWORD MANAGEMENT',
action => $DNS_MANAGE{password_url},
separator => ' | ',
target => qw (target="blank_"),
},
{
cgi => $cgi."?",
title => 'ZONE LIST',
action => 'dns_list_inventory_items',
separator => ' | ',
},
{
cgi => $cgi."?",
title => 'LOGOUT',
action => 'logout',
separator => '',
}
);
$HTML{total_records} = $total_records;
$HTML{records} = $items;
$HTML{page} = $page;
$HTML{limit} = $limit;
$HTML{cgi} = $cgi;
$HTML{f_navpage} = $f_navpage;
$HTML{f_navbar} = \@f_navbar;
$HTML{f_title} = "DNS Management";
$HTML{f_name} = $user_name;
$HTML{stat_message} = "".$error_msg .""."". $info_msg."";
$HTML{title} = $HTML{f_title};
print_form(template => "$path_templates/main.html", data => \%HTML);
}
sub get_inventory_item {
my $inventory_item_id = shift;
my $TPP_request = {
protocol => 'TPP',
version => '1.3.0',
action => 'execute',
object => 'query',
requestor => {
username => $OPENSRS{username},
},
attributes => {
user_id => $user_id,
query_name => 'inventory_item.by_id',
conditions => [
{
type => 'simple',
field => 'inventory_item_id',
operand => {
'eq' => $inventory_item_id,
},
},
],
},
};
my $TPP_response =
$TPP_Client->send_cmd($TPP_request);
if ( not $TPP_response->{is_success} ||
!(defined $TPP_response->{attributes}->{result}->[0]))
{
error_out('Unable to query product: ' .
$TPP_response->{response_text});
exit;
}
return $TPP_response->{attributes}->{result}->[0];
}
sub relativename_to_fullname {
my $zone_data = shift;
my $zone_name = $zone_data->{name};
foreach my $zone_record (@{ $zone_data->{records} }) {
if (($zone_record->{type} =~ /^(CNAME|MX|NS)$/i) and
($zone_record->{content} !~ /^\s*$/ )) {
$zone_record->{content} .= '.'.$zone_name unless
$zone_record->{content} =~ /\.$/;
}
}
}
sub dns_manage_zone {
# when dns_do_update_zone() calls dns_manage_zone() it might pass
# zone update result
my $zone_update_result = shift;
my %HTML = ();
$HTML{cgi} = $cgi;
unless ( $in{inventory_item_id}) {
error_out('Inventory item id must be specified');
exit;
}
my $inventory_item = get_inventory_item($in{inventory_item_id});
if (not $inventory_item) {
error_out('Null inventory_item in response');
exit;
}
if ( !validate_item_action($inventory_item->{product_data}{flags},'zone')) {
add_info_message("Zone management permission is currently disabled for this zone.");
return main();
}
my $dns_zone = $inventory_item->{product_data}{zone_data};
relativename_to_fullname($dns_zone);
if (not defined $dns_zone) {
error_out('Null zone_data in response');
exit;
}
# if we were given a $zone_update_result:
# set error header and extract update results
my $delete_results = [];
my $create_results = [];
my $update_results = [];
if (defined $zone_update_result) {
$delete_results = $zone_update_result->{delete_records};
$create_results = $zone_update_result->{create_records};
$update_results = $zone_update_result->{update_records};
}
my $records = $dns_zone->{records};
my $zone_fqdn = $dns_zone->{name};
$HTML{stat_message} = "".$error_msg .""."". $info_msg."";
$HTML{inventory_item_id} = $in{inventory_item_id};
$HTML{version} = $dns_zone->{version};
$HTML{zone_fqdn} = $zone_fqdn;
$HTML{a_records} = build_records($in{inventory_item_id},
$zone_fqdn, $delete_results, $update_results, $records,'A');
$HTML{cname_records} = build_records($in{inventory_item_id}, $zone_fqdn,
$delete_results, $update_results, $records, 'CNAME');
$HTML{txt_records} = build_records($in{inventory_item_id}, $zone_fqdn,
$delete_results, $update_results, $records, 'TXT');
$HTML{mx_records} = build_records($in{inventory_item_id}, $zone_fqdn,
$delete_results, $update_results, $records, 'MX');
$HTML{ns_records} = build_records($in{inventory_item_id}, $zone_fqdn,
$delete_results, $update_results, $records, 'NS');
$HTML{a_records_add} = build_add_records($zone_fqdn, $create_results, 'A');
$HTML{cname_records_add} =
build_add_records($zone_fqdn,$create_results,'CNAME');
$HTML{txt_records_add} =
build_add_records($zone_fqdn,$create_results,'TXT');
$HTML{mx_records_add} =
build_add_records($zone_fqdn,$create_results,'MX');
$HTML{ns_records_add} =
build_add_records($zone_fqdn, $create_results,'NS');
$HTML{ids} = join(',', map { $_->{id} } @{$records});
$HTML{f_title} = "Zone Management: $zone_fqdn";
$HTML{f_name} = $zone_fqdn;
my @f_navbar = (
{
cgi => $cgi."?",
title => 'ZONE LIST',
action => 'dns_list_inventory_items',
separator => ' | ',
},
{
cgi => $cgi."?",
title => 'LOGOUT',
action => 'logout',
separator => '',
}
);
$HTML{f_navbar} = \@f_navbar;
$HTML{title} = $HTML{f_title};
print_form(template => "$path_templates/dns_manage_zone.html", data => \%HTML);
}
sub build_records {
my ($inventory_item_id, $zone_fqdn,
$delete_results, $update_results,
$in_records, $type) = @_;
my $records = [ grep $_->{type} eq $type, @{$in_records} ];
my %deleted = map { $_->{id} => 1 } @{$delete_results};
my %updated = map { $_->{id} => $_ } @{$update_results};
my @html_records = ();
my %name_map = ();
foreach my $record (@{$records}) {
my $name = $record->{name};
if ($name_map{$name}) {
push @{$name_map{$name}}, $record;
} else {
$name_map{$name} = [ $record ];
}
}
my $counter = 0;
foreach my $name (keys %name_map) {
my $name_records = $name_map{$name};
my $num = scalar @{$name_records};
my $rowspan = $num > 1 ? "valign=top rowspan=$num" : "";
my $first_row = 1;
foreach my $record (@{$name_records}) {
my $id = $record->{id};
if (defined $updated{$id}) {
map {
$record->{$_} = $updated{$id}->{$_}
} keys %{ $updated{$id} };
}
my $error = '';
if (defined $record->{response_code} and
$record->{response_code} != 200 and
$record->{response_text}) {
$error = $record->{response_text};
}
my $rec_name;
if ($first_row) {
$rec_name = $name eq '@' ? $zone_fqdn : "$name.$zone_fqdn";
$first_row = 0;
}
push(@html_records,
{
inventory_item_id => $inventory_item_id,
id => $id,
error => $error,
class => $counter++ % 2 ? "accent" : "soft",
rec_name => $rec_name,
name => $name,
type => $record->{type},
content => $record->{content},
priority => $record->{priority},
delete_checked => $deleted{$id} ? "checked" : '',
rowspan => $rowspan,
read_only => $record->{read_only},
}
);
}
}
return \@html_records;
}
sub build_add_records {
my ($zone_fqdn, $create_results, $type) = @_;
my $created = [];
foreach my $result (grep { $_->{type} eq $type } @{$create_results}) {
if ($_->{name} eq '@') {
unshift @{$created}, $result;
} else {
push @{$created}, $result;
}
}
my @html_add_records = ();
my $counter = 0;
for (my $i = 0; $i < $DNS_MANAGE{bulk_factor}; $i++) {
my $suffix = 'new_' . $i . '_' . $type;
my $create_record = {};
if (($type == 'MX' || $type == 'A') and $i == 0) {
if ($created->[0]->{name} eq '@') {
$create_record = shift @{$created};
} else {
$create_record = {};
}
} else {
$create_record = (shift @{$created}) || {};
}
if ($create_record->{name} eq '@') {
$create_record->{name} = '';
}
my $error = '';
if (defined $create_record->{response_code} and
$create_record->{response_code} != 200 and
$create_record->{response_text}) {
$error = $create_record->{response_text};
}
push(@html_add_records,
{
error => $error,
class => $counter++ % 2 ? "accent" : "soft",
suffix => $suffix,
name => $create_record->{name},
priority => $create_record->{priority},
content => $create_record->{content},
zone_fqdn => $zone_fqdn,
is_input_hidden => ($i == 0 and ($type == 'MX' || $type == 'A')) ?
1 : 0
}
);
}
return \@html_add_records;
}
sub dns_do_update_zone {
my $TPP_request = {
version => '1.4.0',
action => 'update',
object => 'inventory_item.dns',
requestor => {
username => $OPENSRS{username},
},
attributes => {
service => 'dns',
user_id => $user_id,
inventory_item_id => $in{inventory_item_id},
product_data => {
zone => {
version => $in{version},
%{ parse_update_zone_records_request() },
},
},
},
};
my $TPP_response = $TPP_Client->send_cmd($TPP_request);
my $zone_update_result;
if (not $TPP_response->{is_success}) {
if ($TPP_response->{response_code} == 31472) {
add_error_message(
"Zone record entry error"
);
} else {
add_error_message($TPP_response->{response_text});
}
$zone_update_result = $TPP_response->{attributes}{product_data}{zone};
} else {
add_info_message($TPP_response->{response_text});
}
return dns_manage_zone($zone_update_result);
}
sub dns_restore_zone_defaults {
my $delete_records = [];
if ($in{ids}) {
map {
push @{$delete_records}, { id => $_ };
} split /,/, $in{ids};
}
my $TPP_request = {
version => '1.4.0',
action => 'update',
object => 'inventory_item.dns',
requestor => {
username => $OPENSRS{username},
},
attributes => {
user_id => $user_id,
service => 'dns',
inventory_item_id => $in{inventory_item_id},
product_data => {
zone => {
version => $in{version},
delete_records => $delete_records,
create_records => [],
update_records => [],
},
template => {
name => 'default',
},
},
},
};
my $TPP_response = $TPP_Client->send_cmd($TPP_request);
if ($TPP_response->{is_success}) {
add_info_message($TPP_response->{response_text});
} else {
add_error_message($TPP_response->{response_text});
}
dns_manage_zone();
}
sub dns_retrieve_zone {
error_log('Inventory item id must be specified')
unless $in{inventory_item_id};
my $inventory_item = get_inventory_item($in{inventory_item_id});
if (not $inventory_item) {
add_error_message('Null inventory_item in response');
}
my $dns_zone = $inventory_item->{product_data}{zone_data};
if (not defined $dns_zone) {
add_error_message('Null zone_data in response');
}
my $zone_records = $dns_zone->{records} || [];
my $retrieved_records = [];
my $TPP_response = retrieve_zone_records($dns_zone->{name});
if (not $TPP_response->{is_success}) {
add_error_message($TPP_response->{response_text});
return dns_manage_zone();
} else {
$retrieved_records =
$TPP_response->{attributes}{product_data}{zone}{records};
}
my $TPP_request = {
version => '1.4.0',
action => 'update',
object => 'inventory_item.dns',
requestor => {
username => $OPENSRS{username},
},
attributes => {
service => 'dns',
user_id => $user_id,
inventory_item_id => $in{inventory_item_id},
product_data => {
zone => {
version => $in{version},
delete_records => $in{replace} ? $zone_records : [],
create_records => $retrieved_records,
update_records => [],
},
},
},
};
$TPP_response = $TPP_Client->send_cmd($TPP_request);
if ($TPP_response->{is_success}) {
add_info_message($TPP_response->{response_text});
} else {
add_error_message($TPP_response->{response_text});
}
dns_manage_zone();
}
sub retrieve_zone_records {
my $fqdn = shift;
my $prefixes = shift;
my $TPP_request = {
action => 'retrieve',
object => 'dns.zone',
requestor => {
username => $OPENSRS{username},
},
attributes => {
service => 'dns',
user_id => $user_id,
product_data => {
zone => {
name => $fqdn,
},
prefixes => $prefixes || [],
},
},
};
my $TPP_response = $TPP_Client->send_cmd($TPP_request);
return $TPP_response;
}
sub parse_update_zone_records_request {
my $delete_records = [];
if ($in{delete_records}) {
foreach (split /\0/,$in{delete_records}) {
push @{$delete_records}, { id => $_ };
}
}
my %processed = ();
my $update_records = [];
foreach my $orig_entity (keys %in) {
my ($suffix) = $orig_entity =~ /(\d+_orig)$/;
next if (not $suffix or $processed{$suffix});
my ($id) = $suffix =~ /(\d+)_orig$/;
my $update_record;
my @entities = grep /$suffix$/, keys %in;
foreach my $entity (@entities) {
my ($updated_entity) = $entity =~ /^(.+_\d+)_orig$/;
if ($in{$entity} !~ /^\s*$/ and $in{$entity} ne $in{$updated_entity}) {
if (not defined $update_record) {
$update_record = {id => $id};
}
my ($entity_name) = $updated_entity =~ /^(.+)_\d+$/;
$update_record->{$entity_name} = $in{$updated_entity};
}
}
if (defined $update_record) {
if (exists $update_record->{content} and
$update_record->{content} !~ /^\s*$/) {
my $type = $in{'type_' . $update_record->{id}};
if ($type ne 'A' and $update_record->{content} !~ m/\.$/) {
$update_record->{content} .= '.';
}
}
push @{$update_records}, $update_record;
}
$processed{$suffix} = 1;
}
my $create_records = [];
if ($in{suffix}) {
foreach my $suffix (split /\0/, $in{suffix}) {
my ($type) = $suffix =~ /\d+_(.+)$/;
my $create_record = {type => $type};
map {
$_ =~ /^(.+)_$suffix$/;
if ($in{$_} !~ /^\s*$/) {
$create_record->{$1} = $in{$_};
}
} grep /$suffix$/, keys %in;
if (not $create_record->{name}) {
$create_record->{name} = '@';
}
if (scalar keys %{$create_record} > 2) {
if (exists $create_record->{content} and
$create_record->{type} =~ m/^(CNAME|MX|NS)$/i) {
$create_record->{content} .= '.' unless
$create_record->{content} =~ m/\.$/;
}
push @{$create_records}, $create_record;
}
}
}
return {
delete_records => $delete_records,
create_records => $create_records,
update_records => $update_records,
};
}
sub dns_manage_domain_forwarding {
# when dns_update_domain_forwarding() calls dns_manage_domain_forwarding()
# it might pass update result
my $update_result = shift;
my %HTML = ();
$HTML{cgi} = $cgi;
unless ( $in{inventory_item_id} ) {
error_out('Inventory item id must be specified');
exit;
}
my $inventory_item = get_inventory_item($in{inventory_item_id});
if (not $inventory_item) {
error_out('Null inventory_item in response');
exit;
}
if ( !validate_item_action($inventory_item->{product_data}{flags},'forwarding')) {
add_info_message("Domain forwarding permission is currently disabled for this zone.");
return main();
}
my $zone_data = $inventory_item->{product_data}{zone_data};
if (not defined $zone_data) {
error_out('Null zone_data in response');
exit;
}
my $zone_services = $inventory_item->{product_data}{zone_services};
if (not defined $zone_services) {
error_out('Null zone_services in response');
}
# if we were given a $update_result - extract update results
my $delete_results = [];
my $create_results = [];
my $update_results = [];
if (defined $update_result) {
$delete_results = $update_result->{delete_services};
$create_results = $update_result->{create_services};
$update_results = $update_result->{update_services};
}
# scan for 'www' zone service
my $create_www = 1;
map {
$create_www = 0 if $_->{prefix} eq 'www'
} @$zone_services;
# scan for 'www' zone records
if ($create_www) {
map {
$create_www = 0 if $_->{name} eq 'www'
} @{$zone_data->{records}};
}
$HTML{create_www} = $create_www;
my $zone_fqdn = $zone_data->{name};
$HTML{stat_message} = "".$error_msg .""."". $info_msg."";
$HTML{inventory_item_id} = $in{inventory_item_id};
$HTML{zone_fqdn} = $zone_fqdn;
$HTML{f_title} = "Domain Forwarding Management: $zone_fqdn";
$HTML{f_name} = $zone_fqdn;
$HTML{show_forwarding} = $inventory_item->{product_data}{flags}{allow_url_forwarding};
$HTML{show_templates} = $inventory_item->{product_data}{flags}{allow_templates};
# default
$HTML{domain_setting} = "none";
$HTML{chk_none} = "checked";
$HTML{domain_cloak} = 0;
$HTML{domain_url} = 'http://';
my $zone_services_num = scalar @{$zone_services}; # this for subdomain
foreach my $zone_service (@{$zone_services}) {
next unless $zone_service->{prefix} eq "@";
# do not count zone service for domain
--$zone_services_num;
$HTML{domain_zone_service_id} = $zone_service->{id};
if ($zone_service->{type} eq 'template') {
$HTML{chk_none} = "";
if ($zone_service->{content} eq 'under-construction') {
$HTML{domain_setting} = "uc";
$HTML{chk_uc} = "checked";
} elsif ($zone_service->{content} eq 'for-sale') {
$HTML{domain_setting} = "fs";
$HTML{chk_fs} = "checked";
}
} elsif ($zone_service->{type} eq 'url-cloak') {
$HTML{domain_setting} = "fwd";
$HTML{domain_url} = $zone_service->{content};
$HTML{domain_cloak} = 1;
$HTML{chk_none} = "";
$HTML{chk_fwd} = "checked";
} elsif ($zone_service->{type} eq 'redirector') {
$HTML{domain_setting} = "fwd";
$HTML{domain_url} = $zone_service->{content};
$HTML{chk_none} = "";
$HTML{chk_fwd} = "checked";
}
last;
}
$HTML{subdomain_forward_records} =
build_fw_records($zone_services,$zone_fqdn);
$HTML{subdomain_forward_add_records} =
build_fw_add_records($create_results, $zone_fqdn, $create_www);
my @f_navbar = (
{
cgi => $cgi."?",
title => 'ZONE LIST',
action => 'dns_list_inventory_items',
separator => ' | ',
},
{
cgi => $cgi."?",
title => 'LOGOUT',
action => 'logout',
separator => '',
}
);
$HTML{f_navbar} = \@f_navbar;
$HTML{title} = $HTML{f_title};
print_form(template => "$path_templates/dns_domain_forwarding.html", data => \%HTML);
}
sub build_fw_records {
my ($zone_services,$zone_fqdn) = @_;
my @html_fw_records;
my $counter = 0;
foreach my $zone_service (@{$zone_services}) {
next if $zone_service->{prefix} eq '@';
push(@html_fw_records,
{
class => $counter++ % 2 ? "accent" : "soft",
prefix => $zone_service->{prefix},
name => $zone_fqdn,
content => $zone_service->{content},
id => $zone_service->{id},
url_cloak => $zone_service->{type} eq "url-cloak" ? 1 : 0,
}
);
}
return \@html_fw_records;
}
sub build_fw_add_records {
my ($create_results, $zone_fqdn, $create_www) = @_;
my @html_fw_add_records;
my $new_service = {};
foreach my $create_result (@{$create_results}) {
# skip create_result for domain
next if $create_result->{prefix} eq '@';
# XXX fix it to use resonse code
if (not $create_result->{id}) {
# ignore auto-created forwarding for 'www' subdomain
next if $create_result->{prefix} eq 'www' and $create_www;
$new_service = $create_result;
last;
}
}
push(@html_fw_add_records,
{
class => "accent",
new_subdomain => $new_service->{prefix},
new_url => $new_service->{content} || 'http://',
new_cloaked => $new_service->{type} eq 'url-cloak' ? "checked" : "",
zone_fqdn => $zone_fqdn,
}
);
return \@html_fw_add_records;
}
sub dns_update_domain_forwarding {
my $update_data = parse_update_zone_services_request();
if ($in{create_www} and $in{domain_setting} ne 'none') {
# make sure there is no other 'www' domain forward to create
my $www_exists = 0;
map {
$www_exists = 1 if $_->{prefix} eq 'www'
} @{$update_data->{create_services}};
push @{$update_data->{create_services}}, {
prefix => 'www',
type => 'redirector',
content => "http://" . $in{create_www},
} unless $www_exists;
}
if ( scalar @{$update_data->{delete_services}} == 0 &&
scalar @{$update_data->{create_services}} == 0 &&
scalar @{$update_data->{update_services}} == 0)
{
return dns_manage_domain_forwarding();
}
my $TPP_request = {
version => '1.4.0',
action => 'update',
object => 'inventory_item.dns',
requestor => {
username => $OPENSRS{username},
},
attributes => {
user_id => $user_id,
service => 'dns',
inventory_item_id => $in{inventory_item_id},
product_data => {
zone_services => $update_data,
}
},
};
my $TPP_response = $TPP_Client->send_cmd($TPP_request);
my $update_result;
if (not $TPP_response->{is_success}) {
$update_result = $TPP_response->{attributes}{product_data}{zone_services};
my $error_text;
TYPE:
foreach my $type qw(create_services delete_services update_services) {
my @services = @{ $TPP_response->{attributes}{product_data}{zone_services}{$type} };
foreach my $service (@services) {
if ($service->{response_code} != 200 and
$service->{response_text}) {
if ($service->{prefix} ne '@') {
if ($type eq 'create_services') {
$error_text =
"Failed to create subdomain forwarding: ";
} elsif ($type eq 'delete_services') {
$error_text =
"Failed to delete subdomain forwarding: ";
} elsif ($type eq 'update_services') {
$error_text =
"Failed to update subdomain forwarding: ";
}
} else {
$error_text = "Failed to update domain forwarding: ";
}
if ($service->{response_code} == 30441) {
# "Invalid zone service content"
$error_text .= "Format of entry is invalid: " .
$service->{content};
} else {
$error_text .= $service->{response_text};
}
last TYPE;
}
}
}
if ($error_text) {
add_error_message($error_text);
} else {
add_error_message($TPP_response->{response_text});
}
} else {
add_info_message($TPP_response->{response_text});
}
return dns_manage_domain_forwarding($update_result);
}
sub parse_update_zone_services_request {
my $delete_services = [];
my $create_services = [];
my $update_services = [];
# parse domain settings
my $domain_zone_service_type;
my $domain_zone_service_content;
if ($in{domain_setting} eq 'uc') {
$domain_zone_service_type = 'template';
$domain_zone_service_content = 'under-construction';
} elsif ($in{domain_setting} eq 'fs') {
$domain_zone_service_type = 'template';
$domain_zone_service_content = 'for-sale';
} elsif ($in{domain_setting} eq 'fwd') {
$in{domain_cloak} = 0 unless defined $in{domain_cloak};
$domain_zone_service_type =
$in{domain_cloak} ? 'url-cloak' : 'redirector';
$domain_zone_service_content = $in{domain_url};
}
if ($in{domain_setting} ne $in{orig_domain_setting}) {
my $tmp = $in{orig_domain_setting} . $in{domain_setting};
if ($tmp eq 'fsuc' or $tmp eq 'ucfs') {
push @{$update_services}, {
id => $in{domain_zone_service_id},
content => $domain_zone_service_content,
};
} else {
if ($in{orig_domain_setting} ne 'none') {
push @{$delete_services}, {
id => $in{domain_zone_service_id}
};
}
if ($in{domain_setting} ne 'none') {
push @{$create_services}, {
prefix => '@',
type => $domain_zone_service_type,
content => $domain_zone_service_content,
};
}
}
} elsif ($in{domain_setting} eq 'fwd') {
if ($in{domain_cloak} ne $in{orig_domain_cloak}) {
push @{$delete_services}, {
id => $in{domain_zone_service_id},
};
push @{$create_services}, {
prefix => '@',
type => $domain_zone_service_type,
content => $domain_zone_service_content,
};
} elsif ($in{domain_url} ne $in{orig_domain_url}) {
push @{$update_services}, {
id => $in{domain_zone_service_id},
content => $domain_zone_service_content,
};
}
}
# parse new subdomain
if ($in{new_subdomain}) {
push @{$create_services}, {
prefix => $in{new_subdomain},
type => $in{new_cloaked} ? 'url-cloak' : 'redirector',
content => $in{new_url},
};
}
# parse updates/deletions
foreach my $key (keys %in) {
if ($key =~ /^delete_(\d+)$/) {
push @{$delete_services}, { id => $1 };
} elsif ($key =~ /^url_(\d+)$/ ) {
next if defined $in{"delete_$1"};
if ($in{$key} ne $in{"orig_$key"}) {
push @{$update_services}, {
id => $1,
content => $in{$key},
};
}
$in{"subdomain_cloak_$1"} = 0 unless $in{"subdomain_cloak_$1"};
if ($in{"subdomain_cloak_$1"} ne $in{"orig_subdomain_cloak_$1"}) {
push @{$delete_services}, {
id => $1,
};
push @{$create_services}, {
prefix => $in{"prefix_$1"},
type => $in{"subdomain_cloak_$1"} ? 'url-cloak' : 'redirector',
content => $in{"url_$1"},
};
}
}
}
# now check for services to be deleted, but that are in update list also
# remove such services from update list
my %delete_map = map { $_->{id} => undef } @$delete_services;
my %update_map = map { $_->{id} => $_ } @$update_services;
map { delete $update_map{$_} } keys %delete_map;
$update_services = [ values %update_map ];
return {
delete_services => $delete_services,
create_services => $create_services,
update_services => $update_services,
};
}
sub edit_for_sale_template {
my %HTML = ();
$HTML{cgi} = $cgi;
unless ( $in{inventory_item_id} ) {
error_out('Inventory item id must be specified');
exit;
}
my $inventory_item = get_inventory_item($in{inventory_item_id});
if (not $inventory_item) {
error_out('Null inventory_item in response');
exit;
}
my $zone_data = $inventory_item->{product_data}{zone_data};
if (not defined $zone_data) {
error_out('Null zone_data in response');
exit;
}
my $zone_services = $inventory_item->{product_data}{zone_services};
if (not defined $zone_services) {
error_out('Null zone_services in response');
}
foreach my $zone_service (@{$zone_services}) {
next unless $zone_service->{content} eq "for-sale" &&
$zone_service->{type} eq "template";
$HTML{domain_zone_service_id} = $zone_service->{id};
$HTML{heading} = $zone_service->{parameters}{heading};
$HTML{description} = $zone_service->{parameters}{description};
}
$HTML{stat_message} = "".$error_msg .""."". $info_msg."";
$HTML{inventory_item_id} = $in{inventory_item_id};
$HTML{zone_fqdn} = $zone_data->{name};
$HTML{f_title} = "For Sale Template: ".$zone_data->{name};
$HTML{title} = $HTML{f_title};
print_form(template => "$path_templates/for_sale_template.html", data => \%HTML);
}
sub update_for_sale_template {
if ( length($in{heading}) > 255) {
add_error_message("Invalid number of characters for heading field [max 255]");
return edit_for_sale_template();
}
if ( length($in{description}) > 3999) {
add_error_message("Invalid number of characters for description field [max 3999]");
return edit_for_sale_template();
}
my $update_data = parse_update_for_sale_template_request();
if (scalar @{$update_data->{update_services}} == 0) {
return edit_for_sale_template();
}
my $TPP_request = {
version => '1.4.0',
action => 'update',
object => 'inventory_item.dns',
requestor => {
username => $OPENSRS{username},
},
attributes => {
user_id => $user_id,
service => 'dns',
inventory_item_id => $in{inventory_item_id},
product_data => {
zone_services => $update_data,
},
},
};
my $TPP_response = $TPP_Client->send_cmd($TPP_request);
if (not $TPP_response->{is_success}) {
add_error_message($TPP_response->{response_text});
} else {
add_info_message($TPP_response->{response_text});
}
return edit_for_sale_template();
}
sub parse_update_for_sale_template_request {
my $delete_services = [];
my $create_services = [];
my $update_services = [];
push @{$update_services}, {
id => $in{domain_zone_service_id},
parameters => {
heading => $in{heading},
description => $in{description},
}
};
return {
delete_services => $delete_services,
create_services => $create_services,
update_services => $update_services,
};
}
sub add_info_message {
my $message = shift;
$info_msg .= $message."
";
}
sub add_error_message {
my $message = shift;
$error_msg .= $message."
";
}
sub validate_item_action {
my ($flags,$action) = @_;
my $allowed = 0;
if ( $action eq 'zone') {
$allowed = 1 if $flags->{allow_zone_management};
} elsif ( $action eq 'forwarding') {
$allowed = 1 if $flags->{allow_url_forwarding} ||
$flags->{allow_templates};
}
return $allowed;
}
opensrs-client-3.0.0/cgi/dns_manage.css 0000644 0177776 0177776 00000006372 10770014202 021111 0 ustar nobody nogroup 0000000 0000000 BODY { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #B1C0C0; }
TD { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
A.link { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #709BD9; text-decoration: none; background: transparent; }
A.visited { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #3F577A; text-decoration: none; background: transparent; }
A.active { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #709BD9; text-decoration: none; background: transparent; }
A.hover { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #709BD9; text-decoration: none; background: transparent; }
HR { COLOR: #A6C1E9; BACKGROUND-COLOR: #A6C1E9; border: 0px; }
td.accent { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: black; background-color: #E4ECF8; padding-left: 2pt; }
td.soft { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: black; background-color: #EDEDED; padding-left: 2pt; }
td.wh { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: black; background-color: #FFFFFF; padding-left: 15pt; padding-top: 0pt; }
td.bl { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: black; background-color: #000000; }
.header1 { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 24px; color: #000000; font-weight: bold; }
.header2 { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #6D6D6D; font-variant:small-caps;}
.name2 { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #6D6D6D; }
.header3 { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #000000; font-variant:small-caps; }
.nav { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #2E3A4C; font-weight: bold; text-decoration: none; }
input,form { padding: 0; margin: 0; }
input.soft { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.accent { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.zms { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.zma { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.dfs { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.dfa { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.prs { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.pra { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.ed { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.ca { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.sa { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.up { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.rs { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.radio.accent { background : #E4ECF8; }
input.radio.soft { background : #EDEDED; }
.error {font-size: 11px; color: #FF0000;}
opensrs-client-3.0.0/cgi/emaildefense.cgi 0000755 0177776 0177776 00000121266 10770014202 021413 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
# .Copyright (C) 2004 TUCOWS.com Inc.
# .Created: 2004/07/17
# .Contactid:
# .Url: http://email.tucows.com
# .Authors: Yuliya Gumerova
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
use vars qw(%in $cgi $session $path_templates %actions $action $antispam $path_to_config);
# Null these things out for mod_perl users
(%in, $cgi, $session, $path_templates, %actions, $action, $path_to_config) = ();
use constant NUM_SERVERS => 4; # max number of servers a user can specify.
# pull in conf file with defined values
# XXX NOTE XXX Update this configuration file
BEGIN {
# first "do" the major config file
$path_to_config = "";
do "$path_to_config/OpenSRS.conf";
# now load up the config for EmailDefense services
do "$path_to_config/EmailDefense.conf";
}
use strict;
use lib $PATH_LIB;
use CGI ':cgi-lib';
use HTML::Template;
use Data::Dumper;
use OpenSRS::Util::ConfigJar "$path_to_config/OpenSRS.conf";
use OpenSRS::Util::ConfigJar "$path_to_config/EmailDefense.conf";
use OpenSRS::Util::Common qw(send_email build_select_menu build_select_menu3 build_country_list make_navbar);
use OpenSRS::XML_Client;
use OpenSRS::EmailDefense;
use OpenSRS::Util::Session;
# global defines
$cgi = $ENV{SCRIPT_NAME};
$path_templates = "$PATH_TEMPLATES/emaildefense";
%in = ();
%actions = (
start_up => undef,
lookup_domain => undef,
recover_password => undef,
do_recover_password => undef,
login_domain_user => undef,
login_user => undef,
select_service_action => undef,
create_new_user => undef,
add_user_accounts => undef,
do_add_user_accounts => undef,
do_add_user_roles_and_pass_info => undef,
process_new_purchase_order => undef,
manage_service => undef,
do_manage_service => undef,
do_manage => undef,
do_add_email_servers => undef,
add_manage_user_accounts => undef,
do_add_contact_info => undef,
confirm_add_manage_order => undef,
remove_manage_user_accounts => undef,
confirm_remove_manage_order => undef,
list_features_and_users => undef,
cancel_new_purchase_order => undef,
cancel_emaildefense_service => undef,
do_cancel_emaildefense_service => undef,
edit_user_accounts => undef,
edit_contact_info => undef,
edit_manage_user_accounts => undef,
edit_remove_manage_user_accounts => undef,
);
print "Content-type: text/html\n\n";
# start things up
# set debugging level
set_debugging_level();
init_antispam();
# read in the form data
ReadParse(\%in);
local $Data::Dumper::Purity = 1;
local $Data::Dumper::Deepcopy = 1;
$session = OpenSRS::Util::Session->restore(
$in{session},
$in{sign},
$OPENSRS{private_key});
$action = $in{action};
delete $in{session};
delete $in{sign};
delete $in{action};
process_action($action);
$antispam->logout();
exit;
sub init_antispam {
$antispam = new OpenSRS::EmailDefense();
$antispam->init();
}
sub process_action {
my $action = shift;
#-----------------------------------------------------
# perform necessary actions
# no action was supplied, so use the default
if (not $action) {
start_up();
# they passed a valid action
} elsif (exists $actions{$action}) {
no strict "refs";
&$action();
use strict;
# they passed an invalid action
} else {
error_out("Invalid action: $action");
}
}
# Session functions
####################################################################
# delete default value from session.
sub delete_defaults {
map { delete $session->{$_} } keys %{$session};
}
# load default value from config file into session.
sub load_defaults {
foreach my $key ( keys %DEFAULT_VALUES ) {
$session->{$key} = $DEFAULT_VALUES{$key};
}
}
# look up a value from session.
sub lookup_value {
my $key = shift;
return $session->{$key};
}
# store a value into session.
sub store_value {
my ($key, $value) = @_;
$session->{$key} = $value;
}
# just a shorter version of looking up a value of
# "sd_curr_domain_info" from session.
sub lookup_curr_domain_value {
my $key = shift;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
my $value = $curr_domain_info->{$key};
return $value;
}
sub store_curr_domain_value {
my ($key, $value) = @_;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$curr_domain_info->{$key} = $value;
store_value('sd_curr_domain_info',$curr_domain_info );
}
# clears current domain info and initialises domain's accounts info.
# "Current domain" holds info in the session on the domain being managed or purchased.
sub init_curr_domain_info {
my $curr_domain_info = {};
store_value('sd_curr_domain_info', $curr_domain_info);
init_domain_accounts_info();
}
# initialises current domain info to the domain's values.
sub get_current_domain_info {
init_curr_domain_info();
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$curr_domain_info->{domain_name} = $in{domain_name};
$curr_domain_info->{inventory_item_id} = $in{inventory_item_id};
store_value('sd_curr_domain_info', $curr_domain_info );
get_domain_accounts_info();
}
# info about domain's accounts is cleaned.
sub init_domain_accounts_info {
my @old_user_accounts = ();
my @old_user_accounts_string = ();
# 'mod_' is used for added or removed.
my @mod_user_accounts = ();
my @mod_user_accounts_string = ();
my @probable_mod_user_accounts_string = ();
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$curr_domain_info->{old_user_accounts} = \@old_user_accounts;
$curr_domain_info->{old_user_accounts_string} = \@old_user_accounts_string;
$curr_domain_info->{mod_user_accounts} = \@mod_user_accounts;
$curr_domain_info->{mod_user_accounts_string} = \@mod_user_accounts_string;
$curr_domain_info->{probable_mod_user_accounts_string} = \@probable_mod_user_accounts_string;
store_value('sd_curr_domain_info', $curr_domain_info );
}
# Get info of all accounts on the current domain.
# Store the gotten info in the session in "curr_domain_info".
sub get_domain_accounts_info {
my $result = $antispam->get_domain_accounts_info($in{inventory_item_id});
error_out($result->{response_text}) if not $result->{is_success};
error_out("This domain has been deleted. You cannot perform any operation on it. Your list of domains will be updated within 8 hours to exclude deleted domain.")
if $result->{attributes}{result}[0]{state} eq 'deleted';
my @old_user_accounts = ();
my @old_user_accounts_string = ();
map {
push @old_user_accounts, { name => $_->{name}, role => $_->{role}, feature_set => $_->{feature_set}};
} @{$result->{attributes}{result}[0]{product_data}{accounts}};
map {
push @old_user_accounts_string, $_->{name};
} @old_user_accounts;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
if (scalar @old_user_accounts_string == 1) {
$curr_domain_info->{disallow_remove_user_account} = 1;
}
$curr_domain_info->{old_user_accounts} = \@old_user_accounts;
$curr_domain_info->{old_user_accounts_string} = \@old_user_accounts_string;
store_value('sd_curr_domain_info', $curr_domain_info );
}
# get all domains with antispam for a particular user, by page.
sub get_antispam_domains_by_user {
my $domain_user_id = lookup_value('sd_domain_user_id') || $in{domain_user_id};
my %data = ( user_id => $domain_user_id );
my $result = $antispam->get_antispam_domains_by_user( \%data );
return $result;
}
######################### GENERAL FUNCTIONS ###########################################
sub start_up {
# delete deafult values from the session.
delete_defaults();
#load the defaults from config file
load_defaults();
show_lookup();
}
# Lookup is the default page to show if no action is
# specified
sub show_lookup {
# start every lookup with a clean info about the domain.
init_curr_domain_info();
# if defaults contain domain name,
# proceed to the next action without displaying html for domain entry.
if(lookup_value('dflt_domain_name')){
store_curr_domain_value ('domain_name',lookup_value('dflt_domain_name'));
do_lookup_domain();
} else {
print_form(template => "$path_templates/lookup.html");
}
}
sub lookup_domain {
my $domain_name = $in{domain_name};
error_out("Empty domain") if not $domain_name;
store_curr_domain_value ('domain_name',$domain_name);
do_lookup_domain();
}
# Check if domain exists, does not exist,
# or is already taken and belongs to a different reseller.
# If the domain is taken and belongs to a different reseller, error out.
sub do_lookup_domain {
my $curr_domain_info = lookup_value('sd_curr_domain_info');
my $domain_name = $curr_domain_info->{domain_name};
my $result = $antispam->check_domain($domain_name);
if ($result->{is_success}) {
$curr_domain_info->{available} = $result->{available};
# looping can be removed after API is fixed to return only active domains.
foreach my $item (@{$result->{attributes}{result}}) {
$curr_domain_info->{inventory_item_id} = $item->{inventory_item_id};
store_value('sd_domain_user_id',$item->{user_id});
}
store_value ('sd_curr_domain_info',$curr_domain_info);
select_service_action();
} else {
error_out($result->{error});
}
}
# If domain does not exist, login as existing or new user.
# If domain exists and belongs to the querying reseller, login as existing user.
sub select_service_action {
# store_username_and_password();
if (lookup_curr_domain_value('available')) {
new_purchase_service_login();
} else {
manage_service_login();
}
}
sub store_username_and_password {
my ($username, $password, $error, $result);
if(lookup_value('dflt_username')){
$username = lookup_value('dflt_username');
$password = lookup_value('dflt_password');
} else {
$username = $in{username};
$password = $in{password};
}
$result = $antispam->check_username_syntax($username);
$error .= $result->{error} if not $result->{is_success};
#$result = $antispam->check_password_syntax($password);
#$error .= $result->{error} if not $result->{is_success};
error_out($error) if $error;
store_value('sd_username', $username);
store_value('sd_password', $password);
}
sub create_new_user {
store_username_and_password();
store_value('sd_confirm_password',$in{confirm_password}) if not lookup_value('sd_confirm_password');
my $result = $antispam->create_user( lookup_value('sd_username'),
lookup_value('sd_password'),
lookup_value('sd_confirm_password'),
);
error_out($result->{error}) if not $result->{is_success};
store_value('sd_domain_user_id', $result->{attributes}{user_id});
new_purchase_service();
}
# Password is emailed to the user.
sub recover_password {
print_form(template => "$path_templates/recover_password.html");
}
sub do_recover_password {
my %HTML;
$HTML{domain_name} = lookup_curr_domain_value('domain_name');
my $result = $antispam->recover_password($in{username});
if ($result->{is_success}) {
print_form(template => "$path_templates/password_recovery_msg.html", data => \%HTML );
} else {
error_out($result->{error});
}
}
sub new_purchase_service_login {
store_curr_domain_value('service_type','new_purchase');
if(lookup_value('dflt_username')){
login_user();
} else {
my %HTML;
$HTML{domain_name} = lookup_curr_domain_value('domain_name');
print_form(template=> "$path_templates/new_purchase_service_login.html", data => \%HTML);
}
}
# Login user for the purchase of new domain.
sub login_user {
store_username_and_password();
my $result = $antispam->login_user( lookup_value('sd_username'),
lookup_value('sd_password'));
if ($result->{is_success}) {
store_value('sd_domain_user_id',$result->{attributes}{user_id});
new_purchase_service();
} else {
error_out($result->{error});
}
}
sub new_purchase_service {
my %HTML;
add_user_accounts();
}
sub manage_service_login {
if(lookup_value('dflt_username')){
login_domain_user();
} else {
print_form(template => "$path_templates/manage_service_login.html");
}
}
# login user only if queried domain belongs to the user for managing.
sub login_domain_user {
store_username_and_password();
my $result = $antispam->login_domain_user( lookup_value('sd_username'),
lookup_value('sd_password'),
lookup_value('sd_domain_user_id')
);
if ($result->{is_success}) {
manage_service();
} else {
error_out($result->{error});
}
}
# store all domains and info on each of them in the session.
sub manage_service {
my (%HTML, $result, $domain, @sd_domains);
load_defaults();
store_value('sd_domain_user_id', $in{domain_user_id}) if $in{domain_user_id};
$domain = $in{domain_name} || lookup_curr_domain_value('domain_name');
if (lookup_value('dflt_manage_one_domain')) {
$result = $antispam->get_domain_info( $domain );
} else {
$result = get_antispam_domains_by_user();
}
error_out($result->{error}) if not $result->{is_success};
error_out("There are no Email Defense Service domains to manage as your order has not been processed yet.")
if not scalar @{$result->{attributes}{result}};
foreach $domain ( @{$result->{attributes}{result}} ) {
push @sd_domains, {
domain_name => $domain->{description},
inventory_item_id => $domain->{inventory_item_id},
};
}
my @sd_domains = sort { $a->{domain_name} cmp $b->{domain_name} } @sd_domains;
store_value('sd_domains', \@sd_domains);
do_manage_service();
}
# display all domains, with each domain keeping a session in case it is going to be managed.
sub do_manage_service {
my (%HTML, @html_domains, $domain, $i);
init_curr_domain_info();
store_curr_domain_value('service_type','manage');
my %ss = $session->dump($OPENSRS{private_key});
foreach $domain ( @{lookup_value('sd_domains')} ) {
push @html_domains, {
domain_name => $domain->{domain_name},
inventory_item_id => $domain->{inventory_item_id},
class => $i%2 ? 'soft' : 'accent',
session => $ss{session},
sign => $ss{sign},
};
$i++;
}
$HTML{domains} = \@html_domains;
$HTML{navbar} = lookup_value('sd_navbar');
print_form(template => "$path_templates/manage_service.html", data => \%HTML);
}
# mix and match different functions for different actions to be performed.
sub do_manage {
if($in{cancel}) {
if ($in{edit_path}) {
process_action($in{cancel_edit_action});
} else {
do_manage_service();
}
} elsif($in{add_manage_user_accounts}) {
add_manage_user_accounts();
} elsif($in{add_manage_user_roles_and_pass_info}) {
do_add_manage_user_accounts();
add_user_roles_and_pass_info();
} elsif($in{confirm_add_manage_order}) {
do_add_manage_user_roles_and_pass_info();
confirm_add_manage_order();
} elsif($in{process_add_manage_order}) {
process_add_manage_order();
} elsif($in{remove_manage_user_accounts}) {
remove_manage_user_accounts();
} elsif($in{confirm_remove_manage_order}) {
do_remove_manage_user_accounts();
confirm_remove_manage_order();
} elsif($in{process_remove_manage_order}) {
process_remove_manage_order();
}
}
######################## USER ACCOUNTS #########################################
sub add_user_accounts {
get_current_domain_info() if $in{init_curr_domain};
my $HTML = get_basic_user_accounts_html();
print_form(template => "$path_templates/add_user_accounts.html", data => $HTML );
}
sub add_manage_user_accounts {
get_current_domain_info() if $in{init_curr_domain};
my $HTML = get_basic_user_accounts_html();
print_form(template => "$path_templates/add_manage_user_accounts.html", data => $HTML );
}
sub remove_manage_user_accounts {
get_current_domain_info() if $in{init_curr_domain};
my $HTML = get_basic_user_accounts_html();
print_form(template => "$path_templates/remove_manage_user_accounts.html", data => $HTML );
}
sub edit_user_accounts {
my $HTML = get_edit_user_accounts_html();
print_form(template => "$path_templates/add_user_accounts.html", data => $HTML );
}
sub edit_manage_user_accounts {
my $HTML = get_edit_user_accounts_html();
print_form(template => "$path_templates/add_manage_user_accounts.html", data => $HTML );
}
sub edit_remove_manage_user_accounts {
my $HTML = get_edit_user_accounts_html();
print_form(template => "$path_templates/remove_manage_user_accounts.html", data => $HTML );
}
sub get_basic_user_accounts_html {
my %HTML;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$HTML{domain_name} = $curr_domain_info->{domain_name};
$HTML{max_users} = $ANTISPAM{MAX_USERS};
$HTML{disallow_remove_user_account} = $curr_domain_info->{disallow_remove_user_account};
return \%HTML;
}
sub get_edit_user_accounts_html {
my $HTML;
$HTML = get_basic_user_accounts_html();
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$HTML->{user_accounts} = join "\n", @{$curr_domain_info->{probable_mod_user_accounts_string}};
# if we want to edit previously selected user accounts,
# we need to clear previous selection.
$HTML->{edit_path} = 1;
return $HTML;
}
sub do_add_user_accounts {
confirm_new_purchase_order() if $in{cancel};
my @mod_user_accounts_string = split " ", $in{mod_user_accounts_string};
my $result = $antispam->check_user_accounts($ANTISPAM{MAX_USERS}, \@mod_user_accounts_string);
error_out($result->{error}) if not $result->{is_success};
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$curr_domain_info->{probable_mod_user_accounts_string} = \@mod_user_accounts_string;
store_value('sd_curr_domain_info', $curr_domain_info );
add_user_roles_and_pass_info();
}
sub do_add_manage_user_accounts {
my $curr_domain_info = lookup_value('sd_curr_domain_info');
my @mod_user_accounts_string = split " ", $in{mod_user_accounts_string};
my $old_user_accounts_string = $curr_domain_info->{old_user_accounts_string};
my $result = $antispam->check_add_user_accounts($ANTISPAM{MAX_USERS}, \@mod_user_accounts_string, $old_user_accounts_string);
error_out($result->{error}) if not $result->{is_success};
$curr_domain_info->{probable_mod_user_accounts_string} = \@mod_user_accounts_string;
store_value('sd_curr_domain_info', $curr_domain_info );
}
sub do_remove_manage_user_accounts {
if ( ($in{confirm_remove_manage_order} and exists $in{mod_user_accounts_string}) or not $in{confirm_remove_manage_order} ) {
my $curr_domain_info = lookup_value('sd_curr_domain_info');
my @mod_user_accounts_string = split " ", $in{mod_user_accounts_string};
my $old_user_accounts_string = $curr_domain_info->{old_user_accounts_string};
my $result = $antispam->check_remove_user_accounts($ANTISPAM{MAX_USERS}, \@mod_user_accounts_string,$old_user_accounts_string);
error_out($result->{error}) if not $result->{is_success};
$curr_domain_info->{probable_mod_user_accounts_string} = \@mod_user_accounts_string;
store_value('sd_curr_domain_info', $curr_domain_info );
}
}
######################################## USER ROLES AND PASSWORD INFO #######################################
sub add_user_roles_and_pass_info {
my (%HTML, @html_users, $user_accounts);
if ( not lookup_value('dflt_allow_passwd_assgnmt') and lookup_value('dflt_user_role') ) {
if ( lookup_curr_domain_value('service_type') eq 'new_purchase' ) {
do_add_user_roles_and_pass_info();
} else {
collect_user_info();
confirm_add_manage_order();
}
} else {
my @html_users_old_added = ();
my @html_users_new_added = ();
my $user_accounts_remaining_string = ();
my $itr = 0;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
my $user_accounts_new_added_string = $curr_domain_info->{probable_mod_user_accounts_string};
if ( $HTML{edit_path} = $in{edit_path} ) {
my $user_accounts_old = $curr_domain_info->{mod_user_accounts};
# if after edit we have the same user accounts, we don't want to include them again.
my $result = $antispam->get_edit_user_accounts($user_accounts_new_added_string, $user_accounts_old);
# prune newly added accounts that are already in the session.
$user_accounts_new_added_string = $result->{user_accounts_new_added_string};
$user_accounts_remaining_string = $result->{user_accounts_remaining_string};
@html_users_old_added = @{get_mod_html_users($user_accounts_remaining_string)};
$itr = scalar @{$user_accounts_remaining_string};
}
@html_users_new_added = @{get_default_html_users($user_accounts_new_added_string, $itr)};
@html_users = ( @html_users_old_added, @html_users_new_added);
$HTML{users} = \@html_users;
$HTML{domain_name} = $curr_domain_info->{domain_name};
$HTML{allow_passwd_assgnmt} = lookup_value('dflt_allow_passwd_assgnmt');
$HTML{new_purchase} = ( lookup_curr_domain_value('service_type') eq 'new_purchase' ) ? 1 : 0;
print_form(template => "$path_templates/add_user_roles_and_pass_info.html", data => \%HTML);
}
}
sub get_default_html_users {
my $user_accounts_string = shift;
my $itr = shift;
my @html_users;
map { push @html_users, { user_account => $_,
user_roles => build_select_menu(lookup_value('dflt_user_roles'),lookup_value('dflt_html_user_role') ),
itr => $itr++,
}
} @{$user_accounts_string};
return \@html_users;
}
sub get_mod_html_users {
my $user_accounts = shift;
my @html_users;
my $itr = 0;
map { push @html_users, { user_account => $_->{user_account},
user_roles => build_select_menu(lookup_value('dflt_user_roles'), $_->{user_role}),
now_enabled => ( $_->{passwd_assgnmt} eq 'now' ) ? "checked" : "",
later_enabled => ( $_->{passwd_assgnmt} eq 'later' ) ? "checked" : "",
itr => $itr++,
}
} @{$user_accounts};
return \@html_users;
}
sub do_add_user_roles_and_pass_info {
confirm_new_purchase_order() if $in{cancel};
collect_user_info();
if ( $in{edit_path} ) {
confirm_new_purchase_order();
} else {
add_email_servers();
}
}
sub do_add_manage_user_roles_and_pass_info {
if ( ($in{confirm_add_manage_order} and exists $in{list}) or not $in{confirm_add_manage_order} ) {
collect_user_info();
}
}
sub collect_user_info {
my (@data, @user_accounts_string, $user_account, $itr, $password, $confirm_password, $passwd_assgnmt, $user_role);
my $curr_domain_info = lookup_value('sd_curr_domain_info');
my $dflt_user_role = lookup_value('dflt_user_role');
@user_accounts_string = @{$curr_domain_info->{probable_mod_user_accounts_string}};
$itr=0;
foreach $user_account ( @user_accounts_string ) {
$password = $in{'password_'.$itr};
$confirm_password = $in{'confirm_password_'.$itr};
$passwd_assgnmt = $dflt_user_role ? 'later' : $in{'passwd_assgnmt_'.$itr};
$user_role = $dflt_user_role || $in{'user_role_'.$itr};
if ( $passwd_assgnmt eq 'now' ) {
my $result = $antispam->check_edef_user_password($passwd_assgnmt,$password,$confirm_password) ;
error_out($result->{error}) if not $result->{is_success};
}
push @data, { user_account => $user_account,
user_role => $user_role,
passwd_assgnmt => $passwd_assgnmt,
password => $password,
confirm_password => $confirm_password,
};
$itr++;
}
$curr_domain_info->{probable_mod_user_accounts} = \@data;
store_value('sd_curr_domain_info', $curr_domain_info );
}
################################ EMAIL SERVERS #########################
sub add_email_servers {
my (%HTML, $server_info, $i);
if ($server_info = lookup_value('dflt_server_1') ) {
$i=1;
while ($server_info = lookup_value('dflt_server_'.$i)){
# preference number is optional.
$server_info =~ /^(.*),\s*(.*),\s*(.*)$/ or $server_info =~ /^(.*),\s*(.*)$/;
process_email_servers($i,$1,$2,$3);
$i++;
}
add_contact_info();
} else {
$HTML{domain_name} = lookup_curr_domain_value('domain_name');
print_form(template => "$path_templates/add_email_servers.html", data => \%HTML );
}
}
sub do_add_email_servers {
confirm_new_purchase_order() if $in{cancel};
error_out("No email servers specified.") if not $in{'host_1'};
for my $i (1 .. NUM_SERVERS) {
if ( $in{'host_'.$i} ) {
process_email_servers($i,$in{'host_'.$i},$in{'port_'.$i},$in{'preference_'.$i});
}
}
add_contact_info();
}
sub process_email_servers {
my ($num, $host, $port, $preference) = @_;
error_out("Invalid host.") if not $antispam->check_hostname_syntax($host);
error_out("Invalid port.") if not $antispam->check_port_syntax($port);
error_out("Invalid preference.") if $preference and not $antispam->check_preference_syntax($preference);
store_value('sd_host_'.$num, $host);
store_value('sd_port_'.$num, $port);
store_value('sd_preference_'.$num, $preference);
}
############################### CONTACT INFO ###################################
sub add_contact_info {
my (%HTML, $contact_id, @html_contacts, $contacts, %contact_list );
# If contact id is hard coded in the config file, get it and go straight to confirmation.
if ($contact_id = lookup_value('dflt_contact_id')) {
store_value('sd_contact_id',lookup_value('dflt_contact_id'));
confirm_new_purchase_order();
# Otherwise get all user contacts for drop down list and
# also show form for contact input.
} else {
my $result = $antispam->get_contacts_by_user_id(lookup_value('sd_domain_user_id'));
error_out($result->{response_text}) if not $result->{is_success};
map {
$contact_list{$_->{contact_id}} = $_->{first_name}.", ".$_->{last_name}.", ".$_->{email}.", ".$_->{contact_id};
} @{$result->{attributes}{result}};
$contact_list{select} = "Please select Contact";
$HTML{domain_name} = lookup_curr_domain_value('domain_name');
$HTML{country_menu} = build_country_list();
$HTML{contact_list} = build_select_menu(\%contact_list,'select' );
print_form(template => "$path_templates/add_contact_info.html", data => \%HTML );
}
}
sub edit_contact_info {
my (%HTML, @key, @value);
$HTML{domain_name} = lookup_curr_domain_value('domain_name');
my $admin_contacts = lookup_value('sd_admin_contacts');
map { @key=keys %{$_}; @value=values %{$_}; $HTML{@key[0]} = @value[0]} @{$admin_contacts};
$HTML{country_menu} = build_country_list($HTML{country});
$HTML{edit_path} = 1;
print_form(template => "$path_templates/add_contact_info.html", data => \%HTML );
}
sub do_add_contact_info {
confirm_new_purchase_order() if $in{cancel};
# If user selected one of the existing contacts, get its id.
if ( $in{admin_contact} and $in{admin_contact} ne 'select' ) {
store_value('sd_contact_id',$in{admin_contact});
# Otherwise get contact info from the form.
} else {
my (@admin_contacts, $error, $full_key);
my $contact_data = {};
foreach ( qw(first_name last_name address1 city state country postal_code phone email) ) {
next if not $in{$_};
$full_key = ( $_ =~ /^owner_/ ) ? $_ : 'owner_'.$_;
$contact_data->{$full_key} = $in{$_};
push @admin_contacts, {$_ => $in{$_} };
}
my $result = $antispam->validate_contacts( $contact_data );
error_out($result->{error}) if not $result->{is_success};
store_value('sd_admin_contacts', \@admin_contacts);
}
confirm_new_purchase_order();
}
############################ CANCEL ORDER #############################################
sub cancel_new_purchase_order {
print_form(template => "$path_templates/cancel_new_purchase_order.html");
exit;
}
sub cancel_emaildefense_service {
my %HTML;
get_current_domain_info() if $in{init_curr_domain};
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$HTML{domain_name} = $curr_domain_info->{domain_name};
print_form(template => "$path_templates/cancel_emaildefense_service.html", data => \%HTML );
}
sub do_cancel_emaildefense_service {
keep_emaildefense_service() if $in{keep_emaildefense_service};
my %HTML;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
# we need these values when returning to the manage domains page
# to retrieve info for the user or domain.
$HTML{domain_name} = $curr_domain_info->{domain_name};
$HTML{domain_user_id} = $curr_domain_info->{domain_user_id};
my $inventory_item_id = $curr_domain_info->{inventory_item_id};
my $result = $antispam->tpp_cancel_emaildefense_service($inventory_item_id);
error_out($result->{response_text}) if not $result->{is_success};
print_form(template => "$path_templates/do_cancel_emaildefense_service.html", data => \%HTML );
}
sub keep_emaildefense_service {
print_form(template => "$path_templates/keep_emaildefense_service.html");
exit;
}
########################## CONFIRM ORDER ###############################################
sub confirm_new_purchase_order {
my (%HTML, @key, @value);
$HTML{allow_edit_contact} = lookup_value('sd_contact_id') ? 0 : 1;
my $admin_contacts = lookup_value('sd_admin_contacts');
map { @key=keys %{$_}; @value=values %{$_}; $HTML{@key[0]} = @value[0]} @{$admin_contacts};
$HTML{cc_fields} = $antispam->cc_fields("$path_templates/cc_fields.html") if $ANTISPAM{F_SHOW_CC_FIELDS};
confirm_order("confirm_new_purchase_order.html", \%HTML);
exit;
}
sub confirm_add_manage_order {
my %HTML;
$HTML{cc_fields} = $antispam->cc_fields("$path_templates/cc_fields.html") if $ANTISPAM{F_SHOW_CC_FIELDS};
confirm_order("confirm_add_manage_order.html", \%HTML);
}
sub confirm_remove_manage_order {
confirm_order("confirm_remove_manage_order.html");
}
sub confirm_order {
my %HTML;
my $template = shift;
my $HTML = shift;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
if (not $in{cancel}) {
$curr_domain_info->{mod_user_accounts_string} = $curr_domain_info->{probable_mod_user_accounts_string};
$curr_domain_info->{mod_user_accounts} = $curr_domain_info->{probable_mod_user_accounts};
}
$HTML->{mod_user_accounts} = join ("
", @{$curr_domain_info->{mod_user_accounts_string}});
$HTML->{mod_user_accounts_num} = scalar @{$curr_domain_info->{mod_user_accounts_string}};
$HTML->{domain_name} = $curr_domain_info->{domain_name};
$HTML->{new_purchase} = ( lookup_curr_domain_value('service_type') eq 'new_purchase' ) ? 1 : 0;
if (scalar @{$curr_domain_info->{mod_user_accounts_string}}) {
$HTML->{allow_process} = 1;
}
print_form(template => "$path_templates/$template", data => $HTML );
}
###################################### PROCESS ORDER ######################################
sub process_new_purchase_order {
cancel_new_purchase_order() if $in{cancel_new_purchase_order};
process_cc_fields() if $ANTISPAM{F_VERIFY_CC};
my $order_info = get_new_purchase_order_info();
my $result = $antispam->process_new_purchase_order($ANTISPAM{process_immediate}, $order_info);
if ($result->{is_success}) {
$result->{html_action} = "new_purchase";
show_order_results($result);
} else {
error_out("$result->{attributes}{create_items}[0]{major_text}: $result->{response_text} ");
}
}
sub process_add_manage_order {
process_cc_fields() if $ANTISPAM{F_VERIFY_CC};
my $order_info = get_add_manage_order_info();
my $result = $antispam->process_upgrade_order($ANTISPAM{process_immediate}, $order_info);
if ($result->{is_success}) {
$result->{html_action} = "upgrade";
show_order_results($result);
} else {
error_out("$result->{attributes}{create_items}[0]{major_text}: $result->{response_text} ");
}
}
sub process_remove_manage_order {
my $order_info = get_remove_manage_order_info();
my $result = $antispam->process_downgrade_order($ANTISPAM{process_immediate}, $order_info);
if ($result->{is_success}) {
$result->{html_action} = "downgrade";
show_order_results($result);
} else {
error_out("$result->{attributes}{create_items}[0]{major_text}: $result->{response_text} ");
}
}
sub process_cc_fields {
my %data = (
p_cc_num => $in{p_cc_num},
p_cc_type => $in{p_cc_type},
p_cc_exp_mon => $in{p_cc_exp_mon},
p_cc_exp_yr => $in{p_cc_exp_yr}
);
my $result = $antispam->verify_cc_fields(\%data);
error_out($result->{error}) if not $result->{is_success};
my $response = call_payment_gateway(\%data);
if ( not call_payment_gateway(\%data) ) {
error_out ("Credit Card information is not valid.");
}
}
# For a reseller to enter payment gateway (credit card clearing) code.
sub call_payment_gateway {
my $data = shift;
# INSERT PAYMENT GATEWAY CODE HERE
return 1;
}
##################################### GET ORDER INFO #################################
sub get_new_purchase_order_info {
my (%order_info, $i, $server_info, @mtas, $entry);
$order_info{user_id} = lookup_value('sd_domain_user_id');
$order_info{domain_name} = lookup_curr_domain_value('domain_name');
my $curr_domain_info = lookup_value('sd_curr_domain_info');
if ( lookup_value('sd_contact_id') ) {
@{$order_info{admin_contacts}} = ( {id => lookup_value('sd_contact_id')} );
} else {
$order_info{admin_contacts} = lookup_value('sd_admin_contacts');
}
$i=1;
while( lookup_value('sd_host_'.$i) ) {
push @mtas, { host => lookup_value('sd_host_'.$i),
port => lookup_value('sd_port_'.$i),
preference => lookup_value('sd_preference_'.$i),
};
$i++;
}
$order_info{mtas} = \@mtas;
my $mod_user_accounts = $curr_domain_info->{mod_user_accounts};
$i=0;
foreach $entry (@{$mod_user_accounts}) {
$order_info{create_items}[$i]{role} = $entry->{user_role};
$order_info{create_items}[$i]{name} = $entry->{user_account};
$order_info{create_items}[$i]{password} = $entry->{password};
$i++;
}
return \%order_info;
}
sub get_add_manage_order_info {
my (%order_info, $i, $entry);
@{$order_info{mod_user_accounts}} = ();
$order_info{user_id} = lookup_value('sd_domain_user_id');
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$order_info{inventory_item_id} = $curr_domain_info->{inventory_item_id};
my $old_user_accounts = $curr_domain_info->{old_user_accounts};
my $mod_user_accounts = $curr_domain_info->{mod_user_accounts};
$i=0;
foreach $entry (@{$old_user_accounts}) {
$order_info{old_user_accounts}[$i]{role} = $entry->{role};
$order_info{old_user_accounts}[$i]{name} = $entry->{name};
$i++;
}
$i=0;
foreach $entry (@{$mod_user_accounts}) {
$order_info{mod_user_accounts}[$i]{role} = $entry->{user_role};
$order_info{mod_user_accounts}[$i]{name} = $entry->{user_account};
$order_info{mod_user_accounts}[$i]{password} = $entry->{password};
$i++;
}
return \%order_info;
}
sub get_remove_manage_order_info {
my (%order_info, $i, $entry);
$order_info{user_id} = lookup_value('sd_domain_user_id');
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$order_info{inventory_item_id} = $curr_domain_info->{inventory_item_id};
my $old_user_accounts_string = $curr_domain_info->{old_user_accounts_string};
my $mod_user_accounts_string = $curr_domain_info->{mod_user_accounts_string};
@{$order_info{remained_user_accounts}} = ();
foreach $entry (@{$old_user_accounts_string}) {
( push @{$order_info{remained_user_accounts}}, { name => $entry } )
if not grep /^$entry$/, @{$mod_user_accounts_string};
}
@{$order_info{mod_user_accounts_string}} = ();
foreach $entry (@{$mod_user_accounts_string}) {
push @{$order_info{mod_user_accounts_string}}, { name => $entry };
}
return \%order_info;
}
########################### SHOW RESULTS ######################################
sub show_order_results {
my (%HTML);
my $data = shift;
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$HTML{reseller_email} = $ANTISPAM{reseller_email};
$HTML{order_id} = $data->{attributes}{order_id};
$HTML{domain_name} = $curr_domain_info->{domain_name};
$HTML{action} = $data->{html_action};
$HTML{new_purchase} = ( lookup_curr_domain_value('service_type') eq 'new_purchase' ) ? 1 : 0;
$HTML{users} = scalar @{$curr_domain_info->{mod_user_accounts_string}};
$HTML{ed_portal_url} = $ANTISPAM{ed_portal_url};
print_form(template => "$path_templates/order_results.html", data => \%HTML );
}
################################ LIST FEATURES AND USERS ##################################
sub list_features_and_users {
my (%HTML, @user_accounts);
get_current_domain_info() if $in{init_curr_domain};
my $curr_domain_info = lookup_value('sd_curr_domain_info');
$HTML{domain_name} = $curr_domain_info->{domain_name};
$HTML{user_accounts} = join "
", @{$curr_domain_info->{old_user_accounts_string}};
$HTML{num_user_accounts} = scalar @{$curr_domain_info->{old_user_accounts_string}};
print_form(template => "$path_templates/list_features_and_users.html", data => \%HTML );
}
##########################################################################
# substitute values on the specified template and print it to the client
# an optional 'type' arg can be passed: 'framed' specifies to pull in base.html
# as the outer frame and the given template as the inner frame
# 'single' specifies to use the given template alone
# the default behavior is 'framed'
sub print_form {
my %args = @_;
$args{title} = "EmailDefense Registration/Management" if not $args{title};
$args{username} = lookup_value('sd_username');
if (0) { #for easy debug test
local $Data::Dumper::Indent=1;
local $Data::Dumper::Useqq=0;
print "",Dumper(\%args),"
";
}
my $template = HTML::Template->new(cache => 1, filename => $args{template}, die_on_bad_params => 0);
$template->param(CGI=>$cgi,%{$args{data}},$session->dump($OPENSRS{private_key}));
unless ($args{not_framed}) {
my $content = $template->output;
$template = HTML::Template->new(cache => 1, filename => "$path_templates/base.html", die_on_bad_params => 0);
$template->param(CONTENT=>$content);
}
$template->param(CGI=>$cgi,%{$args{data}});
print $template->output;
}
sub set_debugging_level {
if ($ANTISPAM{debug}) {
# print error to the page
select (STDOUT); $| = 1;
open (STDERR, ">&STDOUT") or die "Can't dump stdout: $!\n";
select (STDERR); $| = 1;
select (STDOUT);
}
OpenSRS::Util::Common::initialize( path_templates => $PATH_TEMPLATES );
}
sub error_out {
my %HTML = ( ERROR => shift );
print_form(template => "$path_templates/error.html", data => \%HTML);
exit;
}
opensrs-client-3.0.0/cgi/emaildefense.css 0000644 0177776 0177776 00000012104 10770014202 021424 0 ustar nobody nogroup 0000000 0000000 BODY { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 15px; background-color: #FFF6DE; }
TD { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 15px; }
A.link:link { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #660000; text-decoration: none; background: transparent; }
A.link:visited { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #996633; text-decoration: none; background: transparent; }
A.link:active { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #709BD9; text-decoration: none; background: transparent; }
A.link:hover { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #709BD9; text-decoration: none; background: transparent; }
HR { COLOR: #A6C1E9; BACKGROUND-COLOR: #A6C1E9; border: 0px; }
td.accent { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #DDAA77; padding-left: 2pt; }
td.soft { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFDDAA; padding-left: 2pt; }
td.help { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFF2D1; padding-left: 2pt; }
td.wh { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFFFFF; padding-left: 15pt; padding-top: 0pt; }
td.bl { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #000000; }
tr.accent { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #DDAA77; padding-left: 2pt; }
tr.soft { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFDDAA; padding-left: 2pt; }
tr.help { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFF2D1; padding-left: 2pt; }
tr.wh { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFFFFF; padding-left: 15pt; padding-top: 0pt; }
tr.bl { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #000000; }
table.accent { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #DDAA77; padding-left: 2pt; }
table.soft { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFDDAA; padding-left: 2pt; }
table.help { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFF2D1; padding-left: 2pt; }
table.wh { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #FFFFFF; padding-left: 15pt; padding-top: 0pt; }
table.bl { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: black; background-color: #000000; }
.header1 { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 24px; color: #000000; font-weight: bold; }
.header2 { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #6D6D6D; font-variant:small-caps;}
.header3 { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #000000; font-variant:small-caps; }
.help { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #000000; font-weight: bold; }
.name { font-family: Georgia, Times New Roman, Times, serif; font-size: 14px; color: #6D6D6D; }
.nav { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #2E3A4C; font-weight: bold; text-decoration: none; }
input,form { padding: 0; margin: 0; }
input.soft { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.accent { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.zms { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.zma { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.dfs { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.dfa { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.prs { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.pra { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.ed { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.ca { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.sa { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.up { background-color: #D8D8D8; font-size: 10px; color: #000000; }
input.rs { background-color: #C4CBD7; font-size: 10px; color: #000000; }
input.radio.accent { background : #E4ECF8; }
input.radio.soft { background : #EDEDED; }
.error {font-size: 14px; color: #FF0000; font-weight: bold; font-variant:small-caps;}
opensrs-client-3.0.0/cgi/help.cgi 0000755 0177776 0177776 00000004327 10770014202 017720 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
# .Copyright (C) 1999-2002 TUCOWS.com Inc.
# .Created: 11/19/1999
# .Contactid:
# .Url: http://www.opensrs.org
# .Originally Developed by:
# Tucows/OpenSRS
# .Authors: Evgeniy Pirogov
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# pull in conf file with defined values
# XXX NOTE XXX Update this configuration file
BEGIN {
$path_to_config = '';
do "$path_to_config/OpenSRS.conf";
}
use lib $PATH_LIB;
use strict;
use CGI qw();
use IO::File;
use Core::Exception;
use OpenSRS::Help qw/HelpPages/;
use OpenSRS::Util::Error;
use OpenSRS::Util::Logger '$Log';# =>"$PATH_LOG/help.log";
my $path_templates = "$PATH_TEMPLATES/help";
my $q = new CGI;
try {
if ($q->param('tld')){
$path_templates .= '/' .$q->param('tld');
}
my $topic = $q->param('topic');
unless (HelpPages->{$topic}){
throw 'dev','Invalid topic \'%s\'',$topic;
}
my $fh = IO::File->new($path_templates."/".HelpPages->{$topic},O_RDONLY);
unless ($fh){
throw 'dev','Can\'t find help file for topic \'%s\'',$topic;
}
print $q->header;
my @content = <$fh>;
undef $fh;
print @content;
} catch {
dev => sub {
my $E = shift;
$Log->error("dev %s",$E->dump);
print $q->header;
error_output($E->info);
},
_other => sub {
my $E = shift;
$Log->error("other %s",$E->dump);
print $q->header;
error_output($E->info);
},
};
exit;
1;
opensrs-client-3.0.0/cgi/manage.cgi 0000755 0177776 0177776 00000401564 10770014202 020224 0 ustar nobody nogroup 0000000 0000000 #!/usr/bin/perl
# .Copyright (C) 1999-2000 TUCOWS.com Inc.
# .Created: 11/19/1999
# .Contactid:
# .Url: http://www.opensrs.org
# .Originally Developed by:
# VPOP Technologies, Inc. for Tucows/OpenSRS
# .Authors: Joe McDonald, Tom McDonald, Matt Reimer, Brad Hilton,
# Daniel Manley, Gennady Krizhevsky, John Jerkovic,
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# global defines
use vars qw(
%in %contact_types %actions $XML_Client %cookies $action
$authentication $cgi $path_templates $flag_header_sent
$reg_username $reg_password $reg_domain $cookie $domain_count
$reg_permission $reg_f_owner $expiredate $last_access_time
$last_ip %contact_keys $waiting_request $waiting_requests_no $dns_errors
$COOKIE_KEY %enctypes $T_EXPIRED $T_EXPIRING $t_mode $notice_days
%whois_rsp_info $capabilities %unauthenticated_actions
$inaccuratewhois $auction_escrow $dom_locked
);
( %in, %contact_types, %actions, $XML_Client, %cookies, $action,
$authentication, $cgi, $path_templates, $flag_header_sent,
$reg_username, $reg_password, $reg_domain, $cookie, $domain_count,
$reg_permission, $reg_f_owner, $expiredate, $last_access_time,
$last_ip, %contact_keys, $waiting_request, $waiting_requests_no,
%whois_rsp_info, $capabilities, $dns_errors,
$inaccuratewhois, $auction_escrow, $dom_locked
) = ();
# pull in conf file with defined values
# XXX NOTE XXX Update this configuration file
BEGIN {
$path_to_config = "";
if ($ENV{OSRS_CLIENT_ETC}){
$path_to_config = "$ENV{OSRS_CLIENT_ETC}";
}
do "$path_to_config/OpenSRS.conf";
}
use lib $PATH_LIB;
use CGI ':cgi-lib';
use strict;
use Time::Local;
use OpenSRS::XML_Client qw(:default);
use OpenSRS::Util::America qw(build_app_purpose_list);
use OpenSRS::Util::Common qw(make_navbar locale_build_country_list build_select_menu);
use OpenSRS::Util::Europe qw(build_eu_countries_list build_eu_languages_list build_be_languages_list);
use OpenSRS::Util::Asia qw(build_ced_locality_select_list build_ced_entity_type_select_list
build_ced_contact_type_select_list build_ced_identification_type_select_list);
# initialize global defines
$cgi = $ENV{SCRIPT_NAME};
$path_templates = "$PATH_TEMPLATES/manage";
$COOKIE_KEY = $TEST_SERVER?"REGISTRANT_KEY":"REGISTRANT_LIVE_KEY";
$flag_header_sent = 0; # whether html header has been sent
%in = ();
$reg_username = "";
$reg_password = "";
$reg_domain = "";
$cookie = "";
$domain_count = undef;
$reg_permission = undef;
$reg_f_owner = undef;
$expiredate = undef;
$last_access_time = undef;
$last_ip = undef;
$waiting_request = "";
$waiting_requests_no = undef;
$capabilities = undef;
$dns_errors = undef;
$T_EXPIRING = 1; # there are domains to expire in $notice_days days
$T_EXPIRED = 2; # there are expired domains
$t_mode = undef; # can be 0, $T_EXPIRING, $T_EXPIRED or ($T_EXPIRING | $T_EXPIRED)
$notice_days = $MANAGE{ notice_days } ? $MANAGE{ notice_days } : 60;
# list of contact types
%contact_types = (
owner => 'Organization',
admin => 'Admin',
billing => 'Billing',
tech => 'Technical',
);
%contact_keys = (
first_name => undef,
last_name => undef,
address1 => undef,
address2 => undef,
address3 => undef,
city => undef,
state => undef,
postal_code => undef,
country => undef,
email => undef,
url => undef,
fax => undef,
phone => undef,
org_name => undef,
lang => undef,
vat => undef,
);
# secure actions; require valid cookie
%actions = (
modify_contact => undef,
do_modify_contact => undef,
do_modify_org_contact_de => undef,
revoke_registrant_changes => undef,
modify_nameservers => undef,
do_modify_nameservers => undef,
add_nameserver => undef,
manage_nameservers => undef,
do_manage_nameserver => undef,
do_create_nameserver => undef,
manage_subuser => undef,
do_manage_subuser => undef,
delete_subuser => undef,
view_domains => undef,
manage_domain => undef,
manage_profile => undef,
change_password => undef,
do_change_password => undef,
change_ownership => undef,
do_change_ownership => undef,
view_waiting_history => undef,
get_expire_domains => undef,
whois_rsp_info => undef,
set_whois_rsp_info => undef,
send_password => undef,
domain_locking => undef,
modify_domain_extras => undef,
do_modify_domain_extras => undef,
do_change_ips_tag => undef,
);
%unauthenticated_actions = (
login => undef,
logout => undef,
send_password => undef,
);
start_up();
$XML_Client = new OpenSRS::XML_Client(%OPENSRS);
$XML_Client->login;
# read in the form data
ReadParse(\%in);
%cookies = GetCookies();
$action = $in{action};
#-----------------------------------------------------
# perform necessary actions
# a few actions are allowed without authentication.
if ( $action and exists $unauthenticated_actions{$action} ) {
no strict 'refs';
&$action();
exit;
}
# for all other actions, do validate() (grab cookie if it exists)
# if validate() fails, send them to the low-access menu
$authentication = validate();
################################################
### At this point, the following variables will be set if they logged in:
### $user_object,$user_id,$profile,$post_permission
# show them the login page if they don't have a valid cookie
if (not $authentication) {
show_login();
# no action was passed but they have a valid cookie
} elsif (not $action) {
main_menu();
# they asked for a valid action
} elsif (exists $actions{$action}) {
if(($action eq "get_expire_domains") && ($MANAGE{allow_renewals} == 0)) {
main_menu("Invalid action: $action");
exit;
}
no strict "refs";
&$action();
use strict;
# they gave us an invalid command
} else {
main_menu("Invalid action: $action");
}
$XML_Client->logout;
exit;
sub start_up {
if ($MANAGE{debug}) {
# print error to the page
select (STDOUT); $| = 1;
open (STDERR, ">&STDOUT") or die "Can't dump stdout: $!\n";
select (STDERR); $| = 1;
select (STDOUT);
}
}
# show login page for non-secure users
sub show_login {
my $message = shift;
my (%HTML);
$HTML{CGI} = $cgi;
$HTML{XPACK_MANAGE_WEBDIR} = $XPACK_MANAGE_WEBDIR;
if ( defined $message and $message ) {
$HTML{MESSAGE} = qq($message
);
} else {
$HTML{MESSAGE} = "";
}
print_form("$path_templates/login.html",\%HTML,'single');
}
# show main page for secure users
sub main_menu {
my (%HTML, $key);
my $message = shift;
my $billing_con_name = "Billing";
if($reg_domain =~ /de$/) {
$billing_con_name = "Zone";
}
my ($tld) = $reg_domain =~ /$OPENSRS{OPENSRS_TLDS_REGEX}$/;
# build front page per user's permissions
my %GRANT = (
f_modify_nameservers => "Manage Name Servers",
f_modify_owner => "Organization Contact",
f_modify_admin => "Admin Contact",
f_modify_billing => "$billing_con_name Contact",
f_modify_tech => "Technical Contact",
sub_user => "Manage Profile",
f_modify_whois_rsp_info => "Reseller Contact",
domain_locking => "Domain Locking",
f_modify_domain_extras => "Domain Extras",
);
my %DENY = (
f_modify_nameservers => "Manage Name Servers",
f_modify_owner => "Organization Contact",
f_modify_admin => "Admin Contact",
f_modify_billing => "$billing_con_name Contact",
f_modify_tech => "Technical Contact",
sub_user => "Manage Profile",
f_modify_whois_rsp_info => "Reseller Contact",
domain_locking => "Domain Locking",
f_modify_domain_extras => "Domain Extras",
);
# if user is the owner of the domain, give them full permissions
if ($reg_f_owner) {
foreach $key (keys %GRANT) {
$HTML{$key} = $GRANT{$key};
}
# otherwise, check their permission level against %PERMISSIONS
} else {
foreach $key (keys %GRANT) {
if ($reg_f_owner or ($reg_permission & $PERMISSIONS{$key})) {
$HTML{$key} = $GRANT{$key};
} else {
$HTML{$key} = $DENY{$key};
}
}
}
$HTML{whois_rsp_info} = $GRANT{whois_rsp_info};
$HTML{domain_locking} = $GRANT{domain_locking};
#
# .ca domains don't have a billing contact.
#
if ($reg_domain =~ /ca$/)
{
$HTML{f_modify_billing} = "$DENY{f_modify_billing} (CIRA uses the Administrative Contact for Billing)";
} elsif ($reg_domain =~ /uk$/){
$HTML{f_modify_tech} = "$DENY{f_modify_tech} (Technical contact information is no longer required for .UK)";
} elsif ($reg_domain =~ /(eu|be)$/) {
$HTML{f_modify_billing} = "$DENY{f_modify_billing} (Billling contact information is not required for " . uc $tld .")";
$HTML{f_modify_admin} = "$DENY{f_modify_admin} (Admin contact information is not required for " . uc $tld .")";
}
# if no extra domain info. to be displayed, do not show the link
#for .de there are dns errors also
if ( ! $capabilities->{domain_extras} and ! $dns_errors) {
$HTML{ f_modify_domain_extras } = "$DENY{ f_modify_domain_extras }";
}
# not all TLDs support locking
if ( not $reg_domain =~ /$OPENSRS{ TLDS_SUPPORTING_LOCKING }/i) {
$HTML{ domain_locking } = "$DENY{ domain_locking } (TLD does not support locking)";
} elsif ( not $reg_f_owner ) {
$HTML{ domain_locking } = "$DENY{ domain_locking } (Can only be modified by the owner of the domain)";
}
# .uk domains can't have their owner information changed,
# so only show the organization paragraph if the domain
#if be/eu
if ( $reg_domain =~ /(eu|be)$/ ) {
$HTML{ f_modify_owner } = <$HTML{ f_modify_owner }
This is information about the company or entity, which owns the domain name
you are managing (referred to as the "Licensee" by the registry). For .EU and .BE names changes to the First Name, Last Name or Organization field may result in a charge for the transaction.
EOF
}
# is not .uk
elsif ( $reg_domain !~ /uk$/ ) {
$HTML{ f_modify_owner } = <$HTML{ f_modify_owner }
This is information about the company or entity which owns the domain name
you are managing. Change company information here.
EOF
} else {
$HTML{f_modify_owner} = <$DENY{f_modify_owner}
This is information about the company or entity which owns the domain name
you are managing. Change company information here. NOTE (for .uk domains):
An Organization name change is effectively a Registrant Name Change; to do
this, please refer to your Nominet Domain Certificate.
EOF
}
if ($last_access_time) {
my $human_time = scalar localtime($last_access_time);
$HTML{LAST_ACCESS} = "
Last login: $human_time";
if ($last_ip) {
$HTML{LAST_ACCESS} .= " from $last_ip";
}
}
if ( not $reg_f_owner ) {
$HTML{SUB_USER} = '
Logged in as Sub User.';
}
$HTML{MESSAGE} = $message ? "
$message
\n" : "";
$HTML{DNS_ERRORS} = $dns_errors ? "
This domain is under a 30 day restriction and needs to be validated.
\n" : "";
$HTML{CGI} = $cgi;
$HTML{reg_username} = $reg_username;
print_form("$path_templates/main_menu.html",\%HTML);
}
# show subuser info
sub manage_subuser {
my (%HTML,$perm);
my ($sub_id,$sub_username,$sub_permission) = get_subuser();
$HTML{CGI} = $cgi;
$HTML{sub_id} = $sub_id;
$HTML{sub_username} = $sub_username;
foreach $perm (keys %PERMISSIONS) {
if ($sub_permission & $PERMISSIONS{$perm}) {
$HTML{"${perm}_1"} = "CHECKED";
} else {
$HTML{"${perm}_0"} = "CHECKED";
}
}
print_form("$path_templates/manage_subuser.html",\%HTML);
}
# process data for subuser modifications
sub do_manage_subuser {
my ($response,$perm);
my $sub_username = $in{sub_username};
my $sub_password = $in{sub_password};
my $sub_password2 = $in{sub_password2};
my $sub_id = $in{sub_id};
if (not $sub_username) {
error_out("No username supplied.
\n");
exit;
} elsif ($sub_password ne $sub_password2) {
error_out("Password mismatch.
\n");
exit;
} elsif (not $sub_password and not $sub_id) {
error_out("No password supplied.
\n");
exit;
}
my $sub_permission = 0;
foreach $perm (keys %PERMISSIONS) {
if ($in{$perm}) {
$sub_permission |= $PERMISSIONS{$perm};
}
}
my $xcp_request = {
action => ( $sub_id ? "modify" : "add" ),
object => "subuser",
cookie => $cookie,
attributes => {
sub_id => $sub_id,
sub_username => $sub_username,
sub_password => $sub_password,
sub_permission => $sub_permission,
}
};
$response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Command failed: $response->{response_text}\n");
exit;
}
main_menu("Subuser Changes Successful");
}
sub delete_subuser {
my $sub_id = $in{sub_id};
if (not $reg_f_owner) {
error_out("Only domain owner can delete subuser.
\n");
exit;
} elsif (not $sub_id) {
error_out("Subuser's id not supplied.
\n");
exit;
}
my $xcp_request = {
action => "delete",
object => "subuser",
cookie => $cookie,
attributes => {
sub_id => $sub_id,
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Command failed: $response->{response_text}\n");
exit;
}
main_menu("Subuser deleted");
}
sub change_password {
my (%HTML);
if (not $reg_f_owner) {
error_out("Permission denied: not owner.\n");
exit;
}
$HTML{CGI} = $cgi;
print_form("$path_templates/change_password.html",\%HTML);
}
sub do_change_password {
my $new_password = $in{password};
my $confirm_password = $in{confirm_password};
# validate password
if ($new_password =~ /^\s*$/) {
error_out("No password was given.
\n");
exit;
} elsif ($new_password ne $confirm_password) {
error_out("Password mismatch.
\n");
exit;
} elsif (length $new_password < 3 || length $new_password > 20) {
error_out("Password should have at least 3 and at most 20 characters.
\n");
exit;
} elsif ($new_password !~ /^[A-Za-z0-9\[\]\(\)!@\$\^,\.~\|=\-\+_\{\}\#]+$/) {
error_out("Invalid syntax for password '$new_password'.\n\n
Allowed characters are all alphanumerics (A-Z, a-z, 0-9) and symbols []()!@\$^,.~|=-+_{}#\n");
exit;
}
my $xcp_request = {
action => "change",
object => "password",
cookie => $cookie,
attributes => {
reg_password => $new_password,
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Failed attempt: $response->{response_text}\n");
exit;
}
main_menu("Password successfully changed.");
}
sub revoke_registrant_changes{
my ($error);
my $xcp_request = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "contact_info",
contact_set => {
'owner' => {"revoke_registrant_changes"=>1},
},
},
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
$error = "Failed attempt: $response->{response_text}
\n";
error_out($error);
exit;
}
main_menu($response->{response_text});
}
# show contact info for specified domain and contact type
sub modify_contact {
my ($error);
my $type = $in{type};
my $xcp_request = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => $type,
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
$error = "Failed attempt: $response->{response_text}
\n";
error_out($error);
exit;
}
# process this through escape() to account for " and ' in the data
escape_hash_values( $response );
my %HTML = ();
# put the contact keys/values into %HTML
foreach my $aKey ( keys %{$response->{attributes}->{contact_set}->{$type}} ) {
next unless exists $contact_keys{$aKey};
$HTML{$aKey} = $response->{attributes}->{contact_set}->{$type}->{$aKey};
}
#
# If the change is for the Org and the ccTLD is .ca
# then we need only display a wee little bit of info.
#
if (($type =~ /owner/i) && ($reg_domain =~ /ca$/)) {
my %short_way = %{$response->{attributes}->{contact_set}->{$type}};
if ((defined $short_way{member}) && ($short_way{member} eq "Y")) {
$HTML{member_field} = "Yes\n
No\n";
} else {
$HTML{member_field} = "Yes\n
No\n";
}
if (defined $short_way{cwa} && $short_way{cwa} eq 'Y' ) {
$HTML{cwa_field} = "Yes\n
No\n";
} else {
$HTML{cwa_field} = "Yes\n
No\n";
}
$HTML{legal_type_field} = build_ca_domain_legal_types ($short_way{legal_type});
$HTML{reg_domain} = $reg_domain;
$HTML{contact_type} = $contact_types{$type};
$HTML{type} = $type;
$HTML{description} = $short_way{description};
$HTML{CGI} = $cgi;
print_form("$path_templates/modify_ca_org_contact.html",\%HTML);
return;
}
#
# .ca is, as always, different....
#
if ($reg_domain =~ /ca$/)
{
foreach my $item (@CA_EXTRA_FIELDS)
{
$HTML{$item} = $response->{attributes}->{contact_set}->{$type}->{$item};
}
$HTML{language_type_field} = build_ca_language_preferences ($HTML{language});
$HTML{nationality_field} = build_ca_nationality_pulldown ($HTML{nationality});
if ( $in{ type } eq 'admin' ) {
$HTML{ cc_warning } = <
Note: Modifications to the admin contact info has been
deemed a 'critical change' by CIRA, and any changes to the contact information
will not take affect unless also confirmed at the CIRA site.
EOF
} elsif ( $in{ type } eq 'tech' ) {
$HTML{ cc_warning } = <
Note: If the technical contact info is the same as
that for the admin contact, changes to the information below will be deemed
a 'critical change' by CIRA, and will not take affect unless the changes are
also confirmed at the CIRA site.
EOF
}
}
else
{
$HTML{language_type} = "";
$HTML{middle_name} = "";
$HTML{job_title} = "";
$HTML{nationality} = "";
}
$HTML{org_comment} = '';
$HTML{org_comment_close} = '';
$HTML{uk_org_comment} = '!-- ';
$HTML{uk_org_comment_close} = ' --';
# for uk domains OpensRS do not send org_name to the Nominet
# and Owner org_name can be changed only at Nominet.
# http://www.nominet.org.uk/MakingChangesToYourDomainName/ChangingCompanyName/
# Not a very nice way of hiding
# the org name, but better to keep the template whole. Turn the
# organization line into an HTML comment.
# the exception is uk domain owner contact, we use the Organization as registrant
if ( $reg_domain =~ /\.uk$/ && $type =~ /owner/i ) {
$HTML{uk_org_comment} = '';
$HTML{uk_org_comment_close} = '';
$HTML{org_comment} = '!-- ';
$HTML{org_comment_close} = ' --';
}
if ( $reg_domain =~ /\.de$/ && (($type eq "billing" ) or ($type eq "tech"))) {
$HTML{fax_opt_comment} = '!-- ';
$HTML{fax_opt_comment_close} = ' --';
}
$HTML{reg_domain} = $reg_domain;
if($reg_domain =~ /de$/ and $type eq 'billing') {
$HTML{contact_type} = 'Zone';
} else {
$HTML{contact_type} = $contact_types{$type};
}
$HTML{type} = $type;
$HTML{CGI} = $cgi;
#XXX
if ($reg_domain =~ /eu$/){
if ($type eq 'owner') {
$HTML{COUNTRY_LIST} = build_eu_countries_list($HTML{country});
} elsif($type eq 'tech'){
$HTML{COUNTRY_LIST} = locale_build_country_list($HTML{country});
}
$HTML{LANGUAGE_LIST} = build_eu_languages_list($HTML{lang});
} else {
$HTML{COUNTRY_LIST} = locale_build_country_list($HTML{country});
}
if ($reg_domain =~ /be$/){
$HTML{LANGUAGE_LIST} = build_be_languages_list($HTML{lang});
}
my $template="modify_contact.html";
if ($reg_domain =~ /ca$/) {
$template="modify_contact_ca.html";
$HTML{GLOBAL_CHANGE_MENU} =
make_global_menu($reg_f_owner,$reg_permission,$type)."
Only .ca will be affected
\n";
} elsif ($reg_domain =~ /(be|eu)$/i){
$template="modify_contact_beu.html";
$HTML{GLOBAL_CHANGE_MENU} =
make_beu_global_menu($reg_domain,$reg_f_owner,$reg_permission,$type);
} else {
$HTML{GLOBAL_CHANGE_MENU} =
make_global_menu($reg_f_owner,$reg_permission,$type);
}
if ($type eq 'owner' and
$response->{attributes}->{contact_set}->{'owner'}->{ownership_changes_request}){
my $shortcut=$response->{attributes}->{contact_set}->{'owner'}->{ownership_changes_request};
$HTML{revoke_registrant_changes}=< The new registrant name will be '$shortcut'
Click Here if you want to revoke this request.
EOF
}
print_form("$path_templates/$template",\%HTML);
}
sub do_modify_org_contact_de {
my $descr = $in{descr};
my $orig_descr = $in{orig_descr};
my $affect_domains = $in{affect_domains};
if(($descr eq $orig_descr) and !$affect_domains ) {
return undef;
}
my $xcp_request = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "descr",
affect_domains => $affect_domains,
domainname => $reg_domain,
contact_set => {
owner => {descr => $descr },
},
}
};
return $xcp_request;
}
# process data to modify contact info
sub do_modify_contact {
my ($key, $error, $type);
my $resultString;
if ($in{submit} =~ /cancel/i) {
main_menu("Changes cancelled");
exit;
}
$type = $in{type};
delete $in{type};
my $xcp_request;
$xcp_request = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "contact_info",
affect_domains => $in{affect_domains},
report_email => $in{report_email},
contact_set => {
$type => {},
also_apply_to => [],
},
}
};
foreach $key ( keys %in ) {
next unless exists $contact_keys{$key};
$xcp_request->{attributes}->{contact_set}->{$type}->{$key} = $in{$key};
}
if ($reg_domain =~ /ca$/) {
foreach $key (@CA_EXTRA_FIELDS) {
$xcp_request->{attributes}->{contact_set}->{$type}->{$key} = $in{$key} if defined $in{$key};
}
}
# basic error checking on request vs user permissions
my $affect_domains = $in{affect_domains};
foreach $key (keys %contact_types) {
if ($in{"affect_$key"}) {
if ((not $reg_f_owner) and (not $reg_permission & $PERMISSIONS{"F_MODIFY_$key"})) {
error_out("No permission to modify contact type: $contact_types{$key}.
\n");
exit;
}
push @{$xcp_request->{attributes}->{contact_set}->{also_apply_to}}, $key;
}
}
if ($affect_domains and (not $reg_f_owner)) {
error_out("Only the domain owner can apply changes to multiple domains.
\n");
exit;
}
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
# only go into the total failure page if there
# are not any details, because OpenSRS
# will return not is_success if none
# of the contacts were succesfully modified
# for reasons particular to each domain applied to.
if ( not keys %{$response->{attributes}{details}} ) {
$error .= "Failed attempt: $response->{response_text}.
\n";
if ($response->{attributes}{error}) {
$response->{attributes}{error} =~ s/\n/
\n/g;
$error .= $response->{attributes}{error};
}
error_out($error);
exit;
}
}
# response_code of 250 indicates that an asynchronous registry has
# received the request and the modification completion will
# occur later.
if ( $response->{response_code} == 250 )
{
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
main_menu($resultString."Contact modification submitted, could take up to ".time_to_wait().".");
}
else
{
my $domainResult;
if ( exists $response->{attributes} && keys %{$response->{attributes}->{details}} ) {
$resultString .= $response->{attributes}->{response_text};
$resultString .= "
";
my $tempDetailHash;
foreach $domainResult ( keys %{$response->{attributes}->{details}} ) {
$tempDetailHash = $response->{attributes}->{details}->{$domainResult};
if ( $tempDetailHash->{response_text} =~
/Update of licensee company name is not allowed/){
$tempDetailHash->{response_text} .= "Please contact your service provider to make this change.";
}
$resultString = sprintf( '%s%s : %s
',
$resultString,
$domainResult,
$tempDetailHash->{response_text} );
if ( $domainResult eq $reg_domain && exists $tempDetailHash->{waiting_requests_no}) {
$waiting_requests_no = $tempDetailHash->{waiting_requests_no};
}
}
} else {
$resultString .= $response->{response_text};
}
main_menu($resultString);
}
}
# show domain tld-specific info
sub modify_domain_extras {
my ($error);
my $rsp_auth_info;
if ($capabilities->{domain_auth_info}) {
my $xcp_auth_info = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "domain_auth_info",
}
};
$rsp_auth_info = $XML_Client->send_cmd( $xcp_auth_info );
if (not $rsp_auth_info->{is_success}) {
$error = "Failed attempt: $rsp_auth_info->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_auth_info );
}
my $rsp_forwarding_email;
if ($capabilities->{forwarding_email}) {
my $xcp_forwarding_email = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "forwarding_email",
}
};
$rsp_forwarding_email = $XML_Client->send_cmd( $xcp_forwarding_email );
if (not $rsp_forwarding_email->{is_success}) {
$error = "Failed attempt: $rsp_forwarding_email->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_forwarding_email );
}
my $rsp_nexus_info;
if ($capabilities->{nexus_info}) {
my $xcp_nexus_info = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "nexus_info",
}
};
$rsp_nexus_info = $XML_Client->send_cmd( $xcp_nexus_info );
if (not $rsp_nexus_info->{is_success}) {
$error = "Failed attempt: $rsp_nexus_info->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_nexus_info );
}
my $rsp_ced_info;
if ($capabilities->{ced_info}) {
my $xcp_ced_info = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "ced_info",
}
};
$rsp_ced_info = $XML_Client->send_cmd( $xcp_ced_info );
if (not $rsp_ced_info->{is_success}) {
$error = "Failed attempt: $rsp_ced_info->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_ced_info );
}
my $rsp_trademark;
if ($capabilities->{trademark}) {
my $xcp_trademark = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "trademark",
}
};
$rsp_trademark = $XML_Client->send_cmd( $xcp_trademark );
if (not $rsp_trademark->{is_success}) {
$error = "Failed attempt: $rsp_trademark->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_trademark );
}
my $rsp_uk_whois_opt;
if ($capabilities->{uk_whois_opt}) {
my $xcp_uk_whois_opt = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "uk_whois_opt",
}
};
$rsp_uk_whois_opt = $XML_Client->send_cmd( $xcp_uk_whois_opt );
if (not $rsp_uk_whois_opt->{is_success}) {
$error = "Failed attempt: $rsp_uk_whois_opt->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_uk_whois_opt );
}
my $rsp_whois_privacy;
if ($capabilities->{whois_privacy_state}) {
my $xcp_whois_privacy = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "whois_privacy_state",
}
};
$rsp_whois_privacy = $XML_Client->send_cmd( $xcp_whois_privacy );
if (not $rsp_whois_privacy->{is_success}) {
$error = "Failed attempt: $rsp_whois_privacy->{response_text}
\n";
error_out($error);
exit;
}
escape_hash_values( $rsp_whois_privacy );
}
my %HTML = ();
$HTML{domain_auth_info} = $rsp_auth_info->{attributes}->{domain_auth_info} if ($rsp_auth_info);
$HTML{forwarding_email} = $rsp_forwarding_email->{attributes}->{forwarding_email} if ($rsp_forwarding_email);
if ($rsp_nexus_info) {
$HTML{old_app_purpose} = $rsp_nexus_info->{attributes}->{nexus}->{app_purpose};
$HTML{old_nexus_category} = $rsp_nexus_info->{attributes}->{nexus}->{category};
$HTML{old_nexus_validator} = $rsp_nexus_info->{attributes}->{nexus}->{validator};
$HTML{old_app_purpose} =~ tr/a-z/A-Z/;
$HTML{old_nexus_category} =~ tr/a-z/A-Z/;
$HTML{old_nexus_validator} =~ tr/a-z/A-Z/;
$HTML{"category_" . $HTML{old_nexus_category}} = "checked";
}
if ($rsp_ced_info) {
$HTML{old_contact_type} = $rsp_ced_info->{attributes}->{ced_info}->{contact_type};
$HTML{old_locality_country} = $rsp_ced_info->{attributes}->{ced_info}->{locality_country};
$HTML{old_locality_city} = $rsp_ced_info->{attributes}->{ced_info}->{locality_city};
$HTML{old_locality_state_prov} = $rsp_ced_info->{attributes}->{ced_info}->{locality_state_prov};
$HTML{old_legal_entity_type} = $rsp_ced_info->{attributes}->{ced_info}->{legal_entity_type};
$HTML{old_legal_entity_type_info} = $rsp_ced_info->{attributes}->{ced_info}->{legal_entity_type_info};
$HTML{old_id_type} = $rsp_ced_info->{attributes}->{ced_info}->{id_type};
$HTML{old_id_type_info} = $rsp_ced_info->{attributes}->{ced_info}->{id_type_info};
$HTML{old_id_number} = $rsp_ced_info->{attributes}->{ced_info}->{id_number};
}
if ($HTML{forwarding_email}) {
$HTML{text_comment} = '!-- ';
$HTML{text_comment_close} = ' --';
} else {
$HTML{email_comment} = '!-- ';
$HTML{email_comment_close} = ' --';
}
$HTML{CGI} = $cgi;
# include domain auth code form in the main html page if domain auth code is avaliable
if ($rsp_auth_info) {
$HTML{domain_auth_code_form} = get_content("$path_templates/domain_auth_code_form.html", \%HTML);
}
# include forwarding email form in the main html page if it is capable for forwarding email modification
if ($rsp_forwarding_email) {
$HTML{forwarding_email_form} = get_content("$path_templates/forwarding_email_form.html", \%HTML);
}
# include trademark form in the main html page if it is capable for trademark modification
if ($rsp_trademark) {
if ( $rsp_trademark->{attributes}->{trademark} eq "Y" ) {
$HTML{trademark_enabled}='checked';
$HTML{trademark_disabled}='';
} else {
$HTML{trademark_enabled}='';
$HTML{trademark_disabled}='checked';
}
$HTML{trademark} = $rsp_trademark->{attributes}->{trademark};
$HTML{trademark_form} = get_content("$path_templates/trademark_form.html", \%HTML);
}
if ($reg_domain =~ /\.uk$/){
if ( $capabilities->{change_ips_tag} ) {
$HTML{change_ips_tag_form} = get_content("$path_templates/change_ips_tag.html", \%HTML);
} else {
$HTML{change_ips_tag_form} = get_content("$path_templates/cant_change_ips_tag.html", \%HTML);
}
}
# include uk whois opt out from in the main html page if it is capable for Nominet whois opt out modification
if ($rsp_uk_whois_opt) {
$HTML{old_uk_whois_opt} = $rsp_uk_whois_opt->{attributes}->{uk_whois_opt};
# flip the value as the question is 'Display whois info?', so 'Y' means
# no, I don't want to opt out.
$HTML{old_uk_whois_opt} = $HTML{old_uk_whois_opt} eq 'Y' ? 'N' : 'Y';
$HTML{uk_reg_type_ind} = $rsp_uk_whois_opt->{attributes}->{reg_type} eq 'IND' ? 'checked' : '';
$HTML{uk_reg_type_find} = $rsp_uk_whois_opt->{attributes}->{reg_type} eq 'FIND' ? 'checked' : '';
if ( $HTML{uk_reg_type_ind} ne 'checked' && $HTML{uk_reg_type_find} ne 'checked') {
$HTML{uk_reg_type_other} = 'checked';
} else {
$HTML{uk_reg_type_other} = '';
}
if ( $HTML{old_uk_whois_opt} eq "Y" ) {
$HTML{uk_whois_opt_enabled}='checked';
$HTML{uk_whois_opt_disabled}='';
} else {
$HTML{uk_whois_opt_enabled}='';
$HTML{uk_whois_opt_disabled}='checked';
}
$HTML{uk_whois_opt_form} = get_content("$path_templates/uk_whois_opt_form.html", \%HTML);
}
# include nexus data form in the main html page if it is capable for .us nexus data modification
if ($rsp_nexus_info) {
$HTML{app_purpose_menu} = build_app_purpose_list($HTML{old_app_purpose});
$HTML{citizen_country_list} = locale_build_country_list($HTML{old_nexus_validator}?$HTML{old_nexus_validator}:'--');
$HTML{us_nexus_form} = get_content("$path_templates/us_nexus_form.html", \%HTML);
}
# include ced data form in the main html page if it is capable for .asia ced data modification
if ($rsp_ced_info) {
$HTML{contact_type_menu} = build_ced_contact_type_select_list($HTML{old_contact_type});
$HTML{locality_country_menu} = build_ced_locality_select_list($HTML{old_locality_country});
$HTML{legal_entity_type_menu} = build_ced_entity_type_select_list($HTML{old_legal_entity_type});
$HTML{id_type_menu} = build_ced_identification_type_select_list($HTML{old_id_type});
$HTML{asia_ced_form} = get_content("$path_templates/asia_ced_form.html", \%HTML);
}
# include domain whois_privacy form in the main html page if domain whois_privacy state is enabled or disabled
if ($rsp_whois_privacy->{attributes}->{changeable}) {
$HTML{whois_privacy_state} = $rsp_whois_privacy->{attributes}->{state} if ($rsp_whois_privacy);
$HTML{old_whois_privacy_state} = $HTML{whois_privacy_state} eq 'disabled' ? 'N' : 'Y';
if ($HTML{whois_privacy_state} eq "enabled" ) {
$HTML{wp_state_cur} = 'Enabled';
$HTML{wp_state_change_to} = 'Disable';
$HTML{whois_privacy_radio_button}='
';
} else {
$HTML{wp_state_cur} = 'Disabled';
$HTML{wp_state_change_to} = 'Enable';
$HTML{whois_privacy_radio_button}='';
}
$HTML{whois_privacy_changes_menu} =
make_whois_privacy_changes_menu();
$HTML{whois_privacy_form} = get_content("$path_templates/whois_privacy_form.html", \%HTML);
}
if($dns_errors) {
$HTML{full_dns_error} = $dns_errors;
$HTML{dns_error_form} = get_content("$path_templates/dns_error_form.html", \%HTML);
}
if ( $capabilities->{cira_email_pwd} and $MANAGE{enable_cira_email_pwd} ) {
$HTML{cira_email_pwd} = get_content("$path_templates/cira_email_pwd.html", \%HTML);
}
my $template="modify_domain_extras.html";
print_form("$path_templates/$template",\%HTML);
}
# process data to modify domain extras
sub do_modify_domain_extras {
my ($ok_flag, $do_flag, $resultString);
if ($in{submit} =~ /cancel/i) {
main_menu("Changes cancelled");
exit;
}
if ($in{domain_auth_info} && $in{domain_auth_info} ne $in{old_domain_auth}) {
$do_flag = 1;
my $xcp_auth_info = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "domain_auth_info",
domain_auth_info => $in{domain_auth_info},
}
};
my $rsp_auth_info = $XML_Client->send_cmd( $xcp_auth_info );
if (not $rsp_auth_info->{is_success}) {
$resultString .= "Failed to modify domain auth code for $reg_domain : $rsp_auth_info->{response_text}
";
} else {
$resultString .= "Domain auth code modification successful for $reg_domain
";
$ok_flag = 1;
}
}
if ($in{trademark} && $in{trademark} ne $in{old_trademark}) {
$do_flag = 1;
my $xcp_trademark = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "trademark",
trademark => $in{trademark},
}
};
my $rsp_trademark = $XML_Client->send_cmd( $xcp_trademark );
if (not $rsp_trademark->{is_success}) {
$resultString .= "Failed to modify domain trademark for $reg_domain : $rsp_trademark->{response_text}
";
} else {
$resultString .= "Domain trademark modification successful for $reg_domain
";
$ok_flag = 1;
}
}
# do modification for whois_privacy state
if ($in{whois_privacy} && $in{whois_privacy} ne $in{old_whois_privacy}) {
$do_flag = 1;
my $xcp_whois_privacy = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "whois_privacy_state",
state => $in{whois_privacy},
affect_domains => $in{wp_affect_domains},
report_email => $in{report_email},
}
};
my $rsp_whois_privacy = $XML_Client->send_cmd( $xcp_whois_privacy );
if (not $rsp_whois_privacy->{is_success}) {
$resultString .= "Failed to modify domain whois_privacy state for $reg_domain : $rsp_whois_privacy->{_response_text}
";
} else {
if($in{wp_affect_domains}){
$resultString .= $rsp_whois_privacy->{response_text};
}else{
$resultString .= "Domain Whois Privacy state modification successful for $reg_domain.
";
#$resultString .= $rsp_whois_privacy->{_response_text} ." for " . $reg_domain . "
";
}
$ok_flag = 1;
}
}
if ( $in{new_ips_tag} ) {
my $xcp_change_ips_tag = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "change_ips_tag",
gaining_registrar_tag => $in{new_ips_tag},
domain => $reg_domain,
change_tag_all => $in{uk_change_tag_all},
}
};
my $rsp_change_ips_tag = $XML_Client->send_cmd( $xcp_change_ips_tag );
if ( ! $rsp_change_ips_tag->{is_success} ){
$resultString .= "Failed to modify ips_tag for $reg_domain : $rsp_change_ips_tag->{response_text}.
";
} else {
if ( $in{uk_change_tag_all} ) {
$resultString .= "Domain Domain Tag modification successfully submitted for all domains.
";
} else {
$resultString .= "Failed to modify ips_tag for $reg_domain : " if $rsp_change_ips_tag->{error};
$resultString .= $reg_domain . ": " . $rsp_change_ips_tag->{response_text} . "
";
}
}
}
if ($in{uk_whois_opt} && $in{uk_whois_opt} ne $in{old_uk_whois_opt}) {
$do_flag = 1;
# the question is: Display personal info in whois? So answer 'no' means
# yes, I want to opt out.
$in{uk_whois_opt} = $in{uk_whois_opt} eq 'Y' ? 'N' : 'Y';
my $xcp_uk_whois_opt = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "uk_whois_opt",
uk_whois_opt => $in{uk_whois_opt},
reg_type => $in{reg_type},
uk_affect_domains => $in{uk_affect_domains},
}
};
my $rsp_uk_whois_opt = $XML_Client->send_cmd( $xcp_uk_whois_opt );
if (not $rsp_uk_whois_opt->{is_success}) {
$resultString .= "Failed to submit modifications to Nominet whois settings for $reg_domain : $rsp_uk_whois_opt->{response_text}
";
} else {
$resultString .= "Nominet whois settings modification successfully submitted for $reg_domain
";
$ok_flag = 1;
}
}
if ($in{forwarding_email} && $in{forwarding_email} ne $in{old_forwarding_email}) {
$do_flag = 1;
my $xcp_forwarding_email = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "forwarding_email",
forwarding_email => $in{forwarding_email},
}
};
my $rsp_forwarding_email = $XML_Client->send_cmd( $xcp_forwarding_email );
if (not $rsp_forwarding_email->{is_success}) {
$resultString .= "Failed to modify forwarding email for $reg_domain : $rsp_forwarding_email->{response_text}
";
} elsif ($rsp_forwarding_email->{response_code} == 250) {
$resultString .= "Forwarding email modification successfully submitted, could take up to ".time_to_wait().".
";
$ok_flag = 1;
} else {
$resultString .= "Forwarding email modification successful for $reg_domain
";
$ok_flag = 1;
}
}
if ($capabilities->{nexus_info}) {
my $xcp_nexus_info = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "nexus_info",
nexus => {
app_purpose => $in{app_purpose},
category => $in{nexus_category},
}
}
};
my $mod_flag = 0;
$mod_flag =1 if ($in{app_purpose} ne $in{old_app_purpose});
$mod_flag =1 if ($in{nexus_category} ne $in{old_nexus_category});
if ($in{nexus_category} =~ /^C3/) {
$xcp_nexus_info->{attributes}->{nexus}->{validator} = $in{nexus_validator};
$mod_flag =1 if ($in{nexus_validator} ne $in{old_nexus_validator});
}
if ($mod_flag) {
$do_flag = 1;
my $rsp_nexus_info = $XML_Client->send_cmd( $xcp_nexus_info );
if (not $rsp_nexus_info->{is_success}) {
$resultString .= "Failed to modify nexus info for $reg_domain : $rsp_nexus_info->{response_text}
";
} else {
$resultString .= "Nexus info modification successful for $reg_domain
";
$ok_flag = 1;
}
}
}
if ($capabilities->{ced_info}) {
my $xcp_ced_info = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "ced_info",
ced_info => {
contact_type => $in{contact_type},
locality_country => $in{locality_country},
locality_city => $in{locality_city},
locality_state_prov => $in{locality_state_prov},
legal_entity_type => $in{legal_entity_type},
legal_entity_type_info => $in{legal_entity_type_info},
id_type => $in{id_type},
id_type_info => $in{id_type_info},
id_number => $in{id_number},
}
}
};
my $mod_flag = 0;
$mod_flag =1 if ($in{contact_type} ne $in{old_contact_type});
$mod_flag =1 if ($in{locality_country} ne $in{old_locality_country});
$mod_flag =1 if ($in{locality_city} ne $in{old_locality_city});
$mod_flag =1 if ($in{locality_state_prov} ne $in{old_locality_state_prov});
$mod_flag =1 if ($in{legal_entity_type} ne $in{old_legal_entity_type});
$mod_flag =1 if ($in{legal_entity_type_info} ne $in{old_legal_entity_type_info});
$mod_flag =1 if ($in{id_type} ne $in{old_id_type});
$mod_flag =1 if ($in{id_type_info} ne $in{old_id_type_info});
$mod_flag =1 if ($in{id_number} ne $in{old_id_number});
if ($mod_flag) {
$do_flag = 1;
my $rsp_ced_info = $XML_Client->send_cmd( $xcp_ced_info );
if (not $rsp_ced_info->{is_success}) {
$resultString .= "Failed to modify CED contact info for $reg_domain : $rsp_ced_info->{response_text}
";
} else {
$resultString .= "CED contact info modification successful for $reg_domain
";
$ok_flag = 1;
}
}
}
if($in{flag_do_validate_domain} and $dns_errors) {
$do_flag = 1;
my $validate_command = {
action => "activate",
object => "domain",
cookie => $cookie,
attributes => {
domainname => $reg_domain,
}
};
my $val_res = $XML_Client->send_cmd($validate_command);
if (not $val_res->{is_success}) {
$resultString .= "Failed to submit domain validation for $reg_domain : $val_res->{response_code} $val_res->{response_text}
";
} else {
$resultString .= "Domain validation successfully submitted to registry. Please review your changes in 15" .
"minutes to verify that they were accepted.
";
$ok_flag = 1;
}
}
if( $in{cira_email_pwd} and $MANAGE{enable_cira_email_pwd} ) {
$do_flag = 1;
my $xcp_cira_email_pwd = {
action => "cira_email_pwd",
object => "domain",
attributes => {
domain => $reg_domain,
}
};
my $cira_email_pwd = $XML_Client->send_cmd( $xcp_cira_email_pwd );
if (not $cira_email_pwd->{is_success}) {
$resultString .= "Failed attempt: $cira_email_pwd->{response_text}
";
} else {
$resultString .= "CIRA password sent to admin contact.
You can check email address in domain notes.
";
$ok_flag = 1;
}
}
if (not $do_flag) {
main_menu("Domain Extras Data modification successful
");
} elsif ($ok_flag == 1) {
main_menu($resultString);
} else {
error_out($resultString);
}
}
sub do_change_ips_tag {
my $resultString;
$in{new_ips_tag} =~ s/^\s+//;
$in{new_ips_tag} =~ s/\s+$//;
if ( $in{new_ips_tag} ) {
my $xcp_change_ips_tag = {
action => "modify",
object => "domain",
cookie => $cookie,
attributes => {
data => "change_ips_tag",
gaining_registrar_tag => $in{new_ips_tag},
domain => $reg_domain,
change_tag_all => $in{uk_change_tag_all},
}
};
my $rsp_change_ips_tag = $XML_Client->send_cmd( $xcp_change_ips_tag );
if ( ! $rsp_change_ips_tag->{is_success} ){
$resultString .= "Failed to modify ips_tag for $reg_domain : $rsp_change_ips_tag->{response_text}.
";
} else {
if ( $in{uk_change_tag_all} ) {
$resultString .= "Domain Domain Tag modification successfully submitted for all domains.
";
} else {
$resultString .= "Failed to modify ips_tag for $reg_domain : " if $rsp_change_ips_tag->{error};
$resultString .= $rsp_change_ips_tag->{response_text} . "
";
}
}
}
main_menu($resultString);
}
# display domains a user owns
sub view_domains {
my (%HTML,$domain_name,$domain_html,$next_page,$previous_page);
my $page = $in{ page };
if ( not $page ) { $page = 0 }
my $order_by = $in{ orderby };
if ( not $order_by ) { $order_by = 'name' }
my $limit = $in{ limit };
if( not $limit ) { $limit = 40 }
$in{ sort_by } = 'DESC'
if not $in{ sort_by } or $in{ sort_by } !~ /^(ASC|DESC)$/;
my $sort = $in{sort_by};
my $domain = lc $in{domain};
$domain = trim($domain);
my $domain_search = $in{domain_search};
$domain_search = trim($domain_search);
if ( not $domain_search ) {
$domain_search = '*';
}
# get domains for a given user
my $xcp_request = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
page => $page,
type => "list",
with_encoding_types => 1,
domain => $domain,
domain_search => $domain_search,
expiry_date => $in{ expiry_date },
auto_renew => $in{ auto_renew },
order_by => $order_by,
sort_by => $sort,
limit => $in{ limit },
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Failed attempt: $response->{response_text}\n");
exit;
}
my $remainder = $response->{attributes}->{remainder}; # are there more domains to show?
my @test_array = @{ $response->{ attributes }{ ext_results } };
my %domains = map { %{ $_ } } @{ $response->{ attributes }{ ext_results } };
foreach my $domain ( keys %domains ) {
$domains{ $domain }{ NATIVE } = $domain;
$domains{ $domain }{ auto_renew } = $domains{ $domain }{ auto_renew } ? "Y" : "N";
$domains{ $domain }{ expiredate } =~ s/\s.*//; # get rid of the time
$domains{ $domain }{ wp_service } = $domains{ $domain }{ wp_service } eq 'enabled' ? "Y" : "N";
$domains{ $domain }{ wp_expiredate } = $domains{ $domain }{ wp_expiredate } ? $domains{ $domain }{ wp_expiredate } : "N";
}
foreach my $test ( @test_array ){
foreach my $domain ( keys %$test ){
my $domain_link;
if ( $reg_domain eq $domain ) {
$domain_link = $domains{ $domain }{ NATIVE };
} else {
$domain_link = qq($domains{$domain}{NATIVE});
}
$domain_html .= <
$domain_link
$domains{ $domain }{ expiredate }
EOROW
if ( $MANAGE{ show_auto_renew } ) {
$domain_html .= <$domains{ $domain }{ auto_renew }
EOROW
}
$domain_html .= <$domains{ $domain }{ wp_service }
$domains{ $domain }{ wp_expiredate }
EOROW
}
}
my $num_page_links = 10;
$HTML{page} = $page;
my $navbar = make_navbar(
"view_domains&limit=$in{limit}&domain_search=$in{domain_search}&domain=$in{domain}&expiry_date=$in{expiry_date}&auto_renew=$in{auto_renew}&orderby=$order_by&sort_by=$sort", $response->{ attributes }{ count }, $limit, $num_page_links, $HTML{page}
);
$navbar .= "
\n";
my $new_sort = $sort eq 'ASC' ? 'DESC' : 'ASC';
if ( $MANAGE{ show_auto_renew } ) {
$HTML{header} = <Auto Renew
EOF
} else {
$HTML{header} = " ";
}
$HTML{DOMAIN_COUNT} = $response->{ attributes }{ count };
$HTML{DOMAINS} = $domain_html;
$HTML{domain} = $in{domain};
$HTML{domain_search} = $in{domain_search};
$HTML{page} = $page;
$HTML{limit} = $limit;
$HTML{auto_renew} = $in{auto_renew};
$HTML{cgi} = $cgi;
$HTML{NAVBAR} = $navbar;
$HTML{expiry_date} = $in{expiry_date};
$HTML{new_sort} = $new_sort;
print_form("$path_templates/view_domains.html",\%HTML);
}
# switches authentication to specified domain (updates cookie)
sub manage_domain {
my $domain = lc $in{domain};
$domain =~ s/(^\s+)|(\s+$)//g;
my ($tld) = $domain =~ /$OPENSRS{OPENSRS_TLDS_REGEX}$/;
if ( exists $CANT_SUPPORT{$tld} )
{
my $message = <
interface. We will have a $tld enabled Manage Domain interface in place as
soon as possible.
If need to make emergency nameserver changes to your domain, please contact
support\@opensrs.org.
EOF
error_out($message);
exit;
}
my $xcp_request = {
action => "update",
object => "cookie",
cookie => $cookie,
attributes => {
reg_username => $reg_username,
reg_password => $reg_password,
domain => $reg_domain,
domain_new => $domain,
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Failed attempt: $response->{response_text}\n");
exit;
}
$reg_domain = $domain;
$reg_f_owner = $response->{attributes}->{f_owner};
$reg_permission = $response->{attributes}->{permission};
$domain_count = $response->{attributes}->{domain_count};
$expiredate = $response->{attributes}->{expiredate};
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
validate();
my $mm_str = "Now managing $domain.";
$mm_str .= "[IDN]"
if $domain =~ /^xn--/;
main_menu($mm_str);
}
sub make_de_org_change_menu {
my ($type,$html);
my ($reg_domain,$f_owner,$permission,$current_type) = @_;
my ($tld) = $reg_domain =~ /$OPENSRS{OPENSRS_TLDS_REGEX}$/;
my $table_start = <
Also Apply these changes to:
YES
NO
EOF
my $need_report_email = 0;
if ($reg_f_owner && ($domain_count > 1)) {
$need_report_email = 1;
$html .= <
All UNLOCKED Domains ($domain_count)
EOF
}
my $table_end = "\n";
my ($menu);
if ($html) {
$menu = <
If you are modifying all the domains in the profile and you would like a status
report sent to you, please enter a valid email address in the field provided.
Report Email
Only $tld will be affected
EOF
}
return $menu;
} else {
return "";
}
}
#generate menu for applying whois_privacy changes to all domains in the profile
sub make_whois_privacy_changes_menu {
my ($type,$html);
my $table_start = <
Also Apply these changes to:
YES
NO
EOF
my $need_report_email = 0;
if ($reg_f_owner && ($domain_count > 1)) {
$need_report_email = 1;
$html .= <
All UNLOCKED Domains ($domain_count)
EOF
}
my $table_end = "\n";
my ($menu);
if ($html) {
$menu = <
If you are modifying all the domains in the profile and you would like a status
report sent to you, please enter a valid email address in the field provided.
Report Email
EOF
}
return $menu;
} else {
return "";
}
}
sub make_beu_global_menu {
my ($type,$html);
my ($reg_domain,$f_owner,$permission,$current_type) = @_;
my ($tld) = $reg_domain =~ /$OPENSRS{OPENSRS_TLDS_REGEX}$/;
my $table_start = <
Also Apply these changes to:
YES
NO
EOF
my $need_report_email = 0;
if ($reg_f_owner && ($domain_count > 1)) {
$need_report_email = 1;
$html .= <
All UNLOCKED Domains ($domain_count)
EOF
}
my $table_end = "\n";
my ($menu);
if ($html) {
$menu = <
If you are modifying all the domains in the profile and you would like a status
report sent to you, please enter a valid email address in the field provided.
Report Email
Only $tld will be affected
EOF
}
return $menu;
} else {
return "";
}
}
# generaste menu for applying contact changes to other types/domains
sub make_global_menu {
my ($type,$html);
my ($f_owner,$permission,$current_type) = @_;
my $table_start = <
Also Apply these changes to:
YES
NO
EOF
if($reg_domain =~ /de$/) {
$contact_types{billing} = "Zone";
} else {
$contact_types{billing} = "Billing";
}
foreach $type (qw/owner admin billing tech/) {
next unless exists $contact_types{$type};
if ((($type =~ /owner/i ) && ( $reg_domain =~ /ca$/ )) ||
(($type =~ /billing/i ) && ( $reg_domain =~ /ca$/ )) ||
(($type =~ /tech/i ) && ($reg_domain =~ /uk$/) ))
{
next;
}
if (($f_owner or $permission & $PERMISSIONS{"F_MODIFY_$type"}) and ($type ne $current_type)) {
$html .= <
$contact_types{$type} Contact
EOF
}
}
#
# We can't normalize the data with .ca domains so we don't allow
# for universal changes with .ca domains.
#
# If it is in the organization contact page and if it is .uk domains,
# we do not allow for universal changes with .uk domains right now.
#
my $need_report_email = 0;
if ($reg_f_owner && ($domain_count > 1)) {
$need_report_email = 1;
$html .= <
All UNLOCKED Domains ($domain_count)
EOF
}
my $table_end = "\n";
my ($menu);
if ($html) {
$menu = <
If you are modifying all the domains in the profile and you would like a status
report sent to you, please enter a valid email address in the field provided.
Report Email
EOF
}
return $menu;
} else {
return "";
}
}
sub manage_nameservers {
my (%HTML,$ns,$key,$fqdn,$ip,$delete,$message);
if (@_) {
$message = shift;
}
# retrieve nameserver info
my $xcp_request = {
action => "get",
object => "nameserver",
cookie => $cookie,
attributes => {
type => "all",
},
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Unable to retrieve nameservers: $response->{response_text}\n");
exit;
}
foreach $key ( @{$response->{attributes}->{nameserver_list}} ) {
$fqdn = $key->{name};
$ip = $key->{ipaddress};
if ( $key->{can_delete} ) {
$delete = <
EOF
} else {
$delete = "";
}
$HTML{nameservers} .= <
EOF
}
$HTML{DOMAIN_NAME} = $reg_domain;
$HTML{CGI} = $cgi;
$HTML{MESSAGE} = $message ? "$message
" : "";
print_form("$path_templates/manage_nameservers.html",\%HTML);
}
# change ip address for a given nameserver
sub do_manage_nameserver {
my $fqdn = $in{fqdn};
my $new_fqdn = $in{new_fqdn};
my $ip = $in{ip};
my $xcp_request = {
action => "",
object => "nameserver",
cookie => $cookie,
attributes => {
name => $fqdn,
ipaddress => $ip,
}
};
if ($in{submit} =~ /delete/i) {
$xcp_request->{action} = "delete";
my $need_lock = manage_ns_locked_domain('unlock');
my $response = $XML_Client->send_cmd( $xcp_request );
manage_ns_locked_domain('lock') if $need_lock;
if (not $response->{is_success}) {
my $error = "Unable to delete nameserver: $response->{response_text}";
# check to see why nameservers can't be modified. If because
# domain is locked, return a message to that affect.
if ( get_domain_lock_status() && !$MANAGE{ allow_ns_change_locked_domain } ) {
$error = "This domain is currently locked. The lock must be removed to allow nameservers to be modified."
}
error_out( $error );
exit;
}
# response_code of 250 indicates that an asynchronous registry has
# received the request and the completion of the request will
# occur later.
if ( $response->{response_code} == 250 ) {
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
manage_nameservers("Nameserver deletion submitted, could take up to ".time_to_wait().".");
} else {
manage_nameservers("Nameserver $new_fqdn deleted");
}
} else {
# only pass the new_fqdn param if it is changing
if ( $fqdn ne $new_fqdn ) {
$xcp_request->{attributes}->{new_name} = $new_fqdn;
}
$xcp_request->{action} = "modify";
my $need_lock = manage_ns_locked_domain('unlock');
my $response = $XML_Client->send_cmd( $xcp_request );
manage_ns_locked_domain('lock') if $need_lock;
if (not $response->{is_success}) {
my $error = "Unable to modify nameserver: $response->{response_text}";
# if reason can't add is because domain is locked, return message
# to that affect.
if ( get_domain_lock_status() && !$MANAGE{ allow_ns_change_locked_domain } ) {
$error = "This domain is currently locked. The lock must be removed to allow nameservers to be modified.";
}
error_out( $error );
exit;
}
# response_code of 250 indicates that an asynchronous registry has
# received the request and the completion of the request will
# occur later.
if ( $response->{response_code} == 250 )
{
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
if ( $fqdn ne $new_fqdn ) {
manage_nameservers("Nameserver rename modification submitted, could take up to ".time_to_wait().".");
} else {
manage_nameservers("Nameserver modification submitted to registry for processing. " .
"Please review your changes in 15 minutes to verify that they were accepted.");
}
}
else
{
if ($fqdn ne $new_fqdn ) {
manage_nameservers("Nameserver $fqdn renamed to $new_fqdn");
} else {
manage_nameservers("Nameserver $fqdn successfully modified");
}
}
}
}
# display nameserver information for the current domain
sub modify_nameservers {
my (%fqdns,$fqdn,$ip,$key,$num,$ns_html,%HTML,$title,$add_ns);
my $message = shift;
# retrieve nameserver info
my $xcp_request = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => 'nameservers',
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Unable to retrieve nameserver information: $response->{response_text}\n");
exit;
}
$HTML{CGI} = $cgi;
foreach $key ( @{$response->{attributes}->{nameserver_list}} ) {
$fqdns{$key->{sortorder}} = 1;
}
my $count = 1;
my $total = 13;
foreach $key ( @{$response->{attributes}->{nameserver_list}} ) {
if ($count == 1) {
$title = "Primary";
} elsif ($count == 2) {
$title = "Secondary";
} else {
$title = "Nameserver $count";
}
$total--;
$fqdn = $key->{name};
$ip = $key->{ipaddress};
$ns_html .= <
$title:
EOF
$ns_html .= <$ip
EOF
$count++;
}
foreach (0..$total-1){
if ($count == 1) {
$title = "Primary";
} elsif ($count == 2) {
$title = "Secondary";
} else {
$title = "Nameserver $count";
}
$ns_html .= <
$title:
EOF
$ns_html .= < 
EOF
$count++;
}
# only show the option to create new nameservers for domain owners
if (($reg_f_owner) || ($reg_permission & $PERMISSIONS{f_modify_nameservers})) {
$HTML{CREATE_NAMESERVERS} = <
If you want to create or modify a nameserver which is based on $reg_domain click here.
EOF
}
$HTML{NAMESERVERS} = $ns_html;
$HTML{MESSAGE} = $message ? "$message" : "";
print_form("$path_templates/modify_nameservers.html",\%HTML);
}
# process data to modify nameservers for the current domain
sub do_modify_nameservers {
my ($sortorder,$key,%remove_ids,$ns_data,$response);
if ($in{submit} =~ /cancel/i) {
modify_nameservers("Changes cancelled\n");
exit;
}
my $xcp_request = {
action => "advanced_update_nameservers",
object => "domain",
cookie => $cookie,
attributes => {
op_type => 'assign',
assign_ns => [],
},
};
my @ns_key = ();
my %uniq = ();
foreach $key (keys %in) {
if ($key =~ /^fqdn(\d+)$/) {
push @ns_key => $key;
}
}
foreach $key (sort {$a cmp $b} @ns_key){
next unless $in{$key};
$in{$key} =~ s/\s+//g;
next unless $in{$key};
$in{$key} = lc $in{$key};
next if $uniq{$in{$key}}++;
push @{$xcp_request->{attributes}{assign_ns}} => $in{$key};
}
my $need_lock = manage_ns_locked_domain('unlock');
$response = $XML_Client->send_cmd( $xcp_request );
manage_ns_locked_domain('lock') if $need_lock;
if (not $response->{is_success}) {
my $error = "Unable to update nameservers: $response->{response_text}";
# check to see why nameservers can't be modified. If because
# domain is locked, return a message to that affect.
if ( get_domain_lock_status() && !$MANAGE{allow_ns_change_locked_domain} ) {
$error = "This domain is currently locked. The lock must be removed to make DNS changes.";
}
error_out( $error );
exit;
}
# response_code of 250 indicates that an asynchronous registry has
# received the request and the completion of the request will
# occur later.
if ( $response->{response_code} == 250 ) {
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
modify_nameservers("Nameservers update for $reg_domain successfully submitted, could take up to ".time_to_wait().".");
} elsif ( $response->{response_code} == 251 ) {
# removing a nameserver from a UK domain which is based upon that
# domain will cause any other domains using that nameserver to not
# function properly. In this case, send back a message to that affect.
# This applies at the moment to .uk nameservers, due to the way
# Nominet handles glue records.
modify_nameserver( $response->{ response_text } );
} else {
modify_nameservers("Nameservers modification for $reg_domain successfully submitted to registry.");
}
}
sub do_create_nameserver {
my $domain = $in{domain};
my $hostname = $in{hostname};
my $ip = $in{ip};
my $fqdn = "$hostname.$domain";
my $xcp_request = {
action => "create",
object => "nameserver",
cookie => $cookie,
attributes => {
name => $fqdn,
ipaddress => $ip,
},
};
my $need_lock = manage_ns_locked_domain('unlock');
my $response = $XML_Client->send_cmd( $xcp_request );
manage_ns_locked_domain('lock') if $need_lock;
if (not $response->{is_success}) {
my $error = "Unable to create nameserver: $response->{response_text}";
# check to see why nameservers can't be modified. If because
# domain is locked, return a message to that affect.
if ( get_domain_lock_status() && !$MANAGE{ allow_ns_change_locked_domain } ) {
$error = "This domain is currently locked. The lock must be removed to allow nameservers to be modified."
}
error_out( $error );
exit;
}
# response_code of 250 indicates that an asynchronous registry has
# received the request and the completion of the request will
# occur later.
#
# A response_code of 251 indicated that the nameserver has been created
# in the OSRS database, but will not be usable by other domains until it
# is attached to the parent domain.
if ( $response->{response_code} == 250 ) {
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
manage_nameservers("Name Server Creation successfully submitted, could take up to ".time_to_wait().".");
} elsif ( $response->{ response_code } == 251 ) {
manage_nameservers( $response->{ response_text } );
} else {
manage_nameservers("Name Server Created");
}
}
sub manage_profile {
my (%HTML);
# only allow the domain owner to access this routine
if (not $reg_f_owner) {
error_out("You do not have permission to access this feature.\n");
exit;
}
$HTML{CGI} = $cgi;
print_form("$path_templates/manage_profile.html",\%HTML);
}
sub change_ownership {
my (%HTML);
# only allow the domain owner to access this routine
if (not $reg_f_owner) {
error_out("You do not have permission to access this feature.\n");
exit;
}
$HTML{CGI} = $cgi;
print_form("$path_templates/change_ownership.html",\%HTML);
}
sub do_change_ownership {
# only allow the domain owner to access this routine
if (not $reg_f_owner) {
error_out("You do not have permission to access this feature.\n");
exit;
}
my $username = lc $in{reg_username};
my $password = $in{reg_password};
my $confirm_password = $in{confirm_password};
my $flag_use_profile = $in{flag_use_profile};
my $flag_move_all_domains = $in{flag_move_all_domains};
my $domain = $in{domain};
my ($xcp_request, $response);
if (not $username) {
error_out("Please provide a username.\n");
exit;
} elsif ($username !~ /^[a-z0-9]+$/) {
error_out("Invalid syntax for new username.\n");
exit;
} elsif ($password ne $confirm_password) {
error_out("Password mismatch.\n");
exit;
} elsif (not $password) {
error_out("Please provide a password.\n");
exit;
} elsif ($password !~ /^[A-Za-z0-9\[\]\(\)!@\$\^,\.~\|=\-\+_\{\}\#]+$/) {
error_out("Invalid syntax for new passsword. The only allowed characters are all alphanumerics (A-Z, a-z, 0-9) and symbols []()!@\$^,.~|=-+_{}#\n");
exit;
} elsif ($flag_use_profile and not $domain) {
error_out("Please provide a domain to match the profile with.\n");
exit;
}
$xcp_request = {
action => "change",
object => "ownership",
cookie => $cookie,
attributes => {
username => $username,
password => $password,
}
};
if ($flag_move_all_domains) {
$xcp_request->{attributes}->{move_all} = 1;
}
if ($flag_use_profile) {
$xcp_request->{attributes}->{reg_domain} = $domain;
}
$response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Unable to change domain's ownership: $response->{response_text}.\n");
exit;
}
# make them logout
# note that the cookie here is both needed for authentication and
# for the command itself, hence why it appears twice in the request data
$XML_Client->send_cmd( {
action => "delete",
object => "cookie",
cookie => $cookie,
attributes => {
cookie => $cookie,
},
} );
# make them login again so they are managing the domain under the new
# profile
$in{reg_domain} = $reg_domain;
login("Ownership change successful. Now logged in as new owner.\n");
}
# retrieve subuser information
sub get_subuser {
my ($sub_id,$sub_username,$sub_permission);
# get subuser for a given user
my $xcp_request = {
action => "get",
object => "subuser",
cookie => $cookie,
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Unable to retrieve subuser information: $response->{response_text}\n");
exit;
}
$sub_id = $response->{attributes}->{id};
$sub_username = $response->{attributes}->{username};
$sub_permission = $response->{attributes}->{permission};
return($sub_id,$sub_username,$sub_permission);
}
# display waiting request history for this domain
sub view_waiting_history {
my (%HTML,$record);
my $waiting_actions = {
enhanced_update_nameservers => "Nameserver Update",
update_nameservers => "Nameserver Update",
add_nameserver => "Nameserver Update",
remove_nameserver => "Nameserver Update",
modify_contact_info => "Modify Contact Info",
sw_register => "Registration",
register_domain => "Registration",
process_sw_order => "Registration",
ukstatus => "Transfer",
renew_domain => "Renewal",
modify_uk_whois_opt => "Whois Opt Out",
tld_update_contacts => "Modify Contact Info",
modify_nameserver => "Nameserver Update",
};
# get domains for a given user
my $xcp_request = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "waiting_history",
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
error_out("Failed attempt: $response->{response_text}\n");
exit;
}
my $record_count = $response->{attributes}->{record_count};
my @records = @{$response->{attributes}->{waiting_history}};
$HTML{waiting_history} = "";
if ( not scalar @records )
{
$HTML{waiting_history} .= <
No history found
EOF
}
else
{
foreach $record (@records) {
my $w_action = $waiting_actions->{$record->{action}};
$w_action||=$record->{action}; # if undefined or new action
$HTML{waiting_history} .= <
$record->{request_id}
$w_action
$record->{request_time}
$record->{response_time}
$record->{request_status}
$record->{response_text}
EOF
}
}
$HTML{CGI} = $cgi;
print_form("$path_templates/waiting_history.html",\%HTML);
}
###########################################################################
# print a html header
sub print_header {
if (not $flag_header_sent) {
print "Content-type: text/html; charset=$OPENSRS{HTTP_ENCODING}\n\n";
$flag_header_sent = 1;
}
}
##########################################################################
# substitute values on the specified template and print it to the client
# an optional 'type' arg can be passed: 'framed' specifies to pull in base.html
# as the outer frame and the given template as the inner frame
# 'single' specifies to use the given template alone
# the default behavior is 'framed'
sub print_form {
my ($type,$content,$template_html);
print_header();
my @args = @_;
my ($template,$HTML) = @args[0,1];
if ($args[2]) { $type = $args[2] }
else { $type = 'framed' }
if (not $domain_count) {
$domain_count = 0;
}
my $action;
# show domain search box if they have multiple domains
if ($reg_f_owner and $domain_count > 1) {
my $link;
if ( $MANAGE{ allow_renewals } ) {
$link = qq($domain_count Total);
$action = "get_expire_domains";
} else {
$link = qq($domain_count Total
);
$action = "view_domains";
}
if (not $HTML->{ auto_renew }) { $HTML->{auto_renew} = '*'};
my @selected;
my %selected_show = ( '*' => "All", Y => "Yes", N => "No" );
foreach my $select (keys %selected_show){
if ( $select ne $HTML->{ auto_renew } ){
push @selected, $select;
}
}
$HTML->{SEARCH_BOX} = <
Domain
(Use an asterisk '*' to do wildcard searches.)
Expiry Date
(E.g., mm/dd/yyyy)
EOF
if ( $MANAGE{allow_renewals} ){
$HTML->{SEARCH_BOX} .= <
Auto Renew
EOF
}
$HTML->{SEARCH_BOX} .= <
Number of Records
per Page
(Default is 40 records per page)
EOF
}
$HTML->{DOMAIN_NAME} = $reg_domain;
$HTML->{CONVERT_LINK} = "[IDN]"
if $reg_domain =~ /^xn--/;
$HTML->{EXPIREDATE} = $expiredate;
$HTML->{WAITING_REQUESTS_NO} = $waiting_requests_no;
if ($inaccuratewhois){
$HTML->{INACCURATEWHOIS} = 'Inaccurate WHOIS Lock is ON. Please contact your Reseller to have this corrected';
$HTML->{INACCURATEWHOISLOCK} = "Changes CANNOT be applied while Inaccurate WHOIS lock is ON. Please contact your Reseller to have this corrected";
}
if ($auction_escrow) {
$HTML->{AUCTION_ESCROW} = 'Auction Escrow Lock is ON. Please contact
your Reseller for more information';
}
if ($dom_locked) {
$HTML->{dom_locked} = "is Locked";
}
$HTML->{TOP_NAVBAR} = make_top_navbar();
if ($type eq 'framed') {
$HTML->{AUTORENDATA} = "";
if ($MANAGE{allow_auto_renewal_message}){
my $xcp_request = {
action => "get",
object => "domain",
cookie => $cookie,
attributes => {
type => "expire_action",
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
my $flag = $response->{attributes}->{auto_renew};
if($flag){
my $expiry_epoch = get_expiry_epoch_time($expiredate);
my $new_epoch = $expiry_epoch - 30 * 86400;
$HTML->{AUTORENDATA} = get_date_from_epoch($new_epoch, "stripped");
$HTML->{AUTORENDATA} = get_content("$path_templates/base_autoren.html", $HTML);
}
}
$HTML->{CONTENT} = get_content("$template",$HTML);
if($MANAGE{allow_renewals}){ get_warning_type(); }
if ((defined $t_mode) and $t_mode) {
$template_html = "base2.html";
if (($t_mode == $T_EXPIRED) || ($t_mode == ($T_EXPIRED + $T_EXPIRING))) {
$HTML->{EXPIRED} = "Click here to see the list of names that will be deleted if not renewed.";
}
if (($t_mode == $T_EXPIRING) || ($t_mode == ($T_EXPIRED + $T_EXPIRING))) {
$HTML->{EXPIRING} = "Click here to see the list of names expiring within the next $notice_days days.";
}
} else {
$template_html = "base.html";
}
$content .= get_content("$path_templates/$template_html",$HTML);
} else {
$content .= get_content("$template", $HTML);
}
print $content;
}
sub make_top_navbar {
my ($navbar);
#for .de we mask billing contact into zone contact
my $billing_con_name = "Billing";
if($reg_domain =~ /de$/) {
$billing_con_name = "Zone";
}
if ($reg_f_owner) {
$navbar = "Profile";
$navbar .= <Organization
EOF
#
# .ca does not have a billing contact.
#
if ($reg_domain =~ /ca$/)
{
$navbar .= <Admin
| Technical
| Name Servers
| Reseller Contact
| Logout
EOF
} elsif ($reg_domain =~ /uk$/) {
$navbar .= <Admin
| $billing_con_name
| Name Servers
| Reseller Contact
| Logout
EOF
} elsif ($reg_domain =~ /(eu|be)$/) {
$navbar .= <Technical
| Name Servers
| Reseller Contact
| Logout
EOF
} elsif ( $reg_domain =~ /$OPENSRS{ TLDS_SUPPORTING_LOCKING }/ ) {
$navbar .= <Admin
| $billing_con_name
| Technical
| Name Servers
| Reseller Contact
Domain Locking
| Logout
EOF
} else {
$navbar .= <Admin
| $billing_con_name
| Technical
| Name Servers
| Reseller Contact
Domain Locking
| Logout
EOF
}
$navbar =~ /(.+Name Servers<\/a>)(.*)/s;
if ($capabilities->{domain_extras} or $dns_errors) {
$navbar = $1 . " | Domain Extras<\/a>\n" . $2;
} else {
$navbar = $1 . " | Domain Extras\n" . $2;
}
return $navbar;
} else {
# these first two are never available for sub-users
$navbar .= "Profile\n";
# The owner contact type cannot be modified if the
# domain ends with uk
# if ( ( $reg_permission & $PERMISSIONS{f_modify_owner} ) &&
# ( $reg_domain !~ /uk$/ ) ) {
if ($reg_permission & $PERMISSIONS{f_modify_owner}) {
$navbar .= <Organization
EOF
} else {
$navbar .= "| Organization\n";
}
if ($reg_permission & $PERMISSIONS{f_modify_admin}) {
$navbar .= <Admin
EOF
} else {
$navbar .= "| Admin\n";
}
if (($reg_permission & $PERMISSIONS{f_modify_billing}) && ($reg_domain !~ /ca$/)) {
$navbar .= <$billing_con_name
EOF
} else {
$navbar .= "| $billing_con_name\n";
}
if ($reg_permission & $PERMISSIONS{f_modify_tech}) {
$navbar .= <Technical
EOF
} else {
$navbar .= "| Technical\n";
}
if ($reg_permission & $PERMISSIONS{f_modify_nameservers}) {
$navbar .= <Manage Name Servers
EOF
} else {
$navbar .= "| Manage Name Servers\n";
}
if (($reg_permission & $PERMISSIONS{f_modify_domain_extras}) && $capabilities->{domain_extras}) {
$navbar .= <Domain Extras
EOF
} else {
$navbar .= "| Domain Extras\n";
}
if ($reg_permission & $PERMISSIONS{f_modify_whois_rsp_info}) {
$navbar .= <Reseller Contact
EOF
} else {
$navbar .= "| Reseller Contact";
}
$navbar .= <
Domain Locking
| Logout
EOF
return $navbar;
}
}
# handy method to show default error page
sub error_out {
my ( $error_msg, $domain ) = @_;
my (%HTML);
$HTML{CGI} = $cgi;
$HTML{ERROR} = $error_msg;
$HTML{SHOW_PASS} = "";
if ( defined $domain and
defined $MANAGE{allow_password_requests} and
$MANAGE{allow_password_requests} ) {
if ( $MANAGE{password_send_to_admin} ) {
$HTML{SHOW_PASS} = qq(Click here to have lost password sent to admin.);
if ($MANAGE{password_send_subuser}){
$HTML{SHOW_PASS} .= qq(
Click here to have lost subuser password sent to admin.);
}
}
if ( $MANAGE{password_send_to_owner} ) {
$HTML{SHOW_PASS} .= qq(
Click here to have lost password sent to owner.);
if ($MANAGE{password_send_subuser}){
$HTML{SHOW_PASS} .= qq(
Click here to have lost subuser password sent to admin.);
}
}
}
print_form("$path_templates/error.html",\%HTML,'single');
}
sub escape_hash_values {
my $hash_ref = shift;
foreach my $hash_key ( keys %$hash_ref )
{
if ( ref( $hash_ref->{$hash_key} ) eq "HASH" )
{
escape_hash_values( $hash_ref->{$hash_key} );
}
elsif ( ref( $hash_ref->{$hash_key} ) eq "ARRAY" )
{
escape_array_values( $hash_ref->{$hash_key} );
}
else
{
$hash_ref->{$hash_key} = escape( $hash_ref->{$hash_key} );
}
}
}
sub escape_array_values {
my $array_ref = shift;
foreach my $array_element ( @$array_ref )
{
if ( ref( $array_element ) eq "HASH" )
{
escape_hash_values( $array_element );
}
elsif ( ref( $array_element ) eq "ARRAY" )
{
escape_array_values( $array_element );
}
else
{
$array_element = escape( $array_element );
}
}
}
sub escape {
my $string = shift;
$string =~ s/\"/"/g;
return $string;
}
####################################################
# grab the contents of a template, substitute any supplied values, and return
# the results
sub get_content {
my $content;
my ($template,$HTML) = @_;
open (FILE, "<$template") or die "Couldn't open $template: $!\n";
while () {
s/{{(.*?)}}/pack('A*',$HTML->{$1})/eg;
$content .= $_;
}
close FILE;
return $content;
}
# attempt to validate a user's cookie
sub validate {
my ($expire,$response);
$reg_username = "";
if (exists $cookies{$COOKIE_KEY}) {
$cookie = $cookies{$COOKIE_KEY};
my $xcp_request = {
action => "get",
object => "userinfo",
cookie => $cookie,
};
$response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
return undef;
}
$reg_username = $response->{attributes}->{username};
$reg_domain = $response->{attributes}->{domain};
$reg_f_owner = $response->{attributes}->{f_owner};
$reg_permission = $response->{attributes}->{permission};
$domain_count = $response->{attributes}->{domain_count};
$inaccuratewhois = $response->{attributes}->{inaccuratewhois}||0;
$auction_escrow = $response->{attributes}->{auction_escrow}||0;
$dom_locked = get_domain_lock_status()||0;
$expiredate = $response->{attributes}->{expiredate};
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
$capabilities = $response->{attributes}->{capabilities};
if($SHOW_DNS_ERRORS) {
$dns_errors = $response->{attributes}->{dns_errors};
}
my $domain_extras = 0;
while (my($k,$v) = each %$capabilities) {
$domain_extras += $v;
}
$capabilities->{domain_extras} = $domain_extras;
return 1;
} else {
return undef;
}
}
# get cookies from the client
sub GetCookies {
my ($cookie, %cookies,$key,$value);
foreach $cookie (split /\; /, $ENV{HTTP_COOKIE}) {
($key, $value) = (split /=/, $cookie)[0,1];
$value =~ s/\\0/\n/g;
$cookies{$key} = $value;
}
return %cookies;
}
#####################################################################
# authenticate user
sub login {
my $message = shift;
$reg_username = $in{reg_username};
$reg_password = $in{reg_password};
$in{reg_domain} =~ s/^\s+//;
$in{reg_domain} =~ s/\s+$//;
$reg_domain = $in{reg_domain};
if ( not $in{reg_domain} ) {
error_out("Please enter a domain name.");
exit;
}
if ( $in{reg_domain} =~ /\s/ ) {
error_out("Spaces not allowed inside domain name [$in{reg_domain}].");
exit;
}
if ( $in{reg_domain} =~ /[^A-Za-z0-9\.\-]/ ) {
error_out(
"It seems that $in{reg_domain} is an IDN domain.
".
" Please convert".
" to Punycode first"
);
exit;
}
if ( $in{reg_domain} =~ /^www\..*$OPENSRS{OPENSRS_TLDS_REGEX}$/i ) {
error_out("Please, do not put www. as part of your domain name");
exit;
}
my ($tld) = $reg_domain =~ /$OPENSRS{OPENSRS_TLDS_REGEX}$/;
if ( exists $CANT_SUPPORT{$tld} ) {
my $message = <
interface. We will have a $tld enabled Manage Domain interface in place as
soon as possible.
If need to make emergency nameserver changes to your domain, please contact
support\@opensrs.org.
EOF
error_out($message);
exit;
}
# get permissions for a given user
my $xcp_request = {
action => "set",
object => "cookie",
attributes => {
domain => $reg_domain,
reg_username => $reg_username,
reg_password => $reg_password,
}
};
my $response = $XML_Client->send_cmd( $xcp_request );
if (not $response->{is_success}) {
my $error;
if ( $response->{response_code} == 415 ) { # bad un/pw
$error = "Error: Invalid username/password combination for $reg_domain.
";
$response->{response_text} =~ s/\n/
\n/g;
$error .= $response->{response_text};
error_out( $error, $reg_domain );
exit;
} else { # any other error
$error = "$response->{response_text}
Please contact Support for assistance.";
error_out( $error );
exit;
}
}
if ( $response->{redirect_url} ) {
print "Location: ".$response->{redirect_url}."\n\n";
}
$domain_count = $response->{attributes}->{domain_count};
$reg_permission = $response->{attributes}->{permission};
$reg_f_owner = $response->{attributes}->{f_owner};
$expiredate = $response->{attributes}->{expiredate};
$last_access_time = $response->{attributes}->{last_access_time};
$last_ip = $response->{attributes}->{last_ip};
# XXX what about waiting request stuff???
$waiting_requests_no = $response->{attributes}->{waiting_requests_no};
$cookie = $response->{attributes}->{cookie};
#run validate() here to get capabilities, which is used to decide
#how to diplay the "Domain Extras" page.
$cookies{$COOKIE_KEY} = $cookie;
validate();
my $path = "";
print "Content-type: text/html\n";
print "Set-Cookie: $COOKIE_KEY=$cookie; PATH=$path\n";
print "\n";
$flag_header_sent = 1;
main_menu($message);
}
#############################################################################
# logout user (delete cookie)
sub logout {
my ($cookie);
if (exists($cookies{$COOKIE_KEY})) {
$cookie = $cookies{$COOKIE_KEY};
my $xcp_request = {
action => "delete",
object => "cookie",
cookie => $cookie,
attributes => {
cookie => $cookie,
}
};
$XML_Client->send_cmd( $xcp_request );
}
show_login();
}
########################################################
# dynamically build all .ca legal types.
sub build_ca_domain_legal_types
{
my $type = shift;
my $string = "";
return $string;
}
sub build_ca_language_preferences
{
my $type = shift;
my $string = "\n\nPreferred Language: \n\n\n ";
return $string;
}
sub build_ca_nationality_pulldown
{
my $type = shift;
my $string = "\n\nNationality: \n\n\n ";
return $string;
}
sub get_expiry_epoch_time {
my $tmptime = $_[0];
my @db = $tmptime =~ /^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
return timelocal($db[5], $db[4], $db[3], $db[2], $db[1]-1, $db[0]);
}
sub get_date_from_epoch {
my ($ampm);
my $time = shift;
my $flag = shift;
my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my ($min,$hour,$day,$month,$year) = (localtime($time))[1,2,3,4,5];
$year += 1900;
if ($hour > 12) {
$ampm = "pm";
$hour -= 12;
} else {
$ampm = "am";
}
if ($flag eq 'stripped') {
return sprintf("%3s %2d, %4d",
$months[$month],
$day,
$year);
} else {
return sprintf("%2d:%02d %2s %3s %2d, %4d",
$hour,
$min,
$ampm,
$months[$month],
$day,
$year);
}
}
sub get_expire_domains {
#get list of expired domains or ones to expire within $notice_days days
#/manage?action=get_expire_domains&type={expired/expiring}
my ($error,$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
my (%HTML,$domain_name,$domain_html,$next_page,$previous_page);
my @domains = () ;
my $title = "List of domains due to expire within next $notice_days days";
my @auto_renew = ();
my @expiredate = ();
my @sponsoring = ();
my @expired_index = (); # keep array of expired domain indexes
my @expiring_index = (); # array of domain indexes with date whithin $notice_days days
my $type = $in{type};
my $xcp_request = undef;
my $response = undef;
my $option = "";
my $type_string = "";
my $SELECT_ALL = "Select All";
my $DESELECT_ALL = "De-select All";
my $select_all_mode = $in{select_all_mode} || $SELECT_ALL ;
my $select_all_renew_mode = $in{select_all_renew_mode} || $SELECT_ALL ;
my $submitted = $in{submitted}; # flag to indicate if the user actually submitted request
my $prev_submitted = $submitted;
my $not_first_time = $in{not_first_time};
my $cb_auto_set = $in{cb_auto_set} || "0";
my $cb_renew_set = $in{cb_renew_set} || "0";
my $first_reg_domain = $in{first_reg_domain} || $reg_domain;
my $auto_update_status = 0;
my $updated_domain_html = "";
my $page = $in{page};
my $hpage = $in{hpage} || $page;
my $select_all_autorenew = $in{select_all_autorenew};
my $select_all_renew = $in{select_all_renew};
my $submit_renewals = $in{submit_renewals};
my $dlterm0 = $in{"dlterm-0"};
my %hterm = {};
my %hauto = {};
my %hrenew = {};
my @hdomain= ();
my $rtmp;
my $i=0;
my @status_msg = ();
my $diff_rsp = 0;
my $with_encoding_types=1;
if (not $page) { $page = 0 }
if ($submit_renewals) { # user submitted the request
$submitted = 1;
}
$in{ sort_by } = 'ASC'
if not $in{ sort_by } or $in{ sort_by } !~ /^(ASC|DESC)$/;
my $sort = $in{sort_by};
my $order_by = $in{ orderby };
if ( not $order_by ) { $order_by = 'name' }
my $limit = $in{ limit };
if( not $limit ) { $limit = 40 }
my $auto_renew = $in{ auto_renew };
if( not $auto_renew ) { $auto_renew = '*' }
my $domain = lc $in{domain};
$domain = trim($domain);
my $domain_search = $in{domain_search};
$domain_search = trim($domain_search);
if( not $domain ) { $domain = '*' }
if( not $domain_search ) { $domain_search = '*' }
my $expiry_date = $in{ expiry_date };
foreach my $key (keys %in){
$rtmp = $key;
if ($rtmp =~ /^domain-/) {
$hdomain[$i++]=$in{"$rtmp"};
}
}
my $arraycnt = @hdomain;
foreach my $key (0..$arraycnt){
$hterm{$hdomain[$key]} = $in{"dlterm-$hdomain[$key]"};
$hauto{$hdomain[$key]} = $in{"autorenew-$hdomain[$key]"};
$hrenew{$hdomain[$key]} = $in{"renew-$hdomain[$key]"};
}
if ($type eq "") { error_out("Missing type for $action"); return; };
if ((lc $type) eq "expired") {
$response = do_expired_domains($page, $with_encoding_types, $sort, $domain, $domain_search, $auto_renew, $limit, $order_by, $expiry_date);
$type_string = "&type=expired";
$title = "List of domains that will be deleted if not renewed";
} elsif ((lc $type) eq "expiring") {
$response = do_expiring_domains($page, $with_encoding_types, $sort, $domain, $domain_search, $auto_renew, $limit, $order_by, $expiry_date);
$type_string = "&type=expiring";
$title = "List of domains expiring within the next $notice_days days";
} elsif ((lc $type) eq "all") {
$response = do_all_domains($page, $with_encoding_types, $sort, $domain, $domain_search, $auto_renew, $limit, $order_by, $expiry_date);
$type_string = "&type=all";
$title = "List of domains in profile";
} else {
error_out("
Wrong type used
");
return;
}
my $remainder = $response->{attributes}->{remainder}; # are there more domains to show?
# Get domains: separate domain names from enctypes
@domains = get_domains_store_enctypes($response);
if (defined $domains[0]){
#Get expiredate & auto_renew arrays:
for (my $i=0; $i<@domains; $i++){
$auto_renew[$i] = $response->{attributes}->{ext_results}->[$i]->{$domains[$i]}->{auto_renew};
$expiredate[$i] = $response->{attributes}->{ext_results}->[$i]->{$domains[$i]}->{expiredate};
$sponsoring[$i] = $response->{attributes}->{ext_results}->[$i]->{$domains[$i]}->{sponsoring_rsp};
}
}
my $ref = ref ($response->{attributes}->{domain_list});
if ($ref eq "ARRAY" and (defined $domains[0])) {
for my $i ( 0..$#expiredate) {
my $cb_auto="";
$status_msg[$i] = "";
my $orig_dom_name = $domains[$i];
if ($select_all_autorenew) { # user pressed SELECT_ALL for auto renew this time
if ($select_all_mode eq $SELECT_ALL){
$cb_auto="CHECKED";
} elsif ($select_all_mode eq $DESELECT_ALL) {
$cb_auto="";
}
} else { # user did not press SELECT_ALL for auto renew this time
if (($auto_renew[$i] == 1) and !$not_first_time) {
$cb_auto="CHECKED";
} else { # set preserved state:
$cb_auto=$hauto{$domains[$i]};
}
}
my $cb_renew =$hrenew{$domains[$i]}; # set preserved state
if ( $select_all_renew) { # user pressed SELECT_ALL for renew this time:
if ($select_all_renew_mode eq $SELECT_ALL) {
$cb_renew = "CHECKED";
} elsif ($select_all_renew_mode eq $DESELECT_ALL) {
$cb_renew = "";
}
}
$auto_update_status = 0;
if ($submitted and $sponsoring[$i]) { # process domains if user submitted the request:
if ( $cb_auto eq "CHECKED") {
# change auto-renew:
if (!$auto_renew[$i]) {
change_profile($domains[$i]);
$status_msg[$i] = renewals_autorenew(1);
$auto_update_status = 1;
}
} else {
if ($auto_renew[$i] ) {
change_profile($domains[$i]);
$status_msg[$i] = renewals_autorenew(0);
$auto_update_status = 1;
}
}
if ($i == $#expiredate) { # if this is the last one - change the profile back:
if ($reg_domain ne $first_reg_domain) {
change_profile($first_reg_domain);
}
}
if ( $cb_renew eq "CHECKED") { # renew submitted domains:
my ($exp_year) = $expiredate[$i] =~ m/^(\d+)/;
if ($status_msg[$i]){
$status_msg[$i] = $status_msg[$i] . ", " . renewals_renew($domains[$i], $exp_year, $hterm{$domains[$i]});
} else {
$status_msg[$i] = renewals_renew($domains[$i], $exp_year, $hterm{$domains[$i]});
}
}
if (($cb_renew eq "CHECKED") or $auto_update_status){
$updated_domain_html .= "$orig_dom_name ";
$updated_domain_html .= "$status_msg[$i] ";
}
}
my %termlist= ( '1' => ' 1 year', '2' => ' 2 years', '3' => ' 3 years', '4' => ' 4 years',
'5' => ' 5 years', '6' => ' 6 years', '7' => ' 7 years', '8' => ' 8 years',
'9' => ' 9 years', '10' => '10 years',
);
my $option_data = "";
if ($hterm{$domains[$i]}) {
$option_data = get_select_content($hterm{$domains[$i]}, \%termlist);
}
else {
$option_data = get_select_content('1', \%termlist);
}
my $domain_link;
if ( $type eq 'all' and $domains[ $i ] ne $reg_domain ) {
$domain_link = qq($orig_dom_name);
} else {
$domain_link = $orig_dom_name;
}
# only show renewal options for domains sponsored by this RSP
if ( $sponsoring[ $i ] ) {
$domain_html .= <
$domain_link
$expiredate[$i]
EOF
if ( $MANAGE{show_auto_renew} ){
$domain_html .= <
EOF
}
$domain_html .= <
EOF
} else {
$domain_html .= <
$domain_link
$expiredate[$i]
EOF
my $colspan = 3;
if ( not $MANAGE{show_auto_renew} ){
$colspan = 2;
}
$domain_html .= <
Can't renew this domain. See below.
EOF
$diff_rsp = 1;
}
} # end of the for loop
if ($updated_domain_html) {
$HTML{DOMAINS} = $updated_domain_html;
$HTML{TITLE} = "Update Status";
$HTML{CGI} = $cgi;
print_form("$path_templates/expire_domains_result.html",\%HTML);
exit;
}
# change names of submit buttons acording to the user's choice:
if ( $select_all_autorenew) {
if ($select_all_mode eq $SELECT_ALL) {
$select_all_mode = $DESELECT_ALL;
} else {
$select_all_mode = $SELECT_ALL;
}
$cb_auto_set = "1";
}
if ( $select_all_renew ) {
if ($select_all_renew_mode eq $SELECT_ALL) {
$select_all_renew_mode = $DESELECT_ALL;
} else {
$select_all_renew_mode = $SELECT_ALL;
}
$cb_renew_set = "1";
}
$prev_submitted = $submitted;
if ($submitted) {
$submitted =0;
}
my (%HTML);
$HTML{select_all_mode}= $select_all_mode;
$HTML{select_all_renew_mode}= $select_all_renew_mode;
if ( $MANAGE{show_auto_renew} ){
$HTML{select_auto_renew} = <
EOF
}
$domain_html .= get_content("$path_templates/manage_rview_btns.html", \%HTML);
}
my $num_page_links = 10;
my $navbar = make_navbar(
"get_expire_domains&type=$in{type}&sort_by=$sort&expiry_date=$in{expiry_date}&limit=$limit&orderby=$in{orderby}&domain=$in{domain}&domain_search=$in{domain_search}&auto_renew=$in{auto_renew}", $response->{ attributes }{ count }, $limit, $num_page_links, $page);
$navbar .= "
\n";
if ( $diff_rsp ) {
$HTML{diff_rsp_msg} = <
Note:
Some domains are not sponsored by this domain provider, and can't be
renewed/auto_renewed from this interface.
EOF
}
my $new_sort = $sort eq 'ASC' ? 'DESC' : 'ASC';
$HTML{rows} = "4";
$HTML{header} = <Expiry Date
EOF
if ( $MANAGE{show_auto_renew} ){
$HTML{header} .= <Set Auto Renew
EOF
$HTML{rows} = "5";
}
$not_first_time =1;
$HTML{DOMAINS} = $domain_html;
$HTML{TITLE} = $title;
$HTML{CGI} = $cgi;
$HTML{ACTION_VALUE} = "get_expire_domains";
$HTML{TYPE} = $type;
$HTML{SELECT_ALL_MODE} = $select_all_mode;
$HTML{SELECT_ALL_RENEW_MODE} = $select_all_renew_mode;
$HTML{CB_AUTO_SET} = $cb_auto_set;
$HTML{CB_RENEW_SET} = $cb_renew_set;
$HTML{SUBMITTED} = $submitted;
$HTML{NOT_FIRST_TIME} = $not_first_time;
$HTML{NAVBAR} = $navbar;
$HTML{HPAGE} = $hpage;
$HTML{PAGE} = $page;
$HTML{FIRST_REG_DOMAIN} = $first_reg_domain;
$HTML{domain} = $in{domain};
$HTML{domain_search} = $in{domain_search};
$HTML{limit} = $limit;
$HTML{auto_renew} = $in{auto_renew};
$HTML{expiry_date} = $in{expiry_date};
$HTML{DOMAIN_COUNT} = $response->{ attributes }{ count };
$HTML{new_sort} = $new_sort;
$HTML{TYPE} = $in{type};
print_form("$path_templates/view_expire_domains.html",\%HTML);
}
sub get_select_content {
my $sel_opt = shift;
my $hashptr = shift;
my $htmldata = "";
foreach my $item (sort {$a<=>$b} keys %$hashptr){
if ($item eq $sel_opt){
$htmldata .= "