Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Modify/make WHM account creater..
Old 04-24-2008, 01:03 PM Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Okay so i am trying to do my self a order system and i have a budget of £0 been playing with PHPcoin but its not really what i want. and i would much prefer to build one myself so it can be bare bones.

I have the accounting file from cPanel so thats not a issue.

I want to have a script where i can post the new username, password, domain, package, email to and it will create the account.


The rest i can do.

below is a plugin for phpcoin which does the whm stuff, but i have never done it before and looks a bit confusing >< can someone help me decfer it please

PHP Code:
<?php
/****************************************************************
* File: WHM Module Admin Functions File
* Based On Code By: Jeremi Bergman (http://www.mividdesigns.com)
* Version: 1.4.3
* Author: Keith Holler (http://www.azcappy.com)
* License: DO NOT Remove this text block. See /docs/license.txt
*          Copyright © 2003-2008 phpCOIN.com
* Schema: See sql file for schema reference
* Notes:
* - Translation File: lang_whm.php
*
* Visit http://bugs.azcappy.com or send email to bugs@azcappy.com
* to report bugs or request features.
****************************************************************/
# Code to handle file being loaded by URL
IF (eregi("whm_admin.php"$_SERVER["PHP_SELF"]))
{
 require_once (
'../../coin_includes/session_set.php');
 require_once(
PKG_PATH_INCL.'redirect.php');
 
html_header_location('error.php?err=01&url=mod.php?mod=whm');
 exit;
}
# Include language file (must be after parameter load to use them)
 
require_once($_CCFG['_PKG_PATH_LANG'].'lang_whm.php');
 IF (
file_exists($_CCFG['_PKG_PATH_LANG'].'lang_whm_override.php')) {
  require_once(
$_CCFG['_PKG_PATH_LANG'].'lang_whm_override.php');
 }
