PHP V5 的五种常用设计模式

June 18th, 2011 0 条评论

 

设计模式 一书将设计模式引入软件社区,该书的作者是 Erich Gamma、Richard Helm、Ralph Johnson 和 John Vlissides Design(俗称 “四人帮”)。所介绍的设计模式背后的核心概念非常简单。经过多年的软件开发实践,Gamma 等人发现了某些具有固定设计的模式,就像建筑师设计房子和建筑物一样,可以为浴室的位置或厨房的构造方式开发模板。使用这些模板或者说设计模式 意味着可以更快地设计更好的建筑物。同样的概念也适用于软件。

设计模式不仅代表着更快开发健壮软件的有用方法,而且还提供了以友好的术语封装大型理念的方法。例如,您可以说您正在编写一个提供松散耦合的消息传递系统,也可以说你正在编写名称为观察者 的模式。

用较小的示例展示模式的价值是非常困难的。这往往有些大材小用的意味,因为模式实际上是在大型代码库中发挥作用的。本文不展示大型应用程序,所以您需要思索的是在您自己的大型应用程序中应用示例原理的方法 —— 而不是本文演示的代码本身。这不是说您不应该在小应用程序中使用模式。很多良好的应用程序都以小应用程序为起点,逐渐发展到大型应用程序,所以没有理由不以此类扎实的编码实践为基础。

既然您已经了解了设计模式以及它们的有用之处,现在我们来看看 PHP V5 的五种常用模式。

工厂模式

最初在设计模式 一书中,许多设计模式都鼓励使用松散耦合。要理解这个概念,让我们最好谈一下许多开发人员从事大型系统的艰苦历程。在更改一个代码片段时,就会发生问题,系统其他部分 —— 您曾认为完全不相关的部分中也有可能出现级联破坏。

该问题在于紧密耦合 。系统某个部分中的函数和类严重依赖于系统的其他部分中函数和类的行为和结构。您需要一组模式,使这些类能够相互通信,但不希望将它们紧密绑定在一起,以避免出现联锁。

在大型系统中,许多代码依赖于少数几个关键类。需要更改这些类时,可能会出现困难。例如,假设您有一个从文件读取的 User 类。您希望将其更改为从数据库读取的其他类,但是,所有的代码都引用从文件读取的原始类。这时候,使用工厂模式会很方便。

工厂模式 是一种类,它具有为您创建对象的某些方法。您可以使用工厂类创建对象,而不直接使用 new。这样,如果您想要更改所创建的对象类型,只需更改该工厂即可。使用该工厂的所有代码会自动更改。

清单 1 显示工厂类的一个示列。等式的服务器端包括两个部分:数据库和一组 PHP 页面,这些页面允许您添加反馈、请求反馈列表并获取与特定反馈相关的文章。

清单 1. Factory1.php

<?php

interface IUser

{

  function getName();

}

class User implements IUser

{

  public function __construct( $id ) { }

  public function getName()

  {

    return "Jack";

  }

}

class UserFactory

{

  public static function Create( $id )

  {

    return new User( $id );

  }

}

$uo = UserFactory::Create( 1 );

echo( $uo->getName()."\n" );

?>

IUser 接口定义用户对象应执行什么操作。IUser 的实现称为 User,UserFactory 工厂类则创建 IUser 对象。此关系可以用图 1 中的 UML 表示。

图 1. 工厂类及其相关 IUser 接口和用户类

如果您使用 php 解释器在命令行上运行此代码,将得到如下结果:

% php factory1.php 

Jack

%

测试代码会向工厂请求 User 对象,并输出 getName 方法的结果。

有一种工厂模式的变体使用工厂方法。类中的这些公共静态方法构造该类型的对象。如果创建此类型的对象非常重要,此方法非常有用。例如,假设您需要先创建对象,然后设置许多属性。此版本的工厂模式会将该进程封装在单个位置中,这样,不用复制复杂的初始化代码,也不必将复制好的代码在在代码库中到处粘贴。

清单 2 显示使用工厂方法的一个示例。

清单 2. Factory2.php

<?php

interface IUser

{

  function getName();

}

class User implements IUser

{

  public static function Load( $id ) 

  {

        return new User( $id );

  }

  public static function Create( ) 

  {

        return new User( null );

  }

  public function __construct( $id ) { }

  public function getName()

  {

    return "Jack";

  }

}

$uo = User::Load( 1 );

echo( $uo->getName()."\n" );

?>

这段代码要简单得多。它仅有一个接口 IUser 和一个实现此接口的 User 类。User 类有两个创建对象的静态方法。此关系可用图 2 中的 UML 表示。

图 2. IUser 接口和带有工厂方法的 user 类

 

在命令行中运行脚本产生的结果与清单 1 的结果相同,如下所示:

% php factory2.php 

Jack

%

如上所述,有时此类模式在规模较小的环境中似乎有些大材小用。不过,最好还是学习这种扎实的编码形式,以便应用于任意规模的项目中。

单元素模式

某些应用程序资源是独占的,因为有且只有一个此类型的资源。例如,通过数据库句柄到数据库的连接是独占的。您希望在应用程序中共享数据库句柄,因为在保持连接打开或关闭时,它是一种开销,在获取单个页面的过程中更是如此。

单元素模式可以满足此要求。如果应用程序每次包含且仅包含一个对象,那么这个对象就是一个单元素(Singleton)。清单 3 中的代码显示了 PHP V5 中的一个数据库连接单元素。

清单 3. Singleton.php

<?php

require_once("DB.php");

class DatabaseConnection

{

  public static function get()

  {

    static $db = null;

    if ( $db == null )

      $db = new DatabaseConnection();

    return $db;

  }

  private $_handle = null;

  private function __construct()

  {

    $dsn = 'mysql://root:password@localhost/photos';

    $this->_handle =& DB::Connect( $dsn, array() );

  }

 

  public function handle()

  {

    return $this->_handle;

  }

}

print( "Handle = ".DatabaseConnection::get()->handle()."\n" );

print( "Handle = ".DatabaseConnection::get()->handle()."\n" );

