IPwhois查询,域名whois查询

 更新时间:2016年11月25日 15:58  点击:2249

<div  class=contentbox>
<div class="content_nav"><span class="tt">IP/域名WHOIS查询</span></div>
<div class=toolitem>
<br>
<form action="" method="get">
IP/域名:<input style="height:26px;border: 1px solid rgb(126, 157, 185); background-color: white;" id="query" maxlength="100" size="44" name="q" autocomplete="off" type="text" value="<?php教程 echo $q; ?>">
<span class="backgroundbord"><button class="srh_onesearch" type="submit">查      询</button></span>
</form>
</div>
</div>
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/ad/mid.php';
if($q2<>''){
 if($isdomain){
  echo '<div class=contentbox>';
  echo '<div class="content_nav"><span class="tt">查询结果</span></div>';
  echo '<div class=topmenuitem>';
  // Server List File
  $config['server_list'] = "./whois/servers.lst";
  whois($domain);
  echo '</div>';
  echo '</div>';
 }elseif($isip){
  echo '<div class=contentbox>';
  echo '<div class="content_nav"><span class="tt">查询结果</span></div>';
  echo '<div class=topmenuitem>';
  $sourcecode=getsourcecode("http://wq.apnic.net/apnic-bin/whois.pl?searchtext=".$q);
  //echo $sourcecode;
  preg_match('/(<pre><b><u>.*?)<div class="highlight" id="key">/s', $sourcecode, $ipwhois);
  $result=$ipwhois[1];
  $result=nl2br($result);
  echo $result;
  echo '</div>';
  echo '</div>';
 }else{
  echo '<div class=contentbox>';
  echo '<div class="content_nav"><span class="tt">Error!</span></div>';
  echo '<div class=topmenuitem><p><font color=red>Error!</font>请确保你输入的不是域名(中文域名暂不支持)就是IP,你要是输入的是电话号码之类那我们真查不了!</p>';
  echo '</div>';
  echo '</div>';
 }
}else{
  echo '<div class=contentbox>';
  echo '<div class="content_nav"><span class="tt">工具说明</span></div>';
  echo '<div class=topmenuitem><p>请输入IP或域名,如chaxun.la或xxx.xxx.xxx.xxx</p>';
  echo '</div>';
  echo '</div>';
}
function whois() {
 global $domain;
 if(!$server = get_server()) {
  die("无法查询此类型的域名");
 }
  $result = whois_request($server['server'], $domain);
  if(!$result) {
   echo "无法连接服务器";
   die();
  }
  $server['info']=trim($server['info']);
  if($server['info']){
   $he = strpos($result,$server['info']) + strlen($server['info']);
   $le = strpos($result, " ", $he);
   $whois_server = trim(substr($result, $he, $le-$he));
   $result2 = whois_request($whois_server, $domain);
   if($result2){
    echo nl2br($result." 以下信息来自:".$whois_server." ".$result2);
   }else {
    echo nl2br($result);
   }
  }else {
   echo nl2br($result);
  }
}
/*function whois() {
 global $domain;
 if(!$server = get_server()) {
  echo "无法查询此类型的域名";
 }else{
  $result = whois_request($server['server'], $domain);
  if(!$result) {
   echo "无法连接服务器";
  } else {
   echo $result;
  }
 }
}
*/
function whois_request($server, $query)
{
    $data = "";
 if(!$fp = @fsockopen($server, 43)) {
  Return false;
 } else {
  fputs($fp, $query . " ");
        while (!feof($fp)) {
            $data .= fread($fp, 1000);
        }
        fclose($fp);
 }
    //return nl2br($data);
 return $data;
}

function get_server() {
 global $config,$domain;
 $serverarray = file($config['server_list']);
 $i = 0;
 foreach($serverarray as $key=>$val) {
  if(substr($val,0,1) != "#") {
   $server_p = explode("|",$val);
   $server[$i]['tld'] = $server_p[0];
   $server[$i]['server'] = $server_p[1];
   $server[$i]['avail'] = $server_p[2];
   $server[$i]['infoserver'] = $server_p[3];
   $server[$i]['backserver'] = $server_p[4];
   $server[$i]['info'] = $server_p[5];
  }
  $i++;
 }

 $domain_c = explode(".",$domain);
 $partnum = count($domain_c);
 $last_part_1 = $domain_c[$partnum-1];
 $last_part_2 = $domain_c[$partnum-2];
 
 foreach($server as $key=>$val) {
  if($val['tld'] == $last_part_2.".".$last_part_1) {
   Return $val;
  } elseif($val['tld'] == $last_part_1) {
   Return $val;
  }
 }
 Return false;
}

