国内顺利使用Google的代理网站

http://www.gugesou.com/
http://www.googke.me/
http://s.amysql.com/
http://onccc.net/
http://www.googleisok.com/
https://yue.pao.im/
https://da.pao.im/
https://ibd.pt/
https://soso.red/
https://google.sqzr.cc/
https://www.out1000.com/
http://web.btbook.net/
https://www.lamjoeone.info/
https://jiong.lu/
http://www.googleforchina.com/
https://g.net.co/
https://repigu.com/
https://awk.so/
http://gl.randomk.org/
https://g4w.me/
https://safesearch.avira.com
https://sec.hikyle.me/
http://suche.web.de/
http://webwebweb.com/
http://guge.io/
https://g.keyiso.com/
https://goojie.me/
http://e127f.azurewebsites.net/
http://0s.o53xo.m5xw6z3mmuxgizi.erenta.ru/
http://www.souji8.com/
http://865ba.azurewebsites.net/
https://gusouk.com/
https://d3vv89cvqbrqlq.cloudfront.net/
http://out1000.com/
https://gg.jude.me/
http://google.chn.im/
http://www.sousuodao.com 搜索岛
http://www.googleout.com/
https://g.ratafee.nl/
http://www.1220.cc/
http://music.google.cn/webhp
https://www.glgoo.com GLGOO
https://gg.eeload.com/ GG.EELOAD.COM
http://gusou.in/ GUSO.IN
http://www.wow.com/ WOW
https://xie.lu/ 斜路
https://www.ggncr.com GGNCR.COM
http://www.gfsoso.com 谷粉搜搜
http://www.886404.com/ 886 404 Google
https://g.ttlsa.com/
http://home.tb.ask.com/ ASK Google
http://verygoogle.com/
http://g.openibm.com/ OpenIBM Google
http://z7.cc
http://www.Google.com.im 谷歌复原
http://goog.sinaapp.com
https://sinaapp.co/ Google镜像
https://wen.lu/ Google问路
http://www.sssis.com 备案域名反代理到Google IP
http://www.gvgle.com 代理到Google IP
http://gu1234.com 代理到Google IP
http://www.xiexingwen.com Google镜像,动态检测可用Google服务器IP,实时更新
https://s3.amazonaws.com/google./index.html Google免翻墙镜像,如果镜像被封锁,访问 https://github.com/greatfire/wiki 获得最新网址。
http://www.GoogleStable.com www.GoogleStable.com
http://www.tmd123.com 通天塔

来源:国内顺利使用Google的另类技巧

yii-tips

  • 默认控制器

    1. 普通控制器

      defaultController => 'site'
      
    2. module内的默认控制器

      modules => array(
          'web' => array(
              'class' => 'application.modules.web.WebModule',
              'defaultController' => 'index'
          )
      )
      
    3. 默认控制器为module内的控制器

      defaultController => 'web/site'
      
  • 别名

    1. 内置别名有

      Yii::setPathOfAlias('application',$this->getBasePath());
      Yii::setPathOfAlias('webroot',dirname($_SERVER['SCRIPT_FILENAME']));
      Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions');
      
    2. 获取别名的路径

      Yii::app->getAliasPath('webroot');
      
    3. 自定义别名

      Yii::setPathOfAlias('test',$this->getBasePath());
      
  • 路由

    1. 后缀

      'urlSuffix'  => '.html'
      
    2. 忽略大小写

      'caseSensitive' => false,
      
    3. 隐藏module

      '/<controller:\w+>' => 'web/<controller>',
      '/<controller:\w+>/<action:\w+>' => 'web/<controller>/<action>',
      '<controller:\w+>/<action:\w+>/<id:\d+>'=>'web/<controller>/<action>'
      
  • 日志

    1、 显示执行的sql

    'routes' => array(
        array(
          'class' => 'CWebLogRoute',
           'levels' => 'trace,warning,error,info',
           'categories' => 'system.db.CDbCommand.*',
       )
    ),
    

    2、自定category调试控制器台程序

    array(
        'class'=>'CFileLogRoute',          
        'categories'=>'debug.*',
    ),
    

    使用

    Yii::log($message, 'info', 'debug');
    
  • ActiveRecord

    1. 自动记录 创建时间、修改时间

      protected function beforeSave()
      {
          if ($this->isNewRecord) {
              $this->add_time = time();
          } else {
              $this->modify_time = time();
          }
          return parent::beforeSave();
      }
      
