Пример #1
1
 public function index()
 {
     $os = explode(' ', php_uname());
     $mysql_support = function_exists('mysql_close') ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $register_globals = get_cfg_var("register_globals") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $enable_dl = get_cfg_var("enable_dl") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $allow_url_fopen = get_cfg_var("allow_url_fopen") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $display_errors = get_cfg_var("display_errors") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $session_support = function_exists('session_start') ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $config['server_name'] = $_SERVER['SERVER_NAME'];
     $config['server_ip'] = @gethostbyname($_SERVER['SERVER_NAME']);
     $config['server_time'] = date("Y年n月j日 H:i:s");
     $config['os'] = $os[0];
     $config['os_core'] = $os[2];
     $config['server_root'] = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
     $config['server_engine'] = $_SERVER['SERVER_SOFTWARE'];
     $config['server_port'] = $_SERVER['SERVER_PORT'];
     $config['php_version'] = PHP_VERSION;
     $config['php_run_type'] = strtoupper(php_sapi_name());
     $config['mysql_support'] = $mysql_support;
     $config['register_globals'] = $register_globals;
     $config['allow_url_fopen'] = $allow_url_fopen;
     $config['display_errors'] = $display_errors;
     $config['enable_dl'] = $enable_dl;
     $config['memory_limit'] = get_cfg_var("memory_limit");
     $config['post_max_size'] = get_cfg_var("post_max_size");
     $config['upload_max_filesize'] = get_cfg_var("upload_max_filesize");
     $config['max_execution_time'] = get_cfg_var("max_execution_time");
     $config['session_support'] = $session_support;
     $this->config_arr = $config;
     $this->display();
 }
Пример #2
0
 function query($ip)
 {
     if (!$ip) {
         return false;
     }
     $this->ip = $ip;
     list($a, $b, $c, $d) = explode('.', $ip);
     $query = $this->access_key . ".{$d}.{$c}.{$b}.{$a}." . $this->domain;
     $host = gethostbyname($query);
     list($first, $days, $score, $type) = explode('.', $host);
     if ($first == 127) {
         //spammer
         $this->days = $days;
         $this->score = $score;
         $this->type_num = $type;
         $this->type_txt = $this->answer_codes[$type];
         // search engine
         if ($type == 0) {
             $this->days = 0;
             $this->score = 0;
             $this->engine_num = $score;
             //$this->engine_txt	=$this->engine_codes[$score];
             return 1;
         } else {
             return 2;
         }
     }
     return 0;
 }
