Jan 13

1. 改 "app\vendor\symfony\finder\Iterator\SortableIterator.php":

        } elseif (self::SORT_BY_NAME_NATURAL === $sort) {
            $this->sort = static function (SplFileInfo $a, SplFileInfo $b) use ($order) {
                return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());

忽略大小写的自然排序:

        } elseif (self::SORT_BY_NAME_NATURAL === $sort) {
            $this->sort = static function (SplFileInfo $a, SplFileInfo $b) use ($order) {
                return $order * strnatcasecmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());

2. 改 "app\views\components\file.twig"

<div class="ml-2">
<button
title="{{ translate('file.info') }}"
class="flex justify-center items-center rounded-full p-2 -m-1 md:invisible hover:bg-gray-400 hover:shadow group-hover:visible"
v-on:click.prevent="showFileInfo('{{ url(file.getPathname) | escape('js') }}')"
>
<i class="fas fa-info-circle"></i>
</button>
</div>

不显示 Hash 按钮:

<div class="ml-2">
<button
title="{{ translate('file.info') }}"
class="flex justify-center items-center rounded-full p-2 -m-1 md:invisible hover:bg-gray-400 hover:invisible group-hover:invisible"
v-on:click.prevent="showFileInfo('{{ url(file.getPathname) | escape('js') }}')"
>
<i class="fas fa-info-circle"></i>
</button>
</div>

:roll:


Oct 23

这个脚本功能很简单,如果你有境外 PHP 主机空间,利用这个脚本可以查询到被 DNS 污染的一些站点的真实 IP 。缓存的结果可以直接拷贝到系统 Hosts 文件中使用,也可以转换为 Unbound 的 localzone 格式供 Unbound 调用。hosts.txt 中包含需要查询的站点主机名,一行一个,ipcache.txt 则为查询结果缓存文件,标准的 Windows 系统 Hosts 文件格式。

可以到本站: gethosts 页面体验效果。


<?php
/**
 * gethosts
 *
 * @link       https://www.quakemachinex.com/gethosts/
 * @copyright  Copyright (c) 2011 AvP
 * @license    MIT Style License
 * @version    1.0
 */

$hostsLock = true; //用户提交的查询数据是否写入 hosts.txt,默认:不写入

$isPost = false;

if (isset($_POST['hosts'])){
    $hosts_txt = $_POST['hosts'];
    $isPost = true;
	if (!$hostsLock) file_put_contents('hosts.txt',$hosts_txt);
} else {
	$hosts_txt = file_get_contents('hosts.txt');
}
$hosts_array = preg_split('/[\s,]+/', $hosts_txt, -1, PREG_SPLIT_NO_EMPTY);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>gethosts</title>
<script src="ZeroClipboard.js" type="text/javascript"></script>
<script type="text/javascript">
//类似 PHP 中的 trim
    function trim(str) {
        var str = str.replace(/^\s\s*/, ''),
            ws = /\s/,
            i = str.length;
        while (ws.test(str.charAt(--i)));
        return str.slice(0, i + 1);
    }
//基于 ZeroClipboard 的跨浏览器复制到剪贴板
    function ctoc() {
        var txt = document.getElementById('hostsMap').value;

        if (window.clipboardData) {
            window.clipboardData.setData("text", txt);
            alert("Copied text to clipboard:\n" + txt);
        } else {
            var clip = new ZeroClipboard.Client();
            clip.glue('clickme');
            clip.setText(txt);
            clip.addEventListener('complete', function(client, text) {
                alert("Copied text to clipboard:\n" + text);
            });
            }
    }
//转换 Hosts 文件格式到 Unbound 的 localzone 格式
    function htol() {
        var i;
        var localz = new Array();
        var hosts = document.getElementById('hostsMap').value;
        var localzs='';
        hostdomain = hosts.split("\n");
        for (i=0;i<hostdomain.length;i++) {
            if (trim(hostdomain[i]) != '') {
                localz[i] = hostdomain[i].split("\t");
                localzs += 'local-data: "'+localz[i][1]+' A '+localz[i][0]+'"\n';
            }
        }
        document.getElementById('hostsMap').value = localzs;
    }
</script>
</head>
<body>
<?php
//判定字符串是否是 IP 地址
function IsIPAdress($value){

    if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $value)){
        return true;
    }
    return false;
}
//获取真实 IP,并且缓存,用户提交数据不缓存
function getRealIP(){
    global $hosts_array, $isPost;
    if($isPost) {
        foreach($hosts_array as $hostname){
            $ip = gethostbyname($hostname);
            if (IsIPAdress($ip)) {
                $i = $i + 1;
                echo "$ip\t$hostname";
                echo "\n";
                if ($i > 25) return;
            }
        }
    } else {
        $cache_days = 1; //缓存多少天
        $fz = filesize('ipcache.txt');
        $ipcache_create_time = filectime('ipcache.txt');
        $time_now = date("Y-m-d H:i:s");
        $ipcache_stay_days = (strtotime($time_now)-strtotime(date("Y-m-d H:i:s",$ipcache_create_time)))/86400;
        $ipcache_stay_days = floor($ipcache_stay_days);

        if ($fz && $fz != 0 && $ipcache_stay_days < $cache_days) {
            $ipcache = file_get_contents('ipcache.txt');
            echo $ipcache;
         } else {
            foreach($hosts_array as $hostname){
                $ip = gethostbyname($hostname);
                if (IsIPAdress($ip)) {
                    $ipcacheall .= "$ip\t$hostname\n";
                }
            }
            $local_ipcache = 'ipcache.txt';
            $local_ipcache_actual = fopen($local_ipcache, 'w+');
            fwrite($local_ipcache_actual, $ipcacheall);
            fclose($local_ipcache_actual);
            $ipcache = file_get_contents('ipcache.txt');
            echo $ipcache;
         }
     }
}
?>
    <div style="width:1024px; margin:0 auto;">
        <div style="float:left;margin:0 10px;">
            <h2>Blocked Hostnames</h2>
            <form method="post">
                <button type="submit" style="margin: 5px auto; display: block;">Get Hosts</button>
                <textarea name="hosts" style="width:400px;height:550px;margin:0;padding:3px;display:block;"><?php echo $hosts_txt;?></textarea>
            </form>
        </div>
        <div style="float:left;margin:0 10px;">
            <h2>hosts</h2>
            <div style="margin: 5px auto; display: block;">
            <button type="button" id="clickme" onclick="ctoc();">CopyToClipboard(Click Twice!)</button>
            <button type="button" id="hosttolocal" onclick="htol();">ConventerToLocalzone</button>
            </div>
            <textarea id="hostsMap" onclick="this.focus();this.select()"style="width:500px;height:550px;margin:0;padding:3px;display:block;"><?php getRealIP(); ?></textarea>
        </div>
    </div>
