免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1788 | 回复: 0
打印 上一主题 下一主题

杂乱的主题Ack [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 02:49 |只看该作者 |倒序浏览

<?php
$str = '此次8468058万元';
$preg = '#[0-9]{1,}#';

preg_match_all($preg,$str,$match);
echo $match[0][0];

?>

<?php

$dira = dirname(dirname(__FILE__)) . $DS . "webroot".$DS."attachment".$DS."product".$number.".xlsx" ;

//download the excel file
header( "Content-type: application/excel" );
           
           
header( "Content-disposition: attachment; filename=".basename($dira) );
header( "Content-transfer-encoding: binary\n");
header( "Content-length: " . @filesize($dira ) . "\n" );
// Send the torrent file
$fp = @fopen( $dira, "r" );
@fpassthru( $fp );
@fclose( $fp );

 

?>

<?php

class mysql
{
 
 private function __construct($configs){
  //print_r($configs);
  
  $this->_databaseHost = $configs['databaseHost'];
  $this->_databaseUser = $configs['userName'];
  $this->_databaseName = $configs['databaseName'];
  $this->_passWord     = $configs['passWord'];
  
  
  //$this->_databaseHost = '192.168.4.99';
  //$this->_databaseUser = 'asskuaibo';
  //$this->_databaseName = 'asskuaibo';
  //$this->_passWord     = 'asskuaibo';
  
  //print_r($configs); 
  $this->_init();
 }
 
 private function __clone(){}
 
 private  function _init(){
  try{
   $this->_link = mysql_connect($this->_databaseHost, $this->_databaseUser, $this->_passWord) or die('can not connect mysql!!');
   mysql_query("set names '".$this->_charset."'");
   mysql_select_db ($this->_databaseName, $this->_link);
  }catch (Exception $e){
   echo 'exception';
  }
 }
 
 
 public function get($sql){
  //echo $sql;
  if($this->_isDebug()){
   echo "<font color=red>$sql</font><br />";
  }
     
  $res = mysql_query($sql, $this->_link);
  
  while($row = mysql_fetch_assoc($res)){
   $data[] = $row;
  }
  //var_dump($data);
  return $data;
  
 }
 
 
 public function query($sql){
  
  if($this->_isDebug()){
   echo "<font color=red>$sql</font><br />";
  }
  
  mysql_query($sql, $this->_link);
 }
 
 
 
 /**
  * only one instance
  *
  *
  * */
 public static function getInstance($configs){
  if(self::$_instance === null){
   self::$_instance = new self($configs);
  }
  return self::$_instance;
 }
 
 
 private function _isDebug(){
  return $this->_isDebug;
 }
 
 public function onDebug(){
  $this->_isDebug = true;
 }
 
 public function offDebug(){
  $this->_isDebug = false;
 }
 
 
 private $_isDebug = false;
 
 
 private $_link = null;
 
 private static $_instance = null;
 
 private $_databaseHost = null;
 
 private $_databaseUser = null;
 
 private $_passWord = null;
 
 private $_charset = 'utf8';
 
 private $_databaseName = null;
 
 
}


class request
{
 
 public static function get($key, $default = ''){
  
  if(isset($_POST[$key])){
   return self::_filter($_POST[$key]);
  }else if(isset($_GET[$key])){
   return self::_filter($_GET[$key]);
  }else {
   return $default;
  }
  
 }
 
 public static function _filter($str){
  
  return addslashes($str);
 
 }
 
 
}


class mem_cache
{
 
 public function set($key, $val, $cacheTime){
  $this->_memcache->set($key, $val, 0, $cacheTime); 
 }
 
 
 public function get($key){
  return $this->_memcache->get($key);
  
 }
 
 public function del($key){
  
  $this->_memcache->delete($key);
 }
 
 public function delAll(){
  
  $this->_memcache->flush();
 }
 
 public static function getInstance($mem_config){
  
  if(self::$_instance === null){
   self::$_instance = new self($mem_config);
  }
  return self::$_instance;
 }
 
 private function __clone(){}
 
 private function __construct($mem_config){
  //$this->_config = $mem_config;
  //print_r($mem_config); 
  $this->_config['host'] = $mem_config['host'];
  $this->_config['port'] = $mem_config['port'];
  //$this->_config['host'] = '192.168.3.24';
  //$this->_config['port'] = 11211;
  if($this->_memcache === null){
   $this->_memcache = new Memcache;
   $this->_memcache->connect($this->_config['host'], $this->_config['port']);
    }

 }
 
 private static $_instance = null;
 
 private $_mem = null;
 
 private $_config = array();
 
 
}

class apc_cache
{
 
 
 public function set($key, $val, $cacheTime){
  
  apc_store($key, $val, $cacheTime);
 }
 
 public function get($key){
  
  return apc_fetch($key);
 }
 
 public function del($key){
  apc_delete($key);

 }
 
 public function delAll(){
  apc_clear_cache("user");
  
 }
 
 public static function getInstance(){
  if(self::$_instance === null){
   self::$_instance = new self();
   
  }
  
  return self::$_instance;
  
 }
 
 
 private static $_instance = null;
 
 
 
}


class cache
{
 
 public static function getInstance( $mem_config = array(), $type = 'a'){
  if($type == 'a'){
   return apc_cache::getInstance();
  }else{
   //var_dump($mem_config);
   return mem_cache::getInstance($mem_config);
  }
  
 }
 
 
 public function __construct(){
  
 } 
 
}

 

 

 


?>

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP