随笔-295  评论-26  文章-1  trackbacks-0
 

拷贝函数:

function clone(source:Object):* {
 var copier:ByteArray = new ByteArray();
 copier.writeObject(source);
 copier.position = 0;
 return(copier.readObject());
}

使用方法:

newObjectCopy = clone(originalObject);

posted @ 2008-09-16 20:21 华梦行 阅读(89) | 评论 (0)编辑 收藏

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
NameVirtualHost 211.152.56.216:80
<VirtualHost bbs.justong.cn:80>
  #  ServerAdmin webmaster@dummy-host2.bbs.justong.cn
    DocumentRoot "D:/Apache2.2/htdocs"
    ServerName bbs.xx.cn
     ServerAlias bbs.xxx.cn
    ErrorLog "logs/error.log"
 #   CustomLog "logs/dummy-host2.bbs.justong.cn-access.log" common
</VirtualHost>
<Directory "E:/217_bakcup_0303/apache-tomcat-5.5.20/webapps/phpcms">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
<Directory "E:/217_bakcup_0303/apache-tomcat-5.5.20/webapps/bbb">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

<VirtualHost www.2dgame.cn:80>
  #  ServerAdmin webmaster@dummy-host2.bbs.justong.cn
    DocumentRoot "E:/217_bakcup_0303/apache-tomcat-5.5.20/webapps/phpcms"
    ServerName www.ddddd.cn
     ServerAlias 2dgame.cn
    ErrorLog "E:/217_bakcup_0303/apache-tomcat-5.5.20/webapps/error.log"
 #   CustomLog "logs/dummy-host2.bbs.justong.cn-access.log" common
</VirtualHost>
<VirtualHost www.yqxiaoshuo.cn:80
    DocumentRoot "E:/217_bakcup_0303/apache-tomcat-5.5.20/webapps/bbb"
    ServerName www.yqxiaoshuo.cn
     ServerAlias yqxiaoshuo.cn
    ErrorLog "E:/217_bakcup_0303/apache-tomcat-5.5.20/webapps/error.log"

</VirtualHost>

posted @ 2008-09-16 17:16 华梦行 阅读(479) | 评论 (0)编辑 收藏
     摘要: Phpcms 编码规范 作者:淡淡风  来源:phpcms   1.      ...  阅读全文
posted @ 2008-08-20 14:05 华梦行 阅读(212) | 评论 (0)编辑 收藏
 Security.loadPolicyFile("xmlsocket://"+SERVER_NAME+":5229");   
目前来说这个跨域文件还只能加载一次这个是flashplayer的一个bug在flashplayer9中一直存在这个问题目前还没有解决掉。  具体详情参见 http://bugs.adobe.com/jira/browse/FP-67
posted @ 2008-08-14 13:19 华梦行 阅读(1426) | 评论 (0)编辑 收藏

http://2dgame.cn  正式上线了欢迎光临一下。是一个关于 flash小游戏的网站

posted @ 2008-08-11 08:18 华梦行 阅读(256) | 评论 (0)编辑 收藏
www.2dgame.cn flash 小游戏 flash 小游戏 www.2dgame.cn  热门 小游戏
posted @ 2008-08-07 12:42 华梦行 阅读(302) | 评论 (2)编辑 收藏
function iscn($str){
if (preg_match("/.*[".chr(0xa1)."-".chr(0xff)."]+.*/", $str)) {
return true;
} else {
return false;
}
}
posted @ 2008-07-19 15:02 华梦行 阅读(116) | 评论 (0)编辑 收藏

package {
    import flash.display.Sprite;
    import flash.system.Capabilities;

    public class CapabilitiesExample extends Sprite {
        public function CapabilitiesExample() {
            showCapabilities();
        }
       
        private function showCapabilities():void {
            trace("avHardwareDisable: " + Capabilities.avHardwareDisable);
            trace("hasAccessibility: " + Capabilities.hasAccessibility);
            trace("hasAudio: " + Capabilities.hasAudio);
            trace("hasAudioEncoder: " + Capabilities.hasAudioEncoder);
            trace("hasEmbeddedVideo: " + Capabilities.hasEmbeddedVideo);
            trace("hasMP3: " + Capabilities.hasMP3);
            trace("hasPrinting: " + Capabilities.hasPrinting);
            trace("hasScreenBroadcast: " + Capabilities.hasScreenBroadcast);
            trace("hasScreenPlayback: " + Capabilities.hasScreenPlayback);
            trace("hasStreamingAudio: " + Capabilities.hasStreamingAudio);
            trace("hasVideoEncoder: " + Capabilities.hasVideoEncoder);
            trace("isDebugger: " + Capabilities.isDebugger);
            trace("language: " + Capabilities.language);
            trace("localFileReadDisable: " + Capabilities.localFileReadDisable);
            trace("manufacturer: " + Capabilities.manufacturer);
            trace("os: " + Capabilities.os);
            trace("pixelAspectRatio: " + Capabilities.pixelAspectRatio);
            trace("playerType: " + Capabilities.playerType);
            trace("screenColor: " + Capabilities.screenColor);
            trace("screenDPI: " + Capabilities.screenDPI);
            trace("screenResolutionX: " + Capabilities.screenResolutionX);
            trace("screenResolutionY: " + Capabilities.screenResolutionY);
            trace("serverString: " + Capabilities.serverString);
            trace("version: " + Capabilities.version);
        }
    }
}
返回结果:
avHardwareDisable: false
hasAccessibility: false
hasAudio: true
hasAudioEncoder: true
hasEmbeddedVideo: true
hasMP3: true
hasPrinting: true
hasScreenBroadcast: false
hasScreenPlayback: true
hasStreamingAudio: true
hasVideoEncoder: true
isDebugger: true
language: zh-CN
localFileReadDisable: false
manufacturer: Adobe Windows
os: Windows
pixelAspectRatio: 1
playerType: External
screenColor: color
screenDPI: 72
screenResolutionX: 1024
screenResolutionY: 768
serverString: A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t&SB=f&DEB=t&V=WIN%209%2C0%2C45%2C0&M=Adobe%20Windows&R=1024x768&DP=72&COL=color&AR=1.0&OS=Windows&L=zh-CN&IME=t&PT=External&AVD=f&LFD=f&WD=f&TLS=t
version: WIN 9,0,45,0