$q=trim($_GET['q']);
$q2=$q;
if($q<>''){
if($q=matchip($q2)){
  $isip=1;
 }elseif($q=matchdomain($q2)){
  $domain=topdomain($q2);
  $isdomain=1;
 }
}IPwhois查询,域名whois查询

$q=trim($_GET['q']);
$sd=(int)trim($_GET['sd']);
$t=(int)trim($_GET['t']);
if(strstr($q, " ")){
 $isulist=1;
 $ulist=explode(" ",$q);
 for($i=0;$i<count($ulist);$i++){
  $domain='';
  $domain=matchdomain($ulist[$i]);
  if($domain<>''){
   $q2.=$domain." ";
  }
 }
 $ulist=explode(" ",$q2);
}else{
$q2=matchdomain($q);
}

<div  class=contentbox>
<div class="content_nav"><span class="tt">Google PageRank查询</span></div>
<div class=toolitem>
<br><form action="" method="get">
<table style="vertical-align:middle;"><tr><td>
域名:</td><td><textarea rows="5" cols="40" style="border: 1px solid rgb(126, 157, 185); background-color: white;" id="query"  name="q" autocomplete="off" type="text">
<?php教程
if($q2<>""){
 echo $q2;
}else{
echo "www.111cn.net tool.111cn.net down.111cn.net baidu.com google.com";
}
?>
</textarea>
</td><td>
<input type="checkbox" name="sd" value="1"
<?php if($sd==1){ echo 'checked="checked"';} ?>
/> 查询二级域名PR
<br><input type="checkbox" name="t" value="1"
<?php if($t==1){ echo 'checked="checked"';} ?>
/> 鉴别真假
</td><td>
 <span class="backgroundbord"><button class="srh_onesearch" type="submit">查      询</button></span>