?>

此代码显示名为 DatabaseConnection 的单个类。您不能创建自已的 DatabaseConnection,因为构造函数是专用的。但使用静态 get 方法,您可以获得且仅获得一个 DatabaseConnection 对象。此代码的 UML 如图 3 所示。

图 3. 数据库连接单元素

 

在两次调用间,handle 方法返回的数据库句柄是相同的,这就是最好的证明。您可以在命令行中运行代码来观察这一点。

% php singleton.php 

Handle = Object id #3

Handle = Object id #3

%

返回的两个句柄是同一对象。如果您在整个应用程序中使用数据库连接单元素,那么就可以在任何地方重用同一句柄。

您可以使用全局变量存储数据库句柄,但是,该方法仅适用于较小的应用程序。在较大的应用程序中,应避免使用全局变量,并使用对象和方法访问资源。

观察者模式

观察者模式为您提供了避免组件之间紧密耦合的另一种方法。该模式非常简单:一个对象通过添加一个方法(该方法允许另一个对象,即观察者 注册自己)使本身变得可观察。当可观察的对象更改时,它会将消息发送到已注册的观察者。这些观察者使用该信息执行的操作与可观察的对象无关。结果是对象可以相互对话,而不必了解原因。

一个简单示例是系统中的用户列表。清单 4 中的代码显示一个用户列表,添加用户时,它将发送出一条消息。添加用户时,通过发送消息的日志观察者可以观察此列表。

清单 4. Observer.php

<?php

interface IObserver

{

  function onChanged( $sender, $args );

}

interface IObservable

{

  function addObserver( $observer );

}

class UserList implements IObservable

{

  private $_observers = array();

  public function addCustomer( $name )

  {

    foreach( $this->_observers as $obs )

      $obs->onChanged( $this, $name );

  }

  public function addObserver( $observer )

  {

    $this->_observers []= $observer;

  }

}

class UserListLogger implements IObserver

{

  public function onChanged( $sender, $args )

  {

    echo( "'$args' added to user list\n" );

  }

}

$ul = new UserList();

$ul->addObserver( new UserListLogger() );

$ul->addCustomer( "Jack" );

?>

此代码定义四个元素:两个接口和两个类。IObservable 接口定义可以被观察的对象,UserList 实现该接口,以便将本身注册为可观察。IObserver 列表定义要通过怎样的方法才能成为观察者,UserListLogger 实现 IObserver 接口。图 4 的 UML 中展示了这些元素。

图 4. 可观察的用户列表和用户列表事件日志程序

 

如果在命令行中运行它,您将看到以下输出:

% php observer.php 

'Jack' added to user list

%

测试代码创建 UserList,并将 UserListLogger 观察者添加到其中。然后添加一个消费者,并将这一更改通知 UserListLogger。

认识到 UserList 不知道日志程序将执行什么操作很关键。可能存在一个或多个执行其他操作的侦听程序。例如,您可能有一个向新用户发送消息的观察者,欢迎新用户使用该系统。这种方法的价值在于 UserList 忽略所有依赖它的对象,它主要关注在列表更改时维护用户列表并发送消息这一工作。

此模式不限于内存中的对象。它是在较大的应用程序中使用的数据库驱动的消息查询系统的基础。

命令链模式

命令链 模式以松散耦合主题为基础,发送消息、命令和请求,或通过一组处理程序发送任意内容。每个处理程序都会自行判断自己能否处理请求。如果可以,该请求被处理,进程停止。您可以为系统添加或移除处理程序,而不影响其他处理程序。清单 5 显示了此模式的一个示例。

清单 5. Chain.php

<?php

interface ICommand

{

  function onCommand( $name, $args );

}

class CommandChain

{

  private $_commands = array();

  public function addCommand( $cmd )

  {

    $this->_commands []= $cmd;

  }

  public function runCommand( $name, $args )

  {

    foreach( $this->_commands as $cmd )

    {

      if ( $cmd->onCommand( $name, $args ) )

        return;

    }

  }

}

class UserCommand implements ICommand

{

  public function onCommand( $name, $args )

  {

    if ( $name != 'addUser' ) return false;

    echo( "UserCommand handling 'addUser'\n" );

    return true;

  }

}

class MailCommand implements ICommand

{

  public function onCommand( $name, $args )

  {

    if ( $name != 'mail' ) return false;

    echo( "MailCommand handling 'mail'\n" );

    return true;

  }

}

$cc = new CommandChain();

$cc->addCommand( new UserCommand() );

$cc->addCommand( new MailCommand() );

$cc->runCommand( 'addUser', null );

$cc->runCommand( 'mail', null );

?>

此代码定义维护 ICommand 对象列表的 CommandChain 类。两个类都可以实现 ICommand 接口 —— 一个对邮件的请求作出响应,另一个对添加用户作出响应。 图 5 给出了 UML。

图 5. 命令链及其相关命令

如果您运行包含某些测试代码的脚本,则会得到以下输出:

% php chain.php 

UserCommand handling 'addUser'

MailCommand handling 'mail'

%

代码首先创建 CommandChain 对象,并为它添加两个命令对象的实例。然后运行两个命令以查看谁对这些命令作出了响应。如果命令的名称匹配 UserCommand 或 MailCommand,则代码失败,不发生任何操作。

为处理请求而创建可扩展的架构时,命令链模式很有价值,使用它可以解决许多问题。

策略模式

我们讲述的最后一个设计模式是策略 模式。在此模式中,算法是从复杂类提取的,因而可以方便地替换。例如,如果要更改搜索引擎中排列页的方法,则策略模式是一个不错的选择。思考一下搜索引擎的几个部分 —— 一部分遍历页面,一部分对每页排列,另一部分基于排列的结果排序。在复杂的示例中,这些部分都在同一个类中。通过使用策略模式,您可将排列部分放入另一个类中,以便更改页排列的方式,而不影响搜索引擎的其余代码。

作为一个较简单的示例,清单 6 显示了一个用户列表类,它提供了一个根据一组即插即用的策略查找一组用户的方法。

清单 6. Strategy.php

<?php

