public function save(Doctrine_Connection $con = null)
 {
     if ($fileName = $this->getImage()) {
         DNS::resizeImage(80, 80, $fileName, sfConfig::get('sf_upload_dir') . '/avatars/', sfConfig::get('sf_upload_dir') . '/avatars/');
     }
     parent::save($con);
 }
 public function save(Doctrine_Connection $con = null)
 {
     if ($fileName = $this->getImage()) {
         DNS::resizeImage(150, 150, $fileName, sfConfig::get('sf_upload_dir') . '/leerlijn/', sfConfig::get('sf_upload_dir') . '/leerlijn/small/');
         DNS::resizeImage(200, 200, $fileName, sfConfig::get('sf_upload_dir') . '/leerlijn/', sfConfig::get('sf_upload_dir') . '/leerlijn/big/');
     }
     parent::save($con);
 }
 public function save(Doctrine_Connection $con = null)
 {
     if ($fileName = $this->getImage()) {
         DNS::resizeImage(125, 125, $fileName, sfConfig::get('sf_upload_dir') . '/showcase/', sfConfig::get('sf_upload_dir') . '/showcase/125x125/');
         DNS::resizeImage(120, 120, $fileName, sfConfig::get('sf_upload_dir') . '/showcase/', sfConfig::get('sf_upload_dir') . '/showcase/120x120/');
     }
     parent::save($con);
 }