Пример #3
0
function logit($r = '')
{
    global $siteurl, $prefs, $pretext;
    $mydomain = str_replace('www.', '', preg_quote($siteurl, "/"));
    $out['uri'] = @$pretext['request_uri'];
    $out['ref'] = clean_url(str_replace("http://", "", serverSet('HTTP_REFERER')));
    $host = $ip = serverSet('REMOTE_ADDR');
    if (!empty($prefs['use_dns'])) {
        // A crude rDNS cache
        if ($h = safe_field('host', 'txp_log', "ip='" . doSlash($ip) . "' limit 1")) {
            $host = $h;
        } else {
            // Double-check the rDNS
            $host = @gethostbyaddr(serverSet('REMOTE_ADDR'));
            if ($host != $ip and @gethostbyname($host) != $ip) {
                $host = $ip;
            }
        }
    }
    $out['ip'] = $ip;
    $out['host'] = $host;
    $out['status'] = 200;
    // FIXME
    $out['method'] = serverSet('REQUEST_METHOD');
    if (preg_match("/^[^\\.]*\\.?{$mydomain}/i", $out['ref'])) {
        $out['ref'] = "";
    }
    if ($r == 'refer') {
        if (trim($out['ref']) != "") {
            insert_logit($out);
        }
    } else {
        insert_logit($out);
    }
}
Пример #4
0
function MailGin($correo, $nom, $msj)
{
    //Template Admin
    $templateAdmin = file_get_contents('MailAdminForm.html');
    $templateAdmin = str_replace('%nombre%', $nom, $templateAdmin);
    $templateAdmin = str_replace('%email%', $correo, $templateAdmin);
    $templateAdmin = str_replace('%mensaje%', $msj, $templateAdmin);
    $templateAdmin = str_replace('\\r\\n', '<br>', $templateAdmin);
    //Envia Mail
    $mail = new PHPMailer();
    $mail->Host = gethostbyname('smtp.gmail.com');
    //$mail->SMTPDebug = 3;
    $mail->isSMTP();
    $mail->Host = 'smtp.gmail.com';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls";
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->Port = 587;
    $mail->setFrom('*****@*****.**', 'Gin Gin');
    $mail->addAddress('jcisneros@iegroup.mx ', 'Cisneros');
    $mail->addAddress('*****@*****.**', 'Iegroup');
    //$mail->addAddress('*****@*****.**','Developer');
    $mail->isHTML(true);
    $mail->CharSet = 'UTF-8';
    $mail->Subject = 'Has recibido un nuevo mensaje desde gin-gin.mx';
    $mail->Body = $templateAdmin;
    $mail->send();
    /*   if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent' ;
            }
            */
    //Template Usuario
    $templateUser = file_get_contents('MailUserForm.html');
    $templateUser = str_replace('%nombre%', $nom, $templateUser);
    $templateUser = str_replace('\\r\\n', '<br>', $templateUser);
    //Envia Mail
    $mail = new PHPMailer();
    $mail->Host = gethostbyname('smtp.gmail.com');
    //$mail->SMTPDebug = 3;
    $mail->isSMTP();
    $mail->Host = 'smtp.gmail.com';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls";
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->Port = 587;
    $mail->setFrom('*****@*****.**', 'Gin Gin');
    //$mail->addAddress('jcisneros@iegroup.mx ','Cisneros');
    //$mail->addAddress('*****@*****.**','Iegroup');
    $mail->addAddress($correo);
    $mail->isHTML(true);
    $mail->CharSet = 'UTF-8';
    $mail->Subject = 'Gracias por contactarnos a gin-gin.mx';
    $mail->Body = $templateUser;
    $mail->send();
}
Пример #5
0
Файл: Socket.php Проект: mmr/b1n
 private function Connect($servers)
 {
     if ($this->IsConnected()) {
         throw new Exception('Already connected');
     }
     if (!is_array($servers) || count($servers) == 0) {
         throw new Exception('No servers');
     }
     foreach ($servers as $s) {
         if (!ereg("[^:]+:[0-9]+", $s)) {
             throw new Exception($s . ' is not a valid server');
         }
     }
     srand((double) microtime() * 1000000);
     shuffle($servers);
     foreach ($servers as $s) {
         list($server, $port) = explode(":", $s);
         $server = gethostbyname($server);
         $this->socket = fsockopen($server, $port, $errno, $err);
         if ($this->IsConnected()) {
             break;
         }
     }
     if ($this->IsConnected()) {
         return true;
     } else {
         throw new Exception($errno . ' - ' . $err);
     }
 }
Пример #6
0
 public function titleToChannel(&$irc, $msg, $channel, $matches, $who)
 {
     $host = parse_url($matches[1], PHP_URL_HOST);
     $ip = gethostbyname($host);
     if (!preg_match('/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/', $ip) and ($ip == $matches[1] or $ip === false)) {
         // It isn't a ip address and doesn't resolve as a domain name
         $irc->sayToChannel('Unknown host ' . $host, $channel);
     } else {
         if (!($this->ipIsPrivate($ip) or $this->ipIsLoopback($ip))) {
             if ($file = file_get_contents($matches[1])) {
                 //Max lenght is 256 bytes
                 if (preg_match('@<title>([^<]{1,256}).*?</title>@mi', $file, $matches)) {
                     if (strlen($matches[1]) == 256) {
                         $matches[1] .= '...';
                     }
                     //str_replace is to avoid sending multiple lines when the title is something\nlike\nthis
                     $irc->sayToChannel('Title: ' . str_replace("\n", '', str_replace("\r", '', html_entity_decode($matches[1], ENT_QUOTES, 'utf-8'))), $channel);
                 }
             }
         } else {
             if ($irc->debug) {
                 echo $ip . " is a local address!\n";
             }
         }
     }
 }
Пример #7
0
 protected function connectSocket()
 {
     if (filter_var($this->host, FILTER_VALIDATE_IP)) {
         $ip = $this->host;
     } else {
         $ip = gethostbyname($this->host);
         if ($ip == $this->host) {
             throw new MongoConnectionException(sprintf('couldn\'t get host info for %s', $this->host));
         }
     }
     // For some reason, PHP doesn't currently allow resources opened with
     // fsockopen/pfsockopen to be used with socket_* functions, but HHVM does.
     if (defined('HHVM_VERSION')) {
         $this->socket = pfsockopen($ip, $this->port, $errno, $errstr, $this->connectTimeoutMS / 1000);
         if ($this->socket === false) {
             $this->socket = null;
             throw new MongoConnectionException(sprintf("unable to connect to {$ip}:{$this->port} because: %s", "{$errstr} ({$errno})"));
         }
     } else {
         $this->socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname("tcp"));
         if (!$this->socket) {
             throw new MongoConnectionException(sprintf('error creating socket: %s', socket_strerror(socket_last_error())));
         }
         $connected = socket_connect($this->socket, $ip, $this->port);
         if (!$connected) {
             throw new MongoConnectionException(sprintf("unable to connect to {$ip}:{$this->port} because: %s", socket_strerror(socket_last_error())));
         }
     }
 }