</td></table>
</form>
</div>
</div>
<?php
require_once '../ad/mid.php';
if($q2==''){
?>
<div class=contentbox>
<div class="content_nav"><span class="tt">工具说明</span></div>
<div class=topmenuitem>
<p>请输入域名,如chaxun.la。<br>多域名查询请每行输入一个域名,域名没有个数限制!<br><font color=red>查询二级域名PR:</font>将查询该域名的二级域名的PR。(二级域名通过查询本站数据库教程获得,并不全面!)<br><font color=red>鉴别真假:</font>将鉴别该域名的PR是否是劫持其它网站的PR。</p>
</div>
</div>

<?php
}else{
 echo "<div class=contentbox>";
 echo '<div class="content_nav"><span class="tt">查询结果</span></div>';
 echo "<div class=topmenuitem>";
   echo '<span style="width=200px;text-align:right;padding-right:50px;">域名</span><span class="span_iframe">PR</span>';
   if($t){ echo '<span class="span_iframe_pr">鉴别真假</span>';}
   echo '<br>';
 if($isulist){
  for($jj=0;$jj<count($ulist)-1;$jj++){
  $ch=get_pagerank('http://'.$ulist[$jj]);
   echo '<span style="width=200px;text-align:right;padding-bottom:6px;"><a target="_blank" href="http://'.$ulist[$jj].'"><font color=red>'.$ulist[$jj].'</font></a>:</span><span class="span_iframe"><iframe src="http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;937&ie=UTF-8&oe=UTF-8&features=Rank&ch='.$ch.'&q=info:'.$ulist[$jj].'" width="82" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" class="iframe"></iframe></span>';
   if($t){ echo '<span class="span_iframe_pr"><iframe src="tfpr.php?q='.$ulist[$jj].'" width="500" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0"></iframe></span>';}
   echo '<br>';
   if($sd){
   //从数据库读取此域名的二级域名
    $topdomain=topdomain($ulist[$jj]);
    $sql="select domain from c_domainlist where topdomain='$topdomain' and domain<>'$ulist[$jj]' order by domain";
    $result=mysql教程_query($sql);
    //or die(mysql_error());
    while($row=mysql_fetch_array($result)){
     $ch=get_pagerank('http://'.$row['domain']);
    echo '<span style="width=200px;text-align:right;padding-bottom:6px;"><a target="_blank" href="http://'.$row['domain'].'">'.$row['domain'].'</a>:</span><span class="span_iframe"><iframe src="http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;937&ie=UTF-8&oe=UTF-8&features=Rank&ch='.$ch.'&q=info:'.$row['domain'].'" width="82" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" class="iframe"></iframe></span>';
    if($t){ echo '<span class="span_iframe_pr"><iframe src="tfpr.php?q='.$row['domain'].'" width="500" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0"></iframe></span>';}
    echo '<br>';
    }
   }
  }
 }else{
   $ch=get_pagerank('http://'.$q2);
   echo '<span style="width=200px;text-align:right;padding-bottom:6px;"><a target="_blank" href="http://'.$q2.'"><font color=red>'.$q2.'</font></a>:</span><span class="span_iframe"><iframe src="http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;937&ie=UTF-8&oe=UTF-8&features=Rank&ch='.$ch.'&q=info:'.$q2.'" width="82" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" class="iframe"></iframe></span>';
   if($t){ echo '<span class="span_iframe_pr"><iframe src="tfpr.php?q='.$q2.'" width="500" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0"></iframe></span>';}
    echo '<br>';
   if($sd){
   //从数据库读取此域名的二级域名
    $topdomain=topdomain($q2);
    $sql="select domain from c_domainlist where topdomain='$topdomain' and domain<>'$q2' order by domain";
    $result=mysql_query($sql);
    //or die(mysql_error());
    while($row=mysql_fetch_array($result)){
     $ch=get_pagerank('http://'.$row['domain']);
    echo '<span style="width=200px;text-align:right;padding-bottom:6px;"><a target="_blank" href="http://'.$row['domain'].'">'.$row['domain'].'</a>:</span><span class="span_iframe"><iframe src="http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;937&ie=UTF-8&oe=UTF-8&features=Rank&ch='.$ch.'&q=info:'.$row['domain'].'" width="82" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" class="iframe"></iframe></span>';
    if($t){ echo '<span class="span_iframe_pr"><iframe src="tfpr.php?q='.$row['domain'].'" width="500" height="20" scrolling="no" marginheight="0" marginwidth="0" frameborder="0"></iframe></span>';}
    echo '<br>';
    }
   }
  }
echo "</div></div>";
}
function get_pagerank($permalink){
 $gpr = new PageRank();
 return $gpr->ch("$permalink");
}

class PageRank{
// 7/25/2008 - Updated by Askie (http://www.pkphp.com/)
// 3/20/2008 - Updated by Roger Collins (http://www.rogercollins.com/)
// to remove graphing step

//PageRank Lookup v1.1 by HM2K (update: 31/01/07)
//based on an alogoritham found here: http://pagerank.gamesaga.net/

 //settings - host and user agent
 var $googlehost='toolbarqueries.google.com';
 var $googleua='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5';

 //convert a string to a 32-bit integer
 function StrToNum($Str, $Check, $Magic) {
     $Int32Unit = 4294967296;  // 2^32

     $length = strlen($Str);
     for ($i = 0; $i < $length; $i++) {
         $Check *= $Magic;    
         //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31),
         //  the result of converting to integer is undefined
         //  refer to http://www.php.net/manual/en/language.types.integer.php
         if ($Check >= $Int32Unit) {
             $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
             //if the check less than -2^31
             $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
         }
         $Check += ord($Str{$i});
     }
     return $Check;
 }

 //genearate a hash for a url
 function HashURL($String) {
     $Check1 = $this->StrToNum($String, 0x1505, 0x21);
     $Check2 = $this->StrToNum($String, 0, 0x1003F);

     $Check1 >>= 2;    
     $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
     $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
     $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);   
    
     $T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
     $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
    
