Category: IT

在线广告作弊手段一览

这里提到的在线广告作弊是指媒体为了刷广告流量而进行的作弊。他们的作弊手段很多, 这里介绍常见的几种。

iframe是广告作弊最常用的技巧,就是在自己的网页上嵌入iframe, 大小为0×0或1×1,也就是用户不可见。通过iframe打开其他页面,在用户看不见的情况下刷流量。别看iframe简单,里面花样很多。

页面内嵌入本站页面的iframe

iframe打开和当前页一样的页面地址,或本站的其他页面。 这样用户的一个浏览行为,很轻松就从1个pv翻倍变成2个pv。如果嵌入iframe多点, 就能翻3倍,4倍…。

但使用这个方法很容易被发现,广告投放方,通过分析UV,独立IP等很容易就发现异常。 这是很老的方法,不过还是有些网站乐此不疲。

两个站点间互相嵌入对方站点页面的iframe

这是比较巧妙的作弊技巧,UV,独立IP等分析方法是不能发现异常的。

 

双层iframe

作弊的iframe为了不让人看见,大小只有0×0或1×1,但有些在线广告在显示时会判断浏览窗口大小,如果太小可能就不能显示。这时有些网站就采用了双层iframe技术来刷广告流量。 第一层1×1大小的iframe中又嵌入一个iframe,这个第二层iframe是正常浏览窗口大小,广告代码很难发现异常。

这种作弊方式使用巧妙的,会让主页面和两个iframe使用三个不同的域名,这样因为跨域的问题, 里面的js不可能得到最外层真正的页面地址, 想抓证据都抓不到。

 

IP屏蔽

有些站点在进行作弊时,会屏蔽北京,上海等大城市的访问,你从这些地区访问时,看不到他们的作弊代码,一切正常。等换用其他地方的代理访问时,你在他们页面里就能看到作弊用iframe代码。 这是因为很多IT,在线广告公司都在这些大城市,这种屏蔽让他们的作弊手段很难被同业发现。

 

购买垃圾流量

现在来自iframe,木马的垃圾流量都是明码标价在卖的,可以用这些流量来刷页面,刷广告。这种也比较难以发现。

 

网站去刷流量目的往往比较复杂,一是刷广告流量,赚广告商和广告主的钱,二是为了alexa之类的排名,也有是为了给投资人看所谓的“业绩”。

 

上面谈的基本都是CPM广告方式的作弊,下面说说其他的。

 

CPC作弊

CPC作弊其实是很简单的,只要用iframe打开点击链接即可。

 

CPA作弊

有些网站广告按CPA结算,比如注册人数等。 这种情况下,有的公司会做专门的自动注册机,保证你的注册人数疯狂上涨。

 

CPS作弊

很多人感觉CPS方式是不可能作弊的,其实这也是可以的。 卖个关子,下次和大家介绍Smile

 

其实大多数作弊方法通过耐心细致的分析,不难发现端倪。 但中国在线广告的作弊还是相当严重,形成这种现象的原因是蛮有意思的,和多人都探讨过, 有时间另写个博文分析。

 

另:今年的北马报了半程,但膝盖受伤,没跑成,本来这是我参加北马的第10个年头,很有纪念意义,结果只能抱恨。龙舟队的队友Eric背着我的号码跑了下来,没有浪费这个号码。

 

请参看其他有关马拉松的博文。

Windows Live Messenger 2011尝鲜

今天装了Windows Live 2011, 用上了Windows Live Messenger 2011。一上来显示的窗口如下:

windows live messeger 默认界面

原先的Messenger窗口被挤到右上的小角落,和右下的广告区域差不多大。而MSN中国网站的内容占据了整个界面的一半以上。 好不容易找到右上角有个小按钮,把界面变回原先的界面:

windows live messeger 简单界面

结果在默认显示方式下,下面和messenger无关的区域占了至少1/3的界面高度。放大窗口,发现联系人的显示方式变了:

windows live messeger简单界面最大化

联系人多列显示,这样同屏显示的联系人数量确实多了不少,但找一个人需要视线在屏幕上做“之”字来回扫描,很不习惯。