Пример #8
0
 public function main()
 {
     $count = array();
     $article = M('article');
     $type = M('type');
     $link = M('link');
     $hd = M('flash');
     $ping = M('pl');
     $guest = M('guestbook');
     $count['article'] = $article->count();
     //文章总数
     $count['narticle'] = $article->where('status=0')->count();
     //未审核文章总数
     $count['guestbook'] = $guest->count();
     //留言总数
     $count['nguestbook'] = $guest->where('status=0')->count();
     //未审核留言总数
     $count['type'] = $type->count();
     //栏目总数
     $count['link'] = $link->count();
     //链接总数
     $count['hd'] = $hd->count();
     //幻灯总数
     $count['ping'] = $ping->count();
     //评论总数
     $count['nping'] = $ping->where('status=0')->count();
     //未审核评论
     $this->assign('count', $count);
     unset($article, $type, $link, $hd, $ping, $guest);
     $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '剩余空间' => round(@disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO');
     $this->assign('info', $info);
     $this->display('main');
 }
 public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
 {
     if (!$ip || long2ip(ip2long($ip)) != $ip) {
         return;
     }
     $urls = $this->getLinks($content);
     array_unshift($urls, $site);
     foreach ($urls as $u) {
         $b = parse_url($u);
         if (!isset($b['host']) || !$b['host']) {
             continue;
         }
         $domain = preg_replace('/^[\\w]{2,6}:\\/\\/([\\w\\d\\.\\-]+).*$/', '$1', $b['host']);
         $domain_elem = explode(".", $domain);
         $i = count($domain_elem) - 1;
         if ($i == 0) {
             // "domain" is 1 word long, don't check it
             return null;
         }
         $host = $domain_elem[$i];
         do {
             $host = $domain_elem[$i - 1] . '.' . $host;
             $i--;
             if (substr(gethostbyname($host . '.' . $this->server), 0, 3) == "127") {
                 $status = substr($domain, 0, 128);
                 return true;
             }
         } while ($i > 0);
     }
 }
Пример #10
0
 function __construct()
 {
     $this->S['YourIP'] = @$_SERVER['REMOTE_ADDR'];
     $domain = $this->OS() ? $_SERVER['SERVER_ADDR'] : @gethostbyname($_SERVER['SERVER_NAME']);
     $this->S['DomainIP'] = @get_current_user() . ' - ' . $_SERVER['SERVER_NAME'] . '(' . $domain . ')';
     $this->S['Flag'] = empty($this->sysInfo['win_n']) ? @php_uname() : $this->sysInfo['win_n'];
     $os = explode(" ", php_uname());
     $oskernel = $this->OS() ? $os[2] : $os[1];
     $this->S['OS'] = $os[0] . '内核版本:' . $oskernel;
     $this->S['Language'] = getenv("HTTP_ACCEPT_LANGUAGE");
     $this->S['Name'] = $this->OS() ? $os[1] : $os[2];
     $this->S['Email'] = $_SERVER['SERVER_ADMIN'];
     $this->S['WebEngine'] = $_SERVER['SERVER_SOFTWARE'];
     $this->S['WebPort'] = $_SERVER['SERVER_PORT'];
     $this->S['WebPath'] = $_SERVER['DOCUMENT_ROOT'] ? str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) : str_replace('\\', '/', dirname(__FILE__));
     $this->S['ProbePath'] = str_replace('\\', '/', __FILE__) ? str_replace('\\', '/', __FILE__) : $_SERVER['SCRIPT_FILENAME'];
     $this->S['sTime'] = date('Y-m-d H:i:s');
     $this->sysInfo = $this->GetsysInfo();
     //var_dump($this->sysInfo);
     $CPU1 = $this->GetCPUUse();
     sleep(1);
     $CPU2 = $this->GetCPUUse();
     $data = $this->GetCPUPercent($CPU1, $CPU2);
     $this->CPU_Use = $data['cpu0']['user'] . "%us,  " . $data['cpu0']['sys'] . "%sy,  " . $data['cpu0']['nice'] . "%ni, " . $data['cpu0']['idle'] . "%id,  " . $data['cpu0']['iowait'] . "%wa,  " . $data['cpu0']['irq'] . "%irq,  " . $data['cpu0']['softirq'] . "%softirq";
     if (!$this->OS()) {
         $this->CPU_Use = '目前只支持Linux系统';
     }
     $this->hd = $this->GetDisk();
     $this->NetWork = $this->GetNetWork();
 }