/**************************************************************
*  WHM Remote Access Key
**************************************************************/
function do_get_remote_access_key(){
 
# Cannot be tabbed over
 
$rak 'WHM HASH CODE';
 return 
$rak;
}
/**************************************************************
* Module Admin Functions
**************************************************************/
function do_whm_create_acct ($adata$aret_flag=0$from_api=0)
{
 
# Assumes:  Nothing
 # Passed In:  $adata['username']  - username to add to WHM
 # Passed In:  $adata['password']  - password for username to add to WHM
 # Passed In:  $adata['domain']   - domian to add to WHM
 # Passed In:  $adata['plan']   - plan for domain to add to WHM
 # Passed In:  $adata['dom_id']   - phpCOIN Domain Id
 # Dim some Vars
 
global $_CCFG$_TCFG$_DBCFG$db_coin$_UVAR$_LANG$_SERVER$_nl$_sp;
 
$success 0;  // assume we are unsuccessful until changed
 
$rak do_get_remote_access_key();
 include_once (
$_CCFG['WHM_ACCOUNT_FILE']);
 IF (
$adata['username']!="" && $adata['password']!=""){
  
$whmresult createacct($_CCFG['DOM_DEFAULT_IP'],$_CCFG['WHM_USER'],$rak,0,$adata['domain'],$adata['username'],$adata['password'],$adata['plan']);
  IF (
$_CCFG['WHM_DEBUG_ON']) { print_r($whmresult); }
 } ELSE {
  
$_out '<center>' $_LANG['_WHM']['No_U_P'] . '</center>';
 }
 
# check result and set success string accordingly
 
IF (strstr($whmresult,'New Account Info')) { 
  
$success 1;
 } ELSE { 
  
$success=0;
 }
 IF (
$success) {
  
$_out .= '<center>'.$_LANG['_WHM']['Create_Success'].'</center>';
 } ELSEIF(
strstr($whmresult,'domain is already setup')) {
  
$_out .= '<center>'.$_LANG['_WHM']['Create_Domain_Err'].'</center>';
 } ELSEIF(
strstr($whmresult,'username is taken')) {
  
$_out .= '<center>'.$_LANG['_WHM']['Create_User_Err'].'</center>';
 } ELSEIF(
strstr($whmresult,'choose a plan')) {
  
$_out .= '<center>'.$_LANG['_WHM']['Create_Plan_Err'].'</center>';
 } ELSE {
  
$_out .= '<center>'.$_LANG['_WHM']['Create_Failure'].'</center>';
 }
 IF (
$adata['send_acc_email'] == "on" && $success) {
  include_once ( 
$_CCFG['_PKG_PATH_LANG'].'lang_domains.php');
  
do_mail_domain($adata,1);
  
$_out .= '<center>'.$_LANG['_WHM']['acc_email_sent'].'</center>';
 }
 
# Change output if from API
 
IF ($from_api) { $_out $success; }
 
# Either return output or echo here
 
IF ( $aret_flag ) { return $_out; } ELSE { echo $_out; }
}
function 
do_add_domain_from_api($adata)
{
 global 
$_CCFG$_LANG$_DBCFG$db_coin;
 
$query ""$result ""$row ""$_ret 0;
 
# Set Query for select.
 
$query .= "SELECT dom_user_name_cp,dom_user_pword_cp,dom_id";
 
$query .= " FROM ".$_DBCFG['domains'];
 
$query .= " WHERE dom_domain = '".$adata['ord_domain']."'";
 
# Do select
 
$result  $db_coin->db_query_execute($query);
 
$numrows $db_coin->db_query_numrows($result);
 
$row  $db_coin->db_fetch_array($result);
 
# Check for plan setup
 
IF (get_package_name($adata['ord_prod_id'])==null && ($_CCFG['WHM_DEBUG_ON'])) {
  echo 
'<center><b>Plan does not exist.  Please check package matching <a href="mod.php?mod=whm&mode=match_prods">here</a></b></center>';
 } ELSE {
  
# Set data
  
$data['username'] = $row['dom_user_name_cp'];
  
$data['password'] = $row['dom_user_pword_cp'];
  
$data['domain'] = $adata['ord_domain'];
  
$data['plan'] = get_package_name($adata['ord_prod_id']);
  
$data['dom_id'] = $row['dom_id'];
  
$data['send_acc_email'] = ($_CCFG['WHM_SEND_ACC_ON_AUTO'] ? "on" "off");
  
# Add
  
$_ret do_whm_create_acct($data,1,1);
 }
 return 
$_ret;
}
function 
do_whm_delete_acct ($adata$aret_flag=0)
{
 
# Assumes:  Nothing
 # Passed In:  $adata['cp_username'] - User to delete from WHM
 #                or
 #             $adata['dom_user_name_cp'] - User to delete from WHM
 # Dim some Vars
 
global $_CCFG$_LANG$_DBCFG$db_coin;
 
$rak do_get_remote_access_key();
 if (empty(
$adata['dom_user_name_cp'])) { # check for empty domain username
  
$adata['dom_user_name_cp'] = $adata['cp_username'];
  include_once (
$_CCFG['WHM_ACCOUNT_FILE']);
  
$result killacct($_CCFG['DOM_DEFAULT_IP'],$_CCFG['WHM_USER'],$rak,0,$adata['dom_user_name_cp']);
  IF (
$_CCFG['WHM_DEBUG_ON']) { $_out .= $result; }
  IF (
strstr($result,'Done')) {
   
$_out .= '<center>'.$_LANG['_WHM']['Delete_Success'].'<center>';
  } ELSEIF (
strstr($result,'unix user does not exist')) {
   
$_out .= '<center>'.$_LANG['_WHM']['Delete_User_Err'].'<center>';
  } ELSE {
   
$_out .= '<center>'.$_LANG['_WHM']['Delete_Failure'].'<center>';
  }
  IF ( 
$aret_flag ) {
   return 
$_out;
  } ELSE {
   echo 
$_out;
  }
 }
}
function 
do_whm_suspend_acct ($adata$aret_flag=0)
{
 
# Dim some Vars
 
global $_CCFG$_LANG$_DBCFG$db_coin;
 
$rak do_get_remote_access_key();
 include_once (
$_CCFG['WHM_ACCOUNT_FILE']);
 
$result suspend($_CCFG['DOM_DEFAULT_IP'],$_CCFG['WHM_USER'],$rak,0,$adata['cp_username']);
 IF (
$_CCFG['WHM_DEBUG_ON']) { $_out .= $result; }
 IF (
strstr($result,'account has been suspended')) {
  
$_out .= '<center>'.$_LANG['_WHM']['Account_Suspended'].'</center>';
 } ELSEIF (
strstr($result,'Account Already Suspended')) {
  
$_out .= '<center>'.$_LANG['_WHM']['Suspend_Fail_Already'].'</center>';
 } ELSE {
  
$_out .= '<center>'.$_LANG['_WHM']['Suspend_Fail'].'</center>';
 }
 IF ( 
$aret_flag ) { return $_out; } ELSE { echo $_out; }
}
function 
do_whm_unsuspend_acct ($adata$aret_flag=0)
{
 
# Dim some Vars
 
global $_CCFG$_LANG$_DBCFG$db_coin;
 
$rak do_get_remote_access_key();
 include_once (
$_CCFG['WHM_ACCOUNT_FILE']);
 
$result unsuspend($_CCFG['DOM_DEFAULT_IP'],$_CCFG['WHM_USER'],$rak,0,$adata['cp_username']);
 IF (
$_CCFG['WHM_DEBUG_ON']) { $_out .= $result; }
 IF (
strstr($result,'account is now active')) {
  
$_out .= '<center>'.$_LANG['_WHM']['Account_Unsuspended'].'</center>';
 } ELSE {
  
$_out .= '<center>'.$_LANG['_WHM']['UnSuspend_Fail'].'</center>';
 }
 IF ( 
$aret_flag ) { return $_out; } ELSE { echo $_out; }
}
function 
do_list_domain_table($adata$aret_flag=0)
{
 
# Get security vars
 
$_SEC get_security_flags ();
 
$_PERMS do_decode_perms_admin($_SEC[_sadmin_perms]);
 
# Dim some Vars:
 
global $_CCFG$_TCFG$_DBCFG$db_coin$_UVAR$_LANG$_SERVER$_nl$_sp;
 
$query ""$result""$numrows 0;
 
# Get WHM Version
 
include_once ($_CCFG['WHM_ACCOUNT_FILE']);
 
$rak do_get_remote_access_key();
 
$ver showversion($_CCFG['DOM_DEFAULT_IP'],$_CCFG['WHM_USER'],$rak,0);
 
# Set Query for select for current server information
 
$getserverinfo "SELECT *";
 
$getserverinfo .= " FROM ".$_DBCFG['server_info'];
 
$getserverinfo .= " WHERE si_ip = '".$_CCFG['DOM_DEFAULT_IP']."'";
 
$serverresult  $db_coin->db_query_execute($getserverinfo);
 
$servernumrows $db_coin->db_query_numrows($serverresult);
 
$serverinfo  $db_coin->db_fetch_array($serverresult);
 
 
# Set Query for select.
 
$query .= "SELECT *";
 
$query .= " FROM ".$_DBCFG['domains'];
 
$tmpStatus explode(" ",$_CCFG['WHM_DOMAIN_STATUS']);
 
$tmpStatusCount count($tmpStatus);
 if (
$tmpStatusCount 0) {
  
$query .= " WHERE ";
  
$i 1;
  foreach(
$tmpStatus as $k => $v) {
   
# Pull only the domains that match the domain status parameter field and the current server ID
   
$query .= "dom_status = '$v' && dom_si_id = '".$serverinfo['si_id']."'";
   if (
$i $tmpStatusCount) { $query .= "OR "; }
   
$i++;
  }
 }
 
$query .= " ORDER BY dom_id";
 
# Build Page menu
 # Get count of rows total for pages menu:
 
$query_ttl "SELECT COUNT(*)";
 
$query_ttl .= " FROM ".$_DBCFG['domains'];
 
$query_ttl .= $_where;
 
$result_ttl$db_coin->db_query_execute($query_ttl);
 while(list(
$cnt) = $db_coin->db_fetch_row($result_ttl)) { $numrows_ttl $cnt; }
 
# Page Loading first rec number
 # $_rec_next - is page loading first record number
 # $_rec_start - is a given page start record (which will be rec_next)
 
$_rec_page $_CCFG['WHM_NUM_PAGES'];
 
$_rec_next $adata['rec_next'];
 IF (!
$_rec_next) { $_rec_next=0; }
 
# Range of records on current page
 
$_rec_next_lo $_rec_next+1;
 
$_rec_next_hi $_rec_next+$_rec_page;
 IF ( 
$_rec_next_hi $numrows_ttl) { $_rec_next_hi $numrows_ttl; }
 
# Calc no pages,
 
$_num_pages round(($numrows_ttl/$_rec_page), 0);
 IF ( 
$_num_pages < ($numrows_ttl/$_rec_page) ) { $_num_pages $_num_pages+1; }
 
# Loop Array and Print Out Page Menu HTML
 
$_page_menu $_LANG['_WHM']['l_Pages'].$_sp;
 for (
$i 1$i <= $_num_pages$i++)
 {
  
$_rec_start = ( ($i*$_rec_page)-$_rec_page);
  IF ( 
$_rec_start == $_rec_next ){
   
# Loading Page start record so no link for this page.
   
$_page_menu .= "$i";
  } ELSE {
   
$_page_menu .= '<a href="'.$_SERVER["PHP_SELF"].'?mod=whm'.$_link_xtra.'&rec_next='.$_rec_start.'">'.$i.'</a>';
  }
  IF ( 
$i $_num_pages ) { $_page_menu .= ','.$_sp; }
 }
 
# End page menu
 # Finish out query with record limits and do data select for display and return check
 
$query  .= $_where." LIMIT $_rec_next$_rec_page";
 
$result  $db_coin->db_query_execute($query);
 
$numrows $db_coin->db_query_numrows($result);
 
# Generate Links For Sorting
 
$_hdr_link_prefix '<a href="'.$_SERVER["PHP_SELF"].'?mod=domains&sb=';
 
$_hdr_link_suffix '&fb='.$adata['fb'].'&fs='.$adata['fs'].'&fc='.$adata['fc'].'&rec_next='.$_rec_next.'">';
 
# Build Accounts List From WHM
 
$accts do_build_acct_ary();
 
# Build Javascript To confirm Deletion
 
$_out .= '<script language="JavaScript">'.$_nl;
 
$_out .= ' function ok2delete() {'.$_nl;
 
$_out .= ' var txt = "'.$_LANG['_WHM']['DEL_CONFIRM'].'";'.$_nl;
 
$_out .= ' return confirm(txt); }'.$_nl;
 
$_out .= '</script>'.$_nl;
 
# Build Output
 
$_out .= '<div align="center">'.$_nl;
 
$_out .= '<table align="center" style="border: 1px dashed black" bgcolor="#eeeeee"><tr><td class="TP3SML_NC">'.$_nl;
 
$_out .= '<b>Quick Tip:</b> Click on the Id # to edit the details of the server or the domain within phpCOIN.'.$_nl;
 
$_out .= '</td></tr></table><br>'.$_nl;
 
# Display Title & Server Information Table
 
$_out .= '<table width="95%" border="0" cellpadding="0" cellspacing="1">'.$_nl;
 
$_out .= '<tr><td class="TP3SML_NR">'.$_nl;
 
$_out .= '<a href="http://bugs.azcappy.com" target="_blank">Bug/Dev Tracking System</a> | '.$_nl;
 
$_out .= '<a href="http://docs.phpcoin.com/index.php/WHM_Plug-In" target="_blank">Documentation</a>'.$_nl;
 
$_out .= '</td></tr></table>'.$_nl;
 
$_out .= '<table width="95%" border="0" bordercolor="'.$_TCFG['_TAG_TABLE_BRDR_COLOR'].'" bgcolor="'.$_TCFG['_TAG_TRTD_BKGRND_COLOR'].'" cellpadding="0" cellspacing="1">'.$_nl;
 
$_out .= '<tr class="BLK_DEF_TITLE"><td class="TP3MED_NC" colspan="7">'.$_nl;
 
$_out .= '<table width="100%" cellpadding="0" cellspacing="0">'.$_nl;
 
$_out .= '<tr class="BLK_IT_TITLE_TXT">'.$_nl.'<td class="TP0MED_NL">'.$_nl;
 
$_out .= '<b>Server Information</b><br>'.$_nl;
 
$_out .= '</td><td class="TP0MED_NR">'.$_nl;
 
$_out .= '</td></tr></table></td></tr>'.$_nl;
 
$_out .= '<tr class="BLK_DEF_ENTRY">'.$_nl;
 
$_out .= '<td nowrap width="5%" class="TP3SML_NC" valign="top"><b>Id</b></td>'.$_nl;
 
$_out .= '<td nowrap width="28%" class="TP3SML_NL" valign="top"><b>Server Name</b></td>'.$_nl;
 
$_out .= '<td nowrap width="17%" class="TP3SML_NC" valign="top"><b>IP Address</b></td>'.$_nl;
 
$_out .= '<td nowrap width="13%" class="TP3SML_NC" valign="top"><b>WHM Version</b></td>'.$_nl;
 
$_out .= '<td nowrap width="35%" class="TP3SML_NL" valign="top"><b>Actions</b></td></tr>'.$_nl;
 
$_out .= '<tr class="BLK_DEF_ENTRY">'.$_nl;
 
$_out .= '<td nowrap class="TP3SML_NC"><a href="admin.php?cp=server_info&op=edit&si_id='.$serverinfo['si_id'].'">'.$serverinfo['si_id'].'</a></td>'.$_nl;
 
$_out .= '<td nowrap class="TP3SML_NL">'.$serverinfo['si_name'].'</td>'.$_nl;
 
$_out .= '<td nowrap class="TP3SML_NC">'.$_CCFG['DOM_DEFAULT_IP'].'</td>'.$_nl;
 
$_out .= '<td nowrap class="TP3SML_NC">'.$ver.'</td>'.$_nl;
 
$_out .= '<td nowrap class="TP3SML_NL">'.$_nl;
 
$_out .= '<a href="http://'.$_CCFG['DOM_DEFAULT_IP'].'/whm" target="_blank">Login</a>'.$_sp.$_nl;
 
$_out .= '</td></tr></table><br>'.$_nl;
 
# Display phpCOIN Domains Compared To WHM Table
 
$_out .= '<table width="95%" border="0" bordercolor="'.$_TCFG['_TAG_TABLE_BRDR_COLOR'].'" bgcolor="'.$_TCFG['_TAG_TRTD_BKGRND_COLOR'].'" cellpadding="0" cellspacing="1">'.$_nl;
 
$_out .= '<tr class="BLK_DEF_TITLE"><td class="TP3MED_NC" colspan="7">'.$_nl;
 
$_out .= '<table width="100%" cellpadding="0" cellspacing="0">'.$_nl;
 
$_out .= '<tr class="BLK_IT_TITLE_TXT">'.$_nl.'<td class="TP0MED_NL">'.$_nl;
 
$_out .= '<b>'.$_LANG['_WHM']['TITLE'].$_sp.'</b><br>'.$_nl;
 
$_out .= '</td>'.$_nl.'<td class="TP0MED_NR">'.$_nl;
 
$_out .= '</td>'.$_nl.'</tr>'.$_nl.'</table>'.$_nl;
 
$_out .= '</td></tr>'.$_nl;
 
$_out .= '<tr class="BLK_DEF_ENTRY">'.$_nl;
 
$_out .= '<td class="TP3SML_NC" valign="top"><b>'.$_LANG['_WHM']['l_ID'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NC" valign="top"><b>'.$_LANG['_WHM']['l_In_WHM'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['l_Domain'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['l_UserName'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['l_Actions'].'</b></td></tr>'.$_nl;
 
# Process Query Results
 
IF ( $numrows ) {
  while (
$row $db_coin->db_fetch_array($result))
  {
   
$exists do_acct_exists_in_whm($accts$row['dom_domain']);
   
$suspended $accts[$row['dom_user_name_cp']][3];
   IF (
$exists) { $accts do_del_from_array($accts$row['dom_domain']); } // deletes from tmp array
   
$_out .= '<tr class="BLK_DEF_ENTRY">'.$_nl;
   
$_out .= '<td class="TP3SML_NC"><a href="mod.php?mod=domains&mode=edit&dom_id='.$row['dom_id'].'">'.$row['dom_id'].'</a></td>'.$_nl;
   
$_out .= '<td class="TP3SML_NC">';
   IF (
$exists) {
    
$_out .= "<img src=coin_modules/whm/images/checkmark.gif>";
    
$_out .= '</td>'.$_nl;
   }
   IF (
$suspended==1){
    
$_out .= '<td class="TP3SML_NL"><font color=red><b>'.$row['dom_domain'].'</b></font></td>'.$_nl;
   } ELSE {
    
$_out .= '<td class="TP3SML_NL">'.$row['dom_domain'].'</td>'.$_nl;
   }
   
$_out .= '<td class="TP3SML_NL">'.$row['dom_user_name_cp'].'</td>'.$_nl;
   
$_out .= '<td class="TP3SML_NL">'.$_nl;
   
$_out .= do_create_nav_links($row['dom_id'],$exists,$suspended);
   
$_out .= '</td></tr>'.$_nl;
  }
 }
 
# Closeout phpCOIN Domains Compared To WHM Table
 
$_out .= '<tr class="BLK_DEF_ENTRY"><td class="TP3MED_NC" colspan="7">'.$_nl;
 
$_out .= $_page_menu.$_nl;
 
$_out .= '</td></tr></table></div><br>'.$_nl;
 
# Display Domains In WHM Not In phpCOIN Table
 
$_out .= '<div align="center">'.$_nl;
 
$_out .= '<table width="95%" border="0" bordercolor="'.$_TCFG['_TAG_TABLE_BRDR_COLOR'].'" bgcolor="'.$_TCFG['_TAG_TRTD_BKGRND_COLOR'].'" cellpadding="0" cellspacing="1">'.$_nl;
 
$_out .= '<tr class="BLK_DEF_TITLE"><td class="TP3MED_NC" colspan="7">'.$_nl;
 
$_out .= '<table width="100%" cellpadding="0" cellspacing="0">'.$_nl;
 
$_out .= '<tr class="BLK_IT_TITLE_TXT">'.$_nl.'<td class="TP0MED_NL">'.$_nl;
 
$_out .= '<b>'.$_LANG['_WHM']['In_WHM'].$_sp.'</b><br>'.$_nl;
 
$_out .= '</td><td class="TP0MED_NR">'.$_nl;
 
$_out .= '</td></tr></table></td></tr>'.$_nl;
 
$_out .= '<tr class="BLK_DEF_ENTRY">'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['l_Domain'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['l_UserName'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['plan'].'</b></td>'.$_nl;
 
$_out .= '<td class="TP3SML_NL" valign="top"><b>'.$_LANG['_WHM']['l_Actions'].'</b></td></tr>'.$_nl;
 
# Process Query Results
 
FOREACH($accts as $user => $account)
 {
  
$data="";
  
$data['dom_domain']=$account[0];
  
$data['dom_user_name_cp']=$user;
  
$suspended $account[3];
  
$_out .= '<tr class="BLK_DEF_ENTRY">'.$_nl;
  
$_chk do_check_suspended($user);
  IF (
$suspended==1) {
   
$_out .= '<td class="TP3SML_NL"><font color=red><b>'.$account[0].'</b></font></td>'.$_nl;
  } ELSE {
   
$_out .= '<td class="TP3SML_NL">'.$account[0].'</td>'.$_nl;
  }
  
$_out .= '<td class="TP3SML_NL">'.$user.'</td>'.$_nl;
  
$_out .= '<td class="TP3SML_NL">'.$account[1].'</td>'.$_nl;
  
$_out .= '<td class="TP3SML_NL">'.$_nl;
  
$_out .= do_create_nav_links($data,1,$suspended,1);
  
$_out .= '</td></tr>'.$_nl;
 }
 
# Closeout Domains In WHM Not In phpCOIN Table
 
$_out .= '</table></div><br>'.$_nl;
 
# Display Output
 
IF ( $aret_flag ) { return $_out; } ELSE { echo $_out; }
}
function 
do_add_domain_form($adata$aret_flag 0)
{
 
# Dim some Vars:
 
global $_CCFG$_TCFG$_DBCFG$db_coin$_UVAR$_LANG$_SERVER$_SEC$_nl$_sp;
 
$query ""$result""$numrows 0;
 
$rak do_get_remote_access_key();
 
# Get Packages
 
include_once ($_CCFG['WHM_ACCOUNT_FILE']);
 
$packages listpkgs($_CCFG['DOM_DEFAULT_IP'], $_CCFG['WHM_USER'], $rak0);
 IF (
$_CCFG['WHM_DEBUG_ON']) { $_out .= print_r($packages,true); }
 
# Build Select Code
 
$sel '<SELECT NAME="plan" class="select_form">'.$_nl;
 foreach(
$packages as $key => $value)
 
$sel .= '<OPTION>'.$key.'</OPTION>'.$_nl;
 
$sel .= '</SELECT>'.$_nl;
 IF (
is_numeric($adata['dom_id'])) {
  
# Set Query for select.
  
$query .= "SELECT *";
  
$query .= " FROM ".$_DBCFG['domains'];
  
$query .= " WHERE dom_id = ".$adata['dom_id'];
  
# Do select
  
$result  $db_coin->db_query_execute($query);
  
$numrows $db_coin->db_query_numrows($result);
  
$row  $db_coin->db_fetch_array($result);
 }
 ELSEIF (!empty(
$adata['dom_domain'])) {
  
# Set Query for select.
  
$query .= "SELECT *";
  
$query .= " FROM ".$_DBCFG['domains'];
  
$query .= " WHERE dom_domain = '".$adata['dom_domain']."'";
  
# Do select
  
$result  $db_coin->db_query_execute($query);
  
$numrows $db_coin->db_query_numrows($result);
  
$row  $db_coin->db_fetch_array($result);
 }
 
# Setup some variables
 
$_blk_title  $_LANG['_WHM']['Add_Domain'];
 
# Some HTML Strings (reduce text)
 
$_td_str_span '<td class="TP3SML_BC" colspan="2">';
 
$_td_str_left '<td class="TP3SML_NR" width="30%">';
 
$_td_str_right '<td class="TP3SML_NL" width="70%">';
 
# Build Title String, Content String, and Footer Menu String
 
$_tstr .= $_blk_title;
 
$_cstr .= '<table width="100%" border="0" cellspacing="0" cellpadding="5">'.$_nl;
 
$_cstr .= '<tr><td align="center">'.$_nl;
 
$_cstr .= '<form action=mod.php?mod=whm&mode=add&step=2 method="post" name="domain">'.$_nl;
 
$_cstr .= '<table width="100%" cellspacing="0" cellpadding="1">'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '<b>'.$_LANG['_WHM']['domain'].$_sp.'</b>'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= '<INPUT class="PSML_NL" type="text" name="domain" size="20" value="' $row['dom_domain'] .'">'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= '</tr>'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '<b>'.$_LANG['_WHM']['username'].$_sp.'</b>'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= '<INPUT class="PSML_NL" type="text" name="username" size="20" maxlength="8" value="' $row['dom_user_name_cp'] .'">'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= '</tr>'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '<b>'.$_LANG['_WHM']['password'].$_sp.'</b>'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= '<INPUT class="PSML_NL" type="text" name="password" size="20" maxlength="20" value="' $row['dom_user_pword_cp'] .'">'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= '</tr>'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '<b>'.$_LANG['_WHM']['plan'].$_sp.'</b>'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= $sel.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= '</tr>'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '<b>'.$_LANG['_WHM']['send_acc_email'].$_sp.'</b>'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= '<INPUT type="checkbox" name="send_acc_email" checked>'.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= '</tr>'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= do_input_button_class_sw ('b_submit''SUBMIT'$_LANG['_WHM']['b_submit'], 'button_form_h''button_form''1').$_nl;
 
$_cstr .= do_input_button_class_sw ('b_reset''RESET'$_LANG['_WHM']['b_reset'], 'button_form_h''button_form''1');
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= '</tr>'.$_nl;
 
$_cstr .= '</table>'.$_nl;
 
$_cstr .= '<INPUT type="hidden" name="dom_id" value="' $row['dom_id'] .'">'.$_nl;
 
$_cstr .= '</form>'.$_nl;
 
$_cstr .= '</td></tr>'.$_nl;
 
$_cstr .= '<tr><td align="right">'.$_nl;
 
$_cstr .= '</td></tr>'.$_nl;
 
$_cstr .= '</table>'.$_nl;
 
# Return/Echo Final Output
 
IF ( $aret_flag ) { return $_cstr; } ELSE { echo $_out; }
}
function 
do_create_nav_links($adata$exists$suspended=3$whm=0)
{
 global 
$_sp$_LANG$_DBCFG$db_coin;
 IF (
is_numeric ($adata)) {
  
# Set Query for select.
  
$query .= "SELECT *";
  
$query .= " FROM ".$_DBCFG['domains'];
  
$query .= " WHERE dom_id = $adata";
  
# Do select
  
$result  $db_coin->db_query_execute($query);
  
$numrows $db_coin->db_query_numrows($result);
  
$row  $db_coin->db_fetch_array($result);
 } ELSE {
  
$row $adata;
 }
 IF (!
$exists) {
  
$_ret .= do_nav_link ($_SERVER["PHP_SELF"].'?mod=whm&mode=add&dom_id='.$adata,$_LANG['_WHM']['add'],'').$_sp;
 } ELSE {
  IF(
$whm){
   
$lnk  $_SERVER["PHP_SELF"].'?mod=domains&mode=add';
   
$lnk .= '&dom_domain='.$row['dom_domain'];
   
$lnk .= '&dom_user_name_cp='.$row['dom_user_name_cp'];
   
$lnk .= '&dom_user_name_ftp='.$row['dom_user_name_cp'];
   
$_ret .= do_nav_link($lnk,$_LANG['_WHM']['add_phpcoin'],'').$_sp;
  }
  
$_ret .= do_nav_link ($_SERVER["PHP_SELF"].'?mod=whm&mode=del&cp_username='.$row['dom_user_name_cp'].'" onclick="return ok2delete()"',$_LANG['_WHM']['delete'],'').$_sp;
  IF ((
$suspended==0) || ($suspended==3)) {
   
$_ret .= do_nav_link ($_SERVER["PHP_SELF"].'?mod=whm&mode=suspend&cp_username='.$row['dom_user_name_cp'],$_LANG['_WHM']['suspend'],'').$_sp;
  }
  IF ((
$suspended==1) || ($suspended==3)) {
   
$_ret .= do_nav_link ($_SERVER["PHP_SELF"].'?mod=whm&mode=unsuspend&cp_username='.$row['dom_user_name_cp'],$_LANG['_WHM']['unsuspend'],'').$_sp;
  }
 }
 return 
$_ret;
}
function 
do_build_acct_ary(){
 global 
$_CCFG$db_coin;
 
$rak do_get_remote_access_key();
 include_once (
$_CCFG['WHM_ACCOUNT_FILE']);
 
$accts listaccts($_CCFG['DOM_DEFAULT_IP'], $_CCFG['WHM_USER'], $rak0);
 foreach(
$accts as $user => $account){
  if (
$accts[$user][2] != $_CCFG['WHM_USER']){
   unset(
$accts[$user]);
   continue;
  }
  if (
$_CCFG['WHM_CHECK_SUSPEND']){
   
$accts[$user][3] = do_check_suspended($user);
  } else{
   
$accts[$user][3] = 3;
  }
 }
 IF (
$_CCFG['WHM_DEBUG_ON']) { print_r($accts); }
 return 
$accts;
}
function 
do_acct_exists_in_whm($accts$domain){
 foreach(
$accts as $user => $account)
 IF(
$account[0] == $domain) { return 1; }
 return 
0;
}
function 
do_del_from_array($accts$domain){
 foreach(
$accts as $user => $account)
 IF(
$account[0] == $domain) { unset($accts[$user]); }
 return 
$accts;
}
function 
do_check_suspended($cp_username){
 global 
$_DBCFG,$_CCFG$db_coin;
 
# Set Query For Select
 
$query .= "SELECT dom_path";
 
$query .= " FROM ".$_DBCFG['domains'];
 
$query .= " WHERE dom_user_name_cp = '" $cp_username ."'";
 
# Do Select
 
$result  $db_coin->db_query_execute($query);
 
$numrows $db_coin->db_query_numrows($result);
 
$dom  $db_coin->db_fetch_array($result);
 IF (
$numrows == 0) {
  
$domain_path str_replace('%username%',$cp_username,$_CCFG['WHM_DEFAULT_DOM_PATH']).'.htaccess';
 } ELSE {
  
$domain_path $dom['dom_path'].'/.htaccess';
 }
 
$handle = @fopen($domain_path"r");
 if (!
$handle) { return 3; }
 
$contents '';
 if(
$handle){
  while (!
feof($handle)) {
   
$contents .= fread($handle8192);
  }
  
fclose($handle);
 }
 if (
strpos($contents,'suspended.page')===false){
  return 
0;
 } else {
  return 
1;
 }
}
function 
do_match_products_form($adata$aret_flag=0){
 
# Dim Some Vars
 
global $_CCFG$_TCFG$_DBCFG$db_coin$_UVAR$_LANG$_SERVER$_SEC$_nl$_sp;
 
$query "SELECT prod_id, prod_name, prod_cpanel_package FROM ".$_DBCFG['products'];
 
$result $db_coin->db_query_execute($query);
 
# Some HTML Strings (Reduce Text)
 
$_td_str_span '<td class="TP3SML_BC" colspan="2">';
 
$_td_str_left '<td class="TP3SML_NR" width="30%">';
 
$_td_str_right '<td class="TP3SML_NL" width="70%">';
 
# Build Title String, Content String, and Footer Menu String
 
$_cstr .= '<center>'.$_LANG['_WHM']['match_text'].'</center><br>';
 
$_cstr .= '<table width="100%" border="0" cellspacing="0" cellpadding="5">'.$_nl;
 
$_cstr .= '<tr><td align="center">'.$_nl;
 
$_cstr .= '<form action="mod.php?mod=whm&mode=match_prods&step=2" method="post" name="whm">'.$_nl;
 
$_cstr .= '<table width="100%" cellspacing="0" cellpadding="1">'.$_nl;
 while (
$row $db_coin->db_fetch_array($result)){
  
$_cstr .= '<tr>'.$_nl;
  
$_cstr .= $_td_str_left.$_nl;
  
$_cstr .= '<b>'.$row['prod_name'].$_sp.':</b>'.$_nl;
  
$_cstr .= '</td>'.$_nl;
  
$_cstr .= $_td_str_right.$_nl;
  
$_cstr .= build_package_select("Prod".$row[prod_id],$row['prod_cpanel_package'],"No Package");
  
$_cstr .= '</td></tr>'.$_nl;
 }
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 
$_cstr .= '</td></tr>'.$_nl;
 
$_cstr .= '<tr>'.$_nl;
 
$_cstr .= $_td_str_left.$_nl;
 
$_cstr .= '</td>'.$_nl;
 
$_cstr .= $_td_str_right.$_nl;
 IF(
$adata['resubmit'])
 
$_cstr .= $_LANG['_IPN']['resubmit_warning'].'<br><br>';
 
$_cstr .= do_input_button_class_sw ('b_submit''SUBMIT'$_LANG['_WHM']['b_submit'], 'button_form_h''button_form''1').$_nl;
 
$_cstr .= do_input_button_class_sw ('b_reset''RESET'$_LANG['_WHM']['b_reset'], 'button_form_h''button_form''1');
 
$_cstr .= '</td></tr></table>'.$_nl;
 
$_cstr .= '</form>'.$_nl;
 
$_cstr .= '</td></tr>'.$_nl;
 
$_cstr .= '<tr><td align="right">'.$_nl;
 
$_cstr .= '</td></tr></table>'.$_nl;
 
# Return / Echo Final Output
 
IF ( $aret_flag ) { return $_cstr; } ELSE { echo $_out; }
}
function 
get_package_name($prod_id){
 global 
$_DBCFG$db_coin;
 
$query "SELECT prod_cpanel_package FROM ".$_DBCFG['products']." WHERE prod_id = '$prod_id'";
 
$result $db_coin->db_query_execute($query);
 
$prod $db_coin->db_fetch_array($result);
 return 
$prod['prod_cpanel_package'];
}
function 
build_package_select($sel_name$sel_selected=null$top_show=null){
 global 
$_CCFG$packages$db_coin;
 
# Get Packages
 
if (isset($packages) === false ) {
  include_once (
$_CCFG['WHM_ACCOUNT_FILE']);
  
$packages listpkgs($_CCFG['DOM_DEFAULT_IP'], $_CCFG['WHM_USER'], do_get_remote_access_key(), 0);
 }
 IF (
$_CCFG['WHM_DEBUG_ON']) { print_r($packages); }
 
# Build Select Code
 
$sel "<SELECT NAME=\"$sel_name\" class=\"select_form\">".$_nl;
 if (
$top_show != null){
  
$sel .= "<OPTION VALUE=''>$top_show</OPTION>";
 }
 foreach(
$packages as $key => $value){
  
$sel .= '<OPTION'.($key == $sel_selected " SELECTED" "").'>'.$key.'</OPTION>'.$_nl;
 }
 
$sel .= '</SELECT>'.$_nl;
 return 
$sel;
}
/**************************************************************
* End Module Admin Functions
**************************************************************/
?>
TP for all help
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE

Last edited by dansgalaxy; 04-24-2008 at 01:07 PM..
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 04-24-2008, 05:39 PM Re: Modify/make WHM account creater..
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
basically thats just the presentation side as i can see ...
for example function do_whm_create_acct ($adata, $aret_flag=0, $from_api=0)
this is just for presentation the actual function creating the account is
createacct($_CCFG['DOM_DEFAULT_IP'],$_CCFG['WHM_USER'],$rak,0,$adata['domain'],$adata['username'],$adata['password'],$adata['plan']);
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-24-2008, 05:48 PM Re: Modify/make WHM account creater..
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
At a quick glance, it looks like everything you need is in the do_whm_create_acct() function. Since your script is working from the API, it would be called something like

PHP Code:
$success do_whm_create_acct (
      array(
         
$username,$password,$domain,$plan,$phpcoin_domain_id
      
), 
      
true
      
true); 
$username, $password, and $domain seem obvious enough. $plan, and $phpcoin_domain_id I wouldn't be familiar with.

On success, the function should return 1. On failure though, since the function looks like it was designed to display error message in HTML, you'd have to set $from_api to false then parse the return value ($success in this case).

Hope that helps. I'm not familiar with cpanel or phpcoin
__________________
Chris Duerr
AddonChat Java Chat Software

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 05:50 PM Re: Modify/make WHM account creater..
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
that is just the function that creates the account ... also there are the function to cancel an account .... suspend one etc
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-24-2008, 05:50 PM Re: Modify/make WHM account creater..
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
solomongaby is right -- it's just a wrapper to pretty up output for the createacct() function. If you go that route, just make sure to do all the error checking that the wrapper appears to be doing (check for blank username, domain, password, etc.. and analyze results)
__________________
Chris Duerr
AddonChat Java Chat Software

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 06:39 PM Re: Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Okay so i feel a bit stupid now >< i properly looked at the accounting.php.inc file and its pretty easy.

So i made my own class (which at the moment only has create)

so i can execute: echo $whm->create_account('test.xdnet.co.uk','user','passwor d','dan_HOST');

and it makes the account.

BUT i have come accross a couple of issues.

1) i have all my packages called things like dan_XDhost - Basic and when it executes it it just reads dan_XDhost and returns failed... WHY?! why cant it read spaces >< it allows it when you create the packages

2) it does seem to have a option to add uses email to the account so it has it blank(unknown) how can i add that? (it doesnt have it in accounting.php.inc as far as i can tell so im a bit confused

Thanks for repling!

Da
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-25-2008, 02:48 AM Re: Modify/make WHM account creater..
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
1. from what i know ... you are sending the create comand by a curl request ... so maybe you need to url_encode that request ... but i recomend using names without spaces .. so there is no future trouble

2. where did you saw that option ?
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-25-2008, 04:30 AM Re: Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
I will have to add url encode to it to see if it works (i cant be botherd to re make all the packages at the moment)

When you create a account through WHM not only do you enter user/pass/domain you also enter their Email which is then associated with the account.
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-25-2008, 04:32 AM Re: Modify/make WHM account creater..
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
can you post the creation account code here ... so i can see how you might be able to add the email
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-25-2008, 04:42 AM Re: Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Do you mean the cpanel file? (Accounting.php.inc)

i cant get it at moment as at school, but i will google to see if i can find it online
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-25-2008, 12:09 PM Re: Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Okay im at home now.

tested the URL encode and it works! so thats one thing sorted.

the Accounting.php.inc file is:

PHP Code:
<?php
# cpanel4 - Accounting.php.inc              Copyright(c) 1999-2002 John N. Koston
#                                 All rights Reserved.
# nick@cpanel.net              http://cpanel.net         

# This file is governed by the cPanel license

global $cpanelaccterr;

function 
suspend ($host,$user,$accesshash,$usessl,$suspenduser) {
 
$result whmreq("/scripts/remote_suspend?user=${suspenduser}",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }
 return 
$result;
}
function 
unsuspend ($host,$user,$accesshash,$usessl,$suspenduser) {
 
$result whmreq("/scripts/remote_unsuspend?user=${suspenduser}",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }
 return 
$result;
}
function 
killacct ($host,$user,$accesshash,$usessl,$killuser) {
 
$result whmreq("/scripts/killacct?user=${killuser}&nohtml=1",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }
 return 
$result;
}
function 
showversion ($host,$user,$accesshash,$usessl) {
 
$result whmreq("/scripts2/showversion",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }
 return 
$result;
}
function 
createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan) {
 
$result whmreq("/scripts/wwwacct?remote=1&nohtml=1&username=${acctuser}&password=${acctpass}&domain=${acctdomain}&plan=${acctplan}",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }
 return 
$result;
}
function 
listaccts ($host,$user,$accesshash,$usessl) {
 
$result whmreq("/scripts2/listaccts?nohtml=1&viewall=1",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }
        
$page split("\n",$result);
 foreach (
$page as $line) {
  list(
$acct,$contents) = split("="$line);
  if (
$acct != "") {
   
$allc split(","$contents);
   
$accts[$acct] = $allc;
  }
        }
        return(
$accts);
}
function 
listpkgs ($host,$user,$accesshash,$usessl) {
 
$result whmreq("/scripts/remote_listpkg",$host,$user,$accesshash,$usessl);
 if (
$cpanelaccterr != "") { return; }

        
$page split("\n",$result);
 foreach (
$page as $line) {
  list(
$pkg,$contents) = split("="$line);
  if (
$pkg != "") {
   
$allc split(","$contents);
   
$pkgs[$pkg] = $allc;
  }
        }
        return(
$pkgs);
}
function 
whmreq ($request,$host,$user,$accesshash,$usessl) {

 
$cleanaccesshash preg_replace("'(\r|\n)'","",$accesshash);
        
$authstr $user ":" $cleanaccesshash;
 
$cpanelaccterr "";

 if (
function_exists("curl_init")) {
  
$ch curl_init();
  if (
$usessl) {
   
curl_setopt($chCURLOPT_SSL_VERIFYPEER,0);                
   
curl_setopt($chCURLOPT_SSL_VERIFYHOST,0);
   
curl_setopt($chCURLOPT_URL"https://${host}:2087" $request);
  } else {
   
curl_setopt($chCURLOPT_URL"http://${host}:2086" $request);
                }
  
curl_setopt($chCURLOPT_HEADER0);
  
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
         
$curlheaders[0] = "Authorization: WHM $authstr";
                
curl_setopt($ch,CURLOPT_HTTPHEADER,$curlheaders);
  
$data=curl_exec ($ch);
  
curl_close ($ch);
 } elseif (
function_exists("socket_create")) {
  if (
$usessl) {
   
$cpanelaccterr "SSL Support requires curl";
   return;
  }
  
$service_port 2086;
  
$address gethostbyname($host);
  
$socket socket_create (AF_INETSOCK_STREAM0);
  if (
$socket 0) {
          
$cpanelaccterr "socket_create() failed";
   return;
  }
  
$result socket_connect ($socket$address$service_port);
  if (
$result 0) {
          
$cpanelaccterr "socket_connect() failed";
   return;
  }
  
$in "GET $request HTTP/1.0\n";
  
socket_write($socket,$in,strlen($in)); 
  
$in "Connection: close\n";
  
socket_write($socket,$in,strlen($in)); 
  
$in "Authorization: WHM $authstr\n\n\n";
  
socket_write($socket,$in,strlen($in)); 
 
  
$inheader 1;
  while((
$buf socket_read($socket512)) != false) {
    if (!
$inheader) {
     
$data .= $buf;
           }
    if(
preg_match("'\r\n\r\n$'s"$buf)) {
   
$inheader 0;
    }
    if(
preg_match("'\n\n$'s"$buf)) {
   
$inheader 0;
    }
    if(
preg_match("'\r\n$'s"$buf)) {
   
$inheader 0;
    }
  }
 } else {
  
$cpanelaccterr "php not compiled with --enable-sockets OR curl";
  return;
 }
 return 
$data
}
?>
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-26-2008, 08:28 AM Re: Modify/make WHM account creater..
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
try to add to the user creation function a new parameter ... try email or e-mail or other you might think of .. and see if they have any effect
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-26-2008, 02:09 PM Re: Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Basically GUESS lol ! i will have to look it up on cPanel support or something.
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 07-19-2008, 01:23 PM Re: Modify/make WHM account creater..
azcappy's Avatar
Junior Talker

Posts: 2
Name: Keith D. Holler
Location: Glendale, AZ, USA
Trades: 0
Did you think I would make it easy to rape my script LOL! I troll the net everyday tracking my "stuff".

Don't panic... I'm not angry...

Last edited by azcappy; 07-19-2008 at 04:19 PM..
azcappy is offline
Reply With Quote
View Public Profile Visit azcappy's homepage!
 
Old 07-19-2008, 01:40 PM Re: Modify/make WHM account creater..
azcappy's Avatar
Junior Talker

Posts: 2
Name: Keith D. Holler
Location: Glendale, AZ, USA
Trades: 0
Quote:
Originally Posted by dansgalaxy View Post
1) i have all my packages called things like dan_XDhost - Basic and when it executes it it just reads dan_XDhost and returns failed... WHY?! why cant it read spaces >< it allows it when you create the packages
The reason you can't have spaces is because cPanel doesn't like them. For some reason when the package name variable is passed to WHM on the server, it strips the 1st space and everything after it out. I've been pulling my hair out for months trying to figure that one out. Using my module the account was then created with everything unlimited. Use _ instead of spaces on all of the package names and you will be ok.

Just like you can't use ANY non-alpha numeric character in usernames. If you send the server b00g_us} as a username... it creates the account using b00gus. No error return... it just changes it and creates the account. Then like in phpCOIN you have the usernames not matching between the two. Make sure you trap that when your signup routine collects the account info from the new customer.

There are lots of quirks when interfacing externally with WHM that are not immediately visible.

In my code... it pulls all info for creating the account and connecting to the server from phpCOIN. It collects and stores no data on its own.

Last edited by azcappy; 07-19-2008 at 06:11 PM..
azcappy is offline
Reply With Quote
View Public Profile Visit azcappy's homepage!
 
Old 07-20-2008, 05:24 PM Re: Modify/make WHM account creater..
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
wow this is from a while ago lol, im using WHMCS now...


I found a way to get it to use spaces, it is just the package name needs to be URLencoded before being sent to the server...

Thanks for the info though.

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Modify/make WHM account creater..
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65155 seconds with 12 queries