     return ($T1 | $T2);
 }

 //genearate a checksum for the hash string
 function CheckHash($Hashnum) {
     $CheckByte = 0;
     $Flag = 0;

     $HashStr = sprintf('%u', $Hashnum) ;
     $length = strlen($HashStr);
    
     for ($i = $length - 1;  $i >= 0;  $i --) {
         $Re = $HashStr{$i};
         if (1 === ($Flag % 2)) {             
             $Re += $Re;    
             $Re = (int)($Re / 10) + ($Re % 10);
         }
         $CheckByte += $Re;
         $Flag ++;   
     }

     $CheckByte %= 10;
     if (0 !== $CheckByte) {
         $CheckByte = 10 - $CheckByte;
         if (1 === ($Flag % 2) ) {
             if (1 === ($CheckByte % 2)) {
                 $CheckByte += 9;
             }
             $CheckByte >>= 1;
         }
     }

     return '7'.$CheckByte.$HashStr;
 }

 //return the pagerank checksum hash
 function getch($url) { return $this->CheckHash($this->HashURL($url)); }

 //return the pagerank figure
 function ch($url){
  $urlinfo=parse_url($url);
     $start=$urlinfo["scheme"]<>""?strlen($urlinfo["scheme"]."://"):0;
  $url=substr($url,$start);
  
  $pr = 0;    // default return
     $ch = $this->getch($url);
  return $ch;
 }
}

$q=trim($_GET['q']);
//for($i=0;$i<5;$i++){
$pagecode = @file_get_contents("http://www.google.cn/search?q=info:".$q);
 //   if($pagecode){
// break;
// }
//}
    if($pagecode){
  preg_match('/<cite>(.*?)//', $pagecode, $googlepr);
  if($q==$googlepr[1] or strstr($googlepr[1], '.'.$q) or strstr($q, '.'.$googlepr[1])){
   echo '<font style="color:green;font-weight:bold;">√</font>';
  }elseif($q<>$googlepr[1] and $googlepr[1]<>''){
   echo '<font style="color:red;font-weight:bold;">×</font>,此网站可能劫持'.$googlepr[1].'的PR!';
  }elseif($googlepr[1]==''){
   echo '在Google搜索info:'.$q.'无信息!';
  }
 }else{
 echo "获取Google信息失败!"; 
 }

class deleteFile{
 public $dir ='111cnnet/';
 
 function deldir($this->dir)
 {
  if(is_dir($dir))
  {
   $rdir = $dir;
   if($dirlist = scandir($rdir))
   {
    array_shift($dirlist);
    array_shift($dirlist);
    foreach($dirlist as $d){
     $rd = $rdir.'/'.$d;
     if(isset($d) && is_file($rd)){ 
      unlink($rd);
     }else{
      $this->deldir($rd);
     }
    }  
    rmdir($rdir);
   }else{
    return false;
   }
  }
     return true;
 }  
}
//使用方法
$delete = $this->deleteFile();

<?php
$action = $_GET['action'];
require_once('auc.main.class.inc.php');

$auc = new auc();

if ($action == 'uploadfile') {
 $auc = new auc();
 
 $result = $auc->upload("file");
 if (is_array($result)) {
  echo 'Something Went Wrong';
  echo '<pre>';
  var_dump($result);
  echo '</pre>';
 } else {
  echo 'All OK';
 }
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>advanced Upload Class - Demo</title>
</head>
<body>
<form action="auc.demo.php?action=uploadfile" method="post" enctype="multipart/form-data">
  <input name="file[]" type="file" /><br />
  <input name="file[]" type="file" /><br />
  <input name="upload" type="submit" value="Upload File" />
</form>
</body>
</html>
<?php  } ?>

类文件

<?php

class auc {
 public $errors = array(); //array used to store any errors that occur.
 public $upload_dir = ''; //the upload_dir being used by the script
 public $make_safe = false; //default don't modify the file name to safe version
 public $max_file_size = 1048576; //Max File Size in Bytes, 1MB
 public $overwrite = false; //default don't overwrite files that already exsist
 public $check_file_type = false; //don't check for file type by default but can check for allowed and denied files.
 public $allowed_mime_types = array('image/jpeg', 'image/png', 'image/gif', 'image/tiff'); //array of allowed mime types used when check_file_type is set to allowed
 public $denied_mime_types = array('application/x-php', 'text/html'); //array of denied mime types used when check_file_type is set to denied
 