Пример #11
0
 /**
  * Connect to the specified port. If called when the socket is
  * already connected, it disconnects and connects again.
  *
  * @param $addr string IP address or host name
  * @param $port int TCP port number
  * @param $persistent bool (optional) whether the connection is
  *        persistent (kept open between requests by the web server)
  * @param $timeout int (optional) how long to wait for data
  * @access public
  * @return mixed true on success or error object
  */
 function connect($addr, $port, $persistent = null, $timeout = null)
 {
     if (is_resource($this->fp)) {
         @fclose($this->fp);
         $this->fp = null;
     }
     if (strspn($addr, '.0123456789') == strlen($addr)) {
         $this->addr = $addr;
     } else {
         $this->addr = gethostbyname($addr);
     }
     $this->port = $port % 65536;
     if ($persistent !== null) {
         $this->persistent = $persistent;
     }
     if ($timeout !== null) {
         $this->timeout = $timeout;
     }
     $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
     $errno = 0;
     $errstr = '';
     if ($this->timeout) {
         $fp = $openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout);
     } else {
         $fp = $openfunc($this->addr, $this->port, $errno, $errstr);
     }
     if (!$fp) {
         return $this->raiseError($errstr, $errno);
     }
     $this->fp = $fp;
     return $this->setBlocking($this->blocking);
 }
Пример #12
0
 public function main()
 {
     //$upyun_img = $this->createImgUpYun();
     $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '服务器剩余空间' => round(disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO');
     $this->assign('info', $info);
     $this->display();
 }
Пример #13
0
 public function checktor($addr)
 {
     // Creates empty array.
     $flags = array();
     // Sets tor variable to no.
     $flags['tor'] = "no";
     // Breaks the IP string up into an array.
     $p = explode(".", $addr);
     // Checks whether the user uses the IPv6 addy.
     // Returns the flags array with the false variable.
     if (strpos($addr, ':') != -1) {
         return $flags;
     }
     // Generates a new host name by means of the IP array and TOR string.
     $ahbladdr = $p['3'] . "." . $p['2'] . "." . $p['1'] . "." . $p['0'] . "." . "tor.ahbl.org";
     // Get the IP address corresponding to a given host name.
     $ahbl = gethostbyname($ahbladdr);
     // In the returned IP adress is one of the following, it is from the TOR network.
     // There is then a yes flag assigned to the flag array.
     if ($ahbl == "127.0.0.2") {
         $flags['transit'] = "yes";
         $flags['tor'] = "yes";
     }
     if ($ahbl == "127.0.0.3") {
         $flags['exit'] = "yes";
         $flags['tor'] = "yes";
     }
     // The flags array are returned to the isTor method.
     return $flags;
 }
Пример #14
0
 /**
  * Retreive server information
  *
  * @return array
  */
  function oosGetSystemInformation() {

    // Get database information
    $dbconn =& oosDBGetConn();
    $oostable =& oosDBGetTables();

    $db_host = $dbconn->host;
    $db_database = $dbconn->database;
    $phpv = phpversion();


    $db_result = $dbconn->ServerInfo($oostable['countries']);

    list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);

    return array('date' => oos_datetime_short(date('Y-m-d H:i:s')),
                 'system' => $_ENV["OS"],
                 'kernel' => $kernel,
                 'host' => $host,
                 'ip' => gethostbyname($host),
                 'uptime' => @exec('uptime'),
                 'HTTP_SERVER' => $_SERVER['SERVER_SOFTWARE'],
                 'php' => $phpv,
                 'zend' => (function_exists('zend_version') ? zend_version() : ''),
                 'db_server' => $db_host,
                 'db_ip' => gethostbyname(OOS_DB_SERVER),
                 'db_version' => OOS_DB_TYPE . $db_result['description'],
                 'db_database' => $db_database);
  }