原先在msn(live messenger)显示的名字一直是Oldmonk,安装完新版后,发现名字变成了在微软站点填写的真名。在菜单里选择改名,居然还要去live.com网站上去改,输入一个Oldmonk做first name还不行,必须再输入个last name,只好输入“扫地”做first name,“老僧”做last name。

最希望添加的通话记录和hotmail帐号同步的功能还是没有添加,依然在本地保存,也就更谈不上通话记录的搜索了。

微软大概是想通过hotmail和msn积累起的用户量建立起类似facebook的真名为基础的sns社区,可有些画虎不成反类犬的感觉,让我也离msn渐行渐远了。

Git安装经验

最近安装Git服务器折腾了很多时间Sad smile, 其实就卡在一些小地方。大多数git安装指南提到的东西就不说了,就记录一下卡住我的两点:

  1. git访问接口有ssh, http, git://。 刚开始找到的安装指南这几种方式都实现了,于是也一样画葫芦做了一遍,尤其指南中说git:// 方式最快,所以特别看重这个。实现git://协议需要在服务器安装git-daemon, 在debian用apt-get install git-daemon-run安装, 记得要开放tcp 9418 端口。 后来发现压根不需要实现全部接口,只保留一种就足够了。 其中http方式是readonly的,而git://方式需要多开放一个端口,于是只保留了ssh方式
  2. 桌面是windows,用msysgit+TortoisGit。msysgit用ssh-keygen生成的密钥,需要放到msysgit安装目录下的.ssh目录下,很多安装指南上说要放到C:\Users\[用户名]\.ssh下, 耽误了我很多时间。但这个密钥只是对命令行的git有效。 TortoiseGit要用随它一起安装的Puttygen生成密钥,其中的公钥不要保存文件,而是直接从生成窗口中拷贝,追加到服务器上authorized_keys里。某个指南讲的保存公钥文件再cat 公钥文件>>authorized_keys的方式是行不通的。

Tags:

categories IT

Google搜索结果预览

刚才第一次看到Google搜索结果预览,搜索感恩节,结果的前5个都支持预览。下图红框标出来的就是预览图。让我佩服的是,预览图中加上了搜索关键词所在的段落特别强调标出,关键词用红字显示。

Google Instant Previews

 

通过这项技术的实现我猜google搜索技术已经实现了如下功能:

  1. 索引一个关键词时,google能准确知道这个关键词在真实网页中所在的位置,大小
  2. 搜索爬虫能够解析javascript。 在firefox中用noscript关闭js解析,第一个搜索结果的页面中右侧是显示是完全不同的

本来这就要点发布,突然才又想了想,感觉google很有可能是用webkit之类的浏览器rendering engine渲染出来的,并不能证明google爬虫就有真正完全解析html,css, js的能力。 大家认为呢?

Tags:

categories IT

服务器备份脚本

前些天Linode的Fremont机房出现电源事故,造成一些服务器数据丢失,给一些人造成不小的影响。 以前自己也写过简单的在线备份脚本,但功能太弱,所以后来又写了个复杂点的。这里共享现在用的服务器备份脚本,希望对大家有用。该脚本特点如下:

  1. 用php开发
  2. 通过sftp把指定的目录和数据库备份到指定服务器
  3. 备份目录时会检测目录内文件的最后修改日期,如果和上次备份一样就不会再备份
  4. 每个备份文件都加日期戳,备份文件名是www.20101120.tar.gz 这种。
  5. 备份目录时可指定剔除的文件名
  6. 可以设定一个备份文件的保留时间,超过这个时间就删除。还可以设定一个备份文件保留的最少分数,如果一个数据库或一个目录的备份少于这个份数,超过设定时间也不会删除。

代码遵守GPL协议,请在该协议基础上随便使用。

因为当时是自用,而且对php不熟,所以很多地方写得并不严谨,欢迎指出。

下载链接是: http://www.doyj.com/wp-content/uploads/2010/11/phpbk.zip