 /**
  * Check if the upload dir is valid, if it is not valid attempt to make the dir, if dir is succesfully created chmod it to 0777.
  * If any elments fail return false else set upload_dir and return true.
  * @param string $dir
  * @param boolean $mkdir
  * @return true or false
  */
 public function upload_dir($dir, $mkdir = false) {
  $errors =& $this->errors;
  $status = true;
  
  if (!is_dir($dir)) {
   if ($mkdir) {
    if (!mkdir($dir)) {
     $status = false;
    } else {
     if (!chmod($dir, 0777)) $status = false;
    }
   } else {
    $status = false;
   }
  }
  
  if ($status) {
   $this->upload_dir = $dir;
   return true;
  } else {
   $errors['general'][] = 'Upload Dir is Not Valid and/or a dir could not be created/chmod.';
   return false;
  }
 }
 
 /**
  * check that the upload dir is valid and that it is writeable
  *
  * @param string $dir
  * @return true or false
  */
 public function check_dir($dir) {
  if (!is_dir($dir) || !is_writable($dir)) return false;
  
  return true;
 }
 

 /**
  * make the uploaded file name safe
  *
  * @param string $file_name
  * @return safe file name
  */
 public function make_safe($file_name) {
  return str_replace(' ', '_', $file_name);
 }
  
 /**
  * Check the Attemted Uploads for errors etc if everything goes good move the file, to the upload_dir.
  *
  * @param array $object
  * @return unknown
  */
 public function upload($object) {
  $errors =& $this->errors;
  
  if (empty($errors['general'])) {
   if (empty($this->upload_dir)) $this->upload_dir = dirname(__FILE__).'/'; //if no default upload_dir has been specified used the current dir.
     
   if ($this->check_dir($this->upload_dir)) {
    $files = $_FILES[$object];
    $count = count($files['name']) - 1;
    
    echo '<pre>';
    var_dump($files);
    echo '</pre>';
    
    for ($current = 0; $current <= $count; $current++) {
     $error = '';
     try {
      //check for $_FILES Errors
      switch ($files['error'][$current]) {
       case 0 : break;
       case 1 : $error = $files['name'][$current].' exceeds the upload_max_filesize directive in php.ini'; break;
       case 2 : $error = $files['name'][$current].' exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; break;
       case 3 : $error = $files['name'][$current].' was only partially uploaded'; break;
       case 4 : $error = 'No file was uploaded'; break;
       case 6 : $error = 'Missing a temporary folder'; break;
       case 7 : $error = 'Failed to write '.$files['name'][$current].' to disk'; break;
       case 8 : $error = $files['name'][$current].' stopped by extension'; break;
       default : $error = 'Unidentified Error, caused by '.$files['name'][$current]; break;
      }
      if ($error)
       throw new TrigerErrorException($error, $files['name'][$current]);
      
      //check that the file is not empty
      if ($files['size'][$current] <= 0)
       throw new TrigerErrorException($files['name'][$current].' is empty', $files['name'][$current]);
      
      //check that the file does not exceed the defined max_file_size
      if ($this->max_file_size) {
       if ($files['size'][$current] >= $this->max_file_size)
        throw new TrigerErrorException($files['name'][$current].' exceeds defined max_file_size', $files['name'][$current]);
      }
      
      if ($this->check_file_type == 'allowed' && !in_array($files['type'][$current], $this->allowed_mime_types)) {
       throw new TrigerErrorException($files['name'][$current].' is not an allowed type', $files['name'][$current]);
      } elseif ($this->check_file_type == 'denied' && in_array($files['type'][$current], $this->denied_mime_types)) {
       throw new TrigerErrorException($files['name'][$current].' is a denied type', $files['name'][$current]);
      }
      
      //if make_safe is true call make safe function  
      if ($this->make_safe)
       $files['name'][$current] = $this->make_safe($files['name'][$current]);
      
      //if overwrite is false and the file exists error
      if (!$this->overwrite && file_exists($this->upload_dir.$files['name'][$current]))
       throw new TrigerErrorException($files['name'][$current].' already exsists', $files['name'][$current]);
       
      //move the uploaded file, error if anything goes wrong.
      if (!move_uploaded_file($files['tmp_name'][$current], $this->upload_dir.$files['name'][$current]))
       throw new TrigerErrorException($files['name'][$current].' could not be moved', $files['name'][$current]);
     } catch (TrigerErrorException $e) {
      $errors[$files['name'][$current]][] = $e->Message();
     }
    }
    
    if (empty($errors)) {
     //return true if there where no errors
     return true;
    } else {
     //return the errors array if there where any errros
     return $errors;
    }
   } else {
    //return false as dir is not valid
    $errors['general'][] = "The Specified Dir is Not Valid or is Not Writeable";
    return false;
   }
  }
 } 
}