interface IStrategy

{

  function filter( $record );

}

class FindAfterStrategy implements IStrategy

{

  private $_name;

  public function __construct( $name )

  {

    $this->_name = $name;

  }

  public function filter( $record )

  {

    return strcmp( $this->_name, $record ) <= 0;

  }

}

class RandomStrategy implements IStrategy

{

  public function filter( $record )

  {

    return rand( 0, 1 ) >= 0.5;

  }

}

class UserList

{

  private $_list = array();

  public function __construct( $names )

  {

    if ( $names != null )

    {

      foreach( $names as $name )

      {

        $this->_list []= $name;

      }

    }

  }

  public function add( $name )

  {

    $this->_list []= $name;

  }

  public function find( $filter )

  {

    $recs = array();

    foreach( $this->_list as $user )

    {

      if ( $filter->filter( $user ) )

        $recs []= $user;

    }

    return $recs;

  }

}

$ul = new UserList( array( "Andy", "Jack", "Lori", "Megan" ) );

$f1 = $ul->find( new FindAfterStrategy( "J" ) );

print_r( $f1 );

$f2 = $ul->find( new RandomStrategy() );

print_r( $f2 );

?>

此代码的 UML 如图 6 所示。

图 6. 用户列表和用于选择用户的策略

 

UserList 类是打包名称数组的一个包装器。它实现 find 方法,该方法利用几个策略之一来选择这些名称的子集。这些策略由 IStrategy 接口定义,该接口有两个实现:一个随机选择用户,另一个根据指定名称选择其后的所有名称。运行测试代码时,将得到以下输出:

% php strategy.php 

Array

(

    [0] => Jack

    [1] => Lori

    [2] => Megan

)

Array

(

    [0] => Andy

    [1] => Megan

)

%

测试代码为两个策略运行同一用户列表,并显示结果。在第一种情况中,策略查找排列在 J 后的任何名称,所以您将得到 Jack、Lori 和 Megan。第二个策略随机选取名称,每次会产生不同的结果。在这种情况下,结果为 Andy 和 Megan。

策略模式非常适合复杂数据管理系统或数据处理系统,二者在数据筛选、搜索或处理的方式方面需要较高的灵活性。

 

参考资料

  • PHP.net 是面向 PHP 开发人员的资源。
  • Wikipedia 中有关于设计模式的 优秀文章。
  • C2 Wiki 查找有关设计模式(如 观察者、单元素 等)信息的另一个好去处。 
  • 任何工程师都应该阅读 设计模式 原书。
  • O'Reilly 的 Head First Design Patterns 是学习设计模式的轻量级方法。
  • PHP Hacks 一书中介绍了针对模式设计的几种黑客技术,可扩展本文介绍的示例。
  • 浏览 IBM developerWorks 的 PHP 项目资源,了解关于 PHP 的详细内容。
  • 关注最新的 developerWorks 技术事件和网络广播。
  • 了解全球范围内即将开展的研讨会、内部预映、网络广播和其他 活动,这些都是 IBM 开放源码开发人员感兴趣的内容。
  • 访问 developerWorks 开放源码专区,获得广泛的 how-to 信息、工具和项目更新,帮助您使用开放源码技术进行开发,并与 IBM 产品结合使用。
  • 收听针对软件开发人员的有趣的访谈和讨论,务必浏览 developerWorks 技术讲座。

 

分类: Web

linux/unix编程

May 24th, 2011 0 条评论

学习路径:

首先先学学编辑器,vim, emacs什么的都行。然后学make file文件,只要知道一点就行,这样就可以准备编程序了。

然后看看《C程序设计语言》K&R,这样呢,基本上就可以进行一般的编程了,顺便找本数据结构的书来看。

如果想学习UNIX/LINUX的编程,《APUE》绝对经典的教材,加深一下功底,学习《UNP》的第二卷。这样基本上系统方面的就可以掌握了。

然后再看Douglus E. Comer的《用TCP/IP进行网际互连》第一卷,学习一下网络的知识,再看《UNP》的第一卷,不仅学习网络编程,而且对系统编程的一些常用的技巧就很熟悉了,如果继续网络编程,建议看《TCP/IP进行网际互连》的第三卷,里面有很多关于应用协议telnet、ftp等协议的编程。如果想写设备驱动程序,首先您的系统编程的接口比如文件、IPC等必须要熟知了,再学习《LDD》2。

对于几本经典教材的评价:

《The C Programing Language》K&R

经典的C语言程序设计教材,作者是C语言的发明者,教材内容深入浅出。虽然有点老,但是必备的一本手册,现在有时候我还常翻翻。篇幅比较小,但是每看一遍,就有一遍的收获。

《Advanced Programing in Unix Envirement》 W.Richard Stevens

也是非常经典的书(废话,Stevens的书哪有不经典的!),虽然初学者就可以看,但是事实上它是《Unix Network Programing》的一本辅助资料。国内的翻译的《UNIX环境高级编程》的水平不怎么样,现在有影印版,直接读英文比读中文来得容易。

《Unix Network Programing》W.Richard Stevens

第一卷讲BSD Socket网络编程接口和另外一种网络编程接口的,不过现在一般都用BSD Socket,所以这本书只要看大约一半多就可以了。第二卷没有设计到网络的东西,主要讲进程间通讯和Posix线程。所以看了《APUE》以后,就可以看它了,基本上系统的东西就由《APUE》和《UNP》vol2概括了。看过《UNP》以后,您就会知道系统编程的绝大部分编程技巧,即使卷一是讲网络编程的。国内是清华翻译得《Unix网络编程》,翻译者得功底也比较高,翻译地比较好。所以建议还是看中文版。

《TCP/IP祥解》一共三卷,卷一讲协议,卷二讲实现,卷三讲编程应用。我没有怎么看过。,但是据说也很经典的,因为我没有时间看卷二,所以不便评价。

《用TCP/IP进行网际互连》Douglus.E.Comer

