<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>貳夢の弦 &#187; 開發</title>
	<atom:link href="http://blog.frost.tw/tag/%e9%96%8b%e7%99%bc/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.frost.tw</link>
	<description>夢醒之時，驚覺一切都是虛幻。前行吧！迷途者。</description>
	<lastBuildDate>Wed, 26 Oct 2011 13:28:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://blog.frost.tw/?pushpress=hub'/>
		<item>
		<title>用 PHP 對 cPanel/WHM 下達新增帳號指令</title>
		<link>http://blog.frost.tw/code/poston-2009-12-26/postid-283</link>
		<comments>http://blog.frost.tw/code/poston-2009-12-26/postid-283#comments</comments>
		<pubDate>Sat, 26 Dec 2009 10:52:43 +0000</pubDate>
		<dc:creator>蒼時弦や</dc:creator>
				<category><![CDATA[程式語言]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WHM]]></category>
		<category><![CDATA[網站]]></category>
		<category><![CDATA[開發]]></category>

		<guid isPermaLink="false">http://blog.frost.tw/?p=283</guid>
		<description><![CDATA[前幾天，我意外取得 iPanel 的 Nulled 版本。 因此詢問初心者站長的管理員興趣，並且嘗試整合到 Discuz 論壇幣系統。 經過幾天調查，發現不適用之後又轉向 WHMCS 研究。 而這兩款都使用特殊的加密（Zend的擴充套件，還未完全破解） 因此我無法理解原理，也無法做其他處理。 而在使用MSN對談過程中，我獲得了一個啟發「Access Key」與 cPanel 關係。 因此著手蒐集資料，最後在 cPanel Wiki 發現我的答案。 這是cPanel的一個API能夠控制 WHM 在 Wiki 顯示為 XmlApi 支援格式有 JSON 和 XML 兩種。 官方也公佈了一套範例 PHP 檔案，此篇文章則以其中核心部份 xmlapi.php.inc 做說明。 1.  到 cPanel &#8230; <a href="http://blog.frost.tw/code/poston-2009-12-26/postid-283">Continue reading <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-06-27%2Fpostid-562&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">取得 WHM/cPanel 帳號一組～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-04%2Fpostid-572&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WHM/cPanel for DiscuzX 的插件～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-03-28%2Fpostid-465&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Discuz! X 測試版發布日</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fweb-project%2Fposton-2010-03-22%2Fpostid-458&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Discuz 7.2 插件開發筆記 – 技能系統(1)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>前幾天，我意外取得 iPanel 的 Nulled 版本。<br />
因此詢問初心者站長的管理員興趣，並且嘗試整合到 Discuz 論壇幣系統。<br />
經過幾天調查，發現不適用之後又轉向 WHMCS 研究。<br />
<span id="more-283"></span><br />
而這兩款都使用特殊的加密（Zend的擴充套件，還未完全破解）<br />
因此我無法理解原理，也無法做其他處理。</p>
<p>而在使用MSN對談過程中，我獲得了一個啟發「Access Key」與 cPanel 關係。<br />
因此著手蒐集資料，最後在 cPanel Wiki 發現我的答案。</p>
<p>這是cPanel的一個API能夠控制 WHM 在 Wiki 顯示為 XmlApi<br />
支援格式有 JSON 和 XML 兩種。</p>
<p>官方也公佈了一套範例 PHP 檔案，此篇文章則以其中核心部份 xmlapi.php.inc 做說明。</p>
<p>1.  到<a href="http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v.0.1.tar.gz" target="_blank"> cPanel Wiki </a>下載範例壓縮檔，並且把 xmlapi.php.inc 複製到要製作的目錄。</p>
<p>2. 新增一個 PHP 檔案，內容參考 範例壓縮檔 任一檔案撰寫。</p>
<pre class="brush:php">include('xmlapi.php.inc'); //讀入程式庫

$server = 'domain.com'; //主機域名
$user = 'username'; //登入帳號（某些指令需要root帳號）
$accesskey = ''; //Access Key 可到 WHM 控制台複製（直接貼上即可，無須理會斷行）

//cPanel API Object
$cpapi = new xmlapi($server); //建立物件並連接主機
$cpapi-&gt;hash_auth($user, $accesskey); //進行登入（另一個方法是輸入帳號密碼）

//Create Account
$account_info = array(
  'username' =&gt; 'testuser', //使用者帳號
  'password' =&gt; 'p123456', //使用者密碼
  'domain' =&gt; 'testuser.domain.com', //使用者域名
  'email' =&gt; 'test@domain.com', //使用者信箱
  'plan' =&gt; 'basic' //主機方案
);
$return = $cpapi-&gt;createacct($account_info); //下達指令，並且把傳回的XML儲存
</pre>
<p>3. 接著到 cPanel 控制台觀看，就會發現新帳號出現了！</p>
<p>如果想要把回傳資訊顯示出來，可以利用PHP5的simplexml讀取。</p>
<pre class="brush:php">$xmlobj = simplexml_load_string($return);
foreach($xmlobj as $key =&gt; $arr){
  echo "{$key} - {$arr}
";
}
</pre>
<p>如果想要知道更多資訊，可以到 <a href="http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi" target="_blank">cPanel Wiki</a> 查詢。</p>
<p>經過這次的吸收知識，可是讓我了解WHMCS這類軟體原來是這樣控制主機控制台。<br />
大家也試試看吧！</p>
<p>現在台灣很多人都提供cPanel免空，有租 Reseller 的朋友可以利用這個API做出一套簡易申請系統喔！<br />
不但方便，還能夠順便儲存一些資訊以後調出來查詢呢！</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜歡：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-06-27%2Fpostid-562&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">取得 WHM/cPanel 帳號一組～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-07-04%2Fpostid-572&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">WHM/cPanel for DiscuzX 的插件～</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Flife%2Fposton-2010-03-28%2Fpostid-465&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Discuz! X 測試版發布日</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.frost.tw%2Fweb-project%2Fposton-2010-03-22%2Fpostid-458&from=http%3A%2F%2Fblog.frost.tw%2Fcode%2Fposton-2009-12-26%2Fpostid-283">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Discuz 7.2 插件開發筆記 – 技能系統(1)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.frost.tw/code/poston-2009-12-26/postid-283/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