/**
 * Handle the Exceptions trigered by errors within upload code.
 *
 */
class TrigerErrorException extends Exception {
 protected $file = "";
 public function __construct($message, $file = "", $code = 0) {
  $this->file = $file;
     parent::__construct($message, $code);
 }

   public function Message() {
  return "{$this->message}";
    }
}
?>

class Uploadimg{
 private $_fileName="";         //文件域名称 如 'userfile'
 private $_uploadDir = '';       //上传路径 如 ./upload/
 
 /*上传参数配置*/
 private $_config = array(
  'type'=>array('image/jpeg','image/jpg',
    'image/pjpeg','image/gif'),         //上传的类型
  'size'=>1,                     //文件最大容量单位是M
  'width'=>1000,                   //图片的最大宽度
  'height'=>800                   //图片的最大高度
 );
 
 /**
  * 构造函数
  *
  * @param string $fileName
  * @param string $uploadDir
  * @param array $config
  */
 function __construct($fileName,$uploadDir,$config='')
 {
  $this->_fileName = $fileName;
  $this->_uploadDir = $uploadDir;
  if($config == "" or empty($config) or !is_array($config)){
   $this->_config = $this->_config;
  }else{
   $this->_config = $config;
  }
 }
 
 /**
  * 检测容量是否超过
  *
  * @return boolean
  */
 function checkSize()
 {
  if($_FILES[$this->_fileName]['size'] > $this->_config['size']*1024*1024){
   return false;
  }else{
   return true;
  } 
 }
 
 /**
  * 获取图片信息
  *
  * @return boolean
  */
 function getInfo()
 {
  return @getimagesize($_FILES[$this->_fileName]['tmp_name']);
 }
 
 /**
  * 检测后缀名
  *
  * @return boolean
  */
 function checkExt()
 {
  $imageInfo = $this->getInfo();
  if(in_array($imageInfo['mime'],$this->_config['type'])){
   return true;
  }else{
   return false;
  }
 }
 
 /**
  * 获取后缀名
  *
  * @return boolean
  */
 function getExt()
 {
  $imageInfo = $this->getInfo();
  switch($imageInfo['mime']){
   case 'image/jpeg':$filenameExt = '.jpg';break;
   case 'image/jpg':$filenameExt = '.jpg';break;
   case 'image/pjpeg':$filenameExt = '.jpg';break;
   case 'image/gif':$filenameExt = '.gif';break;
   default:break;
  }
  return $filenameExt;  
 }
 
 /**
  * 检测尺寸
  *
  * @return boolean
  */
 function checkWh()
 {
  $imageInfo = $this->getInfo();
  if(($imageInfo[0] > $this->_config['width']) or ($imageInfo[1] > $this->_config['height'])){
   return false;
  }else{
   return true;
  }
 }
 
 /**
  * 上传一张图片
  *
  * @return string or int
  */
 function uploadSingleImage()
 {
  if($this->checkSize() == false){
   return (-3); /*上传容量过大*/
   exit();
  }  
  if($this->checkExt() == true){
   $filenameExt = $this->getExt();
  }else{
   return (-2);  /*上传格式错误*/
   exit();
  }
  if($this->checkWh() == false){
   return (-1);  /*上传图片太宽或太高*/
   exit();
  }
  $file_new_name = date('YmdHis').$filenameExt;
  $file_new_name_upload = rtrim($_SERVER['DOCUMENT_ROOT'],'/').$this->_uploadDir.$file_new_name;
  if(@move_uploaded_file($_FILES[$this->_fileName]['tmp_name'],$file_new_name_upload)){
   return $file_new_name;
  }else{
   return (0); /*上传失败*/
  } 
 }
 
 /**
  * 删除图片
  *
  * @param string $imageName
  * @return boolen
  */
 function delImage($imageName)
 {
  $path = rtrim($_SERVER['DOCUMENT_ROOT'],'/').$this->_uploadDir.$imageName;
  if(unlink($path) == true){
   return true;
  }else{
   return false;
  }
 }
}

[!--infotagslink--]

