<?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 requested url@param integer $ timeoutタイムアウト時間 (秒)@戻り文字列(リクエストが成功した) | 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>" : {数値} 重みの最大値,<br />"<b>data</b>" : {配列} 座標詳細データ、形式は以下のとおりです{"lng":116.421969,"lat":39.913527,"count":3}、lng lat はそれぞれ経度と緯度です。カウントウェイト値パワーマップの詳細座標点を追加#@param {数値} lng 経度座標#@param {数値} 緯度経度座標@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' => 'SMS テンプレートのコードが間違っているか、テンプレートのステータスが正しくありません', InvalidRecNum.Malformed' => '対象の携帯電話番号が間違っており、送信された番号は一度に 100 を超えることはできません', InvalidParamString.MalFormed' => 'SMS テンプレート内の変数は json 形式ではありません',InvalidParamStringTemplate.Malformed' => 'SMS テンプレート内の変数SMS テンプレートがテンプレートの内容と一致しません' InvalidSendSms' => 'ビジネス フロー制御をトリガーしますInvalidDayu.Malformed' => '変数を 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メソッドで送信したヘッダの応答結果が正しいか判断する ・返されたWebページが正しいか確認するテキスト タイプ - 返された Web ページが特定のタイプであるかどうかを判断する - 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 最上位の並べ替えフィールド# #####################################