取得随机字符串 getcode($length, $mode);*/class activecodeobj{function getcode ($length = 32, $mode = 0){switch ($mode) {case '1':$str = '1234567890';break;case '2':$str = 'abcdefghijklmnopqrstuvwxyz';break;case '3':$str = 'abcdefghijklmnopqrstuvwxyz';break;case '4':$str = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';break;case '5':$str = 'abcdefghijklmnopqrstuvwxyz1234567890';break;case '6':$str = 'abcdefghijklmnopqrstuvwxyz1234567890';break;default:$str = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1234567890';break;}$result = '';$l = strlen($str);for($i = 0;$i $num = rand(0, $l);$result .= $str[$num];}return $result;}}取得客户端信息/*作用:取得客户端信息参数:返回:指定的资料使用:$code = new clientgetobj;1、浏览器:$str = $code->getbrowse();2、ip地址:$str = $code->getip();4、操作系统:$str = $code->getos();*/class clientgetobj{function getbrowse(){global $_server;$agent = $_server['http_user_agent'];$browser = '';$browserver = '';$browser = array('lynx', 'mosaic', 'aol', 'opera', 'java', 'macweb', 'webexplorer', 'omniweb');for($i = 0; $i if(strpos($agent, $browsers[$i])){$browser = $browsers[$i];$browserver = '';}}if(ereg('mozilla', $agent) && !ereg('msie', $agent)){$temp = explode('(', $agent);$part = $temp[0];$temp = explode('/', $part);$browserver = $temp[1];$temp = explode(' ', $browserver);$browserver = $temp[0];$browserver = preg_replace('/([d.]+)/', '\1', $browserver);$browserver = $browserver;$browser = 'netscape navigator';}if(ereg('mozilla', $agent) && ereg('opera', $agent)) {$temp = explode('(', $agent);$part = $temp[1];$temp = explode(')', $part);$browserver = $temp[1];$temp = explode(' ', $browserver);$browserver = $temp[2];$browserver = preg_replace('/([d.]+)/', '\1', $browserver);$browserver = $browserver;$browser = 'opera';}if(ereg('mozilla', $agent) && ereg('msie', $agent)){$temp = explode('(', $agent);$part = $temp[1];$temp = explode(';', $part);$part = $temp[1];$temp = explode(' ', $part);$browserver = $temp[2];$browserver = preg_replace('/([d.]+)/','\1',$browserver);$browserver = $browserver;$browser = 'internet explorer';}if($browser != ''){$browseinfo = $browser.' '.$browserver;} else {$browseinfo = false;}return $browseinfo;}function getip (){global $_server;if (getenv('http_client_ip')) {$ip = getenv('http_client_ip');} else if (getenv('http_x_forwarded_for')) {$ip = getenv('http_x_forwarded_for');} else if (getenv('remote_addr')) {$ip = getenv('remote_addr');} else {$ip = $_server['remote_addr'];}return $ip;}function getos (){global $_server;$agent = $_server['http_user_agent'];$os = false;if (eregi('win', $agent) && strpos($agent, '95')){$os = 'windows 95';}else if (eregi('win 9x', $agent) && strpos($agent, '4.90')){$os = 'windows me';}else if (eregi('win', $agent) && ereg('98', $agent)){$os = 'windows 98';}else if (eregi('win', $agent) && eregi('nt 5.1', $agent)){$os = 'windows xp';}else if (eregi('win', $agent) && eregi('nt 5', $agent)){$os = 'windows 2000';}else if (eregi('win', $agent) && eregi('nt', $agent)){$os = 'windows nt';}else if (eregi('win', $agent) && ereg('32', $agent)){$os = 'windows 32';}else if (eregi('linux', $agent)){$os = 'linux';}else if (eregi('unix', $agent)){$os = 'unix';}else if (eregi('sun', $agent) && eregi('os', $agent)){$os = 'sunos';}else if (eregi('ibm', $agent) && eregi('os', $agent)){$os = 'ibm os/2';}else if (eregi('mac', $agent) && eregi('pc', $agent)){$os = 'macintosh';}else if (eregi('powerpc', $agent)){$os = 'powerpc';}else if (eregi('aix', $agent)){$os = 'aix';}else if (eregi('hpux', $agent)){$os = 'hpux';}else if (eregi('netbsd', $agent)){$os = 'netbsd';}else if (eregi('bsd', $agent)){$os = 'bsd';}else if (ereg('osf1', $agent)){$os = 'osf1';}else if (ereg('irix', $agent)){$os = 'irix';}else if (eregi('freebsd', $agent)){$os = 'freebsd';}else if (eregi('teleport', $agent)){$os = 'teleport';}else if (eregi('flashget', $agent)){$os = 'flashget';}else if (eregi('webzip', $agent)){$os = 'webzip';}else if (eregi('offline', $agent)){$os = 'offline';}else {$os = 'unknown';}return $os;}}//修改自q3boyclass cnstrobj{function substrgb ($str = '', $start = '', $len = ''){if($start == 0 || $start == ''){$start = 1;}if($str == '' || $len == ''){return false;}for($i = 0; $i $tmpstr = (ord($str[$i]) >= 161 && ord($str[$i]) = 161 && ord($str[$i+1]) if ($i >= $start && $i {$tmp .=$tmpstr;}}return $tmp;}function isgb ($str){$strlen = strlen($str);$length = 1;for($i = 0; $i $tmpstr = ord(substr($str, $i, 1));$tmpstr2 = ord(substr($str, $i+1, 1));if(($tmpstr = 247) && ($tmpstr2 = 247)){$legalflag = false;} else {$legalflag = true;}}return $legalflag;}}//下载自某e文网站/***************************************** filename.......: class.smtp.inc** project........: smtp class** version........: 1.00b** last modified..: 30 september 2001***************************************/define('smtp_status_not_connected', 1, true);define('smtp_status_connected', 2, true);class smtp{var $connection;var $recipients;var $headers;var $timeout;var $errors;var $status;var $body;var $from;var $host;var $port;var $helo;var $auth;var $user;var $pass;/***************************************** constructor function. arguments:** $params - an assoc array of parameters:**** host - the hostname of the smtp server default: localhost** port - the port the smtp server runs on default: 25** helo - what to send as the helo command default: localhost** (typically the hostname of the** machine this script runs on)** auth - whether to use basic authentication default: false** user - username for authentication default: ** pass - password for authentication default: ** timeout - the timeout in seconds for the call default: 5** to fsockopen()***************************************/function smtp($params = array()){if(!defined('crlf'))define('crlf', \r\n, true);$this->timeout = 5;$this->status = smtp_status_not_connected;$this->host = 'localhost';$this->port = 25;$this->helo = 'localhost';$this->auth = false;$this->user = '';$this->pass = '';$this->errors = array();foreach($params as $key => $value){$this->$key = $value;}}/***************************************** connect function. this will, when called** statically, create a new smtp object,** call the connect function (ie this function)** and return it. when not called statically,** it will connect to the server and send** the helo command.***************************************/function connect($params = array()){if(!isset($this->status)){$obj = new smtp($params);if($obj->connect()){$obj->status = smtp_status_connected;}return $obj;}else{$this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);socket_set_timeout($this->connection, 0, 250000);$greeting = $this->get_data();if(is_resource($this->connection)){return $this->auth ? $this->ehlo() : $this->helo();}else{$this->errors[] = 'failed to connect to server: '.$errstr;return false;}}}/***************************************** function which handles sending the mail.** arguments:** $params - optional assoc array of parameters.** can contain:** recipients - indexed array of recipients** from - the from address. (used in mail from,** this will be the return path** headers - indexed array of headers, one header per array entry** body - the body of the email** it can also contain any of the parameters from the connect()** function***************************************/function send($params = array()){foreach($params as $key => $value){$this->set($key, $value);}if($this->is_connected()){// do we auth or not? note the distinction between the auth variable and auth() functionif($this->auth){if(!$this->auth())return false;}$this->mail($this->from);if(is_array($this->recipients))foreach($this->recipients as $value)$this->rcpt($value);else$this->rcpt($this->recipients);if(!$this->data())return false;// transparency$headers = str_replace(crlf.'.', crlf.'..', trim(implode(crlf, $this->headers)));$body = str_replace(crlf.'.', crlf.'..', $this->body);$body = $body[0] == '.' ? '.'.$body : $body;$this->send_data($headers);$this->send_data('');$this->send_data($body);$this->send_data('.');return (substr(trim($this->get_data()), 0, 3) === '250');}else{$this->errors[] = 'not connected!';return false;}}/***************************************** function to implement helo cmd***************************************/function helo(){if(is_resource($this->connection)and $this->send_data('helo '.$this->helo)and substr(trim($error = $this->get_data()), 0, 3) === '250' ){return true;}else{$this->errors[] = 'helo command failed, output: ' . trim(substr(trim($error),3));return false;}}/***************************************** function to implement ehlo cmd***************************************/function ehlo(){if(is_resource($this->connection)and $this->send_data('ehlo '.$this->helo)and substr(trim($error = $this->get_data()), 0, 3) === '250' ){return true;}else{$this->errors[] = 'ehlo command failed, output: ' . trim(substr(trim($error),3));return false;}}/***************************************** function to implement auth cmd***************************************/function auth(){if(is_resource($this->connection)and $this->send_data('auth login')and substr(trim($error = $this->get_data()), 0, 3) === '334'and $this->send_data(base64_encode($this->user)) // send usernameand substr(trim($error = $this->get_data()),0,3) === '334'and $this->send_data(base64_encode($this->pass)) // send passwordand substr(trim($error = $this->get_data()),0,3) === '235' ){return true;}else{$this->errors[] = 'auth command failed: ' . trim(substr(trim($error),3));return false;}}/***************************************** function that handles the mail from: cmd***************************************/function mail($from){if($this->is_connected()and $this->send_data('mail from:')and substr(trim($this->get_data()), 0, 2) === '250' ){return true;}elsereturn false;}/***************************************** function that handles the rcpt to: cmd***************************************/function rcpt($to){if($this->is_connected()and $this->send_data('rcpt to:')and substr(trim($error = $this->get_data()), 0, 2) === '25' ){return true;}else{$this->errors[] = trim(substr(trim($error), 3));return false;}}/***************************************** function that sends the data cmd***************************************/function data(){if($this->is_connected()and $this->send_data('data')and substr(trim($error = $this->get_data()), 0, 3) === '354' ){return true;}else{$this->errors[] = trim(substr(trim($error), 3));return false;}}/***************************************** function to determine if this object** is connected to the server or not.***************************************/function is_connected(){return (is_resource($this->connection) and ($this->status === smtp_status_connected));}/***************************************** function to send a bit of data***************************************/function send_data($data){if(is_resource($this->connection)){return fwrite($this->connection, $data.crlf, strlen($data)+2);}elsereturn false;}/***************************************** function to get data.***************************************/function &get_data(){$return = '';$line = '';if(is_resource($this->connection)){while(strpos($return, crlf) === false or substr($line,3,1) !== ' '){$line = fgets($this->connection, 512);$return .= $line;}return $return;}elsereturn false;}/***************************************** sets a variable***************************************/function set($var, $value){$this->$var = $value;return true;}} // end of class?>
复制代码