?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/cPanel-PublicAPI-2.8-0.tar
???????
pm_to_blib 0000644 00000000000 15125143347 0006570 0 ustar 00 Changes 0000644 00000003553 15125143347 0006052 0 ustar 00 Revision history for cPanel-PublicAPI 2.8 2021-01-25 Don’t create symbol table entries for JSON decoders we don’t load. 2.7 2019-11-13 Fix http_tiny_creator parameter handling. 2.6 2019-11-06 Add http_tiny_creator parameter. Fix trivial typo in test error message. 2.5 2019-05-13 Fix error details on 599 error (typo in 2.4 change). 2.4 2019-04-23 Add compatibility logic for cPanel API tokens. Print HTTP::Tiny “content” when it gives a 599 error (e.g., TLS error). 2.3 2018-12-28 Bump version number to be strictly greater than 2.2 Switch cPanel provided encoder to be the real encoder: Cpanel::Encoder::URI Testing commits on Travis now. Update README Block install/test reports for windows since they require getpwuid to pass. 2.2.1 2017-10-09 Update Changes, MANIFEST and README. 2.2 2017-04-17 Implement HTTP support via HTTP::Tiny. Support two-factor authentication (2FA) workflow. Establish session when using user/pass; accesshash still uses Basic Auth. Support API tokens via new api_token constructor option. Documentation fixes. Unit test fixes. 2.0 2015-09-15 Updated PublicAPI pod file to include description of new ssl_verify_mode option. Default WHM API to v1. 1.3 2015-09-14 Fix hash randomization problem on newer Perls. 1.2 2015-08-26 Updated from main code-base, changes include: Fixed non-numeric comparison errors. Cleaned up uninitialized variable use. Error checking after api_request in cPanel::PublicAPI::whm_api() call. Correct comments in copyright headers w/ modified bsd license Correct disclaimer in 3-clause BSD license Changes to accommodate latest version of IO::Socket::SSL Removed Frontpage references Changed to work with self-signed SSL certificates 1.0 2011-02-24 First version, Implement HTTP querying. MANIFEST.SKIP 0000644 00000002254 15125143347 0006452 0 ustar 00 ^\.perltidyrc ^\.travis.yml #!start included /Users/markgardner/.plenv/versions/5.26.1/lib/perl5/5.26.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this \b_eumm/ # 7.05_05 and above # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # and Module::Build::Tiny generated files \b_build_params$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ \..*\.sw.?$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid prove files \B\.prove$ # Avoid MYMETA files ^MYMETA\. #!end included /Users/markgardner/.plenv/versions/5.26.1/lib/perl5/5.26.1/ExtUtils/MANIFEST.SKIP Makefile 0000644 00000104712 15125143347 0006216 0 ustar 00 # This Makefile is for the cPanel::PublicAPI extension to perl. # # It was generated automatically by MakeMaker version # 7.60 (Revision: 76000) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # # MakeMaker Parameters: # ABSTRACT_FROM => q[lib/cPanel/PublicAPI.pod] # AUTHOR => [q[cPanel, Inc. <integration@cpanel.net>]] # BUILD_REQUIRES => { } # CONFIGURE_REQUIRES => { } # LICENSE => q[bsd] # META_MERGE => { meta-spec=>{ version=>q[2] }, resources=>{ bugtracker=>{ web=>q[https://github.com/CpanelInc/cPanel-PublicAPI/issues] }, repository=>{ type=>q[git], url=>q[git://github.com/CpanelInc/cPanel-PublicAPI.git], web=>q[https://github.com/CpanelInc/cPanel-PublicAPI] } } } # NAME => q[cPanel::PublicAPI] # PL_FILES => { } # PREREQ_PM => { HTTP::CookieJar=>q[0], HTTP::Tiny=>q[0.042], IO::Socket::INET=>q[1.31], IO::Socket::SSL=>q[1.988], JSON::XS=>q[2], Test::Exception=>q[0], Test::More=>q[0], URI::Escape=>q[3] } # TEST_REQUIRES => { } # VERSION_FROM => q[lib/cPanel/PublicAPI.pm] # clean => { FILES=>q[cPanel-PublicAPI-*] } # dist => { COMPRESS=>q[gzip -9f], SUFFIX=>q[gz] } # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: # These definitions are from config.sh (via /usr/lib64/perl5/Config.pm). # They may have been overridden via Makefile.PL or on the command line. AR = ar CC = gcc CCCDLFLAGS = -fPIC CCDLFLAGS = -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 DLEXT = so DLSRC = dl_dlopen.xs EXE_EXT = FULL_AR = /usr/bin/ar LD = gcc LDDLFLAGS = -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -L/usr/local/lib -fstack-protector-strong LDFLAGS = -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fstack-protector-strong -L/usr/local/lib LIBC = /lib/../lib64/libc.so.6 LIB_EXT = .a OBJ_EXT = .o OSNAME = linux OSVERS = 4.18.0-513.18.1.el8_9.x86_64 RANLIB = : SITELIBEXP = /usr/local/share/perl5/5.32 SITEARCHEXP = /usr/local/lib64/perl5/5.32 SO = so VENDORARCHEXP = /usr/lib64/perl5/vendor_perl VENDORLIBEXP = /usr/share/perl5/vendor_perl # --- MakeMaker constants section: AR_STATIC_ARGS = cr DIRFILESEP = / DFSEP = $(DIRFILESEP) NAME = cPanel::PublicAPI NAME_SYM = cPanel_PublicAPI VERSION = 2.8 VERSION_MACRO = VERSION VERSION_SYM = 2_8 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" XS_VERSION = 2.8 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script INST_BIN = blib/bin INST_LIB = blib/lib INST_MAN1DIR = blib/man1 INST_MAN3DIR = blib/man3 MAN1EXT = 1 MAN3EXT = 3pm MAN1SECTION = 1 MAN3SECTION = 3 INSTALLDIRS = site DESTDIR = PREFIX = $(SITEPREFIX) PERLPREFIX = /usr SITEPREFIX = /usr/local VENDORPREFIX = /usr INSTALLPRIVLIB = /usr/share/perl5 DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) INSTALLSITELIB = /usr/local/share/perl5/5.32 DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) INSTALLVENDORLIB = /usr/share/perl5/vendor_perl DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) INSTALLARCHLIB = /usr/lib64/perl5 DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) INSTALLSITEARCH = /usr/local/lib64/perl5/5.32 DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) INSTALLVENDORARCH = /usr/lib64/perl5/vendor_perl DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) INSTALLBIN = /usr/bin DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) INSTALLSITEBIN = /usr/local/bin DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) INSTALLVENDORBIN = /usr/bin DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) INSTALLSCRIPT = /usr/bin DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) INSTALLSITESCRIPT = /usr/local/bin DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) INSTALLVENDORSCRIPT = /usr/bin DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) INSTALLMAN1DIR = /usr/share/man/man1 DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) INSTALLSITEMAN1DIR = /usr/local/share/man/man1 DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) INSTALLVENDORMAN1DIR = /usr/share/man/man1 DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) INSTALLMAN3DIR = /usr/share/man/man3 DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) INSTALLSITEMAN3DIR = /usr/local/share/man/man3 DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) INSTALLVENDORMAN3DIR = /usr/share/man/man3 DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) PERL_LIB = /usr/share/perl5 PERL_ARCHLIB = /usr/lib64/perl5 PERL_ARCHLIBDEP = /usr/lib64/perl5 LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile MAKEFILE_OLD = Makefile.old MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) PERL_INC = /usr/lib64/perl5/CORE PERL_INCDEP = /usr/lib64/perl5/CORE PERL = "/usr/bin/perl" FULLPERL = "/usr/bin/perl" ABSPERL = $(PERL) PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) ABSPERLRUN = $(ABSPERL) PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" PERL_CORE = 0 PERM_DIR = 755 PERM_RW = 644 PERM_RWX = 755 MAKEMAKER = /usr/share/perl5/vendor_perl/ExtUtils/MakeMaker.pm MM_VERSION = 7.60 MM_REVISION = 76000 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. MAKE = make FULLEXT = cPanel/PublicAPI BASEEXT = PublicAPI PARENT_NAME = cPanel DLBASE = $(BASEEXT) VERSION_FROM = lib/cPanel/PublicAPI.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic BOOTDEP = # Handy lists of source code files: XS_FILES = C_FILES = O_FILES = H_FILES = MAN1PODS = MAN3PODS = lib/cPanel/PublicAPI.pod \ lib/cPanel/PublicAPI/Utils.pod \ lib/cPanel/PublicAPI/WHM.pod \ lib/cPanel/PublicAPI/WHM/API.pod \ lib/cPanel/PublicAPI/WHM/CachedVersion.pod \ lib/cPanel/PublicAPI/WHM/DNS.pod \ lib/cPanel/PublicAPI/WHM/JSONAPI.pod \ lib/cPanel/PublicAPI/WHM/Legacy.pod \ lib/cPanel/PublicAPI/WHM/XMLAPI.pod # Where is the Config information that we are using/depend on CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h # Where to build things INST_LIBDIR = $(INST_LIB)/cPanel INST_ARCHLIBDIR = $(INST_ARCHLIB)/cPanel INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) INST_STATIC = INST_DYNAMIC = INST_BOOT = # Extra linker info EXPORT_LIST = PERL_ARCHIVE = PERL_ARCHIVEDEP = PERL_ARCHIVE_AFTER = TO_INST_PM = lib/cPanel/PublicAPI.pm \ lib/cPanel/PublicAPI.pod \ lib/cPanel/PublicAPI/Utils.pm \ lib/cPanel/PublicAPI/Utils.pod \ lib/cPanel/PublicAPI/WHM.pm \ lib/cPanel/PublicAPI/WHM.pod \ lib/cPanel/PublicAPI/WHM/API.pm \ lib/cPanel/PublicAPI/WHM/API.pod \ lib/cPanel/PublicAPI/WHM/CachedVersion.pm \ lib/cPanel/PublicAPI/WHM/CachedVersion.pod \ lib/cPanel/PublicAPI/WHM/DNS.pm \ lib/cPanel/PublicAPI/WHM/DNS.pod \ lib/cPanel/PublicAPI/WHM/JSONAPI.pm \ lib/cPanel/PublicAPI/WHM/JSONAPI.pod \ lib/cPanel/PublicAPI/WHM/Legacy.pm \ lib/cPanel/PublicAPI/WHM/Legacy.pod \ lib/cPanel/PublicAPI/WHM/XMLAPI.pm \ lib/cPanel/PublicAPI/WHM/XMLAPI.pod # --- MakeMaker platform_constants section: MM_Unix_VERSION = 7.60 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$$$ARGV[0], $$$$ARGV[1], 0, 1, 1)' -- # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: SHELL = /bin/sh CHMOD = chmod CP = cp MV = mv NOOP = $(TRUE) NOECHO = @ RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' -- EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' -- FALSE = false TRUE = true ECHO = echo ECHO_N = echo -n UNINST = 0 VERBINST = 0 MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' -- DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' -- UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' -- WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' -- MACROSTART = MACROEND = USEMAKEFILE = -f FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' -- CP_NONEMPTY = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'cp_nonempty' -- # --- MakeMaker makemakerdflt section: makemakerdflt : all $(NOECHO) $(NOOP) # --- MakeMaker dist section: TAR = tar TARFLAGS = cvf ZIP = zip ZIPFLAGS = -r COMPRESS = gzip -9f SUFFIX = .gz SHAR = shar PREOP = $(NOECHO) $(NOOP) POSTOP = $(NOECHO) $(NOOP) TO_UNIX = $(NOECHO) $(NOOP) CI = ci -u RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist DISTNAME = cPanel-PublicAPI DISTVNAME = cPanel-PublicAPI-2.8 # --- MakeMaker macro section: # --- MakeMaker depend section: # --- MakeMaker cflags section: # --- MakeMaker const_loadlibs section: # --- MakeMaker const_cccmd section: # --- MakeMaker post_constants section: # --- MakeMaker pasthru section: PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ PREFIX="$(PREFIX)"\ PASTHRU_DEFINE='$(DEFINE) $(PASTHRU_DEFINE)'\ PASTHRU_INC='$(INC) $(PASTHRU_INC)' # --- MakeMaker special_targets section: .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) .PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir pure_all subdirs clean_subdirs makemakerdflt manifypods realclean_subdirs subdirs_dynamic subdirs_pure_nolink subdirs_static subdirs-test_dynamic subdirs-test_static test_dynamic test_static # --- MakeMaker c_o section: # --- MakeMaker xs_c section: # --- MakeMaker xs_o section: # --- MakeMaker top_targets section: all :: pure_all manifypods $(NOECHO) $(NOOP) pure_all :: config pm_to_blib subdirs linkext $(NOECHO) $(NOOP) subdirs :: $(MYEXTLIB) $(NOECHO) $(NOOP) config :: $(FIRST_MAKEFILE) blibdirs $(NOECHO) $(NOOP) help : perldoc ExtUtils::MakeMaker # --- MakeMaker blibdirs section: blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists $(NOECHO) $(NOOP) # Backwards compat with 6.18 through 6.25 blibdirs.ts : blibdirs $(NOECHO) $(NOOP) $(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_LIBDIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR) $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHLIB) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB) $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_AUTODIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR) $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR) $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_BIN) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN) $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_SCRIPT) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT) $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_MAN1DIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR) $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_MAN3DIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR) $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists # --- MakeMaker linkext section: linkext :: dynamic $(NOECHO) $(NOOP) # --- MakeMaker dlsyms section: # --- MakeMaker dynamic_bs section: BOOTSTRAP = # --- MakeMaker dynamic section: dynamic :: $(FIRST_MAKEFILE) config $(INST_BOOT) $(INST_DYNAMIC) $(NOECHO) $(NOOP) # --- MakeMaker dynamic_lib section: # --- MakeMaker static section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" static :: $(FIRST_MAKEFILE) $(INST_STATIC) $(NOECHO) $(NOOP) # --- MakeMaker static_lib section: # --- MakeMaker manifypods section: POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" POD2MAN = $(POD2MAN_EXE) manifypods : pure_all config \ lib/cPanel/PublicAPI.pod \ lib/cPanel/PublicAPI/Utils.pod \ lib/cPanel/PublicAPI/WHM.pod \ lib/cPanel/PublicAPI/WHM/API.pod \ lib/cPanel/PublicAPI/WHM/CachedVersion.pod \ lib/cPanel/PublicAPI/WHM/DNS.pod \ lib/cPanel/PublicAPI/WHM/JSONAPI.pod \ lib/cPanel/PublicAPI/WHM/Legacy.pod \ lib/cPanel/PublicAPI/WHM/XMLAPI.pod $(NOECHO) $(POD2MAN) --section=$(MAN3SECTION) --perm_rw=$(PERM_RW) -u \ lib/cPanel/PublicAPI.pod $(INST_MAN3DIR)/cPanel::PublicAPI.$(MAN3EXT) \ lib/cPanel/PublicAPI/Utils.pod $(INST_MAN3DIR)/cPanel::PublicAPI::Utils.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM/API.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM::API.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM/CachedVersion.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM::CachedVersion.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM/DNS.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM::DNS.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM/JSONAPI.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM::JSONAPI.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM/Legacy.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM::Legacy.$(MAN3EXT) \ lib/cPanel/PublicAPI/WHM/XMLAPI.pod $(INST_MAN3DIR)/cPanel::PublicAPI::WHM::XMLAPI.$(MAN3EXT) # --- MakeMaker processPL section: # --- MakeMaker installbin section: # --- MakeMaker subdirs section: # none # --- MakeMaker clean_subdirs section: clean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. clean :: clean_subdirs - $(RM_F) \ $(BASEEXT).bso $(BASEEXT).def \ $(BASEEXT).exp $(BASEEXT).x \ $(BOOTSTRAP) $(INST_ARCHAUTODIR)/extralibs.all \ $(INST_ARCHAUTODIR)/extralibs.ld $(MAKE_APERL_FILE) \ *$(LIB_EXT) *$(OBJ_EXT) \ *perl.core MYMETA.json \ MYMETA.yml blibdirs.ts \ core core.*perl.*.? \ core.[0-9] core.[0-9][0-9] \ core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] \ core.[0-9][0-9][0-9][0-9][0-9] lib$(BASEEXT).def \ mon.out perl \ perl$(EXE_EXT) perl.exe \ perlmain.c pm_to_blib \ pm_to_blib.ts so_locations \ tmon.out - $(RM_RF) \ blib cPanel-PublicAPI-* $(NOECHO) $(RM_F) $(MAKEFILE_OLD) - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) # --- MakeMaker realclean_subdirs section: # so clean is forced to complete before realclean_subdirs runs realclean_subdirs : clean $(NOECHO) $(NOOP) # --- MakeMaker realclean section: # Delete temporary files (via clean) and also delete dist files realclean purge :: realclean_subdirs - $(RM_F) \ $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - $(RM_RF) \ $(DISTVNAME) # --- MakeMaker metafile section: metafile : create_distdir $(NOECHO) $(ECHO) Generating META.yml $(NOECHO) $(ECHO) '---' > META_new.yml $(NOECHO) $(ECHO) 'abstract: '\''A perl interface for interacting with cPanel'\''' >> META_new.yml $(NOECHO) $(ECHO) 'author:' >> META_new.yml $(NOECHO) $(ECHO) ' - '\''cPanel, Inc. <integration@cpanel.net>'\''' >> META_new.yml $(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: '\''0'\''' >> META_new.yml $(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: '\''0'\''' >> META_new.yml $(NOECHO) $(ECHO) 'dynamic_config: 1' >> META_new.yml $(NOECHO) $(ECHO) 'generated_by: '\''ExtUtils::MakeMaker version 7.60, CPAN::Meta::Converter version 2.150010'\''' >> META_new.yml $(NOECHO) $(ECHO) 'license: bsd' >> META_new.yml $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml $(NOECHO) $(ECHO) ' version: '\''1.4'\''' >> META_new.yml $(NOECHO) $(ECHO) 'name: cPanel-PublicAPI' >> META_new.yml $(NOECHO) $(ECHO) 'no_index:' >> META_new.yml $(NOECHO) $(ECHO) ' directory:' >> META_new.yml $(NOECHO) $(ECHO) ' - t' >> META_new.yml $(NOECHO) $(ECHO) ' - inc' >> META_new.yml $(NOECHO) $(ECHO) 'requires:' >> META_new.yml $(NOECHO) $(ECHO) ' HTTP::CookieJar: '\''0'\''' >> META_new.yml $(NOECHO) $(ECHO) ' HTTP::Tiny: '\''0.042'\''' >> META_new.yml $(NOECHO) $(ECHO) ' IO::Socket::INET: '\''1.31'\''' >> META_new.yml $(NOECHO) $(ECHO) ' IO::Socket::SSL: '\''1.988'\''' >> META_new.yml $(NOECHO) $(ECHO) ' JSON::XS: '\''2'\''' >> META_new.yml $(NOECHO) $(ECHO) ' Test::Exception: '\''0'\''' >> META_new.yml $(NOECHO) $(ECHO) ' Test::More: '\''0'\''' >> META_new.yml $(NOECHO) $(ECHO) ' URI::Escape: '\''3'\''' >> META_new.yml $(NOECHO) $(ECHO) 'resources:' >> META_new.yml $(NOECHO) $(ECHO) ' bugtracker: https://github.com/CpanelInc/cPanel-PublicAPI/issues' >> META_new.yml $(NOECHO) $(ECHO) ' repository: git://github.com/CpanelInc/cPanel-PublicAPI.git' >> META_new.yml $(NOECHO) $(ECHO) 'version: '\''2.8'\''' >> META_new.yml $(NOECHO) $(ECHO) 'x_serialization_backend: '\''CPAN::Meta::YAML version 0.018'\''' >> META_new.yml -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml $(NOECHO) $(ECHO) Generating META.json $(NOECHO) $(ECHO) '{' > META_new.json $(NOECHO) $(ECHO) ' "abstract" : "A perl interface for interacting with cPanel",' >> META_new.json $(NOECHO) $(ECHO) ' "author" : [' >> META_new.json $(NOECHO) $(ECHO) ' "cPanel, Inc. <integration@cpanel.net>"' >> META_new.json $(NOECHO) $(ECHO) ' ],' >> META_new.json $(NOECHO) $(ECHO) ' "dynamic_config" : 1,' >> META_new.json $(NOECHO) $(ECHO) ' "generated_by" : "ExtUtils::MakeMaker version 7.60, CPAN::Meta::Converter version 2.150010",' >> META_new.json $(NOECHO) $(ECHO) ' "license" : [' >> META_new.json $(NOECHO) $(ECHO) ' "bsd"' >> META_new.json $(NOECHO) $(ECHO) ' ],' >> META_new.json $(NOECHO) $(ECHO) ' "meta-spec" : {' >> META_new.json $(NOECHO) $(ECHO) ' "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",' >> META_new.json $(NOECHO) $(ECHO) ' "version" : 2' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "name" : "cPanel-PublicAPI",' >> META_new.json $(NOECHO) $(ECHO) ' "no_index" : {' >> META_new.json $(NOECHO) $(ECHO) ' "directory" : [' >> META_new.json $(NOECHO) $(ECHO) ' "t",' >> META_new.json $(NOECHO) $(ECHO) ' "inc"' >> META_new.json $(NOECHO) $(ECHO) ' ]' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "prereqs" : {' >> META_new.json $(NOECHO) $(ECHO) ' "build" : {' >> META_new.json $(NOECHO) $(ECHO) ' "requires" : {' >> META_new.json $(NOECHO) $(ECHO) ' "ExtUtils::MakeMaker" : "0"' >> META_new.json $(NOECHO) $(ECHO) ' }' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "configure" : {' >> META_new.json $(NOECHO) $(ECHO) ' "requires" : {' >> META_new.json $(NOECHO) $(ECHO) ' "ExtUtils::MakeMaker" : "0"' >> META_new.json $(NOECHO) $(ECHO) ' }' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "runtime" : {' >> META_new.json $(NOECHO) $(ECHO) ' "requires" : {' >> META_new.json $(NOECHO) $(ECHO) ' "HTTP::CookieJar" : "0",' >> META_new.json $(NOECHO) $(ECHO) ' "HTTP::Tiny" : "0.042",' >> META_new.json $(NOECHO) $(ECHO) ' "IO::Socket::INET" : "1.31",' >> META_new.json $(NOECHO) $(ECHO) ' "IO::Socket::SSL" : "1.988",' >> META_new.json $(NOECHO) $(ECHO) ' "JSON::XS" : "2",' >> META_new.json $(NOECHO) $(ECHO) ' "Test::Exception" : "0",' >> META_new.json $(NOECHO) $(ECHO) ' "Test::More" : "0",' >> META_new.json $(NOECHO) $(ECHO) ' "URI::Escape" : "3"' >> META_new.json $(NOECHO) $(ECHO) ' }' >> META_new.json $(NOECHO) $(ECHO) ' }' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "release_status" : "stable",' >> META_new.json $(NOECHO) $(ECHO) ' "resources" : {' >> META_new.json $(NOECHO) $(ECHO) ' "bugtracker" : {' >> META_new.json $(NOECHO) $(ECHO) ' "web" : "https://github.com/CpanelInc/cPanel-PublicAPI/issues"' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "repository" : {' >> META_new.json $(NOECHO) $(ECHO) ' "type" : "git",' >> META_new.json $(NOECHO) $(ECHO) ' "url" : "git://github.com/CpanelInc/cPanel-PublicAPI.git",' >> META_new.json $(NOECHO) $(ECHO) ' "web" : "https://github.com/CpanelInc/cPanel-PublicAPI"' >> META_new.json $(NOECHO) $(ECHO) ' }' >> META_new.json $(NOECHO) $(ECHO) ' },' >> META_new.json $(NOECHO) $(ECHO) ' "version" : "2.8",' >> META_new.json $(NOECHO) $(ECHO) ' "x_serialization_backend" : "JSON::PP version 4.06"' >> META_new.json $(NOECHO) $(ECHO) '}' >> META_new.json -$(NOECHO) $(MV) META_new.json $(DISTVNAME)/META.json # --- MakeMaker signature section: signature : cpansign -s # --- MakeMaker dist_basics section: distclean :: realclean distcheck $(NOECHO) $(NOOP) distcheck : $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck skipcheck : $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- tardist : $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(NOOP) uutardist : $(DISTVNAME).tar$(SUFFIX) uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)_uu' $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)' $(POSTOP) zipdist : $(DISTVNAME).zip $(NOECHO) $(NOOP) $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(NOECHO) $(ECHO) 'Created $(DISTVNAME).zip' $(POSTOP) shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(NOECHO) $(ECHO) 'Created $(DISTVNAME).shar' $(POSTOP) # --- MakeMaker distdir section: create_distdir : $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" distdir : create_distdir distmeta $(NOECHO) $(NOOP) # --- MakeMaker dist_test section: disttest : distdir cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) # --- MakeMaker dist_ci section: ci : $(ABSPERLRUN) -MExtUtils::Manifest=maniread -e '@all = sort keys %{ maniread() };' \ -e 'print(qq{Executing $(CI) @all\n});' \ -e 'system(qq{$(CI) @all}) == 0 or die $$!;' \ -e 'print(qq{Executing $(RCS_LABEL) ...\n});' \ -e 'system(qq{$(RCS_LABEL) @all}) == 0 or die $$!;' -- # --- MakeMaker distmeta section: distmeta : create_distdir metafile $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'exit unless -e q{META.yml};' \ -e 'eval { maniadd({q{META.yml} => q{Module YAML meta-data (added by MakeMaker)}}) }' \ -e ' or die "Could not add META.yml to MANIFEST: $${'\''@'\''}"' -- $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'exit unless -f q{META.json};' \ -e 'eval { maniadd({q{META.json} => q{Module JSON meta-data (added by MakeMaker)}}) }' \ -e ' or die "Could not add META.json to MANIFEST: $${'\''@'\''}"' -- # --- MakeMaker distsignature section: distsignature : distmeta $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }' \ -e ' or die "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}"' -- $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE cd $(DISTVNAME) && cpansign -s # --- MakeMaker install section: install :: pure_install doc_install $(NOECHO) $(NOOP) install_perl :: pure_perl_install doc_perl_install $(NOECHO) $(NOOP) install_site :: pure_site_install doc_site_install $(NOECHO) $(NOOP) install_vendor :: pure_vendor_install doc_vendor_install $(NOECHO) $(NOOP) pure_install :: pure_$(INSTALLDIRS)_install $(NOECHO) $(NOOP) doc_install :: doc_$(INSTALLDIRS)_install $(NOECHO) $(NOOP) pure__install : pure_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: all $(NOECHO) $(MOD_INSTALL) \ read "$(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist" \ write "$(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist" \ "$(INST_LIB)" "$(DESTINSTALLPRIVLIB)" \ "$(INST_ARCHLIB)" "$(DESTINSTALLARCHLIB)" \ "$(INST_BIN)" "$(DESTINSTALLBIN)" \ "$(INST_SCRIPT)" "$(DESTINSTALLSCRIPT)" \ "$(INST_MAN1DIR)" "$(DESTINSTALLMAN1DIR)" \ "$(INST_MAN3DIR)" "$(DESTINSTALLMAN3DIR)" $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ "$(SITEARCHEXP)/auto/$(FULLEXT)" pure_site_install :: all $(NOECHO) $(MOD_INSTALL) \ read "$(SITEARCHEXP)/auto/$(FULLEXT)/.packlist" \ write "$(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist" \ "$(INST_LIB)" "$(DESTINSTALLSITELIB)" \ "$(INST_ARCHLIB)" "$(DESTINSTALLSITEARCH)" \ "$(INST_BIN)" "$(DESTINSTALLSITEBIN)" \ "$(INST_SCRIPT)" "$(DESTINSTALLSITESCRIPT)" \ "$(INST_MAN1DIR)" "$(DESTINSTALLSITEMAN1DIR)" \ "$(INST_MAN3DIR)" "$(DESTINSTALLSITEMAN3DIR)" $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ "$(PERL_ARCHLIB)/auto/$(FULLEXT)" pure_vendor_install :: all $(NOECHO) $(MOD_INSTALL) \ read "$(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist" \ write "$(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist" \ "$(INST_LIB)" "$(DESTINSTALLVENDORLIB)" \ "$(INST_ARCHLIB)" "$(DESTINSTALLVENDORARCH)" \ "$(INST_BIN)" "$(DESTINSTALLVENDORBIN)" \ "$(INST_SCRIPT)" "$(DESTINSTALLVENDORSCRIPT)" \ "$(INST_MAN1DIR)" "$(DESTINSTALLVENDORMAN1DIR)" \ "$(INST_MAN3DIR)" "$(DESTINSTALLVENDORMAN3DIR)" doc_perl_install :: all $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> "$(DESTINSTALLARCHLIB)/perllocal.pod" doc_site_install :: all $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> "$(DESTINSTALLARCHLIB)/perllocal.pod" doc_vendor_install :: all $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLVENDORLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> "$(DESTINSTALLARCHLIB)/perllocal.pod" uninstall :: uninstall_from_$(INSTALLDIRS)dirs $(NOECHO) $(NOOP) uninstall_from_perldirs :: $(NOECHO) $(UNINSTALL) "$(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist" uninstall_from_sitedirs :: $(NOECHO) $(UNINSTALL) "$(SITEARCHEXP)/auto/$(FULLEXT)/.packlist" uninstall_from_vendordirs :: $(NOECHO) $(UNINSTALL) "$(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist" # --- MakeMaker force section: # Phony target to force checking subdirectories. FORCE : $(NOECHO) $(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: # We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) $(PERLRUN) Makefile.PL $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" $(FALSE) # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl FULLPERL = "/usr/bin/perl" MAP_PERLINC = "-Iblib/arch" "-Iblib/lib" "-I/usr/lib64/perl5" "-I/usr/share/perl5" $(MAP_TARGET) :: $(MAKE_APERL_FILE) $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : static $(FIRST_MAKEFILE) pm_to_blib $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR="" \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= # --- MakeMaker test section: TEST_VERBOSE=0 TEST_TYPE=test_$(LINKTYPE) TEST_FILE = test.pl TEST_FILES = t/*.t TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) $(NOECHO) $(NOOP) test :: $(TEST_TYPE) $(NOECHO) $(NOOP) # Occasionally we may face this degenerate target: test_ : test_dynamic $(NOECHO) $(NOOP) subdirs-test_dynamic :: dynamic pure_all test_dynamic :: subdirs-test_dynamic PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) testdb_dynamic :: dynamic pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) subdirs-test_static :: static pure_all test_static :: subdirs-test_static PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) testdb_static :: static pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd : $(NOECHO) $(ECHO) '<SOFTPKG NAME="cPanel-PublicAPI" VERSION="2.8">' > cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <ABSTRACT>A perl interface for interacting with cPanel</ABSTRACT>' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <AUTHOR>cPanel, Inc. <integration@cpanel.net></AUTHOR>' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="HTTP::CookieJar" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="HTTP::Tiny" VERSION="0.042" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="IO::Socket::INET" VERSION="1.31" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="IO::Socket::SSL" VERSION="1.988" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="JSON::XS" VERSION="2" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="Test::Exception" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="Test::More" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <REQUIRE NAME="URI::Escape" VERSION="3" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="x86_64-linux-thread-multi-5.32" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> cPanel-PublicAPI.ppd $(NOECHO) $(ECHO) '</SOFTPKG>' >> cPanel-PublicAPI.ppd # --- MakeMaker pm_to_blib section: pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \ 'lib/cPanel/PublicAPI.pm' 'blib/lib/cPanel/PublicAPI.pm' \ 'lib/cPanel/PublicAPI.pod' 'blib/lib/cPanel/PublicAPI.pod' \ 'lib/cPanel/PublicAPI/Utils.pm' 'blib/lib/cPanel/PublicAPI/Utils.pm' \ 'lib/cPanel/PublicAPI/Utils.pod' 'blib/lib/cPanel/PublicAPI/Utils.pod' \ 'lib/cPanel/PublicAPI/WHM.pm' 'blib/lib/cPanel/PublicAPI/WHM.pm' \ 'lib/cPanel/PublicAPI/WHM.pod' 'blib/lib/cPanel/PublicAPI/WHM.pod' \ 'lib/cPanel/PublicAPI/WHM/API.pm' 'blib/lib/cPanel/PublicAPI/WHM/API.pm' \ 'lib/cPanel/PublicAPI/WHM/API.pod' 'blib/lib/cPanel/PublicAPI/WHM/API.pod' \ 'lib/cPanel/PublicAPI/WHM/CachedVersion.pm' 'blib/lib/cPanel/PublicAPI/WHM/CachedVersion.pm' \ 'lib/cPanel/PublicAPI/WHM/CachedVersion.pod' 'blib/lib/cPanel/PublicAPI/WHM/CachedVersion.pod' \ 'lib/cPanel/PublicAPI/WHM/DNS.pm' 'blib/lib/cPanel/PublicAPI/WHM/DNS.pm' \ 'lib/cPanel/PublicAPI/WHM/DNS.pod' 'blib/lib/cPanel/PublicAPI/WHM/DNS.pod' \ 'lib/cPanel/PublicAPI/WHM/JSONAPI.pm' 'blib/lib/cPanel/PublicAPI/WHM/JSONAPI.pm' \ 'lib/cPanel/PublicAPI/WHM/JSONAPI.pod' 'blib/lib/cPanel/PublicAPI/WHM/JSONAPI.pod' \ 'lib/cPanel/PublicAPI/WHM/Legacy.pm' 'blib/lib/cPanel/PublicAPI/WHM/Legacy.pm' \ 'lib/cPanel/PublicAPI/WHM/Legacy.pod' 'blib/lib/cPanel/PublicAPI/WHM/Legacy.pod' \ 'lib/cPanel/PublicAPI/WHM/XMLAPI.pm' 'blib/lib/cPanel/PublicAPI/WHM/XMLAPI.pm' \ 'lib/cPanel/PublicAPI/WHM/XMLAPI.pod' 'blib/lib/cPanel/PublicAPI/WHM/XMLAPI.pod' $(NOECHO) $(TOUCH) pm_to_blib # --- MakeMaker selfdocument section: # here so even if top_targets is overridden, these will still be defined # gmake will silently still work if any are .PHONY-ed but nmake won't static :: $(NOECHO) $(NOOP) dynamic :: $(NOECHO) $(NOOP) config :: $(NOECHO) $(NOOP) # --- MakeMaker postamble section: # End. META.json 0000644 00000002774 15125143347 0006204 0 ustar 00 { "abstract" : "A perl interface for interacting with cPanel", "author" : [ "cPanel, Inc. <integration@cpanel.net>" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010", "license" : [ "bsd" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "cPanel-PublicAPI", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "HTTP::CookieJar" : "0", "HTTP::Tiny" : "0.042", "IO::Socket::INET" : "1.31", "IO::Socket::SSL" : "1.988", "JSON::XS" : "2", "Test::Exception" : "0", "Test::More" : "0", "URI::Escape" : "3" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/CpanelInc/cPanel-PublicAPI/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/CpanelInc/cPanel-PublicAPI.git", "web" : "https://github.com/CpanelInc/cPanel-PublicAPI" } }, "version" : "2.8", "x_serialization_backend" : "JSON::PP version 2.27400_02" } ignore.txt 0000644 00000000176 15125143347 0006601 0 ustar 00 blib* Makefile Makefile.old Build Build.bat _build* pm_to_blib* *.tar.gz .lwpcookies cover_db pod2htm*.tmp cPanel-PublicAPI-* t/01-api-format.t 0000644 00000021347 15125143347 0007465 0 ustar 00 #!/usr/bin/perl use strict; use warnings; use Test::More; # last test to print use lib 't/lib'; use PubApiTest (); my $pubapi = PubApiTest->new( 'ip' => '127.0.0.1', 'usessl' => 1, 'user' => 'someuser', 'pass' => 'somepass', 'error_log' => '/dev/null', ); # test WHM $PubApiTest::test_config = { 'service' => 'whostmgr', 'uri' => '/json-api/loadavg', 'method' => 'POST', 'call' => 'whm_api-noform', 'return_format' => 'json', }; my $res = $pubapi->whm_api('loadavg'); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); $PubApiTest::test_config->{'test_formdata'} = 'hash'; $PubApiTest::test_config->{'formdata'} = { 'key' => 'value', 'api.version' => 1 }; $PubApiTest::test_config->{'call'} = 'whm_api-refform'; $res = $pubapi->whm_api( 'loadavg', { 'key' => 'value' } ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); $PubApiTest::test_config->{'test_formdata'} = 'hash'; $PubApiTest::test_config->{'formdata'} = { 'key' => 'value', 'api.version' => 0 }; $PubApiTest::test_config->{'call'} = 'whm_api-refapi0'; $res = $pubapi->whm_api( 'loadavg', $PubApiTest::test_config->{'formdata'} ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); $PubApiTest::test_config->{'test_formdata'} = 'hash'; $PubApiTest::test_config->{'formdata'} = { 'key' => 'value', 'api.version' => 1 }; $PubApiTest::test_config->{'call'} = 'whm_api-refapi1'; $res = $pubapi->whm_api( 'loadavg', $PubApiTest::test_config->{'formdata'} ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); $PubApiTest::test_config->{'test_formdata'} = 'string'; $PubApiTest::test_config->{'formdata'} = 'api.version=1&one&two'; $PubApiTest::test_config->{'call'} = 'whm_api-stringform'; $res = $pubapi->whm_api( 'loadavg', 'one&two' ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); $PubApiTest::test_config->{'test_formdata'} = 'string'; $PubApiTest::test_config->{'formdata'} = 'api.version=0&one&two'; $PubApiTest::test_config->{'call'} = 'whm_api-stringapi0'; $res = $pubapi->whm_api( 'loadavg', 'api.version=0&one&two' ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); delete $PubApiTest::test_config->{'formdata'}; delete $PubApiTest::test_config->{'test_formdata'}; $PubApiTest::test_config->{'return_format'} = 'json'; $res = $pubapi->whm_api( 'loadavg', undef, 'json' ); is( $res, '{"something":"somethinglese"}', 'raw JSON data returned raw correctly from whm_api' ); $PubApiTest::test_config->{'test_format'} = 'xml'; $PubApiTest::test_config->{'return_format'} = 'xml'; $PubApiTest::test_config->{'uri'} = '/xml-api/loadavg'; $res = $pubapi->whm_api( 'loadavg', undef, 'xml' ); is( $res, '<node><something>somethingelse</something></node>', 'raw XML data returned raw correctly from whm_api' ); # test API1 $PubApiTest::test_config = { 'service' => 'cpanel', 'uri' => '/json-api/cpanel', 'method' => 'GET', 'call' => 'api1-noargs', 'return_format' => 'json', 'test_formdata' => 'hash', }; # Without arguments $PubApiTest::test_config->{'formdata'} = { 'cpanel_jsonapi_module' => 'Test', 'cpanel_jsonapi_func' => 'test', 'cpanel_jsonapi_apiversion' => 1, }; my $call_config = { 'module' => 'Test', 'func' => 'test', }; $res = $pubapi->cpanel_api1_request( 'cpanel', $call_config ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); # with arguments $PubApiTest::test_config->{'call'} = 'api1-args'; $PubApiTest::test_config->{'formdata'}->{'arg-0'} = 'one'; $PubApiTest::test_config->{'formdata'}->{'arg-1'} = 'two'; $res = $pubapi->cpanel_api1_request( 'cpanel', $call_config, [ 'one', 'two' ] ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); # WHM # with arguments $PubApiTest::test_config->{'call'} = 'whm-api1-args'; $PubApiTest::test_config->{'formdata'}->{'cpanel_jsonapi_user'} = 'someuser'; $PubApiTest::test_config->{'service'} = 'whostmgr'; $call_config->{'user'} = 'someuser'; $res = $pubapi->cpanel_api1_request( 'whostmgr', $call_config, [ 'one', 'two' ] ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); # without arguments $PubApiTest::test_config->{'call'} = 'whm-api1-noargs'; delete $PubApiTest::test_config->{'formdata'}->{'arg-1'}; delete $PubApiTest::test_config->{'formdata'}->{'arg-0'}; $res = $pubapi->cpanel_api1_request( 'whostmgr', $call_config ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); # Test JSON $PubApiTest::test_config->{'call'} = 'whm-api1-rawjson'; $PubApiTest::test_config->{'return_format'} = 'json'; $res = $pubapi->cpanel_api1_request( 'whostmgr', $call_config, undef, 'json' ); is( $res, '{"something":"somethinglese"}', 'raw JSON data returned raw correctly from cpanel_api1_request' ); # Test XML $PubApiTest::test_config->{'call'} = 'whm-api1-rawxml'; $PubApiTest::test_config->{'test_format'} = 'xml'; $PubApiTest::test_config->{'return_format'} = 'xml'; $PubApiTest::test_config->{'uri'} = '/xml-api/cpanel'; $PubApiTest::test_config->{'formdata'} = { 'cpanel_xmlapi_user' => 'someuser', 'cpanel_xmlapi_module' => 'Test', 'cpanel_xmlapi_func' => 'test', 'cpanel_xmlapi_apiversion' => '1', }; $res = $pubapi->cpanel_api1_request( 'whostmgr', $call_config, [], 'xml' ); is( $res, '<node><something>somethingelse</something></node>', 'raw XML data returned raw correctly from cpanel_api1_request' ); # API2 $PubApiTest::test_config = { 'service' => 'cpanel', 'uri' => '/json-api/cpanel', 'method' => 'GET', 'call' => 'api2-noargs', 'return_format' => 'json', 'test_formdata' => 'hash', }; $PubApiTest::test_config->{'formdata'} = { 'cpanel_jsonapi_func' => 'test', 'cpanel_jsonapi_module' => 'Api2Test', 'cpanel_jsonapi_apiversion' => '2', }; $call_config = { 'module' => 'Api2Test', 'func' => 'test', }; # without args $res = $pubapi->cpanel_api2_request( 'cpanel', $call_config ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); # with args $PubApiTest::test_config->{'call'} = 'whm-api2-args'; my $args = { 'testing' => 'one two three', 'earth below' => 'us', }; foreach my $key ( keys %{$args} ) { $PubApiTest::test_config->{'formdata'}->{$key} = $args->{$key}; } $res = $pubapi->cpanel_api2_request( 'cpanel', $call_config, $args ); is( ref $res, 'HASH', 'Returned format ok for ' . $PubApiTest::test_config->{'call'} ); # XML/JSON response tests delete $PubApiTest::test_config->{'formdata'}->{'testing'}; delete $PubApiTest::test_config->{'formdata'}->{'earth below'}; $PubApiTest::test_config->{'call'} = 'api2-rawjson'; $res = $pubapi->cpanel_api2_request( 'cpanel', $call_config, undef, 'json' ); is( $res, '{"something":"somethinglese"}', 'raw JSON data returned raw correctly from cpanel_api2_request' ); #xml $PubApiTest::test_config->{'call'} = 'api2-rawxml'; $PubApiTest::test_config->{'formdata'} = { 'cpanel_xmlapi_module' => 'Api2Test', 'cpanel_xmlapi_func' => 'test', 'cpanel_xmlapi_apiversion' => '2' }; $PubApiTest::test_config->{'format'} = 'xml'; $PubApiTest::test_config->{'return_format'} = 'xml'; $PubApiTest::test_config->{'uri'} = '/xml-api/cpanel'; $res = $pubapi->cpanel_api2_request( 'cpanel', $call_config, undef, 'xml' ); is( $res, '<node><something>somethingelse</something></node>', 'raw XML data returned raw correctly from cpanel_api2_request' ); # test call failure situations $PubApiTest::test_config->{'badcall'} = 'whmapi'; $pubapi->whm_api('version'); like( $pubapi->{'error'}, qr/cPanel::PublicAPI::whm_api was called with the invalid API call of/, 'whm_api invalid call checking works' ); $PubApiTest::test_config->{'badcall'} = 'cpanelapi1'; $pubapi->cpanel_api1_request( 'cpanel', { 'module' => 'test', 'func' => 'test' } ); like( $pubapi->{'error'}, qr/cPanel::PublicAPI::cpanel_api1_request was called with the invalid API1 call of:/, 'cpanel_api1_request invalid call checking works' ); $PubApiTest::test_config->{'badcall'} = 'cpanelapi2'; $pubapi->cpanel_api2_request( 'cpanel', { 'module' => 'test', 'func' => 'test' } ); like( $pubapi->{'error'}, qr/cPanel::PublicAPI::cpanel_api2_request was called with the invalid API2 call of:/, 'cpanel_api1_request invalid call checking works' ); done_testing(); t/05-api-query_tokens.t 0000644 00000010451 15125143347 0010723 0 ustar 00 #!/usr/bin/perl # Copyright 2017, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use strict; use warnings; use Test::More; # last test to print use cPanel::PublicAPI (); my @getpwuid = getpwuid($>); my $homedir = $getpwuid[7]; my $user = $getpwuid[0]; if ( !-d '/usr/local/cpanel' ) { plan skip_all => 'This test requires that cPanel and WHM are installed on a server'; } if ( !-e $homedir . '/.accesshash' ) { plan skip_all => 'This test requires that an account hash is defined (see "Setup Remote Access Keys" in WHM)'; } check_cpanel_version(63) or plan skip_all => 'This test requires cPanel version 64 or higher'; my $pubapi = cPanel::PublicAPI->new( 'ssl_verify_mode' => 0 ); if ( !-e '/var/cpanel/users/papiunit' ) { plan tests => 5; my $password = generate_password(); my $res = $pubapi->whm_api( 'createacct', { 'username' => 'papiunit', 'password' => $password, 'domain' => 'cpanel-public-api-test.acct', 'reseller' => 1, } ); like( $res->{'metadata'}->{'reason'}, qr/Account Creation Ok/, 'Test account created' ); _test_api_token_as_reseller( 'papiunit', $password ); $res = $pubapi->whm_api( 'removeacct', { 'user' => 'papiunit', } ); like( $res->{'metadata'}->{'reason'}, qr/papiunit account removed/, 'Test Account Removed' ); } else { plan skip_all => 'Unable to create test account. It already exists'; } sub _test_api_token_as_reseller { my ( $reseller, $password ) = @_; # Create the API Token my $reseller_api = cPanel::PublicAPI->new( 'user' => $reseller, 'pass' => $password, 'ssl_verify_mode' => 0 ); my $res = $reseller_api->whm_api( 'api_token_create', { 'token_name' => 'my_token' } ); ok( $res->{'metadata'}->{'result'}, 'Successfully called api_token_create API call as reseller' ); my $plaintext_token = $res->{'data'}->{'token'}; my $pub_api_with_token = cPanel::PublicAPI->new( 'user' => $reseller, 'api_token' => 'this is so wrong', 'ssl_verify_mode' => 0 ); eval { $pub_api_with_token->whm_api('loadavg') }; ok( $@, 'API call fails with wrong API token' ); $pub_api_with_token->api_token($plaintext_token); $res = $pub_api_with_token->whm_api('loadavg'); ok( defined $res->{'one'}, 'API call successfully made using the correct token' ); } sub generate_password { my @chars = ( 'A' .. 'Z', 'a' .. 'z', '0' .. '9' ); my $pass = ''; foreach ( 1 .. 32 ) { $pass .= $chars[ int rand @chars ]; } return $pass; } sub check_cpanel_version { my $min_version = shift; open( my $version_fh, '<', '/usr/local/cpanel/version' ) || return 0; my $version = do { local $/; <$version_fh> }; chomp $version; my ( $maj, $min, $rev, $sup ) = split /[\._]/, $version; return 1 if $min >= $min_version; return 0; } t/pod-coverage.t 0000644 00000001220 15125143347 0007547 0 ustar 00 use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Release tests not required for installation" ); } # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); t/check-changes.t 0000644 00000000420 15125143347 0007660 0 ustar 00 #!/usr/bin/env perl use Test::More; plan skip_all => 'Release tests not required for installation' if not $ENV{RELEASE_TESTING}; eval { require Test::CheckChanges }; plan skip_all => 'Test::CheckChanges required for this test' if $@; Test::CheckChanges::ok_changes(); t/manifest.t 0000644 00000000421 15125143347 0007004 0 ustar 00 #!perl -T use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Release tests not required for installation" ); } eval "use Test::CheckManifest 0.9"; plan skip_all => "Test::CheckManifest 0.9 required" if $@; ok_manifest(); t/pod.t 0000644 00000000525 15125143347 0005765 0 ustar 00 #!perl -T use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Release tests not required for installation" ); } # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); t/02-construct.t 0000755 00000016516 15125143347 0007460 0 ustar 00 #!/usr/bin/perl # Copyright 2017, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use strict; use warnings; use Test::More; use Test::Exception; use cPanel::PublicAPI (); my @getpwuid = getpwuid($>); my $homedir = $getpwuid[7]; my $user = $getpwuid[0]; # test default settings if ( !-e $homedir . '/.accesshash' ) { $ENV{'REMOTE_PASSWORD'} = 'b4r!' if !defined $ENV{'REMOTE_PASSWORD'}; $ENV{'SERVER_SOFTWARE'} = 'cpsrvd fakeout'; } check_options(); check_options( 'debug' => 1, 'error_log' => '/dev/null' ); check_options( 'timeout' => 150 ); check_options( 'usessl' => 0 ); check_options( 'ip' => '4.2.2.2' ); check_options( 'host' => 'zomg.cpanel.net' ); check_options( 'error_log' => '/dev/null' ); check_options( 'user' => 'bar' ); check_options( 'pass' => 'f00!3Df@' ); my $accesshash = 'sdflkjl sdafjkl sdlfkjh'; check_options( 'accesshash' => $accesshash ); check_options( 'api_token' => 'sdfkjl' ); throws_ok { check_options( 'api_token' => 'sdfkjl', 'accesshash' => $accesshash ); } qr/You cannot specify both an accesshash and an API token/, 'Dies when specifying both an accesshash and API token'; my $http_tiny_creator_called; my $pubapi = cPanel::PublicAPI->new( 'error_log' => '/dev/null', http_tiny_creator => sub { $http_tiny_creator_called = 1; return HTTP::Tiny->new(@_); }, ); ok( $http_tiny_creator_called, 'http_tiny_creator is called' ); $pubapi->error('random string'); is( $pubapi->{'error'}, 'random string', 'Error variable is stored correctly' ); $pubapi->_init(); is( ref $cPanel::PublicAPI::CFG{'uri_encoder_func'}, 'CODE', 'URI Encoder Detected' ); $pubapi->_init_serializer(); is( ref $cPanel::PublicAPI::CFG{'api_decode_func'}, 'CODE', 'Serializer parse function detected' ); like( $cPanel::PublicAPI::CFG{'serializer_module'}, qr/^JSON/, 'Serializer Module is Named' ); is( $cPanel::PublicAPI::CFG{'serializer'}, 'json', 'Serailizer format is correct' ); my $query_result = $pubapi->format_http_query( { 'one' => 'uno', 'two' => 'dos' } ); is( $query_result, 'one=uno&two=dos', 'format_http_query' ); $pubapi->set_debug(1); is( $pubapi->{'debug'}, 1, 'set_debug accessor' ); $pubapi->user('someuser'); is( $pubapi->{'user'}, 'someuser', 'user accessor' ); $pubapi->{'accesshash'} = 'deleteme'; $pubapi->pass('somepass'); is( $pubapi->{'pass'}, 'somepass', 'pass accessor' ); ok( !exists $pubapi->{'accesshash'}, 'pass accessor deletes accesshash scalar' ); $pubapi->accesshash('onetwothreefour'); is( $pubapi->{'accesshash'}, 'onetwothreefour', 'accesshash accessor' ); ok( !exists $pubapi->{'pass'}, 'accesshash accessor deletes pass scalar' ); $pubapi->api_token('fivesixseveneight'); is( $pubapi->{'accesshash'}, 'fivesixseveneight', 'api_token accessor' ); ok( !exists $pubapi->{'pass'}, 'api_token accessor deletes pass scalar' ); my $header_string = $pubapi->format_http_headers( { 'Authorization' => 'Basic cm9vdDpsMGx1cnNtNHJ0IQ==' } ); is( $header_string, "Authorization: Basic cm9vdDpsMGx1cnNtNHJ0IQ==\r\n", 'format_http_headers is ok' ); can_ok( $pubapi, 'new', 'set_debug', 'user', 'pass', 'accesshash', 'api_token', 'whm_api', 'api_request', 'cpanel_api1_request', 'cpanel_api2_request', '_total_form_length', '_init_serializer', '_init', 'error', 'debug', 'format_http_query' ); done_testing(); # This subroutine is intended to check the options sent to a publicAPI instance. # The first parameter is the publicAPI instance, the rest should be hash key-pairs that allow you to # override default settings sub check_options { my %OPTS = @_; my $pubapi = cPanel::PublicAPI->new(%OPTS); isa_ok( $pubapi, 'cPanel::PublicAPI' ); if ( defined $OPTS{'debug'} ) { is( $pubapi->{'debug'}, $OPTS{'debug'}, 'debug constructor option' ); } else { is( $pubapi->{'debug'}, '0', 'debug default' ); } if ( defined $OPTS{'timeout'} ) { is( $pubapi->{'timeout'}, $OPTS{'timeout'}, 'timeout constructor option' ); } else { is( $pubapi->{'timeout'}, 300, 'timeout default' ); } if ( defined $OPTS{'usessl'} ) { is( $pubapi->{'usessl'}, $OPTS{'usessl'}, 'usessl constructor option' ); } else { is( $pubapi->{'usessl'}, 1, 'usessl default' ); } if ( defined $OPTS{'ip'} ) { is( $pubapi->{'ip'}, $OPTS{'ip'}, 'ip constructor option' ); } elsif ( defined $OPTS{'host'} ) { is( $pubapi->{'host'}, $OPTS{'host'}, 'host constructor option' ); } else { is( $pubapi->{'ip'}, '127.0.0.1', 'ip default' ); } if ( defined $OPTS{'error_log'} ) { ok( $pubapi->{'error_fh'} ne \*STDERR, 'error_log is not STDERR' ); } else { is( $pubapi->{'error_fh'}, \*STDERR, 'error_log is set to STDERR' ); } if ( defined $OPTS{'user'} ) { is( $pubapi->{'user'}, $OPTS{'user'}, 'user constructor option' ); } else { is( $pubapi->{'user'}, $user, 'user default' ); } if ( defined $OPTS{'pass'} ) { is( $pubapi->{'pass'}, $OPTS{'pass'}, 'pass constructor option' ); } elsif ( defined $OPTS{'api_token'} ) { is( $pubapi->{'accesshash'}, $OPTS{'api_token'}, 'api_token constructor option' ); } elsif ( defined $OPTS{'accesshash'} ) { my $accesshash = $OPTS{'accesshash'}; $accesshash =~ s/[\r\n]//g; is( $pubapi->{'accesshash'}, $accesshash, 'accesshash constructor option' ); } else { if ( -e $homedir . './accesshash' ) { my $accesshash = get_accesshash(); is( $pubapi->{'accesshash'}, $accesshash, 'accesshash default' ); } else { is( $pubapi->{'pass'}, $ENV{'REMOTE_PASSWORD'}, 'password default' ); } } } sub get_accesshash { my $accesshash; open( my $ah_fh, '<', $homedir . '/.accesshash' ); foreach my $line ( readline($ah_fh) ) { $accesshash .= $line; } $accesshash =~ s/[\r\n]//; return $accesshash; } t/04-tfa-sessions.t 0000644 00000014450 15125143347 0010044 0 ustar 00 #!/usr/bin/perl # Copyright 2017, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use strict; use warnings; use Test::More; # last test to print use cPanel::PublicAPI (); my @getpwuid = getpwuid($>); my $homedir = $getpwuid[7]; my $user = $getpwuid[0]; if ( !-d '/usr/local/cpanel' ) { plan skip_all => 'This test requires that cPanel and WHM are installed on a server'; } if ( !-e $homedir . '/.accesshash' ) { plan skip_all => 'This test requires that an account hash is defined (see "Setup Remote Access Keys" in WHM)'; } check_cpanel_version() or plan skip_all => 'This test requires cPanel version 54 or higher'; eval { require MIME::Base32; require Digest::SHA; 1; } or do { plan skip_all => 'This test requires the MIME::Base32 and Digest::SHA modules'; }; unshift @INC, '/usr/local/cpanel'; require Cpanel::Security::Authn::TwoFactorAuth::Google; my $pubapi = check_api_access_and_config(); if ( !-e '/var/cpanel/users/papiunit' ) { my $password = generate_password(); my $res = $pubapi->whm_api( 'createacct', { 'username' => 'papiunit', 'password' => $password, 'domain' => 'cpanel-public-api-test.acct', 'reseller' => 1, } ); like( $res->{'metadata'}->{'reason'}, qr/Account Creation Ok/, 'Test account created' ); $res = $pubapi->whm_api( 'setacls', { 'reseller' => 'papiunit', 'acl-create-acct' => 1, } ); ok( $res->{'metadata'}->{'result'}, 'Assigned create-acct ACL successfully' ); _test_tfa_as_reseller( 'papiunit', $password ); $res = $pubapi->whm_api( 'removeacct', { 'user' => 'papiunit', } ); like( $res->{'metadata'}->{'reason'}, qr/papiunit account removed/, 'Test Account Removed' ); } else { plan skip_all => 'Unable to create test account. It already exists'; } done_testing(); sub _test_tfa_as_reseller { my ( $reseller, $password ) = @_; my $reseller_api = cPanel::PublicAPI->new( 'user' => $reseller, 'pass' => $password, 'ssl_verify_mode' => 0 ); my $res = $reseller_api->whm_api( 'twofactorauth_generate_tfa_config', {} ); ok( $res->{'metadata'}->{'result'}, 'Successfully called generate tfa config API call as reseller' ); my $tfa_secret = $res->{'data'}->{'secret'}; my $google_auth = Cpanel::Security::Authn::TwoFactorAuth::Google->new( { 'secret' => $tfa_secret, 'account_name' => '', 'issuer' => '' } ); $res = $reseller_api->whm_api( 'twofactorauth_set_tfa_config', { 'secret' => $tfa_secret, 'tfa_token' => $google_auth->generate_code(), } ); ok( $res->{'metadata'}->{'result'}, '2FA successfully configured for reseller' ); eval { $reseller_api->whm_api('loadavg') }; ok( $@, 'API calls fail without a 2FA session established' ); $reseller_api->establish_tfa_session( 'whostmgr', $google_auth->generate_code() ); $res = $reseller_api->whm_api('loadavg'); ok( defined $res->{'one'}, 'API call successfully made after establishing 2FA session' ); } sub generate_password { my @chars = ( 'A' .. 'Z', 'a' .. 'z', '0' .. '9' ); my $pass = ''; foreach ( 1 .. 32 ) { $pass .= $chars[ int rand @chars ]; } return $pass; } sub check_cpanel_version { open( my $version_fh, '<', '/usr/local/cpanel/version' ) || return 0; my $version = do { local $/; <$version_fh> }; chomp $version; my ( $maj, $min, $rev, $sup ) = split /[\._]/, $version; return 1 if $min >= 53; return 0; } sub check_api_access_and_config { open( my $config_fh, '<', '/var/cpanel/cpanel.config' ) || BAIL_OUT('Could not load /var/cpanel/cpanel.config'); my $securitypolicy_enabled = 0; my $securitypolicy_xml_api_enabled = 0; while ( my $line = readline($config_fh) ) { next if $line !~ /=/; chomp $line; my ( $key, $value ) = split( /=/, $line, 2 ); if ( $key eq 'SecurityPolicy::TwoFactorAuth' ) { $securitypolicy_enabled = 1 if $value; } elsif ( $key eq 'SecurityPolicy::xml-api' ) { $securitypolicy_xml_api_enabled = 1 if $value; } } plan skip_all => '2FA security policy is disabled on the server' if !$securitypolicy_enabled; plan skip_all => 'Security policies do not apply to API calls on the server' if !$securitypolicy_xml_api_enabled; my $pubapi = cPanel::PublicAPI->new( 'ssl_verify_mode' => 0 ); my $res = eval { $pubapi->whm_api('applist') }; if ($@) { plan skip_all => "Failed to verify API access as current user: $@"; } if ( exists $res->{'data'}->{'app'} && ref $res->{'data'}->{'app'} eq 'ARRAY' ) { return $pubapi if grep { $_ eq 'createacct' } @{ $res->{'data'}->{'app'} }; } plan skip_all => "Current user doesn't appear to have proper privileges"; } t/cpan-changes.t 0000644 00000000423 15125143347 0007527 0 ustar 00 #!/usr/bin/env perl use Test::More; plan skip_all => 'Release tests not required for installation' if not $ENV{RELEASE_TESTING}; eval { require Test::CPAN::Changes }; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; Test::CPAN::Changes::changes_ok(); t/00-load.t 0000644 00000000266 15125143347 0006341 0 ustar 00 #!perl -T use Test::More tests => 1; BEGIN { use_ok('cPanel::PublicAPI') || print "Bail out! "; } diag("Testing cPanel::PublicAPI $cPanel::PublicAPI::VERSION, Perl $], $^X"); t/lib/PubApiTest.pm 0000644 00000004772 15125143347 0010152 0 ustar 00 package PubApiTest; use cPanel::PublicAPI; @PubApiTest::ISA = qw( cPanel::PublicAPI ); use strict; use warnings; use Test::More; # This is used to specify what a specific call be using our $test_config = {}; # Used to test the actual input to api_request sub api_request { my ( $self, $service, $uri, $method, $formdata ) = @_; undef $self->{'error'}; if ( defined $test_config->{'badcall'} ) { my $badcall_return; if ( $test_config->{'badcall'} eq 'whmapi' ) { $badcall_return = '{"error":"Unknown App Requested: asdf"}'; } elsif ( $test_config->{'badcall'} eq 'cpanelapi2' ) { $badcall_return = '{"cpanelresult":{"apiversion":2,"error":"Could not find function \'test\' in module \'Test\'","func":"test","module":"Test"}}'; } elsif ( $test_config->{'badcall'} eq 'cpanelapi1' ) { $badcall_return = '{"apiversion":"1","type":"event","module":"Test","func":"test","source":"module","data":{"result":""},"event":{"reason":"Test::test() failed: Undefined subroutine &Cpanel::Test::Test_test called at (eval 21) line 1.\n","result":0}}'; } return 0, 'failed', \$badcall_return; } is( $service, $test_config->{'service'}, 'Service is correct for ' . $test_config->{'call'} ); is( $uri, $test_config->{'uri'}, 'URI is correct for ' . $test_config->{'call'} ); is( $method, $test_config->{'method'}, 'Method is correct for ' . $test_config->{'call'} ); if ( exists $test_config->{'test_formdata'} && $test_config->{'test_formdata'} eq 'hash' ) { is_deeply( $formdata, $test_config->{'formdata'}, 'Formdata is correct for ' . $test_config->{'call'} ); } elsif ( exists $test_config->{'test_formdata'} && $test_config->{'test_formdata'} eq 'string' ) { is( $formdata, $test_config->{'formdata'}, 'Fromdata is correct for ' . $test_config->{'call'} ); } my $return_format = 'string'; if ( $uri =~ /\/json-api\// ) { $return_format = 'json'; } elsif ( $uri =~ /\/xml-api\// ) { $return_format = 'xml'; } is( $return_format, $test_config->{'return_format'}, 'Serialization format correct for ' . $test_config->{'call'} ); my $return; if ( $return_format eq 'json' ) { $return = '{"something":"somethinglese"}'; } elsif ( $return_format eq 'xml' ) { $return = '<node><something>somethingelse</something></node>'; } else { $return = 'some data goes here'; } return '1', 'ok', \$return; } 1; t/03-api-query.t 0000644 00000015542 15125143347 0007344 0 ustar 00 #!/usr/bin/perl use strict; use warnings; use Test::More; # last test to print use cPanel::PublicAPI (); my @getpwuid = getpwuid($>); my $homedir = $getpwuid[7]; my $user = $getpwuid[0]; if ( !-d '/usr/local/cpanel' ) { plan skip_all => 'This test requires that cPanel and WHM are installed on a server'; } if ( !-e $homedir . '/.accesshash' ) { plan skip_all => 'This test requires that an account hash is defined (see "Setup Remote Access Keys" in WHM)'; } # SSL tests my $pubapi = check_api_access(); isa_ok( $pubapi, 'cPanel::PublicAPI' ); my $res = $pubapi->api_request( 'whostmgr', '/xml-api/loadavg', 'GET', {} ); like( $$res, qr/<loadavg>\s*<one>\d+\.\d+<\/one>\s*<five>\d+\.\d+<\/five>\s*<fifteen>\d+\.\d+<\/fifteen>\s*<\/loadavg>*/, 'whm get no params' ); # Create the test regex for reuse my $createacct_regex = qr/<statusmsg>.*is a reserved username.*<\/statusmsg>/; $res = $pubapi->api_request( 'whostmgr', '/xml-api/createacct', 'GET', { 'username' => 'test', 'domain' => 'test.com' } ); like( $$res, $createacct_regex, 'ssl whm get hash params' ); $res = $pubapi->api_request( 'whostmgr', '/xml-api/createacct', 'GET', 'username=test&domain=test.com' ); like( $$res, $createacct_regex, 'ssl whm get string params' ); $res = $pubapi->api_request( 'whostmgr', '/xml-api/createacct', 'POST', { 'username' => 'test', 'domain' => 'test.com' } ); like( $$res, $createacct_regex, 'ssl whm post hash params' ); $res = $pubapi->api_request( 'whostmgr', '/xml-api/createacct', 'POST', 'username=test&domain=test.com' ); like( $$res, $createacct_regex, 'ssl whm post string params' ); # Create account for cpanel & reseller testing if ( !-e '/var/cpanel/users/papiunit' ) { my $password = generate_password(); $res = $pubapi->api_request( 'whostmgr', '/xml-api/createacct', 'POST', { 'username' => 'papiunit', 'password' => $password, 'domain' => 'cpanel-public-api-test.acct', } ); like( $$res, qr/Account Creation Ok/, 'Test account created' ); # skip is not used here due to the other code contained within this block. if ( $$res =~ /Account Creation Ok/ ) { my $cp_pubapi = cPanel::PublicAPI->new( 'user' => 'papiunit', 'pass' => $password, 'ssl_verify_mode' => 0, ); isa_ok( $cp_pubapi, 'cPanel::PublicAPI' ); is( $cp_pubapi->{'operating_mode'}, 'session', 'Session operating mode is set properly when user/pass is used' ); ok( !defined $cp_pubapi->{'cookie_jars'}->{'cpanel'}, 'no cookies have been established for the cpanel service before the first query is made' ); ok( !defined $cp_pubapi->{'security_tokens'}->{'cpanel'}, 'no security_token has been set for the cpanel service before the first query is made' ); $res = $cp_pubapi->api_request( 'cpanel', '/xml-api/cpanel', 'GET', 'cpanel_xmlapi_module=StatsBar&cpanel_xmlapi_func=stat&display=diskusage' ); like( $$res, qr/<module>StatsBar<\/module>/, 'ssl cpanel get string params' ); my $security_token = $cp_pubapi->{'security_tokens'}->{'cpanel'}; ok( $security_token, 'security token for cpanel has been set upon first request' ); $res = $cp_pubapi->api_request( 'cpanel', '/xml-api/cpanel', 'GET', { 'cpanel_xmlapi_module' => 'StatsBar', 'cpanel_xmlapi_func' => 'stat', 'display' => 'diskusage' } ); like( $$res, qr/<module>StatsBar<\/module>/, 'ssl cpanel post hash params' ); is( $cp_pubapi->{'security_tokens'}->{'cpanel'}, $security_token, 'security_token was not changed when the second cpanel request was made' ); $res = $cp_pubapi->api_request( 'cpanel', '/xml-api/cpanel', 'POST', 'cpanel_xmlapi_module=StatsBar&cpanel_xmlapi_func=stat&display=diskusage' ); like( $$res, qr/<module>StatsBar<\/module>/, 'ssl cpanel get string params' ); $res = $cp_pubapi->api_request( 'cpanel', '/xml-api/cpanel', 'POST', { 'cpanel_xmlapi_module' => 'StatsBar', 'cpanel_xmlapi_func' => 'stat', 'display' => 'diskusage' } ); like( $$res, qr/<module>StatsBar<\/module>/, 'ssl cpanel post hash params' ); $res = $pubapi->api_request( 'whostmgr', '/xml-api/removeacct', 'GET', { 'user' => 'papiunit' } ); like( $$res, qr/papiunit account removed/, 'Test Account Removed' ); } } my $cp_conf = load_cpanel_config(); my $nonssl_tests = 0; if ( !$cp_conf->{'requiressl'} && !$cp_conf->{'alwaysredirecttossl'} ) { $nonssl_tests = 1; } SKIP: { skip 'nonssl querying is not supported on this server', 5, unless $nonssl_tests; my $unsecure = cPanel::PublicAPI->new( 'usessl' => 0 ) if $nonssl_tests; isa_ok( $unsecure, 'cPanel::PublicAPI' ); $res = $unsecure->api_request( 'whostmgr', '/xml-api/loadavg', 'GET' ) if $nonssl_tests; like( $$res, qr/<loadavg>\s*<one>\d+\.\d+<\/one>\s*<five>\d+\.\d+<\/five>\s*<fifteen>\d+\.\d+<\/fifteen>\s*<\/loadavg>*/, 'nossl whm get no params' ); $res = $unsecure->api_request( 'whostmgr', '/xml-api/createacct', 'GET', { 'username' => 'test', 'domain' => 'test.com' } ); like( $$res, $createacct_regex, 'nossl whm get hash params' ) if $nonssl_tests; $res = $unsecure->api_request( 'whostmgr', '/xml-api/createacct', 'GET', 'username=test&domain=test.com' ); like( $$res, $createacct_regex, 'nossl whm get string params' ) if $nonssl_tests; $res = $unsecure->api_request( 'whostmgr', '/xml-api/createacct', 'POST', { 'username' => 'test', 'domain' => 'test.com' } ); like( $$res, $createacct_regex, 'nossl whm post hash params' ) if $nonssl_tests; $res = $unsecure->api_request( 'whostmgr', '/xml-api/createacct', 'POST', 'username=test&domain=test.com' ); like( $$res, $createacct_regex, 'nossl whm post string params' ) if $nonssl_tests; } done_testing(); # used for generating the password of a test account sub generate_password { my @chars = ( 'A' .. 'Z', 'a' .. 'z', '0' .. '9' ); my $pass = ''; foreach ( 1 .. 32 ) { $pass .= $chars[ int rand @chars ]; } return $pass; } sub load_cpanel_config { my %cpanel_config; open( my $config_fh, '<', '/var/cpanel/cpanel.config' ) || BAIL_OUT('Could not load /var/cpanel/cpanel.config'); foreach my $line ( readline($config_fh) ) { next if $line !~ /=/; chomp $line; my ( $key, $value ) = split( /=/, $line, 2 ); $cpanel_config{$key} = $value; } return \%cpanel_config; } sub check_api_access { my $pubapi = cPanel::PublicAPI->new( 'ssl_verify_mode' => 0 ); my $res = eval { $pubapi->whm_api('applist') }; if ($@) { plan skip_all => "Failed to verify API access as current user: $@"; } if ( exists $res->{'data'}->{'app'} && ref $res->{'data'}->{'app'} eq 'ARRAY' ) { return $pubapi if grep { $_ eq 'createacct' } @{ $res->{'data'}->{'app'} }; } plan skip_all => "Current user doesn't appear to have proper privileges"; } README.mkdn 0000644 00000041765 15125143347 0006376 0 ustar 00 [](https://travis-ci.org/CpanelInc/cPanel-PublicAPI) # NAME cPanel::PublicAPI - A perl interface for interacting with cPanel # SYNOPSIS use cPanel::PublicAPI; # Auto detect authentication information my $cp = cPanel::PublicAPI->new(); # or specify a user/password my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'pass' => 'somepass' ); # or specify an accesshash my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'accesshash' => $accesshash ); # or specify an API token my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'api_token' => $api_token ); # Perform an xml-api query $cp->whm_api('listaccts'); # Pass parameters to the xml-api $cp->whm_api('createacct', {'username' => 'someuser', 'password' => 's0m3P4$$w()Rd' } ); # Return JSON from xml-api (rather than a hash reference) $cp->whm_api('version', undef, 'json'); # Perform an API2 query $cp->cpanel_api2_request('whostmgr', { 'module' => 'Email', 'func' => 'listpopswithdisk', 'user' => 'someuser', } ); # Perform an API2 query when authenticated as a user $cp->cpanel_api2_request('cpanel', { 'module' => 'Email', 'func' => 'listpopswithdisk', } ); # Pass parameters to an API2 call $cp->cpanel_api2_request('cpanel' { 'module' => 'Email', 'func' => 'addpop', }, { 'domain' => 'domain.com', 'email' => 'username', 'password' => 'SojmASDM(#(Jinasifodanosd', 'quota' => 200 }, ); # Perform an API1 query $cp->cpanel_api1_request('whostmgr', { 'module' => 'LastLogin', 'func' => 'lastlogin', 'user' => 'someuser' } ); # Pass parameters to an API1 query $cp->cpanel_api1_request('cpanel', { 'module' => 'Mysql', 'func' => 'adduserdb', }, [ 'somedb', 'somedbuser', 'ALL' ] ); # perform an HTTP GET request against a URL $cp->api_request('whostmgr', '/xml-api/loadavg', 'GET'); # perform an HTTP GET request with parameters $cp->api_request('whostmgr', '/xml-api/createacct', 'GET', {'username' => 'someuser', domain => 'domain.com'} ); # perform an HTTP POST request (with parameters) $cp->api_request('whostmgr', '/xml-api/createacct', 'POST', {'username' => 'someuser', domain => 'domain.com'} ); # DESCRIPTION cPanel::PublicAPI is a supported interface for interacting with cPanel's APIs over HTTP. This allows you to query either WHM or cPanel accounts from a perl interface. The purpose of this module is to provide an easy-to-use interface into cPanel's various APIs without requiring much knowledge of how they work. ## Object Construction a cPanel::PublicAPI object is constructed with the new() method. my $publicapi = cPanel::PublicAPI->new(); When passed no parameters, this will create the object using the accesshash in ~/.accesshash. If no .accesshash file exists, it will attempt to use the REMOTE\_PASS environment variable. If the REMOTE\_PASS variable is not defined, object creation will error out. ### new() parameters options for new() are specified as a hash reference, the following parameters are supported: - user - The username to authenticate as. - pass - The password to use for authentication. - accesshash - The accesshash to use for authentication. - api\_token - The API token to use for authentication. - timeout - The length of time (in seconds) before an http request should time out. Default to 300. - ip - The IP to be queried. defaults to 127.0.0.1, if host is defined it will take precedence over the 'ip' parameter. - host - The hostname to be queried. This will take precedence over the 'ip' parameter. - usessl - 1 or 0, Indicates whether communication should be performed over SSL or not (default to 1). - ssl\_verify\_mode - 1 or 0, Indicates whether to verify SSL certificates or not. (default to 1). - error\_log - Path to where you want debug and error logging information to be written to. If this is not defined or the module is unable to open the path in question, it will default to STDERR. - debug - Enables debug logging, which will place considerably more information into the error\_log. ### Notes about authentication There are three sets of credentials that can be used to authenticate to WHM. First we have the basic user/password combinations: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); Next is API token authentication. To create an API token, visit "Manage API Tokens" in WHM and click Generate Token. Fill out the form and click Generate. Your token will appear in a special notice. Make certain that you save your API token in a safe location on your workstation. You cannot access the token after you navigate away from the interface or refresh the API Tokens table. To use an API token with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'api_token' => $string_containing_api_token ); Last is accesshash authentication. To configure accesshashes, visit “Setup remote access key” in WHM which will generate an accesshash for your server if one does not already exist. It will store the generated accesshash in ~/.accesshash. To use an accesshash with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'accesshash' => $string_containing_access_hash ); It should be noted that the accesshash can contain newlines in it. Newlines will be stripped by the object when it attempts to perform a query. **NOTE:** Accesshash authentication is deprecated in cPanel & WHM version 64. ### Dependencies This module will fall back on different modules if one fails to load. This allows for compatibility with cPanel & WHM's internal perl parser and maintain compatibility with a standard perl implementation. The order that it will fall back on serialization modules is: - JSON::Syck - JSON - JSON::XS - JSON::PP If you installed this module via CPAN, this should never be an issue. If you are wishing to use this module on a system where you do not have access to compiled modules, JSON::PP is the recommended serializer. # Two-Factor Authentication (2FA) cPanel version 54 and above allows users to configure 2FA on their accounts - this security policy requires that the API queries are performed after authenticating and establishing a session. The workflow to accomodate 2FA will be as so: use cPanel::PublicAPI; use lib '/usr/local/cpanel'; use Cpanel::Security::Authn::TwoFactorAuth::Google (); # only available in 11.54+ my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); my $google_auth = Cpanel::Security::Authn::TwoFactorAuth::Google->new( { 'account_name' => 'foo', 'secret' => $user_2fa_secret, 'issuer' => '' } ); $pubapi->establish_tfa_session('whostmgr', $google_auth->generate_code()); $pubapi->whm_api('applist'); Anytime you change services (e.g. from 'whostmgr' to 'cpanel'), you must establish the 2FA session for the new service. eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "failed cause 2fa session wasn't established\n" if $@; $pubapi->establish_tfa_session('cpanel', $google_auth->generate_code()); eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "success\n" if not $@; **NOTE**: Additionally, since accesshash authentication is not allowed to establish sessions, you must use the 'user'/'pass' authentication in order to make API requests as a user with 2FA configured. # Important Methods ## Querying the xml-api - whm\_api() The XML-API is WHM's API used for administrative functions is handled via the whm\_api() method. The syntax for whmapi is: $cp->whm_api($call [, \%formdata, $format ] ); The meaning of these parameters is: - $call - The XML-API call you wish to query - $formdata - The parameters for the XML-API call in question, f.ex. for suspendacct, here you would pass in a hashref containing “user” and “reason”. If there are no parameters, this can be undef or a blank hash. - $format - The requested response format. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. By default, WHM API v1 is used. If, for legacy reasons, you need to use v0, please set the `api.version` key to 0 in the formdata parameter. For more information on what calls are available and how they can be referenced, please see the xml-api documentation at [http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi](http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi). ## Querying cPanel's APIs cPanel supports two APIs, designated "API1" and "API2". cPanel API calls are seperate into Modules, these module names relate to modules within the Cpanel namespace on a cPanel server. Each module defines a set of functions that are from either API1 or API2 (or both). There are two distinct differences between API1 and API2: - API1 Takes in ordered parameters and returns strings - API2 uses named parameters and returns hashes or arrays of hashes Within the context of the public api, calling a function from API1 or API2 will always return a hash, but the specific data returned from the API call will be contained within the 'data' key of the response. For more information on the differences between API1 and API2 please see the documentation: [http://docs.cpanel.net/twiki/bin/view/DeveloperResources/ApiBasics/WebHome](http://docs.cpanel.net/twiki/bin/view/DeveloperResources/ApiBasics/WebHome) For information on calling API1 and API2 direct via HTTP, please see: [http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CallingAPIFunctions](http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CallingAPIFunctions) ### cpanel\_api1\_request() `cpanel_api1_request()` is used to query cPanel's API1, the function used for querying API1 has the following syntax: $cp->cpanel_api1_request($service, \%cfg [, \@params, $format ] ); - $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. Only a user with reseller or root access can use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. - $cfg - A hash reference describing the call you wish to make. Required parameters are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. - $params - An array reference containing the parameters you wish to pass to the API call. - $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference. To see what modules and functions are available for making API1 calls, please see: [http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome](http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome) ### cpanel\_api2\_request() `cpanel_api2_request()` is used to query cPanel's API2, the function use for querying API2 has the following syntax: $cp->cpanel_api2_request( $service, \%cfg [, \%params, $format ] ); - $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. A user that does not have reseller or root access will not be able to use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. - $cfg - A hash reference describing the call you wish to make. required parameters here are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. - $params - An hash reference containing the parameters you wish to pass to the API call. - $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. To see what modules and functions are available for making API2 calls, please see: [http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome](http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome) ## api\_request() - Making direct URL requests to cPanel & WHM. There are some situations where you will need to query cPanel and WHM URLs directly. This should ONLY be done when there is not an API call available for the function you wish to query. The function used for querying URLs directly is api\_request(). It will always return a string rather than converting the response into a hash reference. It uses the following syntax: $cp->api_request( $service, $uri, $method, \%formdata, $headers) - $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail', when passed an numerical value, PublicAPI will query that port directly. - $uri - The URL you wish to query, e.g. '/xml-api/cpanel' - $method - 'GET' or 'POST' - $formdata - The data you wish to pass to the URL - $headers - Any additional headers are to be passed with the request. These can be either a flat string or as a hashref like {'headertitle' => 'headerdata'} # Other Features - `establish_tfa_session()` See ["Two-Factor Authentication (2FA)"](#two-factor-authentication-2fa) above. - `set_debug()` This function allows you to enable/disable debug mode by passing a value that evaluates to 'true' or 'false'. - `user()` Allows you to change the user that your PublicAPI object is authenticating with. - `pass()` Allows you to change the password that your PublicAPI object is authenticating with, this will remove the stored accesshash from the object. - `accesshash()` Allows you to change the accesshash that your PublicAPI object is authenticating with, this will remove the stored password from the object. - `api_token()` Allows you to change the API token that your PublicAPI object is authenticating with, this will remove the stored password from the object. - `format_http_query()` Allows you to construct formdata for an http query from a hash. For Example: $pubapi->format_http_query( { 'one' => '1', 'two' => 2 } ); would return: 'one=1&two=2' - `format_http_headers()` Allows you to construct headers for an http query from a hash. For Example: $pubapi->format_http_headers( { 'Authorization' => 'Basic cm9vdDpsMGx1cnNtNHJ0IQ=='} ); would return: 'Authorization: Basic cm9vdDpsMGx1cnNtNHJ0IQ==\r\n' - `$pubapi->{'error'}` Errors encountered within the class are stored here before being written out to the error\_fh filehandle. This can be used for checking the existance of query errors. # Bugs see http://rt.cpan.org to report and view bugs # License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: \* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. \* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \* Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. META.yml 0000644 00000001554 15125143347 0006027 0 ustar 00 --- abstract: 'A perl interface for interacting with cPanel' author: - 'cPanel, Inc. <integration@cpanel.net>' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010' license: bsd meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: cPanel-PublicAPI no_index: directory: - t - inc requires: HTTP::CookieJar: '0' HTTP::Tiny: '0.042' IO::Socket::INET: '1.31' IO::Socket::SSL: '1.988' JSON::XS: '2' Test::Exception: '0' Test::More: '0' URI::Escape: '3' resources: bugtracker: https://github.com/CpanelInc/cPanel-PublicAPI/issues repository: git://github.com/CpanelInc/cPanel-PublicAPI.git version: '2.8' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Makefile.PL 0000644 00000002554 15125143347 0006531 0 ustar 00 use strict; use warnings; use ExtUtils::MakeMaker; die "OS unsupported\n" if $^O eq 'MSWin32'; # Requires getpwuid to be implemented. WriteMakefile( NAME => 'cPanel::PublicAPI', AUTHOR => q{cPanel, Inc. <integration@cpanel.net>}, VERSION_FROM => 'lib/cPanel/PublicAPI.pm', ABSTRACT_FROM => 'lib/cPanel/PublicAPI.pod', ( $ExtUtils::MakeMaker::VERSION >= 6.3002 ? ( 'LICENSE' => 'bsd' ) : () ), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Test::Exception' => 0, 'JSON::XS' => 2.0, 'URI::Escape' => 3, 'IO::Socket::INET' => 1.31, 'IO::Socket::SSL' => 1.988, # Versions below this do not handle close calls properly 'HTTP::Tiny' => 0.042, 'HTTP::CookieJar' => 0, }, META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'git://github.com/CpanelInc/cPanel-PublicAPI.git', web => 'https://github.com/CpanelInc/cPanel-PublicAPI', }, bugtracker => { web => 'https://github.com/CpanelInc/cPanel-PublicAPI/issues', }, }, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'cPanel-PublicAPI-*' }, ); blib/man3/cPanel::PublicAPI::WHM::API.3pm 0000644 00000047124 15125143347 0013305 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM::API 3" .TH cPanel::PublicAPI::WHM::API 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM::API \- Legacy interface for querying the xml\-api. .PP NOTE: This module is provided for legacy purposes, cPanel::PublicAPI should be used instead .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides legacy compatibility support between cPanel::PublicAPI and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). .PP Every method contained within this object can be queried using \fBcPanel::publicAPI::whm_api()\fR instead. .PP For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> .SH "functions" .IX Header "functions" .ie n .SS """api_listaccts()""" .el .SS "\f(CWapi_listaccts()\fP" .IX Subsection "api_listaccts()" Used to list the accounts on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listaccts( $search, $searchtype ); .Ve .ie n .SS """api_createacct()""" .el .SS "\f(CWapi_createacct()\fP" .IX Subsection "api_createacct()" Create a new cPanel account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_createacct( $username, $domain, $password, $plan ); .Ve .ie n .SS """api_removeacct()""" .el .SS "\f(CWapi_removeacct()\fP" .IX Subsection "api_removeacct()" Terminate an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_removeacct( $user ); .Ve .ie n .SS """api_showversion()""" .el .SS "\f(CWapi_showversion()\fP" .IX Subsection "api_showversion()" Get the version of cPanel running on the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_showversion( ); .Ve .ie n .SS """api_version()""" .el .SS "\f(CWapi_version()\fP" .IX Subsection "api_version()" Get the version of cPanel running on the server (as as showversion) .PP Syntax: .PP .Vb 1 \& $pubapi\->api_version( ); .Ve .ie n .SS """api_applist()""" .el .SS "\f(CWapi_applist()\fP" .IX Subsection "api_applist()" List out the available xml-api calls. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_applist( ); .Ve .ie n .SS """api_generatessl()""" .el .SS "\f(CWapi_generatessl()\fP" .IX Subsection "api_generatessl()" Generate an ssl certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); .Ve .ie n .SS """api_generatessl_noemail()""" .el .SS "\f(CWapi_generatessl_noemail()\fP" .IX Subsection "api_generatessl_noemail()" Generate an \s-1SSL\s0 certificate without an email. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_generatessl_noemail( $noemail=1 ); .Ve .ie n .SS """api_listcrts()""" .el .SS "\f(CWapi_listcrts()\fP" .IX Subsection "api_listcrts()" List out the certificates that exist on the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listcrts( ); .Ve .ie n .SS """api_setresellerlimits()""" .el .SS "\f(CWapi_setresellerlimits()\fP" .IX Subsection "api_setresellerlimits()" Set the limits for a single reseller account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setresellerlimits( ); .Ve .ie n .SS """api_setresellerpackagelimit()""" .el .SS "\f(CWapi_setresellerpackagelimit()\fP" .IX Subsection "api_setresellerpackagelimit()" Set which packages a reseller account can use. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); .Ve .ie n .SS """api_setresellermainip()""" .el .SS "\f(CWapi_setresellermainip()\fP" .IX Subsection "api_setresellermainip()" Set a reseller's main \s-1IP.\s0 .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setresellermainip( $user, $ip ); .Ve .ie n .SS """api_setresellerips()""" .el .SS "\f(CWapi_setresellerips()\fP" .IX Subsection "api_setresellerips()" Set the \s-1IP\s0 that a reseller has available to it. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setresellerips( $user, $delegate, $ips ); .Ve .ie n .SS """api_setresellernameservers()""" .el .SS "\f(CWapi_setresellernameservers()\fP" .IX Subsection "api_setresellernameservers()" Set the nameservers that a reseller uses by default. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setresellernameservers( $user, $nameservers ); .Ve .ie n .SS """api_suspendreseller()""" .el .SS "\f(CWapi_suspendreseller()\fP" .IX Subsection "api_suspendreseller()" Suspend a reseller and all of their accounts. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_suspendreseller( $user, $reason, $disallow ); .Ve .ie n .SS """api_unsuspendreseller()""" .el .SS "\f(CWapi_unsuspendreseller()\fP" .IX Subsection "api_unsuspendreseller()" Unsuspend a reseller and all of their accounts. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_unsuspendreseller( $user ); .Ve .ie n .SS """api_addzonerecord()""" .el .SS "\f(CWapi_addzonerecord()\fP" .IX Subsection "api_addzonerecord()" Add a record to a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_addzonerecord( @args ); .Ve .ie n .SS """api_editzonerecord()""" .el .SS "\f(CWapi_editzonerecord()\fP" .IX Subsection "api_editzonerecord()" Edit a zone record. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_editzonerecord(@args ); .Ve .ie n .SS """api_removezonerecord()""" .el .SS "\f(CWapi_removezonerecord()\fP" .IX Subsection "api_removezonerecord()" Remove a line from a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_removezonerecord( $domain, $Line ); .Ve .ie n .SS """api_getzonerecord()""" .el .SS "\f(CWapi_getzonerecord()\fP" .IX Subsection "api_getzonerecord()" Get a record from a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_getzonerecord( $domain, $Line ); .Ve .ie n .SS """api_servicestatus()""" .el .SS "\f(CWapi_servicestatus()\fP" .IX Subsection "api_servicestatus()" Get the status of various services running on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_servicestatus( $service ); .Ve .ie n .SS """api_configureservice()""" .el .SS "\f(CWapi_configureservice()\fP" .IX Subsection "api_configureservice()" Enable/Disable various services. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_configureservice( $service, $enabled, $monitored ); .Ve .ie n .SS """api_acctcounts()""" .el .SS "\f(CWapi_acctcounts()\fP" .IX Subsection "api_acctcounts()" Get the number of accounts on a system/that belong to a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_acctcounts( $user ); .Ve .ie n .SS """api_domainuserdata()""" .el .SS "\f(CWapi_domainuserdata()\fP" .IX Subsection "api_domainuserdata()" Get the information about a specific domain's virtualhost. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_domainuserdata( $domain ); .Ve .ie n .SS """api_editquota()""" .el .SS "\f(CWapi_editquota()\fP" .IX Subsection "api_editquota()" Edit a user's quota. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_editquota( $user, $quota ); .Ve .ie n .SS """api_nvget()""" .el .SS "\f(CWapi_nvget()\fP" .IX Subsection "api_nvget()" Get non-volatile data. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_nvget( $key ); .Ve .ie n .SS """api_nvset()""" .el .SS "\f(CWapi_nvset()\fP" .IX Subsection "api_nvset()" Set non-volatile data. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_nvset( $key, $value ); .Ve .ie n .SS """api_myprivs()""" .el .SS "\f(CWapi_myprivs()\fP" .IX Subsection "api_myprivs()" See what privileges are available to your user. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_myprivs( ); .Ve .ie n .SS """api_listzones()""" .el .SS "\f(CWapi_listzones()\fP" .IX Subsection "api_listzones()" List all the zones available to a user. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listzones( ); .Ve .ie n .SS """api_sethostname()""" .el .SS "\f(CWapi_sethostname()\fP" .IX Subsection "api_sethostname()" Set the hostname of a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_sethostname( $hostname ); .Ve .ie n .SS """api_setresolvers()""" .el .SS "\f(CWapi_setresolvers()\fP" .IX Subsection "api_setresolvers()" Set the resolvers a system uses. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); .Ve .ie n .SS """api_addip()""" .el .SS "\f(CWapi_addip()\fP" .IX Subsection "api_addip()" Add a new \s-1IP\s0 to a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_addip( $ip, $netmask ); .Ve .ie n .SS """api_delip()""" .el .SS "\f(CWapi_delip()\fP" .IX Subsection "api_delip()" Remove an \s-1IP\s0 from a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_delip( $ip, $ethernetdev, $skipifshutdown ); .Ve .ie n .SS """api_listips()""" .el .SS "\f(CWapi_listips()\fP" .IX Subsection "api_listips()" List the IPs on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listips( ); .Ve .ie n .SS """api_dumpzone()""" .el .SS "\f(CWapi_dumpzone()\fP" .IX Subsection "api_dumpzone()" Get the contents of a zone file. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_dumpzone( $domain ); .Ve .ie n .SS """api_listpkgs()""" .el .SS "\f(CWapi_listpkgs()\fP" .IX Subsection "api_listpkgs()" List the packages available to your user. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listpkgs( ); .Ve .ie n .SS """api_limitbw()""" .el .SS "\f(CWapi_limitbw()\fP" .IX Subsection "api_limitbw()" Limit the amount of bandwidth available to an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_limitbw( $user, $bwlimit ); .Ve .ie n .SS """api_showbw()""" .el .SS "\f(CWapi_showbw()\fP" .IX Subsection "api_showbw()" Show the amount of \s-1BW\s0 used by an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_showbw( $month, $year, $showres, $search, $searchtype ); .Ve .ie n .SS """api_killdns()""" .el .SS "\f(CWapi_killdns()\fP" .IX Subsection "api_killdns()" Remove a \s-1DNS\s0 zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_killdns( $domain ); .Ve .ie n .SS """api_adddns()""" .el .SS "\f(CWapi_adddns()\fP" .IX Subsection "api_adddns()" Add a dns zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_adddns( $domain, $ip, $trueowner ); .Ve .ie n .SS """api_changepackage()""" .el .SS "\f(CWapi_changepackage()\fP" .IX Subsection "api_changepackage()" Change an Account's Package. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_changepackage( $user, $pkg ); .Ve .ie n .SS """api_modifyacct()""" .el .SS "\f(CWapi_modifyacct()\fP" .IX Subsection "api_modifyacct()" Modify an Account's limits. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); .Ve .ie n .SS """api_suspendacct()""" .el .SS "\f(CWapi_suspendacct()\fP" .IX Subsection "api_suspendacct()" Suspend an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_suspendacct( $user, $reason ); .Ve .ie n .SS """api_unsuspendacct()""" .el .SS "\f(CWapi_unsuspendacct()\fP" .IX Subsection "api_unsuspendacct()" Unsuspend an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_unsuspendacct( $user ); .Ve .ie n .SS """api_listsuspended()""" .el .SS "\f(CWapi_listsuspended()\fP" .IX Subsection "api_listsuspended()" List the suspended accounts on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listsuspended( ); .Ve .ie n .SS """api_addpkg()""" .el .SS "\f(CWapi_addpkg()\fP" .IX Subsection "api_addpkg()" Add a new package. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); .Ve .ie n .SS """api_killpkg()""" .el .SS "\f(CWapi_killpkg()\fP" .IX Subsection "api_killpkg()" Remove a package. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_killpkg( $pkg ); .Ve .ie n .SS """api_editpkg()""" .el .SS "\f(CWapi_editpkg()\fP" .IX Subsection "api_editpkg()" Edit a package. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); .Ve .ie n .SS """api_setacls()""" .el .SS "\f(CWapi_setacls()\fP" .IX Subsection "api_setacls()" Change features available to a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setacls( $reseller, $acllist ); .Ve .ie n .SS """api_terminatereseller()""" .el .SS "\f(CWapi_terminatereseller()\fP" .IX Subsection "api_terminatereseller()" Remove a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_terminatereseller( $reseller, $verify ); .Ve .ie n .SS """api_resellerstats()""" .el .SS "\f(CWapi_resellerstats()\fP" .IX Subsection "api_resellerstats()" Get statistics on a specific reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_resellerstats( $reseller ); .Ve .ie n .SS """api_setupreseller()""" .el .SS "\f(CWapi_setupreseller()\fP" .IX Subsection "api_setupreseller()" Make a cPanel account a Reseller account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setupreseller( $user, $makeowner ); .Ve .ie n .SS """api_lookupnsip()""" .el .SS "\f(CWapi_lookupnsip()\fP" .IX Subsection "api_lookupnsip()" Get the \s-1IP\s0 for a nameserver. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_lookupnsip( $nameserver ); .Ve .ie n .SS """api_listresellers()""" .el .SS "\f(CWapi_listresellers()\fP" .IX Subsection "api_listresellers()" List all the resellers on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listresellers( ); .Ve .ie n .SS """api_listacls()""" .el .SS "\f(CWapi_listacls()\fP" .IX Subsection "api_listacls()" List all of the \s-1ACL\s0 lists available. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_listacls( ); .Ve .ie n .SS """api_saveacllist()""" .el .SS "\f(CWapi_saveacllist()\fP" .IX Subsection "api_saveacllist()" Save a new \s-1ACL\s0 list. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_saveacllist( $acllist ); .Ve .ie n .SS """api_unsetupreseller()""" .el .SS "\f(CWapi_unsetupreseller()\fP" .IX Subsection "api_unsetupreseller()" Remove reseller permissions from an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_unsetupreseller( $user ); .Ve .ie n .SS """api_gethostname()""" .el .SS "\f(CWapi_gethostname()\fP" .IX Subsection "api_gethostname()" Get the hostname of the server currently being queried. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_gethostname( ); .Ve .ie n .SS """api_fetchsslinfo()""" .el .SS "\f(CWapi_fetchsslinfo()\fP" .IX Subsection "api_fetchsslinfo()" Get information on a specific \s-1SSL\s0 certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_fetchsslinfo( $domain, $crtdata ); .Ve .ie n .SS """api_installssl()""" .el .SS "\f(CWapi_installssl()\fP" .IX Subsection "api_installssl()" Install a new \s-1SSL\s0 certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_installssl( $domain, $user, $cert, $key, $cab, $ip ); .Ve .ie n .SS """api_passwd()""" .el .SS "\f(CWapi_passwd()\fP" .IX Subsection "api_passwd()" Change an account's password. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_passwd( $user, $pass ); .Ve .ie n .SS """api_getlanglist()""" .el .SS "\f(CWapi_getlanglist()\fP" .IX Subsection "api_getlanglist()" Get a list of languages available on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_getlanglist( ); .Ve .ie n .SS """api_reboot()""" .el .SS "\f(CWapi_reboot()\fP" .IX Subsection "api_reboot()" Reboot the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_reboot( $force ); .Ve .ie n .SS """api_accountsummary_user()""" .el .SS "\f(CWapi_accountsummary_user()\fP" .IX Subsection "api_accountsummary_user()" Get a summary of an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_accountsummary_user( $user ); .Ve .ie n .SS """api_accountsummary_domain()""" .el .SS "\f(CWapi_accountsummary_domain()\fP" .IX Subsection "api_accountsummary_domain()" Get the summary of an account by specifying the domain. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_accountsummary_domain( $domain ); .Ve .ie n .SS """api_loadavg()""" .el .SS "\f(CWapi_loadavg()\fP" .IX Subsection "api_loadavg()" Get the loadavg on the system. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_loadavg( ); .Ve .ie n .SS """api_restartservice()""" .el .SS "\f(CWapi_restartservice()\fP" .IX Subsection "api_restartservice()" Restart a service. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_restartservice( $service ); .Ve .ie n .SS """api_setsiteip_user()""" .el .SS "\f(CWapi_setsiteip_user()\fP" .IX Subsection "api_setsiteip_user()" Set the \s-1IP\s0 for a specific user. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setsiteip_user( $user, $ip ); .Ve .ie n .SS """api_setsiteip_domain()""" .el .SS "\f(CWapi_setsiteip_domain()\fP" .IX Subsection "api_setsiteip_domain()" Set the \s-1IP\s0 for a specific domain. .PP Syntax: .PP .Vb 1 \& $pubapi\->api_setsiteip_domain( $domain, $ip ); .Ve .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI::Utils.3pm 0000644 00000010502 15125143347 0013222 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::Utils 3" .TH cPanel::PublicAPI::Utils 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::Utils \- Provides some internally used utility functions for cPanel::PublicAPI, should never be used externally. .SH "Subroutines" .IX Header "Subroutines" .SS "\fBremove_trailing_newline()\fP" .IX Subsection "remove_trailing_newline()" Removes the training newline from the provided string .SS "get_string_with_collapsed_trailing_eols" .IX Subsection "get_string_with_collapsed_trailing_eols" Takes an array or array of arrays and puts them into a newline-seperated string. .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI::WHM::JSONAPI.3pm 0000644 00000051254 15125143347 0013776 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM::JSONAPI 3" .TH cPanel::PublicAPI::WHM::JSONAPI 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM::API \- Legacy interface for querying the xml\-api. .PP NOTE: This module is provided for legacy purposes, cPanel::PublicAPI should be used instead .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides legacy compatibility support between cPanel::PublicAPI and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). .PP Every method contained within this object can be queried using \fBcPanel::publicAPI::whm_api()\fR instead. .PP For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> .SH "functions" .IX Header "functions" .ie n .SS """jsonapi_listaccts()""" .el .SS "\f(CWjsonapi_listaccts()\fP" .IX Subsection "jsonapi_listaccts()" Used to list the accounts on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listaccts( $search, $searchtype ); .Ve .ie n .SS """jsonapi_createacct()""" .el .SS "\f(CWjsonapi_createacct()\fP" .IX Subsection "jsonapi_createacct()" Create a new cPanel account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_createacct( $username, $domain, $password, $plan ); .Ve .ie n .SS """jsonapi_removeacct()""" .el .SS "\f(CWjsonapi_removeacct()\fP" .IX Subsection "jsonapi_removeacct()" Terminate an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_removeacct( $user ); .Ve .ie n .SS """jsonapi_showversion()""" .el .SS "\f(CWjsonapi_showversion()\fP" .IX Subsection "jsonapi_showversion()" Get the version of cPanel running on the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_showversion( ); .Ve .ie n .SS """jsonapi_version()""" .el .SS "\f(CWjsonapi_version()\fP" .IX Subsection "jsonapi_version()" Get the version of cPanel running on the server (as as showversion) .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_version( ); .Ve .ie n .SS """jsonapi_applist()""" .el .SS "\f(CWjsonapi_applist()\fP" .IX Subsection "jsonapi_applist()" List out the available xml-api calls. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_applist( ); .Ve .ie n .SS """jsonapi_generatessl()""" .el .SS "\f(CWjsonapi_generatessl()\fP" .IX Subsection "jsonapi_generatessl()" Generate an ssl certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); .Ve .ie n .SS """jsonapi_generatessl_noemail()""" .el .SS "\f(CWjsonapi_generatessl_noemail()\fP" .IX Subsection "jsonapi_generatessl_noemail()" Generate an \s-1SSL\s0 certificate without an email. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_generatessl_noemail( $noemail=1 ); .Ve .ie n .SS """jsonapi_listcrts()""" .el .SS "\f(CWjsonapi_listcrts()\fP" .IX Subsection "jsonapi_listcrts()" List out the certificates that exist on the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listcrts( ); .Ve .ie n .SS """jsonapi_setresellerlimits()""" .el .SS "\f(CWjsonapi_setresellerlimits()\fP" .IX Subsection "jsonapi_setresellerlimits()" Set the limits for a single reseller account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setresellerlimits( ); .Ve .ie n .SS """jsonapi_setresellerpackagelimit()""" .el .SS "\f(CWjsonapi_setresellerpackagelimit()\fP" .IX Subsection "jsonapi_setresellerpackagelimit()" Set which packages a reseller account can use. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); .Ve .ie n .SS """jsonapi_setresellermainip()""" .el .SS "\f(CWjsonapi_setresellermainip()\fP" .IX Subsection "jsonapi_setresellermainip()" Set a reseller's main \s-1IP.\s0 .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setresellermainip( $user, $ip ); .Ve .ie n .SS """jsonapi_setresellerips()""" .el .SS "\f(CWjsonapi_setresellerips()\fP" .IX Subsection "jsonapi_setresellerips()" Set the \s-1IP\s0 that a reseller has available to it. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setresellerips( $user, $delegate, $ips ); .Ve .ie n .SS """jsonapi_setresellernameservers()""" .el .SS "\f(CWjsonapi_setresellernameservers()\fP" .IX Subsection "jsonapi_setresellernameservers()" Set the nameservers that a reseller uses by default. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setresellernameservers( $user, $nameservers ); .Ve .ie n .SS """jsonapi_suspendreseller()""" .el .SS "\f(CWjsonapi_suspendreseller()\fP" .IX Subsection "jsonapi_suspendreseller()" Suspend a reseller and all of their accounts. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_suspendreseller( $user, $reason, $disallow ); .Ve .ie n .SS """jsonapi_unsuspendreseller()""" .el .SS "\f(CWjsonapi_unsuspendreseller()\fP" .IX Subsection "jsonapi_unsuspendreseller()" Unsuspend a reseller and all of their accounts. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_unsuspendreseller( $user ); .Ve .ie n .SS """jsonapi_addzonerecord()""" .el .SS "\f(CWjsonapi_addzonerecord()\fP" .IX Subsection "jsonapi_addzonerecord()" Add a record to a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_addzonerecord( @args ); .Ve .ie n .SS """jsonapi_editzonerecord()""" .el .SS "\f(CWjsonapi_editzonerecord()\fP" .IX Subsection "jsonapi_editzonerecord()" Edit a zone record. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_editzonerecord(@args ); .Ve .ie n .SS """jsonapi_removezonerecord()""" .el .SS "\f(CWjsonapi_removezonerecord()\fP" .IX Subsection "jsonapi_removezonerecord()" Remove a line from a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_removezonerecord( $domain, $Line ); .Ve .ie n .SS """jsonapi_getzonerecord()""" .el .SS "\f(CWjsonapi_getzonerecord()\fP" .IX Subsection "jsonapi_getzonerecord()" Get a record from a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_getzonerecord( $domain, $Line ); .Ve .ie n .SS """jsonapi_servicestatus()""" .el .SS "\f(CWjsonapi_servicestatus()\fP" .IX Subsection "jsonapi_servicestatus()" Get the status of various services running on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_servicestatus( $service ); .Ve .ie n .SS """jsonapi_configureservice()""" .el .SS "\f(CWjsonapi_configureservice()\fP" .IX Subsection "jsonapi_configureservice()" Enable/Disable various services. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_configureservice( $service, $enabled, $monitored ); .Ve .ie n .SS """jsonapi_acctcounts()""" .el .SS "\f(CWjsonapi_acctcounts()\fP" .IX Subsection "jsonapi_acctcounts()" Get the number of accounts on a system/that belong to a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_acctcounts( $user ); .Ve .ie n .SS """jsonapi_domainuserdata()""" .el .SS "\f(CWjsonapi_domainuserdata()\fP" .IX Subsection "jsonapi_domainuserdata()" Get the information about a specific domain's virtualhost. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_domainuserdata( $domain ); .Ve .ie n .SS """jsonapi_editquota()""" .el .SS "\f(CWjsonapi_editquota()\fP" .IX Subsection "jsonapi_editquota()" Edit a user's quota. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_editquota( $user, $quota ); .Ve .ie n .SS """jsonapi_nvget()""" .el .SS "\f(CWjsonapi_nvget()\fP" .IX Subsection "jsonapi_nvget()" Get non-volatile data. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_nvget( $key ); .Ve .ie n .SS """jsonapi_nvset()""" .el .SS "\f(CWjsonapi_nvset()\fP" .IX Subsection "jsonapi_nvset()" Set non-volatile data. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_nvset( $key, $value ); .Ve .ie n .SS """jsonapi_myprivs()""" .el .SS "\f(CWjsonapi_myprivs()\fP" .IX Subsection "jsonapi_myprivs()" See what privileges are available to your user. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_myprivs( ); .Ve .ie n .SS """jsonapi_listzones()""" .el .SS "\f(CWjsonapi_listzones()\fP" .IX Subsection "jsonapi_listzones()" List all the zones available to a user. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listzones( ); .Ve .ie n .SS """jsonapi_sethostname()""" .el .SS "\f(CWjsonapi_sethostname()\fP" .IX Subsection "jsonapi_sethostname()" Set the hostname of a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_sethostname( $hostname ); .Ve .ie n .SS """jsonapi_setresolvers()""" .el .SS "\f(CWjsonapi_setresolvers()\fP" .IX Subsection "jsonapi_setresolvers()" Set the resolvers a system uses. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); .Ve .ie n .SS """jsonapi_addip()""" .el .SS "\f(CWjsonapi_addip()\fP" .IX Subsection "jsonapi_addip()" Add a new \s-1IP\s0 to a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_addip( $ip, $netmask ); .Ve .ie n .SS """jsonapi_delip()""" .el .SS "\f(CWjsonapi_delip()\fP" .IX Subsection "jsonapi_delip()" Remove an \s-1IP\s0 from a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_delip( $ip, $ethernetdev, $skipifshutdown ); .Ve .ie n .SS """jsonapi_listips()""" .el .SS "\f(CWjsonapi_listips()\fP" .IX Subsection "jsonapi_listips()" List the IPs on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listips( ); .Ve .ie n .SS """jsonapi_dumpzone()""" .el .SS "\f(CWjsonapi_dumpzone()\fP" .IX Subsection "jsonapi_dumpzone()" Get the contents of a zone file. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_dumpzone( $domain ); .Ve .ie n .SS """jsonapi_listpkgs()""" .el .SS "\f(CWjsonapi_listpkgs()\fP" .IX Subsection "jsonapi_listpkgs()" List the packages available to your user. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listpkgs( ); .Ve .ie n .SS """jsonapi_limitbw()""" .el .SS "\f(CWjsonapi_limitbw()\fP" .IX Subsection "jsonapi_limitbw()" Limit the amount of bandwidth available to an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_limitbw( $user, $bwlimit ); .Ve .ie n .SS """jsonapi_showbw()""" .el .SS "\f(CWjsonapi_showbw()\fP" .IX Subsection "jsonapi_showbw()" Show the amount of \s-1BW\s0 used by an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_showbw( $month, $year, $showres, $search, $searchtype ); .Ve .ie n .SS """jsonapi_killdns()""" .el .SS "\f(CWjsonapi_killdns()\fP" .IX Subsection "jsonapi_killdns()" Remove a \s-1DNS\s0 zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_killdns( $domain ); .Ve .ie n .SS """jsonapi_adddns()""" .el .SS "\f(CWjsonapi_adddns()\fP" .IX Subsection "jsonapi_adddns()" Add a dns zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_adddns( $domain, $ip, $trueowner ); .Ve .ie n .SS """jsonapi_changepackage()""" .el .SS "\f(CWjsonapi_changepackage()\fP" .IX Subsection "jsonapi_changepackage()" Change an Account's Package. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_changepackage( $user, $pkg ); .Ve .ie n .SS """jsonapi_modifyacct()""" .el .SS "\f(CWjsonapi_modifyacct()\fP" .IX Subsection "jsonapi_modifyacct()" Modify an Account's limits. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); .Ve .ie n .SS """jsonapi_suspendacct()""" .el .SS "\f(CWjsonapi_suspendacct()\fP" .IX Subsection "jsonapi_suspendacct()" Suspend an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_suspendacct( $user, $reason ); .Ve .ie n .SS """jsonapi_unsuspendacct()""" .el .SS "\f(CWjsonapi_unsuspendacct()\fP" .IX Subsection "jsonapi_unsuspendacct()" Unsuspend an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_unsuspendacct( $user ); .Ve .ie n .SS """jsonapi_listsuspended()""" .el .SS "\f(CWjsonapi_listsuspended()\fP" .IX Subsection "jsonapi_listsuspended()" List the suspended accounts on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listsuspended( ); .Ve .ie n .SS """jsonapi_addpkg()""" .el .SS "\f(CWjsonapi_addpkg()\fP" .IX Subsection "jsonapi_addpkg()" Add a new package. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); .Ve .ie n .SS """jsonapi_killpkg()""" .el .SS "\f(CWjsonapi_killpkg()\fP" .IX Subsection "jsonapi_killpkg()" Remove a package. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_killpkg( $pkg ); .Ve .ie n .SS """jsonapi_editpkg()""" .el .SS "\f(CWjsonapi_editpkg()\fP" .IX Subsection "jsonapi_editpkg()" Edit a package. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); .Ve .ie n .SS """jsonapi_setacls()""" .el .SS "\f(CWjsonapi_setacls()\fP" .IX Subsection "jsonapi_setacls()" Change features available to a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setacls( $reseller, $acllist ); .Ve .ie n .SS """jsonapi_terminatereseller()""" .el .SS "\f(CWjsonapi_terminatereseller()\fP" .IX Subsection "jsonapi_terminatereseller()" Remove a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_terminatereseller( $reseller, $verify ); .Ve .ie n .SS """jsonapi_resellerstats()""" .el .SS "\f(CWjsonapi_resellerstats()\fP" .IX Subsection "jsonapi_resellerstats()" Get statistics on a specific reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_resellerstats( $reseller ); .Ve .ie n .SS """jsonapi_setupreseller()""" .el .SS "\f(CWjsonapi_setupreseller()\fP" .IX Subsection "jsonapi_setupreseller()" Make a cPanel account a Reseller account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setupreseller( $user, $makeowner ); .Ve .ie n .SS """jsonapi_lookupnsip()""" .el .SS "\f(CWjsonapi_lookupnsip()\fP" .IX Subsection "jsonapi_lookupnsip()" Get the \s-1IP\s0 for a nameserver. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_lookupnsip( $nameserver ); .Ve .ie n .SS """jsonapi_listresellers()""" .el .SS "\f(CWjsonapi_listresellers()\fP" .IX Subsection "jsonapi_listresellers()" List all the resellers on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listresellers( ); .Ve .ie n .SS """jsonapi_listacls()""" .el .SS "\f(CWjsonapi_listacls()\fP" .IX Subsection "jsonapi_listacls()" List all of the \s-1ACL\s0 lists available. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_listacls( ); .Ve .ie n .SS """jsonapi_saveacllist()""" .el .SS "\f(CWjsonapi_saveacllist()\fP" .IX Subsection "jsonapi_saveacllist()" Save a new \s-1ACL\s0 list. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_saveacllist( $acllist ); .Ve .ie n .SS """jsonapi_unsetupreseller()""" .el .SS "\f(CWjsonapi_unsetupreseller()\fP" .IX Subsection "jsonapi_unsetupreseller()" Remove reseller permissions from an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_unsetupreseller( $user ); .Ve .ie n .SS """jsonapi_gethostname()""" .el .SS "\f(CWjsonapi_gethostname()\fP" .IX Subsection "jsonapi_gethostname()" Get the hostname of the server currently being queried. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_gethostname( ); .Ve .ie n .SS """jsonapi_fetchsslinfo()""" .el .SS "\f(CWjsonapi_fetchsslinfo()\fP" .IX Subsection "jsonapi_fetchsslinfo()" Get information on a specific \s-1SSL\s0 certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_fetchsslinfo( $domain, $crtdata ); .Ve .ie n .SS """jsonapi_installssl()""" .el .SS "\f(CWjsonapi_installssl()\fP" .IX Subsection "jsonapi_installssl()" Install a new \s-1SSL\s0 certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_installssl( $domain, $user, $cert, $key, $cab, $ip ); .Ve .ie n .SS """jsonapi_passwd()""" .el .SS "\f(CWjsonapi_passwd()\fP" .IX Subsection "jsonapi_passwd()" Change an account's password. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_passwd( $user, $pass ); .Ve .ie n .SS """jsonapi_getlanglist()""" .el .SS "\f(CWjsonapi_getlanglist()\fP" .IX Subsection "jsonapi_getlanglist()" Get a list of languages available on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_getlanglist( ); .Ve .ie n .SS """jsonapi_reboot()""" .el .SS "\f(CWjsonapi_reboot()\fP" .IX Subsection "jsonapi_reboot()" Reboot the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_reboot( $force ); .Ve .ie n .SS """jsonapi_accountsummary_user()""" .el .SS "\f(CWjsonapi_accountsummary_user()\fP" .IX Subsection "jsonapi_accountsummary_user()" Get a summary of an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_accountsummary_user( $user ); .Ve .ie n .SS """jsonapi_accountsummary_domain()""" .el .SS "\f(CWjsonapi_accountsummary_domain()\fP" .IX Subsection "jsonapi_accountsummary_domain()" Get the summary of an account by specifying the domain. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_accountsummary_domain( $domain ); .Ve .ie n .SS """jsonapi_loadavg()""" .el .SS "\f(CWjsonapi_loadavg()\fP" .IX Subsection "jsonapi_loadavg()" Get the loadavg on the system. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_loadavg( ); .Ve .ie n .SS """jsonapi_restartservice()""" .el .SS "\f(CWjsonapi_restartservice()\fP" .IX Subsection "jsonapi_restartservice()" Restart a service. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_restartservice( $service ); .Ve .ie n .SS """jsonapi_setsiteip_user()""" .el .SS "\f(CWjsonapi_setsiteip_user()\fP" .IX Subsection "jsonapi_setsiteip_user()" Set the \s-1IP\s0 for a specific user. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setsiteip_user( $user, $ip ); .Ve .ie n .SS """jsonapi_setsiteip_domain()""" .el .SS "\f(CWjsonapi_setsiteip_domain()\fP" .IX Subsection "jsonapi_setsiteip_domain()" Set the \s-1IP\s0 for a specific domain. .PP Syntax: .PP .Vb 1 \& $pubapi\->jsonapi_setsiteip_domain( $domain, $ip ); .Ve .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI::WHM::XMLAPI.3pm 0000644 00000050626 15125143347 0013667 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM::XMLAPI 3" .TH cPanel::PublicAPI::WHM::XMLAPI 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM::API \- Legacy interface for querying the xml\-api. .PP NOTE: This module is provided for legacy purposes, cPanel::PublicAPI should be used instead .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides legacy compatibility support between cPanel::PublicAPI and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). .PP Every method contained within this object can be queried using \fBcPanel::publicAPI::whm_api()\fR instead. .PP For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> .SH "functions" .IX Header "functions" .ie n .SS """xmlapi_listaccts()""" .el .SS "\f(CWxmlapi_listaccts()\fP" .IX Subsection "xmlapi_listaccts()" Used to list the accounts on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listaccts( $search, $searchtype ); .Ve .ie n .SS """xmlapi_createacct()""" .el .SS "\f(CWxmlapi_createacct()\fP" .IX Subsection "xmlapi_createacct()" Create a new cPanel account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_createacct( $username, $domain, $password, $plan ); .Ve .ie n .SS """xmlapi_removeacct()""" .el .SS "\f(CWxmlapi_removeacct()\fP" .IX Subsection "xmlapi_removeacct()" Terminate an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_removeacct( $user ); .Ve .ie n .SS """xmlapi_showversion()""" .el .SS "\f(CWxmlapi_showversion()\fP" .IX Subsection "xmlapi_showversion()" Get the version of cPanel running on the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_showversion( ); .Ve .ie n .SS """xmlapi_version()""" .el .SS "\f(CWxmlapi_version()\fP" .IX Subsection "xmlapi_version()" Get the version of cPanel running on the server (as as showversion) .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_version( ); .Ve .ie n .SS """xmlapi_applist()""" .el .SS "\f(CWxmlapi_applist()\fP" .IX Subsection "xmlapi_applist()" List out the available xml-api calls. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_applist( ); .Ve .ie n .SS """xmlapi_generatessl()""" .el .SS "\f(CWxmlapi_generatessl()\fP" .IX Subsection "xmlapi_generatessl()" Generate an ssl certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); .Ve .ie n .SS """xmlapi_generatessl_noemail()""" .el .SS "\f(CWxmlapi_generatessl_noemail()\fP" .IX Subsection "xmlapi_generatessl_noemail()" Generate an \s-1SSL\s0 certificate without an email. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_generatessl_noemail( $noemail=1 ); .Ve .ie n .SS """xmlapi_listcrts()""" .el .SS "\f(CWxmlapi_listcrts()\fP" .IX Subsection "xmlapi_listcrts()" List out the certificates that exist on the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listcrts( ); .Ve .ie n .SS """xmlapi_setresellerlimits()""" .el .SS "\f(CWxmlapi_setresellerlimits()\fP" .IX Subsection "xmlapi_setresellerlimits()" Set the limits for a single reseller account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setresellerlimits( ); .Ve .ie n .SS """xmlapi_setresellerpackagelimit()""" .el .SS "\f(CWxmlapi_setresellerpackagelimit()\fP" .IX Subsection "xmlapi_setresellerpackagelimit()" Set which packages a reseller account can use. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); .Ve .ie n .SS """xmlapi_setresellermainip()""" .el .SS "\f(CWxmlapi_setresellermainip()\fP" .IX Subsection "xmlapi_setresellermainip()" Set a reseller's main \s-1IP.\s0 .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setresellermainip( $user, $ip ); .Ve .ie n .SS """xmlapi_setresellerips()""" .el .SS "\f(CWxmlapi_setresellerips()\fP" .IX Subsection "xmlapi_setresellerips()" Set the \s-1IP\s0 that a reseller has available to it. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setresellerips( $user, $delegate, $ips ); .Ve .ie n .SS """xmlapi_setresellernameservers()""" .el .SS "\f(CWxmlapi_setresellernameservers()\fP" .IX Subsection "xmlapi_setresellernameservers()" Set the nameservers that a reseller uses by default. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setresellernameservers( $user, $nameservers ); .Ve .ie n .SS """xmlapi_suspendreseller()""" .el .SS "\f(CWxmlapi_suspendreseller()\fP" .IX Subsection "xmlapi_suspendreseller()" Suspend a reseller and all of their accounts. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_suspendreseller( $user, $reason, $disallow ); .Ve .ie n .SS """xmlapi_unsuspendreseller()""" .el .SS "\f(CWxmlapi_unsuspendreseller()\fP" .IX Subsection "xmlapi_unsuspendreseller()" Unsuspend a reseller and all of their accounts. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_unsuspendreseller( $user ); .Ve .ie n .SS """xmlapi_addzonerecord()""" .el .SS "\f(CWxmlapi_addzonerecord()\fP" .IX Subsection "xmlapi_addzonerecord()" Add a record to a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_addzonerecord( @args ); .Ve .ie n .SS """xmlapi_editzonerecord()""" .el .SS "\f(CWxmlapi_editzonerecord()\fP" .IX Subsection "xmlapi_editzonerecord()" Edit a zone record. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_editzonerecord(@args ); .Ve .ie n .SS """xmlapi_removezonerecord()""" .el .SS "\f(CWxmlapi_removezonerecord()\fP" .IX Subsection "xmlapi_removezonerecord()" Remove a line from a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_removezonerecord( $domain, $Line ); .Ve .ie n .SS """xmlapi_getzonerecord()""" .el .SS "\f(CWxmlapi_getzonerecord()\fP" .IX Subsection "xmlapi_getzonerecord()" Get a record from a zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_getzonerecord( $domain, $Line ); .Ve .ie n .SS """xmlapi_servicestatus()""" .el .SS "\f(CWxmlapi_servicestatus()\fP" .IX Subsection "xmlapi_servicestatus()" Get the status of various services running on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_servicestatus( $service ); .Ve .ie n .SS """xmlapi_configureservice()""" .el .SS "\f(CWxmlapi_configureservice()\fP" .IX Subsection "xmlapi_configureservice()" Enable/Disable various services. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_configureservice( $service, $enabled, $monitored ); .Ve .ie n .SS """xmlapi_acctcounts()""" .el .SS "\f(CWxmlapi_acctcounts()\fP" .IX Subsection "xmlapi_acctcounts()" Get the number of accounts on a system/that belong to a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_acctcounts( $user ); .Ve .ie n .SS """xmlapi_domainuserdata()""" .el .SS "\f(CWxmlapi_domainuserdata()\fP" .IX Subsection "xmlapi_domainuserdata()" Get the information about a specific domain's virtualhost. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_domainuserdata( $domain ); .Ve .ie n .SS """xmlapi_editquota()""" .el .SS "\f(CWxmlapi_editquota()\fP" .IX Subsection "xmlapi_editquota()" Edit a user's quota. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_editquota( $user, $quota ); .Ve .ie n .SS """xmlapi_nvget()""" .el .SS "\f(CWxmlapi_nvget()\fP" .IX Subsection "xmlapi_nvget()" Get non-volatile data. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_nvget( $key ); .Ve .ie n .SS """xmlapi_nvset()""" .el .SS "\f(CWxmlapi_nvset()\fP" .IX Subsection "xmlapi_nvset()" Set non-volatile data. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_nvset( $key, $value ); .Ve .ie n .SS """xmlapi_myprivs()""" .el .SS "\f(CWxmlapi_myprivs()\fP" .IX Subsection "xmlapi_myprivs()" See what privileges are available to your user. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_myprivs( ); .Ve .ie n .SS """xmlapi_listzones()""" .el .SS "\f(CWxmlapi_listzones()\fP" .IX Subsection "xmlapi_listzones()" List all the zones available to a user. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listzones( ); .Ve .ie n .SS """xmlapi_sethostname()""" .el .SS "\f(CWxmlapi_sethostname()\fP" .IX Subsection "xmlapi_sethostname()" Set the hostname of a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_sethostname( $hostname ); .Ve .ie n .SS """xmlapi_setresolvers()""" .el .SS "\f(CWxmlapi_setresolvers()\fP" .IX Subsection "xmlapi_setresolvers()" Set the resolvers a system uses. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); .Ve .ie n .SS """xmlapi_addip()""" .el .SS "\f(CWxmlapi_addip()\fP" .IX Subsection "xmlapi_addip()" Add a new \s-1IP\s0 to a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_addip( $ip, $netmask ); .Ve .ie n .SS """xmlapi_delip()""" .el .SS "\f(CWxmlapi_delip()\fP" .IX Subsection "xmlapi_delip()" Remove an \s-1IP\s0 from a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_delip( $ip, $ethernetdev, $skipifshutdown ); .Ve .ie n .SS """xmlapi_listips()""" .el .SS "\f(CWxmlapi_listips()\fP" .IX Subsection "xmlapi_listips()" List the IPs on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listips( ); .Ve .ie n .SS """xmlapi_dumpzone()""" .el .SS "\f(CWxmlapi_dumpzone()\fP" .IX Subsection "xmlapi_dumpzone()" Get the contents of a zone file. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_dumpzone( $domain ); .Ve .ie n .SS """xmlapi_listpkgs()""" .el .SS "\f(CWxmlapi_listpkgs()\fP" .IX Subsection "xmlapi_listpkgs()" List the packages available to your user. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listpkgs( ); .Ve .ie n .SS """xmlapi_limitbw()""" .el .SS "\f(CWxmlapi_limitbw()\fP" .IX Subsection "xmlapi_limitbw()" Limit the amount of bandwidth available to an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_limitbw( $user, $bwlimit ); .Ve .ie n .SS """xmlapi_showbw()""" .el .SS "\f(CWxmlapi_showbw()\fP" .IX Subsection "xmlapi_showbw()" Show the amount of \s-1BW\s0 used by an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_showbw( $month, $year, $showres, $search, $searchtype ); .Ve .ie n .SS """xmlapi_killdns()""" .el .SS "\f(CWxmlapi_killdns()\fP" .IX Subsection "xmlapi_killdns()" Remove a \s-1DNS\s0 zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_killdns( $domain ); .Ve .ie n .SS """xmlapi_adddns()""" .el .SS "\f(CWxmlapi_adddns()\fP" .IX Subsection "xmlapi_adddns()" Add a dns zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_adddns( $domain, $ip, $trueowner ); .Ve .ie n .SS """xmlapi_changepackage()""" .el .SS "\f(CWxmlapi_changepackage()\fP" .IX Subsection "xmlapi_changepackage()" Change an Account's Package. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_changepackage( $user, $pkg ); .Ve .ie n .SS """xmlapi_modifyacct()""" .el .SS "\f(CWxmlapi_modifyacct()\fP" .IX Subsection "xmlapi_modifyacct()" Modify an Account's limits. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); .Ve .ie n .SS """xmlapi_suspendacct()""" .el .SS "\f(CWxmlapi_suspendacct()\fP" .IX Subsection "xmlapi_suspendacct()" Suspend an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_suspendacct( $user, $reason ); .Ve .ie n .SS """xmlapi_unsuspendacct()""" .el .SS "\f(CWxmlapi_unsuspendacct()\fP" .IX Subsection "xmlapi_unsuspendacct()" Unsuspend an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_unsuspendacct( $user ); .Ve .ie n .SS """xmlapi_listsuspended()""" .el .SS "\f(CWxmlapi_listsuspended()\fP" .IX Subsection "xmlapi_listsuspended()" List the suspended accounts on a server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listsuspended( ); .Ve .ie n .SS """xmlapi_addpkg()""" .el .SS "\f(CWxmlapi_addpkg()\fP" .IX Subsection "xmlapi_addpkg()" Add a new package. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); .Ve .ie n .SS """xmlapi_killpkg()""" .el .SS "\f(CWxmlapi_killpkg()\fP" .IX Subsection "xmlapi_killpkg()" Remove a package. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_killpkg( $pkg ); .Ve .ie n .SS """xmlapi_editpkg()""" .el .SS "\f(CWxmlapi_editpkg()\fP" .IX Subsection "xmlapi_editpkg()" Edit a package. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); .Ve .ie n .SS """xmlapi_setacls()""" .el .SS "\f(CWxmlapi_setacls()\fP" .IX Subsection "xmlapi_setacls()" Change features available to a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setacls( $reseller, $acllist ); .Ve .ie n .SS """xmlapi_terminatereseller()""" .el .SS "\f(CWxmlapi_terminatereseller()\fP" .IX Subsection "xmlapi_terminatereseller()" Remove a reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_terminatereseller( $reseller, $verify ); .Ve .ie n .SS """xmlapi_resellerstats()""" .el .SS "\f(CWxmlapi_resellerstats()\fP" .IX Subsection "xmlapi_resellerstats()" Get statistics on a specific reseller. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_resellerstats( $reseller ); .Ve .ie n .SS """xmlapi_setupreseller()""" .el .SS "\f(CWxmlapi_setupreseller()\fP" .IX Subsection "xmlapi_setupreseller()" Make a cPanel account a Reseller account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setupreseller( $user, $makeowner ); .Ve .ie n .SS """xmlapi_lookupnsip()""" .el .SS "\f(CWxmlapi_lookupnsip()\fP" .IX Subsection "xmlapi_lookupnsip()" Get the \s-1IP\s0 for a nameserver. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_lookupnsip( $nameserver ); .Ve .ie n .SS """xmlapi_listresellers()""" .el .SS "\f(CWxmlapi_listresellers()\fP" .IX Subsection "xmlapi_listresellers()" List all the resellers on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listresellers( ); .Ve .ie n .SS """xmlapi_listacls()""" .el .SS "\f(CWxmlapi_listacls()\fP" .IX Subsection "xmlapi_listacls()" List all of the \s-1ACL\s0 lists available. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_listacls( ); .Ve .ie n .SS """xmlapi_saveacllist()""" .el .SS "\f(CWxmlapi_saveacllist()\fP" .IX Subsection "xmlapi_saveacllist()" Save a new \s-1ACL\s0 list. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_saveacllist( $acllist ); .Ve .ie n .SS """xmlapi_unsetupreseller()""" .el .SS "\f(CWxmlapi_unsetupreseller()\fP" .IX Subsection "xmlapi_unsetupreseller()" Remove reseller permissions from an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_unsetupreseller( $user ); .Ve .ie n .SS """xmlapi_gethostname()""" .el .SS "\f(CWxmlapi_gethostname()\fP" .IX Subsection "xmlapi_gethostname()" Get the hostname of the server currently being queried. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_gethostname( ); .Ve .ie n .SS """xmlapi_fetchsslinfo()""" .el .SS "\f(CWxmlapi_fetchsslinfo()\fP" .IX Subsection "xmlapi_fetchsslinfo()" Get information on a specific \s-1SSL\s0 certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_fetchsslinfo( $domain, $crtdata ); .Ve .ie n .SS """xmlapi_installssl()""" .el .SS "\f(CWxmlapi_installssl()\fP" .IX Subsection "xmlapi_installssl()" Install a new \s-1SSL\s0 certificate. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_installssl( $domain, $user, $cert, $key, $cab, $ip ); .Ve .ie n .SS """xmlapi_passwd()""" .el .SS "\f(CWxmlapi_passwd()\fP" .IX Subsection "xmlapi_passwd()" Change an account's password. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_passwd( $user, $pass ); .Ve .ie n .SS """xmlapi_getlanglist()""" .el .SS "\f(CWxmlapi_getlanglist()\fP" .IX Subsection "xmlapi_getlanglist()" Get a list of languages available on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_getlanglist( ); .Ve .ie n .SS """xmlapi_reboot()""" .el .SS "\f(CWxmlapi_reboot()\fP" .IX Subsection "xmlapi_reboot()" Reboot the server. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_reboot( $force ); .Ve .ie n .SS """xmlapi_accountsummary_user()""" .el .SS "\f(CWxmlapi_accountsummary_user()\fP" .IX Subsection "xmlapi_accountsummary_user()" Get a summary of an account. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_accountsummary_user( $user ); .Ve .ie n .SS """xmlapi_accountsummary_domain()""" .el .SS "\f(CWxmlapi_accountsummary_domain()\fP" .IX Subsection "xmlapi_accountsummary_domain()" Get the summary of an account by specifying the domain. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_accountsummary_domain( $domain ); .Ve .ie n .SS """xmlapi_loadavg()""" .el .SS "\f(CWxmlapi_loadavg()\fP" .IX Subsection "xmlapi_loadavg()" Get the loadavg on the system. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_loadavg( ); .Ve .ie n .SS """xmlapi_restartservice()""" .el .SS "\f(CWxmlapi_restartservice()\fP" .IX Subsection "xmlapi_restartservice()" Restart a service. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_restartservice( $service ); .Ve .ie n .SS """xmlapi_setsiteip_user()""" .el .SS "\f(CWxmlapi_setsiteip_user()\fP" .IX Subsection "xmlapi_setsiteip_user()" Set the \s-1IP\s0 for a specific user. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setsiteip_user( $user, $ip ); .Ve .ie n .SS """xmlapi_setsiteip_domain()""" .el .SS "\f(CWxmlapi_setsiteip_domain()\fP" .IX Subsection "xmlapi_setsiteip_domain()" Set the \s-1IP\s0 for a specific domain. .PP Syntax: .PP .Vb 1 \& $pubapi\->xmlapi_setsiteip_domain( $domain, $ip ); .Ve .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI.3pm 0000644 00000056674 15125143347 0012041 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI 3" .TH cPanel::PublicAPI 3 "2019-11-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI \- A perl interface for interacting with cPanel .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use cPanel::PublicAPI; \& \& # Auto detect authentication information \& my $cp = cPanel::PublicAPI\->new(); \& # or specify a user/password \& my $cp = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqsomeuser\*(Aq, \*(Aqpass\*(Aq => \*(Aqsomepass\*(Aq ); \& # or specify an accesshash \& my $cp = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqsomeuser\*(Aq, \*(Aqaccesshash\*(Aq => $accesshash ); \& # or specify an API token \& my $cp = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqsomeuser\*(Aq, \*(Aqapi_token\*(Aq => $api_token ); \& \& # Perform an xml\-api query \& $cp\->whm_api(\*(Aqlistaccts\*(Aq); \& # Pass parameters to the xml\-api \& $cp\->whm_api(\*(Aqcreateacct\*(Aq, {\*(Aqusername\*(Aq => \*(Aqsomeuser\*(Aq, \*(Aqpassword\*(Aq => \*(Aqs0m3P4$$w()Rd\*(Aq } ); \& # Return JSON from xml\-api (rather than a hash reference) \& $cp\->whm_api(\*(Aqversion\*(Aq, undef, \*(Aqjson\*(Aq); \& \& # Perform an API2 query \& $cp\->cpanel_api2_request(\*(Aqwhostmgr\*(Aq, \& { \& \*(Aqmodule\*(Aq => \*(AqEmail\*(Aq, \& \*(Aqfunc\*(Aq => \*(Aqlistpopswithdisk\*(Aq, \& \*(Aquser\*(Aq => \*(Aqsomeuser\*(Aq, \& } \& ); \& # Perform an API2 query when authenticated as a user \& $cp\->cpanel_api2_request(\*(Aqcpanel\*(Aq, \& { \& \*(Aqmodule\*(Aq => \*(AqEmail\*(Aq, \& \*(Aqfunc\*(Aq => \*(Aqlistpopswithdisk\*(Aq, \& } \& ); \& # Pass parameters to an API2 call \& $cp\->cpanel_api2_request(\*(Aqcpanel\*(Aq \& { \& \*(Aqmodule\*(Aq => \*(AqEmail\*(Aq, \& \*(Aqfunc\*(Aq => \*(Aqaddpop\*(Aq, \& }, \& { \& \*(Aqdomain\*(Aq => \*(Aqdomain.com\*(Aq, \& \*(Aqemail\*(Aq => \*(Aqusername\*(Aq, \& \*(Aqpassword\*(Aq => \*(AqSojmASDM(#(Jinasifodanosd\*(Aq, \& \*(Aqquota\*(Aq => 200 \& }, \& ); \& \& # Perform an API1 query \& $cp\->cpanel_api1_request(\*(Aqwhostmgr\*(Aq, \& { \& \*(Aqmodule\*(Aq => \*(AqLastLogin\*(Aq, \& \*(Aqfunc\*(Aq => \*(Aqlastlogin\*(Aq, \& \*(Aquser\*(Aq => \*(Aqsomeuser\*(Aq \& } \& ); \& # Pass parameters to an API1 query \& $cp\->cpanel_api1_request(\*(Aqcpanel\*(Aq, \& { \& \*(Aqmodule\*(Aq => \*(AqMysql\*(Aq, \& \*(Aqfunc\*(Aq => \*(Aqadduserdb\*(Aq, \& }, \& [ \*(Aqsomedb\*(Aq, \*(Aqsomedbuser\*(Aq, \*(AqALL\*(Aq ] \& ); \& \& # perform an HTTP GET request against a URL \& $cp\->api_request(\*(Aqwhostmgr\*(Aq, \*(Aq/xml\-api/loadavg\*(Aq, \*(AqGET\*(Aq); \& \& # perform an HTTP GET request with parameters \& $cp\->api_request(\*(Aqwhostmgr\*(Aq, \*(Aq/xml\-api/createacct\*(Aq, \*(AqGET\*(Aq, {\*(Aqusername\*(Aq => \*(Aqsomeuser\*(Aq, domain => \*(Aqdomain.com\*(Aq} ); \& \& # perform an HTTP POST request (with parameters) \& $cp\->api_request(\*(Aqwhostmgr\*(Aq, \*(Aq/xml\-api/createacct\*(Aq, \*(AqPOST\*(Aq, {\*(Aqusername\*(Aq => \*(Aqsomeuser\*(Aq, domain => \*(Aqdomain.com\*(Aq} ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" cPanel::PublicAPI is a supported interface for interacting with cPanel's APIs over \s-1HTTP.\s0 This allows you to query either \s-1WHM\s0 or cPanel accounts from a perl interface. The purpose of this module is to provide an easy-to-use interface into cPanel's various APIs without requiring much knowledge of how they work. .SS "Object Construction" .IX Subsection "Object Construction" a cPanel::PublicAPI object is constructed with the \fBnew()\fR method. .PP .Vb 1 \& my $publicapi = cPanel::PublicAPI\->new(); .Ve .PP When passed no parameters, this will create the object using the accesshash in ~/.accesshash. If no .accesshash file exists, it will attempt to use the \s-1REMOTE_PASS\s0 environment variable. If the \s-1REMOTE_PASS\s0 variable is not defined, object creation will error out. .PP \fI\f(BInew()\fI parameters\fR .IX Subsection "new() parameters" .PP options for \fBnew()\fR are specified as a hash reference, the following parameters are supported: .IP "\(bu" 4 user \- The username to authenticate as. .IP "\(bu" 4 pass \- The password to use for authentication. .IP "\(bu" 4 accesshash \- The accesshash to use for authentication (\s-1WHM\s0 only). .IP "\(bu" 4 api_token \- The \s-1API\s0 token to use for authentication. .IP "\(bu" 4 timeout \- The length of time (in seconds) before an http request should time out. Default to 300. .IP "\(bu" 4 ip \- The \s-1IP\s0 to be queried. defaults to 127.0.0.1, if host is defined it will take precedence over the 'ip' parameter. .IP "\(bu" 4 host \- The hostname to be queried. This will take precedence over the 'ip' parameter. .IP "\(bu" 4 usessl \- 1 or 0, Indicates whether communication should be performed over \s-1SSL\s0 or not (default to 1). .IP "\(bu" 4 ssl_verify_mode \- 1 or 0, Indicates whether to verify \s-1SSL\s0 certificates or not. (default to 1). .IP "\(bu" 4 error_log \- Path to where you want debug and error logging information to be written to. If this is not defined or the module is unable to open the path in question, it will default to \s-1STDERR.\s0 .IP "\(bu" 4 debug \- Enables debug logging, which will place considerably more information into the error_log. .IP "\(bu" 4 http_tiny_creator \- An optional code reference that receives the list of key/value pairs that normally goes into HTTP::Tiny’s constructor to create an instance of that class for this module’s internal use. The code reference, when called, should return an object that implements an HTTP::Tiny\-compatible interface. .Sp This parameter is useful for customizing that internal HTTP::Tiny instance that cPanel::PublicAPI uses. Handle with care, though: this parameter may break cPanel::PublicAPI in various ways—some subtle, others less so. .Sp For example, if you want a custom User-Agent header, you might do: .Sp .Vb 6 \& http_tiny_creator => sub { \& return HTTP::Tiny\->new( \& @_, \& agent => \*(AqMy Custom UA String\*(Aq, \& ); \& }, .Ve .PP \fIAuthentication methods\fR .IX Subsection "Authentication methods" .PP This module supports three authentication methods: .IP "1. Username & Password" 4 .IX Item "1. Username & Password" .Vb 2 \& use cPanel::PublicAPI; \& my $pubapi = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqfoo\*(Aq, \*(Aqpass\*(Aq => \*(Aqbar\*(Aq ); .Ve .IP "2. \s-1API\s0 Token" 4 .IX Item "2. API Token" (Note: This method does not work with Webmail.) .Sp To create an \s-1API\s0 token, visit \*(L"Manage \s-1API\s0 Tokens\*(R" in cPanel or \s-1WHM,\s0 and follow the appropriate prompts. Your token will appear in a special notice. Make certain that you save your \s-1API\s0 token in a safe location, as this is the only time the token will be shown to you. .Sp To use an \s-1API\s0 token with this module, do the following: .Sp .Vb 2 \& use cPanel::PublicAPI; \& my $pubapi = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqfoo\*(Aq, \*(Aqapi_token\*(Aq => $string_containing_api_token ); .Ve .IP "3. \s-1WHM\s0 Access Hash" 4 .IX Item "3. WHM Access Hash" \&\fB\s-1NOTE:\s0\fR Accesshash authentication is deprecated as of cPanel & \s-1WHM\s0 version 64. .Sp To configure accesshashes, you can either: .RS 4 .IP "\(bu" 4 In cPanel & \s-1WHM\s0 version 66 and earlier, visit “Setup remote access key” in \s-1WHM\s0 which will generate an accesshash for your server if one does not already exist. .IP "\(bu" 4 Run \fI/usr/local/cpanel/bin/mkaccesshash\fR. This will overwrite any existing access hash. .RE .RS 4 .Sp The generated accesshash is stored in \fI~/.accesshash\fR. .Sp To use an accesshash with this module, do the following: .Sp .Vb 2 \& use cPanel::PublicAPI; \& my $pubapi = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqfoo\*(Aq, \*(Aqaccesshash\*(Aq => $string_containing_access_hash ); .Ve .Sp It should be noted that the accesshash can contain newlines in it. Newlines will be stripped by the object when it attempts to perform a query. .RE .PP \fIDependencies\fR .IX Subsection "Dependencies" .PP This module will fall back on different modules if one fails to load. This allows for compatibility with cPanel & \s-1WHM\s0's internal perl parser and maintain compatibility with a standard perl implementation. The order that it will fall back on serialization modules is: .IP "\(bu" 4 JSON::Syck .IP "\(bu" 4 \&\s-1JSON\s0 .IP "\(bu" 4 \&\s-1JSON::XS\s0 .IP "\(bu" 4 \&\s-1JSON::PP\s0 .PP If you installed this module via \s-1CPAN,\s0 this should never be an issue. If you are wishing to use this module on a system where you do not have access to compiled modules, \s-1JSON::PP\s0 is the recommended serializer. .SH "Two-Factor Authentication (2FA)" .IX Header "Two-Factor Authentication (2FA)" cPanel version 54 and above allows users to configure 2FA on their accounts \- this security policy requires that the \s-1API\s0 queries are performed after authenticating and establishing a session. The workflow to accomodate 2FA will be as so: .PP .Vb 1 \& use cPanel::PublicAPI; \& \& use lib \*(Aq/usr/local/cpanel\*(Aq; \& use Cpanel::Security::Authn::TwoFactorAuth::Google (); # only available in 11.54+ \& \& my $pubapi = cPanel::PublicAPI\->new( \*(Aquser\*(Aq => \*(Aqfoo\*(Aq, \*(Aqpass\*(Aq => \*(Aqbar\*(Aq ); \& my $google_auth = Cpanel::Security::Authn::TwoFactorAuth::Google\->new( \& { \& \*(Aqaccount_name\*(Aq => \*(Aqfoo\*(Aq, \& \*(Aqsecret\*(Aq => $user_2fa_secret, \& \*(Aqissuer\*(Aq => \*(Aq\*(Aq \& } \& ); \& $pubapi\->establish_tfa_session(\*(Aqwhostmgr\*(Aq, $google_auth\->generate_code()); \& $pubapi\->whm_api(\*(Aqapplist\*(Aq); .Ve .PP Anytime you change services (e.g. from 'whostmgr' to 'cpanel'), you must establish the 2FA session for the new service. .PP .Vb 4 \& eval { \& $pubapi\->cpanel_api2_request(\*(Aqcpanel\*(Aq, { \*(Aquser\*(Aq => \*(Aqfoo\*(Aq, \*(Aqmodule\*(Aq => \*(AqMysqlFE\*(Aq, \*(Aqfunc\*(Aq => \*(Aqlistdbs\*(Aq }, {} ); \& }; \& print "failed cause 2fa session wasn\*(Aqt established\en" if $@; \& \& $pubapi\->establish_tfa_session(\*(Aqcpanel\*(Aq, $google_auth\->generate_code()); \& eval { \& $pubapi\->cpanel_api2_request(\*(Aqcpanel\*(Aq, { \*(Aquser\*(Aq => \*(Aqfoo\*(Aq, \*(Aqmodule\*(Aq => \*(AqMysqlFE\*(Aq, \*(Aqfunc\*(Aq => \*(Aqlistdbs\*(Aq }, {} ); \& }; \& print "success\en" if not $@; .Ve .PP \&\fB\s-1NOTE\s0\fR: Additionally, since accesshash authentication is not allowed to establish sessions, you must use the 'user'/'pass' authentication in order to make \s-1API\s0 requests as a user with 2FA configured. .SH "Important Methods" .IX Header "Important Methods" .SS "Querying the xml-api \- \fBwhm_api()\fP" .IX Subsection "Querying the xml-api - whm_api()" The XML-API is \s-1WHM\s0's \s-1API\s0 used for administrative functions is handled via the \fBwhm_api()\fR method. .PP The syntax for whmapi is: .PP .Vb 1 \& $cp\->whm_api($call [, \e%formdata, $format ] ); .Ve .PP The meaning of these parameters is: .IP "\(bu" 4 \&\f(CW$call\fR \- The XML-API call you wish to query .IP "\(bu" 4 \&\f(CW$formdata\fR \- The parameters for the XML-API call in question, f.ex. for suspendacct, here you would pass in a hashref containing “user” and “reason”. If there are no parameters, this can be undef or a blank hash. .IP "\(bu" 4 \&\f(CW$format\fR \- The requested response format. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. .PP By default, \s-1WHM API\s0 v1 is used. If, for legacy reasons, you need to use v0, please set the \f(CW\*(C`api.version\*(C'\fR key to 0 in the formdata parameter. .PP For more information on what calls are available and how they can be referenced, please see the xml-api documentation at <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi>. .SS "Querying cPanel's APIs" .IX Subsection "Querying cPanel's APIs" cPanel supports two APIs, designated \*(L"\s-1API1\*(R"\s0 and \*(L"\s-1API2\*(R".\s0 .PP cPanel \s-1API\s0 calls are seperate into Modules, these module names relate to modules within the Cpanel namespace on a cPanel server. Each module defines a set of functions that are from either \s-1API1\s0 or \s-1API2\s0 (or both). .PP There are two distinct differences between \s-1API1\s0 and \s-1API2:\s0 .IP "\(bu" 4 \&\s-1API1\s0 Takes in ordered parameters and returns strings .IP "\(bu" 4 \&\s-1API2\s0 uses named parameters and returns hashes or arrays of hashes .PP Within the context of the public api, calling a function from \s-1API1\s0 or \s-1API2\s0 will always return a hash, but the specific data returned from the \s-1API\s0 call will be contained within the 'data' key of the response. .PP For more information on the differences between \s-1API1\s0 and \s-1API2\s0 please see the documentation: <http://docs.cpanel.net/twiki/bin/view/DeveloperResources/ApiBasics/WebHome> .PP For information on calling \s-1API1\s0 and \s-1API2\s0 direct via \s-1HTTP,\s0 please see: <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CallingAPIFunctions> .PP \fI\f(BIcpanel_api1_request()\fI\fR .IX Subsection "cpanel_api1_request()" .PP \&\f(CW\*(C`cpanel_api1_request()\*(C'\fR is used to query cPanel's \s-1API1,\s0 the function used for querying \s-1API1\s0 has the following syntax: .PP .Vb 1 \& $cp\->cpanel_api1_request($service, \e%cfg [, \e@params, $format ] ); .Ve .IP "\(bu" 4 \&\f(CW$service\fR \- The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. Only a user with reseller or root access can use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the \f(CW$cfg\fR hash. .IP "\(bu" 4 \&\f(CW$cfg\fR \- A hash reference describing the call you wish to make. Required parameters are 'module' and 'func', which correspond to the module and function of the \s-1API\s0 call you wish to query. If you are querying the \*(L"whostmgr\*(R" service, you will need to specify 'user' as well. .IP "\(bu" 4 \&\f(CW$params\fR \- An array reference containing the parameters you wish to pass to the \s-1API\s0 call. .IP "\(bu" 4 \&\f(CW$format\fR \- The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference. .PP To see what modules and functions are available for making \s-1API1\s0 calls, please see: <http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome> .PP \fI\f(BIcpanel_api2_request()\fI\fR .IX Subsection "cpanel_api2_request()" .PP \&\f(CW\*(C`cpanel_api2_request()\*(C'\fR is used to query cPanel's \s-1API2,\s0 the function use for querying \s-1API2\s0 has the following syntax: .PP .Vb 1 \& $cp\->cpanel_api2_request( $service, \e%cfg [, \e%params, $format ] ); .Ve .IP "\(bu" 4 \&\f(CW$service\fR \- The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. A user that does not have reseller or root access will not be able to use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the \f(CW$cfg\fR hash. .IP "\(bu" 4 \&\f(CW$cfg\fR \- A hash reference describing the call you wish to make. required parameters here are 'module' and 'func', which correspond to the module and function of the \s-1API\s0 call you wish to query. If you are querying the \*(L"whostmgr\*(R" service, you will need to specify 'user' as well. .IP "\(bu" 4 \&\f(CW$params\fR \- An hash reference containing the parameters you wish to pass to the \s-1API\s0 call. .IP "\(bu" 4 \&\f(CW$format\fR \- The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. .PP To see what modules and functions are available for making \s-1API2\s0 calls, please see: <http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome> .SS "\fBapi_request()\fP \- Making direct \s-1URL\s0 requests to cPanel & \s-1WHM.\s0" .IX Subsection "api_request() - Making direct URL requests to cPanel & WHM." There are some situations where you will need to query cPanel and \s-1WHM\s0 URLs directly. This should \s-1ONLY\s0 be done when there is not an \s-1API\s0 call available for the function you wish to query. .PP The function used for querying URLs directly is \fBapi_request()\fR. It will always return a string rather than converting the response into a hash reference. It uses the following syntax: .PP .Vb 1 \& $cp\->api_request( $service, $uri, $method, \e%formdata, $headers) .Ve .IP "\(bu" 4 \&\f(CW$service\fR \- The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail', when passed an numerical value, PublicAPI will query that port directly. .IP "\(bu" 4 \&\f(CW$uri\fR \- The \s-1URL\s0 you wish to query, e.g. '/xml\-api/cpanel' .IP "\(bu" 4 \&\f(CW$method\fR \- '\s-1GET\s0' or '\s-1POST\s0' .IP "\(bu" 4 \&\f(CW$formdata\fR \- The data you wish to pass to the \s-1URL\s0 .IP "\(bu" 4 \&\f(CW$headers\fR \- Any additional headers are to be passed with the request. These can be either a flat string or as a hashref like {'headertitle' => 'headerdata'} .SH "Other Features" .IX Header "Other Features" .ie n .IP """establish_tfa_session()""" 4 .el .IP "\f(CWestablish_tfa_session()\fR" 4 .IX Item "establish_tfa_session()" .PP See \*(L"Two-Factor Authentication (2FA)\*(R" above. .ie n .IP """set_debug()""" 4 .el .IP "\f(CWset_debug()\fR" 4 .IX Item "set_debug()" .PP This function allows you to enable/disable debug mode by passing a value that evaluates to 'true' or 'false'. .ie n .IP """user()""" 4 .el .IP "\f(CWuser()\fR" 4 .IX Item "user()" .PP Allows you to change the user that your PublicAPI object is authenticating with. .ie n .IP """pass()""" 4 .el .IP "\f(CWpass()\fR" 4 .IX Item "pass()" .PP Allows you to change the password that your PublicAPI object is authenticating with, this will remove the stored accesshash from the object. .ie n .IP """accesshash()""" 4 .el .IP "\f(CWaccesshash()\fR" 4 .IX Item "accesshash()" .PP Allows you to change the accesshash that your PublicAPI object is authenticating with, this will remove the stored password from the object. .ie n .IP """api_token()""" 4 .el .IP "\f(CWapi_token()\fR" 4 .IX Item "api_token()" .PP Allows you to change the \s-1API\s0 token that your PublicAPI object is authenticating with, this will remove the stored password from the object. .ie n .IP """format_http_query()""" 4 .el .IP "\f(CWformat_http_query()\fR" 4 .IX Item "format_http_query()" .PP Allows you to construct formdata for an http query from a hash. For Example: .PP .Vb 1 \& $pubapi\->format_http_query( { \*(Aqone\*(Aq => \*(Aq1\*(Aq, \*(Aqtwo\*(Aq => 2 } ); .Ve .PP would return: .PP .Vb 1 \& \*(Aqone=1&two=2\*(Aq .Ve .ie n .IP """format_http_headers()""" 4 .el .IP "\f(CWformat_http_headers()\fR" 4 .IX Item "format_http_headers()" .PP Allows you to construct headers for an http query from a hash. For Example: .PP .Vb 1 \& $pubapi\->format_http_headers( { \*(AqAuthorization\*(Aq => \*(AqBasic cm9vdDpsMGx1cnNtNHJ0IQ==\*(Aq} ); .Ve .PP would return: .PP .Vb 1 \& \*(AqAuthorization: Basic cm9vdDpsMGx1cnNtNHJ0IQ==\er\en\*(Aq .Ve .ie n .IP """$pubapi\->{\*(Aqerror\*(Aq}""" 4 .el .IP "\f(CW$pubapi\->{\*(Aqerror\*(Aq}\fR" 4 .IX Item "$pubapi->{error}" .PP Errors encountered within the class are stored here before being written out to the error_fh filehandle. This can be used for checking the existance of query errors. .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI::WHM.3pm 0000644 00000020241 15125143347 0012556 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM 3" .TH cPanel::PublicAPI::WHM 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM \- Legacy interface for querying WHM. .PP NOTE: This module is provided for legacy purposes, cPanel::PublicAPI should be used instead .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides legacy compatibility support between cPanel::PublicAPI and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). .SH "functions" .IX Header "functions" .ie n .SS """simple_get_whmreq()""" .el .SS "\f(CWsimple_get_whmreq()\fP" .IX Subsection "simple_get_whmreq()" This function makes a \s-1HTTP GET\s0 query to \s-1WHM,\s0 an equivalent function within cPanel::PublicAPI is \f(CW\*(C`api_request()\*(C'\fR. This function uses two arrays to specify arguments to be passed to a specific \s-1URI.\s0 This means that you would need to ensure that they both have the key/pair values in the same place in each array, f.ex: .PP .Vb 2 \& $argref = [\*(Aqvalue1\*(Aq, \*(Aqvalue2\*(Aq, \*(Aqvalue3\*(Aq]; \& $argnameref = [\*(Aqkey1\*(Aq, \*(Aqkey2\*(Aq, \*(Aqkey3\*(Aq]; .Ve .PP would be be specifying: .PP .Vb 1 \& key1=value1&key2=value2&key3=value3 .Ve .PP to be passed to the specified \s-1URI.\s0 .PP Arguments .IP "\(bu" 4 \&\f(CW$uri\fR \- The \s-1URI\s0 you to be queried. .IP "\(bu" 4 \&\f(CW$argref\fR \- An array reference containing the values to be passed. .IP "\(bu" 4 \&\f(CW$argnameref\fR \- An array reference containing the keys to be passed. .IP "\(bu" 4 \&\f(CW$opts\fR \- An array reference containing strings like 'key1=value1' to be passed to the \s-1URI.\s0 .PP This will return a scalar reference of the data returned by cpsrvd. .ie n .SS """simple_post_whmreq()""" .el .SS "\f(CWsimple_post_whmreq()\fP" .IX Subsection "simple_post_whmreq()" This function makes a \s-1HTTP POST\s0 query to \s-1WHM,\s0 an equivalent function within cPanel::PublicAPI is \f(CW\*(C`api_request()\*(C'\fR. This function uses two arrays to specify arguments to be passed to a specific \s-1URI.\s0 This means that you would need to ensure that they both have the key/pair values in the same place in each array, f.ex: .PP .Vb 2 \& $argref = [\*(Aqvalue1\*(Aq, \*(Aqvalue2\*(Aq, \*(Aqvalue3\*(Aq]; \& $argnameref = [\*(Aqkey1\*(Aq, \*(Aqkey2\*(Aq, \*(Aqkey3\*(Aq]; .Ve .PP would be be specifying: .PP .Vb 1 \& key1=value1&key2=value2&key3=value3 .Ve .PP to be passed to the specified \s-1URI.\s0 .PP Arguments .IP "\(bu" 4 \&\f(CW$uri\fR \- The \s-1URI\s0 you to be queried. .IP "\(bu" 4 \&\f(CW$argref\fR \- An array reference containing the values to be passed. .IP "\(bu" 4 \&\f(CW$argnameref\fR \- An array reference containing the keys to be passed. .IP "\(bu" 4 \&\f(CW$opts\fR \- An array reference containing strings like 'key1=value1' to be passed to the \s-1URI.\s0 .PP This will return a scalar containing the data returned by cpsrvd. .ie n .SS """whmreq()""" .el .SS "\f(CWwhmreq()\fP" .IX Subsection "whmreq()" This function is used to querying \s-1WHM\s0 with either \s-1GET\s0 or \s-1POST\s0 data. .IP "\(bu" 4 \&\f(CW$uri\fR \- The \s-1URI\s0 to be queried. .IP "\(bu" 4 \&\f(CW$method\fR \- The method of querying the \s-1URI\s0 (either \s-1GET\s0 or \s-1POST\s0). .IP "\(bu" 4 \&\f(CW$formdata\fR \- The data to be passed to the \s-1URI\s0 formatted as formdata (e.g. 'key1=value1&key2=value2'). .ie n .SS """api1()""" .el .SS "\f(CWapi1()\fP" .IX Subsection "api1()" This function is used to query cPanel's \s-1API1.\s0 This will return the \s-1XML\s0 response from the \s-1XML API\s0's cpanel call. .IP "\(bu" 4 \&\f(CW$user\fR \- The user to execute an \s-1API\s0 call for. .IP "\(bu" 4 \&\f(CW$module\fR \- The module of the \s-1API\s0 call to be executed. .IP "\(bu" 4 \&\f(CW$func\fR \- The name of the \s-1API\s0 call to be executed. .IP "\(bu" 4 \&\f(CW@params\fR \- An array containing the parameters for the \s-1API\s0 call. .ie n .SS """api2()""" .el .SS "\f(CWapi2()\fP" .IX Subsection "api2()" This function is used to query cPanel's \s-1API1.\s0 This will return the \s-1XML\s0 response from the \s-1XML API\s0's cpanel call. .IP "\(bu" 4 \&\f(CW$user\fR \- The user to execute an \s-1API\s0 call for. .IP "\(bu" 4 \&\f(CW$module\fR \- The module of the \s-1API\s0 call to be executed. .IP "\(bu" 4 \&\f(CW$func\fR \- The name of the \s-1API\s0 call to be executed. .IP "\(bu" 4 \&\f(CW%params\fR \- An hash containing the parameters for the \s-1API\s0 call. .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/.exists 0000644 00000000000 15125143347 0007625 0 ustar 00 blib/man3/cPanel::PublicAPI::WHM::CachedVersion.3pm 0000644 00000011561 15125143347 0015405 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM::CachedVersion 3" .TH cPanel::PublicAPI::WHM::CachedVersion 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM::CachedVersion \- Allows for lookups of remote versions of cPanel & WHM. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module allows you to lookup the version of a remote instance of cPanel & \s-1WHM\s0 based off of the contents of /var/cpanel/accounting/cache, if the server is not stored there, it will perform the version call. .PP /var/cpanel must exist in order for this to work, /var/cpanel/accounting and /var/cpanel/accounting/cache will be created if necessary. .SH "\fBcached_version()\fP" .IX Header "cached_version()" This module consists of a single function \- \fBcPanel::PublicAPI::WHM::CachedVersion::cached_version()\fR. It expects an already configured publicapi instance. .PP Syntax: .PP .Vb 2 \& my $pubapi = cPanel::PublicAPI::WHM::CachedVersion\->new( \*(Aqhost\*(Aq => \*(Aqsomehost\*(Aq, \*(Aquser\*(Aq => \*(Aqsomeuser\*(Aq, ... ); \& my $version = $pubapi\->cached_version(); .Ve .PP This will return a string containing the version of the cpanel/whm server being queried. .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI::WHM::DNS.3pm 0000644 00000024017 15125143347 0013314 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM::DNS 3" .TH cPanel::PublicAPI::WHM::DNS 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM::DNS \- A module for interacting with WHM's DNS clustering system. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is intended as a client for querying \s-1WHM\s0's \s-1DNS\s0 clustering system. Unless you are specifically looking to write your own interaction with cPanel's \s-1DNS\s0 system, you should never need to use this module, rather the \s-1DNS\s0 functions within cPanel's XML-API should do what you are looking for: <http://docs.cpanel.net/twiki/bin/vief/AllDocumentation/AutomationIntegration/XmlApi#DNS%20functions> .SH "functions" .IX Header "functions" The functions contained within this module share a similiar naming scheme for the variables used within, please consult the list below when figuring out what each function does. .IP "\(bu" 4 \&\f(CW$zone\fR \- The name of the domain to be used. .IP "\(bu" 4 \&\f(CW$dnsuniqid\fR \- A Unique string used to identify uniquely (suggested: 32 character alphanumeric) .IP "\(bu" 4 \&\f(CW$zones\fR \- A pipe seperated list of domains. .IP "\(bu" 4 \&\f(CW$zonedata\fR \- The contents of a zone file, usually used for sending changes of a zone to another system. .ie n .SS """addtocluster()""" .el .SS "\f(CWaddtocluster()\fP" .IX Subsection "addtocluster()" Add a machine to a \s-1DNS\s0 cluster. .PP Call specific parameters: .IP "\(bu" 4 \&\f(CW$clustermaster\fR \- The \s-1IP\s0 of the machine being added to the cluster. .IP "\(bu" 4 \&\f(CW$user\fR \- The user to authenticate \s-1DNS\s0 requests as. .IP "\(bu" 4 \&\f(CW$pass\fR \- The accesshash or \s-1API\s0 token to authenticate \s-1DNS\s0 requests with .IP "\(bu" 4 \&\f(CW$version\fR \- The version of cPanel/WHM of the machine being added to the cluster .PP Syntax: .PP .Vb 1 \& $pubapi\->addtocluster( $user, $clustermaster, $accesshash, $version ) .Ve .ie n .SS """getzone_local()""" .el .SS "\f(CWgetzone_local()\fP" .IX Subsection "getzone_local()" Get the contents of a zone file. .PP Syntax: .PP .Vb 1 \& $pubapi\->getzone_local( $zone, $dnsuniqid ) .Ve .ie n .SS """getzones_local()""" .el .SS "\f(CWgetzones_local()\fP" .IX Subsection "getzones_local()" Get the contents of multiple zone files, this will be split up as: .PP .Vb 1 \& cpdnszone\-%URI ENCODED ZONENAME%=%URI encoded version of zone file%&cpdnszone... .Ve .PP for each zone in the response .PP Syntax: .PP .Vb 1 \& $pubapi\->getzones_local( $zones, $dnsuniqid ) .Ve .ie n .SS """getallzones_local()""" .el .SS "\f(CWgetallzones_local()\fP" .IX Subsection "getallzones_local()" Like getzones_local, but will return all zones in a cluster. .PP Syntax: .PP .Vb 1 \& $pubapi\->getallzones_local( $dnsuniqid ) .Ve .ie n .SS """cleandns_local()""" .el .SS "\f(CWcleandns_local()\fP" .IX Subsection "cleandns_local()" Clean up any old or unused \s-1DNS\s0 zones from named.conf. .PP Syntax: .PP .Vb 1 \& $pubapi\->cleandns_local( $dnsuniqid ) .Ve .ie n .SS """getips_local()""" .el .SS "\f(CWgetips_local()\fP" .IX Subsection "getips_local()" Get a list of extra IPs available on a system, response will be formated as: .PP \&\f(CW$ip:\fR$netmask:$broadcast .PP Syntax: .PP .Vb 1 \& $pubapi\->getips_local( $dnsuniqid ) .Ve .ie n .SS """getpath_local()""" .el .SS "\f(CWgetpath_local()\fP" .IX Subsection "getpath_local()" Returns a newline separated list containing all the machines that this machine is clustered with in the following format: .PP \&\f(CW$hostname\fR \f(CW$remote_host\fR .PP Syntax: .PP .Vb 1 \& $pubapi\->getpath_local( $dnsuniqid ) .Ve .ie n .SS """removezone_local()""" .el .SS "\f(CWremovezone_local()\fP" .IX Subsection "removezone_local()" Remove a \s-1DNS\s0 zone. .PP Syntax: .PP .Vb 1 \& $pubapi\->removezone_local( $zone, $dnsuniqid ) .Ve .ie n .SS """removezones_local()""" .el .SS "\f(CWremovezones_local()\fP" .IX Subsection "removezones_local()" Remove multiple \s-1DNS\s0 zones. .PP Syntax: .PP .Vb 1 \& $pubapi\->removezones_local( $zones, $dnsuniqid ) .Ve .ie n .SS """reloadzones_local()""" .el .SS "\f(CWreloadzones_local()\fP" .IX Subsection "reloadzones_local()" Force bind to re-read zones files via the \*(L"rndc reload\*(R" command. .PP Syntax: .PP .Vb 1 \& $pubapi\->reloadzones_local( $dnsuniqid, $zones ) .Ve .ie n .SS """reloadbind_local()""" .el .SS "\f(CWreloadbind_local()\fP" .IX Subsection "reloadbind_local()" Run the 'rndc reload' command. If no zones are specified, bind will reload everything. .PP Syntax: .PP .Vb 1 \& $pubapi\->reloadbind_local( $dnsuniqid, $zone ) .Ve .ie n .SS """reconfigbind_local()""" .el .SS "\f(CWreconfigbind_local()\fP" .IX Subsection "reconfigbind_local()" Run the 'rndc reconfig' command. .PP Syntax: .PP .Vb 1 \& $pubapi\->reconfigbind_local( $dnsuniqid, $zone ) .Ve .ie n .SS """quickzoneadd_local()""" .el .SS "\f(CWquickzoneadd_local()\fP" .IX Subsection "quickzoneadd_local()" Add a new zone to a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->quickzoneadd_local( $zone, $zonedata, $dnsuniqid ) .Ve .ie n .SS """savezone_local()""" .el .SS "\f(CWsavezone_local()\fP" .IX Subsection "savezone_local()" Update a zone file with the data specified in \f(CW$zonedata\fR. .PP Syntax: .PP .Vb 1 \& $pubapi\->savezone_local( $zone, $zonedata, $dnsuniqid ) .Ve .ie n .SS """synczones_local()""" .el .SS "\f(CWsynczones_local()\fP" .IX Subsection "synczones_local()" Send a dump of all zones and update zones when required. The zones are sent within the \f(CW$formdata\fR in the following format: .PP .Vb 1 \& cpdnszone\-%URI ENCODED ZONENAME%=%URI encoded version of zone file%&cpdnszone... .Ve .PP Syntax: .PP .Vb 1 \& $pubapi\->synczones_local( $formdata, $dnsuniqid ) .Ve .ie n .SS """addzoneconf_local()""" .el .SS "\f(CWaddzoneconf_local()\fP" .IX Subsection "addzoneconf_local()" Add a zone to the named.conf file. .PP Syntax: .PP .Vb 1 \& $pubapi\->addzoneconf_local( $zone, $dnsuniqid ) .Ve .ie n .SS """getzonelist_local()""" .el .SS "\f(CWgetzonelist_local()\fP" .IX Subsection "getzonelist_local()" Get a newline seperated list of the zones on a system. .PP Syntax: .PP .Vb 1 \& $pubapi\->getzonelist_local( $dnsuniqid ) .Ve .ie n .SS """zoneexists_local()""" .el .SS "\f(CWzoneexists_local()\fP" .IX Subsection "zoneexists_local()" Return boolean value indicating whether a zone exists on a remote system or not. .PP Syntax: .PP .Vb 1 \& $pubapi\->zoneexists_local( $zone, $dnsuniqid ) .Ve .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man3/cPanel::PublicAPI::WHM::Legacy.3pm 0000644 00000010157 15125143347 0014074 0 ustar 00 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "cPanel::PublicAPI::WHM::Legacy 3" .TH cPanel::PublicAPI::WHM::Legacy 3 "2019-03-06" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cPanel::PublicAPI::WHM::Legacy \- A module for handling Cpanel::Accounting backward compatibility within the cPanel::PublicAPI framework. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module should never be used, please use cPanel::PublicAPI\->\fBwhm_api()\fR instead. .SH "Bugs" .IX Header "Bugs" see http://rt.cpan.org to report and view bugs .SH "License" .IX Header "License" Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP \&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\s0 \s-1BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES\s0; \&\s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0 blib/man1/.exists 0000644 00000000000 15125143347 0007623 0 ustar 00 blib/arch/.exists 0000644 00000000000 15125143347 0007704 0 ustar 00 blib/arch/auto/cPanel/PublicAPI/.exists 0000644 00000000000 15125143347 0013626 0 ustar 00 blib/bin/.exists 0000644 00000000000 15125143347 0007537 0 ustar 00 blib/script/.exists 0000644 00000000000 15125143347 0010273 0 ustar 00 blib/lib/cPanel/PublicAPI/WHM.pod 0000444 00000011631 15125143347 0012340 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM - Legacy interface for querying WHM. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). =head1 functions =head2 C<simple_get_whmreq()> This function makes a HTTP GET query to WHM, an equivalent function within L<cPanel::PublicAPI> is C<api_request()>. This function uses two arrays to specify arguments to be passed to a specific URI. This means that you would need to ensure that they both have the key/pair values in the same place in each array, f.ex: $argref = ['value1', 'value2', 'value3']; $argnameref = ['key1', 'key2', 'key3']; would be be specifying: key1=value1&key2=value2&key3=value3 to be passed to the specified URI. Arguments =over =item * $uri - The URI you to be queried. =item * $argref - An array reference containing the values to be passed. =item * $argnameref - An array reference containing the keys to be passed. =item * $opts - An array reference containing strings like 'key1=value1' to be passed to the URI. =back This will return a scalar reference of the data returned by cpsrvd. =head2 C<simple_post_whmreq()> This function makes a HTTP POST query to WHM, an equivalent function within L<cPanel::PublicAPI> is C<api_request()>. This function uses two arrays to specify arguments to be passed to a specific URI. This means that you would need to ensure that they both have the key/pair values in the same place in each array, f.ex: $argref = ['value1', 'value2', 'value3']; $argnameref = ['key1', 'key2', 'key3']; would be be specifying: key1=value1&key2=value2&key3=value3 to be passed to the specified URI. Arguments =over =item * $uri - The URI you to be queried. =item * $argref - An array reference containing the values to be passed. =item * $argnameref - An array reference containing the keys to be passed. =item * $opts - An array reference containing strings like 'key1=value1' to be passed to the URI. =back This will return a scalar containing the data returned by cpsrvd. =head2 C<whmreq()> This function is used to querying WHM with either GET or POST data. =over =item * $uri - The URI to be queried. =item * $method - The method of querying the URI (either GET or POST). =item * $formdata - The data to be passed to the URI formatted as formdata (e.g. 'key1=value1&key2=value2'). =back =head2 C<api1()> This function is used to query cPanel's API1. This will return the XML response from the XML API's cpanel call. =over =item * $user - The user to execute an API call for. =item * $module - The module of the API call to be executed. =item * $func - The name of the API call to be executed. =item * @params - An array containing the parameters for the API call. =back =head2 C<api2()> This function is used to query cPanel's API1. This will return the XML response from the XML API's cpanel call. =over =item * $user - The user to execute an API call for. =item * $module - The module of the API call to be executed. =item * $func - The name of the API call to be executed. =item * %params - An hash containing the parameters for the API call. =back =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/Utils.pm 0000444 00000004256 15125143347 0012644 0 ustar 00 package cPanel::PublicAPI::Utils; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sub remove_trailing_newline { my $string = shift; $string =~ s/\r?\n$//g; return $string; } sub get_string_with_collapsed_trailing_eols { my @copy = @_; # this addresses 'Modification of a read-only value attempted at Cpanel/Accounting.pm ...' from $line =~ below my $txt; foreach my $line (@copy) { if ( ref $line eq 'ARRAY' ) { foreach my $subline ( @{$line} ) { $subline =~ s/[\r\n]+$//g; $txt .= $subline . "\n"; } } else { $line =~ s/[\r\n]+$//g; $txt .= $line . "\n"; } } return $txt; } 1; blib/lib/cPanel/PublicAPI/WHM/CachedVersion.pod 0000444 00000004712 15125143347 0015057 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::CachedVersion - Allows for lookups of remote versions of cPanel & WHM. =head1 DESCRIPTION This module allows you to lookup the version of a remote instance of cPanel & WHM based off of the contents of /var/cpanel/accounting/cache, if the server is not stored there, it will perform the version call. /var/cpanel must exist in order for this to work, /var/cpanel/accounting and /var/cpanel/accounting/cache will be created if necessary. =head1 cached_version() This module consists of a single function - cPanel::PublicAPI::WHM::CachedVersion::cached_version(). It expects an already configured publicapi instance. Syntax: my $pubapi = cPanel::PublicAPI::WHM::CachedVersion->new( 'host' => 'somehost', 'user' => 'someuser', ... ); my $version = $pubapi->cached_version(); This will return a string containing the version of the cpanel/whm server being queried. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/WHM/API.pm 0000444 00000041401 15125143347 0012601 0 ustar 00 package cPanel::PublicAPI::API; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM (); cPanel::PublicAPI::_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; sub api_listaccts { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listaccts', \@_, [ 'search', 'searchtype' ] ) ); } sub api_createacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/createacct', \@_, [ 'username', 'domain', 'password', 'plan' ] ) ); } sub api_removeacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/removeacct', \@_, ['user'] ) ); } sub api_showversion { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/version', \@_ ) ); } sub api_version { goto &xmlapi_showversion; } sub api_applist { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/applist', \@_ ) ); } sub api_generatessl { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/generatessl', \@_, [ 'host', 'pass', 'country', 'state', 'city', 'co', 'cod', 'email', 'xemail' ] ) ); } sub api_generatessl_noemail { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/generatessl', \@_, [ 'host', 'pass', 'country', 'state', 'city', 'co', 'cod', 'email' ], ['noemail=1'] ) ); } sub api_listcrts { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listcrts', \@_ ) ); } # Variable arguments sub api_setresellerlimits { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellerlimits', \@_ ) ); } sub api_setresellerpackagelimit { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellerpackagelimit', \@_, [ 'user', 'package', 'allowerd', 'number', 'no_limit' ] ) ); } sub api_setresellermainip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellermainip', \@_, [ 'user', 'ip' ] ) ); } sub api_setresellerips { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellerips', \@_, [ 'user', 'delegate', 'ips' ] ) ); } sub api_setresellernameservers { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellernameservers', \@_, [ 'user', 'nameservers' ] ) ); } sub api_suspendreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/suspendreseller', \@_, [ 'user', 'reason', 'disallow' ] ) ); } sub api_unsuspendreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/unsuspendreseller', \@_, ['user'] ) ); } # Variable arguments sub api_addzonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/addzonerecord', \@_ ) ); } # Variable arguments sub api_editzonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/editzonerecord', \@_ ) ); } sub api_removezonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/removezonerecord', \@_, [ 'domain', 'Line' ] ) ); } sub api_getzonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/getzonerecord', \@_, [ 'domain', 'Line' ] ) ); } sub api_servicestatus { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/servicestatus', \@_, ['service'] ) ); } sub api_configureservice { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/configureservice', \@_, [ 'service', 'enabled', 'monitored' ] ) ); } sub api_acctcounts { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/acctcounts', \@_, ['user'] ) ); } sub api_domainuserdata { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/domainuserdata', \@_, ['domain'] ) ); } sub api_editquota { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/editquota', \@_, [ 'user', 'quota' ] ) ); } sub api_nvget { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/nvget', \@_, ['key'] ) ); } # The underlying XMLAPI call allows setting multiple nvvars at once by appending # labels to the end of the variable names... i.e. key1, value1 sub api_nvset { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/nvset', \@_, [ 'key', 'value' ] ) ); } sub api_myprivs { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/myprivs', \@_ ) ); } sub api_listzones { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listzones', \@_ ) ); } sub api_sethostname { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/sethostname', \@_, ['hostname'] ) ); } sub api_setresolvers { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresolvers', \@_, [ 'nameserver1', 'nameserver2', 'nameserver3' ] ) ); } sub api_addip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/addip', \@_, [ 'ip', 'netmask' ] ) ); } sub api_delip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/delip', \@_, [ 'ip', 'ethernetdev', 'skipifshutdown' ] ) ); } sub api_listips { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listips', \@_ ) ); } sub api_dumpzone { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/dumpzone', \@_, ['domain'] ) ); } sub api_listpkgs { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listpkgs', \@_ ) ); } sub api_limitbw { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/limitbw', \@_, [ 'user', 'bwlimit' ] ) ); } sub api_showbw { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/showbw', \@_, [ 'month', 'year', 'showres', 'search', 'searchtype' ] ) ); } sub api_killdns { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/killdns', \@_, ['domain'] ) ); } sub api_adddns { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/adddns', \@_, [ 'domain', 'ip', 'trueowner' ] ) ); } sub api_changepackage { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/changepackage', \@_, [ 'user', 'pkg' ] ) ); } sub api_modifyacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/modifyacct', \@_, [ 'user', 'domain', 'HASCGI', 'CPTHEME', 'LANG', 'MAXPOP', 'MAXFTP', 'MAXLST', 'MAXSUB', 'MAXPARK', 'MAXADDON', 'MAXSQL', 'shell' ] ) ); } sub api_suspendacct { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/suspendacct', \@_, [ 'user', 'reason' ] ) ); } sub api_unsuspendacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/unsuspendacct', \@_, ['user'] ) ); } sub api_listsuspended { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listsuspended', \@_ ) ); } sub api_addpkg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/addpkg', \@_, [ 'pkgname', 'quota', 'ip', 'cgi', 'cpmod', 'maxftp', 'maxsql', 'maxpop', 'maxlst', 'maxsub', 'maxpark', 'maxaddon', 'featurelist', 'hasshell', 'bwlimit' ] ) ); } sub api_killpkg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/killpkg', \@_, ['pkg'] ) ); } sub api_editpkg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/editpkg', \@_, [ 'pkgname', 'quota', 'ip', 'cgi', 'cpmod', 'maxftp', 'maxsql', 'maxpop', 'maxlst', 'maxsub', 'maxpark', 'maxaddon', 'featurelist', 'hasshell', 'bwlimit' ] ) ); } sub api_setacls { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setacls', \@_, [ 'reseller', 'acllist' ] ) ); } sub api_terminatereseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/terminatereseller', \@_, [ 'reseller', 'verify' ] ) ); } sub api_resellerstats { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/resellerstats', \@_, ['reseller'] ) ); } sub api_setupreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setupreseller', \@_, [ 'user', 'makeowner' ] ) ); } sub api_lookupnsip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/lookupnsip', \@_, ['nameserver'] ) ); } sub api_listresellers { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listresellers', \@_ ) ); } sub api_listacls { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listacls', \@_ ) ); } sub api_saveacllist { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/saveacllist', \@_, ['acllist'] ) ); } sub api_unsetupreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/unsetupreseller', \@_, ['user'] ) ); } sub api_gethostname { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/gethostname', \@_ ) ); } sub api_fetchsslinfo { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/fetchsslinfo', \@_, [ 'domain', 'crtdata' ] ) ); } sub api_installssl { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/installssl', \@_, [ 'domain', 'user', 'cert', 'key', 'cab', 'ip' ] ) ); } sub api_passwd { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/passwd', \@_, [ 'user', 'pass' ] ) ); } sub api_getlanglist { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/getlanglist', \@_ ) ); } sub api_reboot { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/reboot', \@_, ['force'] ) ); } sub api_accountsummary_user { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/accountsummary', \@_, ['user'] ) ); } sub api_accountsummary_domain { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/accountsummary', \@_, ['domain'] ) ); } sub api_loadavg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/loadavg', \@_ ) ); } sub api_restartservice { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/restartservice', \@_, ['service'] ) ); } sub api_setsiteip_user { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setsiteip', \@_, [ 'user', 'ip' ] ) ); } sub api_setsiteip_domain { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setsiteip', \@_, [ 'domain', 'ip' ] ) ); } sub api_initializemsgcenter { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/initializemsgcenter', \@_, [ 'title', 'id' ] ) ); } sub api_createmsg { my $self = shift; # Need to perform magic to deal with the optional parameters. my @parm_names = ( 'title', 'updated', 'published', 'content', 'author.name', 'author.email', 'author.uri', 'contributor.name', 'contributor.email', 'contributor.uri', 'summary' ); my $extra_count = scalar(@_) - scalar(@parm_names); my $cat_count = int( $extra_count / 3 + ( ( $extra_count % 3 ) && 1 ) ); foreach my $i ( 1 .. $cat_count ) { push @parm_names, "category.$i.term", "category.$i.label", "category.$i.scheme"; } return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/createmsg', \@_, \@parm_names ) ); } sub api_deletemsg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/deletemsg', \@_, ['atom_id'] ) ); } sub api_getmsgfeed { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/getmsgfeed', \@_, ['which'] ) ); } sub serialize { my $self = shift; return $cPanel::PublicAPI::CFG{'api_decode_func'}->(@_); } 1; blib/lib/cPanel/PublicAPI/WHM/JSONAPI.pod 0000444 00000026532 15125143347 0013451 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::API - Legacy interface for querying the xml-api. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). Every method contained within this object can be queried using cPanel::publicAPI::whm_api() instead. For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> =head1 functions =head2 C<jsonapi_listaccts()> Used to list the accounts on a server. Syntax: $pubapi->jsonapi_listaccts( $search, $searchtype ); =head2 C<jsonapi_createacct()> Create a new cPanel account. Syntax: $pubapi->jsonapi_createacct( $username, $domain, $password, $plan ); =head2 C<jsonapi_removeacct()> Terminate an account. Syntax: $pubapi->jsonapi_removeacct( $user ); =head2 C<jsonapi_showversion()> Get the version of cPanel running on the server. Syntax: $pubapi->jsonapi_showversion( ); =head2 C<jsonapi_version()> Get the version of cPanel running on the server (as as showversion) Syntax: $pubapi->jsonapi_version( ); =head2 C<jsonapi_applist()> List out the available xml-api calls. Syntax: $pubapi->jsonapi_applist( ); =head2 C<jsonapi_generatessl()> Generate an ssl certificate. Syntax: $pubapi->jsonapi_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); =head2 C<jsonapi_generatessl_noemail()> Generate an SSL certificate without an email. Syntax: $pubapi->jsonapi_generatessl_noemail( $noemail=1 ); =head2 C<jsonapi_listcrts()> List out the certificates that exist on the server. Syntax: $pubapi->jsonapi_listcrts( ); =head2 C<jsonapi_setresellerlimits()> Set the limits for a single reseller account. Syntax: $pubapi->jsonapi_setresellerlimits( ); =head2 C<jsonapi_setresellerpackagelimit()> Set which packages a reseller account can use. Syntax: $pubapi->jsonapi_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); =head2 C<jsonapi_setresellermainip()> Set a reseller's main IP. Syntax: $pubapi->jsonapi_setresellermainip( $user, $ip ); =head2 C<jsonapi_setresellerips()> Set the IP that a reseller has available to it. Syntax: $pubapi->jsonapi_setresellerips( $user, $delegate, $ips ); =head2 C<jsonapi_setresellernameservers()> Set the nameservers that a reseller uses by default. Syntax: $pubapi->jsonapi_setresellernameservers( $user, $nameservers ); =head2 C<jsonapi_suspendreseller()> Suspend a reseller and all of their accounts. Syntax: $pubapi->jsonapi_suspendreseller( $user, $reason, $disallow ); =head2 C<jsonapi_unsuspendreseller()> Unsuspend a reseller and all of their accounts. Syntax: $pubapi->jsonapi_unsuspendreseller( $user ); =head2 C<jsonapi_addzonerecord()> Add a record to a zone. Syntax: $pubapi->jsonapi_addzonerecord( @args ); =head2 C<jsonapi_editzonerecord()> Edit a zone record. Syntax: $pubapi->jsonapi_editzonerecord(@args ); =head2 C<jsonapi_removezonerecord()> Remove a line from a zone. Syntax: $pubapi->jsonapi_removezonerecord( $domain, $Line ); =head2 C<jsonapi_getzonerecord()> Get a record from a zone. Syntax: $pubapi->jsonapi_getzonerecord( $domain, $Line ); =head2 C<jsonapi_servicestatus()> Get the status of various services running on a system. Syntax: $pubapi->jsonapi_servicestatus( $service ); =head2 C<jsonapi_configureservice()> Enable/Disable various services. Syntax: $pubapi->jsonapi_configureservice( $service, $enabled, $monitored ); =head2 C<jsonapi_acctcounts()> Get the number of accounts on a system/that belong to a reseller. Syntax: $pubapi->jsonapi_acctcounts( $user ); =head2 C<jsonapi_domainuserdata()> Get the information about a specific domain's virtualhost. Syntax: $pubapi->jsonapi_domainuserdata( $domain ); =head2 C<jsonapi_editquota()> Edit a user's quota. Syntax: $pubapi->jsonapi_editquota( $user, $quota ); =head2 C<jsonapi_nvget()> Get non-volatile data. Syntax: $pubapi->jsonapi_nvget( $key ); =head2 C<jsonapi_nvset()> Set non-volatile data. Syntax: $pubapi->jsonapi_nvset( $key, $value ); =head2 C<jsonapi_myprivs()> See what privileges are available to your user. Syntax: $pubapi->jsonapi_myprivs( ); =head2 C<jsonapi_listzones()> List all the zones available to a user. Syntax: $pubapi->jsonapi_listzones( ); =head2 C<jsonapi_sethostname()> Set the hostname of a system. Syntax: $pubapi->jsonapi_sethostname( $hostname ); =head2 C<jsonapi_setresolvers()> Set the resolvers a system uses. Syntax: $pubapi->jsonapi_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); =head2 C<jsonapi_addip()> Add a new IP to a server. Syntax: $pubapi->jsonapi_addip( $ip, $netmask ); =head2 C<jsonapi_delip()> Remove an IP from a server. Syntax: $pubapi->jsonapi_delip( $ip, $ethernetdev, $skipifshutdown ); =head2 C<jsonapi_listips()> List the IPs on a server. Syntax: $pubapi->jsonapi_listips( ); =head2 C<jsonapi_dumpzone()> Get the contents of a zone file. Syntax: $pubapi->jsonapi_dumpzone( $domain ); =head2 C<jsonapi_listpkgs()> List the packages available to your user. Syntax: $pubapi->jsonapi_listpkgs( ); =head2 C<jsonapi_limitbw()> Limit the amount of bandwidth available to an account. Syntax: $pubapi->jsonapi_limitbw( $user, $bwlimit ); =head2 C<jsonapi_showbw()> Show the amount of BW used by an account. Syntax: $pubapi->jsonapi_showbw( $month, $year, $showres, $search, $searchtype ); =head2 C<jsonapi_killdns()> Remove a DNS zone. Syntax: $pubapi->jsonapi_killdns( $domain ); =head2 C<jsonapi_adddns()> Add a dns zone. Syntax: $pubapi->jsonapi_adddns( $domain, $ip, $trueowner ); =head2 C<jsonapi_changepackage()> Change an Account's Package. Syntax: $pubapi->jsonapi_changepackage( $user, $pkg ); =head2 C<jsonapi_modifyacct()> Modify an Account's limits. Syntax: $pubapi->jsonapi_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); =head2 C<jsonapi_suspendacct()> Suspend an account. Syntax: $pubapi->jsonapi_suspendacct( $user, $reason ); =head2 C<jsonapi_unsuspendacct()> Unsuspend an account. Syntax: $pubapi->jsonapi_unsuspendacct( $user ); =head2 C<jsonapi_listsuspended()> List the suspended accounts on a server. Syntax: $pubapi->jsonapi_listsuspended( ); =head2 C<jsonapi_addpkg()> Add a new package. Syntax: $pubapi->jsonapi_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<jsonapi_killpkg()> Remove a package. Syntax: $pubapi->jsonapi_killpkg( $pkg ); =head2 C<jsonapi_editpkg()> Edit a package. Syntax: $pubapi->jsonapi_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<jsonapi_setacls()> Change features available to a reseller. Syntax: $pubapi->jsonapi_setacls( $reseller, $acllist ); =head2 C<jsonapi_terminatereseller()> Remove a reseller. Syntax: $pubapi->jsonapi_terminatereseller( $reseller, $verify ); =head2 C<jsonapi_resellerstats()> Get statistics on a specific reseller. Syntax: $pubapi->jsonapi_resellerstats( $reseller ); =head2 C<jsonapi_setupreseller()> Make a cPanel account a Reseller account. Syntax: $pubapi->jsonapi_setupreseller( $user, $makeowner ); =head2 C<jsonapi_lookupnsip()> Get the IP for a nameserver. Syntax: $pubapi->jsonapi_lookupnsip( $nameserver ); =head2 C<jsonapi_listresellers()> List all the resellers on a system. Syntax: $pubapi->jsonapi_listresellers( ); =head2 C<jsonapi_listacls()> List all of the ACL lists available. Syntax: $pubapi->jsonapi_listacls( ); =head2 C<jsonapi_saveacllist()> Save a new ACL list. Syntax: $pubapi->jsonapi_saveacllist( $acllist ); =head2 C<jsonapi_unsetupreseller()> Remove reseller permissions from an account. Syntax: $pubapi->jsonapi_unsetupreseller( $user ); =head2 C<jsonapi_gethostname()> Get the hostname of the server currently being queried. Syntax: $pubapi->jsonapi_gethostname( ); =head2 C<jsonapi_fetchsslinfo()> Get information on a specific SSL certificate. Syntax: $pubapi->jsonapi_fetchsslinfo( $domain, $crtdata ); =head2 C<jsonapi_installssl()> Install a new SSL certificate. Syntax: $pubapi->jsonapi_installssl( $domain, $user, $cert, $key, $cab, $ip ); =head2 C<jsonapi_passwd()> Change an account's password. Syntax: $pubapi->jsonapi_passwd( $user, $pass ); =head2 C<jsonapi_getlanglist()> Get a list of languages available on a system. Syntax: $pubapi->jsonapi_getlanglist( ); =head2 C<jsonapi_reboot()> Reboot the server. Syntax: $pubapi->jsonapi_reboot( $force ); =head2 C<jsonapi_accountsummary_user()> Get a summary of an account. Syntax: $pubapi->jsonapi_accountsummary_user( $user ); =head2 C<jsonapi_accountsummary_domain()> Get the summary of an account by specifying the domain. Syntax: $pubapi->jsonapi_accountsummary_domain( $domain ); =head2 C<jsonapi_loadavg()> Get the loadavg on the system. Syntax: $pubapi->jsonapi_loadavg( ); =head2 C<jsonapi_restartservice()> Restart a service. Syntax: $pubapi->jsonapi_restartservice( $service ); =head2 C<jsonapi_setsiteip_user()> Set the IP for a specific user. Syntax: $pubapi->jsonapi_setsiteip_user( $user, $ip ); =head2 C<jsonapi_setsiteip_domain()> Set the IP for a specific domain. Syntax: $pubapi->jsonapi_setsiteip_domain( $domain, $ip ); =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/WHM/XMLAPI.pod 0000444 00000026320 15125143347 0013333 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::API - Legacy interface for querying the xml-api. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). Every method contained within this object can be queried using cPanel::publicAPI::whm_api() instead. For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> =head1 functions =head2 C<xmlapi_listaccts()> Used to list the accounts on a server. Syntax: $pubapi->xmlapi_listaccts( $search, $searchtype ); =head2 C<xmlapi_createacct()> Create a new cPanel account. Syntax: $pubapi->xmlapi_createacct( $username, $domain, $password, $plan ); =head2 C<xmlapi_removeacct()> Terminate an account. Syntax: $pubapi->xmlapi_removeacct( $user ); =head2 C<xmlapi_showversion()> Get the version of cPanel running on the server. Syntax: $pubapi->xmlapi_showversion( ); =head2 C<xmlapi_version()> Get the version of cPanel running on the server (as as showversion) Syntax: $pubapi->xmlapi_version( ); =head2 C<xmlapi_applist()> List out the available xml-api calls. Syntax: $pubapi->xmlapi_applist( ); =head2 C<xmlapi_generatessl()> Generate an ssl certificate. Syntax: $pubapi->xmlapi_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); =head2 C<xmlapi_generatessl_noemail()> Generate an SSL certificate without an email. Syntax: $pubapi->xmlapi_generatessl_noemail( $noemail=1 ); =head2 C<xmlapi_listcrts()> List out the certificates that exist on the server. Syntax: $pubapi->xmlapi_listcrts( ); =head2 C<xmlapi_setresellerlimits()> Set the limits for a single reseller account. Syntax: $pubapi->xmlapi_setresellerlimits( ); =head2 C<xmlapi_setresellerpackagelimit()> Set which packages a reseller account can use. Syntax: $pubapi->xmlapi_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); =head2 C<xmlapi_setresellermainip()> Set a reseller's main IP. Syntax: $pubapi->xmlapi_setresellermainip( $user, $ip ); =head2 C<xmlapi_setresellerips()> Set the IP that a reseller has available to it. Syntax: $pubapi->xmlapi_setresellerips( $user, $delegate, $ips ); =head2 C<xmlapi_setresellernameservers()> Set the nameservers that a reseller uses by default. Syntax: $pubapi->xmlapi_setresellernameservers( $user, $nameservers ); =head2 C<xmlapi_suspendreseller()> Suspend a reseller and all of their accounts. Syntax: $pubapi->xmlapi_suspendreseller( $user, $reason, $disallow ); =head2 C<xmlapi_unsuspendreseller()> Unsuspend a reseller and all of their accounts. Syntax: $pubapi->xmlapi_unsuspendreseller( $user ); =head2 C<xmlapi_addzonerecord()> Add a record to a zone. Syntax: $pubapi->xmlapi_addzonerecord( @args ); =head2 C<xmlapi_editzonerecord()> Edit a zone record. Syntax: $pubapi->xmlapi_editzonerecord(@args ); =head2 C<xmlapi_removezonerecord()> Remove a line from a zone. Syntax: $pubapi->xmlapi_removezonerecord( $domain, $Line ); =head2 C<xmlapi_getzonerecord()> Get a record from a zone. Syntax: $pubapi->xmlapi_getzonerecord( $domain, $Line ); =head2 C<xmlapi_servicestatus()> Get the status of various services running on a system. Syntax: $pubapi->xmlapi_servicestatus( $service ); =head2 C<xmlapi_configureservice()> Enable/Disable various services. Syntax: $pubapi->xmlapi_configureservice( $service, $enabled, $monitored ); =head2 C<xmlapi_acctcounts()> Get the number of accounts on a system/that belong to a reseller. Syntax: $pubapi->xmlapi_acctcounts( $user ); =head2 C<xmlapi_domainuserdata()> Get the information about a specific domain's virtualhost. Syntax: $pubapi->xmlapi_domainuserdata( $domain ); =head2 C<xmlapi_editquota()> Edit a user's quota. Syntax: $pubapi->xmlapi_editquota( $user, $quota ); =head2 C<xmlapi_nvget()> Get non-volatile data. Syntax: $pubapi->xmlapi_nvget( $key ); =head2 C<xmlapi_nvset()> Set non-volatile data. Syntax: $pubapi->xmlapi_nvset( $key, $value ); =head2 C<xmlapi_myprivs()> See what privileges are available to your user. Syntax: $pubapi->xmlapi_myprivs( ); =head2 C<xmlapi_listzones()> List all the zones available to a user. Syntax: $pubapi->xmlapi_listzones( ); =head2 C<xmlapi_sethostname()> Set the hostname of a system. Syntax: $pubapi->xmlapi_sethostname( $hostname ); =head2 C<xmlapi_setresolvers()> Set the resolvers a system uses. Syntax: $pubapi->xmlapi_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); =head2 C<xmlapi_addip()> Add a new IP to a server. Syntax: $pubapi->xmlapi_addip( $ip, $netmask ); =head2 C<xmlapi_delip()> Remove an IP from a server. Syntax: $pubapi->xmlapi_delip( $ip, $ethernetdev, $skipifshutdown ); =head2 C<xmlapi_listips()> List the IPs on a server. Syntax: $pubapi->xmlapi_listips( ); =head2 C<xmlapi_dumpzone()> Get the contents of a zone file. Syntax: $pubapi->xmlapi_dumpzone( $domain ); =head2 C<xmlapi_listpkgs()> List the packages available to your user. Syntax: $pubapi->xmlapi_listpkgs( ); =head2 C<xmlapi_limitbw()> Limit the amount of bandwidth available to an account. Syntax: $pubapi->xmlapi_limitbw( $user, $bwlimit ); =head2 C<xmlapi_showbw()> Show the amount of BW used by an account. Syntax: $pubapi->xmlapi_showbw( $month, $year, $showres, $search, $searchtype ); =head2 C<xmlapi_killdns()> Remove a DNS zone. Syntax: $pubapi->xmlapi_killdns( $domain ); =head2 C<xmlapi_adddns()> Add a dns zone. Syntax: $pubapi->xmlapi_adddns( $domain, $ip, $trueowner ); =head2 C<xmlapi_changepackage()> Change an Account's Package. Syntax: $pubapi->xmlapi_changepackage( $user, $pkg ); =head2 C<xmlapi_modifyacct()> Modify an Account's limits. Syntax: $pubapi->xmlapi_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); =head2 C<xmlapi_suspendacct()> Suspend an account. Syntax: $pubapi->xmlapi_suspendacct( $user, $reason ); =head2 C<xmlapi_unsuspendacct()> Unsuspend an account. Syntax: $pubapi->xmlapi_unsuspendacct( $user ); =head2 C<xmlapi_listsuspended()> List the suspended accounts on a server. Syntax: $pubapi->xmlapi_listsuspended( ); =head2 C<xmlapi_addpkg()> Add a new package. Syntax: $pubapi->xmlapi_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<xmlapi_killpkg()> Remove a package. Syntax: $pubapi->xmlapi_killpkg( $pkg ); =head2 C<xmlapi_editpkg()> Edit a package. Syntax: $pubapi->xmlapi_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<xmlapi_setacls()> Change features available to a reseller. Syntax: $pubapi->xmlapi_setacls( $reseller, $acllist ); =head2 C<xmlapi_terminatereseller()> Remove a reseller. Syntax: $pubapi->xmlapi_terminatereseller( $reseller, $verify ); =head2 C<xmlapi_resellerstats()> Get statistics on a specific reseller. Syntax: $pubapi->xmlapi_resellerstats( $reseller ); =head2 C<xmlapi_setupreseller()> Make a cPanel account a Reseller account. Syntax: $pubapi->xmlapi_setupreseller( $user, $makeowner ); =head2 C<xmlapi_lookupnsip()> Get the IP for a nameserver. Syntax: $pubapi->xmlapi_lookupnsip( $nameserver ); =head2 C<xmlapi_listresellers()> List all the resellers on a system. Syntax: $pubapi->xmlapi_listresellers( ); =head2 C<xmlapi_listacls()> List all of the ACL lists available. Syntax: $pubapi->xmlapi_listacls( ); =head2 C<xmlapi_saveacllist()> Save a new ACL list. Syntax: $pubapi->xmlapi_saveacllist( $acllist ); =head2 C<xmlapi_unsetupreseller()> Remove reseller permissions from an account. Syntax: $pubapi->xmlapi_unsetupreseller( $user ); =head2 C<xmlapi_gethostname()> Get the hostname of the server currently being queried. Syntax: $pubapi->xmlapi_gethostname( ); =head2 C<xmlapi_fetchsslinfo()> Get information on a specific SSL certificate. Syntax: $pubapi->xmlapi_fetchsslinfo( $domain, $crtdata ); =head2 C<xmlapi_installssl()> Install a new SSL certificate. Syntax: $pubapi->xmlapi_installssl( $domain, $user, $cert, $key, $cab, $ip ); =head2 C<xmlapi_passwd()> Change an account's password. Syntax: $pubapi->xmlapi_passwd( $user, $pass ); =head2 C<xmlapi_getlanglist()> Get a list of languages available on a system. Syntax: $pubapi->xmlapi_getlanglist( ); =head2 C<xmlapi_reboot()> Reboot the server. Syntax: $pubapi->xmlapi_reboot( $force ); =head2 C<xmlapi_accountsummary_user()> Get a summary of an account. Syntax: $pubapi->xmlapi_accountsummary_user( $user ); =head2 C<xmlapi_accountsummary_domain()> Get the summary of an account by specifying the domain. Syntax: $pubapi->xmlapi_accountsummary_domain( $domain ); =head2 C<xmlapi_loadavg()> Get the loadavg on the system. Syntax: $pubapi->xmlapi_loadavg( ); =head2 C<xmlapi_restartservice()> Restart a service. Syntax: $pubapi->xmlapi_restartservice( $service ); =head2 C<xmlapi_setsiteip_user()> Set the IP for a specific user. Syntax: $pubapi->xmlapi_setsiteip_user( $user, $ip ); =head2 C<xmlapi_setsiteip_domain()> Set the IP for a specific domain. Syntax: $pubapi->xmlapi_setsiteip_domain( $domain, $ip ); =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/WHM/Legacy.pod 0000444 00000003476 15125143347 0013554 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::Legacy - A module for handling Cpanel::Accounting backward compatibility within the cPanel::PublicAPI framework. =head1 DESCRIPTION This module should never be used, please use cPanel::PublicAPI-E<gt>whm_api() instead. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/WHM/Legacy.pm 0000444 00000007650 15125143347 0013404 0 ustar 00 package cPanel::PublicAPI::Legacy; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM (); sub _modpkg { my $self = shift; my $op = shift; my $count = 0; my @OPTS = ('nohtml=1'); if ( $op eq 'edit' ) { push @OPTS, 'edit=yes'; } return $self->simple_get_whmreq( '/scripts/addpkg', \@_, [ 'name', 'hasshell', 'bwlimit', 'quota', 'ip', 'cgi', 'cpmod', 'maxftp', 'maxsql', 'maxpop', 'maxlst', 'maxsub', 'maxpark', 'maxaddon', 'featurelist', 'language' ], \@OPTS ); } sub addpkg { my $self = shift; return $self->_modpkg( 'add', @_ ); } sub editpkg { my $self = shift; return $self->_modpkg( 'edit', @_ ); } sub killpkg { my $self = shift; return $self->simple_get_whmreq( '/scripts/killpkg', \@_, ['pkg'], ['nohtml=1'] ); } sub suspend { my $self = shift; return $self->simple_get_whmreq( '/scripts/remote_suspend', \@_, ['user'] ); } sub unsuspend { my $self = shift; return $self->simple_get_whmreq( '/scripts/remote_unsuspend', \@_, ['user'] ); } sub killacct { my $self = shift; return $self->simple_get_whmreq( '/scripts/killacct', \@_, ['user'], ['nohtml=1'] ); } sub showversion { my $self = shift; return $self->simple_get_whmreq( '/scripts2/showversion', \@_ ); } sub version { my $self = shift; return $self->simple_get_whmreq( '/scripts2/showversion', \@_ ); } sub showhostname { my $self = shift; return $self->simple_get_whmreq( '/scripts2/gethostname', \@_ ); } sub createacct { my $self = shift; return $self->simple_get_whmreq( '/scripts/wwwacct', \@_, [ 'domain', 'username', 'password', 'plan', 'language' ], ['nohtml=1'] ); } sub listpkgs { my $self = shift; my $req = $self->simple_get_whmreq( '/scripts/remote_listpkg', \@_ ); my %PKGS; foreach ( split( /\n/, $req ) ) { my ( $pkg, $contents ) = split( /=/, $_ ); my @CONTENTS = split( /\,/, $contents ); $PKGS{$pkg} = \@CONTENTS; } return wantarray ? %PKGS : \%PKGS; } sub listaccts { my $self = shift; my $req = $self->simple_get_whmreq( '/scripts2/listaccts', \@_, [], ['nohtml=1&viewall=1'] ); my %ACCTS; foreach ( split( /\n/, $req ) ) { next if $_ !~ /=/; my ( $acct, $contents ) = split( /=/, $_ ); my @CONTENTS = split( /\,/, $contents ); $ACCTS{$acct} = \@CONTENTS; } return wantarray ? %ACCTS : \%ACCTS; } 1; blib/lib/cPanel/PublicAPI/WHM/JSONAPI.pm 0000444 00000003401 15125143347 0013271 0 ustar 00 package cPanel::PublicAPI::JSONAPI; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM::API (); foreach my $sub ( grep ( /^api_/, keys %cPanel::PublicAPI:: ) ) { *{"json$sub"} = *$sub; } 1; blib/lib/cPanel/PublicAPI/WHM/DNS.pm 0000444 00000012040 15125143347 0012611 0 ustar 00 package cPanel::PublicAPI::DNS; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM (); use cPanel::PublicAPI::Utils (); sub addtocluster { my $self = shift; my $page = $self->simple_post_whmreq( '/cgi/trustclustermaster.cgi', \@_, [ 'user', 'clustermaster', 'pass', 'version' ], ['recurse=0'] ); if ( $page =~ /has been established/i ) { return 1; } return; } sub getzone_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/getzone_local', \@_, [ 'zone', 'dnsuniqid' ] ); } sub getzones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/getzones_local', \@_, [ 'zones', 'dnsuniqid' ] ); } sub getallzones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/getallzones_local', \@_, ['dnsuniqid'] ); } sub cleandns_local { my $self = shift; return $self->simple_get_whmreq( '/scripts2/cleandns_local', \@_, ['dnsuniqid'] ); } sub getips_local { my $self = shift; return cPanel::PublicAPI::Utils::get_string_with_collapsed_trailing_eols( split( /\n/, ( $self->simple_get_whmreq( '/scripts2/getips_local', \@_, ['dnsuniqid'] ) ) ) ); } sub getpath_local { my $self = shift; return cPanel::PublicAPI::Utils::get_string_with_collapsed_trailing_eols( split( /\n/, ( $self->simple_get_whmreq( '/scripts2/getpath_local', \@_, ['dnsuniqid'] ) ) ) ); } sub removezone_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/removezone_local', \@_, [ 'zone', 'dnsuniqid' ] ); } sub removezones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/removezones_local', \@_, [ 'zones', 'dnsuniqid' ] ); } sub reloadzones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/reloadzones_local', \@_, [ 'dnsuniqid', 'zone' ] ); # backcompat } sub reloadbind_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/reloadbind_local', \@_, [ 'dnsuniqid', 'zone' ] ); # backcompat } sub reconfigbind_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/reconfigbind_local', \@_, [ 'dnsuniqid', 'zone' ] ); # backcompat } sub quickzoneadd_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/quickzoneadd_local', \@_, [ 'zone', 'zonedata', 'dnsuniqid' ] ); } sub savezone_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/savezone_local', \@_, [ 'zone', 'zonedata', 'dnsuniqid' ] ); } sub synczones_local { my ( $self, $formdata, $dnsuniqid ) = @_; cPanel::PublicAPI::_init() if !exists $cPanel::PublicAPI::CFG{'init'}; $formdata =~ s/\&$//g; # formdata must come pre encoded. $formdata .= '&dnsuniqid=' . $cPanel::PublicAPI::CFG{'uri_encoder_func'}->($dnsuniqid); my $page = join( "\n", $self->whmreq( '/scripts2/synczones_local', 'POST', $formdata ) ); return if $self->{'error'}; return $page; } sub addzoneconf_local { my $self = shift; return $self->simple_get_whmreq( '/scripts2/addzoneconf_local', \@_, [ 'zone', 'dnsuniqid' ] ); } sub getzonelist_local { my $self = shift; return split( /\n/, $self->simple_get_whmreq( '/scripts2/getzonelist_local', \@_, ['dnsuniqid'] ) ); } sub zoneexists_local { my $self = shift; my $exists = cPanel::PublicAPI::Utils::remove_trailing_newline( $self->simple_post_whmreq( '/scripts2/zoneexists_local', \@_, [ 'zone', 'dnsuniqid' ] ) ); $exists =~ s/[\r\n]//g; if ( $exists eq '1' ) { return 1; } return 0; } blib/lib/cPanel/PublicAPI/WHM/XMLAPI.pm 0000444 00000003377 15125143347 0013174 0 ustar 00 package cPanel::PublicAPI::XMLAPI; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM::API (); foreach my $sub ( grep ( /^api_/, keys %cPanel::PublicAPI:: ) ) { *{"xml$sub"} = *$sub; } 1; blib/lib/cPanel/PublicAPI/WHM/DNS.pod 0000444 00000013434 15125143347 0012767 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::DNS - A module for interacting with WHM's DNS clustering system. =head1 DESCRIPTION This module is intended as a client for querying WHM's DNS clustering system. Unless you are specifically looking to write your own interaction with cPanel's DNS system, you should never need to use this module, rather the DNS functions within cPanel's XML-API should do what you are looking for: L<http://docs.cpanel.net/twiki/bin/vief/AllDocumentation/AutomationIntegration/XmlApi#DNS%20functions> =head1 functions The functions contained within this module share a similiar naming scheme for the variables used within, please consult the list below when figuring out what each function does. =over =item * $zone - The name of the domain to be used. =item * $dnsuniqid - A Unique string used to identify uniquely (suggested: 32 character alphanumeric) =item * $zones - A pipe seperated list of domains. =item * $zonedata - The contents of a zone file, usually used for sending changes of a zone to another system. =back =head2 C<addtocluster()> Add a machine to a DNS cluster. Call specific parameters: =over =item * $clustermaster - The IP of the machine being added to the cluster. =item * $user - The user to authenticate DNS requests as. =item * $pass - The accesshash or API token to authenticate DNS requests with =item * $version - The version of cPanel/WHM of the machine being added to the cluster =back Syntax: $pubapi->addtocluster( $user, $clustermaster, $accesshash, $version ) =head2 C<getzone_local()> Get the contents of a zone file. Syntax: $pubapi->getzone_local( $zone, $dnsuniqid ) =head2 C<getzones_local()> Get the contents of multiple zone files, this will be split up as: cpdnszone-%URI ENCODED ZONENAME%=%URI encoded version of zone file%&cpdnszone... for each zone in the response Syntax: $pubapi->getzones_local( $zones, $dnsuniqid ) =head2 C<getallzones_local()> Like getzones_local, but will return all zones in a cluster. Syntax: $pubapi->getallzones_local( $dnsuniqid ) =head2 C<cleandns_local()> Clean up any old or unused DNS zones from named.conf. Syntax: $pubapi->cleandns_local( $dnsuniqid ) =head2 C<getips_local()> Get a list of extra IPs available on a system, response will be formated as: $ip:$netmask:$broadcast Syntax: $pubapi->getips_local( $dnsuniqid ) =head2 C<getpath_local()> Returns a newline separated list containing all the machines that this machine is clustered with in the following format: $hostname $remote_host Syntax: $pubapi->getpath_local( $dnsuniqid ) =head2 C<removezone_local()> Remove a DNS zone. Syntax: $pubapi->removezone_local( $zone, $dnsuniqid ) =head2 C<removezones_local()> Remove multiple DNS zones. Syntax: $pubapi->removezones_local( $zones, $dnsuniqid ) =head2 C<reloadzones_local()> Force bind to re-read zones files via the "rndc reload" command. Syntax: $pubapi->reloadzones_local( $dnsuniqid, $zones ) =head2 C<reloadbind_local()> Run the 'rndc reload' command. If no zones are specified, bind will reload everything. Syntax: $pubapi->reloadbind_local( $dnsuniqid, $zone ) =head2 C<reconfigbind_local()> Run the 'rndc reconfig' command. Syntax: $pubapi->reconfigbind_local( $dnsuniqid, $zone ) =head2 C<quickzoneadd_local()> Add a new zone to a system. Syntax: $pubapi->quickzoneadd_local( $zone, $zonedata, $dnsuniqid ) =head2 C<savezone_local()> Update a zone file with the data specified in $zonedata. Syntax: $pubapi->savezone_local( $zone, $zonedata, $dnsuniqid ) =head2 C<synczones_local()> Send a dump of all zones and update zones when required. The zones are sent within the $formdata in the following format: cpdnszone-%URI ENCODED ZONENAME%=%URI encoded version of zone file%&cpdnszone... Syntax: $pubapi->synczones_local( $formdata, $dnsuniqid ) =head2 C<addzoneconf_local()> Add a zone to the named.conf file. Syntax: $pubapi->addzoneconf_local( $zone, $dnsuniqid ) =head2 C<getzonelist_local()> Get a newline seperated list of the zones on a system. Syntax: $pubapi->getzonelist_local( $dnsuniqid ) =head2 C<zoneexists_local()> Return boolean value indicating whether a zone exists on a remote system or not. Syntax: $pubapi->zoneexists_local( $zone, $dnsuniqid ) =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/WHM/CachedVersion.pm 0000444 00000005567 15125143347 0014722 0 ustar 00 package cPanel::PublicAPI::WHM::CachedVersion; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM::Legacy (); our $basedir = '/var/cpanel/accounting'; our $cachedir = '/var/cpanel/accounting/cache'; our $cachettl = 3600; #one hour sub check_dirs { foreach my $dir ( $basedir, $cachedir ) { if ( !-e $dir ) { mkdir( $dir, 0700 ); } } } sub cached_version { my $self = shift; my $ttl = shift || $cachettl; my $version; $self->check_dirs(); my $file = ( $self->{'ip'} || $self->{'host'} ); if ( !$file ) { return; } $file =~ s/\///g; my $fullfile = $cachedir . '/' . $file; my $now = time(); my $mtime = ( stat($fullfile) )[9]; if ( $mtime && ( $mtime + $ttl ) > $now && $mtime < $now ) { if ( open( my $cache_fh, '<', $fullfile ) ) { my $fileversion = readline($cache_fh); if ( $fileversion =~ /^(\d+\.\d+\.\d+)/ ) { $version = $1; } close($cache_fh); } } if ($version) { return $version; } $version = $self->version(); if ($version) { if ( open( my $cache_fh, '>', $fullfile ) ) { print {$cache_fh} $version; close($cache_fh); } } return $version; } 1; blib/lib/cPanel/PublicAPI/WHM/API.pod 0000444 00000025462 15125143347 0012760 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::API - Legacy interface for querying the xml-api. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). Every method contained within this object can be queried using cPanel::publicAPI::whm_api() instead. For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> =head1 functions =head2 C<api_listaccts()> Used to list the accounts on a server. Syntax: $pubapi->api_listaccts( $search, $searchtype ); =head2 C<api_createacct()> Create a new cPanel account. Syntax: $pubapi->api_createacct( $username, $domain, $password, $plan ); =head2 C<api_removeacct()> Terminate an account. Syntax: $pubapi->api_removeacct( $user ); =head2 C<api_showversion()> Get the version of cPanel running on the server. Syntax: $pubapi->api_showversion( ); =head2 C<api_version()> Get the version of cPanel running on the server (as as showversion) Syntax: $pubapi->api_version( ); =head2 C<api_applist()> List out the available xml-api calls. Syntax: $pubapi->api_applist( ); =head2 C<api_generatessl()> Generate an ssl certificate. Syntax: $pubapi->api_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); =head2 C<api_generatessl_noemail()> Generate an SSL certificate without an email. Syntax: $pubapi->api_generatessl_noemail( $noemail=1 ); =head2 C<api_listcrts()> List out the certificates that exist on the server. Syntax: $pubapi->api_listcrts( ); =head2 C<api_setresellerlimits()> Set the limits for a single reseller account. Syntax: $pubapi->api_setresellerlimits( ); =head2 C<api_setresellerpackagelimit()> Set which packages a reseller account can use. Syntax: $pubapi->api_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); =head2 C<api_setresellermainip()> Set a reseller's main IP. Syntax: $pubapi->api_setresellermainip( $user, $ip ); =head2 C<api_setresellerips()> Set the IP that a reseller has available to it. Syntax: $pubapi->api_setresellerips( $user, $delegate, $ips ); =head2 C<api_setresellernameservers()> Set the nameservers that a reseller uses by default. Syntax: $pubapi->api_setresellernameservers( $user, $nameservers ); =head2 C<api_suspendreseller()> Suspend a reseller and all of their accounts. Syntax: $pubapi->api_suspendreseller( $user, $reason, $disallow ); =head2 C<api_unsuspendreseller()> Unsuspend a reseller and all of their accounts. Syntax: $pubapi->api_unsuspendreseller( $user ); =head2 C<api_addzonerecord()> Add a record to a zone. Syntax: $pubapi->api_addzonerecord( @args ); =head2 C<api_editzonerecord()> Edit a zone record. Syntax: $pubapi->api_editzonerecord(@args ); =head2 C<api_removezonerecord()> Remove a line from a zone. Syntax: $pubapi->api_removezonerecord( $domain, $Line ); =head2 C<api_getzonerecord()> Get a record from a zone. Syntax: $pubapi->api_getzonerecord( $domain, $Line ); =head2 C<api_servicestatus()> Get the status of various services running on a system. Syntax: $pubapi->api_servicestatus( $service ); =head2 C<api_configureservice()> Enable/Disable various services. Syntax: $pubapi->api_configureservice( $service, $enabled, $monitored ); =head2 C<api_acctcounts()> Get the number of accounts on a system/that belong to a reseller. Syntax: $pubapi->api_acctcounts( $user ); =head2 C<api_domainuserdata()> Get the information about a specific domain's virtualhost. Syntax: $pubapi->api_domainuserdata( $domain ); =head2 C<api_editquota()> Edit a user's quota. Syntax: $pubapi->api_editquota( $user, $quota ); =head2 C<api_nvget()> Get non-volatile data. Syntax: $pubapi->api_nvget( $key ); =head2 C<api_nvset()> Set non-volatile data. Syntax: $pubapi->api_nvset( $key, $value ); =head2 C<api_myprivs()> See what privileges are available to your user. Syntax: $pubapi->api_myprivs( ); =head2 C<api_listzones()> List all the zones available to a user. Syntax: $pubapi->api_listzones( ); =head2 C<api_sethostname()> Set the hostname of a system. Syntax: $pubapi->api_sethostname( $hostname ); =head2 C<api_setresolvers()> Set the resolvers a system uses. Syntax: $pubapi->api_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); =head2 C<api_addip()> Add a new IP to a server. Syntax: $pubapi->api_addip( $ip, $netmask ); =head2 C<api_delip()> Remove an IP from a server. Syntax: $pubapi->api_delip( $ip, $ethernetdev, $skipifshutdown ); =head2 C<api_listips()> List the IPs on a server. Syntax: $pubapi->api_listips( ); =head2 C<api_dumpzone()> Get the contents of a zone file. Syntax: $pubapi->api_dumpzone( $domain ); =head2 C<api_listpkgs()> List the packages available to your user. Syntax: $pubapi->api_listpkgs( ); =head2 C<api_limitbw()> Limit the amount of bandwidth available to an account. Syntax: $pubapi->api_limitbw( $user, $bwlimit ); =head2 C<api_showbw()> Show the amount of BW used by an account. Syntax: $pubapi->api_showbw( $month, $year, $showres, $search, $searchtype ); =head2 C<api_killdns()> Remove a DNS zone. Syntax: $pubapi->api_killdns( $domain ); =head2 C<api_adddns()> Add a dns zone. Syntax: $pubapi->api_adddns( $domain, $ip, $trueowner ); =head2 C<api_changepackage()> Change an Account's Package. Syntax: $pubapi->api_changepackage( $user, $pkg ); =head2 C<api_modifyacct()> Modify an Account's limits. Syntax: $pubapi->api_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); =head2 C<api_suspendacct()> Suspend an account. Syntax: $pubapi->api_suspendacct( $user, $reason ); =head2 C<api_unsuspendacct()> Unsuspend an account. Syntax: $pubapi->api_unsuspendacct( $user ); =head2 C<api_listsuspended()> List the suspended accounts on a server. Syntax: $pubapi->api_listsuspended( ); =head2 C<api_addpkg()> Add a new package. Syntax: $pubapi->api_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<api_killpkg()> Remove a package. Syntax: $pubapi->api_killpkg( $pkg ); =head2 C<api_editpkg()> Edit a package. Syntax: $pubapi->api_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<api_setacls()> Change features available to a reseller. Syntax: $pubapi->api_setacls( $reseller, $acllist ); =head2 C<api_terminatereseller()> Remove a reseller. Syntax: $pubapi->api_terminatereseller( $reseller, $verify ); =head2 C<api_resellerstats()> Get statistics on a specific reseller. Syntax: $pubapi->api_resellerstats( $reseller ); =head2 C<api_setupreseller()> Make a cPanel account a Reseller account. Syntax: $pubapi->api_setupreseller( $user, $makeowner ); =head2 C<api_lookupnsip()> Get the IP for a nameserver. Syntax: $pubapi->api_lookupnsip( $nameserver ); =head2 C<api_listresellers()> List all the resellers on a system. Syntax: $pubapi->api_listresellers( ); =head2 C<api_listacls()> List all of the ACL lists available. Syntax: $pubapi->api_listacls( ); =head2 C<api_saveacllist()> Save a new ACL list. Syntax: $pubapi->api_saveacllist( $acllist ); =head2 C<api_unsetupreseller()> Remove reseller permissions from an account. Syntax: $pubapi->api_unsetupreseller( $user ); =head2 C<api_gethostname()> Get the hostname of the server currently being queried. Syntax: $pubapi->api_gethostname( ); =head2 C<api_fetchsslinfo()> Get information on a specific SSL certificate. Syntax: $pubapi->api_fetchsslinfo( $domain, $crtdata ); =head2 C<api_installssl()> Install a new SSL certificate. Syntax: $pubapi->api_installssl( $domain, $user, $cert, $key, $cab, $ip ); =head2 C<api_passwd()> Change an account's password. Syntax: $pubapi->api_passwd( $user, $pass ); =head2 C<api_getlanglist()> Get a list of languages available on a system. Syntax: $pubapi->api_getlanglist( ); =head2 C<api_reboot()> Reboot the server. Syntax: $pubapi->api_reboot( $force ); =head2 C<api_accountsummary_user()> Get a summary of an account. Syntax: $pubapi->api_accountsummary_user( $user ); =head2 C<api_accountsummary_domain()> Get the summary of an account by specifying the domain. Syntax: $pubapi->api_accountsummary_domain( $domain ); =head2 C<api_loadavg()> Get the loadavg on the system. Syntax: $pubapi->api_loadavg( ); =head2 C<api_restartservice()> Restart a service. Syntax: $pubapi->api_restartservice( $service ); =head2 C<api_setsiteip_user()> Set the IP for a specific user. Syntax: $pubapi->api_setsiteip_user( $user, $ip ); =head2 C<api_setsiteip_domain()> Set the IP for a specific domain. Syntax: $pubapi->api_setsiteip_domain( $domain, $ip ); =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/Utils.pod 0000444 00000003673 15125143347 0013014 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::Utils - Provides some internally used utility functions for cPanel::PublicAPI, should never be used externally. =head1 Subroutines =head2 remove_trailing_newline() Removes the training newline from the provided string =head2 get_string_with_collapsed_trailing_eols Takes an array or array of arrays and puts them into a newline-seperated string. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/cPanel/PublicAPI/WHM.pm 0000444 00000010043 15125143347 0012166 0 ustar 00 package cPanel::PublicAPI::WHM; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = 1.0; package cPanel::PublicAPI; sub simple_get_whmreq { my ( $self, $uri, $argref, $argnameref, $opts ) = @_; $self->_init() if !exists $cPanel::PublicAPI::CFG{'init'}; $self->debug("simple_get_whmreq: ( $self, $uri, $argref, $argnameref, $opts )\n") if $self->{'debug'}; my $count = 0; if ( !$opts || !ref $opts ) { $opts = []; } if ( ref $argnameref ) { foreach my $arg ( @{$argnameref} ) { push @{$opts}, $cPanel::PublicAPI::CFG{'uri_encoder_func'}->($arg) . '=' . ( $cPanel::PublicAPI::CFG{'uri_encoder_func'}->( $argref->[$count] ) || '' ); $count++; } } my $page_ref = $self->whmreq( $uri . '?' . join( '&', @{$opts} ) ); if ( $self->{'error'} ) { return ''; } return $page_ref; } sub simple_post_whmreq { my ( $self, $uri, $argref, $argnameref, $opts ) = @_; $self->_init() if !exists $cPanel::PublicAPI::CFG{'init'}; $self->debug("simple_post_whmreq: ( $self, $uri, $argref, $argnameref, $opts )") if $self->{'debug'}; my $count = 0; if ( !$opts || !ref $opts ) { $opts = []; } if ( ref $argnameref ) { foreach my $arg ( @{$argnameref} ) { push @{$opts}, $cPanel::PublicAPI::CFG{'uri_encoder_func'}->($arg) . '=' . $cPanel::PublicAPI::CFG{'uri_encoder_func'}->( $argref->[$count] ); $count++; } } my $page_ref = $self->whmreq( $uri, 'POST', join( '&', @{$opts} ) ); if ( $self->{'error'} ) { return ''; } return $page_ref; } sub whmreq { my $self = shift; my $uri = shift; my $method = shift || 'GET'; my $formdata = shift; if ( $method eq 'GET' && $uri =~ /\?/ ) { ( $uri, $formdata ) = split( /\?/, $uri ); } $self->debug("whmreq: ( $self, $uri, $method, $formdata )\n") if $self->{'debug'}; my ( $status, $statusmsg, $data ) = $self->api_request( 'whostmgr', $uri, $method, $formdata ); return wantarray ? split( /\r?\n/, $$data ) : $$data; } sub api1 { #Cpanel::Accounting compat my $self = shift; my $user = shift; my $module = shift; my $func = shift; return $self->cpanel_api1_request( 'whostmgr', { 'user' => $user, 'module' => $module, 'func' => $func }, \@_, 'xml' ); } sub api2 { #Cpanel::Accounting compat my $self = shift; my $user = shift; my $module = shift; my $func = shift; return $self->cpanel_api2_request( 'whostmgr', { 'user' => $user, 'module' => $module, 'func' => $func }, {@_}, 'xml' ); } 1; blib/lib/cPanel/.exists 0000644 00000000000 15125143347 0010737 0 ustar 00 blib/lib/cPanel/PublicAPI.pm 0000444 00000056144 15125143347 0011547 0 ustar 00 package cPanel::PublicAPI; # Copyright 2019 cPanel, L.L.C. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. our $VERSION = '2.8'; use strict; use Carp (); use MIME::Base64 (); use HTTP::Tiny (); use HTTP::CookieJar (); our %CFG; my %PORT_DB = ( 'whostmgr' => { 'ssl' => 2087, 'plaintext' => 2086, }, 'cpanel' => { 'ssl' => 2083, 'plaintext' => 2082, }, 'webmail' => { 'ssl' => 2096, 'plaintext' => 2095, }, ); sub _create_http_tiny { return HTTP::Tiny->new(@_); } sub new { my ( $class, %OPTS ) = @_; my $self = {}; bless( $self, $class ); $self->{'debug'} = $OPTS{'debug'} || 0; $self->{'timeout'} = $OPTS{'timeout'} || 300; $self->{'usessl'} = exists $OPTS{'usessl'} ? $OPTS{'usessl'} : 1; if ( exists $OPTS{'ip'} ) { $self->{'ip'} = $OPTS{'ip'}; } elsif ( exists $OPTS{'host'} ) { $self->{'host'} = $OPTS{'host'}; } else { $self->{'ip'} = '127.0.0.1'; } my $ua_creator = $OPTS{'http_tiny_creator'} || \&_create_http_tiny; $self->{'ua'} = $ua_creator->( agent => "cPanel::PublicAPI/$VERSION ", verify_SSL => ( exists $OPTS{'ssl_verify_mode'} ? $OPTS{'ssl_verify_mode'} : 1 ), keep_alive => ( exists $OPTS{'keepalive'} ? int $OPTS{'keepalive'} : 0 ), timeout => $self->{'timeout'}, ); if ( exists $OPTS{'error_log'} && $OPTS{'error_log'} ne 'STDERR' ) { if ( !open( $self->{'error_fh'}, '>>', $OPTS{'error_log'} ) ) { print STDERR "Unable to open $OPTS{'error_log'} for writing, defaulting to STDERR for error logging: $@\n"; $self->{'error_fh'} = \*STDERR; } } else { $self->{'error_fh'} = \*STDERR; } if ( $OPTS{'user'} ) { $self->{'user'} = $OPTS{'user'}; $self->debug("Using user param from object creation") if $self->{'debug'}; } else { $self->{'user'} = exists $INC{'Cpanel/PwCache.pm'} ? ( Cpanel::PwCache::getpwuid($>) )[0] : ( getpwuid($>) )[0]; $self->debug("Setting user based on current uid ($>)") if $self->{'debug'}; } if ( exists $OPTS{'api_token'} && exists $OPTS{'accesshash'} ) { $self->error('You cannot specify both an accesshash and an API token'); die $self->{'error'}; } # Allow the user to specify an api_token instead of an accesshash. # Though, it will just act as a synonym. $OPTS{'accesshash'} = $OPTS{'api_token'} if $OPTS{'api_token'}; if ( ( !exists( $OPTS{'pass'} ) || $OPTS{'pass'} eq '' ) && ( !exists $OPTS{'accesshash'} || $OPTS{'accesshash'} eq '' ) ) { my $homedir = exists $INC{'Cpanel/PwCache.pm'} ? ( Cpanel::PwCache::getpwuid($>) )[7] : ( getpwuid($>) )[7]; $self->debug("Attempting to detect correct authentication credentials") if $self->{'debug'}; if ( -e $homedir . '/.accesshash' ) { local $/; if ( open( my $hash_fh, '<', $homedir . '/.accesshash' ) ) { $self->{'accesshash'} = readline($hash_fh); $self->{'accesshash'} =~ s/[\r\n]+//g; close($hash_fh); $self->debug("Got accesshash from $homedir/.accesshash") if $self->{'debug'}; } else { $self->debug("Failed to fetch accesshash from $homedir/.accesshash") if $self->{'debug'}; } } elsif ( exists $ENV{'REMOTE_PASSWORD'} && $ENV{'REMOTE_PASSWORD'} && $ENV{'REMOTE_PASSWORD'} ne '__HIDDEN__' && exists $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} =~ /^cpsrvd/ ) { $self->debug("Got user password from the REMOTE_PASSWORD environment variables.") if $self->{'debug'}; $self->{'pass'} = $ENV{'REMOTE_PASSWORD'}; } else { Carp::confess('pass, accesshash, or api_token is a required parameter'); } } elsif ( $OPTS{'pass'} ) { $self->{'pass'} = $OPTS{'pass'}; $self->debug("Using pass param from object creation") if $self->{'debug'}; } else { $OPTS{'accesshash'} =~ s/[\r\n]//; $self->{'accesshash'} = $OPTS{'accesshash'}; $self->debug("Using accesshash param from object creation") if $self->{'debug'}; } $self->_update_operating_mode(); return $self; } sub set_debug { my $self = shift; $self->{'debug'} = int shift; } sub user { my $self = shift; $self->{'user'} = shift; } sub pass { my $self = shift; $self->{'pass'} = shift; delete $self->{'accesshash'}; $self->_update_operating_mode(); } sub accesshash { my $self = shift; $self->{'accesshash'} = shift; delete $self->{'pass'}; $self->_update_operating_mode(); } sub api_token { return shift->accesshash(@_); } sub whm_api { my ( $self, $call, $formdata, $format ) = @_; $self->_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; if ( !defined $call || $call eq '' ) { $self->error("A call was not defined when called cPanel::PublicAPI::whm_api_request()"); } if ( defined $format && $format ne 'xml' && $format ne 'json' && $format ne 'ref' ) { $self->error("cPanel::PublicAPI::whm_api_request() was called with an invalid data format, the only valid format are 'json', 'ref' or 'xml'"); } $formdata ||= {}; if ( ref $formdata ) { $formdata = { 'api.version' => 1, %$formdata }; } elsif ( $formdata !~ /(^|&)api\.version=/ ) { $formdata = "api.version=1&$formdata"; } my $query_format; if ( defined $format ) { $query_format = $format; } else { $query_format = $CFG{'serializer'}; } my $uri = "/$query_format-api/$call"; my ( $status, $statusmsg, $data ) = $self->api_request( 'whostmgr', $uri, 'POST', $formdata ); return $self->_parse_returndata( { 'caller' => 'whm_api', 'data' => $data, 'format' => $format, 'call' => $call } ); } sub api_request { my ( $self, $service, $uri, $method, $formdata, $headers ) = @_; $formdata ||= ''; $method ||= 'GET'; $headers ||= {}; $self->debug("api_request: ( $self, $service, $uri, $method, $formdata, $headers )") if $self->{'debug'}; $self->_init() if !exists $CFG{'init'}; undef $self->{'error'}; my $timeout = $self->{'timeout'} || 300; my $orig_alarm = 0; my $page; my $port = $self->_determine_port_for_service($service); $self->debug("Found port for service $service to be $port (usessl=$self->{'usessl'})") if $self->{'debug'}; eval { $self->{'remote_server'} = $self->{'ip'} || $self->{'host'}; $self->_validate_connection_settings(); if ( $self->{'operating_mode'} eq 'session' ) { $self->_establish_session($service) if !( $self->{'security_tokens'}->{$service} && $self->{'cookie_jars'}->{$service} ); $self->{'ua'}->cookie_jar( $self->{'cookie_jars'}->{$service} ); } my $remote_server = $self->{'remote_server'}; my $attempts = 0; my $finished_request = 0; my $hassigpipe; local $SIG{'ALRM'} = sub { $self->error('Connection Timed Out'); die $self->{'error'}; }; local $SIG{'PIPE'} = sub { $hassigpipe = 1; }; $orig_alarm = alarm($timeout); $formdata = $self->format_http_query($formdata) if ref $formdata; my $scheme = $self->{'usessl'} ? "https" : "http"; my $url = "$scheme://$remote_server:$port"; if ( $self->{'operating_mode'} eq 'session' ) { my $security_token = $self->{'security_tokens'}->{$service}; $url .= '/' . $self->{'security_tokens'}->{$service} . $uri; } else { $url .= $uri; } my $content; if ( $method eq 'POST' || $method eq 'PUT' ) { $content = $formdata; } else { $url .= "?$formdata"; } $self->debug("URL: $url") if $self->{'debug'}; if ( !ref $headers ) { my @lines = split /\r\n/, $headers; $headers = {}; foreach my $line (@lines) { last unless length $line; my ( $key, $value ) = split /:\s*/, $line, 2; next unless length $key; $headers->{$key} ||= []; push @{ $headers->{$key} }, $value; } } if ($self->{'operating_mode'} eq 'accesshash') { my $token_app = ($service eq 'whostmgr') ? 'whm' : $service; $headers->{'Authorization'} = sprintf( '%s %s:%s', $token_app, $self->{'user'}, $self->{'accesshash'}, ); } my $options = { headers => $headers, }; $options->{'content'} = $content if defined $content; my $ua = $self->{'ua'}; while ( ++$attempts < 3 ) { $hassigpipe = 0; my $response = $ua->request( $method, $url, $options ); if ( $response->{'status'} == 599 ) { $self->error("Could not connect to $url: $response->{'content'}"); die $self->{'error'}; #exit eval } if ($hassigpipe) { next; } # http spec says to reconnect my %HEADERS; if ( $self->{'debug'} ) { %HEADERS = %{ $response->{'headers'} }; foreach my $header ( keys %HEADERS ) { $self->debug("HEADER[$header]=[$HEADERS{$header}]"); } if ( exists $HEADERS{'transfer-encoding'} && $HEADERS{'transfer-encoding'} =~ /chunked/i ) { $self->debug("READ TYPE=chunked"); } elsif ( defined $HEADERS{'content-length'} ) { $self->debug("READ TYPE=content-length"); } else { $self->debug("READ TYPE=close"); } } if ( !$response->{'success'} ) { $self->error("Server Error from $remote_server: $response->{'status'} $response->{'reason'}"); } $page = $response->{'content'}; $finished_request = 1; last; } if ( !$finished_request && !$self->{'error'} ) { $self->error("The request could not be completed after the maximum attempts"); } }; if ( $self->{'debug'} && $@ ) { warn $@; } alarm($orig_alarm); # Reset with parent's alarm value return ( $self->{'error'} ? 0 : 1, $self->{'error'}, \$page ); } sub establish_tfa_session { my ( $self, $service, $tfa_token ) = @_; if ( $self->{'operating_mode'} ne 'session' ) { $self->error("2FA-authenticated sessions are not supported when using accesshash keys or API tokens"); die $self->{'error'}; } if ( !( $service && $tfa_token ) ) { $self->error("You must specify the service name, and the 2FA token in order to establish a 2FA-authenticated session"); die $self->{'error'}; } undef $self->{'cookie_jars'}->{$service}; undef $self->{'security_tokens'}->{$service}; return $self->_establish_session( $service, $tfa_token ); } sub _validate_connection_settings { my $self = shift; if ( !$self->{'user'} ) { $self->error("You must specify a user to login as."); die $self->{'error'}; } if ( !$self->{'remote_server'} ) { $self->error("You must set a host to connect to. (missing 'host' and 'ip' parameter)"); die $self->{'error'}; } } sub _update_operating_mode { my $self = shift; if ( exists $self->{'accesshash'} ) { $self->{'accesshash'} =~ s/[\r\n]//g; $self->{'operating_mode'} = 'accesshash'; } elsif ( exists $self->{'pass'} ) { $self->{'operating_mode'} = 'session'; # This is called whenever the pass or accesshash is changed, # so we reset the cookie jars, and tokens on such changes $self->{'cookie_jars'} = { map { $_ => undef } keys %PORT_DB }; $self->{'security_tokens'} = { map { $_ => undef } keys %PORT_DB }; } else { $self->error('You must specify an accesshash, API token, or password'); die $self->{'error'}; } } sub _establish_session { my ( $self, $service, $tfa_token ) = @_; return if $self->{'operating_mode'} ne 'session'; return if $self->{'security_tokens'}->{$service} && $self->{'cookie_jars'}->{$service}; $self->{'cookie_jars'}->{$service} = HTTP::CookieJar->new(); $self->{'ua'}->cookie_jar( $self->{'cookie_jars'}->{$service} ); my $port = $self->_determine_port_for_service($service); my $scheme = $self->{'usessl'} ? "https" : "http"; my $url = "$scheme://$self->{'remote_server'}:$port/login"; my $resp = $self->{'ua'}->post_form( $url, { 'user' => $self->{'user'}, 'pass' => $self->{'pass'}, ( $tfa_token ? ( 'tfa_token' => $tfa_token ) : () ), }, ); if ( my $security_token = ( split /\//, $resp->{'headers'}->{'location'} )[1] ) { $self->{'security_tokens'}->{$service} = $security_token; $self->debug("Established $service session"); return 1; } my $details = $resp->{'reason'}; $details .= " ($resp->{'content'})" if $resp->{'status'} == 599; $self->error("Failed to establish session and parse security token: $resp->{'status'} $details"); die $self->{'error'}; } sub _determine_port_for_service { my ( $self, $service ) = @_; my $port; if ( $self->{'usessl'} ) { $port = $service =~ /^\d+$/ ? $service : $PORT_DB{$service}{'ssl'}; } else { $port = $service =~ /^\d+$/ ? $service : $PORT_DB{$service}{'plaintext'}; } return $port; } sub cpanel_api1_request { my ( $self, $service, $cfg, $formdata, $format ) = @_; my $query_format; if ( defined $format ) { $query_format = $format; } else { $query_format = $CFG{'serializer'}; } $self->_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; my $count = 0; if ( ref $formdata eq 'ARRAY' ) { $formdata = { map { ( 'arg-' . $count++ ) => $_ } @{$formdata} }; } foreach my $cfg_item ( keys %{$cfg} ) { $formdata->{ 'cpanel_' . $query_format . 'api_' . $cfg_item } = $cfg->{$cfg_item}; } $formdata->{ 'cpanel_' . $query_format . 'api_apiversion' } = 1; my ( $status, $statusmsg, $data ) = $self->api_request( $service, '/' . $query_format . '-api/cpanel', ( ( scalar keys %$formdata < 10 && _total_form_length( $formdata, 1024 ) < 1024 ) ? 'GET' : 'POST' ), $formdata ); return $self->_parse_returndata( { 'caller' => 'cpanel_api1', 'data' => $data, 'format' => $format, } ); } sub cpanel_api2_request { my ( $self, $service, $cfg, $formdata, $format ) = @_; $self->_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; my $query_format; if ( defined $format ) { $query_format = $format; } else { $query_format = $CFG{'serializer'}; } foreach my $cfg_item ( keys %{$cfg} ) { $formdata->{ 'cpanel_' . $query_format . 'api_' . $cfg_item } = $cfg->{$cfg_item}; } $formdata->{ 'cpanel_' . $query_format . 'api_apiversion' } = 2; my ( $status, $statusmsg, $data ) = $self->api_request( $service, '/' . $query_format . '-api/cpanel', ( ( scalar keys %$formdata < 10 && _total_form_length( $formdata, 1024 ) < 1024 ) ? 'GET' : 'POST' ), $formdata ); return $self->_parse_returndata( { 'caller' => 'cpanel_api2', 'data' => $data, 'format' => $format, } ); } sub _parse_returndata { my ( $self, $opts_hr ) = @_; if ( $self->{'error'} ) { die $self->{'error'}; } elsif ( ${ $opts_hr->{'data'} } =~ m/tfa_login_form/ ) { $self->error("Two-Factor Authentication enabled on the account. Establish a session with the security token, or disable 2FA on the account"); die $self->{'error'}; } if ( defined $opts_hr->{'format'} && ( $opts_hr->{'format'} eq 'json' || $opts_hr->{'format'} eq 'xml' ) ) { return ${ $opts_hr->{'data'} }; } else { my $parsed_data; eval { $parsed_data = $CFG{'api_decode_func'}->( ${ $opts_hr->{'data'} } ); }; if ( !ref $parsed_data ) { $self->error("There was an issue with parsing the following response from cPanel or WHM: [data=[${$opts_hr->{'data'}}]]"); die $self->{'error'}; } my $error_check_dt = { 'whm_api' => \&_check_whm_api_errors, 'cpanel_api1' => \&_check_cpanel_api1_errors, 'cpanel_api2' => \&_check_cpanel_api2_errors, }; return $error_check_dt->{ $opts_hr->{'caller'} }->( $self, $opts_hr->{'call'}, $parsed_data ); } } sub _check_whm_api_errors { my ( $self, $call, $parsed_data ) = @_; if ( ( exists $parsed_data->{'error'} && $parsed_data->{'error'} =~ /Unknown App Requested/ ) || # xml-api v0 version ( exists $parsed_data->{'metadata'}->{'reason'} && $parsed_data->{'metadata'}->{'reason'} =~ /Unknown app\s+(?:\(.+\))?\s+requested/ ) # xml-api v1 version ) { $self->error("cPanel::PublicAPI::whm_api was called with the invalid API call of: $call."); return; } return $parsed_data; } sub _check_cpanel_api1_errors { my ( $self, undef, $parsed_data ) = @_; if ( exists $parsed_data->{'event'}->{'reason'} && ( $parsed_data->{'event'}->{'reason'} =~ /failed: Undefined subroutine/ || # pre-11.44 error message $parsed_data->{'event'}->{'reason'} =~ m/failed: Can\'t use string/ # 11.44+ error message ) ) { $self->error( "cPanel::PublicAPI::cpanel_api1_request was called with the invalid API1 call of: " . $parsed_data->{'module'} . '::' . $parsed_data->{'func'} ); return; } return $parsed_data; } sub _check_cpanel_api2_errors { my ( $self, undef, $parsed_data ) = @_; if ( exists $parsed_data->{'cpanelresult'}->{'error'} && $parsed_data->{'cpanelresult'}->{'error'} =~ /Could not find function/ ) { # xml-api v1 version $self->error( "cPanel::PublicAPI::cpanel_api2_request was called with the invalid API2 call of: " . $parsed_data->{'cpanelresult'}->{'module'} . '::' . $parsed_data->{'cpanelresult'}->{'func'} ); return; } return $parsed_data; } sub _total_form_length { my $data = shift; my $max = shift; my $size = 0; foreach my $key ( keys %{$data} ) { return 1024 if ( ( $size += ( length($key) + 2 + length( $data->{$key} ) ) ) >= 1024 ); } return $size; } sub _init_serializer { return if exists $CFG{'serializer'}; my $self = shift; #not required foreach my $serializer ( #module, key (cpanel api uri), deserializer function name [ 'JSON::Syck', 'json', 'Load' ], [ 'JSON', 'json', 'decode_json' ], [ 'JSON::XS', 'json', 'decode_json' ], [ 'JSON::PP', 'json', 'decode_json' ], ) { my $serializer_module = $serializer->[0]; my $serializer_key = $serializer->[1]; eval " require $serializer_module; "; if ( !$@ ) { $self->debug("loaded serializer: $serializer_module") if $self && ref $self && $self->{'debug'}; $CFG{'serializer'} = $CFG{'parser_key'} = $serializer_key; $CFG{'serializer_module'} = $CFG{'parser_module'} = $serializer_module; $CFG{'api_decode_func'} = $serializer_module->can($serializer->[2]); last; } else { $self->debug("Failed to load serializer: $serializer_module: @_") if $self && ref $self && $self->{'debug'}; } } if ($@) { Carp::confess("Unable to find a module capable of deserializing the api response."); } } sub _init { return if exists $CFG{'init'}; my $self = shift; #not required $CFG{'init'} = 1; # moved this over to a pattern to allow easy change of deps foreach my $encoder ( [ 'Cpanel/Encoder/URI.pm', 'Cpanel::Encoder::URI', 'uri_encode_str' ], [ 'URI/Escape.pm', 'URI::Escape', 'uri_escape' ], ) { my $module_path = $encoder->[0]; my $module = $encoder->[1]; my $funcname = $encoder->[2]; eval { require $module_path; }; if ( !$@ ) { $self->debug("loaded encoder: $module_path") if $self && ref $self && $self->{'debug'}; $CFG{'uri_encoder_func'} = $module->can($funcname); last; } else { $self->debug("failed to load encoder: $module_path") if $self && ref $self && $self->{'debug'}; } } if ($@) { Carp::confess("Unable to find a module capable of encoding api requests."); } } sub error { my ( $self, $msg ) = @_; print { $self->{'error_fh'} } $msg . "\n"; $self->{'error'} = $msg; } sub debug { my ( $self, $msg ) = @_; print { $self->{'error_fh'} } "debug: " . $msg . "\n"; } sub format_http_headers { my ( $self, $headers ) = @_; if ( ref $headers ) { return '' if !scalar keys %{$headers}; return join( "\r\n", map { $_ ? ( $_ . ': ' . $headers->{$_} ) : () } keys %{$headers} ) . "\r\n"; } return $headers; } sub format_http_query { my ( $self, $formdata ) = @_; if ( ref $formdata ) { return join( '&', map { $CFG{'uri_encoder_func'}->($_) . '=' . $CFG{'uri_encoder_func'}->( $formdata->{$_} ) } sort keys %{$formdata} ); } return $formdata; } blib/lib/cPanel/PublicAPI.pod 0000444 00000043310 15125143347 0011704 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI - A perl interface for interacting with cPanel =head1 SYNOPSIS use cPanel::PublicAPI; # Auto detect authentication information my $cp = cPanel::PublicAPI->new(); # or specify a user/password my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'pass' => 'somepass' ); # or specify an accesshash my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'accesshash' => $accesshash ); # or specify an API token my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'api_token' => $api_token ); # Perform an xml-api query $cp->whm_api('listaccts'); # Pass parameters to the xml-api $cp->whm_api('createacct', {'username' => 'someuser', 'password' => 's0m3P4$$w()Rd' } ); # Return JSON from xml-api (rather than a hash reference) $cp->whm_api('version', undef, 'json'); # Perform an API2 query $cp->cpanel_api2_request('whostmgr', { 'module' => 'Email', 'func' => 'listpopswithdisk', 'user' => 'someuser', } ); # Perform an API2 query when authenticated as a user $cp->cpanel_api2_request('cpanel', { 'module' => 'Email', 'func' => 'listpopswithdisk', } ); # Pass parameters to an API2 call $cp->cpanel_api2_request('cpanel' { 'module' => 'Email', 'func' => 'addpop', }, { 'domain' => 'domain.com', 'email' => 'username', 'password' => 'SojmASDM(#(Jinasifodanosd', 'quota' => 200 }, ); # Perform an API1 query $cp->cpanel_api1_request('whostmgr', { 'module' => 'LastLogin', 'func' => 'lastlogin', 'user' => 'someuser' } ); # Pass parameters to an API1 query $cp->cpanel_api1_request('cpanel', { 'module' => 'Mysql', 'func' => 'adduserdb', }, [ 'somedb', 'somedbuser', 'ALL' ] ); # perform an HTTP GET request against a URL $cp->api_request('whostmgr', '/xml-api/loadavg', 'GET'); # perform an HTTP GET request with parameters $cp->api_request('whostmgr', '/xml-api/createacct', 'GET', {'username' => 'someuser', domain => 'domain.com'} ); # perform an HTTP POST request (with parameters) $cp->api_request('whostmgr', '/xml-api/createacct', 'POST', {'username' => 'someuser', domain => 'domain.com'} ); =head1 DESCRIPTION cPanel::PublicAPI is a supported interface for interacting with cPanel's APIs over HTTP. This allows you to query either WHM or cPanel accounts from a perl interface. The purpose of this module is to provide an easy-to-use interface into cPanel's various APIs without requiring much knowledge of how they work. =head2 Object Construction a cPanel::PublicAPI object is constructed with the new() method. my $publicapi = cPanel::PublicAPI->new(); When passed no parameters, this will create the object using the accesshash in ~/.accesshash. If no .accesshash file exists, it will attempt to use the REMOTE_PASS environment variable. If the REMOTE_PASS variable is not defined, object creation will error out. =head3 new() parameters options for new() are specified as a hash reference, the following parameters are supported: =over =item * user - The username to authenticate as. =item * pass - The password to use for authentication. =item * accesshash - The accesshash to use for authentication (WHM only). =item * api_token - The API token to use for authentication. =item * timeout - The length of time (in seconds) before an http request should time out. Default to 300. =item * ip - The IP to be queried. defaults to 127.0.0.1, if host is defined it will take precedence over the 'ip' parameter. =item * host - The hostname to be queried. This will take precedence over the 'ip' parameter. =item * usessl - 1 or 0, Indicates whether communication should be performed over SSL or not (default to 1). =item * ssl_verify_mode - 1 or 0, Indicates whether to verify SSL certificates or not. (default to 1). =item * error_log - Path to where you want debug and error logging information to be written to. If this is not defined or the module is unable to open the path in question, it will default to STDERR. =item * debug - Enables debug logging, which will place considerably more information into the error_log. =item * http_tiny_creator - An optional code reference that receives the list of key/value pairs that normally goes into L<HTTP::Tiny>’s constructor to create an instance of that class for this module’s internal use. The code reference, when called, should return an object that implements an HTTP::Tiny-compatible interface. This parameter is useful for customizing that internal HTTP::Tiny instance that cPanel::PublicAPI uses. Handle with care, though: this parameter may break cPanel::PublicAPI in various ways—some subtle, others less so. For example, if you want a custom User-Agent header, you might do: http_tiny_creator => sub { return HTTP::Tiny->new( @_, agent => 'My Custom UA String', ); }, =back =head3 Authentication methods This module supports three authentication methods: =over =item 1. Username & Password use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); =item 2. API Token (Note: This method does not work with Webmail.) To create an API token, visit "Manage API Tokens" in cPanel or WHM, and follow the appropriate prompts. Your token will appear in a special notice. Make certain that you save your API token in a safe location, as this is the only time the token will be shown to you. To use an API token with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'api_token' => $string_containing_api_token ); =item 3. WHM Access Hash B<NOTE:> Accesshash authentication is deprecated as of cPanel & WHM version 64. To configure accesshashes, you can either: =over =item * In cPanel & WHM version 66 and earlier, visit “Setup remote access key” in WHM which will generate an accesshash for your server if one does not already exist. =item * Run F</usr/local/cpanel/bin/mkaccesshash>. This will overwrite any existing access hash. =back The generated accesshash is stored in F<~/.accesshash>. To use an accesshash with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'accesshash' => $string_containing_access_hash ); It should be noted that the accesshash can contain newlines in it. Newlines will be stripped by the object when it attempts to perform a query. =back =head3 Dependencies This module will fall back on different modules if one fails to load. This allows for compatibility with cPanel & WHM's internal perl parser and maintain compatibility with a standard perl implementation. The order that it will fall back on serialization modules is: =over =item * JSON::Syck =item * JSON =item * JSON::XS =item * JSON::PP =back If you installed this module via CPAN, this should never be an issue. If you are wishing to use this module on a system where you do not have access to compiled modules, JSON::PP is the recommended serializer. =head1 Two-Factor Authentication (2FA) cPanel version 54 and above allows users to configure 2FA on their accounts - this security policy requires that the API queries are performed after authenticating and establishing a session. The workflow to accomodate 2FA will be as so: use cPanel::PublicAPI; use lib '/usr/local/cpanel'; use Cpanel::Security::Authn::TwoFactorAuth::Google (); # only available in 11.54+ my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); my $google_auth = Cpanel::Security::Authn::TwoFactorAuth::Google->new( { 'account_name' => 'foo', 'secret' => $user_2fa_secret, 'issuer' => '' } ); $pubapi->establish_tfa_session('whostmgr', $google_auth->generate_code()); $pubapi->whm_api('applist'); Anytime you change services (e.g. from 'whostmgr' to 'cpanel'), you must establish the 2FA session for the new service. eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "failed cause 2fa session wasn't established\n" if $@; $pubapi->establish_tfa_session('cpanel', $google_auth->generate_code()); eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "success\n" if not $@; B<NOTE>: Additionally, since accesshash authentication is not allowed to establish sessions, you must use the 'user'/'pass' authentication in order to make API requests as a user with 2FA configured. =head1 Important Methods =head2 Querying the xml-api - whm_api() The XML-API is WHM's API used for administrative functions is handled via the whm_api() method. The syntax for whmapi is: $cp->whm_api($call [, \%formdata, $format ] ); The meaning of these parameters is: =over =item * $call - The XML-API call you wish to query =item * $formdata - The parameters for the XML-API call in question, f.ex. for suspendacct, here you would pass in a hashref containing “user” and “reason”. If there are no parameters, this can be undef or a blank hash. =item * $format - The requested response format. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. =back By default, WHM API v1 is used. If, for legacy reasons, you need to use v0, please set the C<api.version> key to 0 in the formdata parameter. For more information on what calls are available and how they can be referenced, please see the xml-api documentation at L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi>. =head2 Querying cPanel's APIs cPanel supports two APIs, designated "API1" and "API2". cPanel API calls are seperate into Modules, these module names relate to modules within the Cpanel namespace on a cPanel server. Each module defines a set of functions that are from either API1 or API2 (or both). There are two distinct differences between API1 and API2: =over =item * API1 Takes in ordered parameters and returns strings =item * API2 uses named parameters and returns hashes or arrays of hashes =back Within the context of the public api, calling a function from API1 or API2 will always return a hash, but the specific data returned from the API call will be contained within the 'data' key of the response. For more information on the differences between API1 and API2 please see the documentation: L<http://docs.cpanel.net/twiki/bin/view/DeveloperResources/ApiBasics/WebHome> For information on calling API1 and API2 direct via HTTP, please see: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CallingAPIFunctions> =head3 cpanel_api1_request() C<cpanel_api1_request()> is used to query cPanel's API1, the function used for querying API1 has the following syntax: $cp->cpanel_api1_request($service, \%cfg [, \@params, $format ] ); =over =item * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. Only a user with reseller or root access can use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. =item * $cfg - A hash reference describing the call you wish to make. Required parameters are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. =item * $params - An array reference containing the parameters you wish to pass to the API call. =item * $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference. =back To see what modules and functions are available for making API1 calls, please see: L<http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome> =head3 cpanel_api2_request() C<cpanel_api2_request()> is used to query cPanel's API2, the function use for querying API2 has the following syntax: $cp->cpanel_api2_request( $service, \%cfg [, \%params, $format ] ); =over =item * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. A user that does not have reseller or root access will not be able to use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. =item * $cfg - A hash reference describing the call you wish to make. required parameters here are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. =item * $params - An hash reference containing the parameters you wish to pass to the API call. =item * $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. =back To see what modules and functions are available for making API2 calls, please see: L<http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome> =head2 api_request() - Making direct URL requests to cPanel & WHM. There are some situations where you will need to query cPanel and WHM URLs directly. This should ONLY be done when there is not an API call available for the function you wish to query. The function used for querying URLs directly is api_request(). It will always return a string rather than converting the response into a hash reference. It uses the following syntax: $cp->api_request( $service, $uri, $method, \%formdata, $headers) =over =item * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail', when passed an numerical value, PublicAPI will query that port directly. =item * $uri - The URL you wish to query, e.g. '/xml-api/cpanel' =item * $method - 'GET' or 'POST' =item * $formdata - The data you wish to pass to the URL =item * $headers - Any additional headers are to be passed with the request. These can be either a flat string or as a hashref like {'headertitle' =E<gt> 'headerdata'} =back =head1 Other Features =over =item C<establish_tfa_session()> =back See L</Two-Factor Authentication (2FA)> above. =over =item C<set_debug()> =back This function allows you to enable/disable debug mode by passing a value that evaluates to 'true' or 'false'. =over =item C<user()> =back Allows you to change the user that your PublicAPI object is authenticating with. =over =item C<pass()> =back Allows you to change the password that your PublicAPI object is authenticating with, this will remove the stored accesshash from the object. =over =item C<accesshash()> =back Allows you to change the accesshash that your PublicAPI object is authenticating with, this will remove the stored password from the object. =over =item C<api_token()> =back Allows you to change the API token that your PublicAPI object is authenticating with, this will remove the stored password from the object. =over =item C<format_http_query()> =back Allows you to construct formdata for an http query from a hash. For Example: $pubapi->format_http_query( { 'one' => '1', 'two' => 2 } ); would return: 'one=1&two=2' =over =item C<format_http_headers()> =back Allows you to construct headers for an http query from a hash. For Example: $pubapi->format_http_headers( { 'Authorization' => 'Basic cm9vdDpsMGx1cnNtNHJ0IQ=='} ); would return: 'Authorization: Basic cm9vdDpsMGx1cnNtNHJ0IQ==\r\n' =over =item C<$pubapi-E<gt>{'error'}> =back Errors encountered within the class are stored here before being written out to the error_fh filehandle. This can be used for checking the existance of query errors. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blib/lib/auto/cPanel/PublicAPI/.exists 0000644 00000000000 15125143347 0013457 0 ustar 00 MYMETA.yml 0000644 00000001554 15125143347 0006275 0 ustar 00 --- abstract: 'A perl interface for interacting with cPanel' author: - 'cPanel, Inc. <integration@cpanel.net>' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010' license: bsd meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: cPanel-PublicAPI no_index: directory: - t - inc requires: HTTP::CookieJar: '0' HTTP::Tiny: '0.042' IO::Socket::INET: '1.31' IO::Socket::SSL: '1.988' JSON::XS: '2' Test::Exception: '0' Test::More: '0' URI::Escape: '3' resources: bugtracker: https://github.com/CpanelInc/cPanel-PublicAPI/issues repository: git://github.com/CpanelInc/cPanel-PublicAPI.git version: '2.8' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' MANIFEST 0000644 00000002017 15125143347 0005702 0 ustar 00 Changes ignore.txt lib/cPanel/PublicAPI.pm lib/cPanel/PublicAPI.pod lib/cPanel/PublicAPI/Utils.pm lib/cPanel/PublicAPI/Utils.pod lib/cPanel/PublicAPI/WHM.pm lib/cPanel/PublicAPI/WHM.pod lib/cPanel/PublicAPI/WHM/API.pm lib/cPanel/PublicAPI/WHM/API.pod lib/cPanel/PublicAPI/WHM/CachedVersion.pm lib/cPanel/PublicAPI/WHM/CachedVersion.pod lib/cPanel/PublicAPI/WHM/DNS.pm lib/cPanel/PublicAPI/WHM/DNS.pod lib/cPanel/PublicAPI/WHM/JSONAPI.pm lib/cPanel/PublicAPI/WHM/JSONAPI.pod lib/cPanel/PublicAPI/WHM/Legacy.pm lib/cPanel/PublicAPI/WHM/Legacy.pod lib/cPanel/PublicAPI/WHM/XMLAPI.pm lib/cPanel/PublicAPI/WHM/XMLAPI.pod Makefile.PL MANIFEST MANIFEST.SKIP README README.mkdn t/00-load.t t/01-api-format.t t/02-construct.t t/03-api-query.t t/04-tfa-sessions.t t/05-api-query_tokens.t t/check-changes.t t/cpan-changes.t t/lib/PubApiTest.pm t/manifest.t t/pod-coverage.t t/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) lib/cPanel/PublicAPI/WHM.pod 0000644 00000011631 15125143347 0011432 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM - Legacy interface for querying WHM. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). =head1 functions =head2 C<simple_get_whmreq()> This function makes a HTTP GET query to WHM, an equivalent function within L<cPanel::PublicAPI> is C<api_request()>. This function uses two arrays to specify arguments to be passed to a specific URI. This means that you would need to ensure that they both have the key/pair values in the same place in each array, f.ex: $argref = ['value1', 'value2', 'value3']; $argnameref = ['key1', 'key2', 'key3']; would be be specifying: key1=value1&key2=value2&key3=value3 to be passed to the specified URI. Arguments =over =item * $uri - The URI you to be queried. =item * $argref - An array reference containing the values to be passed. =item * $argnameref - An array reference containing the keys to be passed. =item * $opts - An array reference containing strings like 'key1=value1' to be passed to the URI. =back This will return a scalar reference of the data returned by cpsrvd. =head2 C<simple_post_whmreq()> This function makes a HTTP POST query to WHM, an equivalent function within L<cPanel::PublicAPI> is C<api_request()>. This function uses two arrays to specify arguments to be passed to a specific URI. This means that you would need to ensure that they both have the key/pair values in the same place in each array, f.ex: $argref = ['value1', 'value2', 'value3']; $argnameref = ['key1', 'key2', 'key3']; would be be specifying: key1=value1&key2=value2&key3=value3 to be passed to the specified URI. Arguments =over =item * $uri - The URI you to be queried. =item * $argref - An array reference containing the values to be passed. =item * $argnameref - An array reference containing the keys to be passed. =item * $opts - An array reference containing strings like 'key1=value1' to be passed to the URI. =back This will return a scalar containing the data returned by cpsrvd. =head2 C<whmreq()> This function is used to querying WHM with either GET or POST data. =over =item * $uri - The URI to be queried. =item * $method - The method of querying the URI (either GET or POST). =item * $formdata - The data to be passed to the URI formatted as formdata (e.g. 'key1=value1&key2=value2'). =back =head2 C<api1()> This function is used to query cPanel's API1. This will return the XML response from the XML API's cpanel call. =over =item * $user - The user to execute an API call for. =item * $module - The module of the API call to be executed. =item * $func - The name of the API call to be executed. =item * @params - An array containing the parameters for the API call. =back =head2 C<api2()> This function is used to query cPanel's API1. This will return the XML response from the XML API's cpanel call. =over =item * $user - The user to execute an API call for. =item * $module - The module of the API call to be executed. =item * $func - The name of the API call to be executed. =item * %params - An hash containing the parameters for the API call. =back =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/Utils.pm 0000644 00000004256 15125143347 0011736 0 ustar 00 package cPanel::PublicAPI::Utils; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sub remove_trailing_newline { my $string = shift; $string =~ s/\r?\n$//g; return $string; } sub get_string_with_collapsed_trailing_eols { my @copy = @_; # this addresses 'Modification of a read-only value attempted at Cpanel/Accounting.pm ...' from $line =~ below my $txt; foreach my $line (@copy) { if ( ref $line eq 'ARRAY' ) { foreach my $subline ( @{$line} ) { $subline =~ s/[\r\n]+$//g; $txt .= $subline . "\n"; } } else { $line =~ s/[\r\n]+$//g; $txt .= $line . "\n"; } } return $txt; } 1; lib/cPanel/PublicAPI/WHM/CachedVersion.pod 0000644 00000004712 15125143347 0014151 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::CachedVersion - Allows for lookups of remote versions of cPanel & WHM. =head1 DESCRIPTION This module allows you to lookup the version of a remote instance of cPanel & WHM based off of the contents of /var/cpanel/accounting/cache, if the server is not stored there, it will perform the version call. /var/cpanel must exist in order for this to work, /var/cpanel/accounting and /var/cpanel/accounting/cache will be created if necessary. =head1 cached_version() This module consists of a single function - cPanel::PublicAPI::WHM::CachedVersion::cached_version(). It expects an already configured publicapi instance. Syntax: my $pubapi = cPanel::PublicAPI::WHM::CachedVersion->new( 'host' => 'somehost', 'user' => 'someuser', ... ); my $version = $pubapi->cached_version(); This will return a string containing the version of the cpanel/whm server being queried. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/WHM/API.pm 0000644 00000041401 15125143347 0011673 0 ustar 00 package cPanel::PublicAPI::API; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM (); cPanel::PublicAPI::_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; sub api_listaccts { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listaccts', \@_, [ 'search', 'searchtype' ] ) ); } sub api_createacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/createacct', \@_, [ 'username', 'domain', 'password', 'plan' ] ) ); } sub api_removeacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/removeacct', \@_, ['user'] ) ); } sub api_showversion { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/version', \@_ ) ); } sub api_version { goto &xmlapi_showversion; } sub api_applist { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/applist', \@_ ) ); } sub api_generatessl { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/generatessl', \@_, [ 'host', 'pass', 'country', 'state', 'city', 'co', 'cod', 'email', 'xemail' ] ) ); } sub api_generatessl_noemail { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/generatessl', \@_, [ 'host', 'pass', 'country', 'state', 'city', 'co', 'cod', 'email' ], ['noemail=1'] ) ); } sub api_listcrts { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listcrts', \@_ ) ); } # Variable arguments sub api_setresellerlimits { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellerlimits', \@_ ) ); } sub api_setresellerpackagelimit { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellerpackagelimit', \@_, [ 'user', 'package', 'allowerd', 'number', 'no_limit' ] ) ); } sub api_setresellermainip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellermainip', \@_, [ 'user', 'ip' ] ) ); } sub api_setresellerips { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellerips', \@_, [ 'user', 'delegate', 'ips' ] ) ); } sub api_setresellernameservers { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresellernameservers', \@_, [ 'user', 'nameservers' ] ) ); } sub api_suspendreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/suspendreseller', \@_, [ 'user', 'reason', 'disallow' ] ) ); } sub api_unsuspendreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/unsuspendreseller', \@_, ['user'] ) ); } # Variable arguments sub api_addzonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/addzonerecord', \@_ ) ); } # Variable arguments sub api_editzonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/editzonerecord', \@_ ) ); } sub api_removezonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/removezonerecord', \@_, [ 'domain', 'Line' ] ) ); } sub api_getzonerecord { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/getzonerecord', \@_, [ 'domain', 'Line' ] ) ); } sub api_servicestatus { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/servicestatus', \@_, ['service'] ) ); } sub api_configureservice { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/configureservice', \@_, [ 'service', 'enabled', 'monitored' ] ) ); } sub api_acctcounts { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/acctcounts', \@_, ['user'] ) ); } sub api_domainuserdata { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/domainuserdata', \@_, ['domain'] ) ); } sub api_editquota { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/editquota', \@_, [ 'user', 'quota' ] ) ); } sub api_nvget { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/nvget', \@_, ['key'] ) ); } # The underlying XMLAPI call allows setting multiple nvvars at once by appending # labels to the end of the variable names... i.e. key1, value1 sub api_nvset { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/nvset', \@_, [ 'key', 'value' ] ) ); } sub api_myprivs { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/myprivs', \@_ ) ); } sub api_listzones { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listzones', \@_ ) ); } sub api_sethostname { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/sethostname', \@_, ['hostname'] ) ); } sub api_setresolvers { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setresolvers', \@_, [ 'nameserver1', 'nameserver2', 'nameserver3' ] ) ); } sub api_addip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/addip', \@_, [ 'ip', 'netmask' ] ) ); } sub api_delip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/delip', \@_, [ 'ip', 'ethernetdev', 'skipifshutdown' ] ) ); } sub api_listips { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listips', \@_ ) ); } sub api_dumpzone { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/dumpzone', \@_, ['domain'] ) ); } sub api_listpkgs { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listpkgs', \@_ ) ); } sub api_limitbw { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/limitbw', \@_, [ 'user', 'bwlimit' ] ) ); } sub api_showbw { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/showbw', \@_, [ 'month', 'year', 'showres', 'search', 'searchtype' ] ) ); } sub api_killdns { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/killdns', \@_, ['domain'] ) ); } sub api_adddns { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/adddns', \@_, [ 'domain', 'ip', 'trueowner' ] ) ); } sub api_changepackage { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/changepackage', \@_, [ 'user', 'pkg' ] ) ); } sub api_modifyacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/modifyacct', \@_, [ 'user', 'domain', 'HASCGI', 'CPTHEME', 'LANG', 'MAXPOP', 'MAXFTP', 'MAXLST', 'MAXSUB', 'MAXPARK', 'MAXADDON', 'MAXSQL', 'shell' ] ) ); } sub api_suspendacct { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/suspendacct', \@_, [ 'user', 'reason' ] ) ); } sub api_unsuspendacct { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/unsuspendacct', \@_, ['user'] ) ); } sub api_listsuspended { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listsuspended', \@_ ) ); } sub api_addpkg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/addpkg', \@_, [ 'pkgname', 'quota', 'ip', 'cgi', 'cpmod', 'maxftp', 'maxsql', 'maxpop', 'maxlst', 'maxsub', 'maxpark', 'maxaddon', 'featurelist', 'hasshell', 'bwlimit' ] ) ); } sub api_killpkg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/killpkg', \@_, ['pkg'] ) ); } sub api_editpkg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/editpkg', \@_, [ 'pkgname', 'quota', 'ip', 'cgi', 'cpmod', 'maxftp', 'maxsql', 'maxpop', 'maxlst', 'maxsub', 'maxpark', 'maxaddon', 'featurelist', 'hasshell', 'bwlimit' ] ) ); } sub api_setacls { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setacls', \@_, [ 'reseller', 'acllist' ] ) ); } sub api_terminatereseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/terminatereseller', \@_, [ 'reseller', 'verify' ] ) ); } sub api_resellerstats { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/resellerstats', \@_, ['reseller'] ) ); } sub api_setupreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setupreseller', \@_, [ 'user', 'makeowner' ] ) ); } sub api_lookupnsip { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/lookupnsip', \@_, ['nameserver'] ) ); } sub api_listresellers { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listresellers', \@_ ) ); } sub api_listacls { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/listacls', \@_ ) ); } sub api_saveacllist { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/saveacllist', \@_, ['acllist'] ) ); } sub api_unsetupreseller { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/unsetupreseller', \@_, ['user'] ) ); } sub api_gethostname { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/gethostname', \@_ ) ); } sub api_fetchsslinfo { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/fetchsslinfo', \@_, [ 'domain', 'crtdata' ] ) ); } sub api_installssl { my $self = shift; return $self->serialize( $self->simple_post_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/installssl', \@_, [ 'domain', 'user', 'cert', 'key', 'cab', 'ip' ] ) ); } sub api_passwd { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/passwd', \@_, [ 'user', 'pass' ] ) ); } sub api_getlanglist { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/getlanglist', \@_ ) ); } sub api_reboot { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/reboot', \@_, ['force'] ) ); } sub api_accountsummary_user { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/accountsummary', \@_, ['user'] ) ); } sub api_accountsummary_domain { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/accountsummary', \@_, ['domain'] ) ); } sub api_loadavg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/loadavg', \@_ ) ); } sub api_restartservice { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/restartservice', \@_, ['service'] ) ); } sub api_setsiteip_user { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setsiteip', \@_, [ 'user', 'ip' ] ) ); } sub api_setsiteip_domain { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/setsiteip', \@_, [ 'domain', 'ip' ] ) ); } sub api_initializemsgcenter { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/initializemsgcenter', \@_, [ 'title', 'id' ] ) ); } sub api_createmsg { my $self = shift; # Need to perform magic to deal with the optional parameters. my @parm_names = ( 'title', 'updated', 'published', 'content', 'author.name', 'author.email', 'author.uri', 'contributor.name', 'contributor.email', 'contributor.uri', 'summary' ); my $extra_count = scalar(@_) - scalar(@parm_names); my $cat_count = int( $extra_count / 3 + ( ( $extra_count % 3 ) && 1 ) ); foreach my $i ( 1 .. $cat_count ) { push @parm_names, "category.$i.term", "category.$i.label", "category.$i.scheme"; } return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/createmsg', \@_, \@parm_names ) ); } sub api_deletemsg { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/deletemsg', \@_, ['atom_id'] ) ); } sub api_getmsgfeed { my $self = shift; return $self->serialize( $self->simple_get_whmreq( '/' . $cPanel::PublicAPI::CFG{'serializer'} . '-api/getmsgfeed', \@_, ['which'] ) ); } sub serialize { my $self = shift; return $cPanel::PublicAPI::CFG{'api_decode_func'}->(@_); } 1; lib/cPanel/PublicAPI/WHM/JSONAPI.pod 0000644 00000026532 15125143347 0012543 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::API - Legacy interface for querying the xml-api. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). Every method contained within this object can be queried using cPanel::publicAPI::whm_api() instead. For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> =head1 functions =head2 C<jsonapi_listaccts()> Used to list the accounts on a server. Syntax: $pubapi->jsonapi_listaccts( $search, $searchtype ); =head2 C<jsonapi_createacct()> Create a new cPanel account. Syntax: $pubapi->jsonapi_createacct( $username, $domain, $password, $plan ); =head2 C<jsonapi_removeacct()> Terminate an account. Syntax: $pubapi->jsonapi_removeacct( $user ); =head2 C<jsonapi_showversion()> Get the version of cPanel running on the server. Syntax: $pubapi->jsonapi_showversion( ); =head2 C<jsonapi_version()> Get the version of cPanel running on the server (as as showversion) Syntax: $pubapi->jsonapi_version( ); =head2 C<jsonapi_applist()> List out the available xml-api calls. Syntax: $pubapi->jsonapi_applist( ); =head2 C<jsonapi_generatessl()> Generate an ssl certificate. Syntax: $pubapi->jsonapi_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); =head2 C<jsonapi_generatessl_noemail()> Generate an SSL certificate without an email. Syntax: $pubapi->jsonapi_generatessl_noemail( $noemail=1 ); =head2 C<jsonapi_listcrts()> List out the certificates that exist on the server. Syntax: $pubapi->jsonapi_listcrts( ); =head2 C<jsonapi_setresellerlimits()> Set the limits for a single reseller account. Syntax: $pubapi->jsonapi_setresellerlimits( ); =head2 C<jsonapi_setresellerpackagelimit()> Set which packages a reseller account can use. Syntax: $pubapi->jsonapi_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); =head2 C<jsonapi_setresellermainip()> Set a reseller's main IP. Syntax: $pubapi->jsonapi_setresellermainip( $user, $ip ); =head2 C<jsonapi_setresellerips()> Set the IP that a reseller has available to it. Syntax: $pubapi->jsonapi_setresellerips( $user, $delegate, $ips ); =head2 C<jsonapi_setresellernameservers()> Set the nameservers that a reseller uses by default. Syntax: $pubapi->jsonapi_setresellernameservers( $user, $nameservers ); =head2 C<jsonapi_suspendreseller()> Suspend a reseller and all of their accounts. Syntax: $pubapi->jsonapi_suspendreseller( $user, $reason, $disallow ); =head2 C<jsonapi_unsuspendreseller()> Unsuspend a reseller and all of their accounts. Syntax: $pubapi->jsonapi_unsuspendreseller( $user ); =head2 C<jsonapi_addzonerecord()> Add a record to a zone. Syntax: $pubapi->jsonapi_addzonerecord( @args ); =head2 C<jsonapi_editzonerecord()> Edit a zone record. Syntax: $pubapi->jsonapi_editzonerecord(@args ); =head2 C<jsonapi_removezonerecord()> Remove a line from a zone. Syntax: $pubapi->jsonapi_removezonerecord( $domain, $Line ); =head2 C<jsonapi_getzonerecord()> Get a record from a zone. Syntax: $pubapi->jsonapi_getzonerecord( $domain, $Line ); =head2 C<jsonapi_servicestatus()> Get the status of various services running on a system. Syntax: $pubapi->jsonapi_servicestatus( $service ); =head2 C<jsonapi_configureservice()> Enable/Disable various services. Syntax: $pubapi->jsonapi_configureservice( $service, $enabled, $monitored ); =head2 C<jsonapi_acctcounts()> Get the number of accounts on a system/that belong to a reseller. Syntax: $pubapi->jsonapi_acctcounts( $user ); =head2 C<jsonapi_domainuserdata()> Get the information about a specific domain's virtualhost. Syntax: $pubapi->jsonapi_domainuserdata( $domain ); =head2 C<jsonapi_editquota()> Edit a user's quota. Syntax: $pubapi->jsonapi_editquota( $user, $quota ); =head2 C<jsonapi_nvget()> Get non-volatile data. Syntax: $pubapi->jsonapi_nvget( $key ); =head2 C<jsonapi_nvset()> Set non-volatile data. Syntax: $pubapi->jsonapi_nvset( $key, $value ); =head2 C<jsonapi_myprivs()> See what privileges are available to your user. Syntax: $pubapi->jsonapi_myprivs( ); =head2 C<jsonapi_listzones()> List all the zones available to a user. Syntax: $pubapi->jsonapi_listzones( ); =head2 C<jsonapi_sethostname()> Set the hostname of a system. Syntax: $pubapi->jsonapi_sethostname( $hostname ); =head2 C<jsonapi_setresolvers()> Set the resolvers a system uses. Syntax: $pubapi->jsonapi_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); =head2 C<jsonapi_addip()> Add a new IP to a server. Syntax: $pubapi->jsonapi_addip( $ip, $netmask ); =head2 C<jsonapi_delip()> Remove an IP from a server. Syntax: $pubapi->jsonapi_delip( $ip, $ethernetdev, $skipifshutdown ); =head2 C<jsonapi_listips()> List the IPs on a server. Syntax: $pubapi->jsonapi_listips( ); =head2 C<jsonapi_dumpzone()> Get the contents of a zone file. Syntax: $pubapi->jsonapi_dumpzone( $domain ); =head2 C<jsonapi_listpkgs()> List the packages available to your user. Syntax: $pubapi->jsonapi_listpkgs( ); =head2 C<jsonapi_limitbw()> Limit the amount of bandwidth available to an account. Syntax: $pubapi->jsonapi_limitbw( $user, $bwlimit ); =head2 C<jsonapi_showbw()> Show the amount of BW used by an account. Syntax: $pubapi->jsonapi_showbw( $month, $year, $showres, $search, $searchtype ); =head2 C<jsonapi_killdns()> Remove a DNS zone. Syntax: $pubapi->jsonapi_killdns( $domain ); =head2 C<jsonapi_adddns()> Add a dns zone. Syntax: $pubapi->jsonapi_adddns( $domain, $ip, $trueowner ); =head2 C<jsonapi_changepackage()> Change an Account's Package. Syntax: $pubapi->jsonapi_changepackage( $user, $pkg ); =head2 C<jsonapi_modifyacct()> Modify an Account's limits. Syntax: $pubapi->jsonapi_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); =head2 C<jsonapi_suspendacct()> Suspend an account. Syntax: $pubapi->jsonapi_suspendacct( $user, $reason ); =head2 C<jsonapi_unsuspendacct()> Unsuspend an account. Syntax: $pubapi->jsonapi_unsuspendacct( $user ); =head2 C<jsonapi_listsuspended()> List the suspended accounts on a server. Syntax: $pubapi->jsonapi_listsuspended( ); =head2 C<jsonapi_addpkg()> Add a new package. Syntax: $pubapi->jsonapi_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<jsonapi_killpkg()> Remove a package. Syntax: $pubapi->jsonapi_killpkg( $pkg ); =head2 C<jsonapi_editpkg()> Edit a package. Syntax: $pubapi->jsonapi_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<jsonapi_setacls()> Change features available to a reseller. Syntax: $pubapi->jsonapi_setacls( $reseller, $acllist ); =head2 C<jsonapi_terminatereseller()> Remove a reseller. Syntax: $pubapi->jsonapi_terminatereseller( $reseller, $verify ); =head2 C<jsonapi_resellerstats()> Get statistics on a specific reseller. Syntax: $pubapi->jsonapi_resellerstats( $reseller ); =head2 C<jsonapi_setupreseller()> Make a cPanel account a Reseller account. Syntax: $pubapi->jsonapi_setupreseller( $user, $makeowner ); =head2 C<jsonapi_lookupnsip()> Get the IP for a nameserver. Syntax: $pubapi->jsonapi_lookupnsip( $nameserver ); =head2 C<jsonapi_listresellers()> List all the resellers on a system. Syntax: $pubapi->jsonapi_listresellers( ); =head2 C<jsonapi_listacls()> List all of the ACL lists available. Syntax: $pubapi->jsonapi_listacls( ); =head2 C<jsonapi_saveacllist()> Save a new ACL list. Syntax: $pubapi->jsonapi_saveacllist( $acllist ); =head2 C<jsonapi_unsetupreseller()> Remove reseller permissions from an account. Syntax: $pubapi->jsonapi_unsetupreseller( $user ); =head2 C<jsonapi_gethostname()> Get the hostname of the server currently being queried. Syntax: $pubapi->jsonapi_gethostname( ); =head2 C<jsonapi_fetchsslinfo()> Get information on a specific SSL certificate. Syntax: $pubapi->jsonapi_fetchsslinfo( $domain, $crtdata ); =head2 C<jsonapi_installssl()> Install a new SSL certificate. Syntax: $pubapi->jsonapi_installssl( $domain, $user, $cert, $key, $cab, $ip ); =head2 C<jsonapi_passwd()> Change an account's password. Syntax: $pubapi->jsonapi_passwd( $user, $pass ); =head2 C<jsonapi_getlanglist()> Get a list of languages available on a system. Syntax: $pubapi->jsonapi_getlanglist( ); =head2 C<jsonapi_reboot()> Reboot the server. Syntax: $pubapi->jsonapi_reboot( $force ); =head2 C<jsonapi_accountsummary_user()> Get a summary of an account. Syntax: $pubapi->jsonapi_accountsummary_user( $user ); =head2 C<jsonapi_accountsummary_domain()> Get the summary of an account by specifying the domain. Syntax: $pubapi->jsonapi_accountsummary_domain( $domain ); =head2 C<jsonapi_loadavg()> Get the loadavg on the system. Syntax: $pubapi->jsonapi_loadavg( ); =head2 C<jsonapi_restartservice()> Restart a service. Syntax: $pubapi->jsonapi_restartservice( $service ); =head2 C<jsonapi_setsiteip_user()> Set the IP for a specific user. Syntax: $pubapi->jsonapi_setsiteip_user( $user, $ip ); =head2 C<jsonapi_setsiteip_domain()> Set the IP for a specific domain. Syntax: $pubapi->jsonapi_setsiteip_domain( $domain, $ip ); =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/WHM/XMLAPI.pod 0000644 00000026320 15125143347 0012425 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::API - Legacy interface for querying the xml-api. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). Every method contained within this object can be queried using cPanel::publicAPI::whm_api() instead. For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> =head1 functions =head2 C<xmlapi_listaccts()> Used to list the accounts on a server. Syntax: $pubapi->xmlapi_listaccts( $search, $searchtype ); =head2 C<xmlapi_createacct()> Create a new cPanel account. Syntax: $pubapi->xmlapi_createacct( $username, $domain, $password, $plan ); =head2 C<xmlapi_removeacct()> Terminate an account. Syntax: $pubapi->xmlapi_removeacct( $user ); =head2 C<xmlapi_showversion()> Get the version of cPanel running on the server. Syntax: $pubapi->xmlapi_showversion( ); =head2 C<xmlapi_version()> Get the version of cPanel running on the server (as as showversion) Syntax: $pubapi->xmlapi_version( ); =head2 C<xmlapi_applist()> List out the available xml-api calls. Syntax: $pubapi->xmlapi_applist( ); =head2 C<xmlapi_generatessl()> Generate an ssl certificate. Syntax: $pubapi->xmlapi_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); =head2 C<xmlapi_generatessl_noemail()> Generate an SSL certificate without an email. Syntax: $pubapi->xmlapi_generatessl_noemail( $noemail=1 ); =head2 C<xmlapi_listcrts()> List out the certificates that exist on the server. Syntax: $pubapi->xmlapi_listcrts( ); =head2 C<xmlapi_setresellerlimits()> Set the limits for a single reseller account. Syntax: $pubapi->xmlapi_setresellerlimits( ); =head2 C<xmlapi_setresellerpackagelimit()> Set which packages a reseller account can use. Syntax: $pubapi->xmlapi_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); =head2 C<xmlapi_setresellermainip()> Set a reseller's main IP. Syntax: $pubapi->xmlapi_setresellermainip( $user, $ip ); =head2 C<xmlapi_setresellerips()> Set the IP that a reseller has available to it. Syntax: $pubapi->xmlapi_setresellerips( $user, $delegate, $ips ); =head2 C<xmlapi_setresellernameservers()> Set the nameservers that a reseller uses by default. Syntax: $pubapi->xmlapi_setresellernameservers( $user, $nameservers ); =head2 C<xmlapi_suspendreseller()> Suspend a reseller and all of their accounts. Syntax: $pubapi->xmlapi_suspendreseller( $user, $reason, $disallow ); =head2 C<xmlapi_unsuspendreseller()> Unsuspend a reseller and all of their accounts. Syntax: $pubapi->xmlapi_unsuspendreseller( $user ); =head2 C<xmlapi_addzonerecord()> Add a record to a zone. Syntax: $pubapi->xmlapi_addzonerecord( @args ); =head2 C<xmlapi_editzonerecord()> Edit a zone record. Syntax: $pubapi->xmlapi_editzonerecord(@args ); =head2 C<xmlapi_removezonerecord()> Remove a line from a zone. Syntax: $pubapi->xmlapi_removezonerecord( $domain, $Line ); =head2 C<xmlapi_getzonerecord()> Get a record from a zone. Syntax: $pubapi->xmlapi_getzonerecord( $domain, $Line ); =head2 C<xmlapi_servicestatus()> Get the status of various services running on a system. Syntax: $pubapi->xmlapi_servicestatus( $service ); =head2 C<xmlapi_configureservice()> Enable/Disable various services. Syntax: $pubapi->xmlapi_configureservice( $service, $enabled, $monitored ); =head2 C<xmlapi_acctcounts()> Get the number of accounts on a system/that belong to a reseller. Syntax: $pubapi->xmlapi_acctcounts( $user ); =head2 C<xmlapi_domainuserdata()> Get the information about a specific domain's virtualhost. Syntax: $pubapi->xmlapi_domainuserdata( $domain ); =head2 C<xmlapi_editquota()> Edit a user's quota. Syntax: $pubapi->xmlapi_editquota( $user, $quota ); =head2 C<xmlapi_nvget()> Get non-volatile data. Syntax: $pubapi->xmlapi_nvget( $key ); =head2 C<xmlapi_nvset()> Set non-volatile data. Syntax: $pubapi->xmlapi_nvset( $key, $value ); =head2 C<xmlapi_myprivs()> See what privileges are available to your user. Syntax: $pubapi->xmlapi_myprivs( ); =head2 C<xmlapi_listzones()> List all the zones available to a user. Syntax: $pubapi->xmlapi_listzones( ); =head2 C<xmlapi_sethostname()> Set the hostname of a system. Syntax: $pubapi->xmlapi_sethostname( $hostname ); =head2 C<xmlapi_setresolvers()> Set the resolvers a system uses. Syntax: $pubapi->xmlapi_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); =head2 C<xmlapi_addip()> Add a new IP to a server. Syntax: $pubapi->xmlapi_addip( $ip, $netmask ); =head2 C<xmlapi_delip()> Remove an IP from a server. Syntax: $pubapi->xmlapi_delip( $ip, $ethernetdev, $skipifshutdown ); =head2 C<xmlapi_listips()> List the IPs on a server. Syntax: $pubapi->xmlapi_listips( ); =head2 C<xmlapi_dumpzone()> Get the contents of a zone file. Syntax: $pubapi->xmlapi_dumpzone( $domain ); =head2 C<xmlapi_listpkgs()> List the packages available to your user. Syntax: $pubapi->xmlapi_listpkgs( ); =head2 C<xmlapi_limitbw()> Limit the amount of bandwidth available to an account. Syntax: $pubapi->xmlapi_limitbw( $user, $bwlimit ); =head2 C<xmlapi_showbw()> Show the amount of BW used by an account. Syntax: $pubapi->xmlapi_showbw( $month, $year, $showres, $search, $searchtype ); =head2 C<xmlapi_killdns()> Remove a DNS zone. Syntax: $pubapi->xmlapi_killdns( $domain ); =head2 C<xmlapi_adddns()> Add a dns zone. Syntax: $pubapi->xmlapi_adddns( $domain, $ip, $trueowner ); =head2 C<xmlapi_changepackage()> Change an Account's Package. Syntax: $pubapi->xmlapi_changepackage( $user, $pkg ); =head2 C<xmlapi_modifyacct()> Modify an Account's limits. Syntax: $pubapi->xmlapi_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); =head2 C<xmlapi_suspendacct()> Suspend an account. Syntax: $pubapi->xmlapi_suspendacct( $user, $reason ); =head2 C<xmlapi_unsuspendacct()> Unsuspend an account. Syntax: $pubapi->xmlapi_unsuspendacct( $user ); =head2 C<xmlapi_listsuspended()> List the suspended accounts on a server. Syntax: $pubapi->xmlapi_listsuspended( ); =head2 C<xmlapi_addpkg()> Add a new package. Syntax: $pubapi->xmlapi_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<xmlapi_killpkg()> Remove a package. Syntax: $pubapi->xmlapi_killpkg( $pkg ); =head2 C<xmlapi_editpkg()> Edit a package. Syntax: $pubapi->xmlapi_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<xmlapi_setacls()> Change features available to a reseller. Syntax: $pubapi->xmlapi_setacls( $reseller, $acllist ); =head2 C<xmlapi_terminatereseller()> Remove a reseller. Syntax: $pubapi->xmlapi_terminatereseller( $reseller, $verify ); =head2 C<xmlapi_resellerstats()> Get statistics on a specific reseller. Syntax: $pubapi->xmlapi_resellerstats( $reseller ); =head2 C<xmlapi_setupreseller()> Make a cPanel account a Reseller account. Syntax: $pubapi->xmlapi_setupreseller( $user, $makeowner ); =head2 C<xmlapi_lookupnsip()> Get the IP for a nameserver. Syntax: $pubapi->xmlapi_lookupnsip( $nameserver ); =head2 C<xmlapi_listresellers()> List all the resellers on a system. Syntax: $pubapi->xmlapi_listresellers( ); =head2 C<xmlapi_listacls()> List all of the ACL lists available. Syntax: $pubapi->xmlapi_listacls( ); =head2 C<xmlapi_saveacllist()> Save a new ACL list. Syntax: $pubapi->xmlapi_saveacllist( $acllist ); =head2 C<xmlapi_unsetupreseller()> Remove reseller permissions from an account. Syntax: $pubapi->xmlapi_unsetupreseller( $user ); =head2 C<xmlapi_gethostname()> Get the hostname of the server currently being queried. Syntax: $pubapi->xmlapi_gethostname( ); =head2 C<xmlapi_fetchsslinfo()> Get information on a specific SSL certificate. Syntax: $pubapi->xmlapi_fetchsslinfo( $domain, $crtdata ); =head2 C<xmlapi_installssl()> Install a new SSL certificate. Syntax: $pubapi->xmlapi_installssl( $domain, $user, $cert, $key, $cab, $ip ); =head2 C<xmlapi_passwd()> Change an account's password. Syntax: $pubapi->xmlapi_passwd( $user, $pass ); =head2 C<xmlapi_getlanglist()> Get a list of languages available on a system. Syntax: $pubapi->xmlapi_getlanglist( ); =head2 C<xmlapi_reboot()> Reboot the server. Syntax: $pubapi->xmlapi_reboot( $force ); =head2 C<xmlapi_accountsummary_user()> Get a summary of an account. Syntax: $pubapi->xmlapi_accountsummary_user( $user ); =head2 C<xmlapi_accountsummary_domain()> Get the summary of an account by specifying the domain. Syntax: $pubapi->xmlapi_accountsummary_domain( $domain ); =head2 C<xmlapi_loadavg()> Get the loadavg on the system. Syntax: $pubapi->xmlapi_loadavg( ); =head2 C<xmlapi_restartservice()> Restart a service. Syntax: $pubapi->xmlapi_restartservice( $service ); =head2 C<xmlapi_setsiteip_user()> Set the IP for a specific user. Syntax: $pubapi->xmlapi_setsiteip_user( $user, $ip ); =head2 C<xmlapi_setsiteip_domain()> Set the IP for a specific domain. Syntax: $pubapi->xmlapi_setsiteip_domain( $domain, $ip ); =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/WHM/Legacy.pod 0000644 00000003476 15125143347 0012646 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::Legacy - A module for handling Cpanel::Accounting backward compatibility within the cPanel::PublicAPI framework. =head1 DESCRIPTION This module should never be used, please use cPanel::PublicAPI-E<gt>whm_api() instead. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/WHM/Legacy.pm 0000644 00000007650 15125143347 0012476 0 ustar 00 package cPanel::PublicAPI::Legacy; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM (); sub _modpkg { my $self = shift; my $op = shift; my $count = 0; my @OPTS = ('nohtml=1'); if ( $op eq 'edit' ) { push @OPTS, 'edit=yes'; } return $self->simple_get_whmreq( '/scripts/addpkg', \@_, [ 'name', 'hasshell', 'bwlimit', 'quota', 'ip', 'cgi', 'cpmod', 'maxftp', 'maxsql', 'maxpop', 'maxlst', 'maxsub', 'maxpark', 'maxaddon', 'featurelist', 'language' ], \@OPTS ); } sub addpkg { my $self = shift; return $self->_modpkg( 'add', @_ ); } sub editpkg { my $self = shift; return $self->_modpkg( 'edit', @_ ); } sub killpkg { my $self = shift; return $self->simple_get_whmreq( '/scripts/killpkg', \@_, ['pkg'], ['nohtml=1'] ); } sub suspend { my $self = shift; return $self->simple_get_whmreq( '/scripts/remote_suspend', \@_, ['user'] ); } sub unsuspend { my $self = shift; return $self->simple_get_whmreq( '/scripts/remote_unsuspend', \@_, ['user'] ); } sub killacct { my $self = shift; return $self->simple_get_whmreq( '/scripts/killacct', \@_, ['user'], ['nohtml=1'] ); } sub showversion { my $self = shift; return $self->simple_get_whmreq( '/scripts2/showversion', \@_ ); } sub version { my $self = shift; return $self->simple_get_whmreq( '/scripts2/showversion', \@_ ); } sub showhostname { my $self = shift; return $self->simple_get_whmreq( '/scripts2/gethostname', \@_ ); } sub createacct { my $self = shift; return $self->simple_get_whmreq( '/scripts/wwwacct', \@_, [ 'domain', 'username', 'password', 'plan', 'language' ], ['nohtml=1'] ); } sub listpkgs { my $self = shift; my $req = $self->simple_get_whmreq( '/scripts/remote_listpkg', \@_ ); my %PKGS; foreach ( split( /\n/, $req ) ) { my ( $pkg, $contents ) = split( /=/, $_ ); my @CONTENTS = split( /\,/, $contents ); $PKGS{$pkg} = \@CONTENTS; } return wantarray ? %PKGS : \%PKGS; } sub listaccts { my $self = shift; my $req = $self->simple_get_whmreq( '/scripts2/listaccts', \@_, [], ['nohtml=1&viewall=1'] ); my %ACCTS; foreach ( split( /\n/, $req ) ) { next if $_ !~ /=/; my ( $acct, $contents ) = split( /=/, $_ ); my @CONTENTS = split( /\,/, $contents ); $ACCTS{$acct} = \@CONTENTS; } return wantarray ? %ACCTS : \%ACCTS; } 1; lib/cPanel/PublicAPI/WHM/JSONAPI.pm 0000644 00000003401 15125143347 0012363 0 ustar 00 package cPanel::PublicAPI::JSONAPI; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM::API (); foreach my $sub ( grep ( /^api_/, keys %cPanel::PublicAPI:: ) ) { *{"json$sub"} = *$sub; } 1; lib/cPanel/PublicAPI/WHM/DNS.pm 0000644 00000012040 15125143347 0011703 0 ustar 00 package cPanel::PublicAPI::DNS; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM (); use cPanel::PublicAPI::Utils (); sub addtocluster { my $self = shift; my $page = $self->simple_post_whmreq( '/cgi/trustclustermaster.cgi', \@_, [ 'user', 'clustermaster', 'pass', 'version' ], ['recurse=0'] ); if ( $page =~ /has been established/i ) { return 1; } return; } sub getzone_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/getzone_local', \@_, [ 'zone', 'dnsuniqid' ] ); } sub getzones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/getzones_local', \@_, [ 'zones', 'dnsuniqid' ] ); } sub getallzones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/getallzones_local', \@_, ['dnsuniqid'] ); } sub cleandns_local { my $self = shift; return $self->simple_get_whmreq( '/scripts2/cleandns_local', \@_, ['dnsuniqid'] ); } sub getips_local { my $self = shift; return cPanel::PublicAPI::Utils::get_string_with_collapsed_trailing_eols( split( /\n/, ( $self->simple_get_whmreq( '/scripts2/getips_local', \@_, ['dnsuniqid'] ) ) ) ); } sub getpath_local { my $self = shift; return cPanel::PublicAPI::Utils::get_string_with_collapsed_trailing_eols( split( /\n/, ( $self->simple_get_whmreq( '/scripts2/getpath_local', \@_, ['dnsuniqid'] ) ) ) ); } sub removezone_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/removezone_local', \@_, [ 'zone', 'dnsuniqid' ] ); } sub removezones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/removezones_local', \@_, [ 'zones', 'dnsuniqid' ] ); } sub reloadzones_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/reloadzones_local', \@_, [ 'dnsuniqid', 'zone' ] ); # backcompat } sub reloadbind_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/reloadbind_local', \@_, [ 'dnsuniqid', 'zone' ] ); # backcompat } sub reconfigbind_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/reconfigbind_local', \@_, [ 'dnsuniqid', 'zone' ] ); # backcompat } sub quickzoneadd_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/quickzoneadd_local', \@_, [ 'zone', 'zonedata', 'dnsuniqid' ] ); } sub savezone_local { my $self = shift; return $self->simple_post_whmreq( '/scripts2/savezone_local', \@_, [ 'zone', 'zonedata', 'dnsuniqid' ] ); } sub synczones_local { my ( $self, $formdata, $dnsuniqid ) = @_; cPanel::PublicAPI::_init() if !exists $cPanel::PublicAPI::CFG{'init'}; $formdata =~ s/\&$//g; # formdata must come pre encoded. $formdata .= '&dnsuniqid=' . $cPanel::PublicAPI::CFG{'uri_encoder_func'}->($dnsuniqid); my $page = join( "\n", $self->whmreq( '/scripts2/synczones_local', 'POST', $formdata ) ); return if $self->{'error'}; return $page; } sub addzoneconf_local { my $self = shift; return $self->simple_get_whmreq( '/scripts2/addzoneconf_local', \@_, [ 'zone', 'dnsuniqid' ] ); } sub getzonelist_local { my $self = shift; return split( /\n/, $self->simple_get_whmreq( '/scripts2/getzonelist_local', \@_, ['dnsuniqid'] ) ); } sub zoneexists_local { my $self = shift; my $exists = cPanel::PublicAPI::Utils::remove_trailing_newline( $self->simple_post_whmreq( '/scripts2/zoneexists_local', \@_, [ 'zone', 'dnsuniqid' ] ) ); $exists =~ s/[\r\n]//g; if ( $exists eq '1' ) { return 1; } return 0; } lib/cPanel/PublicAPI/WHM/XMLAPI.pm 0000644 00000003377 15125143347 0012266 0 ustar 00 package cPanel::PublicAPI::XMLAPI; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM::API (); foreach my $sub ( grep ( /^api_/, keys %cPanel::PublicAPI:: ) ) { *{"xml$sub"} = *$sub; } 1; lib/cPanel/PublicAPI/WHM/DNS.pod 0000644 00000013434 15125143347 0012061 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::DNS - A module for interacting with WHM's DNS clustering system. =head1 DESCRIPTION This module is intended as a client for querying WHM's DNS clustering system. Unless you are specifically looking to write your own interaction with cPanel's DNS system, you should never need to use this module, rather the DNS functions within cPanel's XML-API should do what you are looking for: L<http://docs.cpanel.net/twiki/bin/vief/AllDocumentation/AutomationIntegration/XmlApi#DNS%20functions> =head1 functions The functions contained within this module share a similiar naming scheme for the variables used within, please consult the list below when figuring out what each function does. =over =item * $zone - The name of the domain to be used. =item * $dnsuniqid - A Unique string used to identify uniquely (suggested: 32 character alphanumeric) =item * $zones - A pipe seperated list of domains. =item * $zonedata - The contents of a zone file, usually used for sending changes of a zone to another system. =back =head2 C<addtocluster()> Add a machine to a DNS cluster. Call specific parameters: =over =item * $clustermaster - The IP of the machine being added to the cluster. =item * $user - The user to authenticate DNS requests as. =item * $pass - The accesshash or API token to authenticate DNS requests with =item * $version - The version of cPanel/WHM of the machine being added to the cluster =back Syntax: $pubapi->addtocluster( $user, $clustermaster, $accesshash, $version ) =head2 C<getzone_local()> Get the contents of a zone file. Syntax: $pubapi->getzone_local( $zone, $dnsuniqid ) =head2 C<getzones_local()> Get the contents of multiple zone files, this will be split up as: cpdnszone-%URI ENCODED ZONENAME%=%URI encoded version of zone file%&cpdnszone... for each zone in the response Syntax: $pubapi->getzones_local( $zones, $dnsuniqid ) =head2 C<getallzones_local()> Like getzones_local, but will return all zones in a cluster. Syntax: $pubapi->getallzones_local( $dnsuniqid ) =head2 C<cleandns_local()> Clean up any old or unused DNS zones from named.conf. Syntax: $pubapi->cleandns_local( $dnsuniqid ) =head2 C<getips_local()> Get a list of extra IPs available on a system, response will be formated as: $ip:$netmask:$broadcast Syntax: $pubapi->getips_local( $dnsuniqid ) =head2 C<getpath_local()> Returns a newline separated list containing all the machines that this machine is clustered with in the following format: $hostname $remote_host Syntax: $pubapi->getpath_local( $dnsuniqid ) =head2 C<removezone_local()> Remove a DNS zone. Syntax: $pubapi->removezone_local( $zone, $dnsuniqid ) =head2 C<removezones_local()> Remove multiple DNS zones. Syntax: $pubapi->removezones_local( $zones, $dnsuniqid ) =head2 C<reloadzones_local()> Force bind to re-read zones files via the "rndc reload" command. Syntax: $pubapi->reloadzones_local( $dnsuniqid, $zones ) =head2 C<reloadbind_local()> Run the 'rndc reload' command. If no zones are specified, bind will reload everything. Syntax: $pubapi->reloadbind_local( $dnsuniqid, $zone ) =head2 C<reconfigbind_local()> Run the 'rndc reconfig' command. Syntax: $pubapi->reconfigbind_local( $dnsuniqid, $zone ) =head2 C<quickzoneadd_local()> Add a new zone to a system. Syntax: $pubapi->quickzoneadd_local( $zone, $zonedata, $dnsuniqid ) =head2 C<savezone_local()> Update a zone file with the data specified in $zonedata. Syntax: $pubapi->savezone_local( $zone, $zonedata, $dnsuniqid ) =head2 C<synczones_local()> Send a dump of all zones and update zones when required. The zones are sent within the $formdata in the following format: cpdnszone-%URI ENCODED ZONENAME%=%URI encoded version of zone file%&cpdnszone... Syntax: $pubapi->synczones_local( $formdata, $dnsuniqid ) =head2 C<addzoneconf_local()> Add a zone to the named.conf file. Syntax: $pubapi->addzoneconf_local( $zone, $dnsuniqid ) =head2 C<getzonelist_local()> Get a newline seperated list of the zones on a system. Syntax: $pubapi->getzonelist_local( $dnsuniqid ) =head2 C<zoneexists_local()> Return boolean value indicating whether a zone exists on a remote system or not. Syntax: $pubapi->zoneexists_local( $zone, $dnsuniqid ) =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/WHM/CachedVersion.pm 0000644 00000005567 15125143347 0014014 0 ustar 00 package cPanel::PublicAPI::WHM::CachedVersion; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = '2.3'; package cPanel::PublicAPI; use cPanel::PublicAPI::WHM::Legacy (); our $basedir = '/var/cpanel/accounting'; our $cachedir = '/var/cpanel/accounting/cache'; our $cachettl = 3600; #one hour sub check_dirs { foreach my $dir ( $basedir, $cachedir ) { if ( !-e $dir ) { mkdir( $dir, 0700 ); } } } sub cached_version { my $self = shift; my $ttl = shift || $cachettl; my $version; $self->check_dirs(); my $file = ( $self->{'ip'} || $self->{'host'} ); if ( !$file ) { return; } $file =~ s/\///g; my $fullfile = $cachedir . '/' . $file; my $now = time(); my $mtime = ( stat($fullfile) )[9]; if ( $mtime && ( $mtime + $ttl ) > $now && $mtime < $now ) { if ( open( my $cache_fh, '<', $fullfile ) ) { my $fileversion = readline($cache_fh); if ( $fileversion =~ /^(\d+\.\d+\.\d+)/ ) { $version = $1; } close($cache_fh); } } if ($version) { return $version; } $version = $self->version(); if ($version) { if ( open( my $cache_fh, '>', $fullfile ) ) { print {$cache_fh} $version; close($cache_fh); } } return $version; } 1; lib/cPanel/PublicAPI/WHM/API.pod 0000644 00000025462 15125143347 0012052 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::WHM::API - Legacy interface for querying the xml-api. NOTE: This module is provided for legacy purposes, L<cPanel::PublicAPI> should be used instead =head1 DESCRIPTION This module provides legacy compatibility support between L<cPanel::PublicAPI> and Cpanel::Accounting (distributed with cPanel). This should never be used unless there is a very good reason to use it (such as having a script that uses Cpanel::Accounting). Every method contained within this object can be queried using cPanel::publicAPI::whm_api() instead. For more information on the calls within the methods contained here and what the parameter names mean, please read the documentation at: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi> =head1 functions =head2 C<api_listaccts()> Used to list the accounts on a server. Syntax: $pubapi->api_listaccts( $search, $searchtype ); =head2 C<api_createacct()> Create a new cPanel account. Syntax: $pubapi->api_createacct( $username, $domain, $password, $plan ); =head2 C<api_removeacct()> Terminate an account. Syntax: $pubapi->api_removeacct( $user ); =head2 C<api_showversion()> Get the version of cPanel running on the server. Syntax: $pubapi->api_showversion( ); =head2 C<api_version()> Get the version of cPanel running on the server (as as showversion) Syntax: $pubapi->api_version( ); =head2 C<api_applist()> List out the available xml-api calls. Syntax: $pubapi->api_applist( ); =head2 C<api_generatessl()> Generate an ssl certificate. Syntax: $pubapi->api_generatessl( $host, $pass, $country, $state, $city, $co, $cod, $email, $xemail ); =head2 C<api_generatessl_noemail()> Generate an SSL certificate without an email. Syntax: $pubapi->api_generatessl_noemail( $noemail=1 ); =head2 C<api_listcrts()> List out the certificates that exist on the server. Syntax: $pubapi->api_listcrts( ); =head2 C<api_setresellerlimits()> Set the limits for a single reseller account. Syntax: $pubapi->api_setresellerlimits( ); =head2 C<api_setresellerpackagelimit()> Set which packages a reseller account can use. Syntax: $pubapi->api_setresellerpackagelimit( $user, $package, $allowerd, $number, $no_limit ); =head2 C<api_setresellermainip()> Set a reseller's main IP. Syntax: $pubapi->api_setresellermainip( $user, $ip ); =head2 C<api_setresellerips()> Set the IP that a reseller has available to it. Syntax: $pubapi->api_setresellerips( $user, $delegate, $ips ); =head2 C<api_setresellernameservers()> Set the nameservers that a reseller uses by default. Syntax: $pubapi->api_setresellernameservers( $user, $nameservers ); =head2 C<api_suspendreseller()> Suspend a reseller and all of their accounts. Syntax: $pubapi->api_suspendreseller( $user, $reason, $disallow ); =head2 C<api_unsuspendreseller()> Unsuspend a reseller and all of their accounts. Syntax: $pubapi->api_unsuspendreseller( $user ); =head2 C<api_addzonerecord()> Add a record to a zone. Syntax: $pubapi->api_addzonerecord( @args ); =head2 C<api_editzonerecord()> Edit a zone record. Syntax: $pubapi->api_editzonerecord(@args ); =head2 C<api_removezonerecord()> Remove a line from a zone. Syntax: $pubapi->api_removezonerecord( $domain, $Line ); =head2 C<api_getzonerecord()> Get a record from a zone. Syntax: $pubapi->api_getzonerecord( $domain, $Line ); =head2 C<api_servicestatus()> Get the status of various services running on a system. Syntax: $pubapi->api_servicestatus( $service ); =head2 C<api_configureservice()> Enable/Disable various services. Syntax: $pubapi->api_configureservice( $service, $enabled, $monitored ); =head2 C<api_acctcounts()> Get the number of accounts on a system/that belong to a reseller. Syntax: $pubapi->api_acctcounts( $user ); =head2 C<api_domainuserdata()> Get the information about a specific domain's virtualhost. Syntax: $pubapi->api_domainuserdata( $domain ); =head2 C<api_editquota()> Edit a user's quota. Syntax: $pubapi->api_editquota( $user, $quota ); =head2 C<api_nvget()> Get non-volatile data. Syntax: $pubapi->api_nvget( $key ); =head2 C<api_nvset()> Set non-volatile data. Syntax: $pubapi->api_nvset( $key, $value ); =head2 C<api_myprivs()> See what privileges are available to your user. Syntax: $pubapi->api_myprivs( ); =head2 C<api_listzones()> List all the zones available to a user. Syntax: $pubapi->api_listzones( ); =head2 C<api_sethostname()> Set the hostname of a system. Syntax: $pubapi->api_sethostname( $hostname ); =head2 C<api_setresolvers()> Set the resolvers a system uses. Syntax: $pubapi->api_setresolvers( $nameserver1, $nameserver2, $nameserver3 ); =head2 C<api_addip()> Add a new IP to a server. Syntax: $pubapi->api_addip( $ip, $netmask ); =head2 C<api_delip()> Remove an IP from a server. Syntax: $pubapi->api_delip( $ip, $ethernetdev, $skipifshutdown ); =head2 C<api_listips()> List the IPs on a server. Syntax: $pubapi->api_listips( ); =head2 C<api_dumpzone()> Get the contents of a zone file. Syntax: $pubapi->api_dumpzone( $domain ); =head2 C<api_listpkgs()> List the packages available to your user. Syntax: $pubapi->api_listpkgs( ); =head2 C<api_limitbw()> Limit the amount of bandwidth available to an account. Syntax: $pubapi->api_limitbw( $user, $bwlimit ); =head2 C<api_showbw()> Show the amount of BW used by an account. Syntax: $pubapi->api_showbw( $month, $year, $showres, $search, $searchtype ); =head2 C<api_killdns()> Remove a DNS zone. Syntax: $pubapi->api_killdns( $domain ); =head2 C<api_adddns()> Add a dns zone. Syntax: $pubapi->api_adddns( $domain, $ip, $trueowner ); =head2 C<api_changepackage()> Change an Account's Package. Syntax: $pubapi->api_changepackage( $user, $pkg ); =head2 C<api_modifyacct()> Modify an Account's limits. Syntax: $pubapi->api_modifyacct( $user, $domain, $HASCGI, $CPTHEME, $LANG, $MAXPOP, $MAXFTP, $MAXLST, $MAXSUB, $MAXPARK, $MAXADDON, $MAXSQL, $shell ); =head2 C<api_suspendacct()> Suspend an account. Syntax: $pubapi->api_suspendacct( $user, $reason ); =head2 C<api_unsuspendacct()> Unsuspend an account. Syntax: $pubapi->api_unsuspendacct( $user ); =head2 C<api_listsuspended()> List the suspended accounts on a server. Syntax: $pubapi->api_listsuspended( ); =head2 C<api_addpkg()> Add a new package. Syntax: $pubapi->api_addpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<api_killpkg()> Remove a package. Syntax: $pubapi->api_killpkg( $pkg ); =head2 C<api_editpkg()> Edit a package. Syntax: $pubapi->api_editpkg( $pkgname, $quota, $ip, $cgi, $frontpage, $cpmod, $maxftp, $maxsql, $maxpop, $maxlst, $maxsub, $maxpark, $maxaddon, $featurelist, $hasshell, $bwlimit ); =head2 C<api_setacls()> Change features available to a reseller. Syntax: $pubapi->api_setacls( $reseller, $acllist ); =head2 C<api_terminatereseller()> Remove a reseller. Syntax: $pubapi->api_terminatereseller( $reseller, $verify ); =head2 C<api_resellerstats()> Get statistics on a specific reseller. Syntax: $pubapi->api_resellerstats( $reseller ); =head2 C<api_setupreseller()> Make a cPanel account a Reseller account. Syntax: $pubapi->api_setupreseller( $user, $makeowner ); =head2 C<api_lookupnsip()> Get the IP for a nameserver. Syntax: $pubapi->api_lookupnsip( $nameserver ); =head2 C<api_listresellers()> List all the resellers on a system. Syntax: $pubapi->api_listresellers( ); =head2 C<api_listacls()> List all of the ACL lists available. Syntax: $pubapi->api_listacls( ); =head2 C<api_saveacllist()> Save a new ACL list. Syntax: $pubapi->api_saveacllist( $acllist ); =head2 C<api_unsetupreseller()> Remove reseller permissions from an account. Syntax: $pubapi->api_unsetupreseller( $user ); =head2 C<api_gethostname()> Get the hostname of the server currently being queried. Syntax: $pubapi->api_gethostname( ); =head2 C<api_fetchsslinfo()> Get information on a specific SSL certificate. Syntax: $pubapi->api_fetchsslinfo( $domain, $crtdata ); =head2 C<api_installssl()> Install a new SSL certificate. Syntax: $pubapi->api_installssl( $domain, $user, $cert, $key, $cab, $ip ); =head2 C<api_passwd()> Change an account's password. Syntax: $pubapi->api_passwd( $user, $pass ); =head2 C<api_getlanglist()> Get a list of languages available on a system. Syntax: $pubapi->api_getlanglist( ); =head2 C<api_reboot()> Reboot the server. Syntax: $pubapi->api_reboot( $force ); =head2 C<api_accountsummary_user()> Get a summary of an account. Syntax: $pubapi->api_accountsummary_user( $user ); =head2 C<api_accountsummary_domain()> Get the summary of an account by specifying the domain. Syntax: $pubapi->api_accountsummary_domain( $domain ); =head2 C<api_loadavg()> Get the loadavg on the system. Syntax: $pubapi->api_loadavg( ); =head2 C<api_restartservice()> Restart a service. Syntax: $pubapi->api_restartservice( $service ); =head2 C<api_setsiteip_user()> Set the IP for a specific user. Syntax: $pubapi->api_setsiteip_user( $user, $ip ); =head2 C<api_setsiteip_domain()> Set the IP for a specific domain. Syntax: $pubapi->api_setsiteip_domain( $domain, $ip ); =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/Utils.pod 0000644 00000003673 15125143347 0012106 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI::Utils - Provides some internally used utility functions for cPanel::PublicAPI, should never be used externally. =head1 Subroutines =head2 remove_trailing_newline() Removes the training newline from the provided string =head2 get_string_with_collapsed_trailing_eols Takes an array or array of arrays and puts them into a newline-seperated string. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. lib/cPanel/PublicAPI/WHM.pm 0000644 00000010043 15125143347 0011260 0 ustar 00 package cPanel::PublicAPI::WHM; # Copyright (c) 2015, cPanel, Inc. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use cPanel::PublicAPI (); our $VERSION = 1.0; package cPanel::PublicAPI; sub simple_get_whmreq { my ( $self, $uri, $argref, $argnameref, $opts ) = @_; $self->_init() if !exists $cPanel::PublicAPI::CFG{'init'}; $self->debug("simple_get_whmreq: ( $self, $uri, $argref, $argnameref, $opts )\n") if $self->{'debug'}; my $count = 0; if ( !$opts || !ref $opts ) { $opts = []; } if ( ref $argnameref ) { foreach my $arg ( @{$argnameref} ) { push @{$opts}, $cPanel::PublicAPI::CFG{'uri_encoder_func'}->($arg) . '=' . ( $cPanel::PublicAPI::CFG{'uri_encoder_func'}->( $argref->[$count] ) || '' ); $count++; } } my $page_ref = $self->whmreq( $uri . '?' . join( '&', @{$opts} ) ); if ( $self->{'error'} ) { return ''; } return $page_ref; } sub simple_post_whmreq { my ( $self, $uri, $argref, $argnameref, $opts ) = @_; $self->_init() if !exists $cPanel::PublicAPI::CFG{'init'}; $self->debug("simple_post_whmreq: ( $self, $uri, $argref, $argnameref, $opts )") if $self->{'debug'}; my $count = 0; if ( !$opts || !ref $opts ) { $opts = []; } if ( ref $argnameref ) { foreach my $arg ( @{$argnameref} ) { push @{$opts}, $cPanel::PublicAPI::CFG{'uri_encoder_func'}->($arg) . '=' . $cPanel::PublicAPI::CFG{'uri_encoder_func'}->( $argref->[$count] ); $count++; } } my $page_ref = $self->whmreq( $uri, 'POST', join( '&', @{$opts} ) ); if ( $self->{'error'} ) { return ''; } return $page_ref; } sub whmreq { my $self = shift; my $uri = shift; my $method = shift || 'GET'; my $formdata = shift; if ( $method eq 'GET' && $uri =~ /\?/ ) { ( $uri, $formdata ) = split( /\?/, $uri ); } $self->debug("whmreq: ( $self, $uri, $method, $formdata )\n") if $self->{'debug'}; my ( $status, $statusmsg, $data ) = $self->api_request( 'whostmgr', $uri, $method, $formdata ); return wantarray ? split( /\r?\n/, $$data ) : $$data; } sub api1 { #Cpanel::Accounting compat my $self = shift; my $user = shift; my $module = shift; my $func = shift; return $self->cpanel_api1_request( 'whostmgr', { 'user' => $user, 'module' => $module, 'func' => $func }, \@_, 'xml' ); } sub api2 { #Cpanel::Accounting compat my $self = shift; my $user = shift; my $module = shift; my $func = shift; return $self->cpanel_api2_request( 'whostmgr', { 'user' => $user, 'module' => $module, 'func' => $func }, {@_}, 'xml' ); } 1; lib/cPanel/PublicAPI.pm 0000644 00000056144 15125143347 0010641 0 ustar 00 package cPanel::PublicAPI; # Copyright 2019 cPanel, L.L.C. # All rights reserved. # http://cpanel.net # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # 3. Neither the name of the owner nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. our $VERSION = '2.8'; use strict; use Carp (); use MIME::Base64 (); use HTTP::Tiny (); use HTTP::CookieJar (); our %CFG; my %PORT_DB = ( 'whostmgr' => { 'ssl' => 2087, 'plaintext' => 2086, }, 'cpanel' => { 'ssl' => 2083, 'plaintext' => 2082, }, 'webmail' => { 'ssl' => 2096, 'plaintext' => 2095, }, ); sub _create_http_tiny { return HTTP::Tiny->new(@_); } sub new { my ( $class, %OPTS ) = @_; my $self = {}; bless( $self, $class ); $self->{'debug'} = $OPTS{'debug'} || 0; $self->{'timeout'} = $OPTS{'timeout'} || 300; $self->{'usessl'} = exists $OPTS{'usessl'} ? $OPTS{'usessl'} : 1; if ( exists $OPTS{'ip'} ) { $self->{'ip'} = $OPTS{'ip'}; } elsif ( exists $OPTS{'host'} ) { $self->{'host'} = $OPTS{'host'}; } else { $self->{'ip'} = '127.0.0.1'; } my $ua_creator = $OPTS{'http_tiny_creator'} || \&_create_http_tiny; $self->{'ua'} = $ua_creator->( agent => "cPanel::PublicAPI/$VERSION ", verify_SSL => ( exists $OPTS{'ssl_verify_mode'} ? $OPTS{'ssl_verify_mode'} : 1 ), keep_alive => ( exists $OPTS{'keepalive'} ? int $OPTS{'keepalive'} : 0 ), timeout => $self->{'timeout'}, ); if ( exists $OPTS{'error_log'} && $OPTS{'error_log'} ne 'STDERR' ) { if ( !open( $self->{'error_fh'}, '>>', $OPTS{'error_log'} ) ) { print STDERR "Unable to open $OPTS{'error_log'} for writing, defaulting to STDERR for error logging: $@\n"; $self->{'error_fh'} = \*STDERR; } } else { $self->{'error_fh'} = \*STDERR; } if ( $OPTS{'user'} ) { $self->{'user'} = $OPTS{'user'}; $self->debug("Using user param from object creation") if $self->{'debug'}; } else { $self->{'user'} = exists $INC{'Cpanel/PwCache.pm'} ? ( Cpanel::PwCache::getpwuid($>) )[0] : ( getpwuid($>) )[0]; $self->debug("Setting user based on current uid ($>)") if $self->{'debug'}; } if ( exists $OPTS{'api_token'} && exists $OPTS{'accesshash'} ) { $self->error('You cannot specify both an accesshash and an API token'); die $self->{'error'}; } # Allow the user to specify an api_token instead of an accesshash. # Though, it will just act as a synonym. $OPTS{'accesshash'} = $OPTS{'api_token'} if $OPTS{'api_token'}; if ( ( !exists( $OPTS{'pass'} ) || $OPTS{'pass'} eq '' ) && ( !exists $OPTS{'accesshash'} || $OPTS{'accesshash'} eq '' ) ) { my $homedir = exists $INC{'Cpanel/PwCache.pm'} ? ( Cpanel::PwCache::getpwuid($>) )[7] : ( getpwuid($>) )[7]; $self->debug("Attempting to detect correct authentication credentials") if $self->{'debug'}; if ( -e $homedir . '/.accesshash' ) { local $/; if ( open( my $hash_fh, '<', $homedir . '/.accesshash' ) ) { $self->{'accesshash'} = readline($hash_fh); $self->{'accesshash'} =~ s/[\r\n]+//g; close($hash_fh); $self->debug("Got accesshash from $homedir/.accesshash") if $self->{'debug'}; } else { $self->debug("Failed to fetch accesshash from $homedir/.accesshash") if $self->{'debug'}; } } elsif ( exists $ENV{'REMOTE_PASSWORD'} && $ENV{'REMOTE_PASSWORD'} && $ENV{'REMOTE_PASSWORD'} ne '__HIDDEN__' && exists $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} =~ /^cpsrvd/ ) { $self->debug("Got user password from the REMOTE_PASSWORD environment variables.") if $self->{'debug'}; $self->{'pass'} = $ENV{'REMOTE_PASSWORD'}; } else { Carp::confess('pass, accesshash, or api_token is a required parameter'); } } elsif ( $OPTS{'pass'} ) { $self->{'pass'} = $OPTS{'pass'}; $self->debug("Using pass param from object creation") if $self->{'debug'}; } else { $OPTS{'accesshash'} =~ s/[\r\n]//; $self->{'accesshash'} = $OPTS{'accesshash'}; $self->debug("Using accesshash param from object creation") if $self->{'debug'}; } $self->_update_operating_mode(); return $self; } sub set_debug { my $self = shift; $self->{'debug'} = int shift; } sub user { my $self = shift; $self->{'user'} = shift; } sub pass { my $self = shift; $self->{'pass'} = shift; delete $self->{'accesshash'}; $self->_update_operating_mode(); } sub accesshash { my $self = shift; $self->{'accesshash'} = shift; delete $self->{'pass'}; $self->_update_operating_mode(); } sub api_token { return shift->accesshash(@_); } sub whm_api { my ( $self, $call, $formdata, $format ) = @_; $self->_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; if ( !defined $call || $call eq '' ) { $self->error("A call was not defined when called cPanel::PublicAPI::whm_api_request()"); } if ( defined $format && $format ne 'xml' && $format ne 'json' && $format ne 'ref' ) { $self->error("cPanel::PublicAPI::whm_api_request() was called with an invalid data format, the only valid format are 'json', 'ref' or 'xml'"); } $formdata ||= {}; if ( ref $formdata ) { $formdata = { 'api.version' => 1, %$formdata }; } elsif ( $formdata !~ /(^|&)api\.version=/ ) { $formdata = "api.version=1&$formdata"; } my $query_format; if ( defined $format ) { $query_format = $format; } else { $query_format = $CFG{'serializer'}; } my $uri = "/$query_format-api/$call"; my ( $status, $statusmsg, $data ) = $self->api_request( 'whostmgr', $uri, 'POST', $formdata ); return $self->_parse_returndata( { 'caller' => 'whm_api', 'data' => $data, 'format' => $format, 'call' => $call } ); } sub api_request { my ( $self, $service, $uri, $method, $formdata, $headers ) = @_; $formdata ||= ''; $method ||= 'GET'; $headers ||= {}; $self->debug("api_request: ( $self, $service, $uri, $method, $formdata, $headers )") if $self->{'debug'}; $self->_init() if !exists $CFG{'init'}; undef $self->{'error'}; my $timeout = $self->{'timeout'} || 300; my $orig_alarm = 0; my $page; my $port = $self->_determine_port_for_service($service); $self->debug("Found port for service $service to be $port (usessl=$self->{'usessl'})") if $self->{'debug'}; eval { $self->{'remote_server'} = $self->{'ip'} || $self->{'host'}; $self->_validate_connection_settings(); if ( $self->{'operating_mode'} eq 'session' ) { $self->_establish_session($service) if !( $self->{'security_tokens'}->{$service} && $self->{'cookie_jars'}->{$service} ); $self->{'ua'}->cookie_jar( $self->{'cookie_jars'}->{$service} ); } my $remote_server = $self->{'remote_server'}; my $attempts = 0; my $finished_request = 0; my $hassigpipe; local $SIG{'ALRM'} = sub { $self->error('Connection Timed Out'); die $self->{'error'}; }; local $SIG{'PIPE'} = sub { $hassigpipe = 1; }; $orig_alarm = alarm($timeout); $formdata = $self->format_http_query($formdata) if ref $formdata; my $scheme = $self->{'usessl'} ? "https" : "http"; my $url = "$scheme://$remote_server:$port"; if ( $self->{'operating_mode'} eq 'session' ) { my $security_token = $self->{'security_tokens'}->{$service}; $url .= '/' . $self->{'security_tokens'}->{$service} . $uri; } else { $url .= $uri; } my $content; if ( $method eq 'POST' || $method eq 'PUT' ) { $content = $formdata; } else { $url .= "?$formdata"; } $self->debug("URL: $url") if $self->{'debug'}; if ( !ref $headers ) { my @lines = split /\r\n/, $headers; $headers = {}; foreach my $line (@lines) { last unless length $line; my ( $key, $value ) = split /:\s*/, $line, 2; next unless length $key; $headers->{$key} ||= []; push @{ $headers->{$key} }, $value; } } if ($self->{'operating_mode'} eq 'accesshash') { my $token_app = ($service eq 'whostmgr') ? 'whm' : $service; $headers->{'Authorization'} = sprintf( '%s %s:%s', $token_app, $self->{'user'}, $self->{'accesshash'}, ); } my $options = { headers => $headers, }; $options->{'content'} = $content if defined $content; my $ua = $self->{'ua'}; while ( ++$attempts < 3 ) { $hassigpipe = 0; my $response = $ua->request( $method, $url, $options ); if ( $response->{'status'} == 599 ) { $self->error("Could not connect to $url: $response->{'content'}"); die $self->{'error'}; #exit eval } if ($hassigpipe) { next; } # http spec says to reconnect my %HEADERS; if ( $self->{'debug'} ) { %HEADERS = %{ $response->{'headers'} }; foreach my $header ( keys %HEADERS ) { $self->debug("HEADER[$header]=[$HEADERS{$header}]"); } if ( exists $HEADERS{'transfer-encoding'} && $HEADERS{'transfer-encoding'} =~ /chunked/i ) { $self->debug("READ TYPE=chunked"); } elsif ( defined $HEADERS{'content-length'} ) { $self->debug("READ TYPE=content-length"); } else { $self->debug("READ TYPE=close"); } } if ( !$response->{'success'} ) { $self->error("Server Error from $remote_server: $response->{'status'} $response->{'reason'}"); } $page = $response->{'content'}; $finished_request = 1; last; } if ( !$finished_request && !$self->{'error'} ) { $self->error("The request could not be completed after the maximum attempts"); } }; if ( $self->{'debug'} && $@ ) { warn $@; } alarm($orig_alarm); # Reset with parent's alarm value return ( $self->{'error'} ? 0 : 1, $self->{'error'}, \$page ); } sub establish_tfa_session { my ( $self, $service, $tfa_token ) = @_; if ( $self->{'operating_mode'} ne 'session' ) { $self->error("2FA-authenticated sessions are not supported when using accesshash keys or API tokens"); die $self->{'error'}; } if ( !( $service && $tfa_token ) ) { $self->error("You must specify the service name, and the 2FA token in order to establish a 2FA-authenticated session"); die $self->{'error'}; } undef $self->{'cookie_jars'}->{$service}; undef $self->{'security_tokens'}->{$service}; return $self->_establish_session( $service, $tfa_token ); } sub _validate_connection_settings { my $self = shift; if ( !$self->{'user'} ) { $self->error("You must specify a user to login as."); die $self->{'error'}; } if ( !$self->{'remote_server'} ) { $self->error("You must set a host to connect to. (missing 'host' and 'ip' parameter)"); die $self->{'error'}; } } sub _update_operating_mode { my $self = shift; if ( exists $self->{'accesshash'} ) { $self->{'accesshash'} =~ s/[\r\n]//g; $self->{'operating_mode'} = 'accesshash'; } elsif ( exists $self->{'pass'} ) { $self->{'operating_mode'} = 'session'; # This is called whenever the pass or accesshash is changed, # so we reset the cookie jars, and tokens on such changes $self->{'cookie_jars'} = { map { $_ => undef } keys %PORT_DB }; $self->{'security_tokens'} = { map { $_ => undef } keys %PORT_DB }; } else { $self->error('You must specify an accesshash, API token, or password'); die $self->{'error'}; } } sub _establish_session { my ( $self, $service, $tfa_token ) = @_; return if $self->{'operating_mode'} ne 'session'; return if $self->{'security_tokens'}->{$service} && $self->{'cookie_jars'}->{$service}; $self->{'cookie_jars'}->{$service} = HTTP::CookieJar->new(); $self->{'ua'}->cookie_jar( $self->{'cookie_jars'}->{$service} ); my $port = $self->_determine_port_for_service($service); my $scheme = $self->{'usessl'} ? "https" : "http"; my $url = "$scheme://$self->{'remote_server'}:$port/login"; my $resp = $self->{'ua'}->post_form( $url, { 'user' => $self->{'user'}, 'pass' => $self->{'pass'}, ( $tfa_token ? ( 'tfa_token' => $tfa_token ) : () ), }, ); if ( my $security_token = ( split /\//, $resp->{'headers'}->{'location'} )[1] ) { $self->{'security_tokens'}->{$service} = $security_token; $self->debug("Established $service session"); return 1; } my $details = $resp->{'reason'}; $details .= " ($resp->{'content'})" if $resp->{'status'} == 599; $self->error("Failed to establish session and parse security token: $resp->{'status'} $details"); die $self->{'error'}; } sub _determine_port_for_service { my ( $self, $service ) = @_; my $port; if ( $self->{'usessl'} ) { $port = $service =~ /^\d+$/ ? $service : $PORT_DB{$service}{'ssl'}; } else { $port = $service =~ /^\d+$/ ? $service : $PORT_DB{$service}{'plaintext'}; } return $port; } sub cpanel_api1_request { my ( $self, $service, $cfg, $formdata, $format ) = @_; my $query_format; if ( defined $format ) { $query_format = $format; } else { $query_format = $CFG{'serializer'}; } $self->_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; my $count = 0; if ( ref $formdata eq 'ARRAY' ) { $formdata = { map { ( 'arg-' . $count++ ) => $_ } @{$formdata} }; } foreach my $cfg_item ( keys %{$cfg} ) { $formdata->{ 'cpanel_' . $query_format . 'api_' . $cfg_item } = $cfg->{$cfg_item}; } $formdata->{ 'cpanel_' . $query_format . 'api_apiversion' } = 1; my ( $status, $statusmsg, $data ) = $self->api_request( $service, '/' . $query_format . '-api/cpanel', ( ( scalar keys %$formdata < 10 && _total_form_length( $formdata, 1024 ) < 1024 ) ? 'GET' : 'POST' ), $formdata ); return $self->_parse_returndata( { 'caller' => 'cpanel_api1', 'data' => $data, 'format' => $format, } ); } sub cpanel_api2_request { my ( $self, $service, $cfg, $formdata, $format ) = @_; $self->_init_serializer() if !exists $cPanel::PublicAPI::CFG{'serializer'}; my $query_format; if ( defined $format ) { $query_format = $format; } else { $query_format = $CFG{'serializer'}; } foreach my $cfg_item ( keys %{$cfg} ) { $formdata->{ 'cpanel_' . $query_format . 'api_' . $cfg_item } = $cfg->{$cfg_item}; } $formdata->{ 'cpanel_' . $query_format . 'api_apiversion' } = 2; my ( $status, $statusmsg, $data ) = $self->api_request( $service, '/' . $query_format . '-api/cpanel', ( ( scalar keys %$formdata < 10 && _total_form_length( $formdata, 1024 ) < 1024 ) ? 'GET' : 'POST' ), $formdata ); return $self->_parse_returndata( { 'caller' => 'cpanel_api2', 'data' => $data, 'format' => $format, } ); } sub _parse_returndata { my ( $self, $opts_hr ) = @_; if ( $self->{'error'} ) { die $self->{'error'}; } elsif ( ${ $opts_hr->{'data'} } =~ m/tfa_login_form/ ) { $self->error("Two-Factor Authentication enabled on the account. Establish a session with the security token, or disable 2FA on the account"); die $self->{'error'}; } if ( defined $opts_hr->{'format'} && ( $opts_hr->{'format'} eq 'json' || $opts_hr->{'format'} eq 'xml' ) ) { return ${ $opts_hr->{'data'} }; } else { my $parsed_data; eval { $parsed_data = $CFG{'api_decode_func'}->( ${ $opts_hr->{'data'} } ); }; if ( !ref $parsed_data ) { $self->error("There was an issue with parsing the following response from cPanel or WHM: [data=[${$opts_hr->{'data'}}]]"); die $self->{'error'}; } my $error_check_dt = { 'whm_api' => \&_check_whm_api_errors, 'cpanel_api1' => \&_check_cpanel_api1_errors, 'cpanel_api2' => \&_check_cpanel_api2_errors, }; return $error_check_dt->{ $opts_hr->{'caller'} }->( $self, $opts_hr->{'call'}, $parsed_data ); } } sub _check_whm_api_errors { my ( $self, $call, $parsed_data ) = @_; if ( ( exists $parsed_data->{'error'} && $parsed_data->{'error'} =~ /Unknown App Requested/ ) || # xml-api v0 version ( exists $parsed_data->{'metadata'}->{'reason'} && $parsed_data->{'metadata'}->{'reason'} =~ /Unknown app\s+(?:\(.+\))?\s+requested/ ) # xml-api v1 version ) { $self->error("cPanel::PublicAPI::whm_api was called with the invalid API call of: $call."); return; } return $parsed_data; } sub _check_cpanel_api1_errors { my ( $self, undef, $parsed_data ) = @_; if ( exists $parsed_data->{'event'}->{'reason'} && ( $parsed_data->{'event'}->{'reason'} =~ /failed: Undefined subroutine/ || # pre-11.44 error message $parsed_data->{'event'}->{'reason'} =~ m/failed: Can\'t use string/ # 11.44+ error message ) ) { $self->error( "cPanel::PublicAPI::cpanel_api1_request was called with the invalid API1 call of: " . $parsed_data->{'module'} . '::' . $parsed_data->{'func'} ); return; } return $parsed_data; } sub _check_cpanel_api2_errors { my ( $self, undef, $parsed_data ) = @_; if ( exists $parsed_data->{'cpanelresult'}->{'error'} && $parsed_data->{'cpanelresult'}->{'error'} =~ /Could not find function/ ) { # xml-api v1 version $self->error( "cPanel::PublicAPI::cpanel_api2_request was called with the invalid API2 call of: " . $parsed_data->{'cpanelresult'}->{'module'} . '::' . $parsed_data->{'cpanelresult'}->{'func'} ); return; } return $parsed_data; } sub _total_form_length { my $data = shift; my $max = shift; my $size = 0; foreach my $key ( keys %{$data} ) { return 1024 if ( ( $size += ( length($key) + 2 + length( $data->{$key} ) ) ) >= 1024 ); } return $size; } sub _init_serializer { return if exists $CFG{'serializer'}; my $self = shift; #not required foreach my $serializer ( #module, key (cpanel api uri), deserializer function name [ 'JSON::Syck', 'json', 'Load' ], [ 'JSON', 'json', 'decode_json' ], [ 'JSON::XS', 'json', 'decode_json' ], [ 'JSON::PP', 'json', 'decode_json' ], ) { my $serializer_module = $serializer->[0]; my $serializer_key = $serializer->[1]; eval " require $serializer_module; "; if ( !$@ ) { $self->debug("loaded serializer: $serializer_module") if $self && ref $self && $self->{'debug'}; $CFG{'serializer'} = $CFG{'parser_key'} = $serializer_key; $CFG{'serializer_module'} = $CFG{'parser_module'} = $serializer_module; $CFG{'api_decode_func'} = $serializer_module->can($serializer->[2]); last; } else { $self->debug("Failed to load serializer: $serializer_module: @_") if $self && ref $self && $self->{'debug'}; } } if ($@) { Carp::confess("Unable to find a module capable of deserializing the api response."); } } sub _init { return if exists $CFG{'init'}; my $self = shift; #not required $CFG{'init'} = 1; # moved this over to a pattern to allow easy change of deps foreach my $encoder ( [ 'Cpanel/Encoder/URI.pm', 'Cpanel::Encoder::URI', 'uri_encode_str' ], [ 'URI/Escape.pm', 'URI::Escape', 'uri_escape' ], ) { my $module_path = $encoder->[0]; my $module = $encoder->[1]; my $funcname = $encoder->[2]; eval { require $module_path; }; if ( !$@ ) { $self->debug("loaded encoder: $module_path") if $self && ref $self && $self->{'debug'}; $CFG{'uri_encoder_func'} = $module->can($funcname); last; } else { $self->debug("failed to load encoder: $module_path") if $self && ref $self && $self->{'debug'}; } } if ($@) { Carp::confess("Unable to find a module capable of encoding api requests."); } } sub error { my ( $self, $msg ) = @_; print { $self->{'error_fh'} } $msg . "\n"; $self->{'error'} = $msg; } sub debug { my ( $self, $msg ) = @_; print { $self->{'error_fh'} } "debug: " . $msg . "\n"; } sub format_http_headers { my ( $self, $headers ) = @_; if ( ref $headers ) { return '' if !scalar keys %{$headers}; return join( "\r\n", map { $_ ? ( $_ . ': ' . $headers->{$_} ) : () } keys %{$headers} ) . "\r\n"; } return $headers; } sub format_http_query { my ( $self, $formdata ) = @_; if ( ref $formdata ) { return join( '&', map { $CFG{'uri_encoder_func'}->($_) . '=' . $CFG{'uri_encoder_func'}->( $formdata->{$_} ) } sort keys %{$formdata} ); } return $formdata; } lib/cPanel/PublicAPI.pod 0000644 00000043310 15125143347 0010776 0 ustar 00 =encoding UTF-8 =head1 NAME cPanel::PublicAPI - A perl interface for interacting with cPanel =head1 SYNOPSIS use cPanel::PublicAPI; # Auto detect authentication information my $cp = cPanel::PublicAPI->new(); # or specify a user/password my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'pass' => 'somepass' ); # or specify an accesshash my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'accesshash' => $accesshash ); # or specify an API token my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'api_token' => $api_token ); # Perform an xml-api query $cp->whm_api('listaccts'); # Pass parameters to the xml-api $cp->whm_api('createacct', {'username' => 'someuser', 'password' => 's0m3P4$$w()Rd' } ); # Return JSON from xml-api (rather than a hash reference) $cp->whm_api('version', undef, 'json'); # Perform an API2 query $cp->cpanel_api2_request('whostmgr', { 'module' => 'Email', 'func' => 'listpopswithdisk', 'user' => 'someuser', } ); # Perform an API2 query when authenticated as a user $cp->cpanel_api2_request('cpanel', { 'module' => 'Email', 'func' => 'listpopswithdisk', } ); # Pass parameters to an API2 call $cp->cpanel_api2_request('cpanel' { 'module' => 'Email', 'func' => 'addpop', }, { 'domain' => 'domain.com', 'email' => 'username', 'password' => 'SojmASDM(#(Jinasifodanosd', 'quota' => 200 }, ); # Perform an API1 query $cp->cpanel_api1_request('whostmgr', { 'module' => 'LastLogin', 'func' => 'lastlogin', 'user' => 'someuser' } ); # Pass parameters to an API1 query $cp->cpanel_api1_request('cpanel', { 'module' => 'Mysql', 'func' => 'adduserdb', }, [ 'somedb', 'somedbuser', 'ALL' ] ); # perform an HTTP GET request against a URL $cp->api_request('whostmgr', '/xml-api/loadavg', 'GET'); # perform an HTTP GET request with parameters $cp->api_request('whostmgr', '/xml-api/createacct', 'GET', {'username' => 'someuser', domain => 'domain.com'} ); # perform an HTTP POST request (with parameters) $cp->api_request('whostmgr', '/xml-api/createacct', 'POST', {'username' => 'someuser', domain => 'domain.com'} ); =head1 DESCRIPTION cPanel::PublicAPI is a supported interface for interacting with cPanel's APIs over HTTP. This allows you to query either WHM or cPanel accounts from a perl interface. The purpose of this module is to provide an easy-to-use interface into cPanel's various APIs without requiring much knowledge of how they work. =head2 Object Construction a cPanel::PublicAPI object is constructed with the new() method. my $publicapi = cPanel::PublicAPI->new(); When passed no parameters, this will create the object using the accesshash in ~/.accesshash. If no .accesshash file exists, it will attempt to use the REMOTE_PASS environment variable. If the REMOTE_PASS variable is not defined, object creation will error out. =head3 new() parameters options for new() are specified as a hash reference, the following parameters are supported: =over =item * user - The username to authenticate as. =item * pass - The password to use for authentication. =item * accesshash - The accesshash to use for authentication (WHM only). =item * api_token - The API token to use for authentication. =item * timeout - The length of time (in seconds) before an http request should time out. Default to 300. =item * ip - The IP to be queried. defaults to 127.0.0.1, if host is defined it will take precedence over the 'ip' parameter. =item * host - The hostname to be queried. This will take precedence over the 'ip' parameter. =item * usessl - 1 or 0, Indicates whether communication should be performed over SSL or not (default to 1). =item * ssl_verify_mode - 1 or 0, Indicates whether to verify SSL certificates or not. (default to 1). =item * error_log - Path to where you want debug and error logging information to be written to. If this is not defined or the module is unable to open the path in question, it will default to STDERR. =item * debug - Enables debug logging, which will place considerably more information into the error_log. =item * http_tiny_creator - An optional code reference that receives the list of key/value pairs that normally goes into L<HTTP::Tiny>’s constructor to create an instance of that class for this module’s internal use. The code reference, when called, should return an object that implements an HTTP::Tiny-compatible interface. This parameter is useful for customizing that internal HTTP::Tiny instance that cPanel::PublicAPI uses. Handle with care, though: this parameter may break cPanel::PublicAPI in various ways—some subtle, others less so. For example, if you want a custom User-Agent header, you might do: http_tiny_creator => sub { return HTTP::Tiny->new( @_, agent => 'My Custom UA String', ); }, =back =head3 Authentication methods This module supports three authentication methods: =over =item 1. Username & Password use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); =item 2. API Token (Note: This method does not work with Webmail.) To create an API token, visit "Manage API Tokens" in cPanel or WHM, and follow the appropriate prompts. Your token will appear in a special notice. Make certain that you save your API token in a safe location, as this is the only time the token will be shown to you. To use an API token with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'api_token' => $string_containing_api_token ); =item 3. WHM Access Hash B<NOTE:> Accesshash authentication is deprecated as of cPanel & WHM version 64. To configure accesshashes, you can either: =over =item * In cPanel & WHM version 66 and earlier, visit “Setup remote access key” in WHM which will generate an accesshash for your server if one does not already exist. =item * Run F</usr/local/cpanel/bin/mkaccesshash>. This will overwrite any existing access hash. =back The generated accesshash is stored in F<~/.accesshash>. To use an accesshash with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'accesshash' => $string_containing_access_hash ); It should be noted that the accesshash can contain newlines in it. Newlines will be stripped by the object when it attempts to perform a query. =back =head3 Dependencies This module will fall back on different modules if one fails to load. This allows for compatibility with cPanel & WHM's internal perl parser and maintain compatibility with a standard perl implementation. The order that it will fall back on serialization modules is: =over =item * JSON::Syck =item * JSON =item * JSON::XS =item * JSON::PP =back If you installed this module via CPAN, this should never be an issue. If you are wishing to use this module on a system where you do not have access to compiled modules, JSON::PP is the recommended serializer. =head1 Two-Factor Authentication (2FA) cPanel version 54 and above allows users to configure 2FA on their accounts - this security policy requires that the API queries are performed after authenticating and establishing a session. The workflow to accomodate 2FA will be as so: use cPanel::PublicAPI; use lib '/usr/local/cpanel'; use Cpanel::Security::Authn::TwoFactorAuth::Google (); # only available in 11.54+ my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); my $google_auth = Cpanel::Security::Authn::TwoFactorAuth::Google->new( { 'account_name' => 'foo', 'secret' => $user_2fa_secret, 'issuer' => '' } ); $pubapi->establish_tfa_session('whostmgr', $google_auth->generate_code()); $pubapi->whm_api('applist'); Anytime you change services (e.g. from 'whostmgr' to 'cpanel'), you must establish the 2FA session for the new service. eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "failed cause 2fa session wasn't established\n" if $@; $pubapi->establish_tfa_session('cpanel', $google_auth->generate_code()); eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "success\n" if not $@; B<NOTE>: Additionally, since accesshash authentication is not allowed to establish sessions, you must use the 'user'/'pass' authentication in order to make API requests as a user with 2FA configured. =head1 Important Methods =head2 Querying the xml-api - whm_api() The XML-API is WHM's API used for administrative functions is handled via the whm_api() method. The syntax for whmapi is: $cp->whm_api($call [, \%formdata, $format ] ); The meaning of these parameters is: =over =item * $call - The XML-API call you wish to query =item * $formdata - The parameters for the XML-API call in question, f.ex. for suspendacct, here you would pass in a hashref containing “user” and “reason”. If there are no parameters, this can be undef or a blank hash. =item * $format - The requested response format. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. =back By default, WHM API v1 is used. If, for legacy reasons, you need to use v0, please set the C<api.version> key to 0 in the formdata parameter. For more information on what calls are available and how they can be referenced, please see the xml-api documentation at L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi>. =head2 Querying cPanel's APIs cPanel supports two APIs, designated "API1" and "API2". cPanel API calls are seperate into Modules, these module names relate to modules within the Cpanel namespace on a cPanel server. Each module defines a set of functions that are from either API1 or API2 (or both). There are two distinct differences between API1 and API2: =over =item * API1 Takes in ordered parameters and returns strings =item * API2 uses named parameters and returns hashes or arrays of hashes =back Within the context of the public api, calling a function from API1 or API2 will always return a hash, but the specific data returned from the API call will be contained within the 'data' key of the response. For more information on the differences between API1 and API2 please see the documentation: L<http://docs.cpanel.net/twiki/bin/view/DeveloperResources/ApiBasics/WebHome> For information on calling API1 and API2 direct via HTTP, please see: L<http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CallingAPIFunctions> =head3 cpanel_api1_request() C<cpanel_api1_request()> is used to query cPanel's API1, the function used for querying API1 has the following syntax: $cp->cpanel_api1_request($service, \%cfg [, \@params, $format ] ); =over =item * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. Only a user with reseller or root access can use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. =item * $cfg - A hash reference describing the call you wish to make. Required parameters are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. =item * $params - An array reference containing the parameters you wish to pass to the API call. =item * $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference. =back To see what modules and functions are available for making API1 calls, please see: L<http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome> =head3 cpanel_api2_request() C<cpanel_api2_request()> is used to query cPanel's API2, the function use for querying API2 has the following syntax: $cp->cpanel_api2_request( $service, \%cfg [, \%params, $format ] ); =over =item * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. A user that does not have reseller or root access will not be able to use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. =item * $cfg - A hash reference describing the call you wish to make. required parameters here are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. =item * $params - An hash reference containing the parameters you wish to pass to the API call. =item * $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. =back To see what modules and functions are available for making API2 calls, please see: L<http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome> =head2 api_request() - Making direct URL requests to cPanel & WHM. There are some situations where you will need to query cPanel and WHM URLs directly. This should ONLY be done when there is not an API call available for the function you wish to query. The function used for querying URLs directly is api_request(). It will always return a string rather than converting the response into a hash reference. It uses the following syntax: $cp->api_request( $service, $uri, $method, \%formdata, $headers) =over =item * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail', when passed an numerical value, PublicAPI will query that port directly. =item * $uri - The URL you wish to query, e.g. '/xml-api/cpanel' =item * $method - 'GET' or 'POST' =item * $formdata - The data you wish to pass to the URL =item * $headers - Any additional headers are to be passed with the request. These can be either a flat string or as a hashref like {'headertitle' =E<gt> 'headerdata'} =back =head1 Other Features =over =item C<establish_tfa_session()> =back See L</Two-Factor Authentication (2FA)> above. =over =item C<set_debug()> =back This function allows you to enable/disable debug mode by passing a value that evaluates to 'true' or 'false'. =over =item C<user()> =back Allows you to change the user that your PublicAPI object is authenticating with. =over =item C<pass()> =back Allows you to change the password that your PublicAPI object is authenticating with, this will remove the stored accesshash from the object. =over =item C<accesshash()> =back Allows you to change the accesshash that your PublicAPI object is authenticating with, this will remove the stored password from the object. =over =item C<api_token()> =back Allows you to change the API token that your PublicAPI object is authenticating with, this will remove the stored password from the object. =over =item C<format_http_query()> =back Allows you to construct formdata for an http query from a hash. For Example: $pubapi->format_http_query( { 'one' => '1', 'two' => 2 } ); would return: 'one=1&two=2' =over =item C<format_http_headers()> =back Allows you to construct headers for an http query from a hash. For Example: $pubapi->format_http_headers( { 'Authorization' => 'Basic cm9vdDpsMGx1cnNtNHJ0IQ=='} ); would return: 'Authorization: Basic cm9vdDpsMGx1cnNtNHJ0IQ==\r\n' =over =item C<$pubapi-E<gt>{'error'}> =back Errors encountered within the class are stored here before being written out to the error_fh filehandle. This can be used for checking the existance of query errors. =head1 Bugs see http://rt.cpan.org to report and view bugs =head1 License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. MYMETA.json 0000644 00000002764 15125143347 0006451 0 ustar 00 { "abstract" : "A perl interface for interacting with cPanel", "author" : [ "cPanel, Inc. <integration@cpanel.net>" ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010", "license" : [ "bsd" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "cPanel-PublicAPI", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "HTTP::CookieJar" : "0", "HTTP::Tiny" : "0.042", "IO::Socket::INET" : "1.31", "IO::Socket::SSL" : "1.988", "JSON::XS" : "2", "Test::Exception" : "0", "Test::More" : "0", "URI::Escape" : "3" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/CpanelInc/cPanel-PublicAPI/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/CpanelInc/cPanel-PublicAPI.git", "web" : "https://github.com/CpanelInc/cPanel-PublicAPI" } }, "version" : "2.8", "x_serialization_backend" : "JSON::PP version 4.06" } README 0000644 00000043217 15125143347 0005440 0 ustar 00 NAME cPanel::PublicAPI - A perl interface for interacting with cPanel SYNOPSIS use cPanel::PublicAPI; # Auto detect authentication information my $cp = cPanel::PublicAPI->new(); # or specify a user/password my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'pass' => 'somepass' ); # or specify an accesshash my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'accesshash' => $accesshash ); # or specify an API token my $cp = cPanel::PublicAPI->new( 'user' => 'someuser', 'api_token' => $api_token ); # Perform an xml-api query $cp->whm_api('listaccts'); # Pass parameters to the xml-api $cp->whm_api('createacct', {'username' => 'someuser', 'password' => 's0m3P4$$w()Rd' } ); # Return JSON from xml-api (rather than a hash reference) $cp->whm_api('version', undef, 'json'); # Perform an API2 query $cp->cpanel_api2_request('whostmgr', { 'module' => 'Email', 'func' => 'listpopswithdisk', 'user' => 'someuser', } ); # Perform an API2 query when authenticated as a user $cp->cpanel_api2_request('cpanel', { 'module' => 'Email', 'func' => 'listpopswithdisk', } ); # Pass parameters to an API2 call $cp->cpanel_api2_request('cpanel' { 'module' => 'Email', 'func' => 'addpop', }, { 'domain' => 'domain.com', 'email' => 'username', 'password' => 'SojmASDM(#(Jinasifodanosd', 'quota' => 200 }, ); # Perform an API1 query $cp->cpanel_api1_request('whostmgr', { 'module' => 'LastLogin', 'func' => 'lastlogin', 'user' => 'someuser' } ); # Pass parameters to an API1 query $cp->cpanel_api1_request('cpanel', { 'module' => 'Mysql', 'func' => 'adduserdb', }, [ 'somedb', 'somedbuser', 'ALL' ] ); # perform an HTTP GET request against a URL $cp->api_request('whostmgr', '/xml-api/loadavg', 'GET'); # perform an HTTP GET request with parameters $cp->api_request('whostmgr', '/xml-api/createacct', 'GET', {'username' => 'someuser', domain => 'domain.com'} ); # perform an HTTP POST request (with parameters) $cp->api_request('whostmgr', '/xml-api/createacct', 'POST', {'username' => 'someuser', domain => 'domain.com'} ); DESCRIPTION cPanel::PublicAPI is a supported interface for interacting with cPanel's APIs over HTTP. This allows you to query either WHM or cPanel accounts from a perl interface. The purpose of this module is to provide an easy-to-use interface into cPanel's various APIs without requiring much knowledge of how they work. Object Construction a cPanel::PublicAPI object is constructed with the new() method. my $publicapi = cPanel::PublicAPI->new(); When passed no parameters, this will create the object using the accesshash in ~/.accesshash. If no .accesshash file exists, it will attempt to use the REMOTE_PASS environment variable. If the REMOTE_PASS variable is not defined, object creation will error out. new() parameters options for new() are specified as a hash reference, the following parameters are supported: * user - The username to authenticate as. * pass - The password to use for authentication. * accesshash - The accesshash to use for authentication. * api_token - The API token to use for authentication. * timeout - The length of time (in seconds) before an http request should time out. Default to 300. * ip - The IP to be queried. defaults to 127.0.0.1, if host is defined it will take precedence over the 'ip' parameter. * host - The hostname to be queried. This will take precedence over the 'ip' parameter. * usessl - 1 or 0, Indicates whether communication should be performed over SSL or not (default to 1). * ssl_verify_mode - 1 or 0, Indicates whether to verify SSL certificates or not. (default to 1). * error_log - Path to where you want debug and error logging information to be written to. If this is not defined or the module is unable to open the path in question, it will default to STDERR. * debug - Enables debug logging, which will place considerably more information into the error_log. Notes about authentication There are three sets of credentials that can be used to authenticate to WHM. First we have the basic user/password combinations: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); Next is API token authentication. To create an API token, visit "Manage API Tokens" in WHM and click Generate Token. Fill out the form and click Generate. Your token will appear in a special notice. Make certain that you save your API token in a safe location on your workstation. You cannot access the token after you navigate away from the interface or refresh the API Tokens table. To use an API token with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'api_token' => $string_containing_api_token ); Last is accesshash authentication. To configure accesshashes, visit “Setup remote access key” in WHM which will generate an accesshash for your server if one does not already exist. It will store the generated accesshash in ~/.accesshash. To use an accesshash with this module, do the following: use cPanel::PublicAPI; my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'accesshash' => $string_containing_access_hash ); It should be noted that the accesshash can contain newlines in it. Newlines will be stripped by the object when it attempts to perform a query. NOTE: Accesshash authentication is deprecated in cPanel & WHM version 64. Dependencies This module will fall back on different modules if one fails to load. This allows for compatibility with cPanel & WHM's internal perl parser and maintain compatibility with a standard perl implementation. The order that it will fall back on serialization modules is: * JSON::Syck * JSON * JSON::XS * JSON::PP If you installed this module via CPAN, this should never be an issue. If you are wishing to use this module on a system where you do not have access to compiled modules, JSON::PP is the recommended serializer. Two-Factor Authentication (2FA) cPanel version 54 and above allows users to configure 2FA on their accounts - this security policy requires that the API queries are performed after authenticating and establishing a session. The workflow to accomodate 2FA will be as so: use cPanel::PublicAPI; use lib '/usr/local/cpanel'; use Cpanel::Security::Authn::TwoFactorAuth::Google (); # only available in 11.54+ my $pubapi = cPanel::PublicAPI->new( 'user' => 'foo', 'pass' => 'bar' ); my $google_auth = Cpanel::Security::Authn::TwoFactorAuth::Google->new( { 'account_name' => 'foo', 'secret' => $user_2fa_secret, 'issuer' => '' } ); $pubapi->establish_tfa_session('whostmgr', $google_auth->generate_code()); $pubapi->whm_api('applist'); Anytime you change services (e.g. from 'whostmgr' to 'cpanel'), you must establish the 2FA session for the new service. eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "failed cause 2fa session wasn't established\n" if $@; $pubapi->establish_tfa_session('cpanel', $google_auth->generate_code()); eval { $pubapi->cpanel_api2_request('cpanel', { 'user' => 'foo', 'module' => 'MysqlFE', 'func' => 'listdbs' }, {} ); }; print "success\n" if not $@; NOTE: Additionally, since accesshash authentication is not allowed to establish sessions, you must use the 'user'/'pass' authentication in order to make API requests as a user with 2FA configured. Important Methods Querying the xml-api - whm_api() The XML-API is WHM's API used for administrative functions is handled via the whm_api() method. The syntax for whmapi is: $cp->whm_api($call [, \%formdata, $format ] ); The meaning of these parameters is: * $call - The XML-API call you wish to query * $formdata - The parameters for the XML-API call in question, f.ex. for suspendacct, here you would pass in a hashref containing “user” and “reason”. If there are no parameters, this can be undef or a blank hash. * $format - The requested response format. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. By default, WHM API v1 is used. If, for legacy reasons, you need to use v0, please set the "api.version" key to 0 in the formdata parameter. For more information on what calls are available and how they can be referenced, please see the xml-api documentation at <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegr ation/XmlApi>. Querying cPanel's APIs cPanel supports two APIs, designated "API1" and "API2". cPanel API calls are seperate into Modules, these module names relate to modules within the Cpanel namespace on a cPanel server. Each module defines a set of functions that are from either API1 or API2 (or both). There are two distinct differences between API1 and API2: * API1 Takes in ordered parameters and returns strings * API2 uses named parameters and returns hashes or arrays of hashes Within the context of the public api, calling a function from API1 or API2 will always return a hash, but the specific data returned from the API call will be contained within the 'data' key of the response. For more information on the differences between API1 and API2 please see the documentation: <http://docs.cpanel.net/twiki/bin/view/DeveloperResources/ApiBasics/WebH ome> For information on calling API1 and API2 direct via HTTP, please see: <http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegr ation/CallingAPIFunctions> cpanel_api1_request() "cpanel_api1_request()" is used to query cPanel's API1, the function used for querying API1 has the following syntax: $cp->cpanel_api1_request($service, \%cfg [, \@params, $format ] ); * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. Only a user with reseller or root access can use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. * $cfg - A hash reference describing the call you wish to make. Required parameters are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. * $params - An array reference containing the parameters you wish to pass to the API call. * $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference. To see what modules and functions are available for making API1 calls, please see: <http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/WebHome> cpanel_api2_request() "cpanel_api2_request()" is used to query cPanel's API2, the function use for querying API2 has the following syntax: $cp->cpanel_api2_request( $service, \%cfg [, \%params, $format ] ); * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail'. It is important to note that what services you are able to query depends on the user you are authenticated as. A user that does not have reseller or root access will not be able to use the whostmgr service. If you are authenticated as root, you will not be able to query the 'cpanel' service. When the service is set to 'whostmgr' a 'user' must be set in the $cfg hash. * $cfg - A hash reference describing the call you wish to make. required parameters here are 'module' and 'func', which correspond to the module and function of the API call you wish to query. If you are querying the "whostmgr" service, you will need to specify 'user' as well. * $params - An hash reference containing the parameters you wish to pass to the API call. * $format - The format for the xml-api to respond in. The valid values here are “xml”, “json” or “ref” (perl hash reference). This will default to returning a perl hash reference when the value is undef. To see what modules and functions are available for making API2 calls, please see: <http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/WebHome> api_request() - Making direct URL requests to cPanel & WHM. There are some situations where you will need to query cPanel and WHM URLs directly. This should ONLY be done when there is not an API call available for the function you wish to query. The function used for querying URLs directly is api_request(). It will always return a string rather than converting the response into a hash reference. It uses the following syntax: $cp->api_request( $service, $uri, $method, \%formdata, $headers) * $service - The service that you wish to query. This can be 'cpanel' 'whostmgr', or 'webmail', when passed an numerical value, PublicAPI will query that port directly. * $uri - The URL you wish to query, e.g. '/xml-api/cpanel' * $method - 'GET' or 'POST' * $formdata - The data you wish to pass to the URL * $headers - Any additional headers are to be passed with the request. These can be either a flat string or as a hashref like {'headertitle' => 'headerdata'} Other Features "establish_tfa_session()" See "Two-Factor Authentication (2FA)" above. "set_debug()" This function allows you to enable/disable debug mode by passing a value that evaluates to 'true' or 'false'. "user()" Allows you to change the user that your PublicAPI object is authenticating with. "pass()" Allows you to change the password that your PublicAPI object is authenticating with, this will remove the stored accesshash from the object. "accesshash()" Allows you to change the accesshash that your PublicAPI object is authenticating with, this will remove the stored password from the object. "api_token()" Allows you to change the API token that your PublicAPI object is authenticating with, this will remove the stored password from the object. "format_http_query()" Allows you to construct formdata for an http query from a hash. For Example: $pubapi->format_http_query( { 'one' => '1', 'two' => 2 } ); would return: 'one=1&two=2' "format_http_headers()" Allows you to construct headers for an http query from a hash. For Example: $pubapi->format_http_headers( { 'Authorization' => 'Basic cm9vdDpsMGx1cnNtNHJ0IQ=='} ); would return: 'Authorization: Basic cm9vdDpsMGx1cnNtNHJ0IQ==\r\n' "$pubapi->{'error'}" Errors encountered within the class are stored here before being written out to the error_fh filehandle. This can be used for checking the existance of query errors. Bugs see http://rt.cpan.org to report and view bugs License Copyright (c) 2015, cPanel, Inc. All rights reserved. http://cpanel.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cPanel, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0.12 |
proxy
|
phpinfo
|
???????????