Example #4
0
    $subnet_detailed = $Subnets->get_network_boundaries($subnet['subnet'], $subnet['mask']);
    //set network boundaries
    $slaves = $Subnets->has_slaves($subnet['id']) ? true : false;
    //check if subnet has slaves and set slaves flag true/false
    # fetch all addresses - sorted
    if ($slaves) {
        $addresses = $Addresses->fetch_subnet_addresses_recursive($subnet['id'], false, $sort['field'], $sort['direction']);
        $slave_subnets = (array) $Subnets->fetch_subnet_slaves($subnet['id']);
    } else {
        $addresses = $Addresses->fetch_subnet_addresses($subnet['id'], $sort['field'], $sort['direction']);
    }
    # set permissions
    $subnet_permission = $Subnets->check_permission($User->user, $subnet['id']);
}
# We need DNS object
$DNS = new DNS($Database, $User->settings);
/* verifications */
# checks
if (sizeof($subnet) == 0) {
    $Result->show("danger", _('Subnet does not exist'), true);
}
//subnet doesnt exist
if ($subnet_permission == 0) {
    $Result->show("danger", _('You do not have permission to access this network'), true);
}
//not allowed to access
if (!is_numeric($_REQUEST['subnetId'])) {
    $Result->show("danger", _('Invalid ID'), true);
}
//subnet id must be numeric
/* selected and hidden fields */
    /**
     * @see	\wcf\system\exception\IPrintableException::show()
     */
    public function show()
    {
        // send status code
        @header('HTTP/1.1 503 Service Unavailable');
        // print report
        $e = $this->getPrevious() ?: $this;
        ?>
<!DOCTYPE html>
		<html>
			<head>
				<title>Fatal error: <?php 
        echo htmlspecialchars($this->_getMessage(), ENT_COMPAT, 'UTF-8');
        ?>
</title>
				<meta charset="utf-8" />
				<style>
					.systemException {
						font-family: 'Trebuchet MS', Arial, sans-serif !important;
						font-size: 80% !important;
						text-align: left !important;
						border: 1px solid #036;
						border-radius: 7px;
						background-color: #eee !important;
						overflow: auto !important;
					}
					.systemException h1 {
						font-size: 130% !important;
						font-weight: bold !important;
						line-height: 1.1 !important;
						text-decoration: none !important;
						text-shadow: 0 -1px 0 #003 !important;
						color: #fff !important;
						word-wrap: break-word !important;
						border-bottom: 1px solid #036;
						border-top-right-radius: 6px;
						border-top-left-radius: 6px;
						background-color: #369 !important;
						margin: 0 !important;
						padding: 5px 10px !important;
					}
					.systemException div {
						border-top: 1px solid #fff;
						border-bottom-right-radius: 6px;
						border-bottom-left-radius: 6px;
						padding: 0 10px !important;
					}
					.systemException h2 {
						font-size: 130% !important;
						font-weight: bold !important;
						color: #369 !important;
						text-shadow: 0 1px 0 #fff !important;
						margin: 5px 0 !important;
					}
					.systemException pre, .systemException p {
						text-shadow: none !important;
						color: #555 !important;
						margin: 0 !important;
					}
					.systemException pre {
						font-size: .85em !important;
						font-family: "Courier New" !important;
						text-overflow: ellipsis;
						padding-bottom: 1px;
						overflow: hidden !important;
					}
					.systemException pre:hover{
						text-overflow: clip;
						overflow: auto !important;
					}
				</style>
			</head>
			<body>
				<div class="systemException">
					<h1>Fatal error: <?php 
        if (!$this->getExceptionID()) {
            ?>
Unable to write log file, please make &quot;<?php 
            echo DNS_DIR;
            ?>
/log/&quot; writable!<?php 
        } else {
            echo htmlspecialchars($this->_getMessage(), ENT_COMPAT, 'UTF-8');
        }
        ?>
</h1>
                    
                    <?php 
        if (DNS::debugModeIsEnabled()) {
            ?>
						<div>
							<?php 
            if ($this->getDescription()) {
                ?>
<p><br /><?php 
                echo $this->getDescription();
                ?>
</p><?php 
            }
            ?>
							
							<h2>Information:</h2>
							<p>
								<b>error message:</b> <?php 
            echo htmlspecialchars($this->_getMessage(), ENT_COMPAT, 'UTF-8');
            ?>
<br>
								<b>error code:</b> <?php 
            echo intval($e->getCode());
            ?>
<br>
								<?php 
            echo $this->information;
            ?>
								<b>file:</b> <?php 
            echo htmlspecialchars($e->getFile(), ENT_COMPAT, 'UTF-8');
            ?>
 (<?php 
            echo $e->getLine();
            ?>
)<br>
								<b>php version:</b> <?php 
            echo htmlspecialchars(phpversion(), ENT_COMPAT, 'UTF-8');
            ?>
<br>
								<b>dns version:</b> <?php 
            echo DNS_VERSION;
            ?>
<br>
								<b>date:</b> <?php 
            echo gmdate('r');
            ?>
<br>
								<b>request:</b> <?php 
            if (isset($_SERVER['REQUEST_URI'])) {
                echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_COMPAT, 'UTF-8');
            }
            ?>
<br>
								<b>referer:</b> <?php 
            if (isset($_SERVER['HTTP_REFERER'])) {
                echo htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8');
            }
            ?>
<br>
							</p>
							
							<h2>Stacktrace:</h2>
							<pre><?php 
            echo htmlspecialchars($this->__getTraceAsString(), ENT_COMPAT, 'UTF-8');
            ?>
</pre>
						</div>
                    <?php 
        } else {
            ?>
						<div>
							<h2>Information:</h2>
							<p>
								<?php 
            if (!$this->getExceptionID()) {
                ?>
									Unable to write log file, please make &quot;<?php 
                echo DNS_DIR;
                ?>
/log/&quot; writable!
								<?php 
            } else {
                ?>
									<b>ID:</b> <code><?php 
                echo $this->getExceptionID();
                ?>
</code><br>
									Please send the ID above to the site administrator.
								<?php 
            }
            ?>
							</p>
						</div>
                    <?php 
        }
        ?>
					<?php 
        echo $this->functions;
        ?>
				</div>
			</body>
		</html>
		
		<?php 
    }