Пример #15
0
 function access_details()
 {
     $access_details = array();
     $access_details['domain'] = '';
     $access_details['ip'] = '';
     $access_details['directory'] = '';
     $access_details['server_hostname'] = '';
     $access_details['server_ip'] = '';
     if (function_exists('phpinfo')) {
         ob_start();
         phpinfo();
         $phpinfo = ob_get_contents();
         ob_end_clean();
         $list = strip_tags($phpinfo);
         $access_details['domain'] = $this->scrape_phpinfo($list, 'HTTP_HOST');
         $access_details['ip'] = $this->scrape_phpinfo($list, 'SERVER_ADDR');
         $access_details['directory'] = $this->scrape_phpinfo($list, 'SCRIPT_FILENAME');
         $access_details['server_hostname'] = $this->scrape_phpinfo($list, 'System');
         $access_details['server_ip'] = @gethostbyname($access_details['server_hostname']);
     }
     $access_details['domain'] = $access_details['domain'] ? $access_details['domain'] : $_SERVER['HTTP_HOST'];
     $access_details['ip'] = $access_details['ip'] ? $access_details['ip'] : $this->server_addr();
     $access_details['directory'] = $access_details['directory'] ? $access_details['directory'] : $this->path_translated();
     $access_details['server_hostname'] = $access_details['server_hostname'] ? $access_details['server_hostname'] : @gethostbyaddr($access_details['ip']);
     $access_details['server_hostname'] = $access_details['server_hostname'] ? $access_details['server_hostname'] : 'Unknown';
     $access_details['server_ip'] = $access_details['server_ip'] ? $access_details['server_ip'] : @gethostbyaddr($access_details['ip']);
     $access_details['server_ip'] = $access_details['server_ip'] ? $access_details['server_ip'] : 'Unknown';
     foreach ($access_details as $key => $value) {
         $access_details[$key] = $access_details[$key] ? $access_details[$key] : 'Unknown';
     }
     if ($this->valid_for_product_tiers) {
         $access_details['valid_for_product_tiers'] = $this->valid_for_product_tiers;
     }
     return $access_details;
 }
 public function __construct($logger, $debugHandler)
 {
     $this->logger = $logger;
     $this->debugHandler = $debugHandler;
     if (Settings::Get('system.nameservers') != '') {
         $nameservers = explode(',', Settings::Get('system.nameservers'));
         foreach ($nameservers as $nameserver) {
             $nameserver_ip = gethostbyname(trim($nameserver));
             if (substr($nameserver, -1, 1) != '.') {
                 $nameserver .= '.';
             }
             $this->nameservers[] = array('hostname' => trim($nameserver), 'ip' => trim($nameserver_ip));
         }
     }
     if (Settings::Get('system.mxservers') != '') {
         $mxservers = explode(',', Settings::Get('system.mxservers'));
         foreach ($mxservers as $mxserver) {
             if (substr($mxserver, -1, 1) != '.') {
                 $mxserver .= '.';
             }
             $this->mxservers[] = $mxserver;
         }
     }
     // AXFR server #100
     if (Settings::Get('system.axfrservers') != '') {
         $axfrservers = explode(',', Settings::Get('system.axfrservers'));
         foreach ($axfrservers as $axfrserver) {
             $this->axfrservers[] = trim($axfrserver);
         }
     }
 }
Пример #17
0
 public function __construct($host, $port)
 {
     $ipAddr = self::DEFAULT_IPADDR;
     if (false === ip2long($host)) {
         $ipAddr = gethostbyname($host);
     } else {
         $ipAddr = $host;
     }
     $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if (false === $socket) {
         throw new PhpBuf_RPC_Socket_Exception('socket creation fail:' . socket_strerror(socket_last_error()));
     }
     $connected = socket_connect($socket, $ipAddr, $port);
     if (false === $connected) {
         throw new PhpBuf_RPC_Socket_Exception('socket connection fail:' . socket_strerror(socket_last_error()));
     }
     socket_set_nonblock($socket);
     // socket_set_timeout($socket, 5);
     socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 5, 'usec' => 0));
     socket_set_option($socket, SOL_SOCKET, SO_LINGER, array('l_onoff' => 1, 'l_linger' => 1));
     socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
     socket_set_option($socket, SOL_SOCKET, SO_KEEPALIVE, 1);
     if (defined('TCP_NODELAY')) {
         socket_set_option($socket, SOL_SOCKET, TCP_NODELAY, 1);
     }
     $this->socket = $socket;
 }
Пример #18
0
function sendpacket($packet)
{
    global $myArgs, $proxy, $host, $pport, $port, $html, $proxy_regex;
    if (strcmp($myArgs["p"], "true") != 0) {
        $ock = fsockopen(gethostbyname($host), $port);
        if (!$ock) {
            echo "(-) No response from " . $host . ":" . $port;
            die;
        }
    } else {
        $c = preg_match($proxy_regex, $proxy);
        if (!$c) {
            echo "(-) Not a valid proxy...\n";
            die;
        }
        $ock = fsockopen($proxy, $pport);
        if (!$ock) {
            echo "(-) No response from proxy...";
            die;
        }
    }
    fputs($ock, $packet);
    if ($proxy == "") {
        $html = "";
        while (!feof($ock)) {
            $html .= fgets($ock);
        }
    } else {
        $html = "";
        while (!feof($ock) or !eregi(chr(0xd) . chr(0xa) . chr(0xd) . chr(0xa), $html)) {
            $html .= fread($ock, 1);
        }
    }
    fclose($ock);
}
Пример #19
0
 public function ip_addr()
 {
     if (!($result = getenv('SERVER_ADDR'))) {
         $result = gethostbyname($this->chostname());
     }
     return $result;
 }
