|
发表于 2016-4-14 13:11:17
|
显示全部楼层
牛逼,前些年某东搞了个自动化,好像还是自己开发的,不过现在连某东的博客都死掉了。
自动化好是好,也要人工参与配合才好。早前让我们家的小逗逼写了一个,丫的搞了一半出来给我跑路了。
[ol] array('FriendlyName' => '数据中心', 'Type' => 'dropdown', 'Options' => '2|Dallas TX USA,3|Fremont CA USA,4|Atlanta GA USA,6|Newark NJ USA,7|London England UK,9|Singapore SG,10|Frankfurt DE'), 'PlanID' => array('FriendlyName' => '套餐', 'Type' => 'dropdown', 'Options' => '1|1GB-24GB-$10,2|2GB-48GB-$20 ,4|4GB-96GB-$40,6|8GB-192GB-$80 ,7|16GB-384GB-$160,8|32GB-768GB-$320 '), 'PaymentTerm' => array('FriendlyName' => '付款周期', 'Type' => 'dropdown', 'Options' => '1|月付,12|年付,24|两年付'), 'distribution' => array('FriendlyName' => 'Distributions', 'Type' => 'text', 'Size' => '25')); return $configarray;}function linodepro_CreateAccount($params){ $key = get_key(); $result = select_query('tblcustomfields', '*', array('relid' => $params['pid'], 'type' => 'product', 'fieldname' => 'Linode ID')); $tblcustomfield = mysql_fetch_array($result); if (!$tblcustomfield) { return '在Custom Fields区域设置"Linode ID"字段'; } if (!empty($params['customfields']['Linode ID'])) { return 'VPS已经创建'; } $DatacenterID = jiequ($params['configoption1']); $PlanID = jiequ($params['configoption2']); $PaymentTerm = jiequ($params['configoption3']); //获取用户配置选项 $result = select_query('tblhostingconfigoptions', '*', array('relid' => $params['serviceid'])); $config = array(); while ($data = mysql_fetch_array($result)) { $configid = $data['configid']; $optionid = $data['optionid']; $result1 = select_query('tblproductconfigoptions', '*', array('id' => $configid)); $data1 = mysql_fetch_array($result1); $name = explode('|',$data1['optionname']); $name = $name[0]; $result2 = select_query('tblproductconfigoptionssub', '*', array('id' => $optionid)); $data2 = mysql_fetch_array($result2); $value = explode('|',$data2['optionname']); $value = $value[0]; $re = array($name=>$value); $config = array_merge($config, $re); } if($config['datacenter']){ $DatacenterID = $config['datacenter']; } if($config['os']){ $osid = $config['os']; } $LinodeApi = new Linode\LinodeApi($key); $linode = $LinodeApi->create($DatacenterID, $PlanID, $PaymentTerm); $LinodeID = $linode['LinodeID']; if (!$LinodeID) { return '创建失败'; } else { $result = update_query('tblcustomfieldsvalues', array('value' => $LinodeID), array('relid' => $params['serviceid'])); $api = new Linode\Linode\IpApi($key); $linode = $api->getList($LinodeID); $ip = $linode[0]['IPADDRESS']; // 写入IP $result = update_query('tblhosting', array('dedicatedip' => $ip), array('id' => $params['serviceid'])); // 写入Username $username = 'Lin' . time(); $result = update_query('tblhosting', array('username' => $username), array('id' => $params['serviceid'])); // 写入密码 $command = 'modulechangepw'; $adminuser = 'Rojey'; $values['serviceid'] = $params['serviceid']; $values['servicepassword'] = randStr(); $results = localAPI($command, $values, $adminuser); //安装系统 install_os($params,$LinodeApi,$LinodeID,null,$osid , $values['servicepassword'],$key); return 'success'; }}[/ol]复制代码 |
|