相关文章

  • Mybatis Plus select 实现只查询部分字段

    这篇文章主要介绍了Mybatis Plus select 实现只查询部分字段的操作,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-09-01
  • MyBatisPlus-QueryWrapper多条件查询及修改方式

    这篇文章主要介绍了MyBatisPlus-QueryWrapper多条件查询及修改方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2022-06-27
  • Oracle使用like查询时对下划线的处理方法

    这篇文章主要介绍了Oracle使用like查询时对下划线的处理方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-03-16
  • 解决mybatis-plus 查询耗时慢的问题

    这篇文章主要介绍了解决mybatis-plus 查询耗时慢的问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-07-04
  • Yii2.0高级框架数据库增删改查的一些操作

    yii2.0框架是PHP开发的一个比较高效率的框架,集合了作者的大量心血,下面通过用户为例给大家详解yii2使用中的一些基本的增删改查操作。 User::find()->all(); //返回所有用户数据; User::findOne($id); //返回 主键...2015-11-24
  • MySQL中在查询结果集中得到记录行号的方法

    如果需要在查询语句返回的列中包含一列表示该条记录在整个结果集中的行号, ISO SQL:2003 标准提出的方法是提供 ROW_NUMBER() / RANK() 函数。 Oracle 中可以使用标准方法(8i版本以上),也可以使用非标准的 ROWNUM ; MS SQL...2015-03-15
  • 详解nginx同一端口监听多个域名和同时监听http与https

    这篇文章主要介绍了详解nginx同一端口监听多个域名和同时监听http与https的相关资料,需要的朋友可以参考下...2017-07-06
  • Node实现搜索框进行模糊查询

    这篇文章主要为大家详细介绍了Node实现搜索框进行模糊查询,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-06-28
  • Mybatis用注解写in查询的实现

    这篇文章主要介绍了Mybatis用注解写in查询的实现方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-07-13
  • PHP+Mysql+jQuery查询和列表框选择操作实例讲解

    本文讲解如何通过ajax查询mysql数据,并将返回的数据显示在待选列表中,再通过选择最终将选项加入到已选区,可以用在许多后台管理系统中。本文列表框的操作依赖jquery插件。HTML <form id="sel_form" action="post.php" me...2015-10-23
  • Element-ui 自带的两种远程搜索(模糊查询)用法讲解

    这篇文章主要介绍了Element-ui 自带的两种远程搜索(模糊查询)用法讲解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-29
  • Mybatis和Mybatis-Plus时间范围查询方式

    这篇文章主要介绍了Mybatis和Mybatis-Plus时间范围查询方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-08-06
  • mysql like查询字符串示例语句

    MySQL提供标准的SQL模式匹配,以及一种基于象Unix实用程序如vi、grep和sed的扩展正则表达式模式匹配的格式 一、SQL模式SQL的模式匹配允许你使用“_”匹配任何单个字符,而“%”匹配任意数目字符(包括零个字符)。在 MySQL...2013-10-04
  • JPA如何使用nativequery多表关联查询返回自定义实体类

    这篇文章主要介绍了JPA如何使用nativequery多表关联查询返回自定义实体类,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-11-18
  • Select下拉框模糊查询功能实现代码

    这篇文章主要介绍了Select下拉框模糊查询功能实现代码的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下...2016-07-29
  • C#百万数据查询出现超时问题的解决方法

    这篇文章主要介绍了C#百万数据查询出现超时问题的解决方法,是非常实用的技巧,需要的朋友可以参考下...2020-06-25
  • postgresql的jsonb数据查询和修改的方法

    这篇文章主要介绍了postgresql的jsonb数据查询和修改的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-03-03
  • Mybatis-Plus根据时间段去查询数据的实现示例

    这篇文章主要介绍了Mybatis-Plus根据时间段去查询数据的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-04-18
  • postgresql数据库连接数和状态查询操作

    这篇文章主要介绍了postgresql数据库连接数和状态查询操作,具有很好的参考价值,对大家有所帮助。一起跟随小编过来看看吧...2021-02-01
  • rails常用数据库查询操作、方法浅析

    这篇文章主要介绍了rails常用数据库查询操作、方法浅析,总结的比较全,WEB开发种常用的数据库操作都列出了rails对应代码,需要的朋友可以参考下...2020-06-30