#!/usr/bin/perl -w ############################################################################### # HCCExtensions.pm - A custom API module for CPanel # Version 0.1 beta - 8/DEC/2003 # (c) 2002-2003 Juan R. Pozo # http://html.conclase.net/cp/scripts/ # mailto:jrpozo@conclase.net # Mailing-list: http://www.conclase.net/mailman/listinfo/cpanel_conclase.net ############################################################################### # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### # For INSTALLATION and DOCUMENTATION please see: # http://html.conclase.net/cp/scripts/HCCExtensions.txt (plain text), or # http://html.conclase.net/cp/scripts/HCCExtensions.pdf (Acrobat) ############################################################################### # Please consider making a donation today. Visit my amazon.com wishlist at: # http://html.conclase.net/link/wishlist # Thank you :) ############################################################################### package Cpanel::HCCExtensions; use strict; use vars qw(@ISA @EXPORT $VERSION $prefix); require Exporter; @ISA = qw(Exporter); @EXPORT = qw( HCCExtensions_init HCCExtensions_viewfile HCCExtensions_AddonsListInstalledOptions HCCExtensions_OwnerDomain ); $VERSION = '0.1'; $prefix = "HCCExtensions"; require 5.004; sub HCCExtensions_init { return(1); } sub HCCExtensions_viewfile { my $dir = shift; my $file = shift; if ($dir =~ /^\s*(\S*)\s*$/) { $dir = $1; } if ($file =~ /^\s*(\S*)\s*$/) { $file = $1; } my $pid = open(VF, "-|"); if (!defined($pid)) { return; } if (!$pid) { # child Cpanel::Fileman::viewfile($dir, $file); exit; } else { # parent my $output = ""; while () { $output .= $_; } close(VF); my ($info, $source) = split (/
/, $output, 2); $info .= "
"; if ($source =~ /^
/)   { $source = substr($source, 5); }
        if ($source =~ /<\/pre>$/) { $source = substr($source, 0, -6); }

        if ($info =~ /
[^:]*:([^<]*)/ && $1 =~ /text/i) { $info .= "
";
            $source =~ s/&/&/g;
            $source =~ s//>/g;
            $source =~ s/"/"/g;
            $source .= "
"; } print $info.$source; } } sub HCCExtensions_AddonsListInstalledOptions { my $addonname = shift; $addonname = escape_input($addonname); my $filename = $Cpanel::homedir . "/.addonscgi-" . $addonname; if (-r $filename) { open(INDEX, "<$filename") or return; while () { if (/^(\S+)\s*/) { print "\n"; } } close(INDEX); } } sub HCCExtensions_OwnerDomain { my $filename = "/var/cpanel/users/$Cpanel::CPDATA{'OWNER'}"; if (-r $filename) { open(CPU, "<$filename") or return; while () { if (/^\s*DNS\s*=\s*(\S+)/) { print $1; last; } } close(CPU); } else { print `/bin/hostname`; } } sub escape_input { my $input = shift; $input =~ s/([\&;\`'\\\|"\*?~<>^\(\)\[\]\{\}\$\n\r!#:])/\\$1/g; $input =~ s/\0//g; return $input; } 1;