diff --git a/build.xml b/build.xml index 03a3bf365..9d7395408 100644 --- a/build.xml +++ b/build.xml @@ -46,6 +46,7 @@ + diff --git a/src/.htaccess b/src/.htaccess index 79070e342..768d7512f 100644 --- a/src/.htaccess +++ b/src/.htaccess @@ -37,6 +37,7 @@ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] +RewriteRule ^page/(.*)$ index.php?_url=/custompages/$1 RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] diff --git a/src/bb-library/Server/Account.php b/src/bb-library/Server/Account.php index 24d75487d..ee840b808 100644 --- a/src/bb-library/Server/Account.php +++ b/src/bb-library/Server/Account.php @@ -32,7 +32,7 @@ class Server_Account private $ns_2 = NULL; private $ns_3 = NULL; private $ns_4 = NULL; - private $note = 'Client created via BoxBilling'; + private $note = NULL; public function setUsername($param) { diff --git a/src/bb-library/Server/Manager/MOFH.php b/src/bb-library/Server/Manager/MOFH.php new file mode 100644 index 000000000..080b9db93 --- /dev/null +++ b/src/bb-library/Server/Manager/MOFH.php @@ -0,0 +1,258 @@ +_" (abc_12345678) + // This makes everything weird, the user logs into the control panel with the abc_12345678 username, but we still need to store the other one somewhere + // While making API calls, the username you submit is not the one which user uses during their sign-in process, it's the one *you* generated in the beginning. + // Hence, you need to store it, or hash the domain as we did. + // + // We used the "domainToID()" function to generate a unique hash for every domain, and we can be sure that it won't change unless the domain was changed + // Changing the domain is not supported by MyOwnFreeHost's API, so the domain probably won't be changed afterwards. + + public function init() + { + $this->MOFHclient = Client::create([ + 'apiUsername' => $this->_config['username'], + 'apiPassword' => $this->_config['password'], + ]); + + if (!extension_loaded('curl')) { + throw new Server_Exception('cURL extension is not enabled'); + } + } + + public static function domainToID($domain) + { + // So, here's how this works. + // We first generate a SHA-256 hash with the domain + // And then, strip out the first 8 characters to + // generate a unique ID. + // + // Let's understand it better with an example. + // So, here's the SHA-256 hash of 'boxbilling.com': + // 0d3019bc07e517c2158a2c7eaccdf286fdececa78de7f736f2d1d602522e80c7 + // + // We get the first 8 characters out of that, and it produces: + // 0d3019bc + // + // Since it's a hash, it doesn't matter whether portions are discarded, + // but rather that the same input will produce the same hash. + // + // And the nice part, we don't need to store this in a database. + // As long as it's the same domain, it will always generate the same hash. + + return mb_substr(hash('sha256', $domain), 0, 8); + } + + public static function getForm() + { + return array( + 'label' => 'MyOwnFreeHost', + ); + } + + public function getLoginUrl() + { + if($this->_config['secure']) { + $protocol = 'https'; + } else { + $protocol = 'http'; + } + $host = $this->_config['host']; + return $protocol . '://cpanel.' . $host; + } + + public function getResellerLoginUrl() + { + return 'https://panel.myownfreehost.net/'; + } + + public function testConnection() + { + $request = $this->MOFHclient->availability([ + 'domain' => 'boxbilling.com', + ]); + + $response = $request->send(); + + if ($response->isSuccessful()) { + return true; + } + + return false; + } + + public function synchronizeAccount(Server_Account $a) + { + $this->getLog()->info('Synchronizing account with server '.$a->getUsername()); + $this->client = $a->getClient(); + + $request = $this->MOFHclient->getDomainUser([ + 'domain' => $a->getDomain(), + ]); + + // Let's send the request, and store the response. + $response = $request->send(); + + if ($response->isFound()) { + + if ($response->getStatus() == "ACTIVE") { + $a->setSuspended(false); + } else if ($response->getStatus() == "SUSPENDED") { + $a->setSuspended(true); + }; + + // Setting the username to the one that is being used in the client area. + $a->setUsername($response->getUsername()); + } + + // If something went wrong, we'll catch the error, and display it. + if (!$response->isSuccessful()) { + throw new Server_Exception($response->getMessage()); + } + + return $a; + } + + /** + * Create an account + * + * We'll use the provided Server_Account object to use the data from the order, + * and call the MyOwnFreeHost API to create an account. + * Then, we'll store the returned vPanel username to our local database. + * + * @param Server_Account $a + */ + + public function createAccount(Server_Account $a) { + // Temporarily suspending the account while it's being set up. + $a->setSuspended(true); + + $this->client = $a->getClient(); + + $request = $this->MOFHclient->createAccount([ + 'username' => $this->domainToID($a->getDomain()), + 'password' => $a->getPassword(), + 'domain' => $a->getDomain(), + 'email' => $this->client->getEmail(), + 'plan' => 'boxbilling', + ]); + + // Let's send the request, and store the response. + $response = $request->send(); + + // Setting the username to the one that is being used in the client area. + $a->setUsername($response->getVpUsername()); + + // If something went wrong, we'll catch the error, and display it. + if (!$response->isSuccessful()) { + throw new Server_Exception($response->getMessage()); + } + + // It's all done. We can now unsuspend the account. + $a->setSuspended(false); + + return $a; + } + + public function suspendAccount(Server_Account $a, $suspend = true) { + + $request = $this->MOFHclient->suspend([ + 'username' => $this->domainToID($a->getDomain()), + 'reason' => "Triggered by BoxBilling.", + 'linked' => false + ]); + + $response = $request->send(); + + // If something went wrong, we'll catch the error, and display it. + if (!$response->isSuccessful()) { + throw new Server_Exception('MOFH error: ' . $response->getMessage()); + } + + return true; + } + + public function unsuspendAccount(Server_Account $a) { + + $request = $this->MOFHclient->unsuspend([ + 'username' => $this->domainToID($a->getDomain()) + ]); + + // Let's send the request, and store the response. + $response = $request->send(); + + // If something went wrong, we'll catch the error, and display it. + if (!$response->isSuccessful()) { + throw new Server_Exception('MOFH error: ' . $response->getMessage()); + } + + return true; + } + + public function cancelAccount(Server_Account $a) + { + throw new Server_Exception("Unfortunately, MyOwnFreeHost API does not support account termination. You may log into your reseller panel, and execute the action there."); + } + + public function changeAccountPackage(Server_Account $a, Server_Package $p) + { + throw new Server_Exception("Unfortunately, MyOwnFreeHost API does not support changing account packages. You may log into your reseller panel, and execute the action there."); + } + + public function changeAccountPassword(Server_Account $a, $new) { + $request = $this->MOFHclient->password([ + 'username' => $this->domainToID($a->getDomain()), + 'password' => $new, + ]); + + $response = $request->send(); + + if (!$response->isSuccessful()) { + throw new Server_Exception('MOFH error: ' . $response->getMessage()); + } + + return true; + } + + public function changeAccountUsername(Server_Account $a, $new) + { + throw new Server_Exception('Server manager does not support username changes'); + } + + public function changeAccountDomain(Server_Account $a, $new) + { + throw new Server_Exception('Server manager does not support domain changes'); + } + + public function changeAccountIp(Server_Account $a, $new) + { + throw new Server_Exception('Server manager does not support IP changes'); + } + + private function _getResourcePlan(Server_Package $p) + { + + } + + private function _getDnsTemplate(Server_Package $p) + { + throw new Server_Exception('Server manager does not support DNS templates'); + } +} \ No newline at end of file diff --git a/src/bb-modules/Custompages/Api/Admin.php b/src/bb-modules/Custompages/Api/Admin.php new file mode 100644 index 000000000..7eeeae19b --- /dev/null +++ b/src/bb-modules/Custompages/Api/Admin.php @@ -0,0 +1,141 @@ +di['array_get']($data, 'search', null); + $pager = $this->getService()->searchPages($search); + + foreach ($pager['list'] as $key => $item) { + $pager['list'][$key] = $item; + } + + return $pager; + } + + /** + * Delete custom page + * + * @param int $id - custom page ID + * + * @return bool + */ + public function delete($data) + { + $required = array( + 'id' => 'Custom Page ID not passed', + ); + $this->di['validator']->checkRequiredParamsForArray($required, $data); + + $this->getService()->deletePage($data['id']); + return true; + } + + /** + * Delete custom pages + * + * @param array $ids - custom page IDs + * + * @return bool + */ + public function batch_delete($data) + { + $required = array( + 'ids' => 'Custom Page IDs not passed', + ); + $this->di['validator']->checkRequiredParamsForArray($required, $data); + + $this->getService()->deletePage($data['ids']); + return true; + } + + /** + * Create new custom page + * + * @param string $title - custom page title + * @param string $content - custom page content + * + * @optional string $description - custom page meta description + * @optional string $keywords - custom page meta keywords + * + * @return array + */ + public function create($data) + { + $required = array( + 'title' => 'Custom page title not passed', + 'content' => 'Custom page content not passed', + ); + $this->di['validator']->checkRequiredParamsForArray($required, $data); + + $title = $data['title']; + + $content = $data['content']; + $description = $this->di['array_get']($data, 'description', NULL); + $keywords = $this->di['array_get']($data, 'keywords', NULL); + + return $this->getService()->createPage($title, $description, $keywords, $content); + } + + /** + * Update custom page + * + * @param string $id - custom page id + * @param string $slug - custom page slug + * @param string $content - custom page content + * + * @optional string $description - custom page meta description + * @optional string $keywords - custom page meta keywords + * + * @return array + */ + public function update($data) + { + $required = array( + 'id' => 'Custom page id not passed', + 'title' => 'Custom page title not passed', + 'slug' => 'Custom page slug not passed', + 'content' => 'Custom page content not passed', + ); + $this->di['validator']->checkRequiredParamsForArray($required, $data); + + $id = $data['id']; + $title = $data['title']; + $content = $data['content']; + $slug = $data['slug']; + $description = $this->di['array_get']($data, 'description', NULL); + $keywords = $this->di['array_get']($data, 'keywords', NULL); + + return $this->getService()->updatePage($id, $title, $description, $keywords, $content, $slug); + } + + /** + * Get custom page by id + * + * @param string $id - custom page id + * + * @return array + */ + public function get_page($data) + { + return $this->getService()->getPage($data['page_id']); + } +} \ No newline at end of file diff --git a/src/bb-modules/Custompages/Controller/Admin.php b/src/bb-modules/Custompages/Controller/Admin.php new file mode 100644 index 000000000..365274ea2 --- /dev/null +++ b/src/bb-modules/Custompages/Controller/Admin.php @@ -0,0 +1,67 @@ +di = $di; + } + + /** + * @return mixed + */ + public function getDi() + { + return $this->di; + } + + public function fetchNavigation() + { + return array( + 'subpages'=> array( + array( + 'location' => 'extensions', + 'label' => 'Custom Pages', + 'index' => 2000, + 'uri' => $this->di['url']->adminLink('custompages'), + 'class' => '', + ), + ), + ); + + } + + public function register(\Box_App &$app) + { + $app->get('/custompages', 'get_index', array(), get_class($this)); + $app->get('/custompages/:id', 'get_page', array('id'=>'[0-9]+'), get_class($this)); + } + + public function get_index(\Box_App $app) + { + $this->di['is_admin_logged']; + return $app->render('mod_custompages_index'); + } + + public function get_page(\Box_App $app, $id) + { + return $app->render('mod_custompages_page', array('page_id' => $id)); + } +} \ No newline at end of file diff --git a/src/bb-modules/Custompages/Controller/Client.php b/src/bb-modules/Custompages/Controller/Client.php new file mode 100644 index 000000000..321a10fed --- /dev/null +++ b/src/bb-modules/Custompages/Controller/Client.php @@ -0,0 +1,64 @@ +di = $di; + } + + /** + * @return mixed + */ + public function getDi() + { + return $this->di; + } + + /** + * Methods maps client areas urls to corresponding methods + * Always use your module prefix to avoid conflicts with other modules + * in future + * + * @param \Box_App $app - returned by reference + */ + public function register(\Box_App &$app) + { + $app->get('/custompages/:slug', 'get_page', array('slug' => '[a-z0-9-]+'), get_class($this)); + } + + public function get_page(\Box_App $app, $slug) + { + $service = new \Box\Mod\Custompages\Service(); + $service->setDi($this->di); + $page = $service->getPage($slug, 'slug'); + if(isset($page['id'])) { + return $app->render('mod_custompages_content', array('page' => $page)); + } + else { + die(header('Location: '.$this->di['url']->get(''))); + } + } +} \ No newline at end of file diff --git a/src/bb-modules/Custompages/Service.php b/src/bb-modules/Custompages/Service.php new file mode 100644 index 000000000..d7a295e57 --- /dev/null +++ b/src/bb-modules/Custompages/Service.php @@ -0,0 +1,90 @@ +di = $di; + } + + public function install() + { + $db = $this->di['db']; + $db->exec("CREATE TABLE IF NOT EXISTS `custom_pages` (`id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` varchar(555) NOT NULL, `keywords` varchar(555) NOT NULL, `content` text NOT NULL, `slug` varchar(255) NOT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + return true; + } + + public function searchPages($search = null, $per_page = 100, $page = null) + { + $filter = array(); + $sql = "SELECT * FROM custom_pages WHERE 1"; + if ($search) { + $sql .= " AND title LIKE :q OR content LIKE :q"; + $filter[':q'] = "%$search%"; + } + $sql .= " ORDER BY id DESC"; + return $this->di['pager']->getSimpleResultSet($sql, $filter, $per_page, $page); + } + + public function deletePage($id) { + if(is_array($id)) { + foreach($id as $i => $x) { + $id[$i] = (int)$x; + } + $this->di['pdo']->query('DELETE from custom_pages WHERE id in ('.join(', ', $id).')'); + } + else { + $this->di['pdo']->prepare('DELETE from custom_pages WHERE id = ?')->execute([$id]); + } + } + + public function getPage($id, $type = 'id') { + $q = $this->di['pdo']->prepare('SELECT * from custom_pages WHERE '.$type.' = ?'); + $q->execute([$id]); + return $q->fetch(); + } + + public function createPage($title, $description, $keywords, $content) { + $slug = $this->di['tools']->slug($title); + $i = 0; + $ex = $this->di['pdo']->prepare('SELECT id from custom_pages WHERE slug = ?'); + $ex->execute([$slug]); + $ex = $ex->rowCount(); + while($ex > 0) { + $slug = $this->di['tools']->slug($title).'-'.++$i; + $ex = $this->di['pdo']->prepare('SELECT id from custom_pages WHERE slug = ?'); + $ex->execute([$slug]); + $ex = $ex->rowCount(); + } + $this->di['pdo']->prepare('INSERT into custom_pages (title, description, keywords, content, slug) VALUES (?, ?, ?, ?, ?)')->execute([$title, $description, $keywords, $content, $slug]); + $id = $this->di['pdo']->lastInsertId(); + $this->di['logger']->info('Created new custom page #%s', $id); + return $id; + } + + public function updatePage($id, $title, $description, $keywords, $content, $slug) { + $slug = $this->di['tools']->slug($slug); + $ex = $this->di['pdo']->prepare('SELECT id from custom_pages WHERE slug = ? AND id <> ?'); + $ex->execute([$slug, $id]); + if($ex->rowCount() > 0) { + die(json_encode(['result' => null, 'error' => ['message' => 'You need to set unique slug.', 'code' => 9999]])); + } + $this->di['pdo']->prepare('UPDATE custom_pages SET title = ?, description = ?, keywords = ?, content = ?, slug = ? WHERE id = ?')->execute([$title, $description, $keywords, $content, $slug, $id]); + $this->di['logger']->info('Updated custom page #%s', $id); + return $id; + } +} diff --git a/src/bb-modules/Custompages/html_admin/mod_custompages_index.phtml b/src/bb-modules/Custompages/html_admin/mod_custompages_index.phtml new file mode 100644 index 000000000..acb1dc80e --- /dev/null +++ b/src/bb-modules/Custompages/html_admin/mod_custompages_index.phtml @@ -0,0 +1,106 @@ +{% import "macro_functions.phtml" as mf %} +{% extends "layout_default.phtml" %} +{% set active_menu = 'extensions' %} +{% block meta_title %}{% trans 'Custom Pages' %}{% endblock %} + +{% block content %} +
+ + + +
+ +
+
+ {{ mf.table_search }} + + + + + + + + + + + + + {% set pages = admin.custompages_get_list({"per_page":30, "page":request.page}|merge(request)) %} + {% for page in pages.list %} + + + + + + + + {% else %} + + + + {% endfor %} + +
{% trans 'ID' %}{% trans 'Title' %}{% trans 'Slug' %} 
{{ page.id }}{{ page.title }}{{ page.slug }} + + + +
{% trans 'The list is empty' %}
+ + {% include "partial_batch_delete.phtml" with {'action' : 'admin/custompages/batch_delete'} %} + {% include "partial_pagination.phtml" with {'list': pages, 'url':'custompages'} %} +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ +{% endblock %} + +{% block js %} + + + +{% endblock %} + +{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %} \ No newline at end of file diff --git a/src/bb-modules/Custompages/html_admin/mod_custompages_page.phtml b/src/bb-modules/Custompages/html_admin/mod_custompages_page.phtml new file mode 100644 index 000000000..5b9a083cc --- /dev/null +++ b/src/bb-modules/Custompages/html_admin/mod_custompages_page.phtml @@ -0,0 +1,73 @@ +{% extends "layout_default.phtml" %} +{% import "macro_functions.phtml" as mf %} +{% set active_menu = 'extensions' %} +{% block meta_title %} {% trans 'Edit Custom Page' %} {% endblock %} +{% set page = admin.custompages_get_page({page_id}|merge(request)) %} + +{% block breadcrumbs %} + +{% endblock %} + + +{% block content %} +{% if page.id > 0 %} + + +
+ +
+
{{ page.title}}
+
+ +
+ +
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+{% else %} + +{% endif %} +{% endblock %} + +{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %} \ No newline at end of file diff --git a/src/bb-modules/Custompages/html_client/mod_custompages_content.phtml b/src/bb-modules/Custompages/html_client/mod_custompages_content.phtml new file mode 100644 index 000000000..1d535689f --- /dev/null +++ b/src/bb-modules/Custompages/html_client/mod_custompages_content.phtml @@ -0,0 +1,25 @@ +{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %} + +{% block meta_title %}{{ page.title }}{% endblock %} +{% block meta_description %}{{ page.description }}{% endblock %} +{% block meta_keywords %}{{ page.keywords }}{% endblock %} +{% block breadcrumb %}
  • {% trans 'Example module' %}
  • {% endblock %} +{% block page_header %} + +{% endblock%} +{% block content %} +
    +
    +
    +
    +

    {{ page.title }}

    +
    +
    + {{ page.content | bbmd }} +
    +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/src/bb-modules/Custompages/icon.png b/src/bb-modules/Custompages/icon.png new file mode 100644 index 000000000..36da9bfe4 Binary files /dev/null and b/src/bb-modules/Custompages/icon.png differ diff --git a/src/bb-modules/Custompages/manifest.json b/src/bb-modules/Custompages/manifest.json new file mode 100644 index 000000000..553fd5e7b --- /dev/null +++ b/src/bb-modules/Custompages/manifest.json @@ -0,0 +1,12 @@ +{ + "id": "custompages", + "type": "mod", + "name": "Custom Pages", + "description": "This module allows you to create custom pages.", + "homepage_url": "https://github.com/boxbilling/", + "author": "BoxBilling", + "icon_url": "icon.png", + "author_url": "https://github.com/boxbilling/", + "license": "GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html", + "version": "1.0.0" +} diff --git a/src/bb-modules/Example/Controller/Admin.php b/src/bb-modules/Example/Controller/Admin.php index 076d1adae..0f6a33ac3 100644 --- a/src/bb-modules/Example/Controller/Admin.php +++ b/src/bb-modules/Example/Controller/Admin.php @@ -111,7 +111,7 @@ class Admin implements \Box\InjectionAwareInterface return $app->render('mod_example_index', $params); } - public function get_api(\Box_App $app, $id) + public function get_api(\Box_App $app, $id = null) { // always call this method to validate if admin is logged in $api = $this->di['api_admin']; diff --git a/src/bb-modules/Example/html_admin/mod_example_index.phtml b/src/bb-modules/Example/html_admin/mod_example_index.phtml index 66c5b8b58..a84fe8f91 100644 --- a/src/bb-modules/Example/html_admin/mod_example_index.phtml +++ b/src/bb-modules/Example/html_admin/mod_example_index.phtml @@ -54,11 +54,11 @@
    Data from API and passed to template from controller
    -
    {% debug list_from_controller %}
    +
    {{ dump(list_from_controller) }}
    Data from API accessed directly from template file
    {% set list = admin.example_get_something({"microsoft":1}) %} -
    {% debug list %}
    +
    {{ dump(list) }}
    {% endif %} diff --git a/src/bb-modules/Servicehosting/Service.php b/src/bb-modules/Servicehosting/Service.php index 922b10787..75eb37e78 100644 --- a/src/bb-modules/Servicehosting/Service.php +++ b/src/bb-modules/Servicehosting/Service.php @@ -257,7 +257,7 @@ class Service implements InjectionAwareInterface public function changeAccountUsername(\Model_ClientOrder $order, \Model_ServiceHosting $model, $data) { if(!isset($data['username']) || empty($data['username'])) { - throw new \Box_Exception('Account password is missing or is not valid'); + throw new \Box_Exception('Account username is missing or is not valid'); } $u = strtolower($data['username']); diff --git a/src/bb-themes/bootstrap/html/layout_default.phtml b/src/bb-themes/bootstrap/html/layout_default.phtml index ec37e160f..cbc1f512e 100755 --- a/src/bb-themes/bootstrap/html/layout_default.phtml +++ b/src/bb-themes/bootstrap/html/layout_default.phtml @@ -236,7 +236,6 @@ {% endif %} {% endfor %} - {# Removing this link is allowed only for BoxBilling PRO license owners. #} {% if guest.extension_is_on({"mod":'branding'}) or settings.footer_branding_enabled %}
  • {% trans 'Powered by BoxBilling' %}
  • {% endif %} @@ -251,4 +250,4 @@ - \ No newline at end of file + diff --git a/src/bb-themes/boxbilling/html/layout_default.phtml b/src/bb-themes/boxbilling/html/layout_default.phtml index 97e35334c..9d1a0cbdd 100644 --- a/src/bb-themes/boxbilling/html/layout_default.phtml +++ b/src/bb-themes/boxbilling/html/layout_default.phtml @@ -214,8 +214,6 @@

    - {# Removing this link is allowed only for BoxBilling PRO license owners. #} - {#Powered by BoxBilling#} © {{ now|date('Y') }} {{ company.signature }}

    @@ -229,4 +227,4 @@ {% include 'partial_pending_messages.phtml' ignore missing %} - \ No newline at end of file + diff --git a/src/bb-themes/huraga/html/layout_default.phtml b/src/bb-themes/huraga/html/layout_default.phtml index a9762b214..dbf09db4e 100644 --- a/src/bb-themes/huraga/html/layout_default.phtml +++ b/src/bb-themes/huraga/html/layout_default.phtml @@ -247,7 +247,6 @@ {% endif %} - {# Removing this link is allowed only for BoxBilling PRO license owners. #} {% if guest.extension_is_on({"mod":'branding'}) %}
  • {% trans 'Powered by BoxBilling' %} @@ -279,4 +278,4 @@ {% endif %} {% include 'partial_pending_messages.phtml' ignore missing %} - \ No newline at end of file + diff --git a/src/bb-update.php b/src/bb-update.php index 8632057e9..5e039b9e1 100644 --- a/src/bb-update.php +++ b/src/bb-update.php @@ -10,6 +10,18 @@ * with this source code in the file LICENSE */ +/** + * Unnamed new release + */ +class BBPatch_24 extends BBPatchAbstract +{ + public function patch() + { + $q = "CREATE TABLE IF NOT EXISTS `custom_pages` (`id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` varchar(555) NOT NULL, `keywords` varchar(555) NOT NULL, `content` text NOT NULL, `slug` varchar(255) NOT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8"; + $this->execSql($q); + } +} + class BBPatch_23 extends BBPatchAbstract { public function patch() diff --git a/src/composer.json b/src/composer.json index 1dfe1db7c..2547f3e9f 100644 --- a/src/composer.json +++ b/src/composer.json @@ -28,7 +28,8 @@ "stripe/stripe-php": "2.1.1", "guzzlehttp/guzzle": "*", "laminas/laminas-httphandlerrunner": "^1.2.0", - "docnet/tfpdf": "^2.2" + "docnet/tfpdf": "^2.2", + "infinityfree/mofh-client": "^0.7.0" }, "suggest": { "ext-gettext": "*" diff --git a/src/composer.lock b/src/composer.lock index 43577929f..fc2a30c27 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "28b4af5f035ec4db05fb0f54c8d17a8e", + "content-hash": "f628e09f5dff007c1c3b51f040151cbd", "packages": [ { "name": "composer/ca-bundle", @@ -426,6 +426,48 @@ }, "time": "2020-09-30T07:37:11+00:00" }, + { + "name": "infinityfree/mofh-client", + "version": "0.7.0", + "source": { + "type": "git", + "url": "https://github.com/InfinityFreeHosting/mofh-client.git", + "reference": "94a8081dbc1461ad7fa32c8301ae467fbd2c64b3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/InfinityFreeHosting/mofh-client/zipball/94a8081dbc1461ad7fa32c8301ae467fbd2c64b3", + "reference": "94a8081dbc1461ad7fa32c8301ae467fbd2c64b3", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "~6.0|~7.0" + }, + "require-dev": { + "fzaninotto/faker": "^1.7", + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^7.0|^8.0|^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "InfinityFree\\MofhClient\\": "src/", + "InfinityFree\\MofhClient\\Tests\\": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Hans Adema", + "email": "hans@infinityfree.net" + } + ], + "description": "A WHM API client for MyOwnFreeHost in PHP", + "time": "2020-09-12T15:50:56+00:00" + }, { "name": "ircmaxell/password-compat", "version": "v1.0.4", @@ -3666,5 +3708,5 @@ "ext-mbstring": "*" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "1.1.0" } diff --git a/src/install/index.php b/src/install/index.php index f18edf11e..5c0e91873 100644 --- a/src/install/index.php +++ b/src/install/index.php @@ -108,11 +108,34 @@ final class Box_Installer $this->makeInstall($this->session); $this->generateEmailTemplates(); session_destroy(); + // Try to remove install folder + function rmAllDir($dir) { + if (is_dir($dir)) { + $contents = scandir($dir); + foreach ($contents as $content) { + if ($content != '.' && $content != '..') { + if (filetype($dir.'/'.$content) == 'dir') { + rmAllDir($dir.'/'.$content); + } + else { + unlink($dir.'/'.$content); + } + } + } + reset($contents); + rmdir($dir); + } + } + try { + rmAllDir('../install'); + } + catch(Exception $e) { + // do nothing + } print 'ok'; } catch (Exception $e) { print $e->getMessage(); } - break; case 'index': @@ -185,7 +208,7 @@ final class Box_Installer { $path = BB_PATH_LICENSE; if (!file_exists($path)) { - return 'Please visit http://www.boxbilling.com for licensing information'; + return 'BoxBilling is licensed under the Apache License, Version 2.0.'.PHP_EOL.'Please visit https://github.com/boxbilling/boxbilling/blob/master/LICENSE for full license text.'; } return file_get_contents($path); } diff --git a/src/install/install.phtml b/src/install/install.phtml index 0a63394a7..576b60fb7 100644 --- a/src/install/install.phtml +++ b/src/install/install.phtml @@ -212,7 +212,7 @@

    Even though BoxBilling was installed successfully, you must take a few more actions.

    Remove installation module

    -

    For security reasons, you have to delete the installer from your web server before getting started.

    +

    Normally, install folder should be automatically deleted. But if it still exists, you have to delete the installer from your web server before getting started.

    {{ install_module_path }}

    Change configuration file permissions

    diff --git a/tests/bb-modules/Servicehosting/ServiceTest.php b/tests/bb-modules/Servicehosting/ServiceTest.php index 40d262671..3f9f7078a 100644 --- a/tests/bb-modules/Servicehosting/ServiceTest.php +++ b/tests/bb-modules/Servicehosting/ServiceTest.php @@ -562,7 +562,7 @@ class ServiceTest extends \BBTestCase { $data = array(); $this->expectException(\Box_Exception::class); - $this->expectExceptionMessage('Account password is missing or is not valid'); + $this->expectExceptionMessage('Account username is missing or is not valid'); $this->service->changeAccountUsername($orderModel, $model, $data); } diff --git a/tests/bb-modules/System/Api/AdminTest.php b/tests/bb-modules/System/Api/AdminTest.php index 6b94afeb2..4a98f5018 100644 --- a/tests/bb-modules/System/Api/AdminTest.php +++ b/tests/bb-modules/System/Api/AdminTest.php @@ -23,22 +23,6 @@ class AdminTest extends \BBTestCase { $this->assertEquals($di, $getDi); } - public function testlicense_info() - { - $data = array( - - ); - $serviceMock = $this->getMockBuilder('\Box\Mod\System\Service')->getMock(); - $serviceMock->expects($this->atLeastOnce()) - ->method('getLicenseInfo') - ->will($this->returnValue(array())); - - $this->api->setService($serviceMock); - - $result = $this->api->license_info($data); - $this->assertIsArray($result); - } - public function testparam() { $data = array( @@ -234,4 +218,4 @@ class AdminTest extends \BBTestCase { } - \ No newline at end of file +