Skip to content

Commit 1fb821a

Browse files
committed
initial commit
0 parents  commit 1fb821a

4 files changed

Lines changed: 149 additions & 0 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# MyAdmin Cpanel Webhosting Plugin
2+
3+
This plugin adds support for selling Cpanel licenses to the MyAdmin system
4+
5+
[![Latest Stable Version](https://poser.pugx.org/detain/myadmin-cpanel-webhosting/version)](https://packagist.org/packages/detain/myadmin-cpanel-webhosting)
6+
[![Total Downloads](https://poser.pugx.org/detain/myadmin-cpanel-webhosting/downloads)](https://packagist.org/packages/detain/myadmin-cpanel-webhosting)
7+
[![Latest Unstable Version](https://poser.pugx.org/detain/myadmin-cpanel-webhosting/v/unstable)](//packagist.org/packages/detain/myadmin-cpanel-webhosting)
8+
[![License](https://poser.pugx.org/detain/myadmin-cpanel-webhosting/license)](https://packagist.org/packages/detain/myadmin-cpanel-webhosting)
9+
[![Monthly Downloads](https://poser.pugx.org/detain/myadmin-cpanel-webhosting/d/monthly)](https://packagist.org/packages/detain/myadmin-cpanel-webhosting)
10+
[![Daily Downloads](https://poser.pugx.org/detain/myadmin-cpanel-webhosting/d/daily)](https://packagist.org/packages/detain/myadmin-cpanel-webhosting)
11+
[![Reference Status](https://www.versioneye.com/php/detain:myadmin-cpanel-webhosting/reference_badge.svg?style=flat)](https://www.versioneye.com/php/detain:myadmin-cpanel-webhosting/references)
12+
[![Build Status](https://travis-ci.org/detain/myadmin-cpanel-webhosting.svg?branch=master)](https://travis-ci.org/detain/myadmin-cpanel-webhosting)
13+
[![Code Climate](https://codeclimate.com/github/detain/myadmin-cpanel-webhosting/badges/gpa.svg)](https://codeclimate.com/github/detain/myadmin-cpanel-webhosting)
14+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/detain/myadmin-cpanel-webhosting/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/detain/myadmin-cpanel-webhosting/?branch=master)
15+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/dcfdb555bf234afabceb40728959280b)](https://www.codacy.com/app/detain/myadmin-cpanel-webhosting)

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "detain/myadmin-cpanel-webhosting",
3+
"type": "myadmin-plugin",
4+
"description": "Cpanel Webhosting Class",
5+
"keywords": ["cpanel","administration","license"],
6+
"license": "LGPL-2.1",
7+
"authors": [
8+
{
9+
"name": "Joe Huss",
10+
"homepage": "https://my.interserver.net/"
11+
}
12+
],
13+
"repositories": [
14+
{
15+
"type": "git",
16+
"url": "https://github.com/detain/myadmin-plugin-installer"
17+
}
18+
],
19+
"require": {
20+
"php": ">=5.0.0",
21+
"ext-soap": "*",
22+
"symfony/event-dispatcher": "*",
23+
"detain/myadmin-plugin-installer": "dev-master",
24+
"detain/cpanel-webhosting": "*"
25+
},
26+
"autoload": {
27+
"psr-4": {"Detain\\MyAdminCpanel\\": "src/"}
28+
}
29+
}

myadmin.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/* TODO:
3+
- service type, category, and services adding
4+
- dealing with the SERVICE_TYPES_cpanel define
5+
- add way to call/hook into install/uninstall
6+
*/
7+
return [
8+
'name' => 'Cpanel Webhosting',
9+
'description' => 'Allows selling of Cpanel Server and VPS License Types. More info at https://www.netenberg.com/cpanel.php',
10+
'help' => 'It provides more than one million end users the ability to quickly install dozens of the leading open source content management systems into their web space. Must have a pre-existing cPanel license with cPanelDirect to purchase a cpanel license. Allow 10 minutes for activation.',
11+
'module' => 'licenses',
12+
'author' => 'detain@interserver.net',
13+
'home' => 'https://github.com/detain/myadmin-cpanel-webhosting',
14+
'repo' => 'https://github.com/detain/myadmin-cpanel-webhosting',
15+
'version' => '1.0.0',
16+
'type' => 'licenses',
17+
'hooks' => [
18+
'function.requirements' => ['Detain\MyAdminCpanel\Plugin', 'Requirements'],
19+
'licenses.settings' => ['Detain\MyAdminCpanel\Plugin', 'Settings'],
20+
'licenses.activate' => ['Detain\MyAdminCpanel\Plugin', 'Activate'],
21+
'licenses.change_ip' => ['Detain\MyAdminCpanel\Plugin', 'ChangeIp'],
22+
'ui.menu' => ['Detain\MyAdminCpanel\Plugin', 'Menu']
23+
],
24+
];

src/Plugin.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
namespace Detain\MyAdminCpanel;
4+
5+
use Detain\Cpanel\Cpanel;
6+
use Symfony\Component\EventDispatcher\GenericEvent;
7+
8+
class Plugin {
9+
10+
public function __construct() {
11+
}
12+
13+
public static function Activate(GenericEvent $event) {
14+
// will be executed when the licenses.license event is dispatched
15+
$license = $event->getSubject();
16+
if ($event['category'] == SERVICE_TYPES_FANTASTICO) {
17+
myadmin_log('licenses', 'info', 'Cpanel Activation', __LINE__, __FILE__);
18+
function_requirements('activate_cpanel');
19+
activate_cpanel($license->get_ip(), $event['field1']);
20+
$event->stopPropagation();
21+
}
22+
}
23+
24+
public static function ChangeIp(GenericEvent $event) {
25+
if ($event['category'] == SERVICE_TYPES_FANTASTICO) {
26+
$license = $event->getSubject();
27+
$settings = get_module_settings('licenses');
28+
$cpanel = new Cpanel(FANTASTICO_USERNAME, FANTASTICO_PASSWORD);
29+
myadmin_log('licenses', 'info', "IP Change - (OLD:".$license->get_ip().") (NEW:{$event['newip']})", __LINE__, __FILE__);
30+
$result = $cpanel->editIp($license->get_ip(), $event['newip']);
31+
if (isset($result['faultcode'])) {
32+
myadmin_log('licenses', 'error', 'Cpanel editIp('.$license->get_ip().', '.$event['newip'].') returned Fault '.$result['faultcode'].': '.$result['fault'], __LINE__, __FILE__);
33+
$event['status'] = 'error';
34+
$event['status_text'] = 'Error Code '.$result['faultcode'].': '.$result['fault'];
35+
} else {
36+
$GLOBALS['tf']->history->add($settings['TABLE'], 'change_ip', $event['newip'], $license->get_ip());
37+
$license->set_ip($event['newip'])->save();
38+
$event['status'] = 'ok';
39+
$event['status_text'] = 'The IP Address has been changed.';
40+
}
41+
$event->stopPropagation();
42+
}
43+
}
44+
45+
public static function Menu(GenericEvent $event) {
46+
// will be executed when the licenses.settings event is dispatched
47+
$menu = $event->getSubject();
48+
$module = 'licenses';
49+
if ($GLOBALS['tf']->ima == 'admin') {
50+
$menu->add_link($module, 'choice=none.reusable_cpanel', 'icons/database_warning_48.png', 'ReUsable Cpanel Licenses');
51+
$menu->add_link($module, 'choice=none.cpanel_list', 'icons/database_warning_48.png', 'Cpanel Licenses Breakdown');
52+
$menu->add_link($module.'api', 'choice=none.cpanel_licenses_list', 'whm/createacct.gif', 'List all Cpanel Licenses');
53+
}
54+
}
55+
56+
public static function Requirements(GenericEvent $event) {
57+
// will be executed when the licenses.loader event is dispatched
58+
$loader = $event->getSubject();
59+
$loader->add_requirement('crud_cpanel_list', '/../vendor/detain/crud/src/crud/crud_cpanel_list.php');
60+
$loader->add_requirement('crud_reusable_cpanel', '/../vendor/detain/crud/src/crud/crud_reusable_cpanel.php');
61+
$loader->add_requirement('get_cpanel_licenses', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel.inc.php');
62+
$loader->add_requirement('get_cpanel_list', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel.inc.php');
63+
$loader->add_requirement('cpanel_licenses_list', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel_licenses_list.php');
64+
$loader->add_requirement('cpanel_list', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel_list.php');
65+
$loader->add_requirement('get_available_cpanel', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel.inc.php');
66+
$loader->add_requirement('activate_cpanel', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel.inc.php');
67+
$loader->add_requirement('get_reusable_cpanel', '/../vendor/detain/myadmin-cpanel-webhosting/src/cpanel.inc.php');
68+
$loader->add_requirement('reusable_cpanel', '/../vendor/detain/myadmin-cpanel-webhosting/src/reusable_cpanel.php');
69+
$loader->add_requirement('class.Cpanel', '/../vendor/detain/cpanel-webhosting/src/Cpanel.php');
70+
$loader->add_requirement('vps_add_cpanel', '/vps/addons/vps_add_cpanel.php');
71+
}
72+
73+
public static function Settings(GenericEvent $event) {
74+
// will be executed when the licenses.settings event is dispatched
75+
$settings = $event->getSubject();
76+
$settings->add_text_setting('licenses', 'Cpanel', 'cpanel_username', 'Cpanel Username:', 'Cpanel Username', $settings->get_setting('FANTASTICO_USERNAME'));
77+
$settings->add_text_setting('licenses', 'Cpanel', 'cpanel_password', 'Cpanel Password:', 'Cpanel Password', $settings->get_setting('FANTASTICO_PASSWORD'));
78+
$settings->add_dropdown_setting('licenses', 'Cpanel', 'outofstock_licenses_cpanel', 'Out Of Stock Cpanel Licenses', 'Enable/Disable Sales Of This Type', $settings->get_setting('OUTOFSTOCK_LICENSES_FANTASTICO'), array('0', '1'), array('No', 'Yes', ));
79+
}
80+
81+
}

0 commit comments

Comments
 (0)