Esempio n. 1
0
/**
 * Print subnets structure
 */
function printAdminSubnets($subnets, $actions = true, $vrf = "0")
{
    $html = array();
    $rootId = 0;
    # root is 0
    if (sizeof($subnets) > 0) {
        foreach ($subnets as $item) {
            $children[$item['masterSubnetId']][] = $item;
        }
    }
    /* get custom fields */
    $custom = getCustomFields('subnets');
    global $settings;
    /* set hidden fields */
    $ffields = json_decode($settings['hiddenCustomFields'], true);
    if (is_array($ffields['subnets'])) {
        $ffields = $ffields['subnets'];
    } else {
        $ffields = array();
    }
    # loop will be false if the root has no children (i.e., an empty menu!)
    $loop = !empty($children[$rootId]);
    # initializing $parent as the root
    $parent = $rootId;
    $parent_stack = array();
    # display selected subnet as opened
    if (isset($_GET['subnetId'])) {
        if (!is_numeric($_GET['subnetId'])) {
            die('<div class="alert alert-danger">' . _("Invalid ID") . '</div>');
        }
        $allParents = getAllParents($_GET['subnetId']);
    }
    # return table content (tr and td's)
    while ($loop && (($option = each($children[$parent])) || $parent > $rootId)) {
        # repeat
        $repeat = str_repeat(" - ", count($parent_stack));
        # dashes
        if (count($parent_stack) == 0) {
            $dash = "";
        } else {
            $dash = "-";
        }
        if (count($parent_stack) == 0) {
            $margin = "0px";
            $padding = "0px";
        } else {
            # padding
            $padding = "10px";
            # margin
            $margin = count($parent_stack) * 10 - 10;
            $margin = $margin * 2;
            $margin = $margin . "px";
        }
        # count levels
        $count = count($parent_stack) + 1;
        # get VLAN
        $vlan = subnetGetVLANdetailsById($option['value']['vlanId']);
        $vlan = $vlan['number'];
        if (empty($vlan) || $vlan == "0") {
            $vlan = "";
        }
        # no VLAN
        # description
        if (strlen($option['value']['description']) == 0) {
            $description = "/";
        } else {
            $description = $option['value']['description'];
        }
        # description
        # requests
        if ($option['value']['allowRequests'] == 1) {
            $requests = "<i class='fa fa-gray fa-check'></i>";
        } else {
            $requests = "";
        }
        # request disabled
        # hosts check
        if ($option['value']['pingSubnet'] == 1) {
            $pCheck = "<i class='fa fa-gray fa-check'></i>";
        } else {
            $pCheck = "";
        }
        # ping check disabled
        #vrf
        if ($vrf == "1") {
            # get VRF details
            if ($option['value']['vrfId'] != "0" && $option['value']['vrfId'] != "NULL") {
                $vrfTmp = getVRFDetailsById($option['value']['vrfId']);
                $vrfText = $vrfTmp['name'];
            } else {
                $vrfText = "";
            }
        }
        # print table line
        if (strlen($option['value']['subnet']) > 0) {
            $html[] = "<tr>";
            # folder
            if ($option['value']['isFolder'] == 1) {
                $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-folder-open'></i> <a href='" . create_link("folder", $option['value']['sectionId'], $option['value']['id']) . "'>{$description}</a></td>";
                $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-folder-open'></i> {$description}</td>";
            } else {
                if ($count == 1) {
                    $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'>  " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
                    $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i> {$description}</td>";
                } else {
                    # last?
                    if (!empty($children[$option['value']['id']])) {
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i> <a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'>  " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i> {$description}</td>";
                    } else {
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-angle-right'></i> <a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'>  " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-angle-right'></i> {$description}</td>";
                    }
                }
            }
            $html[] = "\t<td class='hidden-xs hidden-sm'>{$vlan}</td>";
            #vrf
            if ($vrf == "1") {
                $html[] = "\t<td class='hidden-xs hidden-sm'>{$vrfText}</td>";
            }
            $html[] = "\t<td class='hidden-xs hidden-sm hidden-md'>{$requests}</td>";
            $html[] = "\t<td class='hidden-xs hidden-sm hidden-md'>{$pCheck}</td>";
            # custom
            if (sizeof($custom) > 0) {
                foreach ($custom as $field) {
                    if (!in_array($field['name'], $ffields)) {
                        $html[] = "\t<td class='hidden-xs hidden-sm'>" . $option['value'][$field['name']] . "</td>";
                    }
                }
            }
            # actions
            if ($actions) {
                $html[] = "\t<td class='actions' style='padding:0px;'>";
                $html[] = "\t<div class='btn-group btn-group-xs'>";
                if ($option['value']['isFolder'] == 1) {
                    $html[] = "\t\t<button class='btn btn-sm btn-default add_folder'     data-action='edit'   data-subnetid='" . $option['value']['id'] . "'  data-sectionid='" . $option['value']['sectionId'] . "'><i class='fa fa-gray fa-pencil'></i></button>";
                    $html[] = "\t\t<button class='btn btn-sm btn-default showSubnetPerm' data-action='show'   data-subnetid='" . $option['value']['id'] . "'  data-sectionid='" . $option['value']['sectionId'] . "'><i class='fa fa-gray fa-tasks'></i></button>";
                    $html[] = "\t\t<button class='btn btn-sm btn-default add_folder'     data-action='delete' data-subnetid='" . $option['value']['id'] . "'  data-sectionid='" . $option['value']['sectionId'] . "'><i class='fa fa-gray fa-times'></i></button>";
                } else {
                    $html[] = "\t\t<button class='btn btn-sm btn-default editSubnet'     data-action='edit'   data-subnetid='" . $option['value']['id'] . "'  data-sectionid='" . $option['value']['sectionId'] . "'><i class='fa fa-gray fa-pencil'></i></button>";
                    $html[] = "\t\t<button class='btn btn-sm btn-default showSubnetPerm' data-action='show'   data-subnetid='" . $option['value']['id'] . "'  data-sectionid='" . $option['value']['sectionId'] . "'><i class='fa fa-gray fa-tasks'></i></button>";
                    $html[] = "\t\t<button class='btn btn-sm btn-default editSubnet'     data-action='delete' data-subnetid='" . $option['value']['id'] . "'  data-sectionid='" . $option['value']['sectionId'] . "'><i class='fa fa-gray fa-times'></i></button>";
                }
                $html[] = "\t</div>";
                $html[] = "\t</td>";
            }
            $html[] = "</tr>";
        }
        if ($option === false) {
            $parent = array_pop($parent_stack);
        } elseif (!empty($children[$option['value']['id']])) {
            array_push($parent_stack, $option['value']['masterSubnetId']);
            $parent = $option['value']['id'];
        } else {
        }
    }
    return implode("\n", $html);
}
Esempio n. 2
0
 /**
  * Send mail on new changelog
  *
  * @access public
  * @param string $changelog
  * @return boolean
  */
 public function changelog_send_mail($changelog)
 {
     # initialize tools class
     $this->Tools = new Tools($this->Database);
     # set object
     $obj_details = $this->object_action == "add" ? $this->object_new : $this->object_old;
     # change ip_addr
     $this->object_type = str_replace("ip_addr", "address", $this->object_type);
     $this->object_type = str_replace("ip_range", "address range", $this->object_type);
     # folder
     if ($this->object_new['isFolder'] == "1" || $this->object_old['isFolder'] == "1") {
         $this->object_type = "folder";
     }
     # set subject
     $subject = string;
     if ($this->object_action == "add") {
         $subject = ucwords($this->object_type) . " create notification";
     } elseif ($this->object_action == "edit") {
         $subject = ucwords($this->object_type) . " change notification";
     } elseif ($this->object_action == "delete") {
         $subject = ucwords($this->object_type) . " delete notification";
     }
     // if address we need subnet details !
     $address_subnet = array();
     if ($this->object_type == "address") {
         $address_subnet = (array) $this->Tools->fetch_object("subnets", "id", $obj_details['subnetId']);
     }
     # set object details
     $details = string;
     if ($this->object_type == "section") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("subnets", $obj_details['id']) . "'>" . $obj_details['name'] . "(" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "subnet") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("subnets", $obj_details['sectionId'], $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['subnet'], "dotted") . "/" . $obj_details['mask'] . " (" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "folder") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("folder", $obj_details['sectionId'], $obj_details['id']) . "'>" . $obj_details['description'] . " - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address") {
         $details = "<a style='font-family:Helvetica, Verdana, Arial, sans-serif; font-size:12px;color:#a0ce4e;' href='" . $this->createURL() . create_link("subnets", $address_subnet['sectionId'], $obj_details['subnetId'], "address-details", $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['ip_addr'], "dotted") . " ( hostname " . $obj_details['dns_name'] . ", subnet: " . $this->Subnets->transform_address($address_subnet['subnet'], "dotted") . "/" . $address_subnet['mask'] . ")- id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address range") {
         $details = $changelog;
     }
     # set content
     $content = array();
     $content[] = "<div style='padding:10px;'>";
     $content[] = "<table>";
     $content[] = "<tr><td colspan='2'>{$this->mail_font_style}<strong>The following change was made on ipam:</strong></font></td></tr>";
     $content[] = "<tr><td colspan='2'>&nbsp;</td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Object type:</font><td>{$this->mail_font_style}" . ucwords($this->object_type) . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Object details:</font><td>{$this->mail_font_style_href}" . $details . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} User:</font><td>{$this->mail_font_style}" . $this->user->real_name . " (" . $this->user->username . ")" . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Action:</font><td>{$this->mail_font_style}" . $this->object_action . "</font></td></tr>";
     $content[] = "<tr><td>{$this->mail_font_style} Date:</font><td>{$this->mail_font_style}" . date("Y-m-d H:i:s") . "</font></td></tr>";
     $content[] = "<tr><td colspan='2'><hr style='height:0px;border-top:0px;border-bottom:1px solid #ddd;'></td></tr>";
     $content[] = "<tr><td style='vertical-align:top;'>{$this->mail_font_style} Changes:</td>";
     $content[] = "<td>";
     // add changelog
     $changelog = str_replace("\r\n", "<br>", $changelog);
     $changelog = array_filter(explode("<br>", $changelog));
     $content[] = "<table>";
     foreach ($changelog as $c) {
         // field
         $field = explode(":", $c);
         $value = explode("=>", $field[1]);
         // format field
         $field = trim(str_replace(array("[", "]"), "", $field[0]));
         if (is_array($this->changelog_keys[$this->object_type])) {
             if (array_key_exists($field, $this->changelog_keys[$this->object_type])) {
                 $field = $this->changelog_keys[$this->object_type][$field];
             }
         } else {
             $field = $field;
         }
         $content[] = "<tr>";
         $content[] = "  <td>{$this->mail_font_style}<strong> {$field}</strong>: </font></td>";
         $content[] = "  <td>{$this->mail_font_style} " . trim($value[0]) . " </font></td>";
         if ($this->object_action == "edit") {
             $content[] = "  <td>{$this->mail_font_style} => </font></td>";
             $content[] = "  <td>{$this->mail_font_style} " . trim($value[1]) . " </font></td>";
         }
         $content[] = "</tr>";
     }
     $content[] = "</table>";
     $content[] = "</font></td></tr>";
     $content[] = "</table>";
     $content[] = "</div>";
     # set plain content
     $content_plain = array();
     $content_plain[] = "Object type: " . $this->object_type;
     $content_plain[] = "Object details: " . $details;
     $content_plain[] = "User: "******" (" . $this->user->username . ")";
     $content_plain[] = "Action: " . $this->object_action;
     $content_plain[] = "Date: " . date("Y-m-d H:i:s");
     $content_plain[] = "\r\n--------------------\r\n";
     $content_plain[] = str_replace("<br>", "\r\n", $changelog);
     # get all admins and check who to end mail to
     //subnets, addresses - send mail to normal users also
     if ($this->object_type == "subnet" || $this->object_type == "address") {
         if ($this->object_type == "subnet") {
             $recipients = $this->changelog_mail_get_recipients($obj_details['id']);
         } else {
             $recipients = $this->changelog_mail_get_recipients($obj_details['subnetId']);
         }
     } else {
         $recipients = $this->changelog_mail_get_recipients(false);
     }
     if ($recipients === false) {
         return true;
     }
     # fetch mailer settings
     $mail_settings = $this->Tools->fetch_object("settingsMail", "id", 1);
     # initialize mailer
     $phpipam_mail = new phpipam_mail($this->settings, $mail_settings);
     $phpipam_mail->initialize_mailer();
     // set content
     $content = $phpipam_mail->generate_message(implode("\r\n", $content));
     $content_plain = implode("\r\n", $content_plain);
     # try to send
     try {
         $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
         foreach ($recipients as $r) {
             $phpipam_mail->Php_mailer->addAddress(addslashes(trim($r->email)));
         }
         $phpipam_mail->Php_mailer->Subject = $subject;
         $phpipam_mail->Php_mailer->msgHTML($content);
         $phpipam_mail->Php_mailer->AltBody = $content_plain;
         //send
         $phpipam_mail->Php_mailer->send();
     } catch (phpmailerException $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     } catch (Exception $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     }
     # ok
     return true;
 }