一共三卷,卷一讲原理,卷二讲实现,卷三讲高级协议。感觉上这一套要比Stevens的那一套要好,就连Stevens也不得不承认它的第一卷非常经典。事实上,第一卷即使你没有一点网络的知识,看完以后也会对网络的来龙去脉了如指掌。第一卷中还有很多习题也设计得经典和实用,因为作者本身就是一位教师,并且卷一是国外研究生的教材。习题并没有答案,留给读者思考,因为问题得答案可以让你成为一个中级的Hacker,这些问题的答案可以象Douglus索取,不过只有他只给教师卷二我没有怎么看,卷三可以作为参考手册,其中地例子也很经典。如果您看过Qterm的源代码,就会知道Qterm的telnet 实现部分大多数就是从这本书的源代码过来的。对于网络原理的书,我推荐它,而不是Stevens的《TCP/IP祥解》。

《Operating System - Design and Implement》

这个是讲操作系统的书,用Minix做的例子。作者母语不是英文,所以英文看起来比较晦涩。国内翻译的是《操作系统设计与实现》,我没看过中文版,因为翻译者是尤晋元,他翻译的《APUE》已经让我失望头顶了。读了这本书,对操作系统的底层怎么工作的就会有一个清晰的认识。

《Linux Device Driver》2e

为数不多的关于Linux设备驱动程序的好书。不过内容有些杂乱,如果您没有一些写驱动的经验,初次看会有些摸不着南北。国内翻译的是《Linux设备驱动程序》第二版,第一版,第二版的译者我都有很深的接触,不过总体上来说,虽然第二版翻译的有些不尽人意,但是相比第一版来说已经超出了一大截。要读这一本书,至少应该先找一些《计算机原理》《计算机体系结构》的书来马马虎虎读读,至少应该对硬件和计算机的工作过程有一些了解。

分类: Linux&Unix

google hack search keyword

May 23rd, 2011 0 条评论

filetype:htpasswd htpasswd

intitle:"Index of" ".htpasswd" -intitle:"dist" -apache -htpasswd.c

index.of.private (algo privado)

intitle:index.of master.passwd

inurl:passlist.txt (para encontrar listas de passwords)

intitle:"Index of..etc" passwd

intitle:admin intitle:login

"Incorrect syntax near" (SQL script error)

intitle:"the page cannot be found" inetmgr (debilidad en IIS4)

intitle:index.of ws_ftp.ini

"Supplied arguments is not a valid PostgreSQL result" (possible debilidad SQL)

_vti_pvt password intitle:index.of (Frontpage)

inurl:backup intitle:index.of inurl:admin

"Index of /backup"

index.of.password

index.of.winnt

inurl:"auth_user_file.txt"

"Index of /admin"

"Index of /password"

"Index of /mail"

"Index of /" +passwd

Index of /" +.htaccess

Index of ftp +.mdb allinurl:/cgi-bin/ +mailto

allintitle: "index of/admin"

allintitle: "index of/root"

allintitle: sensitive filetype:doc

allintitle: restricted filetype :mail

allintitle: restricted filetype:doc site:gov

administrator.pwd.index

authors.pwd.index

service.pwd.index

filetype:config web

gobal.asax index

inurl:passwd filetype:txt

inurl:admin filetype:db

inurl:iisadmin

inurl:"auth_user_file.txt"

inurl:"wwwroot/*."

allinurl: winnt/system32/ (get cmd.exe)

allinurl:/bash_history

intitle:"Index of" .sh_history

intitle:"Index of" .bash_history

intitle:"Index of" passwd

intitle:"Index of" people.1st

intitle:"Index of" pwd.db

intitle:"Index of" etc/shadow

intitle:"Index of" spwd

intitle:"Index of" master.passwd

intitle:"Index of" htpasswd

intitle:"Index of" members OR accounts

intitle:"Index of" user_carts OR user _cart 

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Selasa, 04 August 2009 - 01:40:38 WIB

Google Hacking Keyword

Posted By : Administrator - Read: 2938

Duclassified" -site:duware.com "DUware All Rights reserved"

"

duclassmate" -site:duware.com

"

Dudirectory" -site:duware.com

"

dudownload" -site:duware.com

"

Elite Forum Version *.*"

"

Link Department"

"sets mode: +k"

"your password is" filetype:log

"

DUpaypal" -site:duware.com

allinurl: admin mdb

auth_user_file.txt

config.php

eggdrop filetype:user user

enable password | secret "current configuration" -intext:the

etc (index.of)

ext:asa | ext:bak intext:uid intext:pwd -"uid..pwd" database | server | dsn

ext:inc "pwd=" "UID="

ext:ini eudora.ini

ext:ini Version=4.0.0.4 password

ext:passwd -intext:the -sample -example

ext:txt inurl:unattend.txt

ext:yml database inurl:config

filetype:bak createobject sa

filetype:bak inurl:"htaccess|passwd|shadow|htusers"

filetype:cfg mrtg "target

filetype:cfm "cfapplication name" password

filetype:conf oekakibbs

filetype:conf slapd.conf

filetype:config config intext:appSettings "User ID"

filetype:dat "password.dat"

filetype:dat inurl:Sites.dat

filetype:dat wand.dat

filetype:inc dbconn

filetype:inc intext:mysql_connect

filetype:inc mysql_connect OR mysql_pconnect

filetype:inf sysprep

filetype:ini inurl:"serv-u.ini"

filetype:ini inurl:flashFXP.ini

filetype:ini ServUDaemon

filetype:ini wcx_ftp

filetype:ini ws_ftp pwd

filetype:ldb admin

filetype:log "See `ipsec --copyright"

filetype:log inurl:"password.log"

filetype:mdb inurl:users.mdb

filetype:mdb wwforum

filetype:netrc password

filetype:pass pass intext:userid

filetype:pem intext:private

filetype:properties inurl:db intext:password

filetype:pwd service

filetype:pwl pwl

filetype:reg reg +intext:"defaultusername" +intext:"defaultpassword"

filetype:reg reg +intext:?WINVNC3?

filetype:reg reg HKEY_CURRENT_USER SSHHOSTKEYS

filetype:sql "insert into" (pass|passwd|password)