posted @ 2008-03-31 13:21 华梦行 阅读(174) | 评论 (0)编辑 收藏

 
package org.jivesoftware.xiff.core

 import flash.events.DataEvent;
 import flash.events.Event;
 import flash.events.EventDispatcher;
 import flash.events.IOErrorEvent;
 import flash.events.SecurityErrorEvent;
 import flash.events.TimerEvent;
 import flash.net.XMLSocket;
 import flash.utils.Timer;
 import flash.xml.XMLDocument;
 import flash.xml.XMLNode;
 
 import org.jivesoftware.xiff.data.IExtension;
 import org.jivesoftware.xiff.data.IQ;
 import org.jivesoftware.xiff.data.Message;
 import org.jivesoftware.xiff.data.Presence;
 import org.jivesoftware.xiff.data.XMPPStanza;
 import org.jivesoftware.xiff.data.auth.AuthExtension;
 import org.jivesoftware.xiff.data.forms.FormExtension;
 import org.jivesoftware.xiff.data.register.RegisterExtension;
 import org.jivesoftware.xiff.events.*;
 import org.jivesoftware.xiff.exception.SerializationException;

 /**
  * 当密码修改成功的时候被触发
  *
  * @eventType org.jivesoftware.xiff.events.ChangePasswordSuccessEvent.PASSWORD_SUCCESS
  */
    [Event(name="changePasswordSuccess", type="org.jivesoftware.xiff.events.ChangePasswordSuccessEvent")]
   
    /**
     * 当成功的链接到服务器上的时候触发
     *
     * @eventType org.jivesoftware.xiff.events.ConnectionSuccessEvent.CONNECT_SUCCESS
     */
    [Event(name="connection", type="org.jivesoftware.xiff.events.ConnectionSuccessEvent")]
   
    /**
     * 当与服务器断开的时候将会被触发
     *
     * @eventType org.jivesoftware.xiff.events.DisconnectionEvent.DISCONNECT
     */
    [Event(name="disconnection", type="org.jivesoftware.xiff.events.DisconnectionEvent")]
   
    /**
     * Dispatched when there is some type of XMPP error.
     * 当有xmpp 错误的时候将会被触发
     * @eventType org.jivesoftware.xiff.events.XIFFErrorEvent.XIFF_ERROR
     */
    [Event(name="error", type="org.jivesoftware.xiff.events.XIFFErrorEvent")]
   
    /**
     * Dispatched whenever there is incoming XML data.
     * 当有传入的数据的时候将会被触发
     * @eventType org.jivesoftware.xiff.events.IncomingDataEvent.INCOMING_DATA
     */
    [Event(name="incomingData", type="org.jivesoftware.xiff.events.IncomingDataEvent")]
   
    /**
     * Dispatched on successful authentication (login) with the server.
     * 当有用户登陆成功的时候将会被触发
     * @eventType org.jivesoftware.xiff.events.LoginEvent.LOGIN
     */
    [Event(name="login", type="org.jivesoftware.xiff.events.LoginEvent")]
   
    /**
     * Dispatched on incoming messages.
     *  当有进入的消息的时候将会被触发
     * @eventType org.jivesoftware.xiff.events.MessageEvent.MESSAGE
     */
    [Event(name="message", type="org.jivesoftware.xiff.events.MessageEvent")]
   
    /**
     * Dispatched whenever data is sent to the server.
     * 当有数据被传往服务器端的时候触发
     * @eventType org.jivesoftware.xiff.events.OutgoingDataEvent.OUTGOING_DATA
     */
    [Event(name="outgoingData", type="org.jivesoftware.xiff.events.OutgoingDataEvent")]
   
    /**
     * Dispatched on incoming presence data.
     *  当进入是否在线相关数据的时候触发
     * @eventType org.jivesoftware.xiff.events.PresenceEvent.PRESENCE
     */
    [Event(name="presence", type="org.jivesoftware.xiff.events.PresenceEvent")]
   
    /**
     * Dispatched on when new user account registration is successful.
     * 当用户注册成功的时候触发
     * @eventType org.jivesoftware.xiff.events.RegistrationSuccessEvent.REGISTRATION_SUCCESS
     */
    [Event(name="registrationSuccess", type="org.jivesoftware.xiff.events.RegistrationSuccessEvent")]
   
    /**
     * This class is used to connect to and manage data coming from an XMPP server. Use one instance
     * of this class per connection.
     * XMPPConnection这个类被用做连接和管理从服务器端发来的数据,每一个连接一个实例
     */
 public class XMPPConnection extends EventDispatcher
 {
  /**
   * @private
   * 是否匿名登陆
   */
  protected var _useAnonymousLogin:Boolean;
  
  /**
   * @private
   *xmlsocket
   */
  protected var _socket:XMLSocket;
  
  /**
   * @private
   * 服务器地址或者名称
   */
  protected var myServer:String;
  
  /**
   * @private
   * 用户名
   */
  protected var myUsername:String;
  
  /**
   * @private
   * 绑定的资源名称  比如smark linkq msn 等
   * */
  protected var myResource:String;
  
  /**
   * @private
   * 用户密码
   */
  protected var myPassword:String;
 
  /**
   * @private
   * 登陆端口
   */
  protected var myPort:Number;
  
  /**
   * 是否已经激活
   * @private
   */
  protected var _active:Boolean;
  
  /**
   * 是否已经登陆
   * @private
   */
  protected var loggedIn:Boolean;
  
  /**
   * 是否忽略空白字符
   * @private
   */
  protected var ignoreWhitespace:Boolean;
  
  /**
   * @private
   * 打开流的标签
   */
  protected var openingStreamTag:String;
  
  /**
   * @private
   * 关闭流的标签
   */
  protected var closingStreamTag:String;

  /**
   * @private
   * 会话id
   */
  protected var sessionID:String;
  
  /**
   * @private
   */
  protected var pendingIQs:Object;
  
  /**
   * @private
   */
  protected var _expireTagSearch:Boolean;
  
  protected static var _openConnections:Array = [];
  
  public function XMPPConnection()
  { 
   
   // Hash to hold callbacks for IQs
   pendingIQs = new Object();
   
   _useAnonymousLogin = false;
   active = false;
   loggedIn = false;
   ignoreWhitespace = true;
   //初始化为忽略空白字符
   resource = "xiff";
   //初始化资源为xiff
   port = 5222;
   
   AuthExtension.enable();
   RegisterExtension.enable();
   FormExtension.enable();
  }
  
  /**
   * Connects to the server.
   * 链接到服务器端
   * @param streamType (Optional) The type of initial stream negotiation, either &lt;flash:stream&gt; or &lt;stream:stream&gt;.
   * Some servers, like Jabber, Inc.'s XCP and Jabberd 1.4 expect &lt;flash:stream&gt; from a Flash client instead of the standard &lt;stream:stream&gt;.
   * The options for this parameter are: "flash", "terminatedFlash", "standard" and "terminatedStandard". The default is "terminatedStandard".
   *返回是否找到服务器
   * @return A boolean indicating whether the server was found.
   */
  public function connect( streamType:String = "terminatedStandard" ):Boolean
  {
   
   // Create the socket 创建一个socket连接字
   _socket = _createXmlSocket();
   
   active = false;
   loggedIn = false;
   
   ///  创建流样式  <stream:flash>
   // Stream type lets user set opening/closing tag - some servers (jadc2s) prefer <stream:flash> to the standard
   // <stream:stream>
   switch( streamType ) {
    /////在xiff中用flash
    case "flash":
     openingStreamTag = new String( "<?xml version=\"1.0\"?><flash:stream to=\"" + server + "\" xmlns=\"jabber:client\" xmlns:flash=\"http://www.jabber.com/streams/flash\" version=\"1.0\">" );
     closingStreamTag = new String( "</flash:stream>" );
     break;
     
    case "terminatedFlash":
     openingStreamTag = new String( "<?xml version=\"1.0\"?><flash:stream to=\"" + server + "\" xmlns=\"jabber:client\" xmlns:flash=\"http://www.jabber.com/streams/flash\" version=\"1.0\" />" );
     closingStreamTag = new String( "</flash:stream>" );
     break;
     
    case "standard":
     openingStreamTag = new String( "<?xml version=\"1.0\"?><stream:stream to=\"" + server + "\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">" );
     closingStreamTag = new String( "</stream:stream>" );
     break;
   
    case "terminatedStandard":
    default:
     openingStreamTag = new String( "<?xml version=\"1.0\"?><stream:stream to=\"" + server + "\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\" />" );
     closingStreamTag = new String( "</stream:stream>" );
     break;
   }
   //链接到服务器如果成功返回true
   _socket.connect( server, port );
   return true;
  }
  
  /**
   * 关闭与服务器的连接
   * Disconnects from the server if currently connected. After disconnect,
   * a <code>DisconnectionEvent.DISCONNECT</code> event is broadcast.
   */
  public function disconnect():void
  {
   //如果链接是活动的,发送一个关闭流  设置活动状态为false
   if( isActive() ) {
    sendXML( closingStreamTag );
    _socket.close();
    active = false;
    loggedIn = false;
    var event:DisconnectionEvent = new DisconnectionEvent();
    dispatchEvent(event);
    //将关闭连接这个事件分发( 广播)
   }
  }
  
  /**
   * Sends data to the server. If the data to send cannot be serialized properly, this method throws a <code>SerializeException</code>.
   *发送数据给服务器,如果数据不能被序列号则不能被发送
   * @param o The data to send. This must be an instance of a class that implements the ISerializable interface.
  * 参数必须是已经实现了ISerriable接口的实例
   *  * @see org.jivesoftware.xiff.data.ISerializable
   * @example The following example sends a basic chat message to the user with the JID "sideshowbob@springfieldpenitentiary.gov".<br />
   * <pre>var msg:Message = new Message( "sideshowbob@springfieldpenitentiary.gov", null, "Hi Bob.", "<b>Hi Bob.</b>", Message.CHAT_TYPE );
   * myXMPPConnection.send( msg );</pre>
   */
  public function send( o:XMPPStanza ):void
  {
   if( isActive() ) {
    ///主要是处理  IQ(info 、query)
    if( o is IQ ) {
                 var iq:IQ = o as IQ;
                 if ((iq.callbackName != null && iq.callbackScope != null) || iq.callback != null)
                 {
                  addIQCallbackToPending( iq.id, iq.callbackName, iq.callbackScope, iq.callback );
                 }  
    }
    var root:XMLNode = o.getNode().parentNode;
    if (root == null) {
     root = new XMLDocument();
    }
 
    if (o.serialize(root)) {
     sendXML( root.firstChild );
    } else {
     throw new SerializationException();
    }
   }
  }
  ///发送一个空包,保持这个联结
  public function sendKeepAlive():void
  {
   if( isActive() ) {
    sendXML(" ");
   }
  }
  
  /**
   * Determines whether the connection with the server is currently active. (Not necessarily logged in.
   * For login status, use the <code>isLoggedIn()</code> method.)
   * 检测这个连接是否是活动的
   * @return A boolean indicating whether the connection is active.
   * @see org.jivesoftware.xiff.core.XMPPConnection#isLoggedIn
   */
  public function isActive():Boolean
  {
   return active;
  }
  
  /**
   * Determines whether the user is connected and logged into the server.
   * 判断用户是否已经登陆
   * @return A boolean indicating whether the user is logged in.
   * @see org.jivesoftware.xiff.core.XMPPConnection#isActive
   */
  public function isLoggedIn():Boolean
  {
   return loggedIn;
  }
  
  /**
   * Issues a request for the information that must be submitted for registration with the server.
   * 发布一个请求去获取必须提交的信息以用来向服务器注册,注册用户时用到
   * When the data returns, a <code>RegistrationFieldsEvent.REG_FIELDS</code> event is dispatched
   * containing the requested data.
   */
  public function getRegistrationFields():void
  {
   var regIQ:IQ = new IQ( new JID(server), IQ.GET_TYPE, XMPPStanza.generateID("reg_info_"), "getRegistrationFields_result", this, null);
   regIQ.addExtension(new RegisterExtension(regIQ.getNode()));
 
   send( regIQ );
  }
  
  /**
   * Registers a new account with the server, sending the registration data as specified in the fieldMap paramter.
   * 向服务注册一个新的帐号,发送注册所需的数据
   * @param fieldMap An object map containing the data to use for registration. The map should be composed of
   * attribute:value pairs for each registration data item.
   * @param key (Optional) If a key was passed in the "data" field of the "registrationFields" event,
   * that key must also be passed here.
   * required field needed for registration.
   */
  public function sendRegistrationFields( fieldMap:Object, key:String ):void
  {
   var regIQ:IQ = new IQ( new JID(server), IQ.SET_TYPE, XMPPStanza.generateID("reg_attempt_"), "sendRegistrationFields_result", this, null );
   var ext:RegisterExtension = new RegisterExtension(regIQ.getNode());
 
   for( var i:String in fieldMap ) {
    ext[i] = fieldMap[i];
   }
   if (key != null) {
    ext.key = key;
   }
 
   regIQ.addExtension(ext);
   send( regIQ );
  }
  
  /**
   * Changes the user's account password on the server. If the password change is successful,
   * the class will broadcast a <code>ChangePasswordSuccessEvent.PASSWORD_SUCCESS</code> event.
   *变更用户帐号密码, 如果成功将会触发事件:ChangePasswordSuccessEvent.PASSWORD_SUCCESS
   * @param newPassword The new password
   */
  public function changePassword( newPassword:String ):void
  {
   var passwdIQ:IQ = new IQ( new JID(server), IQ.SET_TYPE, XMPPStanza.generateID("pswd_change_"), "changePassword_result", this, null );
   var ext:RegisterExtension = new RegisterExtension(passwdIQ.getNode());
 
   ext.username = jid.toBareJID();
   ext.password = newPassword;
 
   passwdIQ.addExtension(ext);
   send( passwdIQ );
  }
  
  /**
   * Gets the fully qualified JID (user@server/resource) of the user. A fully-qualified JID includes
   * the resource. A bare JID does not. To get the bare JID, use the <code>getBareJID()</code> method.
   * 返回一个完整的jid user@server/resource
   * @return The fully qualified JID
   * @see #getBareJID
   */
  public function get jid():JID
  {
   return new JID(myUsername + "@" + myServer + "/" + myResource);
  }
  
  /**
   * @private  修改密码的返回情况
   */
  protected function changePassword_result( resultIQ:IQ ):void
  {
   if( resultIQ.type == IQ.RESULT_TYPE ) {
    var event:ChangePasswordSuccessEvent = new ChangePasswordSuccessEvent();
    dispatchEvent(event);
   }
   else {
    // We weren't expecting this
    ////400  修改密码错误
    dispatchError( "unexpected-request", "Unexpected Request", "wait", 400 );
   }
  }
  
  /**
   * @private 注册用户的返回情况
   */
  protected function getRegistrationFields_result( resultIQ:IQ ):void
  {
   try
   {
    var ext:RegisterExtension = resultIQ.getAllExtensionsByNS(RegisterExtension.NS)[0];
    var fields:Array = ext.getRequiredFieldNames(); //TODO, phase this out
    
    var event:RegistrationFieldsEvent = new RegistrationFieldsEvent();
    event.fields = fields;
    event.data = ext;
   }
   catch (e:Error)
    {
     trace(e.getStackTrace());
    }
  }
  
  /**
   * @private
   */
  protected function sendRegistrationFields_result( resultIQ:IQ ):void
  {
   if( resultIQ.type == IQ.RESULT_TYPE ) {

    var event:RegistrationSuccessEvent = new RegistrationSuccessEvent();
    dispatchEvent( event );
   }
   else {
    // We weren't expecting this
    dispatchError( "unexpected-request", "Unexpected Request", "wait", 400 );
   }
  }
  
  // Listener function from the ListenerXMLSocket
  /**
   * @private
   */
  protected function socketConnected(ev:Event):void
  {
   active = true;
   sendXML( openingStreamTag );
   var event:ConnectionSuccessEvent = new ConnectionSuccessEvent();
   dispatchEvent( event );
  }
  
  /**
   * @private
   */
  protected function socketReceivedData( ev:DataEvent ):void
  {
   // parseXML is more strict in AS3 so we must check for the presence of flash:stream
   // the unterminated tag should be in the first string of xml data retured from the server
   if (!_expireTagSearch)
   {
    var pattern:RegExp = new RegExp("<flash:stream");
    var resultObj:Object = pattern.exec(ev.data);
    if (resultObj != null) // stop searching for unterminated node
    {
     ev.data = ev.data.concat("</flash:stream>");
     _expireTagSearch = true;
    }
   }
   
   if(ev.data == "</flash:stream>")
   {
    socketClosed(null);
    return; 
   } 
   
   var xmlData:XMLDocument = new XMLDocument();
   xmlData.ignoreWhite = this.ignoreWhite;
   xmlData.parseXML( ev.data );
   
   var event:IncomingDataEvent = new IncomingDataEvent();
   event.data = xmlData;
   dispatchEvent( event );
   
   // Read the data and send it to the appropriate parser
   var firstNode:XMLNode = xmlData.firstChild;
   var nodeName:String = firstNode.nodeName.toLowerCase();
   //trace("RECV: " + firstNode);
   switch( nodeName )
   {
    case "stream:stream":
    case "flash:stream":
     _expireTagSearch = false;
     handleStream( firstNode );
     break;
     
    case "stream:error":
     handleStreamError( firstNode );
     break;
     
    case "iq":
     handleIQ( firstNode );
     break;
     
    case "message":
     handleMessage( firstNode );
     break;
     
    case "presence":
     handlePresence( firstNode );
     break;
     
    case "stream:features":
     break;
     
    default:
     // silently ignore lack of or unknown stanzas
     // if the app designer wishes to handle raw data they
     // can on "incomingData".
 
     // Use case: received null byte, XMLSocket parses empty document
     // sends empty document
     
     // I am enabling this for debugging
     dispatchError( "undefined-condition", "Unknown Error", "modify", 500 );
     break;
   }
  }
  
  /**
   * @private
   */
  protected function socketClosed(e:Event):void
  { 
   var event:DisconnectionEvent = new DisconnectionEvent();
   dispatchEvent( event );
  }
  
  /**
   * @private
   */
  protected function handleStream( node:XMLNode ):void
  {
   sessionID = node.attributes.id;
   server = node.attributes.from;
   
   if(_useAnonymousLogin) {
    // Begin anonymous login
    sendAnonymousLogin();
   } else if( username != null && username.length > 0 ) {
    // Begin login sequence
    beginAuthentication();
   } else {
    //get registration fields
    getRegistrationFields();
   }
  }
  
  /**
   * @private
   */
  protected function handleStreamError( node:XMLNode ):void
  {
   dispatchError( "service-unavailable", "Remote Server Error", "cancel", 502 );
   
   // Cancel everything by closing connection
   try {
    _socket.close();
   }
   catch (error:Error){
    
   }
   active = false;
   loggedIn = false;
   var event:DisconnectionEvent = new DisconnectionEvent();
   
   dispatchEvent( event );
  }
  
  protected function set active(flag:Boolean):void
  {
   if(flag)
   {
    _openConnections.push(this);
   }
   else
   {
    _openConnections.splice(_openConnections.indexOf(this), 1);
   }
   _active = flag;
  }
  
  protected function get active():Boolean
  {
   return _active;
  }
  
  public static function get openConnections():Array
  {
   return _openConnections;
  }
  
  /**
   * @private
   */
  protected function handleIQ( node:XMLNode ):IQ
  {
   var iq:IQ = new IQ();
   // Populate the IQ with the incoming data
   if( !iq.deserialize( node ) ) {
    throw new SerializationException();
   }
   
   // If it's an error, handle it
   
   if( iq.type == IQ.ERROR_TYPE && !pendingIQs[iq.id]) {
    dispatchError( iq.errorCondition, iq.errorMessage, iq.errorType, iq.errorCode );
   }
   else {
    
    // Start the callback for this IQ if one exists
    if( pendingIQs[iq.id] !== undefined ) {
     var callbackInfo:* = pendingIQs[iq.id];
     
     if(callbackInfo.methodScope && callbackInfo.methodName) {
      callbackInfo.methodScope[callbackInfo.methodName].apply( callbackInfo.methodScope, [iq] );
     }   
     if (callbackInfo.func != null) {
      callbackInfo.func( iq );
     }
     pendingIQs[iq.id] = null;
     delete pendingIQs[iq.id];
    }
    else {
     var exts:Array = iq.getAllExtensions();
     for (var ns:String in exts) {
      // Static type casting
      var ext:IExtension = exts[ns] as IExtension;
      if (ext != null) {
       var event:IQEvent = new IQEvent(ext.getNS());
       event.data = ext;
       event.iq = iq;
       dispatchEvent( event );
      }
     }
    }
   }
         return iq;
  }
  
  /**
   * @private
   */
  protected function handleMessage( node:XMLNode ):Message
  {
   var msg:Message = new Message();
   //trace(msg); 
   // Populate with data
   if( !msg.deserialize( node ) ) {
    throw new SerializationException();
   }
   // ADDED in error handling for messages
   if( msg.type == Message.ERROR_TYPE ) {
    dispatchError( msg.errorCondition, msg.errorMessage, msg.errorType, msg.errorCode );
   }
   else
   {
    var event:MessageEvent = new MessageEvent();
    event.data = msg;
    dispatchEvent( event );  
   }
         return msg;
  }
  
  /**
   * @private
   */
  private var presenceQueue:Array = [];
  private var presenceQueueTimer:Timer;
  protected function handlePresence( node:XMLNode ):Presence
  {
   if(!presenceQueueTimer)
   {
    presenceQueueTimer = new Timer(1, 1);
    presenceQueueTimer.addEventListener(TimerEvent.TIMER_COMPLETE, flushPresenceQueue);
   }
   
   var pres:Presence = new Presence();
   
   // Populate
   if( !pres.deserialize( node ) ) {
    throw new SerializationException();
   }
   
   presenceQueue.push(pres);
   
   presenceQueueTimer.reset();
   presenceQueueTimer.start();

         return pres;
  }
  
  protected function flushPresenceQueue(evt:TimerEvent):void
  {
   var event:PresenceEvent = new PresenceEvent();
   event.data = presenceQueue;
   dispatchEvent( event );
   presenceQueue = [];
  }
  
  /**
   * @private
   */
  protected function onIOError(event:IOErrorEvent):void{
   /*
   this fires the standard dispatchError method. need to add
   the appropriate error code
   */
   dispatchError( "service-unavailable", "Service Unavailable", "cancel", 503 );
  }
  
  /**
   * @private
   */
  protected function securityError(event:SecurityErrorEvent):void{
   trace("there was a security error of type: " + event.type + "\nError: " + event.text);
   dispatchError( "not-authorized", "Not Authorized", "auth", 401 );
  }
  
  /**
   * @private
   */
  protected function dispatchError( condition:String, message:String, type:String, code:Number ):void
  {
   var event:XIFFErrorEvent = new XIFFErrorEvent();
   event.errorCondition = condition;
   event.errorMessage = message;
   event.errorType = type;
   event.errorCode = code;
   dispatchEvent( event );
  }
  
  /**
   * @private
   */
  protected function sendXML( someData:* ):void
  {
   //trace("SEND: " + someData);
   // Data is untyped because it could be a string or XML
   _socket.send( someData );
   var event:OutgoingDataEvent = new OutgoingDataEvent();
   event.data = someData;
   dispatchEvent( event );
  }
  
  // anonymous login
  /**
   * @private
   */
  protected function sendAnonymousLogin():void
  {
   var anonIQ:IQ = new IQ(null, IQ.SET_TYPE, XMPPStanza.generateID("log_anom_"), "sendAnonymousLogin_result", this, null );
   var authExt:AuthExtension = new AuthExtension(anonIQ.getNode());
   anonIQ.addExtension(authExt);
   send(anonIQ);
  }
  
  /**
   * @private
   */
  protected function sendAnonymousLogin_result(resultIQ:IQ):void
  {resultIQ
   if( resultIQ.type == IQ.RESULT_TYPE ) {
    // update resource
    var jid:JID = resultIQ.to;
    resource = jid.resource;
    username = jid.node;
    // dispatch login event
    loggedIn = true;
    var event:LoginEvent = new LoginEvent();
    dispatchEvent( event );
   }
  }
  
  /**
   * @private
   */
  protected function beginAuthentication():void
  {
   var authIQ:IQ = new IQ( null, IQ.GET_TYPE, XMPPStanza.generateID("log_user_"), "beginAuthentication_result", this, null );
   var authExt:AuthExtension = new AuthExtension(authIQ.getNode());
   authExt.username = username
   
   authIQ.addExtension(authExt);
   send( authIQ );
  }
  
  /**
   * @private
   */
  protected function beginAuthentication_result( resultIQ:IQ ):void
  {
   var connectionType:String = "none";
 
   // Begin authentication procedure
   if( resultIQ.type == IQ.RESULT_TYPE ) {
    var authIQ:IQ = new IQ( null, IQ.SET_TYPE, XMPPStanza.generateID("log_user2_"), "sendAuthentication_result", this, null );
    try
    {
     var resultAuth:* = resultIQ.getAllExtensionsByNS(AuthExtension.NS)[0];
     var responseAuth:AuthExtension = new AuthExtension(authIQ.getNode());
     responseAuth.password = password;
     responseAuth.username = username;
     responseAuth.resource = resource;
     authIQ.addExtension(responseAuth);
     send( authIQ );
    }
    catch (e:Error)
    {
     trace("Error : null trapped. Resuming.");
    }
   }
   else {
    // We weren't expecting this
    dispatchError( "unexpected-request", "Unexpected Request", "wait", 400 );
   }
  }
  
  /**
   * @private
   */
  protected function sendAuthentication_result( resultIQ:IQ ):void
  {
   if( resultIQ.type == IQ.RESULT_TYPE ) {
    loggedIn = true;
    var event:LoginEvent = new LoginEvent();
    dispatchEvent( event );
   }
   else {
    // We weren't expecting this
    dispatchError( "unexpected-request", "Unexpected Request", "wait", 400 );
   }
  }
  
  /**
   * @private
   */
  protected function addIQCallbackToPending( id:String, callbackName:String, callbackScope:Object, callbackFunc:Function ):void
  {
   pendingIQs[id] = {methodName:callbackName, methodScope:callbackScope, func:callbackFunc};
  }
  
  /**
   * The XMPP server to use for connection.
   */
  public function get server():String
  {
   return myServer;
  }
  
  /**
   * @private
   */
  public function set server( theServer:String ):void
  {
   myServer = theServer;
  }
  
  /**
   * The username to use for connection. If this property is null when <code>connect()</code> is called,
   * the class will fetch registration field data rather than attempt to login.
   */
  public function get username():String
  {
   return myUsername;
  }
  
  /**
   * @private
   */
  public function set username( theUsername:String ):void
  {
   myUsername = theUsername;
  }
  
  /**
   * The password to use when logging in.
   */
  public function get password():String
  {
   return myPassword;
  }
  
  public function set password( thePassword:String ):void
  {
   myPassword = thePassword;
  }
  
  /**
   * The resource to use when logging in. A resource is required (defaults to "XIFF") and
   * allows a user to login using the same account simultaneously (most likely from multiple machines).
   * Typical examples of the resource include "Home" or "Office" to indicate the user's current location.
   */
  public function get resource():String
  {
   return myResource;
  }
  
  /**
   * @private
   */
  public function set resource( theResource:String ):void
  {
   if( theResource.length > 0 )
   {
    myResource = theResource;
   }
  }
  
  /**
   * Whether to use anonymous login or not.
   */
  public function get useAnonymousLogin():Boolean
  {
   return _useAnonymousLogin;
  }
  
  /**
   * @private
   */
  public function set useAnonymousLogin(value:Boolean):void
  {
   // set only if not connected
   if(!isActive()) _useAnonymousLogin = value;
  }
  
  /**
   * The port to use when connecting. The default XMPP port is 5222.
   */
  public function get port():Number
  {
   return myPort;
  }
  
  public function set port( portNum:Number ):void
  {
   myPort = portNum;
  }
 
  /**
   * Determines whether whitespace will be ignored on incoming XML data.
   * Behaves the same as <code>XML.ignoreWhite</code>
   */
  public function get ignoreWhite():Boolean
  {
   return ignoreWhitespace;
  }
 
  public function set ignoreWhite( val:Boolean ):void
  {
   ignoreWhitespace = val;
  }
  
  private function _createXmlSocket():XMLSocket {
   var socket:XMLSocket = new XMLSocket(server, port);
   socket.addEventListener(Event.CONNECT,socketConnected);
   socket.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
   socket.addEventListener(Event.CLOSE,socketClosed);
   socket.addEventListener(DataEvent.DATA,socketReceivedData);
   socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityError);
   return socket;
  }
 }
}