Esempio n. 3
0
 /**
  * Updates users password
  *
  * @access public
  * @param mixed $password
  * @return void
  */
 public function update_user_pass($password)
 {
     try {
         $this->Database->updateObject("users", array("password" => $this->crypt_user_pass($password), "passChange" => "No", "id" => $this->user->id), "id");
     } catch (Exception $e) {
         $this->Result->show("danger", $e->getMessage(), true);
     }
     $this->Result->show("success", "Hi, " . $this->user->real_name . ", " . _("your password was updated") . ". <a class='btn btn-sm btn-default' href='" . create_link("dashboard") . "'>Dashboard</a>", false);
 }
Esempio n. 4
0
<?php

/*
 * Script to print some stats on home page....
 *********************************************/
/* required functions */
if (!function_exists('getSubnetStatsDashboard')) {
    require_once dirname(__FILE__) . '/../../../functions/functions.php';
}
/* if direct request that redirect to tools page */
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
    header("Location: " . BASE . "" . create_link("administration", "manageRequests"));
}
/* get all */
$allActiveRequests = getAllActiveIPrequests();
?>



<?php 
if (sizeof($allActiveRequests) == 0) {
    print "<blockquote style='margin-top:20px;margin-left:20px;'>";
    print "<small>" . _("No IP address requests available") . "!</small><br>";
    print "</blockquote>";
} else {
    ?>

<table id="requestedIPaddresses" class="table table-condensed table-hover table-top">

<!-- headers -->
<tr>
Esempio n. 5
0
 print "\t<th class='small hidden-xs hidden-sm'>% " . _('Free') . "</th>";
 print "\t<th class='small hidden-xs hidden-sm'>" . _('Requests') . "</th>";
 print " <th class='actions'></th>";
 print "</tr>";
 # print subnets
 foreach ($slaves as $subnet) {
     # cast
     $subnet = (array) $subnet;
     # check permission
     $permission = $Subnets->check_permission($User->user, $subnet['id']);
     # allowed
     $m = 0;
     if ($permission > 0) {
         print "<tr>";
         print "\t<td class='small description'><a href='" . create_link("subnets", $_GET['section'], $subnet['id']) . "'>{$subnet['description']}</a></td>";
         print "\t<td><a href='" . create_link("subnets", $_GET['section'], $subnet['id']) . "'>{$subnet['ip']}/{$subnet['mask']}</a></td>";
         # host check
         if ($subnet['pingSubnet'] == 1) {
             print '<td class="allowRequests small hidden-xs hidden-sm">' . _('enabled') . '</td>';
         } else {
             print '<td class="allowRequests small hidden-xs hidden-sm"></td>';
         }
         # increase IP count
         $ipCount = 0;
         if (!$Subnets->has_slaves($subnet['id'])) {
             $ipCount = $Addresses->count_subnet_addresses($subnet['id']);
         } else {
             # fix for subnet and broadcast free space calculation
             $ipCount = 0;
             //initial count
             $Subnets->reset_subnet_slaves_recursive();
Esempio n. 6
0
        } elseif ($_GET['page'] == "administration") {
            # Admin object
            $Admin = new Admin($Database);
            if (!isset($_GET['section'])) {
                include "app/admin/index.php";
            } elseif (@$_GET['subnetId'] == "section-changelog") {
                include "app/sections/section-changelog.php";
            } else {
                if (!file_exists("app/admin/{$_GET['section']}/index.php")) {
                    header("Location: " . create_link("error", "404"));
                } else {
                    include "app/admin/{$_GET['section']}/index.php";
                }
            }
        } else {
            header("Location: " . create_link("error", "404"));
        }
        print "</div>";
        print "</td>";
        print "</tr>";
        print "</table>";
    }
    ?>

</div>
</div>

<!-- Base for IE -->
<div class="iebase hidden"><?php 
    print BASE;
    ?>
Esempio n. 7
0
        //explode
        unset($sec);
        $sections_tmp = explode(";", $domain->permissions);
        foreach ($sections_tmp as $t) {
            //fetch section
            $tmp_section = $Sections->fetch_section(null, $t);
            $sec[] = $tmp_section->name;
        }
        //implode
        $sections = implode("<br>", $sec);
    }
    // print
    print "<tr class='text-top'>";
    print "\t<td><a class='btn btn-sm btn-default' href='" . create_link("tools", "vlan", $domain->id) . "'>{$domain->name}</a></td>";
    print "\t<td>{$domain->description}</td>";
    print "\t<td><span class='text-muted'>{$sections}</span></td>";
    print "\t<td><a href='" . create_link("tools", "vlan", $domain->id) . "'>Show VLANs</a></td>";
    //manage
    if ($User->isadmin === true) {
        print "\t<td class='actions'>";
        print "\t<div class='btn-group'>";
        print "\t\t<button class='btn btn-xs btn-default editVLANdomain' data-action='edit'   data-domainid='{$domain->id}'><i class='fa fa-pencil'></i></button>";
        print "\t\t<button class='btn btn-xs btn-default editVLANdomain' data-action='delete' data-domainid='{$domain->id}'><i class='fa fa-times'></i></button>";
        print "\t</div>";
        print "\t</td>";
    }
    print "\t</td>";
    print "</tr>";
}
?>
</table>
Esempio n. 8
0
                 print "</td>";
             }
         }
     }
 } else {
     print "<tr class='{$class}'>";
     print "<td></td>";
     print "<td></td>";
     print "<td></td>";
 }
 //subnet?
 if ($v->subnetId != null) {
     //section
     $section = $Sections->fetch_section(null, $v->sectionId);
     print " <td><a href='" . create_link("subnets", $section->id, $v->subnetId) . "'>" . $Subnets->transform_to_dotted($v->subnet) . "/{$v->mask}</a></td>";
     print " <td><a href='" . create_link("subnets", $section->id) . "'>{$section->name}</a></td>";
     // actions
     if ($k == 0 && $_GET['page'] == "administration") {
         print "\t<td class='actions'>";
         print "\t<div class='btn-group'>";
         print "\t\t<button class='btn btn-xs btn-default editVLAN' data-action='edit'   data-vlanid='{$v->vlanId}'><i class='fa fa-pencil'></i></button>";
         print "\t\t<button class='btn btn-xs btn-default moveVLAN' \t\t\t\t\t data-vlanid='{$v->vlanId}'><i class='fa fa-external-link'></i></button>";
         print "\t\t<button class='btn btn-xs btn-default editVLAN' data-action='delete' data-vlanid='{$v->vlanId}'><i class='fa fa-times'></i></button>";
         print "\t</div>";
         print "\t</td>";
     } else {
         print "<td></td>";
     }
     print "</tr>";
 } else {
     print "\t<td>/</td>";
Esempio n. 9
0
    header('Location: ' . $ssoBuiltUrl);
    exit;
} else {
    //process the authentication response
    if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) {
        $requestID = $_SESSION['AuthNRequestID'];
    } else {
        $requestID = null;
    }
    // process errors and check for errors
    $auth->processResponse($requestID);
    $errors = $auth->getErrors();
    // check if errors are present
    if (!empty($errors)) {
        $Result->show("danger", implode('<br>', $errors), true);
        exit;
    }
    // is user authenticated
    if (!$auth->isAuthenticated()) {
        $Result->show("danger", "Not authenticated", true);
        exit;
    }
    // try to authenticate in phpipam
    $User->authenticate($auth->getNameId(), '', true);
    // Redirect user where he came from, if unknown go to dashboard.
    if (isset($_COOKIE['phpipamredirect'])) {
        header("Location: " . $_COOKIE['phpipamredirect']);
    } else {
        header("Location: " . create_link("dashboard"));
    }
}
Esempio n. 10
0
    # migrate settings
    $User->migrate_domain_settings();
    $User->migrate_ldap_settings();
    # check for possible errors
    if (sizeof($errors = $Tools->verify_database()) > 0) {
        $esize = sizeof($errors['tableError']) + sizeof($errors['fieldError']);
        print '<div class="alert alert-danger">' . "\n";
        # print table errors
        if (isset($errors['tableError'])) {
            print '<strong>' . _('Missing table') . 's:</strong>' . "\n";
            print '<ul class="fix-table">' . "\n";
            foreach ($errors['tableError'] as $table) {
                print '<li>' . $table . '</li>' . "\n";
            }
            print '</ul>' . "\n";
        }
        # print field errors
        if (isset($errors['fieldError'])) {
            print '<strong>' . _('Missing fields') . ':</strong>' . "\n";
            print '<ul class="fix-field">' . "\n";
            foreach ($errors['fieldError'] as $table => $field) {
                print '<li>Table `' . $table . '`: missing field `' . $field . '`;</li>' . "\n";
            }
            print '</ul>' . "\n";
        }
        print "</div>";
    }
} else {
    # print failure
    $Result->show("danger", _("Failed to upgrade database! <a class='btn btn-sm btn-default' href='" . create_link('administration', "verify-database") . "'>Go to administration and fix</a>"), false);
}
Esempio n. 11
0
</sup></a>
		</li>

		<?php 
}
# check for new version periodically, 1x/week
if ($User->isadmin && strtotime(date("Y-m-d H:i:s")) - strtotime($User->settings->vcheckDate) > 604800) {
    # check for new version
    if (!($version = $Tools->check_latest_phpipam_version())) {
        # we failed, so NW is not ok. update time anyway to avoid future failures
        $Tools->update_phpipam_checktime();
    } else {
        # new version available
        if ($User->settings->version < $version) {
            print "<li>";
            print "\t<a href='" . create_link("administration", "version-check") . "' class='icon-li btn-warning' rel='tooltip' data-placement='bottom' title='" . _('New version available') . "'><i class='fa fa-bullhorn'></i><sup>{$version}</sup></a>";
            print "</li>";
        } else {
            # version ok
            $Tools->update_phpipam_checktime();
        }
    }
}
?>

	</ul>

	</div>	 <!-- end menu div -->
