老谢博客

  • 首页
  • WordPress
  • 网络技术
  • 乱七八糟
  • 运维技术
  • 给我留言
  • 关于老谢

转载:SolusVM提供的API让我用烂手机wap功能管理VPS

分类:运维技术日期:2012-02-07 - 11:52:43作者:老谢

以下代码转自:http://dao.daimaku.com

老谢的烂手机终于也能简单的操作vps了,有个重启功能足矣,诺基亚继续坚挺着

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
 
if (!empty($_GET['action'])) {
    $action = $_GET['action'];
    $sure = $_GET['sure'];
 
    if ('boot' == $action && empty($sure)) {
        echo '您确定要启动VPS吗?<a href="vps?action=boot&sure=1">确定</a>';
    } elseif ('reboot' == $action && empty($sure)) {
        echo '您确定要重新启动VPS吗?<a href="vps?action=reboot&sure=1">确定</a>';
    } elseif ($action != 'status' && $action != 'boot' && $action != 'reboot') {
        echo "操作错误!";
    } else {
        $key = "API KEY 在控制面板可获取";
        $hash = "API HASH 在控制面板可获取";
 
        $url = "http://SolusVM管理地址/api/client/command.php?key=$key&hash=$hash&action=$action";
        $data = file_get_contents($url);
 
        // Parse the returned data and build an array
 
        preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $data, $match);
        $result = array();
        foreach ($match[1] as $x => $y) {
            $result[$y] = $match[2][$x];
        }
 
        //错误信息
        if ($result["status"] == "error") {
            echo $result["statusmsg"];
        } elseif ($result["status"] == "success") {
            if ($result["statusmsg"] == "online") {
                echo "The virtual server is online!";
            } elseif ($result["statusmsg"] == "offline") {
                echo "The virtual server is offline!";
            } elseif ($result["statusmsg"] == "rebooted") {
                echo "The virtual server has been rebooted!";
            } elseif ($result["statusmsg"] == "shutdown") {
                echo "The virtual server has been shutdown!";
            } elseif ($result["statusmsg"] == "booted") {
                echo "The virtual server has been booted!";
            } else {
                echo "Status message unknown!";
            }
        }
    }
    echo '<hr>';
}
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=UTF-8"/>
<meta http-equiv="Cache-control" content="no-cache" />
<title>VPS管理</title>
</head>
<body>
<ul>
<li><a href="vps.php?action=status">查看状态</a> </li>
<li><a href="vps.php?action=boot">启动VPS</a> <br /></li>
<li><a href="vps.php?action=reboot">重启VPS</a></li>
</ul>
</body>
</html>