posted @ 2008-03-26 14:59 华梦行 阅读(3251) | 评论 (0)编辑 收藏
http://is.qq.com/webpresence/code.shtml
<a target=blank href=tencent://message/?uin=331998039&Site=bbs.justong.cn&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:331998039:10 alt="有事就Q我"></a>
posted @ 2008-03-22 10:24 华梦行 阅读(317) | 评论 (1)编辑 收藏
[client]
default-character-set = utf8
[mysqld]
init-connect='SET NAMES utf8'
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
default-character-set = utf8
max_connections=150
[mysql]
default-character-set = utf8
posted @ 2008-03-21 09:39 华梦行 阅读(201) | 评论 (0)编辑 收藏

mysql 远程访问的设置

登陆以后运行以下命令,给予远程访问客户端权限.. 

grant all on *.* to 'remote'@'172.16.21.39' identified by 'password';

remote表示用户名.

'172.16.21.39' 远程ip地址

password表示远程登陆密码.

posted @ 2008-03-05 21:02 华梦行 阅读(245) | 评论 (0)编辑 收藏

VNC,全称为Virtual Network Computing,它是一个桌面共享系统。它的功能,类似于Windows中的远程桌面功能。VNC使用了RFB(Remote FrameBuffer,远程帧缓冲)协议来实现远程控制另外一台计算机。它把键盘鼠标动作发送到远程计算机,并把远程计算机的屏幕发回到本地。