</nav>
</div>
Esempio n. 12
0
    $missingExt[] = "php PEAR support";
}
# if any extension is missing print error and die!
if (sizeof($missingExt) != 1) {
    /* remove dummy 0 line */
    unset($missingExt[0]);
    /* headers */
    $error = "<html>";
    $error .= "<head>";
    $error .= "<base href='{$url}' />";
    $error .= '<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.min.css">';
    $error .= '<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-custom.css">';
    $error .= "</head>";
    $error .= "<body style='margin:0px;'>";
    $error .= '<div class="row header-install" id="header"><div class="col-xs-12">';
    $error .= '<div class="hero-unit" style="padding:20px;margin-bottom:10px;">';
    $error .= '<a href="' . create_link(null, null, null, null, null, true) . '">phpipam requirements error</a>';
    $error .= '</div>';
    $error .= '</div></div>';
    /* error */
    $error .= "<div class='alert alert-danger' style='margin:auto;margin-top:20px;width:500px;'><strong>" . _('The following required PHP extensions are missing') . ":</strong><br><hr>";
    $error .= '<ul>' . "\n";
    foreach ($missingExt as $missing) {
        $error .= '<li>' . $missing . '</li>' . "\n";
    }
    $error .= '</ul><hr>' . "\n";
    $error .= _('Please recompile PHP to include missing extensions and restart Apache.') . "\n";
    $error .= "</body>";
    $error .= "</html>";
    die($error);
}
Esempio n. 13
0
                foreach ($permissions as $key => $p) {
                    # get subnet name
                    $group = getGroupById($key);
                    # parse permissions
                    $perm = parsePermissions($p);
                    print $group['g_name'] . " : " . $perm . "<br>";
                }
            } else {
                print _("All groups: No access");
            }
        }
        print "</td>";
        print '	<td class="actions">' . "\n";
        print "\t<div class='btn-group btn-group-xs'>";
        print "\t\t<button class='btn btn-default editSection' data-action='edit'   data-sectionid='{$section['id']}'><i class='fa fa-pencil'></i></button>";
        print "\t\t<a class='btn btn-default' href='" . create_link("administration", "manageSection", "sectionChangelog", $section['id']) . "'><i class='fa fa-clock-o'></i></a>";
        print "\t\t<button class='btn btn-default editSection' data-action='delete' data-sectionid='{$section['id']}'><i class='fa fa-times'></i></button>";
        print "\t</div>";
        print '	</td>' . "\n";
        print '</tr>' . "\n";
    }
    ?>