<?php ini_set('display_errors', 1); error_reporting(E_ALL ^ E_NOTICE); if (!empty($_GET['action'])) { $action = $_GET['action']; $sure = $_GET['sure']; if ('boot' == $action && empty($sure)) { echo '您确定要启动VPS吗?<a href="vps?action=boot&sure=1">确定</a>'; } elseif ('reboot' == $action && empty($sure)) { echo '您确定要重新启动VPS吗?<a href="vps?action=reboot&sure=1">确定</a>'; } elseif ($action != 'status' && $action != 'boot' && $action != 'reboot') { echo "操作错误!"; } else { $key = "API KEY 在控制面板可获取"; $hash = "API HASH 在控制面板可获取"; $url = "http://SolusVM管理地址/api/client/command.php?key=$key&hash=$hash&action=$action"; $data = file_get_contents($url); // Parse the returned data and build an array preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $data, $match); $result = array(); foreach ($match[1] as $x => $y) { $result[$y] = $match[2][$x]; } //错误信息 if ($result["status"] == "error") { echo $result["statusmsg"]; } elseif ($result["status"] == "success") { if ($result["statusmsg"] == "online") { echo "The virtual server is online!"; } elseif ($result["statusmsg"] == "offline") { echo "The virtual server is offline!"; } elseif ($result["statusmsg"] == "rebooted") { echo "The virtual server has been rebooted!"; } elseif ($result["statusmsg"] == "shutdown") { echo "The virtual server has been shutdown!"; } elseif ($result["statusmsg"] == "booted") { echo "The virtual server has been booted!"; } else { echo "Status message unknown!"; } } } echo '<hr>'; } ?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="application/xhtml+xml;charset=UTF-8"/> <meta http-equiv="Cache-control" content="no-cache" /> <title>VPS管理</title> </head> <body> <ul> <li><a href="vps.php?action=status">查看状态</a> </li> <li><a href="vps.php?action=boot">启动VPS</a> <br /></li> <li><a href="vps.php?action=reboot">重启VPS</a></li> </ul> </body> </html>

原文地址 : https://www.xj123.info/2386.html

本站遵循 : 署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5)

版权声明 : 原创文章转载时,请务必以超链接形式标明文章原始出处

Tags: SolusVM , SolusVM API
  • 上一篇:监控apache虚拟主机进程
  • 下一篇:thinkpad x220i简单试用
10条评论
  1. suN 说:

    沙发, 老谢这种华丽斑斓的代码颜色~~~~~~~~~~~~~~~~~~~

    POST:2012-02-07 13:44 回复
    • 小可 说:

      这个就是代码高亮啊,这个你都不知道?

      POST:2012-02-07 17:18 回复
    • 老谢 说:

      @suN 锅锅~~~

      POST:2012-02-07 22:53 回复
  2. DickWu 说:

    呵呵~Android淡定飘过~

    POST:2012-02-07 18:53 回复
    • 老谢 说:

      @DickWu 羡慕一把~

      POST:2012-02-07 22:53 回复
  3. NONO 说:

    从未用过cps

    POST:2012-02-08 13:09 回复
  4. SEO博客 说:

    我看会很痛苦

    POST:2012-02-10 18:30 回复
  5. 连仕彤 说:

    我试过但是不行,期待谢大哥指点迷津!

    POST:2014-03-29 18:34 回复
    • 老谢 说:

      @连仕彤 solusvm提供了api权限么?api填写正确么?

      POST:2014-03-29 18:45 回复
  6. 超级小猫 说:

    额~~~有asp的代码吗?

    POST:2014-03-30 03:51 回复
发表评论 点击取消评论.

*必填

*必填

  • 文章归档
  • 子网计算
  • 我的共享
  • 锻炼计划
  • 给我留言
  • 关于老谢
2025 年 6 月
一 二 三 四 五 六 日
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« 5 月    

最新文章

  • 认知,是否是一座大山?当架构决策变成配置清单比价
  • 重装博客服务器环境
  • 特斯拉24款标续 Model Y 2万公里使用体验
  • 接盘的傻子
  • 小牛us电瓶指示灯闪三次不上电
  • 一次还不错的小米售后体验
  • 装台1600元办公主机
  • 2021好久没更新博客
  • Zabbix监控oxidized备份状态
  • Zabbix 5.0 LTS版本MySQL表分区及编译安装随记

最新评论

  • zwwooooo:类似以前做网站开发时,一开始有自...
  • 老陳网志:有点高端,像我们整点nas玩玩就够...
  • springwood:自从 CentOS 不维护之后,我换 U...
  • 大D:难都搞下来了,那就更得YM了
  • 大D:只能是YM了,谢总牛啊
  • 灰常记忆:经济不好 今年我也换了机器 一...
  • 大峰:这是海外服务器嘛?速度挺快的。
  • 大D:只能单走一个6了哈哈哈
  • zwwooooo:买特斯拉和买iPhone的人群其实相似...
  • 平安家属子痕:一直坚持油车,看你写的心里有...

日志存档

  • 2025 年 5 月
  • 2025 年 4 月
  • 2025 年 3 月
  • 2024 年 9 月
  • 2024 年 5 月
  • 2024 年 1 月
  • 2023 年 4 月
  • 2021 年 10 月
  • 2021 年 4 月
  • 2021 年 3 月
  • 2021 年 2 月
  • 2020 年 11 月
  • 2020 年 9 月
  • 2020 年 5 月
  • 2020 年 4 月
  • 2020 年 3 月
  • 2020 年 1 月
  • 2019 年 12 月
  • 2019 年 10 月
  • 2019 年 7 月
  • 2019 年 6 月
  • 2019 年 5 月
  • 2019 年 3 月
  • 2019 年 1 月
  • 2018 年 12 月
  • 2018 年 11 月
  • 2018 年 10 月
  • 2018 年 7 月
  • 2018 年 6 月
  • 2018 年 5 月
  • 2018 年 4 月
  • 2018 年 3 月
  • 2018 年 1 月
  • 2017 年 10 月
  • 2017 年 9 月
  • 2017 年 8 月
  • 2017 年 7 月
  • 2017 年 2 月
  • 2017 年 1 月
  • 2016 年 12 月
  • 2016 年 11 月
  • 2016 年 10 月
  • 2016 年 7 月
  • 2016 年 6 月
  • 2016 年 4 月
  • 2016 年 2 月
  • 2016 年 1 月
  • 2015 年 12 月
  • 2015 年 10 月
  • 2015 年 9 月
  • 2015 年 7 月
  • 2015 年 5 月
  • 2015 年 4 月
  • 2015 年 3 月
  • 2015 年 2 月
  • 2015 年 1 月
  • 2014 年 12 月
  • 2014 年 10 月
  • 2014 年 9 月
  • 2014 年 8 月
  • 2014 年 7 月
  • 2014 年 6 月
  • 2014 年 5 月
  • 2014 年 4 月
  • 2014 年 3 月
  • 2014 年 2 月
  • 2014 年 1 月
  • 2013 年 12 月
  • 2013 年 11 月
  • 2013 年 10 月
  • 2013 年 9 月
  • 2013 年 8 月
  • 2013 年 7 月
  • 2013 年 6 月
  • 2013 年 5 月
  • 2013 年 4 月
  • 2013 年 3 月
  • 2013 年 2 月
  • 2013 年 1 月
  • 2012 年 12 月
  • 2012 年 11 月
  • 2012 年 9 月
  • 2012 年 8 月
  • 2012 年 7 月
  • 2012 年 6 月
  • 2012 年 5 月
  • 2012 年 4 月
  • 2012 年 3 月
  • 2012 年 2 月
  • 2012 年 1 月
  • 2011 年 12 月
  • 2011 年 11 月
  • 2011 年 10 月
  • 2011 年 9 月
  • 2011 年 8 月
  • 2011 年 7 月
  • 2011 年 6 月
  • 2011 年 5 月
  • 2011 年 4 月
  • 2011 年 3 月
  • 2011 年 2 月
  • 2011 年 1 月
  • 2010 年 12 月
  • 2010 年 11 月
  • 2010 年 10 月
  • 2010 年 9 月
  • 2010 年 8 月
  • 2010 年 7 月

W3C

  • XHTML 1.0 Transitional
  • CSS level 3
  • Google+
Copyright © 2010-2025 老谢博客 All rights reserved.
Gzipped 76.5% | Optimized loading 49 queries in 0.374 seconds | Memory 38.86 MB | 尼玛的备案
Powered by WordPress. | Hosted By LAOXUEHOST | Theme by WordPress主题巴士 | 站点地图 | SiteMap | uptime查询