Пример #20
0
 function getLocation($domainName)
 {
     $ipAddress = gethostbyname($domainName);
     $response = null;
     if ($ipAddress != $domainName) {
         $details_url = "http://ipinfo.io/" . gethostbyname($domainName);
         $response = json_decode(file_get_contents($details_url), true);
         //echo "ipinfo ";
         //var_dump($response);
     } else {
         //echo "domain does not exist";
     }
     if (!$response) {
         return array('lng' => null, 'lat' => null, 'address' => null);
     }
     $loc = explode(",", $response['loc']);
     $address = "";
     if ($response['org']) {
         $org = explode(" ", $response['org']);
         $org[0] = '';
         $org = implode(" ", $org);
         trim($org);
         $address = $org . ", ";
         if ($org) {
             $geo = $this->queryGeocode($org);
             if ($geo) {
                 return $geo;
             }
         }
     }
     $address .= isset($response['city']) ? $response['city'] . ", " : "";
     $address .= isset($response['region']) ? $response['region'] . ", " : "";
     $address .= isset($response['country']) ? $response['country'] : "";
     return ['lat' => $loc[0], 'lng' => $loc[1], 'address' => $address];
 }
function hal_parse($url)
{
    $url = trim(html_entity_decode($url), "\"' ");
    $infos = parse_url($url);
    $ip = gethostbyname($infos['host']);
    if ($ip != '193.48.96.10') {
        spip_log("Url invalid", _LOG_ERREUR);
        return;
    }
    spip_log(sprintf("[hal_parse] init_http(%s)", $url), _LOG_DEBUG);
    $content = recuperer_page($url);
    spip_log(sprintf("[hal_parse] init_http(%s): Done", $url), _LOG_DEBUG);
    $dom = new DomDocument('1.0', 'UTF-8');
    $dom->preserveWhiteSpace = false;
    $str = mb_convert_encoding($content, "HTML-ENTITIES");
    @$dom->loadHTML($str);
    $xpath = new DOMXpath($dom);
    $entries = $xpath->query('//div[@id="res_script"]');
    if ($entries->length == 0) {
        spip_log("No tag found ...", _LOG_ERREUR);
        return;
    }
    $res_script = $dom->saveXML($entries->item(0));
    return $res_script;
}
Пример #22
0
 public static function authorizeTestApiAccess()
 {
     if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] && $_SERVER['REMOTE_ADDR'] != gethostbyname($_SERVER['HTTP_HOST'])) {
         JSON::error('Access to test API denied', 403);
         exit;
     }
 }
Пример #23
0
 function get_mx($hostname)
 {
     if (strpos($hostname, '@')) {
         list($user, $hostname) = explode('@', $hostname);
     }
     // split hostname from email address
     if (function_exists('getmxrr')) {
         @getmxrr($hostname, $mxhosts, $mxweight);
     }
     // check for a true MX record
     if (isset($mxhosts) && !empty($mxhosts)) {
         return array_shift($mxhosts);
     } else {
         // RFC says use the A line if there is no MX
         $ip = gethostbyname($hostname);
         // get the ip from hostname
         if ($ip != $hostname) {
             // continue if returned ip not hostname
             $hostname = gethostbyaddr($ip);
             // get the rdns (real) hostname
             $ip = gethostbyname($hostname);
             // check the (real) hostname has an A record
             if ($ip != $hostname) {
                 return $hostname;
             }
             // return if returned ip not hostname
         }
     }
     // If all else fails...
     return $hostname;
 }
 public function index()
 {
     if (isset($_POST['config']) && isset($_POST['command_test'])) {
         $RESPONSE_END_TAG = "<END/>";
         $addr = gethostbyname("localhost");
         $client = stream_socket_client("tcp://{$addr}:2014", $errno, $errorMessage);
         if ($client === false) {
             throw new UnexpectedValueException("Failed to connect: {$errorMessage}");
         }
         $config = $_POST['config'];
         fwrite($client, 'test ' . $_POST['command_test'] . ' ' . $config);
         $server_response = stream_get_line($client, 1024, $RESPONSE_END_TAG);
         fclose($client);
         $response_code = substr($server_response, 0, 2);
         $server_response = substr($server_response, 3, strlen($server_response));
         $msg = '';
         $time = '';
         if ($response_code == 'OK') {
             $data = explode(') ', $server_response);
             $msg = str_replace('(', '', $data[0]) . '.';
             $time = str_replace(')', '', str_replace('(', '', $data[1])) . '.';
         } else {
             $msg = 'The following error occurred : ' . str_replace(')', '', str_replace('(', '', $server_response)) . '.';
         }
         header('Content-Type: application/json');
         echo json_encode(array('response' => nl2br($msg), 'others' => $time));
         //echo $msg."</br>".$time;
     } else {
         header('Content-Type: application/json');
         echo json_encode(array('response' => 'Missing parameters : Please fill all the required parameters ! ', 'others' => ''));
     }
 }
