<?php namespace TijsVerkoyen\CssToInlineStyles; use Symfony\Component\CssSelector\CssSelector; use Symfony\Component\CssSelector\CssSelectorConverter; use Symfony\Component\CssSelector\Exception\ExceptionInterface; use TijsVerkoyen\CssToInlineStyles\Css\Processor; use TijsVerkoyen\CssToInlineStyles\Css\Property\Processor as PropertyProcessor; use TijsVerkoyen\CssToInlineStyles\Css\Rule\Processor as RuleProcessor; use TijsVerkoyen\CssToInlineStyles\Css\Rule\Rule; class CssToInlineStyles { private $cssConverter; public function __construct() { if (class_exists('Symfony\Component\CssSelector\CssSelectorConverter')) { $this->cssConverter = new CssSelectorConverter(); } }이것은 이메일 템플릿에 포함된 인라인 CSS 라이브러리입니다. 필요한 친구는 다운로드하여 사용할 수 있습니다
<?php /** * 参数处理类 * @author JasonWei */ class Params { public $get = array(); public $post = array(); function __construct() { if (!emptyempty($_GET)) { foreach ($_GET as $key => $val) { if (is_numeric($val)) { $this->get[$key] = $this->getInt($val); } else { $this->get[$key] = $this->getStr($val); } } } if (!emptyempty($_POST)) { foreach ($_POST as $key => $val) { if (is_numeric($val)) { $this->post[$key] = $this->getInt($val); } else { $this->post[$key] = $this->getStr($val); } } }이것은 매우 유용한 PHP 방지 주입 클래스입니다. 필요한 친구는 다운로드하여 사용할 수 있습니다
<?php /** * Validator 数据验证类 */ class Validator { /** * 待校验数据 * @var array */ private $_data; /** * 校验规则 * @var array */ private $_ruleList = null; /** * 校验结果 * @var bool */ private $_result = null; /** * 校验数据信息 * @var array */ private $_resultInfo = array(); /** * 构造函数 * @param array $data 待校验数据 */ public function __construct($data = null) { if ($data) { $this->_data = $data; } }이것은 매우 완벽한 PHP 검증 수업입니다. 필요한 친구들은 다운로드하여 사용할 수 있습니다
<?php class crypt { private $skey; public function __construct($key) { $this->skey = hash("md5", $key, true); //32位skey } public function safe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array('+', '/', '='), array('-', '_', ''), $data); return $data; } public function safe_b64decode($string) { $data = str_replace(array('-', '_'), array('+', '/'), $string); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); }PHP 암호화 및 복호화 클래스입니다. 필요한 친구는 다운로드해서 사용할 수 있습니다
<?php class cls_http_request { public static function curl_get($url, $timeout = 1) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $result = curl_exec($ch); curl_close($ch); if (is_string($result) && strlen($result)) { return $result; } else { return false; } }http 요청 처리 클래스(CURL 기반으로 캡슐화됨)get 요청(curl)@param string $url 요청 url@param 정수 $timeout 시간 제한(초)@return 문자열(요청 성공) false (요청 실패)
<?php class CacheLayer{ protected $root = ""; protected $cache = ""; protected $key = ""; protected $life = 0; public function __construct($key, $root = "/cachelayer"){ $this->root = $_SERVER["DOCUMENT_ROOT"].$root; $this->key = $key; } public function expired($life_span){ $this->life = $life_span; $file = $this->root."/".$this->key.".cachelayer"; if(is_file($file)){ $mtime = filemtime($file); return (time() >= ($mtime + $this->life)); }else{ return true; } } public function put($content){ $file = $this->root."/".$this->key.".cachelayer"; if(!is_dir(dirname($this->root))){ return false; } $this->delete(); $content = json_encode($content); return (bool)file_put_contents($file, $content); } public function get(){ $file = $this->root."/".$this->key.".cachelayer"; if(is_file($file)){ return json_decode(file_get_contents($file), true); } return array(); } public function delete(){ $file = $this->root."/".$this->key.".cachelayer"; if(is_file($file)){ unlink($file); return true; } return false; } } ?>이것은 매우 유용한 PHP 캐싱 라이브러리입니다. 필요한 친구는 다운로드하여 사용할 수 있습니다. 파일 캐싱을 통해 데이터베이스에 대한 부담을 크게 줄일 수 있습니다.
<?php class upload { var $dir; //附件存放物理目录 var $time; //自定义文件上传时间 var $allow_types; //允许上传附件类型 var $field; //上传控件名称 var $maxsize; //最大允许文件大小,单位为KB var $thumb_width; //缩略图宽度 var $thumb_height; //缩略图高度 var $watermark_file; //水印图片地址 var $watermark_pos; //水印位置 var $watermark_trans;//水印透明度 //构造函数 //$types : 允许上传的文件类型 , $maxsize : 允许大小 , $field : 上传控件名称 , $time : 自定义上传时间 function upload($types = 'jpg|png', $maxsize = 1024, $field = 'attach', $time = '') { $this->allow_types = explode('|',$types); $this->maxsize = $maxsize * 1024; $this->field = $field; $this->time = $time ? $time : time(); } //设置并创建文件具体存放的目录 //$basedir : 基目录,必须为物理路径 //$filedir : 自定义子目录,可用参数{y}、{m}、{d} function set_dir($basedir,$filedir = '') { $dir = $basedir; !is_dir($dir) && @mkdir($dir,0777); if (!empty($filedir)) { $filedir = str_replace(array('{y}','{m}','{d}'),array(date('Y',$this->time),date('m',$this->time),date('d',$this->time)),strtolower($filedir));//用string_replace把{y} {m} {d}几个标签进行替换 $dirs = explode('/',$filedir); foreach ($dirs as $d) { !empty($d) && $dir .= $d.'/'; !is_dir($dir) && @mkdir($dir,0777); } } $th는 워터마크, 날짜, 썸네일 PHP 다중 파일 업로드 클래스를 지원하고 파일이 저장되는 특정 디렉토리 설정 및 생성, 그림 썸네일 설정, 썸네일이 생성되지 않으면 설정이 필요하지 않음, 워터마크가 생성되지 않는 경우 그림 워터마크 설정 , 설정이 필요하지 않습니다. 파일 업로드를 설정하고 실행하며 처리 후 업로드 성공 또는 실패를 포함하는 파일 정보 배열을 반환합니다.
<?php class IP { public static function generate($province = '') { $ip_address = self::_IPSegment($province); $ip = self::_randomIP($ip_address['begin'], $ip_address['end']); return $ip; } public static function update() { require 'QueryList.class.php'; $province = array( 'BJ', 'GD', 'SD', 'ZJ', 'JS', 'SH', 'LN', 'SC', 'HA', 'HB', 'FJ', 'HN', 'HE', 'CQ', 'SX', 'JX', 'SN', 'AH', 'HL', 'GX', 'JL', 'YN', 'TJ', 'NM', 'XJ', 'GS', 'GZ', 'HI', 'NX', 'QH', 'XZ' ); $count = count($province); $ip_segment = array(); for ($i = 0; $i < $count; $i++) { // 采集IP地址段目标网址 $url = 'http://ips.chacuo.net/view/s_' . $province[$i]; $ip_list = QueryList::Query($url, array('begin' => array('.v_l', 'text'), 'end' => array('.v_r', 'text')), '', 'UTF-8'); $ip_array = $ip_list->jsonArr; $ip_segment[$province[$i]] = $ip_array; } $path = str_replace('\', '/', __DIR__); $file = $path . '/ip_segment.php'; $res = self::_write($file, $ip_segment); if ($res) { echo 'Update OK!'; } }지방 이름(중국어)을 기준으로 IPV4 주소를 무작위로 생성$province가 비어 있으면 임의의 국내 지방
(function(w){ // the heatmapFactory creates heatmap instances var heatmapFactory = (function(){ // store object constructor // a heatmap contains a store // the store has to know about the heatmap in order to trigger heatmap updates when datapoints get added var store = function store(hmap){ var _ = { // data is a two dimensional array // a datapoint gets saved as data[point-x-value][point-y-value] // the value at [point-x-value][point-y-value] is the occurrence of the datapoint data: [], // tight coupling of the heatmap object heatmap: hmap }; // the max occurrence - the heatmaps radial gradient alpha transition is based on it this.max = 1; this.get = function(key){ return _[key]; }; this.set = function(key, value){ _[key] = value; }; }히트맵으로 표시되는 상세 데이터를 설정합니다. 구현 후 즉시 표시할 수 있습니다. @param {Json Object} data{"<b>max</b>: {Number} <br />"<b>data</b>" : {Array} 좌표 상세 데이터, 형식은 다음과 같습니다<br/>{"lng":116.421969, "lat":39.913527," count":3}, 여기서<br/>lng lat는 각각 위도와 경도이며, 가중치 값을 계산합니다파워 맵의 세부 좌표 지점을 추가합니다@param {Number } lng 경도 좌표@param {Number} 위도 경도 좌표@param {Number} 카운트 경도 좌표
<?php /** * 阿里云短信验证码发送类 */ class Sms { // 保存错误信息 public $error; // Access Key ID private $accessKeyId = ''; // Access Access Key Secret private $accessKeySecret = ''; // 签名 private $signName = ''; // 模版ID private $templateCode = ''; public function __construct($cofig = array()) { $cofig = array ( 'accessKeyId' => '***************', 'accessKeySecret' => '******************', 'signName' => '七零', 'templateCode' => 'SMS_25300059' ); // 配置参数 $this->accessKeyId = $cofig ['accessKeyId']; $this->accessKeySecret = $cofig ['accessKeySecret']; $this->signName = $cofig ['signName']; $this->templateCode = $cofig ['templateCode']; }InvalidDayuStatus.Malformed' => '계정 SMS 활성화 상태가 잘못되었습니다.',InvalidSignName.Malformed' => 'SMS 서명이 잘못되었거나 서명 상태가 잘못되었습니다.',InvalidTemplateCode.MalFormed' => 템플릿 코드가 올바르지 않거나 템플릿 상태가 올바르지 않습니다.',InvalidRecNum.Malformed' => '대상 휴대전화 번호가 올바르지 않습니다. 한번에 보내는 개수는 100을 초과할 수 없습니다',InvalidParamString.MalFormed' => ' SMS 템플릿의 변수는 json 형식이 아닙니다.',InvalidParamStringTemplate.Malformed' => 'SMS 템플릿의 변수가 템플릿 내용과 일치하지 않습니다.'InvalidSendSms' => '비즈니스 흐름 제어 실행InvalidDayu. 형식이 잘못됨' => '변수는 URL이 될 수 없습니다. 변수는 템플릿에서 확정될 수 있습니다
<?php class HttpDownload { private $m_url = ""; private $m_urlpath = ""; private $m_scheme = "http"; private $m_host = ""; private $m_port = "80"; private $m_user = ""; private $m_pass = ""; private $m_path = "/"; private $m_query = ""; private $m_fp = ""; private $m_error = ""; private $m_httphead = "" ; private $m_html = ""; public function PrivateInit($url){ $urls = ""; $urls = @parse_url($url); $this->m_url = $url; if(is_array($urls)) { $this->m_host = $urls["host"]; if(!empty($urls["scheme"])) $this->m_scheme = $urls["scheme"]; if(!empty($urls["user"])) $this->m_user = $urls["user"]; if(!empty($urls["pass"])) $this->m_pass = $urls["pass"]; if(!empty($urls["port"])) $this->m_port = $urls["port"]; if(!empty($urls["path"])) $this->m_path = $urls["path"]; $this->m_urlpath = $this->m_path; if(!empty($urls["query"])) { $this->m_query = $urls["query"]; $this->m_urlpath .= "?".$this->m_query; } } }초기화 - 지정된 URL 열기 - 각 매개변수 재설정 - 시스템 초기화 - 작업 오류의 원인 파악 - Get 메소드에서 보낸 헤더의 응답 결과가 올바른지 확인 - 반환된 웹 페이지가 텍스트인지 확인 유형 - 반환된 웹 페이지가 특정 유형인지 확인 - HTTP 프로토콜 다운로드 파일
<?php function qsort(&$arr) { _quick_sort($arr, 0, count($arr) - 1); } function _quick_sort(&$arr, $low, $high) { $low_data = $arr[$low]; $prev_low = $low; $prev_high = $high; while ($low < $high) { while ($arr[$high] >= $low_data && $low < $high) { $high--; } if ($low < $high) { $arr[$low] = $arr[$high]; $low++; } while ($arr[$low] <= $low_data && $low < $high) { $low++; } if ($low < $high) { $arr[$high] = $arr[$low]; $high--; } }재귀 알고리즘을 사용한 빠른 정렬입니다. @param array $arr 정렬할 배열@param int $low 가장 낮게 정렬된 하위 섹션@param int $high 가장 높게 정렬된 필드