下面是备份文件中最主要的phpbk.php的代码

  1. <?php
  2. /*
  3. Server Backup Script 0.1 2010/11/22
  4. Programmer: Cui Yingjie
  5. Email: cuiyingjie@gmail.com 
  6. Blog: http://www.doyj.com
  7. Sina microblog: http://t.sina.com.cn/laoseng
  8. Twitter: http://twitter.com/#!/oldmonk
  9.  
  10.  
  11. **************************************************************
  12. Copyright (C) 2010 Cui Yingjie
  13. All Rights Reserved
  14.  
  15. This library is free software: you can redistribute it and/or
  16. modify it under the terms of the GNU Lesser General Public
  17. License as published by the Free Software Foundation, either
  18. version 3 of the License, or (at your option) any later version.
  19.  
  20. This library is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23. Lesser General Public License for more details.
  24.  
  25. You should have received a copy of the GNU Lesser General Public
  26. License along with this library; If not, see <http://www.gnu.org/licenses/>.
  27. */
  28.  
  29. require_once("sftp.php");                                           
  30.  
  31. define('BKFTP_SERVER','www.bkserver.com');        //backup server address
  32. define('BKFTP_USER','bkuser');                                //backup server user name
  33. define('BKFTP_PASS','password');                            //backup server password
  34. define('BKFTP_PORT', 22);                                            //backup server port
  35. define('BKFTP_KEEPDAYS','60');                              //backup files keep days
  36. define('BKFTP_MAXBKCOUNT','4');                                //定义备份保留的最大个数, 当一个备份文件已经超过了设定的保留最大天数,但这个备份的数量少于最大备份个数时不删除此文件
  37.  
  38.  
  39. function load_array_dump($filename) 
  40. {
  41.     return unserialize(file_get_contents($filename));
  42. }
  43.  
  44. //first char of filepath must be  "/".
  45. function get_bkpath( $filepath )
  46. {
  47.     return '/home/'.BKFTP_USER.$filepath ;    //need be changed according your server configuration. 这段是因为备份服务器的目录结构是 /home/用户名,请根据自己服务器器的情况修改,
  48. }
  49.  
  50. function save_array_dump($filename, $array) 
  51. {
  52.     $fp = fopen($filename, 'w+') or die("I could not open $filename.");
  53.     fwrite($fp, serialize($array));
  54.     fclose($fp);
  55. }
  56.  
  57. function nftpupload( $srcfile, $dest )
  58. {
  59.     try 
  60.     {
  61.         $ftp_dir=$dest;
  62.        
  63.         $filename = end(explode('/',$srcfile )) ;
  64.        
  65.         //build a fully qualified (FTP) path name where the file will reside
  66.         $destination_file= get_bkpath( $ftp_dir.$filename ) ;   
  67.        
  68.         $sftp = new SFTPConnection(BKFTP_SERVER, BKFTP_PORT);
  69.         $sftp->login(BKFTP_USER, BKFTP_PASS);
  70.        
  71.         $sftp->uploadFile($srcfile, $destination_file);
  72.     }
  73.     catch (Exception $e) 
  74.     {
  75.         echo $e->getMessage() . "\n";
  76.     }
  77. }
  78.  
  79. function IsFTPFileExist( $ftpfile )
  80. {
  81.     try 
  82.     {
  83.         $sftp = new SFTPConnection(BKFTP_SERVER, BKFTP_PORT);
  84.         $sftp->login(BKFTP_USER, BKFTP_PASS);
  85.        
  86.         $filelist = $sftp->scanFilesystem( get_bkpath( dirname( $ftpfile ) ) );
  87.        
  88.         return in_array( basename( $ftpfile ) , $filelist ) ;
  89.     }
  90.     catch (Exception $e) 
  91.     {
  92.         echo $e->getMessage() . "\n";
  93.     }
  94.  
  95.     return false ;
  96. }
  97.  
  98. function DeleteNDaysAgoInDirFTPFile( $ftpdir , $days ) 
  99. {
  100.     try 
  101.     {
  102.         $sftp = new SFTPConnection(BKFTP_SERVER, BKFTP_PORT);
  103.         $sftp->login(BKFTP_USER, BKFTP_PASS);
  104.        
  105.         $filelist = $sftp->scanFilesystem(  get_bkpath( $ftpdir ) );
  106.        
  107.         $ic = count( $filelist ) ;
  108.         $afiles = array() ;
  109.         for( $i = 0 ; $i < $ic ; $i++ )
  110.         {
  111.             $afn = explode('.',$filelist[ $i ] ) ;
  112.             if( count( $afn ) != 4 )
  113.                 continue ;
  114.             if( strlen( $afn[ 1 ] ) != 8 )
  115.                 continue ;
  116.            
  117.             if( !isset( $afiles[ $afn[ 0 ] ] ) )
  118.                 $afiles[ $afn[ 0 ] ] = array() ;
  119.            
  120.             $afiles[ $afn[ 0 ] ][ $afn[ 1 ] ] = $filelist[ $i ] ;
  121.         }
  122.        
  123.         $ic = count( $afiles ) ;
  124.         foreach (  $afiles as $key => $value ) 
  125.         {
  126.             $jc = count( $value ) ;
  127.             if( $jc < BKFTP_MAXBKCOUNT )
  128.                 continue ;
  129.            
  130.             ksort( $value ) ;
  131.             foreach( $value as $date => $filepath ) 
  132.             {
  133.                 $bktime = strtotime( substr( $date , 0 , 4 ).'-'.substr( $date , 4 , 2 ).'-'.substr( $date , 6 , 2 ).' 00:00:00' ) ;
  134.                 if( $bktime == false )
  135.                     continue ;
  136.                
  137.                 $diff = time() - $bktime ;
  138.                 if( $diff > 86400 * $days )
  139.                 {
  140.                     $jc-- ;
  141.                    
  142.                     $sftp->deleteFile( get_bkpath( $ftpdir.$filepath ) ) ;
  143.                     if( $jc < BKFTP_MAXBKCOUNT )
  144.                         break ;
  145.                 }
  146.             }
  147.         }
  148.     }
  149.     catch (Exception $e) 
  150.     {
  151.         echo $e->getMessage() . "\n";
  152.     }
  153. }
  154.  
  155. //获取一个目录下所有文件最晚的最后修改时间
  156. function GetPathLastMTime( $filepath , $aexcludefiles )
  157. {
  158.     if (is_dir($filepath)) 
  159.     {
  160.         $lmtime = strtotime( '2000-01-01 00:00:00' ) ;
  161.         if ($dh = opendir($filepath)) 
  162.         {
  163.             while (($file = readdir($dh)) !== false) 
  164.             {
  165.                 if( $file == '.' || $file == '..' )
  166.                     continue ;
  167.                    
  168.                 if( in_array( $file , $aexcludefiles ) )
  169.                     continue ;
  170.                
  171.                 if( is_link( $filepath."/".$file ) )
  172.                     continue ;
  173.                    
  174.                 $lt1 = GetPathLastMTime( $filepath."/".$file    , $aexcludefiles ) ;
  175.                
  176.                 if( $lt1 > $lmtime )
  177.                     $lmtime = $lt1 ;
  178.             }
  179.            
  180.             closedir($dh);
  181.         }
  182.        
  183.         return $lmtime ;
  184.     }
  185.     else
  186.         return filemtime( $filepath ) ;
  187. }
  188.    
  189.     $bkdatafile = '/backup/bkdata.dat' ;        //备份时用到的数据文件,会在这里保存目录的最后修改时间,用来在下次备份中做比对,看是否有被修改
  190.     $bkdatdir     = '/backup/tmp' ;                        //备份用到的临时目录
  191.     $bklogfile     = '/backup/bk.log' ;                //备份日志文件
  192.     $tarexclude = '/backup/tarexclude.cfg' ;    //备份tar目录时需要剔除的文件名列表,会把日志,缓存等文件剔除掉
  193.    
  194.     $dbbkftppath = '/backup/db/' ;                    //数据库备份到备份服务器上的目录名
  195.     $filebkftppath = '/backup/' ;                        //目录备份到备份服务器上的目录名
  196.    
  197.     DeleteNDaysAgoInDirFTPFile( $dbbkftppath , BKFTP_KEEPDAYS ) ;           
  198.     DeleteNDaysAgoInDirFTPFile( $filebkftppath , BKFTP_KEEPDAYS ) ;
  199.    
  200.     $aexcludefiles = array( 'logs' , 'nobk' , 'cache' , '.log.gz' , '.log' ) ;   
  201.    
  202.     $abkdb = array( array( 'user' => 'dbadmin1' , 'pin' => 'dbpassword1' , 'dbname' => 'db1' ) , //这个数组里放入要备份的数据库列表,用户名,口令,数据库名
  203.         array( 'user' => 'dbadmin2' , 'pin' => 'dbpassword2' , 'dbname' => 'db2' ) ,
  204.         array( 'user' => 'dbadmin3' , 'pin' => 'dbpassword3' , 'dbname' => 'db3' ) ,
  205.                 ) ;
  206.                
  207.     $abkdir = array( '/home/user' , '/var/www'    , '/etc' ) ;        //在这个数组里放入要备份的目录路径
  208.    
  209.     $bklog = fopen( $bklogfile, 'a');
  210.  
  211.     if( file_exists( $bkdatafile ) )
  212.     {
  213.         $aLastBkTime = load_array_dump( $bkdatafile ) ;
  214.     }
  215.     else
  216.     {
  217.         $ic = count( $abkdir ) ;
  218.         for( $i = 0 ; $i < $ic ; $i++ )
  219.         {
  220.             $aLastBkTime[ $abkdir[ $i ] ] = strtotime( '2000-01-01 00:00:00' ) ;
  221.         }
  222.     }
  223.  
  224.     //备份数据库
  225.     $ic = count( $abkdb ) ;
  226.     for( $i = 0 ; $i < $ic ; $i++ )
  227.     {
  228.         $sqlfile = $bkdatdir.$abkdb[ $i ][ 'dbname' ].'.'.gmstrftime ('%Y%m%d', time()).'.sql' ;
  229.         $gzsqlfile = $sqlfile.'.gz' ;
  230.         $ftpfile = $dbbkftppath.basename( $gzsqlfile ) ;
  231.        
  232.         if( IsFTPFileExist( $ftpfile ) )
  233.         {
  234.             $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' ftp file exist '.$ftpfile."\n" ;
  235.             fwrite($bklog, $smsg);
  236.             echo $smsg ;
  237.             continue ;
  238.         }
  239.        
  240.         $cmd = '/usr/bin/mysqldump -u'.$abkdb[ $i ][ 'user' ].' -p'.$abkdb[ $i ][ 'pin' ].' -f '.$abkdb[ $i ][ 'dbname' ].'>'.$sqlfile ;
  241.        
  242.         $sr = shell_exec( $cmd ) ;
  243.         $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' backup database '.$abkdb[ $i ][ 'dbname' ]." $sr\n" ;
  244.         fwrite($bklog, $smsg);
  245.         echo $smsg ;
  246.        
  247.         $cmd = '/bin/gzip -9 -f '.$sqlfile ;
  248.         $sr = shell_exec( $cmd ) ;
  249.         $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' compress sql file '.$sqlfile." $sr\n" ;
  250.         fwrite($bklog, $smsg );
  251.         echo $smsg ;
  252.        
  253.         nftpupload( $gzsqlfile , $dbbkftppath ) ;
  254.        
  255.         $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' ftp upload file '.$gzsqlfile.' to '.$dbbkftppath."\n" ;
  256.         fwrite($bklog, $smsg );
  257.         echo $smsg ;
  258.        
  259.         unlink( $gzsqlfile ) ;
  260.     }
  261.    
  262.     //备份文件
  263.     $ic = count( $abkdir ) ;
  264.     for( $i = 0 ; $i < $ic ; $i++ )
  265.     {
  266.         $tarfile = $bkdatdir.end(explode('/',$abkdir[ $i ] )).'.'.gmstrftime ('%Y%m%d', time()).'.tar.gz' ;
  267.         $ftpfile = $filebkftppath.basename( $tarfile ) ;
  268.        
  269.         if( IsFTPFileExist( $ftpfile ) )
  270.         {
  271.             $aLastBkTime[ $abkdir[ $i ] ] = time() ;
  272.             $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' ftp file exist '.$ftpfile."\n" ;
  273.             fwrite($bklog, $smsg);
  274.             echo $smsg ;
  275.             continue ;
  276.         }
  277.            
  278.        
  279.         $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' check last update time '.$abkdir[ $i ]."\n" ;
  280.         fwrite($bklog, $smsg );
  281.         echo $smsg ;
  282.        
  283.         $lmtime = GetPathLastMTime( $abkdir[ $i ] , $aexcludefiles ) ;
  284.        
  285.         if( $lmtime <= $aLastBkTime[ $abkdir[ $i ] ] )
  286.         {
  287.             $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' file is not changed '.$abkdir[ $i ]."\n" ;
  288.             fwrite($bklog, $smsg );
  289.             echo $smsg ;
  290.             continue ;
  291.         } 
  292.        
  293.         //备份文件
  294.         $cmd = 'tar -czf '.$tarfile.' --exclude-caches --exclude-from='.$tarexclude.' '.$abkdir[ $i ] ;
  295.         $sr = shell_exec( $cmd ) ;
  296.         $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' compress file '.$tarfile." $sr\n" ;
  297.         fwrite($bklog, $smsg );
  298.         echo $smsg ;
  299.        
  300.         nftpupload( $tarfile , $filebkftppath  ) ;
  301.         $smsg = gmstrftime ('%b %d %Y %H:%M:%S', time()).' ftp upload file '.$tarfile.' to '.$filebkftppath."\n" ;
  302.         fwrite($bklog, $smsg );
  303.         echo $smsg ;
  304.        
  305.         $aLastBkTime[ $abkdir[ $i ] ] = time() ;
  306.        
  307.         unlink( $tarfile ) ;
  308.     }
  309.    
  310.     save_array_dump( $bkdatafile , $aLastBkTime ) ;   
  311. ?>

