This file is indexed.

/usr/share/ipplan/user/swiplib.php is in ipplan 4.92a-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php

// IPplan v4.92a
// Aug 24, 2001
//
// 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.
//

require_once("../xmllib.php");
require_once("../class.templib.php");

// function to generate swip entry - returns a string with swip
// which can then be displayed/emailed etc
function genSWIP($ds, $baseindex, $start, $end, $cust, 
                 $descrip, $swipmod, $filename) {

    global $ntnameopt;

    //************ now process customer standard fields ************//

    $result1=&$ds->ds->Execute("SELECT *
            FROM custinfo
            WHERE customer=$cust");
    // should only be one row here, none if SWIP turned off during creation
    // of customer
    $row1=$result1->FetchRow();

    $result2=&$ds->ds->Execute("SELECT hname, ipaddr
            FROM revdns
            WHERE customer=$cust
            ORDER BY horder");

    $fields=array();
    $fields["ntsnum"]=$start;
    $fields["ntenum"]=$end;
    $fields=array_merge($fields, $row1);

    // use subnet description field? then only a-z, 0-9 max 21 chars allowed
    if ($ntnameopt and preg_match("/^[A-Za-z0-9\-]{1,21}$/", $descrip)) {
        $ntname=$descrip;
    }
    else {
        $ntname=MAINTAINERID."-".str_replace(".", "-", $start);
    }
    $fields["ntname"]=$ntname;
    $fields["maint"]=MAINTAINERID;

    if($row2 = $result2->FetchRow()) {
        $fields["hname1"]=$row2["hname"];
        $fields["ipaddr1"]=$row2["ipaddr"];
    }
    else {
        $fields["hname1"]="";
        $fields["ipaddr1"]="";
    }

    if($row2 = $result2->FetchRow()) {
        $fields["hname2"]=$row2["hname"];
        $fields["ipaddr2"]=$row2["ipaddr"];
    }
    else {
        $fields["hname1"]="";
        $fields["ipaddr1"]="";
    }

    if($row2 = $result2->FetchRow()) {
        $fields["hname3"]=$row2["hname"];
        $fields["ipaddr3"]=$row2["ipaddr"];
    }
    else {
        $fields["hname1"]="";
        $fields["ipaddr1"]="";
    }

    $cnt=3;
    while($row2 = $result2->FetchRow()) {
        $fields["hname$cnt"]=$row2["hname"];
        $fields["ipaddr$cnt"]=$row2["ipaddr"];
        $cnt++;
    }

    $fields["regid"]=REGID;
    $fields["password"]=REGPASS;
    $fields["source"]=REGISTRY;

    // add a UTC format date
    $now = getdate();
    $fields["date"] = $now["year"] . str_pad($now["mon"], 2, '0',
            STR_PAD_LEFT) . str_pad( $now["mday"], 2, '0', STR_PAD_LEFT);
    $fields["swipmod"]=$swipmod;

    //************ now process customer template fields ************//

    // if a specific customer template exists
    $err=TRUE;
    $template=new IPplanIPTemplate("custtemplate", $cust);
    $err=$template->is_error();

    // process fields form the user defined template
    if (!$err) {
        $restmp=&$ds->ds->Execute("SELECT info
                FROM custadd
                WHERE customer=$cust");

        if($rowadd = $restmp->FetchRow()) {
            $template->Merge($template->decode($rowadd["info"]));
            foreach($template->userfld as $key=>$arr) {
                $fields[$key]=$arr["value"];
            }
        }
    }

    //************ now process base template fields ************//

    // if a specific base template exists, use that, else use generic template
    $err=TRUE;
    $template=new IPplanIPTemplate("basetemplate", $cust);
    $err=$template->is_error();

    if (!$err) {
        $result_template=&$ds->ds->Execute("SELECT info, infobin
                FROM baseadd
                WHERE baseindex=$baseindex");

        if ( $rowadd = $result_template->FetchRow()) {
            $template->Merge($template->decode($rowadd["info"]));

            foreach($template->userfld as $key=>$arr) {
                $fields[$key]=$arr["value"];
            }
        }
    }

    $rep = new myTemplate;
    if ($rep->get("../templates/$filename") == FALSE)
        return FALSE;
    $swip=$rep->process($fields);

    return $swip;
}

// email the swip entry
function emailSWIP($swip) {

    require_once("/usr/share/php/libphp-phpmailer/class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SetLanguage("en", "../");
    $mail->Host = EMAILSERVER; // SMTP server
    $mail->From = REGADMINEMAIL;
    $mail->FromName = "IP Plan";
    $mail->AddAddress(REGEMAIL);
    $mail->IsHTML(false);
    $mail->Subject = "SWIP";
    $mail->Body= $swip;
    $mail->AddReplyTo(REGADMINEMAIL);
    $mail->AddCustomHeader("X-Mailer: PHP/" . phpversion());
    //$mail->AddCustomHeader("IPplan version goes here");

    if(REGISTRY=="RIPE") {
       $mail->AddCustomHeader("X-NCC-regid: ".REGID);
    }

    if(!@$mail->Send()) {
        return $mail->ErrorInfo;
    }

/*
    $header="From: ".REGADMINEMAIL."\n".
        "Reply-To: ".REGADMINEMAIL."\n".
        "X-Mailer: PHP/" . phpversion();

    if(REGISTRY=="RIPE") {
        $header.="\nX-NCC-regid: ".REGID."\n";
    }

    mail(REGEMAIL, "SWIP",
            $swip, $header);
    */
}

?>