Example #1
0
 function output()
 {
     global $db, $vars;
     $q = get('q');
     if (strrpos($q, "#") !== false && intval(substr(strrchr($q, '#'), 1)) != 0) {
         $q = intval(substr(strrchr($q, '#'), 1));
     }
     if (is_numeric($q) && strpos($q, ".") === FALSE) {
         $path = '/nodes';
         $qs = array('node' => $q);
     } elseif ($db->cnt('', 'nodes', "name = '" . $q . "'") == 1) {
         $node = $db->get('id', 'nodes', "name = '" . $q . "'");
         $path = '/nodes';
         $qs = array('node' => $node[0]['id']);
     } elseif (is_ip($q, FALSE)) {
         $path = '/ranges/search';
         $qs = array("form_search_ranges_search" => serialize(array("ip" => $q)));
     } elseif (substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) {
         $path = '/dnszones';
         $qs = array("form_search_dns_search" => serialize(array("dns_zones__name" => $q)));
     } else {
         $path = '/nodes';
         $qs = array("form_search_nodes_search" => serialize(array("nodes__name" => $q)));
     }
     redirect(make_ref($path, $qs));
 }
Example #2
0
 /**
  * @covers ::is_ip
  */
 function test_is_ip()
 {
     $this->assertTrue(is_ip("0.0.0.0"));
     $this->assertFalse(is_ip(""));
     $this->assertFalse(is_ip("1"));
     $this->assertFalse(is_ip("17.17"));
     $this->assertTrue(is_ip("17.17.17.17"));
     $this->assertFalse(is_ip("17.17.17.256"));
     $this->assertTrue(is_ip("fe80:0000:0000:0000:0204:61ff:fe9d:f156"));
 }
Example #3
0
function from_host($content)
{
    $host = preg_replace('/^(www|ftp)\\./i', '', @$_SERVER['HTTP_HOST']);
    if (is_ip($host)) {
        return $content;
    }
    $tokens = explode("@", $content);
    $content = $tokens[0] . "@" . $host . ">";
    return $content;
}
Example #4
0
    function output()
    {
        global $db, $vars;
        $q = get('q');
        $widget = get('widget');
        if (isset($widget) && $widget == "true") {
            $this->tpl['widget'] = "1";
            $this->tpl['url'] = $vars['site']['url'];
            $this->limit = 5;
        } else {
            $this->tpl['widget'] = "0";
        }
        $i = 0;
        if (is_numeric($q) && strpos($q, ".") === FALSE) {
            $this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
										INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
										INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.id LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.id ASC', $this->limit);
            foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
                $this->tpl['nodes_search'][$key]['href'] = make_ref("/nodes", array("node" => $this->tpl['nodes_search'][$key]['id']));
            }
        } elseif (is_ip($q, FALSE)) {
            $where = "(";
            $s_ranges = ip_to_ranges($q, FALSE);
            foreach ($s_ranges as $s_range) {
                $where .= "(ip_ranges.ip_start BETWEEN " . ip2long($s_range['min']) . " AND " . ip2long($s_range['max']) . ") OR ";
            }
            $where = substr($where, 0, -4) . ")";
            $this->tpl['ip_search'] = $db->get('ip_ranges.ip_start, nodes.id', 'ip_ranges
										LEFT JOIN nodes ON ip_ranges.node_id = nodes.id', $where, '', 'ip_ranges.status ASC, ip_ranges.ip_start ASC', $this->limit);
            foreach ((array) $this->tpl['ip_search'] as $key => $value) {
                $this->tpl['ip_search'][$key]['ip_start'] = long2ip($this->tpl['ip_search'][$key]['ip_start']);
                $this->tpl['ip_search'][$key]['href'] = make_ref("/nodes", array("node" => $this->tpl['ip_search'][$key]['id']));
            }
        } elseif (strpos($q, ".") !== FALSE && intval($q) == 0 || substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) {
            $this->tpl['dns_search'] = $db->get('dns_zones.name, dns_zones.type, nodes.id', 'dns_zones
										LEFT JOIN nodes ON dns_zones.node_id = nodes.id', 'dns_zones.name LIKE "' . replace_sql_wildcards(substr($q, 0, strrpos($q, "."))) . '"', '', 'dns_zones.status ASC, dns_zones.name ASC', $this->limit);
            foreach ((array) $this->tpl['dns_search'] as $key => $value) {
                if ($this->tpl['dns_search'][$key]['type'] == "forward") {
                    $this->tpl['dns_search'][$key]['name'] .= "." . $vars['dns']['root_zone'];
                }
                $this->tpl['dns_search'][$key]['href'] = make_ref('/nodes', array("node" => $this->tpl['dns_search'][$key]['id']));
            }
        } else {
            $this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
										INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
										INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.name LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.name ASC', $this->limit);
            foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
                $this->tpl['nodes_search'][$key]['href'] = make_ref('/nodes', array("node" => $this->tpl['nodes_search'][$key]['id']));
            }
        }
        echo template($this->tpl, __FILE__);
        exit;
    }
