生成sessionid和随机密码的例子

来源:互联网 发布:java开发小游戏教程 编辑:程序博客网 时间:2024/05/17 00:01
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
用这个可以来验证用户和生成随机密码--teaman
<?
        //----------------------------------------------------
        // Function GetSID()
        //
        // Parameters : $nSize number of caracters, default 24
        // Return value : 24 caracters string
        //
        // Description : This function returns a random string
        // of 24 caracters that can be used to identify users
        // on your web site in a more secure way. You can also  
        // use this function to generate passwords.
        //----------------------------------------------------
        function GetSID ($nSize=24) {
             
            // Randomize
            mt_srand ((double) microtime() * 1000000);
            for ($i=1; $i<=$nSize; $i++) {
                 
                // if you wish to add numbers in your string,  
                // uncomment the two lines that are commented
                // in the if statement
                $nRandom = mt_rand(1,30);
                if ($nRandom <= 10) {
                    // Uppercase letters
                    $sessionid .= chr(mt_rand(65,90));
            //    } elseif ($nRandom <= 20) {
            //        $sessionid .= mt_rand(0,9);
                } else {
                    // Lowercase letters
                    $sessionid .= chr(mt_rand(97,122));
                }
                 
            }         
            return $sessionid;
        }
        // Test the function  
        echo GetSID(16);
    ?> <script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>