</body>
</html>

ZeroClipboard 可到官方下载。 :!:


Sep 25

Google 提供了一个获取站点 favicon 的服务:

http://www.google.com/s2/favicons?domain=

但是天朝,Google 不稳定,所以需要把这些站点图标缓存到本地,以下:


//从URL中提取域名函数
function get_domain($url) {
/*
Author : Ayush
URL : http://Webgarb.com
*/
    $url = explode('/', str_replace('www.', '', str_replace('http://', '', $url)));
    return $url[0];
}

function getFavicon($var){
    $cache_days = 30; //图标缓存多少天
    $linkdomain = get_domain($var);
    $favicon_cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'favicon_cache';
    $favicon_url = 'https://www.quakemachinex.com/blog/wp-content/plugins/favicon_cache/'.$linkdomain.'.png';
    $fp = fopen ($favicon_cache_dir.'/'.$linkdomain.'.png', 'r');
    $favicon_create_time = filectime($favicon_cache_dir.'/'.$linkdomain.'.png');
    $time_now = date("Y-m-d H:i:s");
    $favicon_stay_days = (strtotime($time_now)-strtotime(date("Y-m-d H:i:s",$favicon_create_time)))/86400;
    $favicon_stay_days = floor($favicon_stay_days);

    if ($fp && $favicon_stay_days < $cache_days) {
        return $favicon_url;
     } else {
        $remote_favicon = file_get_contents('http://www.google.com/s2/favicons?domain='.$linkdomain);
        $local_favicon = $favicon_cache_dir.'/'.$linkdomain.'.png';
        $local_favicon_actual = fopen($local_favicon, 'w+');
	fwrite($local_favicon_actual, $remote_favicon);
	fclose($local_favicon_actual);
        return $favicon_url;
     }

}

把这个函数引用到友情链接或者 BlogRoll 都行,可以参见本站效果。


Sep 28

哥,帮我做个相册好不?靠,你很闲啊,自己去弄!

ImageVue 是一款做的非常漂亮的基于 Flash+PHP+Javascript 的网络相册,在 2008 年 9 月发布了它的最新版本 03.09.08 Beta 。

ImageVue V2 功能

  • 1.加入了 HTML 相册模式及 Rewrite 地址静态化支持,使原来 Flash 不利于搜索引擎收录的缺点得到很好的改善
  • 2.放弃了 V1 中的相框设计,采用了更加美观的开放界面,使宽屏和大显示器用户拥有更好的浏览效果
  • 3.后台管理模块更加强大,包括管理用户、修改配置文件、更改语言包、更换主题和管理所有图片文件夹等
  • 4.基于 V1 的功能,包括自动探测文件夹、自动生成缩略图、支持 MP3 背景音乐等
  • 目前已经非常完美的支持中文,包括中文目录,文件名,文件描述等等,而你只需要稍微修改一下模板的 CSS 文件中的字体定义而已