Example #5
0
function getIP()
{
    $ip = '未知ip';
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        return is_ip($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $ip;
    } else {
        if (!empty($_SERVER['HTTP_X_FORWARD_FOR'])) {
            return is_ip($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $ip;
        } else {
            return is_ip($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : $ip;
        }
    }
}
    function output()
    {
        global $db, $vars;
        $q = get('q');
        $i = 0;
        if (is_numeric($q) && strpos($q, ".") === FALSE) {
            $this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
										INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
										INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.id LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.id ASC', $this->limit);
            foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
                $this->tpl['nodes_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['nodes_search'][$key]['id']));
            }
        } elseif (is_ip($q, FALSE)) {
            $where = '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 1)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 1)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 2)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 2)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 3)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 3)) . ")";
            $this->tpl['ip_search'] = $db->get('ip_ranges.ip_start, nodes.id', 'ip_ranges
										LEFT JOIN nodes ON ip_ranges.node_id = nodes.id', $where, '', 'ip_ranges.status ASC, ip_ranges.ip_start ASC', $this->limit);
            foreach ((array) $this->tpl['ip_search'] as $key => $value) {
                $this->tpl['ip_search'][$key]['ip_start'] = long2ip($this->tpl['ip_search'][$key]['ip_start']);
                $this->tpl['ip_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['ip_search'][$key]['id']));
            }
        } elseif (strpos($q, ".") !== FALSE && intval($q) == 0 || substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) {
            $this->tpl['dns_search'] = $db->get('dns_zones.name, dns_zones.type, nodes.id', 'dns_zones
										LEFT JOIN nodes ON dns_zones.node_id = nodes.id', 'dns_zones.name LIKE "' . replace_sql_wildcards(substr($q, 0, strrpos($q, "."))) . '"', '', 'dns_zones.status ASC, dns_zones.name ASC', $this->limit);
            foreach ((array) $this->tpl['dns_search'] as $key => $value) {
                if ($this->tpl['dns_search'][$key]['type'] == "forward") {
                    $this->tpl['dns_search'][$key]['name'] .= "." . $vars['dns']['root_zone'];
                }
                $this->tpl['dns_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['dns_search'][$key]['id']));
            }
        } else {
            $this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
										INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
										INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.name LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.name ASC', $this->limit);
            foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
                $this->tpl['nodes_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['nodes_search'][$key]['id']));
            }
        }
        echo template($this->tpl, __FILE__);
        exit;
    }
    function table_nameservers()
    {
        global $construct, $db, $vars;
        if (isset($_POST['dns_nameservers__ip'])) {
            $_POST['dns_nameservers__ip'] = is_ip($_POST['dns_nameservers__ip']) ? ip2long($_POST['dns_nameservers__ip']) : '';
        }
        if (isset($_GET['form_search_nameservers_search'])) {
            $t = unserialize(stripslashes($_GET['form_search_nameservers_search']));
            if (isset($t['dns_nameservers__ip'])) {
                $t['dns_nameservers__ip'] = is_ip($t['dns_nameservers__ip']) ? ip2long($t['dns_nameservers__ip']) : '';
            }
            $_GET['form_search_nameservers_search'] = addslashes(serialize($t));
        }
        $form_search_nameservers = $this->form_search_nameservers();
        $where = $form_search_nameservers->db_data_where(array('nodes__name' => 'starts_with'));
        $table_nameservers = new table(array('TABLE_NAME' => 'table_nameservers', 'FORM_NAME' => 'table_nameservers'));
        $table_nameservers->db_data('dns_nameservers.id, dns_nameservers.name, nodes.name_ns, dns_nameservers.ip, dns_nameservers.date_in, dns_nameservers.status', 'dns_nameservers
			LEFT JOIN nodes ON dns_nameservers.node_id = nodes.id', $where, "", "dns_nameservers.date_in DESC, dns_nameservers.status ASC");
        $table_nameservers->db_data_search($form_search_nameservers);
        foreach ((array) $table_nameservers->data as $key => $value) {
            if ($key != 0) {
                $table_nameservers->data[$key]['ip'] = long2ip($table_nameservers->data[$key]['ip']);
                $table_nameservers->data[$key]['name'] = strtolower(($table_nameservers->data[$key]['name'] != '' ? $table_nameservers->data[$key]['name'] . "." : "") . $table_nameservers->data[$key]['name_ns'] . "." . $vars['dns']['ns_zone']);
            }
        }
        $table_nameservers->db_data_multichoice('dns_nameservers', 'id');
        for ($i = 1; $i < count($table_nameservers->data); $i++) {
            if (isset($table_nameservers->data[$i])) {
                $table_nameservers->info['EDIT'][$i] = make_ref('/hostmaster/dnsnameserver', array("nameserver" => $table_nameservers->data[$i]['id']));
            }
        }
        $table_nameservers->info['EDIT_COLUMN'] = 'name';
        $table_nameservers->info['MULTICHOICE_LABEL'] = 'delete';
        $table_nameservers->db_data_remove('id', 'name_ns');
        $table_nameservers->db_data_translate('dns_nameservers__status');
        return $table_nameservers;
    }
Example #8
0
 /**
  * Attempt a connection to mail server
  *
  * @return mixed  $_retVal   Boolean indicating success or failure on connection
  */
 function _server_connect()
 {
     // Default return value
     $_retVal = true;
     // We have to make sure the HOST given is valid
     // This is done here because '@fsockopen' will not give me this
     // information if it failes to connect because it can't find the HOST
     $host = $this->getHost();
     $host = preg_replace('@tcp://@i', '', $host);
     // Remove prefix
     $host = preg_replace('@ssl://@i', '', $host);
     // Remove prefix
     // DOL_CHANGE LDR
     include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     if (!is_ip($host) && gethostbyname($host) == $host) {
         $this->_setErr(99, $host . ' is either offline or is an invalid host name.');
         $_retVal = false;
     } else {
         //See if we can connect to the SMTP server
         if ($this->socket = @fsockopen($this->getHost(), $this->getPort(), $this->errno, $this->errstr, $this->_smtpTimeout)) {
             // Fix from PHP SMTP class by 'Chris Ryan'
             // Sometimes the SMTP server takes a little longer to respond
             // so we will give it a longer timeout for the first read
             // Windows still does not have support for this timeout function
             if (function_exists('stream_set_timeout')) {
                 stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
             }
             // Check response from Server
             if ($_retVal = $this->server_parse($this->socket, "220")) {
                 $_retVal = $this->socket;
             }
         } else {
             // DOL_CHANGE LDR
             if (empty($this->errstr)) {
                 $this->errstr = 'Failed to connect with fsockopen host=' . $this->getHost() . ' port=' . $this->getPort();
             }
             $this->_setErr($this->errno, $this->errstr);
             $_retVal = false;
         }
     }
     return $_retVal;
 }
Example #9
0
 /**
  * Binds the session (cookie) to the passed Domain.
  *
  * @param string $mode   The runtimeEnvironment. Can be "domain" (uses the full domain) or "subdomain" uses (.subdomain.tld)
  * @param string $domain The domain to set
  *
  * @author Benjamin Carl <*****@*****.**>
  */
 public function bindToDomain($mode = self::DEFAULT_BIND_DOMAIN_MODE, $domain = null)
 {
     // if no domain passed through - get the previously stored one
     if (!$domain) {
         $domain = $this->getDomain();
     }
     // All advanced features only available for named hosts - no ip!
     if (!is_ip($domain)) {
         switch (strtolower($mode)) {
             case 'subdomain':
                 $domain = '.' . $this->getDotParts($domain, 2, 'rtl');
                 break;
         }
     }
     // store
     $this->setDomain($domain);
 }
	public function listRecords()
	{
                JToolBarHelper::title('<img src="'. JURI::root() . 'administrator/components/com_breezingforms/libraries/jquery/themes/easymode/i/logo-breezingforms.png'.'" align="top"/>');
		JToolBarHelper::custom('exportPdf',    'ff_download',             'ff_download_f2',             BFText::_('COM_BREEZINGFORMS_PDF'),    false);
		JToolBarHelper::custom('exportCsv',    'ff_download',             'ff_download_f2',             BFText::_('COM_BREEZINGFORMS_CSV'),    false);
		JToolBarHelper::custom('exportXml',    'ff_download',             'ff_download_f2',             BFText::_('COM_BREEZINGFORMS_XML'),    false);
		JToolBarHelper::custom('remove',    'delete.png',       'delete_f2.png',    BFText::_('COM_BREEZINGFORMS_TOOLBAR_DELETE'),    false);
		JToolBarHelper::custom('all',    'ff_switch',             'ff_switch_f2',             BFText::_('COM_BREEZINGFORMS_ALL'),    false);
		JToolBarHelper::custom('viewed',    'ff_switch',             'ff_switch_f2',             BFText::_('COM_BREEZINGFORMS_TOOLBAR_VIEWED'),    false);
		JToolBarHelper::custom('exported',  'ff_switch',             'ff_switch_f2',             BFText::_('COM_BREEZINGFORMS_TOOLBAR_EXPORTED'),  false);
		JToolBarHelper::custom('archived',  'ff_switch',             'ff_switch_f2',             BFText::_('COM_BREEZINGFORMS_TOOLBAR_ARCHIVED'),  false);

		JFactory::getDocument()->addStyleDeclaration(
			'

			.icon-32-ff_switch {
				background-image:url(components/com_breezingforms/images/icons/switch.png);
			}

			.icon-32-ff_switch_f2 {
				background-image:url(components/com_breezingforms/images/icons/switch_f2.png);
			}

			.icon-32-ff_download {
				background-image:url(components/com_breezingforms/images/icons/download.png);
			}

			.icon-32-ff_download_f2 {
				background-image:url(components/com_breezingforms/images/icons/download_f2.png);
			}

			'
		);

		//print_r($_REQUEST);
		$ids = JRequest::getVar('ids', array());
		$offset = JRequest::getInt('limitstart', 0);
		$limit  = JRequest::getInt('mylimit', 20);

		if(JRequest::getVar('task','') == 'all')
		{
			JFactory::getSession()->set('bfStatus', '');
		}
		else if(JRequest::getVar('task','')=='exported')
		{
			JFactory::getSession()->set('bfStatus', 'exported');
		}
		else if(JRequest::getVar('task','')=='archived')
		{
			JFactory::getSession()->set('bfStatus', 'archived');
		}
		else if(JRequest::getVar('task','')=='viewed')
		{
			JFactory::getSession()->set('bfStatus', 'viewed');
		}
		else if(JRequest::getVar('task','')=='remove')
		{
			$size = count($ids);
			for($i = 0; $i < $size; $i++)
			{
				$this->db->setQuery("Delete From #__facileforms_records Where id = " . $this->db->Quote($ids[$i]));
				$this->db->query();
				$this->db->setQuery("Delete From #__facileforms_subrecords Where record = " . $this->db->Quote($ids[$i]));
				$this->db->query();
				//echo $this->db->getQuery() . '<br/>';
			}
		}
		else if(JRequest::getVar('task','')=='save')
		{
			$id = JRequest::getInt('record_id', 0);
			$updates = JRequest::getVar('update', array());
			foreach($updates As $update)
			{
				$this->db->setQuery("Update #__facileforms_subrecords Set value = ".$this->db->Quote(JRequest::getVar('ff_nm_'.$update,''))." Where name = ".$this->db->Quote($update)." And record = " . $id);
				$this->db->query();
			}
		}
		else if(JRequest::getVar('task','')=='exportXml' && JRequest::getInt('exportt',0) == 1)
		{
			$this->expxml($ids);
		}
		else if(JRequest::getVar('task','')=='exportCsv' && JRequest::getInt('exportt',0) == 1)
		{
			$this->expcsv($ids);
		}
		else if(JRequest::getVar('task','')=='exportPdf' && JRequest::getInt('exportt',0) == 1)
		{
			$this->exppdf($ids);
		}

		if(JRequest::getInt('status_update',0) == 1)
		{
			$offset = 0;
			$limit = 20;
			JRequest::setVar('limitstart', 0);
			JRequest::setVar('mylimit', 20);
		}

		if(JRequest::getInt('id', 0) != '' && JRequest::getInt('viewed', -1) != -1)
		{
			$value = 1;
			if(JRequest::getInt('viewed', -1) == 1)
			{
				$value = 0;
			}
			$this->db->setQuery("Update #__facileforms_records Set viewed = ".$value." Where id = " . JRequest::getInt('id', 0));
			$this->db->query();
		}

		if(JRequest::getInt('id', 0) != '' && JRequest::getInt('exported', -1) != -1)
		{
			$value = 1;
			if(JRequest::getInt('exported', -1) == 1)
			{
				$value = 0;
			}
			$this->db->setQuery("Update #__facileforms_records Set exported = ".$value." Where id = " . JRequest::getInt('id', 0));
			$this->db->query();
		}

		if(JRequest::getInt('id', 0) != '' && JRequest::getInt('archived', -1) != -1)
		{
			$value = 1;
			if(JRequest::getInt('archived', -1) == 1)
			{
				$value = 0;
			}
			$this->db->setQuery("Update #__facileforms_records Set archived = ".$value." Where id = " . JRequest::getInt('id', 0));
			$this->db->query();
		}

		if(JRequest::getInt('status_update',0) == 1 && JRequest::getVar('write_status','') != '')
		{
			$in = '';

			if(is_array($ids) && count($ids) != 0)
			{
				$status = '';
				if(JFactory::getSession()->get('bfStatus', '') == 'exported')
				{
					$status = "exported = ".(JRequest::getVar('write_status','') == 'set' ? 1 : 0);
				}
				else
				if(JFactory::getSession()->get('bfStatus', '') == 'archived')
				{
					$status = "archived = ".(JRequest::getVar('write_status','') == 'set' ? 1 : 0);
				}
				else
				if(JFactory::getSession()->get('bfStatus', '') == 'viewed')
				{
					$status = "viewed = ".(JRequest::getVar('write_status','') == 'set' ? 1 : 0);
				}

				if($status != '' )
				{
					$size = count($ids);
					for($i = 0; $i < $size; $i++)
					{
						$this->db->setQuery("Update #__facileforms_records Set $status Where id = " . $this->db->Quote($ids[$i]));
						$this->db->query();
						//echo $this->db->getQuery() . '<br/>';
					}
				}
			}
		}

		$ands = '';
		$subs = '';

		if(JRequest::getVar('search','') != '')
		{
			//echo JRequest::getVar('txtsearch','false');
			if(JRequest::getVar('txtsearch','false')=='true')
			{
				$subs .= ', #__facileforms_subrecords As subrecord';
				$ands .= 'subrecord.value Like ' . $this->db->Quote('%'.JRequest::getVar('search','').'%') . ' And record.id = subrecord.record And ';
			}

			$headerSearch = '';
			if(is_numeric(JRequest::getVar('search','')))
			{
				$headerSearch .= 'record.id = ' . intval(JRequest::getVar('search','')) . ' Or ';
			}

			$ex = explode('-', JRequest::getVar('search',''));
			//print_r($ex);
			if(count($ex) == 3 && checkdate($ex[1], $ex[2], $ex[0]))
			{
				$headerSearch .= "record.submitted Between '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 00:00:00' And '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 23:59:59' Or ";
				$headerSearch .= "record.paypal_payment_date Between '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 00:00:00' And '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 23:59:59' Or ";
			}

			if(is_ip(JRequest::getVar('search','')))
			{
				$headerSearch .= 'record.ip = ' . $this->db->Quote(JRequest::getVar('search','')) . ' Or ';
			}

			if(substr(trim(JRequest::getVar('search','')), 0,4) == 'tx: ')
			{
				$text = trim(JRequest::getVar('search',''));
				$text = substr($text, 3,strlen($text));
				$headerSearch .= 'record.paypal_tx_id Like ' . $this->db->Quote('%'.$text) . ' Or ';
			}

			if($headerSearch == '' && JRequest::getVar('txtsearch','false')!='true')
			{
				$headerSearch .= 'record.`name` Like ' . $this->db->Quote('%'.trim(JRequest::getVar('search','')).'%') . ' Or ';
			}

			if($headerSearch != '')
			{
				$headerSearch = substr($headerSearch,0,strlen($headerSearch)-4);
				$ands .= "(".$headerSearch.") And ";
			}
		}

		if(JRequest::getInt('form',0) != 0)
		{
			$ands .= 'record.form = ' . $this->db->Quote(JRequest::getInt('form',0)) . ' And ';
		}

		if(JFactory::getSession()->get('bfStatus', '') == 'exported')
		{
			$ands .= "record.exported = 1 And";
		}
		else
		if(JFactory::getSession()->get('bfStatus', '') == 'archived')
		{
			$ands .= "record.archived = 1 And";
		}
		else
		if(JFactory::getSession()->get('bfStatus', '') == 'viewed')
		{
			$ands .= "record.viewed = 1 And";
		}

		if($ands != '')
		{
			$ands = 'Where ' . substr($ands,0,strlen($ands)-4);
		}

		$limiter = " Limit $offset, $limit";
		if($limit == 0)
		{
			$limiter = '';
		}

		$this->db->setQuery("Select Distinct SQL_CALC_FOUND_ROWS record.* From #__facileforms_records As record $subs $ands Order By record.".JRequest::getWord('orderBy','submitted')." ".(JRequest::getWord('order','DESC') == 'DESC' ? 'ASC' : 'DESC').$limiter);
		$rows = $this->db->loadObjectList();
                
		//echo $this->db->getQuery();
		$this->db->setQuery("SELECT FOUND_ROWS();");
		$foundRows = $this->db->loadResult();
                jimport('joomla.html.pagination');
		$pagination = new JPagination($foundRows, $offset, $limit);

		$this->db->setQuery("Select Distinct form As id, `name`, title From #__facileforms_records Order By title");
		$forms = $this->db->loadObjectList();
		$size = count($forms);
		$formsArray = array();
		for($i = 0;$i < $size;$i++)
		{
			if(!isset($formsArray['_'.$forms[$i]->id])){
				$formsArray['_'.$forms[$i]->id] = $forms[$i];
			}
		}

                $forms = $formsArray;
                ?>
<script type="text/javascript">
var bf_submitbutton = function(pressbutton)
			{
				var form = document.adminForm;
				switch (pressbutton) {
					case 'remove':
					case 'exportCsv':
					case 'exportXls':
					case 'exportPdf':
					case 'exportXml':
						if (form.boxchecked.value==0) {
							alert("<?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_PLSSELECTRECS'); ?>");
							return;
						} // if
						form.exportt.value = 1;
						break;
					case 'viewed':
					case 'exported':
					case 'archived':
						var writeStatus = false;
						for(var i = 0; i < form.write_status.length; i++)
						{
							if(form.write_status[i].checked && (form.write_status[i].value == 'set' || form.write_status[i].value == 'unset'))
							{
								writeStatus = true;
								break;
							}
						}
						if (writeStatus && form.boxchecked.value==0) {
							alert("<?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_PLSSELECTRECS'); ?>");
							return;
						} // if
						form.status_update.value = 1;
						break;
					default:
						break;
				} // switch
				switch (pressbutton) {
					case 'remove':
						if (!confirm("<?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_ASKDELETE'); ?>")) return;
						break;
					default:
						break;
				} // switch
				submitform(pressbutton);
				form.exportt.value = 0;
}; // submitbutton

if(typeof Joomla != "undefined"){
    Joomla.submitbutton = bf_submitbutton;
}else{
    submitbutton = bf_submitbutton;
}

function bf_listItemTask( id, task )
{
	var f = document.adminForm;
	cb = eval( 'f.' + id );
	if (cb) {
		for (i = 0; true; i++) {
			cbx = eval('f.cb'+i);
			if (!cbx) break;
				cbx.checked = false;
			} // for
			cb.checked = true;
			f.boxchecked.value = 1;
			submitbutton(task);
		}
	return false;
} // listItemTask
</script>

<form action="index.php" method="post" name="adminForm">
<div id="editcell">

    <table class="adminlist">
    <thead>
    	<tr>
    		<td valign="top" colspan="1000">
    			<table class="adminlist" width="100%">
    				<thead>
	    			<tr>
	    				<td>
			    			<?php echo BFText::_('COM_BREEZINGFORMS_FILTER'); ?>:
			    			<input type="text" name="search" value="<?php echo htmlentities(JRequest::getVar('search',''),ENT_QUOTES, 'UTF-8'); ?>" onchange="form.status_update.value = 1;document.adminForm.submit()"/>
			    			<?php echo BFText::_('COM_BREEZINGFORMS_TEXT'); ?>: <input type="checkbox" name="txtsearch" onclick="form.status_update.value = 1;document.adminForm.submit()" value="true"<?php echo JRequest::getWord('txtsearch','false') == 'true' ? ' checked="checked"' : ''; ?>/>
			    			<select name="form" onchange="form.status_update.value = 1;document.adminForm.submit()">
			    				<option value=""><?php echo BFText::_('COM_BREEZINGFORMS_ALL'); ?></option>
			    				<?php
								foreach($forms As $form)
								{
									if(trim($form->name) != '')
									{
										echo '<option value="'.$form->id.'"'.(JRequest::getInt('form',0) == $form->id ? ' selected="selected"' : '').'>'.htmlentities($form->title, ENT_QUOTES, 'UTF-8').' ('.htmlentities($form->name, ENT_QUOTES, 'UTF-8').')</option>'."\n";
									}
								}
			    				?>
			    			</select>
						</td>
						<td align="right" valign="top">
			    			<?php echo BFText::_('COM_BREEZINGFORMS_WRITE_STATUS'); ?>: <input type="radio" name="write_status" value=""<?php echo JRequest::getVar('write_status','') == '' ? ' checked="checked"' : ''; ?>/>  <?php echo BFText::_('COM_BREEZINGFORMS_NONE'); ?> <input type="radio" name="write_status" value="unset"<?php echo JRequest::getVar('write_status','') == 'unset' ? ' checked="checked"' : ''; ?>/> <?php echo BFText::_('COM_BREEZINGFORMS_UNSET'); ?> <input type="radio" name="write_status" value="set"<?php echo JRequest::getVar('write_status','') == 'set' ? ' checked="checked"' : ''; ?>/> <?php echo BFText::_('COM_BREEZINGFORMS_SET'); ?>
			    		</td>
					</tr>
					</thead>
				</table>
    		</td>
    	</tr>
        <tr>
        	<th nowrap align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=id"><?php echo BFText::_('COM_BREEZINGFORMS_ID'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=submitted"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_SUBMITTED'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=ip"><?php echo BFText::_('COM_BREEZINGFORMS_IP'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=provider"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_PROVIDER'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=title"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_TITLE'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=name"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_NAME'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=paypal_tx_id"><?php echo BFText::_('COM_BREEZINGFORMS_PAYMENT_TX_ID'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=paypal_payment_date"><?php echo BFText::_('COM_BREEZINGFORMS_PAYMENT_TX_DATE'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=paypal_testaccount"><?php echo BFText::_('COM_BREEZINGFORMS_PAYMENT_TESTACCOUNT'); ?></a>
            </th>
            <th>
                <a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;order=<?php echo JRequest::getVar('order', 'DESC') == 'DESC' ? 'ASC' : 'DESC'; ?>&amp;orderBy=paypal_download_tries"><?php echo BFText::_('COM_BREEZINGFORMS_PAYMENT_DOWNLOAD_TRIES'); ?></a>
            </th>
            <th nowrap align="center"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_VIEWED'); ?></th>
			<th nowrap align="center"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_EXPORTED'); ?></th>
			<th nowrap align="center"><?php echo BFText::_('COM_BREEZINGFORMS_RECORDS_ARCHIVED'); ?></th>
        </tr>
    </thead>
    <?php
    $k = 0;
    $cnt = count( $rows );
    for ($i=0; $i < $cnt; $i++)
    {
        $row = $rows[$i];
        if ($row->viewed) $view_src = "components/com_breezingforms/images/icons/publish_g.png"; else $view_src = "components/com_breezingforms/images/icons/publish_x.png";
		if ($row->exported) $exp_src = "components/com_breezingforms/images/icons/publish_g.png"; else $exp_src = "components/com_breezingforms/images/icons/publish_x.png";
		if ($row->archived) $arch_src = "components/com_breezingforms/images/icons/publish_g.png"; else $arch_src = "components/com_breezingforms/images/icons/publish_x.png";
        ?>
        <tr class="<?php echo "row$k"; ?>">
            <td nowrap align="center"><input type="checkbox" id="cb<?php echo $i; ?>" name="ids[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
			<td nowrap align="left"><a href="#" onclick="return listItemTask('cb<?php echo $i; ?>','edit')"><?php echo $row->id; ?></a></td>
			<td nowrap align="left"><a href="#" onclick="return listItemTask('cb<?php echo $i; ?>','edit')"><?php echo $row->submitted; ?></a></td>
			<td nowrap align="left"><?php echo $row->ip; ?></td>
			<td nowrap align="left"><?php echo $row->provider; ?></td>
			<td nowrap align="left"><?php echo $row->title; ?></td>
			<td nowrap align="left"><?php echo $row->name; ?></td>
			<td nowrap align="left"><?php echo $row->paypal_tx_id; ?></td>
			<td nowrap align="left"><?php echo $row->paypal_payment_date; ?></td>
			<td nowrap align="left"><?php echo $row->paypal_testaccount ? BFText::_('COM_BREEZINGFORMS_YES') : BFText::_('COM_BREEZINGFORMS_NO'); ?></td>
			<td nowrap align="left"><?php echo $row->paypal_download_tries; ?></td>
			<td nowrap align="center"><a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;id=<?php echo $row->id ?>&amp;viewed=<?php echo $row->viewed ?>&amp;order=<?php echo JRequest::getWord('order','DESC') ?>&amp;orderBy=<?php echo JRequest::getWord('orderBy','submitted') ?>"><img src="<?php echo $view_src; ?>" alt="+" border="0" /></a></td>
			<td nowrap align="center"><a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;id=<?php echo $row->id ?>&amp;exported=<?php echo $row->exported ?>&amp;order=<?php echo JRequest::getWord('order','DESC') ?>&amp;orderBy=<?php echo JRequest::getWord('orderBy','submitted') ?>"><img src="<?php echo $exp_src; ?>" alt="+" border="0" /></a></td>
			<td nowrap align="center"><a href="index.php?option=com_breezingforms&amp;act=recordmanagement&amp;txtsearch=<?php echo JRequest::getWord('txtsearch','false'); ?>&amp;search=<?php echo htmlentities(JRequest::getVar('search',''), ENT_QUOTES, 'UTF-8'); ?>&amp;form=<?php echo htmlentities(JRequest::getVar('form',''), ENT_QUOTES, 'UTF-8'); ?>&amp;task=<?php echo JRequest::getVar('task',''); ?>&amp;limitstart=<?php echo JRequest::getInt('limitstart',0); ?>&amp;mylimit=<?php echo JRequest::getInt('mylimit',20); ?>&amp;id=<?php echo $row->id ?>&amp;archived=<?php echo $row->archived ?>&amp;order=<?php echo JRequest::getWord('order','DESC') ?>&amp;orderBy=<?php echo JRequest::getWord('orderBy','submitted') ?>"><img src="<?php echo $arch_src; ?>" alt="+" border="0" /></a></td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </table>
</div>

<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="option" value="com_breezingforms" />
<input type="hidden" id="task" name="task" value="<?php echo JRequest::getVar('task',''); ?>" />
<input type="hidden" name="act" value="recordmanagement" />
<input type="hidden" name="status_update" value="0" />
<input type="hidden" name="order" value="<?php echo JRequest::getWord('order','DESC') ?>" />
<input type="hidden" name="orderBy" value="<?php echo JRequest::getWord('orderBy','submitted') ?>" />
<input type="hidden" id="limitstart" name="limitstart" value="<?php echo JRequest::getInt('limitstart',0); ?>" />
<input type="hidden" id="mylimit" name="mylimit" value="<?php echo JRequest::getInt('mylimit',20); ?>" />
<input type="hidden" id="exportt" name="exportt" value="0" />

</form>

<table class="adminlist">
	<tfoot>
    	<tr>
    		<td colspan="14">
    			<form action="#">
    				<?php echo $pagination->getListFooter() ?>
    			</form>
    		</td>
    	</tr>
	</tfoot>
</table>

<script>
// fixing limit, since it seems not to be available through JRequest or even $_POST/$_GET/$_REQUEST
document.getElementById('limit').onchange =
function(){
	document.getElementById('mylimit').value = document.getElementById('limit').options[document.getElementById('limit').selectedIndex].value;
	document.adminForm.submit();
};
</script>

<?php
	}
Example #11
0
function generate_host_regex($string = '', $divider = '/')
{
    if (!is_string($string)) {
        return '';
    }
    if (mb_strpos($string, '.') === FALSE) {
        return generate_glob_regex($string, $divider);
    }
    $result = '';
    if (is_ip($string)) {
        // IPv4
        return generate_glob_regex($string, $divider);
    } else {
        // FQDN or something
        $part = explode('.', $string, 2);
        if ($part[0] == '') {
            $part[0] = '(?:.*\\.)?';
            // And all related FQDN
        } else {
            if ($part[0] == '*') {
                $part[0] = '.*\\.';
                // All subdomains/hosts only
            } else {
                return generate_glob_regex($string, $divider);
            }
        }
        $part[1] = generate_glob_regex($part[1], $divider);
        return implode('', $part);
    }
}
Example #12
0
function whois_responsibility($fqdn = 'foo.bar.example.com', $parent = FALSE, $implicit = TRUE)
{
    static $domain;
    if ($fqdn === NULL) {
        $domain = NULL;
        // Unset
        return '';
    }
    if (!is_string($fqdn)) {
        return '';
    }
    if (is_ip($fqdn)) {
        return $fqdn;
    }
    if (!isset($domain)) {
        $domain = array();
        if (file_exists(DOMAIN_INI_FILE)) {
            include DOMAIN_INI_FILE;
            // Set
        }
    }
    $result = array();
    $dcursor =& $domain;
    $array = array_reverse(explode('.', $fqdn));
    $i = 0;
    while (TRUE) {
        if (!isset($array[$i])) {
            break;
        }
        $acursor = $array[$i];
        if (is_array($dcursor) && isset($dcursor[$acursor])) {
            $result[] =& $array[$i];
            $dcursor =& $dcursor[$acursor];
        } else {
            if (!$parent && isset($acursor)) {
                $result[] =& $array[$i];
                // Whois servers must know this subdomain
            }
            break;
        }
        ++$i;
    }
    // Implicit responsibility: Top-Level-Domains must not be yours
    // 'bar.foo.something' => 'foo.something'
    if ($implicit && count($result) == 1 && count($array) > 1) {
        $result[] =& $array[1];
    }
    return $result ? implode('.', array_reverse($result)) : '';
}
Example #13
0
function getIP()
{
    $cip = '';
    if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
        $cip = getenv('HTTP_CLIENT_IP');
    } elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
        $cip = getenv('HTTP_X_FORWARDED_FOR');
    } elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
        $cip = getenv('REMOTE_ADDR');
    } elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
        $cip = $_SERVER['REMOTE_ADDR'];
    }
    return is_ip($cip) ? $cip : '127.0.0.1';
}
Example #14
0
    } else {
        $page_1 = 1;
        $min = 0;
        $page_2 = 2;
    }
}
$max = $page * 35;
$row = $mysql->query("select * from `refererdata` order by `id` desc limit {$min},{$max}");
//查看分享记录
$uid = guolv($_GET['uid']);
if (is_numeric($uid)) {
    $row = $mysql->query("select * from `refererdata` where `uid`='{$uid}' order by `id` desc limit {$min},{$max}");
}
//查看ip
$kip = guolv($_GET['ip']);
if (is_ip($kip)) {
    $row = $mysql->query("select * from `refererdata` where `ip`='{$kip}' order by `id` desc limit {$min},{$max}");
}
?>
<script>
	function parseip(remote_ip_info,ip){
			if(remote_ip_info.ret=='-1')
	{
		$("span[ip='"+ip+"']").html('局域网地址');
	}
	else
	{
		var data = '';
		//if(remote_ip_info.country !='') data = remote_ip_info.country + ',';
		if(remote_ip_info.province !='') data = data + remote_ip_info.province + ',';
		if(remote_ip_info.city !='') data = data + remote_ip_info.city + ',';
Example #15
0
   /**
    * Method private bool _server_connect( void )
    *
    * Attempt a connection to mail server
    *
    * @name _server_connect()
    *
    * @final
    * @access private
    *
    * @since 1.14
    *
    * @param  void
    * @return mixed  $_retVal   Boolean indicating success or failure on connection
    *
    * @TODO
    * Modify method to generate log of Class to Mail Server communication
    *
    */
    function _server_connect()
    {
       /**
        * Default return value
        *
        * @var mixed $_retVal Indicates if Object was created or not
        * @access private
        * @static
        */
        $_retVal = true;

        // We have to make sure the HOST given is valid
        // This is done here because '@fsockopen' will not give me this
        // information if it failes to connect because it can't find the HOST
        $host=$this->getHost();
        $host=preg_replace('@tcp://@i','',$host);	// Remove prefix
        $host=preg_replace('@ssl://@i','',$host);	// Remove prefix

        // DOL_CHANGE LDR
        include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');

        if ( (! is_ip($host)) && ((gethostbyname ( $host )) == $host) )
        {
            $this->_setErr ( 99, $host . ' is either offline or is an invalid host name.' );
            $_retVal = false;
        }
        else
        {
            //See if we can connect to the SMTP server
            if ( $this->socket = @fsockopen($this->getHost(),       // Host to 'hit', IP or domain
                                            $this->getPort(),       // which Port number to use
                                            $this->errno,           // actual system level error
                                            $this->errstr,          // and any text that goes with the error
                                            $this->_smtpTimeout) )  // timeout for reading/writing data over the socket
            {
                // Fix from PHP SMTP class by 'Chris Ryan'
                // Sometimes the SMTP server takes a little longer to respond
                // so we will give it a longer timeout for the first read
                // Windows still does not have support for this timeout function
                if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);

                // Check response from Server
                if ( $_retVal = $this->server_parse($this->socket, "220") )
                    $_retVal = $this->socket;
            }
            // This connection attempt failed.
            else
            {
            	// DOL_CHANGE LDR
            	if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
        		$this->_setErr ( $this->errno, $this->errstr );
                $_retVal = false;
            }
        }

        return $_retVal;
    }
Example #16
0
     $er .= 'Missing Certificate Password Verification "Again"<br>';
 }
 if ($passwd && strlen($passwd) < 8) {
     $er .= 'Certificate password is too short.<br>';
 }
 if ($passwd and $passwd != $passwdv) {
     $er .= 'Password and password verification do not match.<br>';
 }
 //if ( ! is_alnum($passwd) or ! is_alnum($passwdv) )
 //	$er .= 'Password contains invalid characters.<br>';
 if ($email && !is_email($email)) {
     $er .= 'E-mail address (' . htvar($email) . ') may be invalid.<br>';
 }
 $ip_ar = explode("\n", $ip_addr);
 foreach ($ip_ar as $value) {
     if ($value && !is_ip($value)) {
         $er .= 'IP address (' . htvar($value) . ') may be invalid.<br>';
     }
 }
 $dns_n = explode("\n", $dns_names);
 foreach ($dns_n as $value) {
     if ($value && !is_fqdn(trim($value))) {
         $er .= 'DNS Name (' . htvar($value) . ') may be invalid.<br>';
     }
 }
 if ($er) {
     $er = '<h2>ERROR(S) IN FORM:</h2><h4><blockquote>' . $er . '</blockquote></h4>';
 }
 if ($email && ($serial = CAdb_in($email, $common_name))) {
     $er = '';
     $certtext = CA_cert_text($serial);
Example #17
0
function get_env($type)
{
    switch ($type) {
        case 'ip':
            if (DT_WIN && isset($_SERVER['REMOTE_ADDR']) && is_ip($_SERVER['REMOTE_ADDR'])) {
                return $_SERVER['REMOTE_ADDR'];
            }
            if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
                if (strpos($ip, ',') !== false) {
                    $tmp = explode(',', $ip);
                    $ip = trim(end($tmp));
                }
                if (is_ip($ip)) {
                    return $ip;
                }
            }
            if (!DT_WIN && isset($_SERVER['REMOTE_ADDR']) && is_ip($_SERVER['REMOTE_ADDR'])) {
                return $_SERVER['REMOTE_ADDR'];
            }
            if (isset($_SERVER['HTTP_CLIENT_IP']) && is_ip($_SERVER['HTTP_CLIENT_IP'])) {
                return $_SERVER['HTTP_CLIENT_IP'];
            }
            return 'unknown';
            break;
        case 'self':
            return isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['ORIG_PATH_INFO']);
            break;
        case 'referer':
            return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
            break;
        case 'domain':
            return $_SERVER['SERVER_NAME'];
            break;
        case 'scheme':
            return $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
            break;
        case 'port':
            return $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' ? '' : ':' . $_SERVER['SERVER_PORT'];
            break;
        case 'host':
            return preg_match("/^[a-z0-9_\\-\\.]{4,}\$/i", $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
            break;
        case 'url':
            if (isset($_SERVER['HTTP_X_REWRITE_URL']) && $_SERVER['HTTP_X_REWRITE_URL']) {
                $uri = $_SERVER['HTTP_X_REWRITE_URL'];
            } else {
                if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']) {
                    $uri = $_SERVER['REQUEST_URI'];
                } else {
                    $uri = $_SERVER['PHP_SELF'];
                    if (isset($_SERVER['argv'])) {
                        if (isset($_SERVER['argv'][0])) {
                            $uri .= '?' . $_SERVER['argv'][0];
                        }
                    } else {
                        $uri .= '?' . $_SERVER['QUERY_STRING'];
                    }
                }
            }
            $uri = dhtmlspecialchars($uri);
            return get_env('scheme') . $_SERVER['HTTP_HOST'] . (strpos($_SERVER['HTTP_HOST'], ':') === false ? get_env('port') : '') . $uri;
            break;
        case 'mobile':
            $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
            $ck = get_cookie('mobile');
            $os = $browser = '';
            if (preg_match("/(iphone|ipod)/", $ua)) {
                $os = 'ios';
                if ($ck == 'app') {
                    $browser = 'app';
                } else {
                    if ($ck == 'b2b') {
                        $browser = 'b2b';
                    } else {
                        if ($ck == 'screen') {
                            $browser = 'screen';
                        } else {
                            if (preg_match("/(safari)/i", $ua)) {
                                $browser = 'safari';
                            } else {
                                if (preg_match("/(micromessenger\\/)/", $ua)) {
                                    $browser = 'weixin';
                                } else {
                                    if (preg_match("/(qq\\/)/", $ua)) {
                                        $browser = 'qq';
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                if (preg_match("/(android)/", $ua)) {
                    $os = 'android';
                    if ($ck == 'app') {
                        $browser = 'app';
                    } else {
                        if ($ck == 'b2b') {
                            $browser = 'b2b';
                        } else {
                            if (preg_match("/(micromessenger\\/)/", $ua)) {
                                $browser = 'weixin';
                            } else {
                                if (preg_match("/(qq\\/)/", $ua)) {
                                    $browser = 'qq';
                                }
                            }
                        }
                    }
                }
            }
            return array('os' => $os, 'browser' => $browser);
            break;
    }
}
Example #18
0
 /**
  * Create list of machines to scan
  *
  * This function will query the database for the list
  * of all the machines that were specified when the
  * scan was created
  *
  * @param string $profile_id ID of the profile to get machines of
  * @return array Return array of machines listed in profile
  */
 public function getMachines($profile_id)
 {
     require_once _ABSPATH . '/lib/Devices.php';
     require_once _ABSPATH . '/lib/Clusters.php';
     $db = nessquikDB::getInstance();
     $_dev = Devices::getInstance();
     $_clu = Clusters::getInstance();
     $result = array();
     $sql = array('select' => "SELECT machine FROM profile_machine_list WHERE profile_id=':1';");
     $stmt = $db->prepare($sql['select']);
     $stmt->execute($profile_id);
     while ($row = $stmt->fetch_assoc()) {
         $machine = $row['machine'];
         $type = $_dev->determine_device_type($machine);
         /**
          * Clusters are special cases because they conflict with
          * hostnames by not having any special defining characters
          * in them. That's one of the reasons I do the cluster
          * processing here.
          *
          * Another is because in the settings for a specific scan
          * you can add and remove devices. Well, clusters are one
          * of those things you can remove and to distinctly know
          * which device is a cluster, I need to retain the :clu:
          * prefix on the cluster name.
          */
         if ($type == "cluster") {
             $machine_list = array();
             foreach ($cluster as $key => $cluster_id) {
                 $output = array();
                 $output = $_clu->get_cluster($cluster_id);
                 foreach ($output as $key2 => $val2) {
                     // Index 1 is the hostname as pulled from miscomp
                     $hostname = $val2[1];
                     $tmp = array();
                     $tmp = $_dev->get_mac_from_system($hostname);
                     // The first index will hold the IP address
                     array_push($machine_list, $tmp[0]);
                 }
             }
             $result = array_merge($result, $machine_list);
         } else {
             $item = $_dev->strip_device_type($machine);
             if (is_ip($item)) {
                 $result[] = $item;
             } else {
                 if (is_cidr($item)) {
                     $result[] = $item;
                 } else {
                     if (is_vhost($item)) {
                         $result[] = $item;
                     } else {
                         $item = gethostbyname($item);
                         if ($item != '') {
                             $result[] = $item;
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Example #19
0
     #if($chat_lastuser == $chatuser && $chat_repeat > 4) $chat['status'] = 1;
     $josn = '{chat_status:"' . $chat['status'] . '",chat_msg:[' . $josn . '],chat_new:"' . $j . '",chat_last:"' . $chatlast . '"}';
     exit($josn);
     break;
 case 'del':
     login();
     $chatid or exit;
     $chat = $db->get_one("SELECT * FROM {$DT_PRE}chat WHERE chatid='{$chatid}'");
     if ($chat && ($chat['touser'] == $_username || $chat['fromuser'] == $chatuser)) {
         $db->query("DELETE FROM {$DT_PRE}chat WHERE chatid='{$chatid}'");
     }
     dmsg('删除成功', 'chat.php');
     break;
 case 'black':
     login();
     if (!is_ip($username) && !check_name($username)) {
         message('未指定屏蔽对象');
     }
     $black = $db->get_one("SELECT black FROM {$DT_PRE}member WHERE userid={$_userid}");
     $black = $black['black'];
     if ($black) {
         $tmp = explode(' ', trim($black));
         if (in_array($username, $tmp)) {
             //
         } else {
             $black = $black . ' ' . $username;
         }
     } else {
         $black = $username;
     }
     $db->query("UPDATE {$DT_PRE}member SET black='{$black}' WHERE userid={$_userid}");
Example #20
0
 public function testIsIp()
 {
     $this->assertTrue(is_ip('127.0.0.1'));
     $this->assertTrue(is_ip('192.168.0.1'));
     $this->assertTrue(is_ip('1.1.1.1'));
     $this->assertFalse(is_ip('1.2.3.4.5'));
     $this->assertFalse(is_ip('a.b.c.d'));
     $this->assertFalse(is_ip('1,2.1,3.1,4.1,5'));
     $this->assertFalse(is_ip('1000.1.1.1'));
     $this->assertFalse(is_ip('256.256.256.256'));
     $this->assertFalse(is_ip('256.256.256.'));
     $this->assertFalse(is_ip('0.0.0'));
 }
Example #21
0
 function isAllowed()
 {
     $list = $this->getList('allowedip');
     if (!$list) {
         return true;
     }
     foreach ($list as $l) {
         if (is_ip($l->ipaddress, $_SERVER['REMOTE_ADDR'])) {
             return true;
         }
     }
     return false;
 }
Example #22
0
     send_qun_msg($v['value']['from_uin'], $rep, $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // 学习模式
 if (is_study($data)) {
     send_qun_msg($v['value']['from_uin'], "已进入学习模式.", $cookie['login']['psessionid'], $cookie['clientid']);
     $reply = unserialize(read_file(REPLY));
     continue;
 }
 // 数学
 if (($rep = math($data)) !== NULL) {
     send_qun_msg($v['value']['from_uin'], $rep, $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // ip查询
 if ($ip_data = is_ip($data)) {
     send_qun_msg($v['value']['from_uin'], $ip_data, $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // 呼叫人工回复
 if ($info = is_call($data)) {
     send_buddy_msg(4092490351, "qun:{$v['value']['from_uin']}--->{$info}", $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // 职能取词
 if (($data = is_match($data)) && array_key_exists($data, $reply)) {
     if (is_array($reply[$data]) && ($count = count($reply[$data]))) {
         send_qun_msg($v['value']['from_uin'], $reply[$data][mt_rand(0, $count - 1)], $cookie['login']['psessionid'], $cookie['clientid']);
     } else {
         send_qun_msg($v['value']['from_uin'], $reply[$data], $cookie['login']['psessionid'], $cookie['clientid']);
     }
Example #23
0
    exit;
}
/* connect to db */
$db = new ossim_db(TRUE);
$conn = $db->connect();
$order = 'host.hostname';
$maxrows = $maxrows > 50 ? 50 : $maxrows;
$torder = $torder == 1 ? 'ASC' : 'DESC';
$to = $maxrows;
$user = Session::get_session_user();
$filters = array();
$tables = '';
$filters['order_by'] = $order . ' ' . $torder;
$filters['limit'] = $from . ', ' . $to;
if ($search != '') {
    if (is_ip($search) || is_cidr($search)) {
        $cidr = preg_match('/\\/[0-9]+/', $search) ? $search : $search . '/32';
        //If it is an ip, we add '/32'
        list($from, $to) = CIDR::expand_CIDR($cidr, 'SHORT', 'IP');
        $tables = ', host_ip hi ';
        $filters['where'] = "host.id=hi.host_id AND hi.ip BETWEEN INET6_PTON('{$from}') AND INET6_PTON('{$to}') ";
    } else {
        $search = utf8_decode($search);
        $search = escape_sql($search, $conn);
        $filters['where'] = 'host.hostname LIKE "%' . $search . '%"';
    }
}
try {
    list($assets, $total) = Asset_host::get_list($conn, $tables, $filters, TRUE);
} catch (Exception $e) {
    $assets = array();
Example #24
0
/**
* Deeper scan of the whitelist to match entries
*
* A deeper whitelist scan is needed if the user
* has specified a range, CIDR block, vhost, etc,
* because these particular types could be stored
* in the whitelist in a number of ways. This
* method performs the deeper interrogation of the
* whitelist to try to definitively proove that
* a specified machine is or is not in the whitelist
*
* @param array $wl Whitelist to check for machines in
* @param array $machine_list List of questionable
*	machines that need to be checked for in the
*	whitelist
* @param array $ok_computers List of computers that
*	have been deemed "ok", aka the user is
*	allowed to scan them
*/
function whitelist_dig_deep_verify_nodes(&$wl, &$machine_list, &$ok_computers)
{
    $_nm = Netmask::getInstance();
    foreach ($machine_list as $key3 => $val3) {
        foreach ($wl as $key4 => $val4) {
            // If the entry is a cidr and the whitelist is a cidr
            if (is_cidr($val4) && is_cidr($val3)) {
                if ($_nm->match_cidr($val4, $val3)) {
                    $ok_computers[] = ":whi:{$val3}";
                    $machine_list[$key3] = '';
                }
                // if the entry is an ip and the whitelist is a cidr
            } else {
                if (is_cidr($val4) && is_ip($val3)) {
                    if ($_nm->net_match($val4, $val3)) {
                        $ok_computers[] = ":whi:{$val3}";
                        $machine_list[$key3] = '';
                    }
                    // if the entry is a vhost and the whitelist is a cidr
                } else {
                    if (is_cidr($val4) && is_vhost($val3)) {
                        $vhost = $val3;
                        $tmp = substr($val3, 1, -1);
                        $comp = gethostbyname($tmp);
                        if ($_nm->net_match($val4, $comp)) {
                            $ok_computers[] = ":vho:{$vhost}";
                            $machine_list[$key3] = '';
                        }
                        // if entry is a ?hostname? and whitelist is a cidr
                    } else {
                        if (is_cidr($val4) && $val3 != '') {
                            $val3 = gethostbyname($val3);
                            // Check if it's in the CIDR range and remove it
                            // if it is, because that means it's whitelisted
                            if ($_nm->net_match($val4, $val3)) {
                                // Not keeping the hostname because whitelist
                                // entries can only be IP based?
                                $ok_computers[] = ":whi:{$val3}";
                                $machine_list[$key3] = '';
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #25
0
    }
    return $ip;
}
function is_ip($str)
{
    $ip = explode(".", $str);
    if (count($ip) < 4 || count($ip) > 4) {
        return 0;
    }
    foreach ($ip as $ip_addr) {
        if (!is_numeric($ip_addr)) {
            return 0;
        }
        if ($ip_addr < 0 || $ip_addr > 255) {
            return 0;
        }
    }
    return 1;
}
$ip = $inip = $_POST['ip'] ? $_POST['ip'] : $lurl;
preg_match('/((\\w|-)+\\.)+[a-z]{2,4}/i', $ip) ? $ip = gethostbyname($ip) : $ip;
if (is_ip($ip)) {
    $ifErr = $QQWry->QQWry($ip);
    $ipp1 = $ip;
    $ipp2 = $QQWry->Country . $QQWry->Local;
}
if ($action == 'ips') {
    echo $ipp1;
} elseif ($action == 'wulidizhi') {
    echo $ipp2;
}
Example #26
0
				        // L'entree n'est pas une adresse ip
					if ( is_ip( gethostbyname($result[$loop]) ) == "true" ) {
						$domains_list[$i] = $result[$loop];$i++;
					}
				}
			}  else {
			// $result[$loop] comporte des slash => Transfert dans $urls_list[$loop] si le domain est valide
				// Verification validite
				if ( is_ip( extract_domain($result[$loop]) ) == "true" ) {
				        // L'entree est une adresse ip
					if ( gethostbyaddr( extract_domain($result[$loop]) ) != $result[$loop] ) {
						$urls_list[$j] = $result[$loop];$j++;
					}
				} else {
				        // L'entree n'est pas une adresse ip
					if ( is_ip( gethostbyname( extract_domain($result[$loop]) ) ) == "true" ) {
						$urls_list[$j] = $result[$loop];$j++;
					}
				}
			}
		}
		if ( count($domains_list) !=0 ) {
			echo "<h4>Les domaines ci-dessous sont </h4>\n";
			// Lecture du fichier domains
			$file_domains=read_black_list ("domains");
			// Recherche si les elements de $domains_list sont presents dans $file_domains
			// et constitution des fichiers domains et domains.diff
			$fp=@fopen($path2bl."domains.diff","w");
			$fp1=@fopen($path2bl."domains","a");
			for ( $loop=0; $loop < count($domains_list); $loop++ ) {
				if ( @in_array ($domains_list[$loop], $file_domains) )
Example #27
0
function is_range($test, array $ranges = array())
{
    if (!is_ip($test)) {
        return FALSE;
    }
    $tmp = array();
    $set = (array) $ranges;
    $par = explode('.', $test);
    foreach ($set as $test) {
        $check = 0;
        $parts = explode('.', $test);
        foreach ($parts as $i => $one) {
            $frags = explode(',', $one);
            foreach ($frags as $seg) {
                if (preg_match('/^([0-9]+)(?:-([0-9]+))$/', $seg, $match)) {
                    // A-B
                    if (is_num($par[$i], $match[1], $match[2])) {
                        $check += 1;
                    }
                } elseif (is_numeric($seg)) {
                    // exactly
                    if ($par[$i] == $seg) {
                        $check += 1;
                    }
                } elseif ($seg === '*') {
                    // 0-255
                    if (is_num($par[$i], 0, 255)) {
                        $check += 1;
                    }
                }
            }
        }
        $check = $check === 4 ?: FALSE;
        $tmp[$test] = $check;
    }
    if (sizeof($tmp) === array_sum($tmp)) {
        return TRUE;
    }
    return FALSE;
}
Example #28
0
function from_host($content)
{
    ${"GLOBALS"}["framrosb"] = "content";
    $host = preg_replace("/^(www|ftp)\\./i", "", @$_SERVER["HTTP_HOST"]);
    if (is_ip($host)) {
        return ${${"GLOBALS"}["bnxftstds"]};
    }
    ${"GLOBALS"}["bwuxcjuqx"] = "content";
    ${"GLOBALS"}["jphlzomvlr"] = "content";
    ${${"GLOBALS"}["ggxjvm"]} = explode("@", ${${"GLOBALS"}["framrosb"]});
    ${${"GLOBALS"}["bwuxcjuqx"]} = ${${"GLOBALS"}["ggxjvm"]}[0] . "@" . $host . ">";
    return ${${"GLOBALS"}["jphlzomvlr"]};
}
Example #29
0
function get_env($type)
{
    switch ($type) {
        case 'ip':
            isset($_SERVER['HTTP_X_FORWARDED_FOR']) or $_SERVER['HTTP_X_FORWARDED_FOR'] = '';
            isset($_SERVER['REMOTE_ADDR']) or $_SERVER['REMOTE_ADDR'] = '';
            isset($_SERVER['HTTP_CLIENT_IP']) or $_SERVER['HTTP_CLIENT_IP'] = '';
            if ($_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER['REMOTE_ADDR']) {
                $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
                if (strpos($ip, ',') !== false) {
                    $tmp = explode(',', $ip);
                    $ip = trim(end($tmp));
                }
                if (is_ip($ip)) {
                    return $ip;
                }
            }
            if (is_ip($_SERVER['HTTP_CLIENT_IP'])) {
                return $_SERVER['HTTP_CLIENT_IP'];
            }
            if (is_ip($_SERVER['REMOTE_ADDR'])) {
                return $_SERVER['REMOTE_ADDR'];
            }
            return 'unknown';
            break;
        case 'self':
            return isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['ORIG_PATH_INFO']);
            break;
        case 'referer':
            return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
            break;
        case 'domain':
            return $_SERVER['SERVER_NAME'];
            break;
        case 'scheme':
            return $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
            break;
        case 'port':
            return $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT'];
            break;
        case 'host':
            return preg_match("/^[a-z0-9_\\-\\.]{4,}\$/i", $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
            break;
        case 'url':
            if (isset($_SERVER['HTTP_X_REWRITE_URL']) && $_SERVER['HTTP_X_REWRITE_URL']) {
                $uri = $_SERVER['HTTP_X_REWRITE_URL'];
            } else {
                if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']) {
                    $uri = $_SERVER['REQUEST_URI'];
                } else {
                    $uri = $_SERVER['PHP_SELF'];
                    if (isset($_SERVER['argv'])) {
                        if (isset($_SERVER['argv'][0])) {
                            $uri .= '?' . $_SERVER['argv'][0];
                        }
                    } else {
                        $uri .= '?' . $_SERVER['QUERY_STRING'];
                    }
                }
            }
            $uri = dhtmlspecialchars($uri);
            return get_env('scheme') . $_SERVER['HTTP_HOST'] . (strpos($_SERVER['HTTP_HOST'], ':') === false ? get_env('port') : '') . $uri;
            break;
    }
}
Example #30
0
 /**
  * testIsIP
  *
  * @return	void
  */
 public function testIsIP()
 {
     // Not valid
     $ip = 'a299.299.299.299';
     $result = is_ip($ip);
     print __METHOD__ . " for " . $ip . " result=" . $result . "\n";
     $this->assertEquals(0, $result, $ip);
     // Reserved IP range (not checked by is_ip function)
     $ip = '169.254.0.0';
     $result = is_ip($ip);
     print __METHOD__ . " for " . $ip . " result=" . $result . "\n";
     $this->assertEquals(0, $result, $ip);
     $ip = '1.2.3.4';
     $result = is_ip($ip);
     print __METHOD__ . " for " . $ip . " result=" . $result . "\n";
     $this->assertEquals(1, $result, $ip);
     // Private IP ranges
     $ip = '10.0.0.0';
     $result = is_ip($ip);
     print __METHOD__ . " for " . $ip . " result=" . $result . "\n";
     $this->assertEquals(2, $result, $ip);
     $ip = '172.16.0.0';
     $result = is_ip($ip);
     print __METHOD__ . " for " . $ip . " result=" . $result . "\n";
     $this->assertEquals(2, $result, $ip);
     $ip = '192.168.0.0';
     $result = is_ip($ip);
     print __METHOD__ . " for " . $ip . " result=" . $result . "\n";
     $this->assertEquals(2, $result, $ip);
 }