</table>	<!-- end table -->

<!-- show no configured -->
<?php 
} else {
    ?>
<div class="alert alert-warn alert-absolute"><?php 
    print _('No sections configured');
Esempio n. 14
0
                        } else {
                            $l['ctype'] = "Subnet";
                        }
                        break;
                    case "section":
                        $l['ctype'] = "Section";
                        break;
                }
                print "<tr>";
                print "\t<td>{$l['real_name']}</td>";
                print "\t<td>{$l['ctype']} / {$l['caction']} {$l['cresult']}</td>";
                # subnet, section or ip address
                if ($l['ctype'] == "IP address") {
                    print "\t<td><a href='" . create_link("subnets", $l['sectionId'], $l['subnetId'], "address-details", $l['tid']) . "'>" . $Subnets->transform_address($l['ip_addr'], "dotted") . "</a></td>";
                } elseif ($l['ctype'] == "Subnet") {
                    print "\t<td><a href='" . create_link("subnets", $l['sectionId'], $l['tid']) . "'>" . $Subnets->transform_address($l['ip_addr'], "dotted") . "/{$l['mask']}</a></td>";
                } elseif ($l['ctype'] == "Folder") {
                    print "\t<td><a href='" . create_link("folder", $l['sectionId'], $l['tid']) . "'>{$l['sDescription']}</a></td>";
                } elseif ($l['ctype'] == "Section") {
                    print "\t<td><a href='" . create_link("subnets", $l['tid']) . "'>{$l['sDescription']}</a></td>";
                }
                print "\t<td>{$l['cdate']}</td>";
                print "\t<td class='hidden-xs'>" . implode("<br>", $diff) . "</td>";
                print "</tr>";
                // next item
                $pc++;
            }
        }
    }
    print "</table>";
}
     }
     $PHP_OUTPUT .= '>';
     $container1 = array();
     $container1['url'] = 'skeleton.php';
     $container1['body'] = 'rankings_alliance_vs_alliance.php';
     $container1['alliance_id'] = $curr_alliance->getAllianceID();
     $PHP_OUTPUT .= create_link($container1, $curr_alliance->getAllianceName());
     //$PHP_OUTPUT.=('.$db->escapeString($curr_alliance->getAllianceName()');
     $PHP_OUTPUT .= '</td>';
 } else {
     $container1 = array();
     $container1['url'] = 'skeleton.php';
     $container1['body'] = 'rankings_alliance_vs_alliance.php';
     $container1['alliance_id'] = 0;
     $PHP_OUTPUT .= '<td width=10% valign="top">';
     $PHP_OUTPUT .= create_link($container1, 'None');
     $PHP_OUTPUT .= '</td>';
 }
 foreach ($alliance_vs as $key => $id) {
     $db2->query('SELECT 1 FROM player WHERE alliance_id = ' . $db2->escapeNumber($id) . ' AND game_id = ' . $db2->escapeNumber($player->getGameID()) . ' LIMIT 1');
     if ($db2->nextRecord() == 0) {
         $out2 = TRUE;
     } else {
         $out2 = FALSE;
     }
     if ($curr_id == $id && $id != 0) {
         if ($out || $out2) {
             $PHP_OUTPUT .= '<td class="red">-';
         } elseif ($id == $player->getAllianceID() || $curr_id == $player->getAllianceID()) {
             $PHP_OUTPUT .= '<td class="bold">-';
         } else {
Esempio n. 16
0
             if ($subnet->isFolder == 1) {
                 print "\t<td><a href='" . create_link("folder", $section['id'], $subnet['id']) . "'>{$subnet['description']}</a></td>";
             } else {
                 print "\t<td><a href='" . create_link("subnets", $section['id'], $subnet['id']) . "'>" . $Subnets->transform_to_dotted($subnet['subnet']) . "/{$subnet['mask']}</a></td>";
             }
             if ($masterSubnet) {
                 print '	<td>/</td>' . "\n";
             } else {
                 $master = (array) $Subnets->fetch_subnet(null, $subnet['masterSubnetId']);
                 # orphaned
                 if (strlen($master['subnet']) == 0) {
                     print "\t<td>" . $Result->show('warning', _('Master subnet does not exist') . "!", false) . "</td>";
                 } elseif ($master['isFolder'] == 1) {
                     print "\t<td><i class='fa fa-folder fa-gray'></i> <a href='" . create_link("folder", $subnet['sectionId'], $subnet['masterSubnetId']) . "'>{$master['description']}</a></td>";
                 } else {
                     print "\t<td><a href='" . create_link("subnets", $subnet['sectionId'], $subnet['masterSubnetId']) . "'>" . $Subnets->transform_to_dotted($master['subnet']) . "/{$master['mask']} ({$master['description']})</a></td>";
                 }
             }
             # allow requests
             if ($subnet['allowRequests'] == 1) {
                 print '<td class="allowRequests requests hidden-xs hidden-sm">' . _('enabled') . '</td>';
             } else {
                 print '<td class="allowRequests hidden-xs hidden-sm"></td>';
             }
             print '</tr>' . "\n";
         }
     }
 } else {
     print '<tr>' . "\n";
     print '<td colspan="8">';
     $Result->show("info", _('No subnets belonging to this VRF') . "!", false);
Esempio n. 17
0
 print '<div class="row-fluid">';
 foreach ($uwidgetschunk as $w) {
     # print itams in a row
     foreach ($w as $c) {
         /* print items */
         $wdet = (array) $widgets[$c];
         if (array_key_exists($c, $widgets)) {
             //reset size if not set
             if (strlen($wdet['wsize']) == 0) {
                 $wdet['wsize'] = 6;
             }
             print "\t<div class='col-xs-12 col-sm-12 col-md-12 col-lg-{$wdet['wsize']} widget-dash' id='w-{$wdet['wfile']}'>";
             print "\t<div class='inner'><i class='fa fa-times remove-widget icon-action fa-gray pull-right'></i>";
             // href?
             if ($wdet['whref'] == "yes") {
                 print "<a href='" . create_link("widgets", $wdet['wfile']) . "'> <h4>" . _($wdet['wtitle']) . "<i class='fa fa-external-link fa-gray pull-right'></i></h4></a>";
             } else {
                 print "<h4>" . _($wdet['wtitle']) . "</h4>";
             }
             print "\t\t<div class='hContent'>";
             print "\t\t\t<div style='text-align:center;padding-top:50px;'><strong>" . _('Loading statistics') . "</strong><br><i class='fa fa-spinner fa-spin'></i></div>";
             print "\t\t</div>";
             print "\t</div>";
             print "\t</div>";
         } else {
             print "\t<div class='col-xs-12 col-sm-12 col-md-12 col-lg-6' id='w-{$c}'>";
             print "\t<div class='inner'>";
             print "\t\t<blockquote style='margin-top:20px;margin-left:20px;'><p>Invalid widget {$c}</p></blockquote>";
             print "\t</div>";
             print "\t</div>";
         }
Esempio n. 18
0
print "\t<th>" . _('Hosts check') . "</th>";
print "\t<th>" . _('Discover') . "</th>";
print "\t<th></th>";
print "</tr>";
//loop
if ($subnets !== false) {
    foreach ($subnets as $subnet) {
        //fetch section
        $section = $Sections->fetch_section(null, $subnet->sectionId);
        //set hosts check
        $status_check = $subnet->pingSubnet == 1 ? "<i class='fa fa-check'></i>" : "";
        //set discovery
        $discovery = $subnet->discoverSubnet == 1 ? "<i class='fa fa-check'></i>" : "";
        # print
        print "<tr>";
        print "\t<td><a href='" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($subnet->subnet) . "/{$subnet->mask}</a></td>";
        print "\t<td>{$subnet->description}</td>";
        print "\t<td>{$section->name} ({$section->description})</td>";
        print "\t<td>{$status_check}</td>";
        print "\t<td>{$discovery}</td>";
        print "\t<td class='actions' style='padding:0px;'>";
        print "\t<div class='btn-group'>";
        print "\t\t<button class='btn btn-xs btn-default editSubnet'     data-action='edit'   data-subnetid='" . $subnet->id . "'  data-sectionid='" . $section->id . "'><i class='fa fa-gray fa-pencil'></i></button>";
        print "\t\t<button class='btn btn-xs btn-default editSubnet'     data-action='delete' data-subnetid='" . $subnet->id . "'  data-sectionid='" . $section->id . "'><i class='fa fa-gray fa-times'></i></button>";
        print "\t</div>";
        print "\t</td>";
        print "</tr>";
    }
} else {
    print "<tr>";
    print "\t<td colspan=6>";
Esempio n. 19
0
 print $Subnets->print_breadcrumbs($Sections, $Subnets, $_GET);
 print "</td>";
 print "</tr>";
 # description
 print "<tr>";
 print "\t<th>" . _('Description') . "</th>";
 print "\t<td>{$prefix->description}</td>";
 print "</tr>";
 # device
 print "<tr>";
 print "\t<th>" . _('Device') . "</th>";
 $device = $Tools->fetch_object("devices", "id", $prefix->deviceId);
 if ($device === false) {
     print "<td>/</td>";
 } else {
     print "\t<td><a href='" . create_link("tools", "devices", $device->id) . "'>{$device->hostname}</a></td>";
 }
 print "</tr>";
 # divider
 print "<tr>";
 print "\t<td colspan='2'><hr></td>";
 print "</tr>";
 print "<tr>";
 print "\t<th>" . _('Range') . ":</th>";
 print "\t<td></td>";
 print "</tr>";
 print "<tr>";
 print "\t<th style='font-weight:normal;'>" . _('Start') . "</th>";
 print "\t<td>{$prefix->prefix}{$prefix->start}</td>";
 print "</tr>";
 print "<tr>";
Esempio n. 20
0
/**
 * Print subnets structure
 */
function printToolsSubnets($subnets, $custom)
{
    $html = array();
    $rootId = 0;
    # root is 0
    # remove all not permitted!
    foreach ($subnets as $k => $s) {
        $permission = checkSubnetPermission($s['id']);
        if ($permission == "0") {
            unset($subnets[$k]);
        }
    }
    if (sizeof($subnets) > 0) {
        foreach ($subnets as $item) {
            $children[$item['masterSubnetId']][] = $item;
        }
    }
    # loop will be false if the root has no children (i.e., an empty menu!)
    $loop = !empty($children[$rootId]);
    # initializing $parent as the root
    $parent = $rootId;
    $parent_stack = array();
    # display selected subnet as opened
    if (isset($_GET['subnetId'])) {
        $allParents = getAllParents($_GET['subnetId']);
    }
    # return table content (tr and td's)
    while ($loop && (($option = each($children[$parent])) || $parent > $rootId)) {
        # repeat
        $repeat = str_repeat(" - ", count($parent_stack));
        # dashes
        if (count($parent_stack) == 0) {
            $dash = "";
        } else {
            $dash = "-";
        }
        if (count($parent_stack) == 0) {
            $margin = "0px";
            $padding = "0px";
        } else {
            # padding
            $padding = "10px";
            # margin
            $margin = count($parent_stack) * 10 - 10;
            $margin = $margin * 2;
            $margin = $margin . "px";
        }
        # count levels
        $count = count($parent_stack) + 1;
        # get subnet details
        # get VLAN
        $vlan = subnetGetVLANdetailsById($option['value']['vlanId']);
        $vlan = $vlan['number'];
        if (empty($vlan) || $vlan == "0") {
            $vlan = "";
        }
        # no VLAN
        # description
        if (strlen($option['value']['description']) == 0) {
            $description = "/";
        } else {
            $description = $option['value']['description'];
        }
        # description
        # requests
        if ($option['value']['allowRequests'] == 1) {
            $requests = "<i class='fa fa-gray fa-check'></i>";
        } else {
            $requests = "";
        }
        # request disabled
        # hosts check
        if ($option['value']['pingSubnet'] == 1) {
            $pCheck = "<i class='fa fa-gray fa-check'></i>";
        } else {
            $pCheck = "";
        }
        # ping check disabled
        # print table line
        if (strlen($option['value']['subnet']) > 0) {
            $html[] = "<tr>";
            # folder
            if ($option['value']['isFolder'] == 1) {
                $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-folder-open'></i> <a href='" . create_link("folder", $option['value']['sectionId'], $option['value']['id']) . "'>{$description}</a></td>";
                $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-sfolder fa-folder-open'></i> {$description}</td>";
            } else {
                if ($count == 1) {
                    $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-folder-open-o'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'>  " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
                    $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-gray fa-folder-open-o'></i> {$description}</td>";
                } else {
                    # last?
                    if (!empty($children[$option['value']['id']])) {
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'>  " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-folder-open-o'></i> {$description}</td>";
                    } else {
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-angle-right'></i><a href='" . create_link("subnets", $option['value']['sectionId'], $option['value']['id']) . "'>  " . transform2long($option['value']['subnet']) . "/" . $option['value']['mask'] . "</a></td>";
                        $html[] = "\t<td class='level{$count}'><span class='structure' style='padding-left:{$padding}; margin-left:{$margin};'></span><i class='fa fa-angle-right'></i> {$description}</td>";
                    }
                }
            }
            //vlan
            $html[] = "\t<td>{$vlan}</td>";
            //masterSubnet
            if ($option['value']['masterSubnetId'] == 0 || empty($option['value']['masterSubnetId'])) {
                $masterSubnet = true;
            } else {
                $masterSubnet = false;
            }
            if ($masterSubnet) {
                $html[] = '	<td>/</td>' . "\n";
            } else {
                $master = getSubnetDetailsById($option['value']['masterSubnetId']);
                if ($master['isFolder']) {
                    $html[] = "\t<td><i class='fa fa-gray fa-folder-open-o'></i> <a href='" . create_link("subnets", $option['value']['sectionId'], $master['id']) . "'>{$master['description']}</a></td>" . "\n";
                } else {
                    $html[] = "\t<td><a href='" . create_link("folder", $option['value']['sectionId'], $master['id']) . "'>" . transform2long($master['subnet']) . '/' . $master['mask'] . '</a></td>' . "\n";
                }
            }
            //used , free
            if ($option['value']['isFolder'] == 1) {
                $html[] = '<td class="hidden-xs hidden-sm"></td>' . "\n";
            } elseif (!$masterSubnet || !subnetContainsSlaves($option['value']['id'])) {
                $ipCount = countIpAddressesBySubnetId($option['value']['id']);
                $calculate = calculateSubnetDetails(gmp_strval($ipCount), $option['value']['mask'], $option['value']['subnet']);
                $html[] = ' <td class="used hidden-xs hidden-sm">' . reformatNumber($calculate['used']) . '/' . reformatNumber($calculate['maxhosts']) . ' (' . reformatNumber($calculate['freehosts_percent']) . ' %)</td>';
            } else {
                $html[] = '<td class="hidden-xs hidden-sm"></td>' . "\n";
            }
            //requests
            $html[] = "\t<td class='hidden-xs hidden-sm'>{$requests}</td>";
            $html[] = "\t<td class='hidden-xs hidden-sm'>{$pCheck}</td>";
            //custom
            if (sizeof($custom) > 0) {
                foreach ($custom as $field) {
                    $html[] = "<td class='hidden-xs hidden-sm hidden-md'>";
                    //booleans
                    if ($field['type'] == "tinyint(1)") {
                        if ($option['value'][$field['name']] == "0") {
                            $html[] = _("No");
                        } elseif ($option['value'][$field['name']] == "1") {
                            $html[] = _("Yes");
                        }
                    } elseif ($field['type'] == "text") {
                        if (strlen($option['value'][$field['name']]) > 0) {
                            $html[] = "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='" . str_replace("\n", "<br>", $option['value'][$field['name']]) . "'>";
                        } else {
                            $html[] = "";
                        }
                    } else {
                        $html[] = $option['value'][$field['name']];
                    }
                    $html[] = "</td>";
                }
            }
            $html[] = "</tr>";
        }
        if ($option === false) {
            $parent = array_pop($parent_stack);
        } elseif (!empty($children[$option['value']['id']])) {
            array_push($parent_stack, $option['value']['masterSubnetId']);
            $parent = $option['value']['id'];
        } else {
        }
    }
    return implode("\n", $html);
}
Esempio n. 21
0
 /**
  * Send mail on new changelog
  *
  * @access public
  * @param mixed $changelog
  * @param int $obj_id
  * @return void
  */
 public function changelog_send_mail($changelog, $obj_id)
 {
     # initialize tools class
     $this->Tools = new Tools($this->Database);
     # set object
     $obj_details = $this->object_action == "add" ? $this->object_new : $this->object_old;
     # change ip_addr
     $this->object_type = str_replace("ip_addr", "address", $this->object_type);
     $this->object_type = str_replace("ip_range", "address range", $this->object_type);
     # folder
     if ($this->object_new['isFolder'] == "1" || $this->object_old['isFolder'] == "1") {
         $this->object_type = "folder";
     }
     # set subject
     if ($this->object_action == "add") {
         $subject = ucwords($this->object_type) . " create notification";
     } elseif ($this->object_action == "edit") {
         $subject = ucwords($this->object_type) . " change notification";
     } elseif ($this->object_action == "delete") {
         $subject = ucwords($this->object_type) . " delete notification";
     }
     // if address we need subnet details !
     if ($this->object_type == "address") {
         $address_subnet = (array) $this->Tools->fetch_object("subnets", "id", $obj_details['subnetId']);
     }
     # set object details
     if ($this->object_type == "section") {
         $details = "<a href='" . $this->createURL() . create_link("subnets", $obj_details['id']) . "'>" . $obj_details['name'] . "(" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "subnet") {
         $details = "<a href='" . $this->createURL() . create_link("subnets", $obj_details['sectionId'], $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['subnet'], "dotted") . "/" . $obj_details['mask'] . " (" . $obj_details['description'] . ") - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "folder") {
         $details = "<a href='" . $this->createURL() . create_link("folder", $obj_details['sectionId'], $obj_details['id']) . "'>" . $obj_details['description'] . " - id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address") {
         $details = "<a href='" . $this->createURL() . create_link("subnets", $address_subnet['sectionId'], $obj_details['subnetId'], "address-details", $obj_details['id']) . "'>" . $this->Subnets->transform_address($obj_details['ip_addr'], "dotted") . " ( hostname " . $obj_details['dns_name'] . ", subnet: " . $this->Subnets->transform_address($address_subnet['subnet'], "dotted") . "/" . $address_subnet['mask'] . ")- id " . $obj_details['id'] . "</a>";
     } elseif ($this->object_type == "address range") {
         $details = $changelog;
     }
     # set content
     $style = "face='Helvetica, Verdana, Arial, sans-serif' style='font-size:13px;'";
     $content[] = "<div style='padding:10px;'>";
     $content[] = "<table>";
     $content[] = "<tr><td><font {$style}>Object type:</font><td><font {$style}>" . $this->object_type . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>Object details:</font><td><font {$style}>" . $details . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>User:</font><td><font {$style}>" . $this->user->real_name . " (" . $this->user->username . ")" . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>Action:</font><td><font {$style}>" . $this->object_action . "</font></td></tr>";
     $content[] = "<tr><td><font {$style}>Date:</font><td><font {$style}>" . date("Y-m-d H:i:s") . "</font></td></tr>";
     $content[] = "<tr><td colspan='2'><hr></td></tr>";
     $content[] = "<tr><td colspan='2'><font {$style}>Changes:<br>";
     $content[] = "<tr><td colspan='2'><font {$style}>&nbsp;<br>";
     $changelog = str_replace("\r\n", "<br>", $changelog);
     $content[] = "{$changelog}</font></td></tr>";
     $content[] = "</table>";
     $content[] = "</div>";
     # set plain content
     $content_plain[] = "Object type: " . $this->object_type;
     $content_plain[] = "Object details: " . $details;
     $content_plain[] = "User: "******" (" . $this->user->username . ")";
     $content_plain[] = "Action: " . $this->object_action;
     $content_plain[] = "Date: " . date("Y-m-d H:i:s");
     $content_plain[] = "\r\n--------------------\r\n";
     $content_plain[] = str_replace("<br>", "\r\n", $changelog);
     # get all admins and check who to end mail to
     $recipients = $this->changelog_mail_get_recipients();
     if ($recipients === false) {
         return true;
     }
     # fetch mailer settings
     $mail_settings = $this->Tools->fetch_object("settingsMail", "id", 1);
     # initialize mailer
     $phpipam_mail = new phpipam_mail($this->settings, $mail_settings);
     $phpipam_mail->initialize_mailer();
     // set content
     $content = $phpipam_mail->generate_message(implode("\r\n", $content));
     $content_plain = implode("\r\n", $content_plain);
     # try to send
     try {
         $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
         foreach ($recipients as $r) {
             $phpipam_mail->Php_mailer->addAddress(addslashes(trim($r->email)));
         }
         $phpipam_mail->Php_mailer->Subject = $subject;
         $phpipam_mail->Php_mailer->msgHTML($content);
         $phpipam_mail->Php_mailer->AltBody = $content_plain;
         //send
         $phpipam_mail->Php_mailer->send();
     } catch (phpmailerException $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     } catch (Exception $e) {
         $this->Result->show("danger", "Mailer Error: " . $e->errorMessage(), true);
     }
     # ok
     return true;
 }
Esempio n. 22
0
<?php

echo "<div class=\"row top-spacer_20\">\n    <div class=\"three columns center\">\n      <a href=\"" . create_link($ip, $polls[0]) . "\" class=\"" . klass($ip, $polls[0]) . "\">" . format_poll_name($polls[0]) . "</a>\n    </div>\n    <div class=\"two columns center\">\n      <a href=\"" . create_link($ip, $polls[1]) . "\" class=\"" . klass($ip, $polls[1]) . "\">" . format_poll_name($polls[1]) . "</a>\n    </div>\n    <div class=\"two columns center\">\n      <a href=\"" . create_link($ip, $polls[2]) . "\" class=\"" . klass($ip, $polls[2]) . "\">" . format_poll_name($polls[2]) . "</a>\n    </div>\n    <div class=\"two columns center\">\n      <a href=\"" . create_link($ip, $polls[3]) . "\" class=\"" . klass($ip, $polls[3]) . "\">" . format_poll_name($polls[3]) . "</a>\n    </div>\n    <div class=\"three columns center\">\n      <a href=\"" . create_link($ip, $polls[4]) . "\" class=\"" . klass($ip, $polls[4]) . "\">" . format_poll_name($polls[4]) . "</a>\n    </div>\n  </div>\n  <div class=\"row\">\n    <div class=\"four columns center\">\n      <a href=\"" . create_link($ip, $polls[5]) . "\" class=\"" . klass($ip, $polls[5]) . "\">" . format_poll_name($polls[5]) . "</a>\n    </div>\n    <div class=\"four columns center\">\n      <a href=\"" . create_link($ip, $polls[6]) . "\" class=\"" . klass($ip, $polls[6]) . "\">" . format_poll_name($polls[6]) . "</a>\n    </div>\n    <div class=\"four columns center\">\n      <a href=\"" . create_link($ip, $polls[7]) . "\" class=\"" . klass($ip, $polls[7]) . "\">" . format_poll_name($polls[7]) . "</a>\n    </div>\n  </div>\n  <div class=\"row\">\n    <div class=\"four columns center\">\n      <a href=\"" . create_link($ip, $polls[8]) . "\" class=\"" . klass($ip, $polls[8]) . "\">" . format_poll_name($polls[8]) . "</a>\n    </div>\n    <div class=\"four columns center\">\n      <a href=\"" . create_link($ip, $polls[9]) . "\" class=\"" . klass($ip, $polls[9]) . "\">" . format_poll_name($polls[9]) . "</a>\n    </div>\n    <div class=\"four columns center\">\n      <a href=\"" . create_link($ip, $polls[10]) . "\" class=\"" . klass($ip, $polls[10]) . "\">" . format_poll_name($polls[10]) . "</a>\n    </div>\n  </div>\n  <div class=\"row\">\n    <div class=\"three columns center\">\n      <a href=\"" . create_link($ip, $polls[11]) . "\" class=\"" . klass($ip, $polls[11]) . "\">" . format_poll_name($polls[11]) . "</a>\n    </div>\n    <div class=\"three columns center\">\n      <a href=\"" . create_link($ip, $polls[12]) . "\" class=\"" . klass($ip, $polls[12]) . "\">" . format_poll_name($polls[12]) . "</a>\n    </div>  \n    <div class=\"three columns center\">\n      <a href=\"" . create_link($ip, $polls[13]) . "\" class=\"" . klass($ip, $polls[13]) . "\">" . format_poll_name($polls[13]) . "</a>\n    </div>\n    <div class=\"three columns center\">\n      <a href=\"" . create_link($ip, $polls[14]) . "\" class=\"" . klass($ip, $polls[14]) . "\">" . format_poll_name($polls[14]) . "</a>\n    </div>\n  </div>\n</div>";
Esempio n. 23
0
 /**
  * This function redirects to install page
  *
  * @access private
  * @return void
  */
 private function redirect_to_install()
 {
     # redirect to install
     header("Location: " . BASE . create_link("install", null, null, null, null, true));
 }
Esempio n. 24
0
		</div>
	</td>
	<td class="submit"></td>
</tr>

</table>
</div>


<div id="requestIPresult"></div>


<!-- back to login page -->
<div class="iprequest" style="text-align:left">
	<a href="<?php 
print create_link("login");
?>
">
		<i class="fa fa-angle-left fa-pad-right"></i> <?php 
print _('Back to login');
?>
	</a>
</div>

</form>
</div>



<?php 
# check for requests guide
Esempio n. 25
0
/* IP changelog */
if ($clogsAddresses) {
    # header
    print "<h4 style='margin-top:30px;'>" . _('Underlying hosts') . " " . _('Changelog') . "</h4><hr>";
    # printout
    print "<table class='table table-striped table-top table-condensed'>";
    # headers
    print "<tr>";
    print "\t<th>" . _('User') . "</th>";
    print "\t<th>" . _('IP') . "</th>";
    print "\t<th>" . _('Action') . "</th>";
    print "\t<th>" . _('Result') . "</th>";
    print "\t<th>" . _('Date') . "</th>";
    print "\t<th>" . _('Change') . "</th>";
    print "</tr>";
    # logs
    foreach ($clogsAddresses as $l) {
        $l = (array) $l;
        # format diff
        $l['cdiff'] = str_replace("\n", "<br>", $l['cdiff']);
        print "<tr>";
        print "\t<td>{$l['real_name']}</td>";
        print "\t<td><a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "address-details", $l['id']) . "'>" . $Subnets->transform_to_dotted($l['ip_addr']) . "</a></td>";
        print "\t<td>" . _("{$l['caction']}") . "</td>";
        print "\t<td>" . _("{$l['cresult']}") . "</td>";
        print "\t<td>{$l['cdate']}</td>";
        print "\t<td>{$l['cdiff']}</td>";
        print "</tr>";
    }
    print "</table>";
}
Esempio n. 26
0
 /**
  * Prints pagination if subnet has multiple pages of IP addresses
  *
  * @access public
  * @param int $page	//current page number
  * @param int $pages	//number of all subpages
  * @return mixed
  */
 public function print_pagination($page, $pages)
 {
     print "<hr>";
     print "<div class='text-right'>";
     print "<ul class='pagination pagination-sm'>";
     //previous - disabled?
     if ($page == 1) {
         print "<li class='disabled'><a href='#'>&laquo;</a></li>";
     } else {
         print "<li>\t\t\t\t<a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page" . ($page - 1)) . "'>&laquo;</a></li>";
     }
     # less than 8
     if ($pages < 8) {
         for ($m = 1; $m <= $pages; $m++) {
             //active?
             if ($page == $m) {
                 print "<li class='active'><a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
             } else {
                 print "<li>\t\t\t\t<a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
             }
         }
     } else {
         //first page
         if ($page <= 3) {
             for ($m = 1; $m <= 5; $m++) {
                 //active?
                 if ($page == $m) {
                     print "<li class='active'><a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
                 } else {
                     print "<li>\t\t\t\t<a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
                 }
             }
             print "<li class='disabled'><a href='#'>...</a></li>";
             print "<li>\t\t\t\t    <a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$pages}") . "'>{$pages}</a></li>";
         } elseif ($page > $pages - 4) {
             print "<li>\t\t\t\t    <a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page1") . "'>1</li>";
             print "<li class='disabled'><a href='#'>...</a></li>";
             for ($m = $pages - 4; $m <= $pages; $m++) {
                 //active?
                 if ($page == $m) {
                     print "<li class='active'><a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
                 } else {
                     print "<li>\t\t\t\t<a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
                 }
             }
         } else {
             print "<li>\t\t\t\t    <a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page1") . "'>1</li>";
             print "<li class='disabled'><a href='#'>...</a></li>";
             for ($m = $page - 1; $m <= $page + 1; $m++) {
                 //active?
                 if ($page == $m) {
                     print "<li class='active'><a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
                 } else {
                     print "<li>\t\t\t\t<a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$m}") . "'>{$m}</a></li>";
                 }
             }
             print "<li class='disabled'><a href='#'>...</a></li>";
             print "<li><a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page{$pages}") . "'>{$pages}</li>";
         }
     }
     //next - disabled?
     if ($page == $pages) {
         print "<li class='disabled'><a href='#'>&raquo;</a></li>";
     } else {
         print "<li>\t\t\t\t  <a href='" . create_link("subnets", $_GET['section'], $_GET['subnetId'], "page" . ($page + 1)) . "'>&raquo;</a></li>";
     }
     print "</ul>";
     print "</div>";
 }