VNC技术与平台无关,VNC VIEwer可以和VNC Server在不同的操作系统上。VNC几乎支持所有的操作系统,也支持Java,甚至可以通过支持Java的浏览器来访问VNC Server。多个VNC客户端可以同时连接到一个VNC Server上。

VNC最初由AT&T开发的,它的源代码是开源的。

在CentOs 4.3上配置VNC服务很简单(这里假定你的计算机上已经安装了VNC软件)

首先需要配置VNC密码,密码在使用客户端连接服务器时使用。

注意:VNC密码保存在用户的主目录中,每个用户都可以设置自己的密码。因此,请使用你的用户名(尽量不要使用root)运行下列命令:

vncpasswd

然后输入密码。

接下来就可以启动VNC server了。在启动VNC server时,需要为你的server指定一个display参数。你可以把display理解为一个桌面,每个用户都可以有自己的桌面。VNC客户端在连接时,可以指定连接到哪个桌面上。在系统中,display号不能重复,也就是说,如果有用户已经建立了名为“:1”的display,另外一个用户就不能再使用“:1”了,他可以使用“:2”。

启动VNC server的命令是:

vncserver <display>

例如,

vncserver :1

最后,需要配置一下防火墙,允许VNC客户端连接VNC server。VNC server监听的端口从5900开始,display :1的监听5901,display :2监听5902,以此类推。CentOs的防火墙缺省是不允许连接这些端口的,所以需要使用下面的步骤打开防火墙(需要root权限):