下面是sftp.php的内容

  1. //Need libssh2 libssh2-php, PECL ssh2 >= 0.9.0
  2. class SFTPConnection
  3. {
  4.     private $connection;
  5.     private $sftp;
  6.  
  7.     public function __construct($host, $port=22)
  8.     {
  9.         $this->connection = @ssh2_connect($host, $port);
  10.         if (! $this->connection)
  11.             throw new Exception("Could not connect to $host on port $port.");
  12.     }
  13.  
  14.     public function login($username, $password)
  15.     {
  16.         if (! @ssh2_auth_password($this->connection, $username, $password))
  17.             throw new Exception("Could not authenticate with username $username " . "and password $password.");
  18.         $this->sftp = @ssh2_sftp($this->connection);
  19.         if (! $this->sftp)
  20.             throw new Exception("Could not initialize SFTP subsystem.");
  21.     }
  22.  
  23.     public function uploadFile($local_file, $remote_file)
  24.     {
  25.         $sconn = $this->connection;
  26.         ssh2_scp_send ( $sconn , $local_file , $remote_file ) ;
  27.         /*$sftp = $this->sftp;
  28.         $stream = @fopen("ssh2.sftp://$sftp$remote_file", 'w');
  29.         if (! $stream)
  30.             throw new Exception("Could not open file: $remote_file");
  31.         $data_to_send = @file_get_contents($local_file);
  32.         if ($data_to_send === false)
  33.             throw new Exception("Could not open local file: $local_file.");
  34.         if (@fwrite($stream, $data_to_send) === false)
  35.             throw new Exception("Could not send data from file: $local_file.");
  36.         @fclose($stream);*/
  37.     }
  38.    
  39.         function scanFilesystem($remote_file) {
  40.               $sftp = $this->sftp;
  41.             $dir = "ssh2.sftp://$sftp$remote_file"
  42.               $tempArray = array();
  43.             $handle = opendir($dir);
  44.           // List all the files
  45.             while (false !== ($file = readdir($handle))) {
  46.             if (substr("$file", 0, 1) != "."){
  47.               if(is_dir($file)){
  48. //                $tempArray[$file] = $this->scanFilesystem("$dir/$file");
  49.                } else {
  50.                  $tempArray[]=$file;
  51.                }
  52.              }
  53.             }
  54.            closedir($handle);
  55.           return $tempArray;
  56.         }   
  57.  
  58.     public function receiveFile($remote_file, $local_file)
  59.     {
  60.         ssh2_scp_recv( $this->$connection , $remote_file , $local_file ) ;
  61.         /*$sftp = $this->sftp;
  62.         $stream = @fopen("ssh2.sftp://$sftp$remote_file", 'r');
  63.         if (! $stream)
  64.             throw new Exception("Could not open file: $remote_file");
  65.         $contents = fread($stream, filesize("ssh2.sftp://$sftp$remote_file"));           
  66.         file_put_contents ($local_file, $contents);
  67.         @fclose($stream);*/
  68.     }
  69.        
  70.     public function deleteFile($remote_file){
  71.      $sftp = $this->sftp;
  72.       unlink("ssh2.sftp://$sftp$remote_file");
  73.     }
  74. }
  75.  
  76. ?>