Esempio n. 27
0
$ipcnt = 0;
if (sizeof($addresses) > 0) {
    foreach ($addresses as $ip) {
        # cast
        $ip = (array) $ip;
        # check permission
        $subnet_permission = $Subnets->check_permission($User->user, $ip['subnetId']);
        if ($subnet_permission > 0) {
            # get subnet and section details for belonging IP
            $subnet = (array) $Subnets->fetch_subnet(null, $ip['subnetId']);
            $section = (array) $Sections->fetch_section(null, $subnet['sectionId']);
            # print
            print "<tr>";
            print "\t<td class='ip'><a href='" . create_link("subnets", $section['id'], $subnet['id'], "address-details", $ip['id']) . "'>" . $Subnets->transform_to_dotted($ip['ip_addr']) . "</a></td>";
            print "\t<td class='port'>{$ip['port']}</td>";
            print "\t<td class='subnet'><a href='" . create_link("subnets", $section['id'], $subnet['id']) . "'>{$subnet['ip']}/{$subnet['mask']}</a> <span class='text-muted'>({$subnet['description']})</span></td>";
            print "\t<td class='description'>{$ip['description']}</td>";
            # print info button for hover
            print "<td class='note'>";
            if (!empty($ip['note'])) {
                $ip['note'] = str_replace("\n", "<br>", $ip['note']);
                print "\t<i class='fa fa-comment-o' rel='tooltip' title='{$ip['note']}'></i>";
            }
            print "</td>";
            print "\t<td class='dns hidden-xs'>{$ip['dns_name']}</td>";
            print "\t<td class='owner hidden-xs hidden-sm'>{$ip['owner']}</td>";
            print "</tr>";
            $ipcnt++;
        }
    }
}
Esempio n. 28
0
     }
 } else {
     if ($addresses[$n]->class == "compressed-range") {
         print "<a class='edit_ipaddress   btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Edit IP address details (disabled)') . "'>\t<i class='fa fa-gray fa-pencil'></i></a>";
         print "<a class='\t\t\t\t   btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-cogs'></i></a>";
         print "<a class='\t\t\t\t   btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-search'></i></a>";
         print "<a class='\t\t\t\t   btn btn-xs btn-default disabled' href='#'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-envelope-o'></i></a>";
         print "<a class='delete_ipaddress btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Delete IP address (disabled)') . "'>\t\t\t<i class='fa fa-gray fa-times'></i></a>";
     } else {
         print "<a class='edit_ipaddress   btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Edit IP address details (disabled)') . "'>\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-pencil'></i></a>";
         print "<a class='\t\t\t\t   btn btn-xs btn-default disabled'  data-id='" . $addresses[$n]->id . "' href='#' rel='tooltip' data-container='body' title='" . _('Check avalibility') . "'>\t\t\t\t\t<i class='fa fa-gray fa-cogs'></i></a>";
         print "<a class='search_ipaddress btn btn-xs btn-default         ";
         if (strlen($resolve['name']) == 0) {
             print "disabled";
         }
         print "' href='" . create_link("tools", "search", $resolve['name']) . "' ";
         if (strlen($resolve['name']) != 0) {
             print "rel='tooltip' data-container='body' title='" . _('Search same hostnames in db') . "'";
         }
         print ">\t<i class='fa fa-gray fa-search'></i></a>";
         print "<a class='mail_ipaddress   btn btn-xs btn-default          ' href='#' data-id='" . $addresses[$n]->id . "' rel='tooltip' data-container='body' title='" . _('Send mail notification') . "'>\t\t\t\t<i class='fa fa-gray fa-envelope-o'></i></a>";
         print "<a class='delete_ipaddress btn btn-xs btn-default disabled' rel='tooltip' data-container='body' title='" . _('Delete IP address (disabled)') . "'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-gray fa-times'></i></a>";
     }
 }
 print "\t</div>";
 print "</td>";
 print '</tr>' . "\n";
 /*	if last one return ip address and broadcast IP
  ****************************************************/
 if ($n == $m) {
     if ($User->user->hideFreeRange != 1) {
Esempio n. 29
0
     $subnet = $Subnets->fetch_subnet(null, $change['subnetId']);
     //set section
     $section = $Tools->fetch_object("sections", "id", $subnet->sectionId);
     //ago
     if (is_null($change['lastSeen']) || $change['lastSeen'] == "0000-00-00 00:00:00") {
         $ago = "never";
     } else {
         $timeDiff = time() - strtotime($change['lastSeen']);
         $ago = $change['lastSeen'] . " (" . sec2hms($timeDiff) . " ago)";
     }
     //content
     $content[] = "<tr>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($change['ip_addr']) . "</a></td>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$change['description']}</td>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . " - " . $subnet->description . "</a></td>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id) . "'>{$section->name} {$section->description}</a></td>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$ago}</td>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$oldStatus}</td>";
     $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$newStatus}</td>";
     $content[] = "</tr>";
     //plain content
     $content_plain[] = "\t * " . $Subnets->transform_to_dotted($change['ip_addr']) . " (" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . ")\r\n \t  " . strip_tags($oldStatus) . " => " . strip_tags($newStatus);
 }
 $content[] = "</table>";
 # set content
 $content = $phpipam_mail->generate_message(implode("\r\n", $content));
 $content_plain = implode("\r\n", $content_plain);
 # try to send
 try {
     $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
     //add all admins to CC
    $container = array();
    $container['url'] = 'skeleton.php';
    $container['body'] = 'galactic_post_delete_confirm.php';
    $container['article'] = 'yes';
    transfer('id');
    $PHP_OUTPUT .= create_link($container, '<b>Delete This article</b>');
    $PHP_OUTPUT .= '<br /><br />';
    $db->query('SELECT * FROM galactic_post_paper WHERE game_id = ' . $db->escapeNumber($player->getGameID()));
    $container = array();
    $container['url'] = 'galactic_post_add_article_to_paper.php';
    transfer('id');
    if (!$db->getNumRows()) {
        $PHP_OUTPUT .= 'You have no papers made that you can add an article to.';
        $PHP_OUTPUT .= create_link(create_container('skeleton.php', 'galactic_post_make_paper.php'), '<b>Click Here</b>');
        $PHP_OUTPUT .= 'To make a new one.';
    }
    while ($db->nextRecord()) {
        $paper_title = $db->getField('title');
        $paper_id = $db->getField('paper_id');
        $container['paper_id'] = $paper_id;
        $PHP_OUTPUT .= create_link($container, '<b>Add this article to ' . $paper_title . '!</b>');
        $PHP_OUTPUT .= '<br />';
    }
    $container = array();
    $container['url'] = 'skeleton.php';
    $container['body'] = 'galactic_post_view_article.php';
    $container['news'] = $message;
    transfer('id');
    $PHP_OUTPUT .= '<small><br />note: breaking news is in the news section.<br /></small>';
    $PHP_OUTPUT .= create_link($container, 'Add to Breaking News');
}