Пример #25
0
 public function connect($address = "", $port = "")
 {
     global $merchantAddress;
     if ($this->connected) {
         $this->close();
     }
     $a = Tools::address($merchantAddress);
     if (empty($port) || !is_integer($port)) {
         $port = intval($a['port']);
     }
     if (empty($address)) {
         $address = $a['address'];
     }
     $address = gethostbyname($address);
     $this->address = $address;
     $this->port = $port;
     $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if ($this->socket === false) {
         return false;
     }
     $result = socket_connect($this->socket, $this->address, $this->port);
     if ($result === false) {
         return false;
     }
     $this->connectmessage = @socket_read($this->socket, 1024 * 1024, PHP_NORMAL_READ);
     $this->connected = true;
     return true;
 }
Пример #26
0
 public static function find($ip)
 {
     if (empty($ip) === TRUE) {
         return 'N/A';
     }
     $nip = gethostbyname($ip);
     $ipdot = explode('.', $nip);
     if ($ipdot[0] < 0 || $ipdot[0] > 255 || count($ipdot) !== 4) {
         return 'N/A';
     }
     if (self::$fp === NULL) {
         self::init();
     }
     $nip2 = pack('N', ip2long($nip));
     $tmp_offset = (int) $ipdot[0] * 4;
     $start = unpack('Vlen', self::$index[$tmp_offset] . self::$index[$tmp_offset + 1] . self::$index[$tmp_offset + 2] . self::$index[$tmp_offset + 3]);
     $index_offset = $index_length = NULL;
     $max_comp_len = self::$offset['len'] - 1024 - 4;
     for ($start = $start['len'] * 8 + 1024; $start < $max_comp_len; $start += 8) {
         if (self::$index[$start] . self::$index[$start + 1] . self::$index[$start + 2] . self::$index[$start + 3] >= $nip2) {
             $index_offset = unpack('Vlen', self::$index[$start + 4] . self::$index[$start + 5] . self::$index[$start + 6] . "");
             $index_length = unpack('Clen', self::$index[$start + 7]);
             break;
         }
     }
     if ($index_offset === NULL) {
         return 'N/A';
     }
     fseek(self::$fp, self::$offset['len'] + $index_offset['len'] - 1024);
     $ret_arr = explode("\t", fread(self::$fp, $index_length['len']));
     return array('country' => $ret_arr[0], 'province' => $ret_arr[1], 'city' => $ret_arr[2]);
 }
Пример #27
0
 public function open($host, $port, $transport = 'tcp')
 {
     // if a socket is current open then close it
     $this->close();
     if (($ip = filter_var($host, FILTER_VALIDATE_IP)) !== false) {
         $this->host = $ip;
     } elseif (($ip = gethostbyname($host)) != $host) {
         $this->host = $ip;
     } else {
         throw new Exception('Unable to resolve host: ' . $host);
     }
     $this->port = filter_var($port, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 65535)));
     if (!$this->port) {
         throw new Exception('Invalid Port: ' . $port);
     }
     $err = 0;
     $msg = '';
     $this->stream = fsockopen("{$transport}://{$this->host}", $this->port, $err, $msg, $this->timeout);
     if (!$this->isOpen()) {
         throw new Exception("Unable to open socket: {$msg}", $err);
     }
     stream_set_timeout($this->stream, $this->timeout);
     stream_set_blocking($this->stream, $this->block);
     return $this;
 }
Пример #28
0
 /**
  * Constructor.
  *
  * @param string $host
  *  Host to connect to. Defaults to localhost (127.0.0.1)
  * @param integer $port
  *  When ssl is used, defaults to 465
  *  When no ssl is used, and ini_get returns no value, defaults to 25.
  * @param array $options
  *  Currently supports 3 values:
  *    $options['secure'] can be ssl, tls or null.
  *    $options['username'] the username used to login to the server. Leave empty for no authentication.
  *    $options['password'] the password used to login to the server. Leave empty for no authentication.
  *    $options['local_ip'] the ip address used in the ehlo/helo commands. Only ip's are accepted.
  * @throws SMTPException
  */
 public function __construct($host = '127.0.0.1', $port = null, $options = array())
 {
     if ($options['secure'] !== null) {
         switch (strtolower($options['secure'])) {
             case 'tls':
                 $this->_secure = 'tls';
                 break;
             case 'ssl':
                 $this->_transport = 'ssl';
                 $this->_secure = 'ssl';
                 if ($port == null) {
                     $port = 465;
                 }
                 break;
             case 'no':
                 break;
             default:
                 throw new SMTPException(__('Unsupported SSL type'));
         }
     }
     if (is_null($options['local_ip'])) {
         $this->_ip = gethostbyname(php_uname('n'));
     } else {
         $this->_ip = $options['local_ip'];
     }
     if ($port == null) {
         $port = 25;
     }
     if ($options['username'] !== null && $options['password'] !== null) {
         $this->_user = $options['username'];
         $this->_pass = $options['password'];
     }
     $this->_host = $host;
     $this->_port = $port;
 }
