예제 #1
0
 $validFileNames = array();
 for ($i = 1; $i <= $config['upload']['maxFiles']; $i++) {
     // If no file specified, go to the next
     if (!isset($input['files'][$i]['file'])) {
         continue;
     }
     // If invalid, go to the next
     if ($input['files'][$i]['invalid']) {
         continue;
     }
     if (move_uploaded_file($input['files'][$i]['file']['tmpfilename'], $config['paths']['tmp'] . $user['bzid'] . '_' . $input['files'][$i]['file']['filename'])) {
         // Insert into queue
         $data['queue'] = array();
         $data['queue']['bzid'] = $user['bzid'];
         $data['queue']['username'] = $user['username'];
         $data['queue']['ipaddress'] = ip2hex($_SERVER['REMOTE_ADDR']);
         $data['queue']['uploaderfirstname'] = $input['uploaderfirstname'];
         $data['queue']['uploaderlastname'] = $input['uploaderlastname'];
         $data['queue']['uploaderemail'] = $input['uploaderemail'];
         $data['queue']['filename'] = $input['files'][$i]['file']['filename'];
         $data['queue']['filemd5'] = md5_file($config['paths']['tmp'] . $user['bzid'] . '_' . $input['files'][$i]['file']['filename']);
         $data['queue']['authorname'] = $input['files'][$i]['authorname'];
         $data['queue']['licensename'] = @$input['files'][$i]['licensename'];
         $data['queue']['licenseurl'] = @$input['files'][$i]['licenseurl'];
         $data['queue']['licensetext'] = @$input['files'][$i]['licensetext'];
         if (!$qdb->Queue_Insert($data['queue'])) {
             $messages['errors'][] = str_replace('%ID%', $i, $lang['errorMiscUploadError']);
             $input['files'][$i]['invalid'] = true;
         } else {
             $validFileNames[] = $data['queue']['filename'];
         }
            $fsho = long2ip($dsnet + 1);
            $sbc = long2ip($dsnet + $dwsmsk);
            $lsho = long2ip($dsnet + $dwsmsk - 1);
            $nsho += $snoff - 2;
            echo "<tr bgcolor=#{$bg}><th bgcolor=#{$bi}><img src=img/16/{$ntimg} title={$ntit}></th><th>{$s}</th>\n";
            echo "<td class=prp>{$snet}/{$spfix}</td><td class=drd>{$fsho}</td><td class=drd>{$lsho}</td><td class=prp>{$sbc}</td><td align=center class=blu>{$nsho}</td></tr>";
        }
    } elseif ($pfix > $spfix) {
        $snet = long2ip($dip & $dsmsk);
        $dsnet = ip2long($snet);
        $bsnet = ip2bin($snet);
        $hsnet = "0x" . str_pad(ip2hex($snet), 8, 0);
        $sbc = long2ip($dsnet + $dwsmsk);
        $dsbc = ip2long($sbc);
        $bsbc = ip2bin($sbc);
        $hsbc = "0x" . ip2hex($sbc);
        ?>
<h2>Supernet</h2>
<table bgcolor=#666666 <?php 
        echo $tabtag;
        ?>
 >
<tr bgcolor=#<?php 
        echo $bg2;
        ?>
><th width=80>&nbsp;</th><th width=30%>Dotted Decimal</th><th>Binary</th><th>Hexadecimal</th></tr>
<tr bgcolor=#<?php 
        echo $bga;
        ?>
><th bgcolor=#<?php 
        echo $bg2;
예제 #3
0
 /**
  * @dataProvider providerIp2Hex
  * @group ip
  */
 public function testIp2Hex($string, $separator, $result)
 {
     $this->assertSame($result, ip2hex($string, $separator));
 }
예제 #4
0
 $sql .= 'LEFT JOIN `bgpPeers-state` ON `bgpPeers`.bgpPeer_id = `bgpPeers-state`.bgpPeer_id ';
 $sql .= 'WHERE `device_id` = ?';
 foreach (dbFetchRows($sql, array($device['device_id'])) as $peer) {
     // Poll BGP Peer
     $peer_ip = $peer['bgpPeerRemoteAddr'];
     $remote_ip = strstr($peer_ip, ':') ? Net_IPv6::compress($peer_ip) : $peer_ip;
     // Compact IPv6. Used only for log.
     echo "Checking BGP peer: " . $peer_ip . " ";
     if (!strstr($peer_ip, ':') && !$use_cisco_v2) {
         // Common IPv4 BGP4 MIB
         foreach ($bgp_oids as $bgp_oid) {
             ${$bgp_oid} = $bgp_peers[$peer_ip][$bgp_oid];
         }
     } elseif ($use_cisco_v2) {
         // Cisco BGP4 V2 MIB
         $c_index = strstr($peer_ip, ':') ? 'ipv6.' . ip2hex($peer_ip, ':') : 'ipv4.' . $peer_ip;
         foreach ($bgp_oids as $bgp_oid) {
             $c_oid = str_replace(array('bgpPeer', 'Identifier'), array('cbgpPeer2', 'RemoteIdentifier'), $bgp_oid);
             if ($bgp_oid == 'bgpPeerLocalAddr') {
                 $cisco_peers[$c_index][$c_oid] = hex2ip($cisco_peers[$c_index][$c_oid]);
             }
             ${$bgp_oid} = $cisco_peers[$c_index][$c_oid];
         }
     } elseif ($use_vendor) {
         foreach ($bgp_oids as $bgp_oid) {
             $vendor_oid = $vendor_oids[$device['os']][str_replace('bgp', 'vendor_', $bgp_oid)];
             ${$bgp_oid} = $vendor_peers[$peer_ip][$vendor_oid];
         }
         print_debug("Peer: {$peer_ip} (State = {$bgpPeerState} AdminStatus = {$bgpPeerAdminStatus})");
     }
     // FIXME I left the eventlog code for now, as soon as alerts send an entry to the eventlog this can go.
예제 #5
0
파일: User.php 프로젝트: hypnomez/opir.org
 /**
  * User registration
  *
  * @param string 				$email
  * @param bool					$confirmation	If <b>true</b> - default system option is used, if <b>false</b> - registration will be
  *												finished without necessity of confirmation, independently from default system option
  *												(is used for manual registration).
  * @param bool					$auto_sign_in	If <b>false</b> - no auto sign in, if <b>true</b> - according to system configuration
  *
  * @return array|bool|string					<b>exists</b>	- if user with such email is already registered<br>
  * 												<b>error</b>	- if error occurred<br>
  * 												<b>false</b>	- if email is incorrect<br>
  * 												<b>array(<br>
  * 												&nbsp;'reg_key'		=> *,</b>	//Registration confirmation key, or <b>true</b>
  * 																					if confirmation is not required<br>
  * 												&nbsp;<b>'password'	=> *,</b>	//Automatically generated password<br>
  * 												&nbsp;<b>'id'		=> *</b>	//Id of registered user in DB<br>
  * 												<b>)</b>
  */
 function registration($email, $confirmation = true, $auto_sign_in = true)
 {
     $email = mb_strtolower($email);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return false;
     }
     $this->delete_unconfirmed_users();
     if (!Trigger::instance()->run('System/User/registration/before', ['email' => $email])) {
         return false;
     }
     $email_hash = hash('sha224', $email);
     $login = strstr($email, '@', true);
     $login_hash = hash('sha224', $login);
     if ($login && in_array($login, file_get_json(MODULES . '/System/index.json')['profile']) || $this->get_id($login_hash) !== false) {
         $login = $email;
         $login_hash = $email_hash;
     }
     if ($this->db_prime()->qf(["SELECT `id`\n\t\t\tFROM `[prefix]users`\n\t\t\tWHERE `email_hash` = '%s'\n\t\t\tLIMIT 1", $email_hash])) {
         return 'exists';
     }
     $Config = Config::instance();
     $password = password_generate($Config->core['password_min_length'], $Config->core['password_min_strength']);
     $password_hash = hash('sha512', hash('sha512', $password) . Core::instance()->public_key);
     $reg_key = md5($password . $this->ip);
     $confirmation = $confirmation && $Config->core['require_registration_confirmation'];
     if ($this->db_prime()->q("INSERT INTO `[prefix]users` (\n\t\t\t\t`login`,\n\t\t\t\t`login_hash`,\n\t\t\t\t`password_hash`,\n\t\t\t\t`email`,\n\t\t\t\t`email_hash`,\n\t\t\t\t`reg_date`,\n\t\t\t\t`reg_ip`,\n\t\t\t\t`reg_key`,\n\t\t\t\t`status`\n\t\t\t) VALUES (\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s',\n\t\t\t\t'%s'\n\t\t\t)", $login, $login_hash, $password_hash, $email, $email_hash, TIME, ip2hex($this->ip), $reg_key, !$confirmation ? 1 : -1)) {
         $this->reg_id = $this->db_prime()->id();
         if (!$confirmation) {
             $this->set_groups([self::USER_GROUP_ID], $this->reg_id);
         }
         if (!$confirmation && $auto_sign_in && $Config->core['auto_sign_in_after_registration']) {
             $this->add_session($this->reg_id);
         }
         if (!Trigger::instance()->run('System/User/registration/after', ['id' => $this->reg_id])) {
             $this->registration_cancel();
             return false;
         }
         if (!$confirmation) {
             $this->set_groups([self::USER_GROUP_ID], $this->reg_id);
         }
         unset($this->cache->{$login_hash});
         return ['reg_key' => !$confirmation ? true : $reg_key, 'password' => $password, 'id' => $this->reg_id];
     } else {
         return 'error';
     }
 }