代码运行环境是php 5, mysql 5, 要安装libssh2-php, 没在其他环境下测试过。现在用cron每天定期运行该脚本,曾有次误删网站根目录全部内容,幸亏有前一天的备份才得以立刻恢复。照理应该再写个对应的恢复脚本,但一直犯懒没写,想等着服务器出问题再说,希望不会有这样的机会。

欢迎大家使用,有啥意见请多交流, 联系方式写在了代码中。

Tags:

categories IT

推荐个性价比很高的wifi信号覆盖方案

以前为团园做过wifi信号覆盖,但信号总是不稳定。 后来自己在家做的时候,发现还是要用wds来做效果最好,当时原生支持wds的路由还找不到,是买了linksys路由后自己刷ddwrt来做wds,效果很好,一直用到现在。前一阵左岸说无线信号频频出问题,于是重新找方案,最终是用三个TP-LINK WR841N来做wds,效果非常好。这个路由支持802.11N制式,原厂固件就支持wds,而且信号极佳,在京东只卖143元。 在网上找到个不错的教程,按图索骥就把信号覆盖做好了。

Tags:

categories IT

改用围脖直播

wordpress老死

移步围脖

Tags:

categories IT

我们小区的房地产中介市场

昨天去散步时发现旁边的小区14个底商里有7个是房地产中介,这才想起自己住的小区里地产中介也很多。

