php 為 營運主機產生不同的隨機秘鑰。

來源:互聯網
上載者:User

標籤:主機   php   營運   

<?phpclass generator1 {//const HOSTS = array(array(‘ubuntu‘=>‘123.57.221.66‘),array(‘pay_web‘=>‘101.201.222.104‘),array(‘video_web‘=>‘101.201.31.40‘),array(‘bg_web211‘=>‘123.56.181.211‘),array(‘quanzi‘=>‘101.201.55.37‘),array(‘bg_web231‘=>‘60.205.127.231‘),array(‘db2_master‘=>‘60.205.166.72‘),array(‘db2_slave‘=>‘60.205.166.74‘),array(‘db3_others‘=>‘59.110.11.16‘),array(‘test_web‘=>‘60.205.150.53‘),array(‘nfs1_redis2‘=>‘123.57.184.167‘),array(‘nfs1_redis1‘=>‘123.57.184.235‘),array(‘zhuanfaqi‘=>‘123.57.185.38‘),array(‘prepare_web‘=>‘59.110.8.82‘),array(‘bg_web64‘=>‘10.29.130.64‘));//define("HOSTS",array(‘123.57.221.66‘,‘101.201.222.104‘,‘101.201.31.40‘,‘123.56.181.211‘,‘101.201.55.37‘,‘60.205.127.231‘,‘60.205.166.72‘,‘60.205.166.74‘,‘59.110.11.16‘,‘60.205.150.53‘,‘123.57.184.167‘,‘123.57.184.235‘,‘123.57.185.38‘,‘59.110.8.82‘,‘10.29.130.64‘));const HOSTS = array(‘123.57.203.66‘,‘101.101.222.104‘,‘102.221.51.40‘,‘112.56.131.211‘,‘121.202.45.37‘,‘101.205.127.231‘,‘101.205.166.72‘,‘63.205.166.74‘,‘39.110.13.12‘,‘65.205.150.53‘,‘33.57.134.167‘,‘123.59.104.235‘,‘148.57.135.38‘,‘59.190.8.77‘,‘10.29.130.52‘);const HOSTNAMES = array(‘ubuntu‘,‘pay_web104‘,‘video_web40‘,‘bg_web211‘,‘quanzi37‘,‘bg_web231‘,‘db2_master72‘,‘db2_slave74‘,‘db3_others‘,‘test_web‘,‘nfs1_redis1‘,‘nfs2_redis2‘,‘zhuanfaqi‘,‘prepare_web‘,‘bg_web64‘);// 密碼產生器函數public function generator_pass(){$time = time();//$md5($string);md5 函數也可以為字串產生一個隨機的值$string = $time . "[email protected]#$%^&";$string1 = str_shuffle($string); //$password = chunk_split($string1,9); 會在第9個位置插入一個指定的字串$password = mb_substr($string1,0,12);return $password;//var_dump($string1."\n");//var_dump($password."\n");}// 為主機產生密碼並記錄日誌public function produce_pass_for_hosts(){$new_hosts = array();$hosts = generator1::HOSTS;$hostnames = generator1::HOSTNAMES;for($i=0;$i<count($hosts);$i++){$new_hosts[$i][‘hostname‘]  = $hostnames[$i];$new_hosts[$i][‘host‘]  = $hosts[$i];$new_hosts[$i][‘password‘]  = $this->generator_pass();}return $new_hosts;}}$gen = new generator1();$host_info = $gen->produce_pass_for_hosts();var_dump($host_info);?>

python 寫習慣了,寫php還是有些不習慣!!多多聯絡吧!樂在其中!!

本文出自 “bobo的營運之路” 部落格,請務必保留此出處http://shiyiguo.blog.51cto.com/4949751/1900351

php 為 營運主機產生不同的隨機秘鑰。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.