├── CHANGELOG.md ├── README.md └── myownfreehost ├── hooks.php ├── index.php └── myownfreehost.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.2] - 09-10-2021 4 | 5 | ### Added 6 | 7 | - cPanel Login Menu. 8 | 9 | ### Removed 10 | 11 | - Removal of the services management page using the module folders and replacement by the cPanel page of the default WHMCS module. 12 | 13 | ## [1.1] - 17-05-2021 14 | 15 | ### Fixed 16 | 17 | - Fixed bugs. 18 | 19 | ## [1.0] - 05-01-2021 20 | 21 | ### Added 22 | 23 | - Move the cancel button and add buttons in the sidebar. 24 | - Add the cpanel template on the service form. 25 | 26 | ## [0.9] - 05-01-2021 27 | 28 | ### Added 29 | 30 | - Possibility to choose the language of the cpanel when logging in via the options of an offer. 31 | - It is now possible to change the offer only with an existing plan on the reseller panel. 32 | 33 | ### Fixed 34 | 35 | - Fixed a bug on the service suspension and termination process. 36 | 37 | 38 | ## [0.8] - 02-01-2021 39 | 40 | - Initial Release. 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MyOwnFreeHost server module 2 | Unofficial MyOwnFreeHost server module for WHMCS 3 | 4 | # Installation 5 | 1/ Unzip the folder. 6 | 7 | 2/ Copy the myownfreehost folder to /modules/server. 8 | 9 | 3/ Go to server settings and create a new server: 10 | 11 | In module: MyOwnFreeHost, In Hostname: panel.myownfreehost.net, 12 | 13 | In Username: Your User API, 14 | 15 | In Password: Your API password click on test the connection if all went well click on save if not check the error message. 16 | 17 | 4/ Create a server group and add the server you created. 18 | 19 | 5/ Go to product/service settings and creates a product: 20 | 21 | In the module parameters select the MyOwnFreeHost module and select the server group previously created. Leave the boxes empty and fill in according to what you want. Don't forget to put your reseller domain in Cpanel Login Domain !!! Save. 22 | 23 | 6/ End. 24 | -------------------------------------------------------------------------------- /myownfreehost/hooks.php: -------------------------------------------------------------------------------- 1 | getChild("Service Details Actions")) { 6 | return NULL; 7 | } 8 | $service = Menu::context("service"); 9 | if ($service instanceof WHMCS\Service\Service && $service->product->module != "myownfreehost") { 10 | return NULL; 11 | } 12 | $ssoPermission = checkContactPermission("productsso", true); 13 | $username = $service->username; 14 | $command = 'DecryptPassword'; 15 | $postData = array('password2' => $service->password); 16 | $results = localAPI($command, $postData); 17 | $password = $results['password']; 18 | $result = Capsule::select(Capsule::raw('SELECT configoption10,configoption11 FROM tblproducts WHERE id = '.$service->product->id.''))[0]; 19 | $cpanelurl = $result->configoption10; 20 | $lang = $result->configoption11; 21 | $bodyhtml = ' 22 |
23 | 24 | 25 | 26 | 27 |
'; 28 | $sidebar->getChild("Service Details Actions")->addChild("Login to Webmail", array("uri" => "http://185.27.134.244/roundcubemail/", "label" => Lang::trans("cpanelwebmaillogin"), "attributes" => array("target" => "_blank"), "disabled" => $service->status != "Active", "order" => 3)); 29 | $sidebar->getChild("Service Details Actions")->addChild("Request Cancellation", array("uri" => "clientarea.php?action=cancel&id=" . $service->id, "label" => Lang::trans("cancellationrequested"), "disabled" => $service->status != "Active", "order" => 4)); 30 | $sidebar->addChild('cPanel Login', array('label' => 'cPanel Logins', 'icon' => 'fa-server','order' => 20,'footerHtml' => $bodyhtml,)); 31 | } 32 | ?> -------------------------------------------------------------------------------- /myownfreehost/index.php: -------------------------------------------------------------------------------- 1 | getMessage(), $err->getTraceAsString()); 50 | } 51 | 52 | function Myownfreehost_MetaData() 53 | { 54 | return array( "DisplayName" => "MyOwnFreeHost", "APIVersion" => "1.0", "DefaultNonSSLPort" => "2086", "DefaultSSLPort" => "2087", "ServiceSingleSignOnLabel" => "Login to cPanel", "AdminSingleSignOnLabel" => "Login to MOFH" ); 55 | } 56 | 57 | 58 | function Myownfreehost_ConfigOptions() { 59 | return [ 60 | "WHM_Package_Name" => [ 61 | "FriendlyName" => "WHM Package Name", 62 | "Type" => "text", 63 | "Size" => 25, 64 | ], 65 | "Web_Space_Quota" => [ 66 | "FriendlyName" => "Web Space Quota", 67 | "Description" => "MB", 68 | "Type" => "text", 69 | "Size" => 10, 70 | ], 71 | "Bandwidth_Limit" => [ 72 | "FriendlyName" => "Bandwidth Limit", 73 | "Description" => "MB", 74 | "Type" => "text", 75 | "Size" => 10, 76 | ], 77 | "Max_FTP_Accounts" => [ 78 | "FriendlyName" => "Max FTP Accounts", 79 | "Type" => "text", 80 | "Size" => 10, 81 | "Default" => "1", 82 | ], 83 | "Max_Email_Accounts" => [ 84 | "FriendlyName" => "Max Email Accounts", 85 | "Type" => "text", 86 | "Size" => 10, 87 | "Default" => "None", 88 | ], 89 | "Max_SQL_Databases" => [ 90 | "FriendlyName" => "Max SQL Databases", 91 | "Type" => "text", 92 | "Size" => 10, 93 | ], 94 | "Max_Subdomains" => [ 95 | "FriendlyName" => "Max Subdomains", 96 | "Type" => "text", 97 | "Size" => 10, 98 | ], 99 | "Max_Parked_Domains" => [ 100 | "FriendlyName" => "Max Parked Domains", 101 | "Type" => "text", 102 | "Size" => 10, 103 | ], 104 | "Max_Addon_Domains" => [ 105 | "FriendlyName" => "Max Addon Domains", 106 | "Type" => "text", 107 | "Size" => 10, 108 | ], 109 | "Cpanel" => [ 110 | "FriendlyName" => "Cpanel Login Domain", 111 | "Description" => "Use for connection to the cpanel", 112 | "Type" => "text", 113 | "Size" => 10, 114 | ], 115 | "Lang" => [ 116 | "FriendlyName" => "Cpanel Language", 117 | "Description" => "Use to set the language that cpanel should display if the value is empty the English language will be used", 118 | "Type" => "text", 119 | "Size" => 10, 120 | ], 121 | ]; 122 | } 123 | 124 | 125 | function Myownfreehost_TestConnection(array $params) { 126 | $err = ""; 127 | try { 128 | $response = Myownfreehost_API($params, '/json-api/listpkgs'); 129 | 130 | if($response['package']['0']['FRONTPAGE'] !== 'n') { 131 | $status_code = $response['cpanelresult']['error']; 132 | $err = "" . $status_code . ""; 133 | } 134 | 135 | } catch(Exception $e) { 136 | Myownfreehost_Error(__FUNCTION__, $params, $e); 137 | $err = $e->getMessage(); 138 | } 139 | 140 | return [ 141 | "success" => $err === "", 142 | "error" => $err, 143 | ]; 144 | } 145 | 146 | function Myownfreehost_GetOption(array $params, $id, $default = NULL) { 147 | $options = Myownfreehost_ConfigOptions(); 148 | 149 | $friendlyName = $options[$id]['FriendlyName']; 150 | if(isset($params['configoptions'][$friendlyName]) && $params['configoptions'][$friendlyName] !== '') { 151 | return $params['configoptions'][$friendlyName]; 152 | } else if(isset($params['configoptions'][$id]) && $params['configoptions'][$id] !== '') { 153 | return $params['configoptions'][$id]; 154 | } else if(isset($params['customfields'][$friendlyName]) && $params['customfields'][$friendlyName] !== '') { 155 | return $params['customfields'][$friendlyName]; 156 | } else if(isset($params['customfields'][$id]) && $params['customfields'][$id] !== '') { 157 | return $params['customfields'][$id]; 158 | } 159 | 160 | $found = false; 161 | $i = 0; 162 | foreach(Myownfreehost_ConfigOptions() as $key => $value) { 163 | $i++; 164 | if($key === $id) { 165 | $found = true; 166 | break; 167 | } 168 | } 169 | 170 | if($found && isset($params['configoption' . $i]) && $params['configoption' . $i] !== '') { 171 | return $params['configoption' . $i]; 172 | } 173 | 174 | return $default; 175 | } 176 | 177 | function Myownfreehost_CreateAccount(array $params) { 178 | try { 179 | 180 | $package = Myownfreehost_GetOption($params, 'WHM_Package_Name'); 181 | $space = Myownfreehost_GetOption($params, 'Web_Space_Quota'); 182 | $banwidth = Myownfreehost_GetOption($params, 'Bandwidth_Limit'); 183 | $ftp = Myownfreehost_GetOption($params, 'Max_FTP_Accounts'); 184 | $email = Myownfreehost_GetOption($params, 'Max_Email_Accounts'); 185 | $sql = Myownfreehost_GetOption($params, 'Max_SQL_Databases'); 186 | $subdomains = Myownfreehost_GetOption($params, 'Max_Subdomains'); 187 | $parked = Myownfreehost_GetOption($params, 'Max_Parked_Domains'); 188 | $addons = Myownfreehost_GetOption($params, 'Max_Addon_Domains'); 189 | 190 | 191 | $postfields = array( ); 192 | $postfields["username"] = $params["username"]; 193 | $postfields["password"] = $params["password"]; 194 | $postfields["domain"] = $params["domain"]; 195 | $postfields["savepkg"] = 0; 196 | $postfields["quota"] = $space; 197 | $postfields["bwlimit"] = $banwidth; 198 | $postfields["contactemail"] = $params['clientsdetails']['email']; 199 | $postfields["maxftp"] = $ftp; 200 | $postfields["maxsql"] = $sql; 201 | $postfields["maxpop"] = $email; 202 | $postfields["maxsub"] = $subdomains; 203 | $postfields["parked"] = $maxpark; 204 | $postfields["maxaddon"] = $addons; 205 | $postfields["plan"] = $package; 206 | $postfields["api.version"] = 1; 207 | $postfields["reseller"] = 0; 208 | $output = Myownfreehost_API($params, "/xml-api/createacct", $postfields); 209 | 210 | if($output["result"]["status"] !== "1" ) 211 | { 212 | $error = $output["result"]["statusmsg"]; 213 | throw new Exception(''.$error.''); 214 | } 215 | 216 | } catch(Exception $err) { 217 | return $err->getMessage(); 218 | } 219 | 220 | return 'success'; 221 | } 222 | 223 | 224 | function Myownfreehost_SuspendAccount(array $params) { 225 | try { 226 | 227 | $output = Myownfreehost_API($params, "/xml-api/suspendacct?api.version=1&user=" . urlencode($params['username']) . "&reason=" . urlencode($params['suspendreason'])); 228 | 229 | if($output == "") throw new Exception('The reason for cancellation is incorrect only these reasons are valid: PHISHING, VIRUS_MALWARE_HOSTING, NULLED_SCRIPT, CONTENT_VIOLATION, ABUSE_COMPLAINT, SPAM_DOMAIN_SIGNUP, REQUESTED and OTHER.'); 230 | 231 | if($output["result"]["status"] !== "1" ) 232 | { 233 | $error = $output["result"]["statusmsg"]; 234 | throw new Exception(''.$error.''); 235 | } 236 | } catch(Exception $err) { 237 | return $err->getMessage(); 238 | } 239 | return 'success'; 240 | } 241 | 242 | function Myownfreehost_UnsuspendAccount(array $params) { 243 | try { 244 | 245 | $output = Myownfreehost_API($params, "/xml-api/unsuspendacct?api.version=1&user=" . urlencode($params['username']) . "&keepdns=0"); 246 | 247 | 248 | if($output["result"]["status"] !== "1" ) 249 | { 250 | $error = $output["result"]["statusmsg"]; 251 | throw new Exception(''.$error.''); 252 | } 253 | } catch(Exception $err) { 254 | return $err->getMessage(); 255 | } 256 | return 'success'; 257 | } 258 | 259 | function Myownfreehost_TerminateAccount(array $params) { 260 | try { 261 | 262 | $output = Myownfreehost_API($params, "/xml-api/removeacct?user=" . $params["username"]); 263 | 264 | if($output["result"]["status"] !== "1" ) 265 | { 266 | $error = $output["result"]["statusmsg"]; 267 | throw new Exception(''.$error.''); 268 | } 269 | 270 | } catch(Exception $err) { 271 | return $err->getMessage(); 272 | } 273 | 274 | return 'success'; 275 | } 276 | 277 | function Myownfreehost_ChangePassword(array $params) { 278 | try { 279 | 280 | $output = Myownfreehost_API($params, "/json-api/passwd?user=" . $params["username"] . "&pass=" . urlencode($params["password"])); 281 | 282 | 283 | if($output["passwd"]["0"]["status"] !== "1") 284 | { 285 | $error = $output["passwd"]["0"]["statusmsg"]; 286 | throw new Exception(''.$error.''); 287 | } 288 | 289 | } catch(Exception $err) { 290 | return $err->getMessage(); 291 | } 292 | 293 | return 'success'; 294 | } 295 | 296 | function Myownfreehost_ChangePackage(array $params) { 297 | try { 298 | 299 | $package = Myownfreehost_GetOption($params, 'WHM_Package_Name'); 300 | $output = Myownfreehost_API($params, "/xml-api/changepackage?user=" . $params["username"] . "&pkg=" . urlencode($package)); 301 | 302 | if($output["result"]["status"] !== "1" ) 303 | { 304 | $error = $output["result"]["statusmsg"]; 305 | throw new Exception(''.$error.''); 306 | } 307 | 308 | } catch(Exception $err) { 309 | return $err->getMessage(); 310 | } 311 | 312 | return 'success'; 313 | } 314 | function Myownfreehost_SingleSignOn($params) 315 | { 316 | $cpanel = Myownfreehost_GetOption($params, 'Cpanel'); 317 | $link = "https://cpanel." . $cpanel; 318 | return array( "success" => true, "redirectTo" => $link); 319 | } 320 | function Myownfreehost_ServiceSingleSignOn($params) 321 | { 322 | return Myownfreehost_SingleSignOn($params); 323 | } 324 | function Myownfreehost_AdminSingleSignOn($params) 325 | { 326 | return array( "success" => true, "redirectTo" => 'https://panel.myownfreehost.net' ); 327 | } 328 | 329 | function Myownfreehost_ClientArea($params) 330 | { 331 | return array( "overrideDisplayTitle" => ucfirst($params["domain"]), "tabOverviewReplacementTemplate" => "../cpanel/templates/overview.tpl", 'vars' => [ 'cpanelurl' => $cpanel, 'lang' => $country,]); 332 | } --------------------------------------------------------------------------------