filetype:sql ("values * MD5" | "values * password" | "values * encrypt")

filetype:sql +"IDENTIFIED BY" -cvs

filetype:sql password

filetype:url +inurl:"ftp://" +inurl:";@"

filetype:xls username password email

htpasswd

htpasswd / htgroup

htpasswd / htpasswd.bak

intext:"enable password 7"

intext:"enable secret 5 $"

intext:"

EZGuestbook"

intext:"

Web Wiz Journal"

intitle:"index of" intext:connect.inc

intitle:"index of" intext:globals.inc

intitle:"Index of" passwords modified

intitle:"Index of" sc_serv.conf sc_serv content

intitle:"phpinfo()" +"mysql.default_password" +"Zend Scripting Language Engine"

intitle:dupics inurl:(add.asp | default.asp | view.asp | voting.asp) -site:duware.com

intitle:index.of administrators.pwd

intitle:Index.of etc shadow

intitle:index.of intext:"secring.skr"|"secring.pgp"|"secring.bak"

intitle:rapidshare intext:login

inurl:"calendarscript/users.txt"

inurl:"editor/list.asp" | inurl:"database_editor.asp" | inurl:"login.asa" "are set"

inurl:"GRC.DAT" intext:"password"

inurl:"Sites.dat"+"PASS="

inurl:"slapd.conf" intext:"credentials" -manpage -"Manual Page" -man: -sample

inurl:"slapd.conf" intext:"rootpw" -manpage -"Manual Page" -man: -sample

inurl:"wvdial.conf" intext:"password"

inurl:/db/main.mdb

inurl:/wwwboard

inurl:/yabb/Members/Admin.dat

inurl:ccbill filetype:log

inurl:cgi-bin inurl:calendar.cfg

inurl:chap-secrets -cvs

inurl:config.php dbuname dbpass

inurl:filezilla.xml -cvs

inurl:lilo.conf filetype:conf password -tatercounter2000 -bootpwd -man

inurl:nuke filetype:sql

inurl:ospfd.conf intext:password -sample -test -tutorial -download

inurl:pap-secrets -cvs

inurl:pass.dat

inurl:perform filetype:ini

inurl:perform.ini filetype:ini

inurl:secring ext:skr | ext:pgp | ext:bak

inurl:server.cfg rcon password

inurl:ventrilo_srv.ini adminpassword

inurl:vtund.conf intext:pass -cvs

inurl:zebra.conf intext:password -sample -test -tutorial -download

LeapFTP intitle:"index.of./" sites.ini modified

master.passwd

mysql history files

NickServ registration passwords

passlist

passlist.txt (a better way)

passwd

passwd / etc (reliable)

people.lst

psyBNC config files

pwd.db

server-dbs "intitle:index of"

signin filetype:url

spwd.db / passwd

trillian.ini

wwwboard WebAdmin inurl:passwd.txt wwwboard|webadmin

[WFClient] Password= filetype:ica

intitle:"remote assessment" OpenAanval Console

intitle:opengroupware.org "resistance is obsolete" "Report Bugs" "Username" "password"

"bp blog admin" intitle:login | intitle:admin -site:johnny.ihackstuff.com

"Emergisoft web applications are a part of our"

"Establishing a secure Integrated Lights Out session with" OR intitle:"Data Frame - Browser not HTTP 1.1 compatible" OR intitle:"HP Integrated Lights-

"HostingAccelerator" intitle:"login" +"Username" -"news" -demo

"iCONECT 4.1 :: Login"

"IMail Server Web Messaging" intitle:login

"inspanel" intitle:"login" -"cannot" "Login ID" -site:inspediumsoft.com

"intitle:3300 Integrated Communications Platform" inurl:main.htm

"Login - Sun Cobalt RaQ"

"login prompt" inurl:GM.cgi

"Login to Usermin" inurl:20000

"Microsoft CRM : Unsupported Browser Version"

"OPENSRS Domain Management" inurl:manage.cgi

"pcANYWHERE EXPRESS Java Client"

"Please authenticate yourself to get access to the management interface"

"please log in"

"Please login with admin pass" -"leak" -sourceforge

"

CuteNews" "2003..2005 CutePHP"

"

DWMail" password intitle:dwmail

"

Merak Mail Server Software" -.gov -.mil -.edu -site:merakmailserver.com

"

Midmart Messageboard" "Administrator Login"

"

Monster Top List" MTL numrange:200-

"

UebiMiau" -site:sourceforge.net

"site info for" "Enter Admin Password"

"SquirrelMail version" "By the SquirrelMail Development Team"

"SysCP - login"

"This is a restricted Access Server" "Javascript Not Enabled!"|"Messenger Express" -edu -ac

"This section is for Administrators only. If you are an administrator then please"

"ttawlogin.cgi/?action="

"VHCS Pro ver" -demo

"VNC Desktop" inurl:5800

"Web-Based Management" "Please input password to login" -inurl:johnny.ihackstuff.com

"WebExplorer Server - Login" "Welcome to WebExplorer Server"

"WebSTAR Mail - Please Log In"

"You have requested access to a restricted area of our website. Please authenticate yourself to continue."

"You have requested to access the management functions" -.edu