vi /etc/sysconfig/iptables

找到下面的语句:

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

在此行之前,加上下面的内容:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT

这句话的含义是,允许其它机器访问本机的5900到5903端口,这样,display:1, display:2, display:3的用户就可以连接到本机。

然后使用root身份重新启动防火墙:

/sbin/service iptables restart

好了,现在就可以运行客户端软件,连接到VNC server上了。

VNC客户端软件很多,在Linux下有vncviewer,KDE还提供了一个krdc(它的菜单项就是”Remote Desktop Connection",远程桌面连接)。

在window也有不少vnc客户端,你可以到http://www.realvnc.com/去下载一个,安装就可以用了。

假设VNC server的IP地址是192.168.1.1,display是:1。在VNC viewer的server栏中输入:“192.168.1.1:1”,然后连接。OK,你可以看到自己的桌面了。以后不管你什么时候关闭自己的本地PC机都不怕了,只要server不关机,你只要连接到VNC server,你就可以看到你前一天关闭本地PC机时的桌面还保持着原样。

不过...这个桌面怎么这么丑?!

原来vncserver默认使用的窗口管理器是twm,这是一个很简陋的窗口管理器,你可以把你的桌面改成GNOME或KDE。

方法是,进入你自己的home目录,然后编辑这个文件:.vnc/xstartup,下面是这个文件的内容:

#!/bin/sh

# Uncomment the following two lines for normal desktop:

#unset SESSION_MANAGER

#exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

#twm &

gnome-session &

你可以把像上面这样把"twm &"这一行注释掉,然后在下面加入一行"gnome-session &",或者是"startkde &",分别启动GNOME桌面和KDE桌面。

如果server重启了,那你就需要重新运行一次vncserver命令来启动VNC server,这很麻烦。有没有更好的方法呢?

有!我们可以把VNC server启动成后台服务。执行如下步骤:

首先要允许VNC server在系统启动过程中被启动。这可以通过“系统设置-->服务器设置-->服务”菜单来配置,把vncserver一项选上就可以了。

如果使用命令行的话,以root身份运行以下两条命令:

cd /etc/rc5.d

mv K35vncserver S35vncserver

然后编辑/etc/sysconfig/vncservers,以下是文件内容:

																# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC passWord; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/vnc/sshvnc.HTML>.
VNCSERVERS="1:user1 2:user2 3:user3"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
VNCSERVERARGS[3]="-geometry 800x600"
														

解释一下这个文件:

VNCSERVERS这一行是配置在系统启动时启动几个VNC server,上面的例子里运行了三个VNC server,其中user1在display :1,user2在display :2,user3在display :3。

VNCSERVERARGS这三行,分别为VNC server 1, 2, 3配置启动参数,上面的例子里对user1和user2使用屏幕分辨率1024x768,对user3使用800x600。

其它支持的参数请使用“man vncserver”命令查询。

编辑好这个文件后,保存,然后以root身份运行:

/sbin/service vncserver start

这样user1, user2, user3的vncserver就启动了。

以后每次系统重启时,都会自动启动这三个用户的vncserver。

注意:上面三个用户必须已经使用vncpasswd命令设置过vnc密码,不然他的vncserver启动会失败

posted @ 2008-03-04 19:21 华梦行 阅读(354) | 评论 (0)编辑 收藏
/etc/my.conf下添加配置

[client]
default-character-set = utf8
[mysqld]
init-connect='SET NAMES utf8'
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
default-character-set = utf8
[mysql]
default-character-set = utf8
posted @ 2008-03-04 19:18 华梦行 阅读(141) | 评论 (0)编辑 收藏

允许Flash跨域加载数据

Flash 文档可通过使用以下某种数据加载调用方法从外部源加载数据:XML.load()XML.sendAndLoad()LoadVars.load()LoadVars.sendAndLoad()loadVariables()loadVariablesNum()、MovieClip.loadVariables()XMLSocket.connect() 和 Macromedia Flash Remoting (NetServices.createGatewayConnection)。另外,SWF 文件可以在运行时导入运行时共享库 (RSL) 或另一个 SWF 文件中定义的资源。默认情况下,数据或 RSL 必须与加载该外部数据或媒体的 SWF 文件驻留在同一个域中。

若要使运行时共享库中的数据和资源可用于其它域中的 SWF 文件,应使用跨域策略文件。跨域策略文件是一个 XML 文件,该文件提供的方法可以使服务器指示其数据和文档可用于从某些域或所有域提供的 SWF 文件。服务器的策略文件指定的域所提供的所有 SWF 文件都将被允许访问该服务器中的数据、资源或 RSL。

如果您加载外部数据,即使不想将任何文件移植到 Flash Player 7 中,也应创建策略文件。如果您使用 RSL,并且调用或被调用文件是以 Flash Player 7 为目标播放器发布的,则应创建策略文件。

允许跨域数据加载

当 Flash 文档试图访问另一个域中的数据时,Flash Player 将自动试图从该域加载策略文件。如果试图访问数据的 Flash 文档所在的域包括在该策略文件中,则数据将自动成为可访问数据。

策略文件必须命名为 crossdomain.xml,并且可以驻留在服务器的根目录和其它目录之中,该服务器提供具有其它 ActionScript 的数据。只有在通过 HTTP、HTTPS 或 FTP 进行通信的服务器上,策略文件才起作用。策略文件特定于它所驻留的服务器的端口和协议。

例如,位于 https://www.macromedia.com:8080/crossdomain.xml 的策略文件只适用于在端口 8080 通过 HTTPS 对 www.macromedia.com 进行的数据加载调用。

此规则的例外情况是,使用 XMLSocket 对象连接到另一个域中的套接字服务器。如果是这种情况,运行于与套接字服务器所在的同一个域中端口 80 上的 HTTP 服务器必须提供该方法调用的策略文件。

XML 策略文件包含单个 <cross-domain-policy> 标签,该标签又包含零个或多个 <allow-access-from> 标签。每个 <allow-access-from> 标签包含一个属性 domain,该属性指定一个确切的 IP 地址、一个确切的域或一个通配符域(任何域)。通配符域由单个星号 (*)(匹配所有域和所有 IP 地址)或后接后缀的星号(只匹配那些以指定后缀结尾的域)表示。后缀必须以点开头。但是,带有后缀的通配符域可以匹配那些只包含后缀但不包含前导点的域。例如,cenfun.com 可以看作是 *.cenfun.com 的一部分。IP 域规范中不允许使用通配符。

如果您指定了一个 IP 地址,则将只向使用 IP 语法从该 IP 地址(例如 http://65.57.83.12/flashmovie.swf)加载的 SWF 文件授予访问权限,而不向使用域名语法加载的 SWF 文件授予访问权限。Flash Player 不执行 DNS 解析。

下面的示例显示一个策略文件,该策略文件允许从 cenfun.com 上的 Flash 文档访问来自 cenfun.com、www.friendOfcenfun.com、*.cenfun.com 和 105.216.0.40 的 Flash 文档:

<?xml version="1.0"?>
<!-- http://www.cenfun.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from domain="www.friendOfcenfun.com" />
<allow-access-from domain="*.cenfun.com" />
<allow-access-from domain="105.216.0.40" />
</cross-domain-policy>

您也可以允许访问来自任何域的文档,如下面的示例所示:(http://www.cenfun.com/crossdomain.xml )

								<?xml version="1.0"?>
<!-- http://www.cenfun.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
						

每个 <allow-access-from> 标签还具有可选的 secure 属性。secure 属性默认为 true。如果您的策略文件在 HTTPS 服务器上,并且要允许 HTTP 服务器上的 SWF 文件从 HTTPS 服务器加载数据,则可以将此属性设置为 false

secure 属性设置为 false 可能会危及 HTTPS 提供的安全性。

如果您正在下载来自 HTTPS 服务器的 SWF 文件,而加载它的 SWF 文件在 HTTP 服务器上,则您需要为 <allow-access-from> 标签添加 secure="false" 属性,如下面的代码所示:

<allow-access-from domain="www.cenfun.com" secure="false" />

不包含任何 <allow-access-from> 标签的策略文件相当于服务器上没有策略。

posted @ 2008-02-28 14:50 华梦行 阅读(2386) | 评论 (0)编辑 收藏

 

public class Escape {
        private final static String[] hex = { "00", "01", "02", "03", "04", "05",
        "06", "07", "08", "09", "0A", "0B", "0C", "0D", "0E", "0F", "10",
        "11", "12", "13", "14", "15", "16", "17", "18", "19", "1A", "1B",
        "1C", "1D", "1E", "1F", "20", "21", "22", "23", "24", "25", "26",
        "27", "28", "29", "2A", "2B", "2C", "2D", "2E", "2F", "30", "31",
        "32", "33", "34", "35", "36", "37", "38", "39", "3A", "3B", "3C",
        "3D", "3E", "3F", "40", "41", "42", "43", "44", "45", "46", "47",
        "48", "49", "4A", "4B", "4C", "4D", "4E", "4F", "50", "51", "52",
        "53", "54", "55", "56", "57", "58", "59", "5A", "5B", "5C", "5D",
        "5E", "5F", "60", "61", "62", "63", "64", "65", "66", "67", "68",
        "69", "6A", "6B", "6C", "6D", "6E", "6F", "70", "71", "72", "73",
        "74", "75", "76", "77", "78", "79", "7A", "7B", "7C", "7D", "7E",
        "7F", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
        "8A", "8B", "8C", "8D", "8E", "8F", "90", "91", "92", "93", "94",
        "95", "96", "97", "98", "99", "9A", "9B", "9C", "9D", "9E", "9F",
        "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "AA",
        "AB", "AC", "AD", "AE", "AF", "B0", "B1", "B2", "B3", "B4", "B5",
        "B6", "B7", "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF", "C0",
        "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "CA", "CB",
        "CC", "CD", "CE", "CF", "D0", "D1", "D2", "D3", "D4", "D5", "D6",
        "D7", "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF", "E0", "E1",
        "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "EA", "EB", "EC",
        "ED", "EE", "EF", "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7",
        "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF" };

        private final static byte[] val = { 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x01,
        0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F };

        /**
        * 编码
        *
        * @param s
        * @return
        */
        public static String escape(String s) {
        StringBuffer sbuf = new StringBuffer();
        int len = s.length();
        for (int i = 0; i < len; i++) {
        int ch = s.charAt(i);
        if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' : as it was
        sbuf.append((char) ch);
        } else if ('a' <= ch && ch <= 'z') { // 'a'..'z' : as it was
        sbuf.append((char) ch);
        } else if ('0' <= ch && ch <= '9') { // '0'..'9' : as it was
        sbuf.append((char) ch);
        } else if (ch == '-' || ch == '_' // unreserved : as it was
        || ch == '.' || ch == '!' || ch == '~' || ch == '*'
        || ch == '\'' || ch == '(' || ch == ')') {
        sbuf.append((char) ch);
        } else if (ch <= 0x007F) { // other ASCII : map to %XX
        sbuf.append('%');
        sbuf.append(hex[ch]);
        } else { // unicode : map to %uXXXX
        sbuf.append('%');
        sbuf.append('u');
        sbuf.append(hex[(ch >>> 8)]);
        sbuf.append(hex[(0x00FF & ch)]);
        }
        }
        return sbuf.toString();
        }

        /**
        * 解码 说明:本方法保证 不论参数s是否经过escape()编码,均能得到正确的“解码”结果
        *
        * @param s
        * @return
        */
        public static String unescape(String s) {
        StringBuffer sbuf = new StringBuffer();
        int i = 0;
        int len = s.length();
        while (i < len) {
        int ch = s.charAt(i);
        if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' : as it was
        sbuf.append((char) ch);
        } else if ('a' <= ch && ch <= 'z') { // 'a'..'z' : as it was
        sbuf.append((char) ch);
        } else if ('0' <= ch && ch <= '9') { // '0'..'9' : as it was
        sbuf.append((char) ch);
        } else if (ch == '-' || ch == '_' // unreserved : as it was
        || ch == '.' || ch == '!' || ch == '~' || ch == '*'
        || ch == '\'' || ch == '(' || ch == ')') {
        sbuf.append((char) ch);
        } else if (ch == '%') {
        int cint = 0;
        if ('u' != s.charAt(i + 1)) { // %XX : map to ascii(XX)
        cint = (cint << 4) | val[s.charAt(i + 1)];
        cint = (cint << 4) | val[s.charAt(i + 2)];
        i += 2;
        } else { // %uXXXX : map to unicode(XXXX)
        cint = (cint << 4) | val[s.charAt(i + 2)];
        cint = (cint << 4) | val[s.charAt(i + 3)];
        cint = (cint << 4) | val[s.charAt(i + 4)];
        cint = (cint << 4) | val[s.charAt(i + 5)];
        i += 5;
        }
        sbuf.append((char) cint);
        } else { // 对应的字符未经过编码
        sbuf.append((char) ch);
        }
        i++;
        }
        return sbuf.toString();
        }

        public static void main(String[] args) {
        String stest = "中文1234 abcd[]()<+>,.~\\";
        System.out.println(stest);
        System.out.println(escape(stest));
        System.out.println(unescape(escape(stest)));
        }

        }

 

posted @ 2008-02-27 21:18 华梦行 阅读(479) | 评论 (0)编辑 收藏
     摘要: 附录B:错误代码和消息 目录 B.1. 服务器错误代码和消息 B.2. 客户端错误代码和消息 ...  阅读全文
posted @ 2008-02-26 21:28 华梦行 阅读(1738) | 评论 (0)编辑 收藏
<marquee scrollAmount=2 onMouseOver=this.stop() onMouseOut=this.start()>    调节速度:scrollAmount
ln -s /data/oracle9/product/9.2.0/oracle.swd.jre/bin/i386/native_threads/java

/data/oracle9/product/9.2.0/oracle.swd.jre/bin/i386/native_threads/jre

posted @ 2008-02-21 20:33 华梦行 阅读(113) | 评论 (0)编辑 收藏
 1 在web。xml中添加
  <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>

在客户端文件中添加
OutService._path = 'http://192.168.1.120:8080/justchat/dwr';
DWREngine.setMethod(DWREngine.ScriptTag);
posted @ 2008-02-21 19:37 华梦行 阅读(626) | 评论 (0)编辑 收藏

                          
Linux 9 安装过程。
首先在bios中的启动顺序改为从cd-rom 启动,同时修改相关的io-device。设置为auto
格式化选择自动分区。
安装过程中版本选择选择服务器版本。
4.root的用户密码默认为:123456
完成安装。

二..jdk安装
1.到java官方网站去下载linux版本的jdk 1.5(prm)
2.运行相应的jdk rpm 安装文件,自动安装到/usr/java/jdk1.5.0_14   目录下面
3设置类路径:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
export JAVA_HOME=/usr/java/jdk1.5.0_14
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
在 /etc/profile  添加上面的代码即可
重起计算机运行javac即可完成测试: 如果出现javac相关的信息则说明安装成功。
二。openfire的安装以及部署
到openfire官方网站上去下载最新的openfire
关于openfire  的部署以及启动.自动安装到opt/openfire目录下面 相应的启动文件为
/opt/openfire/bin/openfire.sh
 将oracle9驱动classses12.jar复制到 /opt/openfire/lib目录下面,同时还需要修改配置文件/opt/openfire/conf/openfire.xml  

 如果是oracle则需要将classses12.jar复制到 /opt/openfire/lib目录下面,同时还需要修改配置文

件/opt/openfire/conf/openfire.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
   This file stores bootstrap properties needed by Openfire.
   Property names must be in the format: "prop.name.is.blah=value"
   That will be stored as:
       <prop>
           <name>
               <is>
                   <blah>value</blah>
               </is>
           </name>
       </prop>
   Most properties are stored in the Openfire database. A
 property viewer and editor is included in the admin console.
-->
<!-- root element, all properties must be under this element -->
<jive>
 <adminConsole>
   <!-- Disable either port by setting the value to -1 -->
   <port>9090</port>
   <securePort>9091</securePort>
 </adminConsole>
 <admin>
   <!-- Use this section to define users that will have admin privileges. Below,
         you will find two ways to specify which users are admins. Admins will
         have access to the admin console (only local users) and may have also access
         to other functionalities like ad-hoc commands. -->
   <!-- By default, only the user with the username "admin" can login
        to the admin console. Alternatively, you can specify a comma-delimitted
        list usernames that should be authorized to login to the admin console
        by setting the <authorizedUsernames> field below. -->
   <!-- <authorizedUsernames></authorizedUsernames> -->
   <!-- Comma-delimitted list of bare JIDs. The JIDs may belong to local
        or remote users. -->
   <!-- <authorizedJIDs></authorizedJIDs> -->
 </admin>
 <locale>zh_CN</locale>
 <!-- Network settings. By default, Openfire will bind to all network interfaces.
     Alternatively, you can specify a specific network interfaces that the server
     will listen on. For example, 127.0.0.1. This setting is generally only useful
      on multi-homed servers. -->
 <!--
   <network>
       <interface></interface>
   </network>
   -->
 <connectionProvider>
   <className>org.jivesoftware.database.DefaultConnectionProvider</className>
 </connectionProvider>
 <database>
   <defaultProvider>
     <driver>oracle.jdbc.driver.OracleDriver</driver>
     <serverURL>jdbc:oracle:thin:@192.168.1.2:1521:tlink</serverURL>
     <username>openfire</username>
     <password>openfire</password>
     <minConnections>5</minConnections>
     <maxConnections>15</maxConnections>
     <connectionTimeout>1.0</connectionTimeout>
   </defaultProvider>
 </database>
 <setup>true</setup>
</jive>


    Oracle9i 在Linux9上的安装过程


添加安装过程中需要用到的用户和组,这当中会用到二个用户一个是root,一个是oracle
#groupadd oinstall
#groupadd dba
#useradd –g oinstall –G dba oracle
#passwd oracle
 (二)新建安装目录
#mkdir –p /data/oracle9/product/9.2.0
#chown –R oracle.oinstall /data/oracle9
#mkdir /var/opt/oracle
#chown oracle.dba /var/opt/oracle
#chmod 755 /var/opt/oracle
(三)为了一开机系统就能自动帮你设好这些参数,
也可改动 /etc/sysctl.conf 这个文件,加入以下的语句:
kernel.shmmax = 8589934590
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

注意:如果你的共享内存不够大的话,在安装的过程中会提示ORA-27123错误,到时候你只要把/proc/sys/kernel/shmmax的值调大就

可以了到于多大就看你的了

(六) oracle对文件的要求:编辑文件:
/etc/security/limits.conf 加入以下语句:
oracle    soft    nofile    65536
oracle    hard    nofile   65536
oracle    soft    nproc    16384
oracle    hard    nproc    16384

设置oracle的环境
vi ~/.bash_profile
export LD_ASSUME_KERNEL=2.4.10
export ORACLE_BASE=/data/oracle9
export ORACLE_HOME=/data/oracle9/product/9.2.0
export ORACLE_SID=ora9i
export ORACLE_TERM=xterm
#export NLS_LANG=AMERICAN
export ORACLE_OWNER=oracle
export THREADS_FLAG=native
#export LANG=en_US
export ORA_NLS33=$OROCLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PAHT=/data/oracle9/product/9.2.0/lib:/lib:/usr /lib:/usr/local/lib
export PAHT=/data/oracle9/product/9.2.0/bin:$PATH
export PATH=$PATH:$ORACLE_HOME/bin


#su – oracle
$ vi ~/.bash_profile export LD_ASSUME_KERNEL=2.4.1
#export DISPLAY=”192.168.9.205:0.0” (127.0.0.1:0.0)
export ORACLE_BASE=/data/oracle9 export ORACLE_HOME=/data/oracle9/product/9.2.0
export ORACLE_SID=ora9i (数据库全局变量名)
export ORACLE_TERM=xterm (xterm窗口模式 vt100 终端调试模式)
export NLS_LANG=AMERICAN (设置语言AMERICAN英文)
export ORACLE_OWNER=oracle
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export THREADS_FLAG=native
export LD_LIBRARY_PATH=/data/oracle9/product/9.2.0/lib:/lib:/usr /lib:/usr/local/lib export

PATH=/data/oracle9/product/9.2/bin:$PATH export PATH=$PATH:$ORACLE_HOME/bin

然后注销再重新登录就可以,oracle 的环境就应该生效了 (要用英文环境)
安装oracle :
ship_9204_linux_disk1.cpio.gz
ship_9204_linux_disk2.cpio.gz
ship_9204_linux_disk3.cpio.gz
用zcat ship_9204_linux_disk1.cpio.gz|cpio -idmv
zcat ship_9204_linux_disk2.cpio.gz|cpio -idmv
zcat ship_9204_linux_disk3.cpio.gz|cpio -idmv
生成三个文件夹Disk1,Disk2,Disk3;
你也可以用(我用的是这个)
cpio -idmv < ship_9204_linux_disk1.cpio
cpio -idmv < ship_9204_linux_disk2.cpio
cpio -idmv < ship_9204_linux_disk3.cpio
在当前目录上会产生三个目录:
Disk1,Disk2,Disk3
#cd Disk1
#./runInstaller 出现图形安装界面。
按照提示完成安装即可。
安装过程中可能遇到的问题
1.遇到乱码时首先运行 export LANG=en_US
2.创见一个指向的链接:
ln -s /data/oracle9/product/9.2.0/oracle.swd.jre/bin/i386/native_threads/java

/data/oracle9/product/9.2.0/oracle.swd.jre/bin/i386/native_threads/jre
配置监听器服务命名还有目录服务 net config assistent
 /data/oracle9/product/9.2.0/bin/netca
启动oracle监听器.
/data/oracle9/product/9.2.0/bin/lsnrctl start TLINK
配置启动oracle服务器
 /data/oracle9/product/9.2.0/bin/dbca
在gui模式下启动oracle

linux 常见命令:
neat  =====redhat-config-network 配置网络
redhat-config-users 配置用户
 rpm -Uvv openfire.rpm --force   强制更新软件
rpm -ql package 列出该软件的所有文件所在的目录     | less  分页显示结果
rpm -qa 列出所有已安装的包
rpm -qi package 列出包信息
 /etc/rc.d/init.d/httpd start
启动 apache:
/etc/rc.d/init.d/httpd stop
关闭apache
  关于ssh 因为在linux下是内置的服务,所以只要启动服务即可。让在window下用ssh的客户端即可进行操作

 
 

posted @ 2008-02-18 11:48 华梦行 阅读(570) | 评论 (0)编辑 收藏
仅列出标题
共15页: First 上一页 3 4 5 6 7 8 9 10 11 下一页 Last