Пример #29
0
function discover_new_device($hostname, $device = '', $method = '', $interface = '')
{
    global $config;
    if (!empty($config['mydomain']) && isDomainResolves($hostname . '.' . $config['mydomain'])) {
        $dst_host = $hostname . '.' . $config['mydomain'];
    } else {
        $dst_host = $hostname;
    }
    d_echo("discovering {$dst_host}\n");
    $ip = gethostbyname($dst_host);
    if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
        // $ip isn't a valid IP so it must be a name.
        if ($ip == $dst_host) {
            d_echo("name lookup of {$dst_host} failed\n");
            log_event("{$method} discovery of " . $dst_host . " failed - Check name lookup", $device['device_id'], 'discovery');
            return false;
        }
    } elseif (filter_var($dst_host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === true || filter_var($dst_host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === true) {
        // gethostbyname returned a valid $ip, was $dst_host an IP?
        if ($config['discovery_by_ip'] === false) {
            d_echo('Discovery by IP disabled, skipping ' . $dst_host);
            log_event("{$method} discovery of " . $dst_host . " failed - Discovery by IP disabled", $device['device_id'], 'discovery');
            return false;
        }
    }
    d_echo("ip lookup result: {$ip}\n");
    $dst_host = rtrim($dst_host, '.');
    // remove trailing dot
    if (match_network($config['autodiscovery']['nets-exclude'], $ip)) {
        d_echo("{$ip} in an excluded network - skipping\n");
        return false;
    }
    if (match_network($config['nets'], $ip)) {
        try {
            $remote_device_id = addHost($dst_host, '', '161', 'udp', $config['distributed_poller_group']);
            $remote_device = device_by_id_cache($remote_device_id, 1);
            echo '+[' . $remote_device['hostname'] . '(' . $remote_device['device_id'] . ')]';
            discover_device($remote_device);
            device_by_id_cache($remote_device_id, 1);
            if ($remote_device_id && is_array($device) && !empty($method)) {
                $extra_log = '';
                $int = ifNameDescr($interface);
                if (is_array($int)) {
                    $extra_log = ' (port ' . $int['label'] . ') ';
                }
                log_event('Device ' . $remote_device['hostname'] . " ({$ip}) {$extra_log} autodiscovered through {$method} on " . $device['hostname'], $remote_device_id, 'discovery');
            } else {
                log_event("{$method} discovery of " . $remote_device['hostname'] . " ({$ip}) failed - Check ping and SNMP access", $device['device_id'], 'discovery');
            }
            return $remote_device_id;
        } catch (HostExistsException $e) {
            // already have this device
        } catch (Exception $e) {
            log_event("{$method} discovery of " . $dst_host . " ({$ip}) failed - " . $e->getMessage());
        }
    } else {
        d_echo("{$ip} not in a matched network - skipping\n");
    }
    //end if
}
Пример #30
-1
function sendUSD($text, $pass_server = '000000')
{
    $address = gethostbyname('127.0.0.1');
    //IP Адрес вашего компьютера
    $service_port = 8000;
    //Порт
    //$pass_server='000000'; //Пароль
    $phone = preg_replace('/^\\+/', '', $phone);
    $socket = socket_create(AF_INET, SOCK_STREAM, 0);
    if ($socket < 0) {
        echo "socket create failed reason: " . socket_strerror($socket) . "\n";
    }
    $result = socket_connect($socket, $address, $service_port);
    if ($result < 0) {
        echo "socket connect failed.\nReason: ({$result}) " . socket_strerror($result) . "\n";
    }
    $text = iconv("UTF-8", "Windows-1251", $text);
    $in = base64_encode($pass_server . "#CMD#[USSD]" . $text);
    //Пример отправки смс
    //$in = base64_encode($pass_server."#CMD#[USSD]*102#"); //Пример запроса USSD команды
    $out = '';
    socket_write($socket, $in, strlen($in));
    //echo "Response:\n\n";
    $res = '';
    while ($out = socket_read($socket, 2048)) {
        $res .= $out;
    }
    socket_close($socket);
    $res = iconv("Windows-1251", "UTF-8", $res);
    if (preg_match('/USSD-RESPONSE\\[.+?\\]:(.+)/is', $res, $m)) {
        $res = $m[1];
    }
    return $res;
}