(intitle:"Please login - Forums

UBB.threads")|(inurl:login.php "ubb")

(intitle:"Please login - Forums

WWWThreads")|(inurl:"wwwthreads/login.php")|(inurl:"wwwthreads/login.pl?Cat=")

(intitle:"rymo Login")|(intext:"Welcome to rymo") -family

(intitle:"WmSC e-Cart Administration")|(intitle:"WebMyStyle e-Cart Administration")

(inurl:"ars/cgi-bin/arweb?O=0" | inurl:arweb.jsp) -site:remedy.com -site:mil

4images Administration Control Panel

allintitle:"Welcome to the Cyclades"

allinurl:"exchange/logon.asp"

allinurl:wps/portal/ login

ASP.login_aspx "ASP.NET_SessionId"

CGI:IRC Login

ext:cgi intitle:"control panel" "enter your owner password to continue!"

ez Publish administration

filetype:php inurl:"webeditor.php"

filetype:pl "Download: SuSE Linux Openexchange Server CA"

filetype:r2w r2w

intext:""BiTBOARD v2.0" BiTSHiFTERS Bulletin Board"

intext:"Fill out the form below completely to change your password and user name. If new username is left blank, your old one will be assumed." -edu

intext:"Mail admins login here to administrate your domain."

intext:"Master Account" "Domain Name" "Password" inurl:/cgi-bin/qmailadmin

intext:"Master Account" "Domain Name" "Password" inurl:/cgi-bin/qmailadmin

intext:"Storage Management Server for" intitle:"Server Administration"

intext:"Welcome to" inurl:"cp" intitle:"H-SPHERE" inurl:"begin.html" -Fee

intext:"vbulletin" inurl:admincp

intitle:"*- HP WBEM Login" | "You are being prompted to provide login account information for *" | "Please provide the information requested and press

intitle:"Admin Login" "admin login" "blogware"

intitle:"Admin login" "Web Site Administration" "Copyright"

intitle:"AlternC Desktop"

intitle:"Athens Authentication Point"

intitle:"b2evo > Login form" "Login form. You must log in! You will have to accept cookies in order to log in" -demo -site:b2evolution.net

intitle:"Cisco CallManager User Options Log On" "Please enter your User ID and Password in the spaces provided below and click the Log On button to co

intitle:"ColdFusion Administrator Login"

intitle:"communigate pro * *" intitle:"entrance"

intitle:"Content Management System" "user name"|"password"|"admin" "Microsoft IE 5.5" -mambo

intitle:"Content Management System" "user name"|"password"|"admin" "Microsoft IE 5.5" -mambo

intitle:"Dell Remote Access Controller"

intitle:"Docutek ERes - Admin Login" -edu

intitle:"Employee Intranet Login"

intitle:"eMule *" intitle:"- Web Control Panel" intext:"Web Control Panel" "Enter your password here."

intitle:"ePowerSwitch Login"

intitle:"eXist Database Administration" -demo

intitle:"EXTRANET * - Identification"

intitle:"EXTRANET login" -.edu -.mil -.gov

intitle:"EZPartner" -netpond

intitle:"Flash Operator Panel" -ext:php -wiki -cms -inurl:asternic -inurl:sip -intitle:ANNOUNCE -inurl:lists

intitle:"i-secure v1.1" -edu

intitle:"Icecast Administration Admin Page"

intitle:"iDevAffiliate - admin" -demo

intitle:"ISPMan : Unauthorized Access prohibited"

intitle:"ITS System Information" "Please log on to the SAP System"

intitle:"Kurant Corporation StoreSense" filetype:bok

intitle:"ListMail Login" admin -demo

intitle:"Login -

Easy File Sharing Web Server"

intitle:"Login Forum

AnyBoard" intitle:"If you are a new user:" intext:"Forum

AnyBoard" inurl:gochat -edu

intitle:"Login to @Mail" (ext:pl | inurl:"index") -dwaffleman

intitle:"Login to Cacti"

intitle:"Login to the forums - @www.aimoo.com" inurl:login.cfm?id=

intitle:"MailMan Login"

intitle:"Member Login" "NOTE: Your browser must have cookies enabled in order to log into the site." ext:php OR ext:cgi

intitle:"Merak Mail Server Web Administration" -ihackstuff.com

intitle:"microsoft certificate services" inurl:certsrv

intitle:"MikroTik RouterOS Managing Webpage"

intitle:"MX Control Console" "If you can't remember"

intitle:"Novell Web Services" "GroupWise" -inurl:"doc/11924" -.mil -.edu -.gov -filetype:pdf

intitle:"Novell Web Services" intext:"Select a service and a language."

intitle:"oMail-admin Administration - Login" -inurl:omnis.ch

intitle:"OnLine Recruitment Program - Login"

intitle:"Philex 0.2*" -script -site:freelists.org

intitle:"PHP Advanced Transfer" inurl:"login.php"

intitle:"php icalendar administration" -site:sourceforge.net

intitle:"php icalendar administration" -site:sourceforge.net

intitle:"phpPgAdmin - Login" Language

intitle:"PHProjekt - login" login password

intitle:"please login" "your password is *"

intitle:"Remote Desktop Web Connection" inurl:tsweb

intitle:"SFXAdmin - sfx_global" | intitle:"SFXAdmin - sfx_local" | intitle:"SFXAdmin - sfx_test"

intitle:"SHOUTcast Administrator" inurl:admin.cgi

intitle:"site administration: please log in" "site designed by emarketsouth"

intitle:"Supero Doctor III" -inurl:supermicro

intitle:"SuSE Linux Openexchange Server" "Please activate JavaScript!"

intitle:"teamspeak server-administration

intitle:"Tomcat Server Administration"

intitle:"TOPdesk ApplicationServer"

intitle:"TUTOS Login"

intitle:"TWIG Login"

intitle:"vhost" intext:"vHost . 2000-2004"

intitle:"Virtual Server Administration System"

intitle:"VisNetic WebMail" inurl:"/mail/"

intitle:"VitalQIP IP Management System"

intitle:"VMware Management Interface:" inurl:"vmware/en/"

intitle:"VNC viewer for Java"

intitle:"web-cyradm"|"by Luc de Louw" "This is only for authorized users" -tar.gz -site:web-cyradm.org

intitle:"WebLogic Server" intitle:"Console Login" inurl:console

intitle:"Welcome Site/User Administrator" "Please select the language" -demos

intitle:"Welcome to Mailtraq WebMail"

intitle:"welcome to netware *" -site:novell.com

intitle:"WorldClient" intext:"? (2003|2004) Alt-N Technologies."

intitle:"xams 0.0.0..15 - Login"

intitle:"XcAuctionLite" | "DRIVEN BY XCENT" Lite inurl:admin

intitle:"XMail Web Administration Interface" intext:Login intext:password

intitle:"Zope Help System" inurl:HelpSys

intitle:"ZyXEL Prestige Router" "Enter password"

intitle:"inc. vpn 3000 concentrator"

intitle:("TrackerCam Live Video")|("TrackerCam Application Login")|("Trackercam Remote") -trackercam.com

intitle:asterisk.management.portal web-access

intitle:endymion.sak?.mail.login.page | inurl:sake.servlet

intitle:Group-Office "Enter your username and password to login"

intitle:ilohamail "

IlohaMail"

intitle:ilohamail intext:"Version 0.8.10" "

IlohaMail"

intitle:IMP inurl:imp/index.php3

intitle:Login * Webmailer

intitle:Login intext:"RT is ? Copyright"

intitle:Node.List Win32.Version.3.11

intitle:Novell intitle:WebAccess "Copyright *-* Novell, Inc"

intitle:open-xchange inurl:login.pl

intitle:Ovislink inurl:private/login

intitle:phpnews.login

intitle:plesk inurl:login.php3

inurl:"/admin/configuration. php?" Mystore

inurl:"/slxweb.dll/external?name=(custportal|webticketcust)"

inurl:"1220/parse_xml.cgi?"

inurl:"631/admin" (inurl:"op=*") | (intitle:CUPS)

inurl:":10000" intext:webmin

inurl:"Activex/default.htm" "Demo"

inurl:"calendar.asp?action=login"

inurl:"default/login.php" intitle:"kerio"

inurl:"gs/adminlogin.aspx"

inurl:"php121login.php"

inurl:"suse/login.pl"

inurl:"typo3/index.php?u=" -demo

inurl:"usysinfo?login=true"

inurl:"utilities/TreeView.asp"

inurl:"vsadmin/login" | inurl:"vsadmin/admin" inurl:.php|.asp

nurl:/admin/login.asp

inurl:/cgi-bin/sqwebmail?noframes=1

inurl:/Citrix/Nfuse17/

inurl:/dana-na/auth/welcome.html

inurl:/eprise/

inurl:/Merchant2/admin.mv | inurl:/Merchant2/admin.mvc | intitle:"Miva Merchant Administration Login" -inurl:cheap-malboro.net

inurl:/modcp/ intext:Moderator+vBulletin

inurl:/SUSAdmin intitle:"Microsoft Software Update Services"

inurl:/webedit.* intext:WebEdit Professional -html

inurl:1810 "Oracle Enterprise Manager"

inurl:2000 intitle:RemotelyAnywhere -site:realvnc.com

inurl::2082/frontend -demo

inurl:administrator "welcome to mambo"

inurl:bin.welcome.sh | inurl:bin.welcome.bat | intitle:eHealth.5.0

inurl:cgi-bin/ultimatebb.cgi?ubb=login

inurl:Citrix/MetaFrame/default/default.aspx

inurl:confixx inurl:login|anmeldung

inurl:coranto.cgi intitle:Login (Authorized Users Only)

inurl:csCreatePro.cgi

inurl:default.asp intitle:"WebCommander"

inurl:exchweb/bin/auth/owalogon.asp

inurl:gnatsweb.pl

inurl:ids5web

inurl:irc filetype:cgi cgi:irc

inurl:login filetype:swf swf

inurl:login.asp

inurl:login.cfm

inurl:login.php "SquirrelMail version"

inurl:metaframexp/default/login.asp | intitle:"Metaframe XP Login"

inurl:mewebmail

inurl:names.nsf?opendatabase

inurl:ocw_login_username

inurl:orasso.wwsso_app_admin.ls_login

inurl:postfixadmin intitle:"postfix admin" ext:php

inurl:search/admin.php

inurl:textpattern/index.php

inurl:WCP_USER

inurl:webmail./index.pl "Interface"

inurl:webvpn.html "login" "Please enter your"

Login ("

Jetbox One CMS ?" | "

Jetstream ? *")

Novell NetWare intext:"netware management portal version"

Outlook Web Access (a better way)

PhotoPost PHP Upload

PHPhotoalbum Statistics

PHPhotoalbum Upload

phpWebMail

Please enter a valid password! inurl:polladmin

分类: Others

c语言的声明

May 20th, 2011 0 条评论

 

1. 声明合法与否

a. 函数的返回值不能是一个函数,如f()(),可以是函数指针,如int(* fun())();

b. 函数的返回值不能是一个数组,如f()[],可以是指向数组的指针,如int(*foo())[];

c. 数组里面不能有函数,如a[](),数组里面可以有函数指针,如int(* a[])(),可以有其他数组,如int a[][]

 

2. c语言声明的优先级规则

    A 声明从它的名字开始读取,然后按照优先级顺序依次读取;

    B 优先级从高到低依次是:

        B.1 声明中被括号括起来的那部分;

        B.2 后缀操作符:括号()表示这是一个函数,而方括号[]表示这是一个数组;

        B.3 前缀操作符:星号*标识"指向……的指针";

    C 如果const和(或者)volatile关键字的后面紧跟类型说明符(如int,long等),那么它作用于类型说明符,在其他情况下,const和(或)volatile关键字作用于它左边紧邻的指针星号。

 

3.例子:char * const * (*next)();

    A next                ——next为声明的名字

    B.1 (*next)           ——next为一个指向……的指针

    B.2 (*next)()         ——next是一个函数指针

    B.3 *(*next)()        ——next是一个函数指针,这个函数返回一个指向……的指针

    C char * const        ——指向字符类型的常量指针

故 char * const *(*next)();的含义就是: next是一个函数指针,这个函数返回一个指向字符类型的常量指针的指针。

 

分类: Coding Base

世界三大数字电视标准简介

May 13th, 2011 0 条评论

数字电视相对模拟电视的巨大优势使之成为公认的下一代电视系统,而要将数字电视变成现实,业界需要完成复杂的系统性工作,而其中最重要的一环就是数字电视标准的制定。标准的作用在于定义整个数字电视系统的具体实现细节,主要内容涵盖数字节目的前期制作、数字节目的显示格式、数字节目的传输几个方面。在所有这些标准确定之后,整套数字电视系统才可以组合并运转起来,整个数字电视产业也才可能真正启动。

数字电视按传输方式分为地面、卫星和有线三种。1995年,欧洲150个组织成立了DVB(Digital Video Broadcasting,数字视频广播)联盟,这个联盟现在已经拥有近200个成员。1997年,DVB联盟发表了它的数据广播技术规范,包括卫星数字电视传输标准DVB-S、有线电视传输系统标准DVB-C和地面传输标准DVB-T,为卫星、有线和地面电视频道传送高速数据铺平了道路。其中,DVB-S规定了卫星数字广播调制标准,使原来传送一套PAL制节目的频道可以传播四套数字电视节目,大大提高了卫星的效率。DVB-C规定了在有线电视网中传播数字电视的调制标准,使原来传送一套PAL制节目的频道可以传播四至六套数字电视节目。DVB-S和DVB-C这两个全球化的卫星和有线传输方式标准,目前已作为世界统一标准被大多数国家所接受(包括中国)。而对于地面数字电视广播标准,经国际电讯联盟(ITU)批准的共有三个,分别为:欧盟的DVB-T标准、美国的ATSC(Advanced Television System Committee,先进电视制式委员会)标准和日本的ISDB-T(Integrated Services Digital Broadcasting,综合业务数字广播)标准,因此,数字电视标准之争主要集中在地面数字广播系统。

数字电视三种标准的比较

 

---------------------------------------------------

                       ATSC               DVB            ISDB
                                DVB-T DVB-C DVB-S
视频编码方式 MPEG2 MPEG2 MPEG2 MPEG2 MPEG2 
音频编码方式 AC-3   MPEG2 MPEG2 MPEG2 MPEG2
复用方式      MPEG2  MPEG2 MPEG2 MPEG2 MPEG2
调用方式       8VSB   COFDM  QAM  QPSK   QPSK
带宽(Hz)   6M      8M         -        -         27M

 

--------------------------------------------------

欧洲DVB-T标准

DVB-T标准采用的大量导频信号插入和保护间隔技术使得系统具有较强的多径反射适应能力,在密集的楼群中也能良好接收,除能够移动接收外,还可建立单频网,适合于信号有屏蔽的山区。另外,欧洲系统还对载波数目、保护间隔长度和调制星座数目等参数进行组合,形成了多种传输模式供使用者选择。但欧洲标准也存在缺陷:①频带损失严重;②即使防止了大量导频信号,对信道估计仍是不足;③在交织深度、抗脉冲噪声干扰及信道编码等方面的性能存在明显不足;④覆盖面较小。

美国ATSC标准

美国于1996年12月24日决定采用以HDTV为基础的ATSC作为美国国家数字电视标准。美国联邦通信委员会(FCC)决定用9年时间完成模拟电视向数字电视的历史性过渡。

ATSC标准具备噪声门限低(接近于14.9dB的理论值)、传输容量大(6MHz带宽传输19.3Mbps)、传输远、覆盖范围广和接收方案易实现等主要技术优势。但是也存在一系列问题,最主要的是不能有效对付强多径和快速变化的动态多径,造成某些环境中固定接收不稳定以及不支持移动接收。

日本ISDB-T标准

日本于1996年开始启动自主的数字电视标准研发项目,在欧洲COFDM技术的基础上,增加具有自主知识产权的技术,形成ISDB-T地面数字广播传输标准,于1995年7月在日本电气通信技术审议会上通过。2001年,该标准正式被ITU接受为世界第3个数字电视传输国际标准。

频谱分段传输与强化移动接收是日本ISDB-T标准的两个主要特点,是对地面数字电视体系众多参数及相关性能进行客观分析优化组合的结果,但是此标准是日本根据本国具体情况及产业发展战略进行权衡取舍的。在实现系统特定功能的同时也为之付出相应的代价,如频谱分段传输对系统频率分集性能与净载荷率的影响,采取以频谱分段为基础实现不同误码保护率分层传输对系统复杂度的影响,在系统内层采用延时长达数百毫秒交织环节对系统及业务同步响应的影响等。

目前,世界各国都根据本国的具体情况,慎重地选择地面数字电视标准。从世界范围看,除了美国外,还有加拿大、阿根廷、韩国等国家采用美国的ATSC标准。而欧洲所有国家和澳大利亚、新加坡、印度等国则选用了欧洲联盟的DVB-T标准。

我国正积极开展数字电视标准的研究,国家标准即将出台。从保护国内产业的角度出发,制定具有我国独立自主知识产权、技术上领先的数字电视传输标准,将对我国电视、通信、互联网等产业发展带来不可低估的影响,有利于发达国家向我国开放技术,亦可因数字技术本身的特性,保护国家的信息安全。按照计划,我国将在2010年实现数字电视的普及,2015年将全面取代现有的模拟电视系统。因此,对产业界来说,数字电视也意味着巨大的市场机遇。

 

分类: STB&IPTV

C++头文件包含顺序

May 6th, 2011 0 条评论

假设某个CPP如下:

#include <iostream>

#include "myclass.h"

编译器的分析过程

先分析<iostream>,这个没有错误,OK继续分析

分析"myclass.h",发现编译错误,终止分析并报错。

如果我们把上述顺序调换,变为:

#include "myclass.h"

#include <iostream>

那么编译器先分析"myclass.h",发现编译错误,终止分析并报错。

明显可以看出第二种方式能够令分析速度加快。

把最容易出错的头文件(也就是最特殊的头文件)首先#include,这有点像短路求值(if ( 0 && 1 )),一旦出错,后面就不必再分析。

当然如果所有文件都没有错误,那么两种方式的分析速度会一样快。

综合来看,我们应该以这样的方式来#include头文件:

从最特殊到最一般,也就是,

#include "本类头文件"

#include "本目录头文件"

#include "自己写的工具头文件"

#include "第三方头文件"

#include "平台相关头文件"

#include "C++库头文件"

#include "C库头文件"

预编译头文件:防止同一组头文件在多个CPP文件中被重复分析。

头文件守卫:防止同一头文件在单个CPP文件中被重复分析。

头文件包含顺序有最特殊到最一般:使用短路编译以加快编译出错的过程。

分类: Coding Base