首页 > 编程技术 > php

php 导入excel文档程序

发布时间:2016-11-25 16:01

php 导入excel文档程序
$a = "用户名,真实姓名,联系方式,联系QQ,联系地址,邮箱地址 rn";
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
$Sql = "Select * from  gx_member";
$Result = mysql_query($Sql) or die(mysql_error());
  while($rs = mysql_fetch_array($Result) ){
    if(get_days($rs['m_time'])<= $Table ){
   $a.=$rs['m_name'].','. $rs['m_realname'].",". $rs['m_tel'].",". $rs['m_qq'].",";
   $a.="".$rs['m_address'].",". $rs['m_mail']." rn ";
   }
  } 
  echo $a;

如何给dedecms增加迅雷联盟代码
第一步:在templates/plus/download_links_templet.htm打开这个文件把下面代码放

在</head>之前就行了。
<script" width=100% src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script>
<script" width=100% src="http://pstatic.xunlei.com/js/base64.js"></script>
第二步:在站点根目录找到plus/download.php文件,打开。找到$downlinks =

ch_softlinks($row[$vname], $ctag, $cu, '', true);这一句,在后段加上这一段代

preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\/a.*?>/sim',$downlinks,$vlink);

$downlinks =  '';
    foreach( $vlink[1] as $getlink =>$value )
    {
      if( strtolower(substr( $value ,0,10 ))

=='thunder://' )
   {
    $downlinks.= '<a href="#"

thunderHref="'.$value.'" thunderPid="85957" thunderType=""

thunderResTitle="" onClick="return OnDownloadClick_Simple(this,2);"

oncontextmenu="ThunderNetwork_SetHref(this)" >迅雷下载</a>&nbsp;';
   }
   else
   {
    $downlinks.= '<a href="#"

thunderHref="'.$value.'" thunderPid="85957" thunderType=""

thunderResTitle="" onClick="return OnDownloadClick_Simple(this,2);"

oncontextmenu="ThunderNetwork_SetHref(this)" >本地下载</a>&nbsp;';
   }
   
    }
好了大功告诉成了,很简单的方法就给你的网站增加迅雷联盟的下载代码了哦,

本站原创转载注明www.111cn.net

php ip获取与判断IP分段类

class Ip {

 /**
  * 取IP
  * @return string
  */
 public static function get() {
  if ($_SERVER['HTTP_CLIENT_IP'] && $_SERVER

['HTTP_CLIENT_IP']!='unknown') {
   $ip = $_SERVER['HTTP_CLIENT_IP'];
  } elseif ($_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER

['HTTP_X_FORWARDED_FOR']!='unknown') {
   $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  } else {
   $ip = $_SERVER['REMOTE_ADDR'];
  }
  return $ip;
 }
 
 /**
  * IP转成整形数值
  * @param string $ip IP
  * @return int
  */
 public static function ipToInt($ip) {
  $ips = explode('.',$ip);
  if (count($ips)>=4) {
   $int = $ips[0]*256*256*256+$ips[1]*256*256+$ips[2]

*256+$ips[3];//根据IP,a,b,c类进行计算
  } else {
   throw new Exception('ip is error');
  }
  return $int;
 }
 
 /**
  * 判断IP是否在一个IP段内
  * @param string $startIp 开始IP
  * @param string $endIp 结束IP
  * @param string $ip IP
  * @return bool
  */
 public static function isIn($startIp, $endIp, $ip) {
  $start = Ip::ipToInt($startIp);
  $end = Ip::ipToInt($endIp);
  $ipInt = Ip::ipToInt($ip);
  $result = false;
  if ($ipInt>=$start && $ipInt<=$end) {
   $result = true;
  }
  return $result;
 }
}

php日期所在月的第一天日期和最后一天

/**
  * 日期所在月的第一天日期
  * @return int
  */
 public function getFirstDayOfMonth ($format = 'timestamp') {
  $day = $this->getPart('yy') . '-' . $this->getPart('mm') .

'-' . '01';
  if ($format=='timestamp') {
   $day = (int)$this->toTimeStamp($day);
  }
  return $day;
 }
 /**
  * 日期所在月的最后一天日期
  * @return int
  */
 public function getLastDayOfMonth ($format = 'timestamp') {
  $day = $this->getPart('yy') . '-' . $this->getPart('mm') .

'-' . $this->daysOfMonth();
  if ($format=='timestamp') {
   $day = (int)$this->toTimeStamp($day);
  }
  return $day;
 }

php 格式化输出日期函数

public function format ($formatTo='standard',$timestamp = NULL) {
  if ($timestamp!==NULL) {
   $source = $timestamp;
   if (!$source) {
    return '';
   }
  } else {
   $source = $this->timestamp;
  }
  
  switch (strtolower($formatTo))
  {
   case 'chinese' : //中文格式串“YYYY年MM月DD日

HH:MM:SS”
    $result = date("Y年m月d日 H:i:s", $source);

break ;
   case 'cdate':
    $result = date("Y年m月d日", $source); break

;
   case 'date':
    $result = date("Y-m-d", $source); break ;
   case 'time':
    $result = date("H:i:s", $source); break ;
   case 'standard' : //标准格式串“YYYY-MM-DD HH:MM:SS


    $result = date("Y-m-d H:i:s", $source);

break;
   default :
    $result = date($formatTo, $source);
  }
  return $result;
 }

标签:[!--infotagslink--]

您可能感兴趣的文章: