HTML定义文件上传组件和上传按钮,使用了 Bootstrap ,不满意可以自己美化。 <form id="form1"> <div class="form-group"> <div class="custom-file"><input id="fileUpload" class="custom-file-input" type="file" /> …

2023年01月01日 0条评论 1453点热度 0人点赞 路灯 阅读全文

单例模式(Singleton Pattern):顾名思义,就是只有一个实例。作为对象的创建模式,单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。 为什么要使用单例模式 1、PHP语言本身的局限性 PHP语言是一种解释型的脚本语言,这种运行机制使得每个PHP页面被解释执行后,所有的相关资源都会被回收。也就是说,PHP在语言级别上没有办法让某个对象常驻内存,这和ASP.NET、Java等编译型是不同的,比如在Java中单例会一直存在于整个应用程序的生命周期里,变量是跨页面级的,真正可以做到这个…

2023年01月01日 0条评论 1488点热度 0人点赞 路灯 阅读全文

现在很多人喜欢用md5或md5+salt加密密码存储在数据库中,从技术的角度来说,MD5真的安全,因为MD5是不可逆的,没办法解密,除了撞库这样的方式。关于撞库简单来说就是通过建立大型数据库,将常用的各种句子密码等加密成为密文,并存储在数据库中;然后拿着密文到数据库网站查询,就有可能查到密码。 但在PHP中有更好的密码存储方式:Password Hashing,主要用到了4个函数: //查看哈希值的相关信息 array password_get_info (string $hash) //创建hash密码 stri…

2022年12月30日 0条评论 1616点热度 0人点赞 路灯 阅读全文

php支持的伪协议 1 file:// — 访问本地文件系统 2 http:// — 访问 HTTP(s) 网址 3 ftp:// — 访问 FTP(s) URLs 4 php:// — 访问各个输入/输出流(I/O streams) 5 zlib:// — 压缩流 6 data:// — 数据(RFC 2397) 7 glob:// — 查找匹配的文件路径模式 8 phar:// — PHP 归档 9 ssh2:// — Secure Shell 2 10 rar:// — RAR 11 ogg:// — 音频流…

2022年12月27日 0条评论 1596点热度 0人点赞 路灯 阅读全文

<?php // 非常给力的authcode加密函数,Discuz!经典代码(带详解) // 函数authcode($string, $operation, $key, $expiry)中的$string:字符串,明文或密文;$operation:DECODE表示解密,其它表示加密;$key:密匙;$expiry:密文有效期。 function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0…

2022年12月27日 0条评论 1477点热度 0人点赞 路灯 阅读全文

/** * 通过UTC获取精确时间,默认为北京时间 * @param int $timezone * @param int $timestamp * @return bool|false|string */ public function getutctime($timezone = 8, $timestamp = 0) { $fp = fsockopen('time.nist.gov', 13, $err_no, $err_str, 90); $t = fread($fp, 2096); if…

2022年12月27日 0条评论 1379点热度 0人点赞 路灯 阅读全文

/** * 缩略图生成函数,使用GD2 * @param $srcFile * @param $toW * @param $toH * @param string $toFile * @param string $default_ext * @return bool|string */ public function image_resize($srcFile, $toW, $toH, $toFile = "", $default_ext="png") { //error_r…

2022年12月27日 0条评论 1357点热度 0人点赞 路灯 阅读全文

/** * 字符串加密 * @param $str * @param string $key1 * @param string $key2 * @return string */ function encode_z($str, $key1 = "", $key2 = "") { global $config; $b = array(); $c = array(); $s = ''; if (strlen($key1) != 16) $key1 = $con…

2022年12月27日 0条评论 1352点热度 0人点赞 路灯 阅读全文

<?php /** * PHP 非对称 加密 */ $config = array( "digest_alg" => "sha512", "private_key_bits" => 4096, //字节数 512 1024 2048 4096 等 "private_key_type" => OPENSSL_KEYTYPE_RSA, //加密类型 ); $res = openssl_pkey_new($config…

2022年12月26日 0条评论 1527点热度 0人点赞 路灯 阅读全文

<? $start_time = microtime(true); $n=5000; // 圆周率的长度 $w = $n+10; $b =bcpow(10,$w); $rtemp=bcmul($left=$b, $right=4); $x1 =bcdiv($left=$rtemp, $right=5); $x2 =bcdiv($left=$b, $right=-239); $he=bcadd($left=$x1, $right=$x2); $n =$n*2; for ($i=3; $i<$n; $i =…

2022年12月24日 0条评论 1810点热度 0人点赞 路灯 阅读全文