Example #6
0
    foreach ($scan_subnets as $sk => $s) {
        if (isset($add_tmp[$s->id])) {
            $scan_subnets[$sk]->discovered = $add_tmp[$s->id];
        }
    }
}
# print change
if ($Scan->debugging) {
    "\nDiscovered addresses:\n----------\n";
    print_r($scan_subnets);
}
# reinitialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Result = new Result();
# insert to database
$discovered = 0;
//for mailing
foreach ($scan_subnets as $s) {
    if (sizeof(@$s->discovered) > 0) {
        foreach ($s->discovered as $ip) {
            // try to resolve hostname
            $tmp = new stdClass();
            $tmp->ip_addr = $ip;
            $hostname = $DNS->resolve_address($tmp, true);
            //set update query
            $values = array("subnetId" => $s->id, "ip_addr" => $Subnets->transform_address($ip, "decimal"), "dns_name" => $hostname['name'], "description" => "-- autodiscovered --", "note" => "This host was autodiscovered on " . date("Y-m-d H:i:s"), "lastSeen" => date("Y-m-d H:i:s"));
            $Admin->object_modify("ipaddresses", "add", "id", $values);
            //set discovered
Example #7
0
# set ping statuses
$statuses = explode(";", $User->settings->pingStatus);
# permissions
$subnet_permission = $Subnets->check_permission($User->user, $subnet['id']);
$section_permission = $Sections->check_permission($User->user, $subnet['sectionId']);
# checks
if (sizeof($subnet) == 0) {
    $Result->show("danger", _('Subnet does not exist'), true);
}
//subnet doesnt exist
if ($subnet_permission == 0) {
    $Result->show("danger", _('You do not have permission to access this network'), true);
}
//not allowed to access
# resolve dns name
$DNS = new DNS($Database);
$resolve = $DNS->resolve_address($address['ip_addr'], $address['dns_name'], false, $subnet['nameserverId']);
# reformat empty fields
$address = $Addresses->reformat_empty_array_fields($address, "<span class='text-muted'>/</span>");
#header
print "<h4>" . _('IP address details') . "</h4><hr>";
# back
print "<a class='btn btn-default btn-sm btn-default' href='" . create_link("subnets", $subnet['sectionId'], $subnet['id']) . "'><i class='fa fa-chevron-left'></i> " . _('Back to subnet') . "</a>";
# check if it exists, otherwise print error
if (sizeof($address) > 1) {
    # table - details
    print "<table class='ipaddress_subnet table table-noborder table-condensed' style='margin-top:10px;'>";
    # ip
    print "<tr>";
    print "\t<th>" . _('IP address') . "</th>";
    print "\t<td><strong>{$address['ip']}</strong></td>";
Example #8
0
# if true it will only update the ones without DNS entry!
$resolve_config['subnets'] = array();
# which subnets to check - by id
# example -> array(1,3,5)	will only update subnets with id 1,3,5
# 	you can get id's and descriptions with following MySQL query:
#	select `id`,`description` from `subnets`;
$resolve_config['verbose'] = true;
# verbose response - prints results, cron will email it to you!
# include required scripts
require dirname(__FILE__) . '/../functions.php';
require dirname(__FILE__) . '/../../functions/classes/class.Thread.php';
# initialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Result = new Result();
// set to 1 in case of errors
ini_set('display_errors', 0);
error_reporting(E_ERROR);
# cli required
if ($resolve_config['clionly'] && !defined('STDIN')) {
    $Result->show_cli("cli only\n", true);
} elseif (!$resolve_config['clionly'] && !defined('STDIN')) {
    $User = new User($Database);
    # verify that user is logged in
    $User->check_user_session();
}
#
# If id is provided via STDIN resolve hosts for 1 subnet only,
# otherwise check all
Example #9
0
    $subnet_detailed = $Subnets->get_network_boundaries($subnet['subnet'], $subnet['mask']);
    //set network boundaries
    $slaves = $Subnets->has_slaves($subnet['id']) ? true : false;
    //check if subnet has slaves and set slaves flag true/false
    # fetch all addresses - sorted
    if ($slaves) {
        $addresses = (array) $Addresses->fetch_subnet_addresses_recursive($subnet['id'], false, $sort['field'], $sort['direction']);
        $slave_subnets = (array) $Subnets->fetch_subnet_slaves($subnet['id']);
    } else {
        $addresses = $Addresses->fetch_subnet_addresses($subnet['id'], $sort['field'], $sort['direction']);
    }
    # set permissions
    $subnet_permission = $Subnets->check_permission($User->user, $subnet['id']);
}
# We need DNS object
$DNS = new DNS($Database, $User->settings);
/* verifications */
# checks
if (sizeof($subnet) == 0) {
    $Result->show("danger", _('Subnet does not exist'), true);
}
//subnet doesnt exist
if ($subnet_permission == 0) {
    $Result->show("danger", _('You do not have permission to access this network'), true);
}
//not allowed to access
if (!is_numeric($_REQUEST['subnetId'])) {
    $Result->show("danger", _('Invalid ID'), true);
}
//subnet id must be numeric
/* selected and hidden fields */
 /**
  * destroy the session
  */
 public function destroy()
 {
     $this->sessionData = array();
     $sql = "DELETE FROM dns_session WHERE sessionID = ?";
     DNS::getDB()->query($sql, array($this->sessionID));
 }
 public function getNameSlug()
 {
     return DNS::slugify($this->getName());
 }
Example #12
0
<?php

/**
 *	Script that resolved hostname from IP address
 */
# include required scripts
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize required objects
$Database = new Database_PDO();
$User = new User($Database);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
# verify that user is logged in
$User->check_user_session();
# fetch subnet
$subnet = $Subnets->fetch_subnet("id", $_POST['subnetId']);
$nsid = $subnet === false ? false : $subnet->nameserverId;
# resolve
$hostname = $DNS->resolve_address($_POST['ipaddress'], false, true, 0);
# print result
print $hostname['name'];
Example #13
0
include "includes/plesk.class.php";
include "includes/dns.class.php";
include "includes/config.inc.php";
// Do not log notices and warnings (imap_open logs notices and warnings on wrong login)
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
if (VERSION != 5) {
    echo "Version mismatch. You need to update your configuration file\n";
    exit;
}
$backup = new Backup(BACKUP_PATH, IGNORE_DB_NAMES, IGNORE_DB_USERS, IGNORE_SITES, DEBUG);
// backup_path is a constant from the config file containing untarred DA backup
$other = new Other(MAIL_FROM_ADDR, MAIL_FROM_NAME, SEND_MAIL, DEBUG);
$mail = new Email(BACKUP_PATH, DEBUG);
// backup_path is all we need, rest is relative
$plesk = new Plesk();
$dns = new DNS(NS_API_DOUPDATE, NS_API_UP, NS_API_DATA, NS_API_URL, unserialize(NS_OUR_CONTROL), IPv4, IPv6, DEBUG);
$arguments = $other->parseArguments($argv);
if (array_key_exists("reseller", $arguments)) {
    $reseller = $arguments['reseller'];
    if (!$plesk->isValidReseller($reseller)) {
        echo "Invalid reseller username given. Exiting...\n";
        exit;
    }
} else {
    $reseller = FALSE;
}
$sp = $plesk->getServicePlans($reseller);
if (array_key_exists("list-serviceplans", $arguments)) {
    foreach ($sp as $plan) {
        echo $plan['id'] . ": " . $plan['name'] . "\n";
    }
Example #14
0
    {
        $xml = $this->getDnsRowList($domain);
        foreach ($xml->data->row as $item) {
            if ($item->name == $subdomain) {
                return $item->ID;
            }
        }
        return 0;
    }
    public function updateSubdomainIp($subdomain, $domain, $ip)
    {
        $rowId = $this->getSubdomainRowId($subdomain, $domain);
        echo "rowId: " . $rowId . "\n";
        $xml = $this->cmd("dns-row-update", array("domain" => $domain, "row_id" => $rowId, "ttl" => self::TTL, "rdata" => $ip));
        print_r($xml);
    }
}
if (isset($argc) && $argc == 2) {
    $ip = $argv[1];
    echo "ip: " . $ip . "\n";
    $dns = new DNS();
    $dns->updateSubdomainIp("pi", "vician.cz", $ip);
} else {
    echo "ERROR: Wrong parameters!\n";
    echo "Usage: ./dns.php ip_addr\n";
}
//$id = $dns->getSubdomainRowId("pi","vician.cz");
//echo "pi.vician.cz: ".$id."\n";
//$dns->getDnsRowList("vician.cz");
//$xml = $dns->cmd("ping");
//print_r($xml);
Example #15
0
        if (isset($add_tmp[$s->id])) {
            $scan_subnets[$sk]->discovered = $add_tmp[$s->id];
        }
    }
}
# print change
if ($Scan->debugging) {
    "\nDiscovered addresses:\n----------\n";
    print_r($scan_subnets);
}
# reinitialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Addresses = new Addresses($Database);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Scan = new Scan($Database);
$Result = new Result();
# insert to database
$discovered = 0;
//for mailing
foreach ($scan_subnets as $s) {
    if (sizeof(@$s->discovered) > 0) {
        foreach ($s->discovered as $ip) {
            // fetch subnet
            $subnet = $Subnets->fetch_subnet("id", $s->id);
            $nsid = $subnet === false ? false : $subnet->nameserverId;
            // try to resolve hostname
            $hostname = $DNS->resolve_address($ip, false, true, $nsid);
            //set update query
            $values = array("subnetId" => $s->id, "ip_addr" => $Subnets->transform_address($ip, "decimal"), "dns_name" => $hostname['name'], "description" => "-- autodiscovered --", "note" => "This host was autodiscovered on " . $nowdate, "lastSeen" => $nowdate, "state" => "2", "action" => "add");
Example #16
0
# set ping statuses
$statuses = explode(";", $User->settings->pingStatus);
# permissions
$subnet_permission = $Subnets->check_permission($User->user, $subnet['id']);
$section_permission = $Sections->check_permission($User->user, $subnet['sectionId']);
# checks
if (sizeof($subnet) == 0) {
    $Result->show("danger", _('Subnet does not exist'), true);
}
//subnet doesnt exist
if ($subnet_permission == 0) {
    $Result->show("danger", _('You do not have permission to access this network'), true);
}
//not allowed to access
# resolve dns name
$DNS = new DNS($Database);
$resolve = $DNS->resolve_address((object) $address);
# reformat empty fields
$address = $Addresses->reformat_empty_array_fields($address, "<span class='text-muted'>/</span>");
#header
print "<h4>" . _('IP address details') . "</h4><hr>";
# back
print "<a class='btn btn-default btn-sm btn-default' href='" . create_link("subnets", $subnet['sectionId'], $subnet['id']) . "'><i class='fa fa-chevron-left'></i> " . _('Back to subnet') . "</a>";
# check if it exists, otherwise print error
if (sizeof($address) > 1) {
    # table - details
    print "<table class='ipaddress_subnet table table-noborder table-condensed' style='margin-top:10px;'>";
    # ip
    print "<tr>";
    print "\t<th>" . _('IP address') . "</th>";
    print "\t<td><strong>{$address['ip']}</strong></td>";
 /**
  * get accessible domains for given user
  *
  * @param	integer	$userID
  * @return	array
  */
 public static function getAccessibleDomains($userID = 0)
 {
     $data = array();
     if ($userID === 0 && self::isLoggedIn()) {
         if (DNS::getSession()->userID !== null) {
             $userID = DNS::getSession()->userID;
         }
         if (self::isAdmin()) {
             $res = DNS::getDB()->query("SELECT * FROM dns_soa");
             while ($row = DNS::getDB()->fetch_array($res)) {
                 $data[] = $row['id'];
             }
             return $data;
         }
     }
     $res = DNS::getDB()->query("SELECT * FROM dns_soa_to_user WHERE userID = ?", array($userID));
     while ($row = DNS::getDB()->fetch_array($res)) {
         $data[] = $row['soaID'];
     }
     return $data;
 }
Example #18
0
<?php

/**
 *	Script that resolved hostname from IP address
 */
# include required scripts
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize required objects
$Database = new Database_PDO();
$User = new User($Database);
$DNS = new DNS($Database);
# verify that user is logged in
$User->check_user_session();
# create object
$address = new StdClass();
$address->ip_addr = $_POST['ipaddress'];
$address->dns_name = null;
# resolve
$hostname = $DNS->resolve_address($address, true);
# print result
print $hostname['name'];