住的小区分南北区,我们住南区,有8栋楼,每栋都至少有1家地产中介,多的有两家,整个南区应该有10家以上的中介。 曾经去过其中一家,大概有8个左右的工位,也就是职工人数在8个左右,也曾看到有的房地产中介把人拉出来在外面培训,大约10个人左右。就按每个中介8个人算,算下来我们这个小区南区的地产从业人员应该在80个,假设地产从业人员平均的人力成本在每个月5000元,那么每个月这些地产公司的人力维持费用要40万。因为小区南区实行比较严格的封闭管理,所以这些中介应该主要就是做小区南区的生意。

中介只能从租住和房屋买卖上赚取佣金。小区房子的租赁价格根据面积装修等在3000到1万多每月不等,取中按6000每月算。 地产中介介绍房屋租赁时,中介费一般是一个月房租,也就是做成一单租赁生意能平均得到6000, 如果单做租赁生意,每个月要做成70单才能持平,加上税收,基本的盈利,应该要100单左右,也就是说我们这个2000多户的小区,如果中介只靠租赁业务为生,大约每年要做1200单的租赁合同才能维持这么多地产中介。

网上查到房屋买卖地产中介的提成在1.8%-3%左右, 我们这里房子价格在150万到600来万之间,就按300万来算,提成按2.4%来算, 每单房屋买卖中介平均收入7.2万,一个月有6单房屋买卖生意就能持平,算上税收盈利应该要9单,一年下来要108单。算下来小区房子每年的换手率在5%的话,中介们就能活得不错了。

我父母从80年到现在的30年内换过5次住房,而且我们家绝不是个例,在当地很有典型性。如果大家都是按这个这个速度换房,那住房的换手率摊到每年是16%, 远远超过刚才提到的5%的盈亏平衡线,这还不算我和我妹的房子。一个年轻人一般18-22岁出来工作,这时候要租房,25-30岁之间要结婚,这时要买房,27-35岁间,要生孩子,这时要换大一点的房子,等到快50的时候,他的子女又开始这个轮回,而这中间的每个换房过程都是房产中介的市场机会。 由此看来现在的房地产中介市场还是大有可为的。

小区在北京东三环和四环之间,位置不算特别好,距离繁华的路段都有些距离。 也看过周围的几个小区,发现地产中介也差不多一样多,看来房地产中介的火爆是北京的普遍现象。

小区2000多套房子养活了80个地产中介从业人员,也就是25:1,每25套房子养活一个房产中介从业人员,不知这是不是普遍及合理的比率。

Page 1 of 1412345...10...Last »