2. 乐观锁(版本号)

        class PostModel extends CActiveRecord
        {
            public function rules()
            {
                return array(
                    array('version', 'required'),
                    array('id', 'exists', 'on' => 'update', 'criteria' => array('condition' => 'version <'. $this->version))
                );
            }
        }

        $model1 = PostModel::model()->findByPk(1);
        $model2 = PostModel::model()->findByPk(1);

        $model1->version = $model->version++;
        $model->save();//true


        $model2->save();//false
  • 显示控制器action执行时间

    protected function afterAction($action)
    {
        $time = sprintf('%0.5f', Yii::getLogger()->getExecutionTime());
        $memory = round(memory_get_peak_usage() / (1024 * 1024), 2) . "MB";
    
        echo "Time: $time, memory: $memory";
        parent::afterAction($action);
    }
    
  • 维护通知main.php

    return array(
     .... 
         'catchAllRequest'=>array(
              'offline/notice'
              'otherParams'=>'value',
          ),
     ....
    ),
    

memcached批量删除

都说Cache是万金油,哪里不舒服抹哪里。不过要想批量删除缓存可没那么简单,
memcached 不支持批量删除缓存键。

遍历方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* Function to get all memcache keys
* @author Manish Patel
* @Created: 28-May-2010
* @modified: 16-Jun-2011
*/
function getMemcacheKeys() {
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect to memcache server");
$list = array();
$allSlabs = $memcache->getExtendedStats('slabs');
$items = $memcache->getExtendedStats('items');
foreach($allSlabs as $server => $slabs) {
foreach($slabs AS $slabId => $slabMeta) {
$cdump = $memcache->getExtendedStats('cachedump',(int)$slabId);
foreach($cdump AS $keys => $arrVal) {
if (!is_array($arrVal)) continue;
foreach($arrVal AS $k => $v) {
echo $k .'<br>';
}
}
}
}
}//EO getMemcacheKeys()
?>

代码摘自 php手册

版本号方式

通过维护一个版本号管理缓存键,删除缓存时直接更新版本号,则带有版本号的缓存到过期时间时自动被删除(memcached的删除机制和发展方向)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
$cache = new Memcache();
$cache->connect('127.0.0.1', 11211);
$key1 = genKey('key1');
$cache->set($key1, 'this is test1', 0, 60);
$key2 = genKey('key2');
$cache->set($key2, 'this is test2', 0, 60);
print_r($cache->get($key1)); //this is test1
print_r($cache->get($key2)); //this is test2
//修改
delVersionKey();
//生成代码号的key
function genKey($key)
{
global $cache;
$versionKey = getVersionKey();
$version = $cache->get($versionKey);
if($version === false) {
$cache->set($versionKey, rand(1, 100));
}
return $key . $version;
}
//版本号前缀
function getVersionKey()
{
return 'public_version_';
}
//更新本版号值
function delVersionKey()
{
global $cache;
$cache->increment(getVersionKey());
}
?>

打tag方式

存储时关联缓存键和tag(可以多个)。删除时通过tag找到管理的缓存键,便利删除。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
class KeyEnabled_Memcached extends Zend_Cache_Backend_Memcached
{
private function getTagListId()
{
return "MyTagArrayCacheKey";
}
private function getTags()
{
if(!$tags = $this->_memcache->get($this->getTagListId()))
{
$tags = array();
}
return $tags;
}
private function saveTags($id, $tags)
{
// First get the tags
$siteTags = $this->getTags();
foreach($tags as $tag)
{
$siteTags[$tag][] = $id;
}
$this->_memcache->set($this->getTagListId(), $siteTags);
}
private function getItemsByTag($tag)
{
$siteTags = $this->_memcache->get($this->getTagListId());
return isset($siteTags[$tag]) ? $siteTags[$tag] : false;
}
/**
* Save some string datas into a cache record
*
* Note : $data is always "string" (serialization is done by the
* core not by the backend)
*
* @param string $data Datas to cache
* @param string $id Cache id
* @param array $tags Array of strings, the cache record will be tagged by each string entry
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @return boolean True if no problem
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
if ($this->_options['compression']) {
$flag = MEMCACHE_COMPRESSED;
} else {
$flag = 0;
}
$result = $this->_memcache->set($id, array($data, time()), $flag, $lifetime);
if (count($tags) > 0) {
$this->saveTags($id, $tags);
}
return $result;
}
/**
* Clean some cache records
*
* Available modes are :
* 'all' (default) => remove all cache entries ($tags is not used)
* 'old' => remove too old cache entries ($tags is not used)
* 'matchingTag' => remove cache entries matching all given tags
* ($tags can be an array of strings or a single string)
* 'notMatchingTag' => remove cache entries not matching one of the given tags
* ($tags can be an array of strings or a single string)
*
* @param string $mode Clean mode
* @param array $tags Array of tags
* @return boolean True if no problem
*/
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
if ($mode==Zend_Cache::CLEANING_MODE_ALL) {
return $this->_memcache->flush();
}
if ($mode==Zend_Cache::CLEANING_MODE_OLD) {
$this->_log("Zend_Cache_Backend_Memcached::clean() : CLEANING_MODE_OLD is unsupported by the Memcached backend");
}
if ($mode==Zend_Cache::CLEANING_MODE_MATCHING_TAG) {
$siteTags = $newTags = $this->getTags();
if(count($siteTags))
{
foreach($tags as $tag)
{
if(isset($siteTags[$tag]))
{
foreach($siteTags[$tag] as $item)
{
// We call delete directly here because the ID in the cache is already specific for this site
$this->_memcache->delete($item);
}
unset($newTags[$tag]);
}
}
$this->_memcache->set($this->getTagListId(),$newTags);
}
}
if ($mode==Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG) {
$siteTags = $newTags = $this->getTags();
if(count($siteTags))
{
foreach($siteTags as $siteTag => $items)
{
if(array_search($siteTag,$tags) === false)
{
foreach($items as $item)
{
$this->_memcache->delete($item);
}
unset($newTags[$siteTag]);
}
}
$this->_memcache->set($this->getTagListId(),$newTags);
}
}
}
}

