<?php namespace Lurker\Tests\Event; use Lurker\Resource\FileResource; use Lurker\Resource\DirectoryResource; use Lurker\Event\FilesystemEvent; use Lurker\Resource\TrackedResource; class FilesystemEventTest extends \PHPUnit_Framework_TestCase { public function testConstructAndGetters() { $event = new FilesystemEvent( $tracked = new TrackedResource(23, new DirectoryResource(__DIR__)), $resource = new FileResource(__FILE__), $type = FilesystemEvent::MODIFY ); $this->assertSame($tracked, $event->getTrackedResource()); $this->assertSame($resource, $event->getResource()); $this->assertSame($type, $event->getType()); } public function testIsFileChange() { $event = new FilesystemEvent( $tracked = new TrackedResource(23, new DirectoryResource(__DIR__.'/../')), $resource = new FileResource(__FILE__), $type = FilesystemEvent::MODIFY ); $this->assertTrue($event->isFileChange()); $this->assertFalse($event->isDirectoryChange()); }这是一份资源跟踪PHP类库,需要的朋友可以下载使用。
<?php namespace Stampie\Adapter; use Buzz\Browser; use Buzz\Message\Form\FormUpload; use Buzz\Message\RequestInterface; class Buzz implements AdapterInterface { /** * @var Browser $browser */ protected $browser; /** * @param Browser $browser */ public function __construct(Browser $browser) { $this->browser = $browser; } /** * @return Browser */ public function getBrowser() { return $this->browser; }这是一份邮件服务的PHP库,需要的朋友可以下载使用。
<?php /** * Simple autoloader that follow the PHP Standards Recommendation #0 (PSR-0) * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md for more informations. * * Code inspired from the SplClassLoader RFC * @see https://wiki.php.net/rfc/splclassloader#example_implementation */ spl_autoload_register(function ($className) { $className = ltrim($className, '\'); $fileName = ''; if ($lastNsPos = strripos($className, '\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName = __DIR__ . DIRECTORY_SEPARATOR . $fileName . $className . '.php'; if (file_exists($fileName)) { require $fileName; return true; } return false; });这是一份PHP邮件回复解析器库,需要的朋友可以下载使用。
<?php class HasMxTest extends PHPUnit_Framework_TestCase { /** * Set up for tests in this file. * * @access private */ private function setupTest() { $this->validator = new \EmailValidator\Validator(); } /** * Test hasMx * * @cover \EmailValidator\Validator::hasMx */ public function testHasMx() { $this->setupTest(); // Not an email $this->assertNull( $this->validator->hasMx('example.com') ); // No Records $this->assertFalse( $this->validator->hasMx('example@example.com') ); // Records $this->assertTrue( $this->validator->hasMx('example@google.com') ); $this->assertTrue( $this->validator->hasMx('example@yahoo.com') ); } }这是一份PHP的邮箱验证库,需要的朋友可以下载使用
<?php namespace Hoa\Mime; use Hoa\Consistency; use Hoa\Stream; use Hoa\Zformat; */ class Mime implements Zformat\Parameterizable { const STRUCTURE_MEDIA_TYPE = 0; const STRUCTURE_EXTENSION = 1; const MIME_MEDIA = 0; const MIME_TYPE = 1; private $_parameters = null; * Computed magic file. * Structure: * array( * structure_media_type => array( * media => array( * type => array(extensions) * ) * ), * structure_extension => array( * extension => media/type * ) * ) * * @var array这是一个MIME检测PHP库,需要的朋友可以下载使用
<?php class Category { private $model; //分类的数据表模型 private $rawList = array(); //原始的分类数据 private $formatList = array(); //格式化后的分类 private $error = ""; //错误信息 private $icon = array(' │', ' ├ ', ' └ '); //格式化的字符 private $fields = array(); / public function __construct($model = '', $fields = array()) { if (is_string($model) && (!empty($model))) { if (!$this->model = D($model)) $this->error = $model . "模型不存在!"; } if (is_object($model)) $this->model = &$model; $this->fields['cid'] = $fields['0'] ? $fields['0'] : 'id'; $this->fields['pid'] = $fields['1'] ? $fields['1'] : 'pid'; $this->fields['name'] = $fields['2'] ? $fields['2'] : 'name'; $this->fields['fullname'] = $fields['3'] ? $fields['3'] : 'fullname'; }这是一个php无限分类的Category类库,需要的朋友可以下载使用。
<?php class File { private $_dir; const EXT = '.txt'; public function __construct() { $this->_dir = dirname(__FILE__) . '/files/'; } public function cacheData($key, $value = '', $cacheTime = 0) { $filename = $this->_dir . $key . self::EXT; if($value !== '') { // 将value值写入缓存 if(is_null($value)) { //$value 为null 将删除缓存 return @unlink($filename); } //目录不存在建立目录 $dir = dirname($filename); if(!is_dir($dir)) { mkdir($dir, 0777); } //设置定长缓存时间,保存到缓存文件中 $cacheTime = sprintf('%011d', $cacheTime); return file_put_contents($filename,$cacheTime . json_encode($value)); }这是一个PHP文件缓存类库,需要的朋友可以下载使用
<?php class Cache { private $dir; private $lifetime; private $cacheid; private $ext; function __construct($dir='',$lifetime=1800) { if ($this->dir_isvalid($dir)) { $this->dir = $dir; $this->lifetime = $lifetime; $this->ext = '.Php'; $this->cacheid = $this->getcacheid(); } } private function isvalid() { if (!file_exists($this->cacheid)) return false; if (!(@$mtime = filemtime($this->cacheid))) return false; if (mktime() - $mtime > $this->lifetime) return false; return true; }这是一个PHP实现的缓存类库,需要的朋友可以下载使用
<?php class mysql { private $defaultDB = null; private $link = null; private $sql = null; private $bindValue = null; public $num_rows = 0; public $affected_rows = 0; public $insert_id = 0; public $queries = 0; public function __construct() { if(func_num_args()) { $argv = func_get_arg(0); if(!empty($argv) && is_array($argv)) { $this->connect($argv); $argv['charset'] = isset($argv['charset']) ? $argv['charset'] : 'utf8'; $this->setCharset($argv['charset']); } } }这是一个php连接mysql的工具类,需要的朋友可以下载使用
<?php define("TOKEN", "weixin"); $wechatObj = new wechatCallbackapiTest(); if (!isset($_GET['echostr'])) { $wechatObj->responseMsg(); }else{ $wechatObj->valid(); } class wechatCallbackapiTest { //验证消息 public function valid() { $echoStr = $_GET["echostr"]; if($this->checkSignature()){ echo $echoStr; exit; } }这是一个php的微信公众平台开发接口类,需要的朋友可以下载使用
<?php <?php set_time_limit(0); $urls = array('http://www.baidu.com','http://www.php.cn',); $handle = curl_multi_init(); $curls = array(); foreach ($urls as $k=>$url) { $curls[$k] = add_handle($handle, $url); } function add_handle(& $handle, $url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, ''); curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($handle, $curl); return $curl; }这是一个php的curl多线程采集类,需要的朋友可以下载使用。
/** * 生成二维码 * @param string $url url连接 * @param integer $size 尺寸 纯数字 */ function qrcode($url,$size=4){ Vendor('Phpqrcode.phpqrcode'); // 如果没有http 则添加 if (strpos($url, 'http')===false) { $url='http://'.$url; } QRcode::png($url,false,QR_ECLEVEL_L,$size,2,false,0xFFFFFF,0x000000); }第一个参数$text;就是上面代码里的URL网址参数;第二个参数$outfile默认为否;不生成文件;只将二维码图片返回;否则需要给出存放生成二维码图片的路径;第三个参数$level默认为L;这个参数可传递的值分别是L(QR_ECLEVEL_L,7%)、M(QR_ECLEVEL_M,15%)、Q(QR_ECLEVEL_Q,25%)、H(QR_ECLEVEL_H,30%);这个参数控制二维码容错率;不同的参数表示二维码可被覆盖的区域百分比。利用二维维码的容错率;我们可以将头像放置在生成的二维码图片任何区域;第四个参数$size;控制生成图片的大小;默认为4;第五个参数$margin;控制生成二维码的空白区域大小;第六个参数$saveandprint;保存二维码图片并显示出来;$outfile必须传递图片路径;第七个参数$back_color;背景颜色;第八个参数$fore_color;绘制二维码的颜色;