ImageVue V2 新功能和特色

  • 1.后台管理员增加目录管理,可设置特定用户管理某一特定图片文件夹,实现了相册的多人管理和分级管理
  • 2.增加了Cache缓存模块,极大的节省了图片打开时间
  • 3.管理员可以在前台页面直接修改图片,使管理直观化

ImageVue V2 官方演示

ImageVue V2 环境需求

ImageVue 运行在 PHP 环境下,并且最好带 GD2 库(为了自动生成缩略图,如果没有 GD2,你也可以手工生成缩略图然后上传)。V2 在后台提供了空间测试功能,用来测试你的空间是否(完全)支持 ImageVue。V2 程序采用了智能模块化设计,所以某些空间上的缺陷并不会影响到整个程序,好比我测试的时候用的 PHPStudy 包默认没有开 EXIF 支持,它只是提醒而已,这并不会影响整体功能。

(要打开 EXIF 功能,你需要编辑 php.ini 文件,取消 php_exif.dll 以及 php_mbstring.dll 前面的注释,而且注意,php_mbstring.dll 必须在 php_exif.dll 之前加载!而 php.ini 中默认 php_exif.dll 是在 php_mbstring.dll 之后的,一定记得调整。)

ImageVueV2

ImageVue V2 简单设置

解压上传后,假设你的相册地址是:

https://www.quakemachinex.com/imagevue/

那么你的后台管理地址是:

https://www.quakemachinex.com/imagevue/imagevue

嗯,不要搞错了,默认用户名和密码都是 admin,进入后它会提示你及时更改这个超级用户密码,安全第一,改了吧。

点 Config,再点右边的 Create New Language ,新建一个语言包,输入 Chines,你就可以自己定制语言包了,要翻译的东西非常简单我就不详细说了。然后你需要在 themes - 你选择的模板 - edit - settings - language 里面填入 Chinese 就让主界面变成中文了。

它默认模板的字体对中文支持都不好,所以你可以在:

“themes - 你选择的模板 - edit - 右边的 Create new theme, based on default theme - Edit theme stylesheet”

里面修改类似:

“font-family: Candara, Arial, "Times New Roman", Times, serif;

的字段为:

" font-family: Tahoma, Arial, "Times New Roman", Times, serif;”

当然你也可以用文本编辑器打开:

https://www.quakemachinex.com/imagevue/imagevue/themes/你选择的模板目录名字

下面的 imagevue.css 文件,查找替换一次性搞定。 :mrgreen:

好了,其他的自己研究吧。 :evil:


Dec 26

Mr. DeZend 是一个完整的本地 DeZend 系统,可以还原/整理大多数经过 Zend 的 PHP 源代码。

指南:
1、操作系统:Windows 2000/XP,内存越大越好,推荐 1G 以上。

2、安装 PHP5 ,假定安装在 c:\php5 ,复制 c:\php5 下所有文件到 c:\php-de 文件夹。

3、安装 ZendOptimizer-3.3.0 ,假定安装在 C:\Program Files\Zend\ZendOptimizer-3.3.0 。

4、解压 dezend.rar 包到 c:\php-de 文件夹,覆盖里面的 php.exe 和 php5ts.dll 文件,还有两个文件 config.ini(混淆函数列表)、PhpVars.reg(环境变量配置)和 decode_all.bat(批量 dezend )下面要用到。

5、修改 c:\php-de 文件夹下的 php.ini 文件,增加下面一个节:

[Zend]
zend_extension_manager.optimizer_ts="C:\Program Files\Zend\ZendOptimizer-3.3.0\lib\Optimizer-3.3.0"
zend_extension_ts="C:\Program Files\Zend\ZendOptimizer-3.3.0\lib\ZendExtensionManager.dll"

修改内存限制
memory_limit = 128M

6、修改 PhpVars.reg 文件,将对应的行修改为:
"PHP_DECODE_INI"="c:\\php-de"
"PHP_DECODE_PATH"="c:\\php-de\\decode"
然后双击该文件,导入注册表。

7、复制要 dezend 的文件夹到 c:\php-de 目录下,假定是 c:\php-de\dezend 。运行 cmd ,执行:
cd c:\php-de
decode_all zend

8、耐心的等一段时间,dezend 好的文件就在 c:\php-de\decode 文件夹了。

提示:
可以修改decode_all里面的*.php *.inc,添加其他扩展名的php文件。

嗯,可以用来破解某些 PHP 源码。


[1/2]  1 2 >