代码摘自zendframework Memcache should support tags

参考

实现远程文件打包下载

  • 传统实现方法
    下载远程文件到本地服务器—>压缩–>下载–>删除。
    这样实现 消耗内存、cpu、大量磁盘空间、速度太慢(取决于网络).

  • 使用第三方mod_zip 实现打包下载。
    内存消耗极低。
    通过输出X-Archive-Files和文件列表,自动将远程文件打包下载避免了临时文件的创建和删除。

安装过程

下载mod_zip 源文件

1
2
#cd /usr/local/src
#git clone https://github.com/evanmiller/mod_zip.git

tengine安装过程

使用dso-tool编译动态模块

1
2
3
/usr/local/tengine/bin/dso-tool \
--add-module=/usr/local/src/mod_zip/ \
--dst=/usr/local/tengine/modules/

报错1

此处输入图片的描述

1
#vi +331 /usr/local/src/mod_zip/ngx_http_zip_file.c

修改为
此处输入图片的描述
保存
重新编译
仍然报错

ngx_http_zip_header_charset_name defined but not use```
1
2
```
#vi +11 /usr/local/src/mod_zip/ngx_http_zip_file.c

注释掉

1
//static ngx_str_t ngx_http_zip_header_charset_name = ngx_string("upstream_http_x_archive_charset");

重新编译通过

查看动态模块是否生成

1
#ls /usr/local/tengine/modules/

  • 修改nginx配置文件测试
1
2
3
4
5
6
7
#vi nginx.conf
dso {
...
load ngx_http_zip_module.so;
...
}
  • 编写测试代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
vi zip.php
<?php
header('X-Accel-Chareset: utf-8');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=test.zip');
header('X-Archive-Files: zip');
$crc32 = "-";
//格式 crc32(可以用-忽略)、文件大小、文件uri、文件名
printf("%s %d %s %s\n", $crc32, 688746, '/lms/M00/00/11/qMB6HVOaakWARZXJAAqCatIt43Y37.pptx', '1.pptx');
printf("%s %d %s %s\n", $crc32, 5236, '/default.conf', 'd.conf');
?>
  • tips

    • 文件大小一定要正确 否则压缩打不开
    • 文件uri (非url 远程文件需要配置nginx跳转).
      例子中的lms(fastdfs)远程文件 需要在nginx内做配置跳转到正确的地址。
    • 如果不需要断点续传crc32参数可以使用-忽略。
      1
      2
      3
      4
      5
      6
      7
      8
      #vi nginx.conf
      server {
      ...
      location /lms {
      proxy_pass http://fastdf_server;
      }
      ...
      }

nginx 安装

  • 查看旧的编译参数

    1
    #/usr/local/nginx/sbin/nginx -V
  • 编译

1
2
3
4
5
6
#/usr/local/nginx/configure \
--prefix=/usr/local/nginx \
--user=www --group=www \
--add-module=/usr/local/src/mod_zip
#make

报错级处理参考tengine内的处理方法.

#升级nginx

1
2
3
4
#cp objs/nginx /usr/local/nginx/sbin
#/usr/local/nginx/sbin/nginx -t
#/usr/local/nginx/sbin/nginx

参考文档
NgxZip
利用Nginx第三方模块,实现附件打包下载
mod_zip