diff --git a/src/bb-config-sample.php b/src/bb-config-sample.php index 37f5565c1..fd2fda56c 100755 --- a/src/bb-config-sample.php +++ b/src/bb-config-sample.php @@ -6,7 +6,7 @@ * to "bb-config.php" and fill in the values. * Import /install/structure.sql to your database * Import /install/content.sql to your database - * Open browser http://www.youdomain.com/index.php?_url=/bb-admin to create new admin account. + * Open browser http://www.yourdomain.com/index.php?_url=/bb-admin to create new admin account. * Remove /install directory */ diff --git a/src/bb-load.php b/src/bb-load.php index 88896d125..d74d75e39 100644 --- a/src/bb-load.php +++ b/src/bb-load.php @@ -53,7 +53,7 @@ function handler_exception($e) - BoxBilling + BoxBilling "; $page = str_replace(PHP_EOL, "", $page); print $page; diff --git a/src/bb-modules/Branding/manifest.json b/src/bb-modules/Branding/manifest.json index a621c2a8b..39acb03e1 100644 --- a/src/bb-modules/Branding/manifest.json +++ b/src/bb-modules/Branding/manifest.json @@ -2,10 +2,10 @@ "id": "branding", "type": "mod", "name": "Branding", - "description": "BoxBilling branding module. Can be deactivated by PRO license owners only.", + "description": "Branding module of BoxBilling. This extension includes the footer reference to BoxBilling's official website.", "homepage_url": "http://github.com/boxbilling/", "author": "BoxBilling", "author_url": "http://extensions.boxbilling.com/", "license": "http://www.boxbilling.com/license.txt", "version": "1.0.0" -} \ No newline at end of file +} diff --git a/src/bb-modules/Serviceboxbillinglicense/Api/Admin.php b/src/bb-modules/Serviceboxbillinglicense/Api/Admin.php deleted file mode 100644 index 6eb57ca20..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/Api/Admin.php +++ /dev/null @@ -1,138 +0,0 @@ -di['db']->findOne('client_order', - "id=:id - AND service_type = 'boxbillinglicense' - ", - array('id'=>$data['order_id'])); - - if(!$order) { - throw new \Box_Exception('BoxBilling license order not found'); - } - - $s = $this->di['db']->findOne('service_boxbillinglicense', - 'id=:id', - array('id'=>$order->service_id)); - if(!$s) { - throw new \Box_Exception('Order is not activated'); - } - return array($order, $s); - } - - /** - * Update module configuration - * - * @param int $order_id - order id - * @return bool - */ - public function config_update($data) - { - $this->getService()->setModuleConfig($data); - $this->di['logger']->info('Updated configuration information.'); - return true; - } - - /** - * Get module configuration - * - * @param int $order_id - order id - * @return bool - */ - public function config_get($data) - { - return $this->getService()->getModuleConfig($data); - } - - /** - * Get detailed license order info - * - * @param int $order_id - order id - * - * @return array - */ - public function order_info($data) - { - list(, $service) = $this->_getService($data); - return $this->getService()->licenseDetails($service); - } - - /** - * Reset license information. Usually used when moving BoxBilling to - * new server. - * - * @param int $order_id - order id - * - * @return bool - */ - public function order_reset($data) - { - list(, $service) = $this->_getService($data); - $this->getService()->licenseReset($service); - return true; - } - - /** - * Convenience method to become partner. After you become BoxBilling - * partner you are able to sell licenses. - * - * @return bool - */ - public function become_partner() - { - return $this->getService()->becomePartner(); - } - - /** - * Test connection to BoxBilling server. Used to test your configuration. - * - * @return bool - */ - public function test_connection() - { - $this->getService()->testApiConnection(); - return true; - } - - /** - * Update existing order service - * This method used to change service data if order setup fails - * or have changed on remote server - * - * @param int $order_id - order id - * - * @return boolean - */ - public function update($data) - { - list(, $service) = $this->_getService($data); - - $service->oid = $this->di['array_get']($data, 'oid', $service->oid); - $service->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($service); - - $this->di['logger']->info('Updated BoxBilling license %s details', $service->id); - return true; - } -} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/Api/Client.php b/src/bb-modules/Serviceboxbillinglicense/Api/Client.php deleted file mode 100644 index c1c3b8ac1..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/Api/Client.php +++ /dev/null @@ -1,62 +0,0 @@ -di['db']->findOne('client_order', - "id=:id - AND client_id = :cid - AND service_type = 'boxbillinglicense' - ", - array(':id' => $data['order_id'], ':cid' => $this->getIdentity()->id)); - - if (!$order) { - throw new \Box_Exception('BoxBilling license order not found'); - } - - $s = $this->di['db']->findOne('service_boxbillinglicense', - 'id=:id AND client_id = :cid', - array('id' => $order->service_id, 'cid' => $this->getIdentity()->id)); - if (!$s) { - throw new \Box_Exception('Order is not activated'); - } - - return array($order, $s); - } - - /** - * Reset license information. Usually used when moving BoxBilling to - * new server. - * - * @param int $order_id - order id - * @return bool - */ - public function reset($data) - { - list($order, $service) = $this->_getService($data); - $this->getService()->reset($order, $service, $data); - $this->di['logger']->info('Reset license information. Order ID #%s', $order->id); - - return true; - } -} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/Service.php b/src/bb-modules/Serviceboxbillinglicense/Service.php deleted file mode 100644 index 69537878b..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/Service.php +++ /dev/null @@ -1,235 +0,0 @@ -di = $di; - } - - /** - * @return mixed - */ - public function getDi() - { - return $this->di; - } - - public function install() - { - $sql=" - CREATE TABLE IF NOT EXISTS `service_boxbillinglicense` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `client_id` bigint(20) DEFAULT NULL, - `oid` varchar(255) DEFAULT NULL, - `created_at` varchar(35) DEFAULT NULL, - `updated_at` varchar(35) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `oid` (`oid`), - KEY `client_id_idx` (`client_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - "; - - $this->di['db']->exec($sql); - } - - public function uninstall() - { - - $this->di['db']->exec("DROP TABLE IF EXISTS `service_boxbillinglicense`"); - } - - public function setModuleConfig($data) - { - $this->getModuleConfig(); - - $sql=" - UPDATE extension_meta - SET meta_value = :config - WHERE extension = 'mod_serviceboxbillinglicense' - AND meta_key = 'config' - "; - $params = array( - 'config' => json_encode($data), - ); - $this->di['db']->exec($sql, $params); - } - - public function getModuleConfig() - { - $c = $this->di['db']->findOne('extension_meta', 'extension = :ext AND meta_key = :key', array('ext'=>'mod_serviceboxbillinglicense', 'key'=>'config')); - if(is_null($c)) { - $c = $this->di['db']->dispense('extension_meta'); - $c->extension = 'mod_serviceboxbillinglicense'; - $c->meta_key = 'config'; - $c->meta_value = null; - $c->created_at = date('Y-m-d H:i:s'); - $c->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($c); - } - $config = json_decode($c->meta_value, 1); - if(!isset($config['api_key'])) { - $config['api_key'] = null; - } - return $config; - } - - /** - * @param $order - * @return void - */ - public function create($order) - { - $model = $this->di['db']->dispense('service_boxbillinglicense'); - $model->client_id = $order->client_id; - $model->created_at = date('Y-m-d H:i:s'); - $model->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($model); - return $model; - } - - /** - * @param $order - * @return boolean - */ - public function activate($order, $model) - { - if(!is_object($model)) { - throw new \Box_Exception('Could not activate order. Service was not created', null, 7456); - } - - $result = $this->_getApi()->partner_order_create(); - - $model->oid = $result; - $model->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($model); - - return true; - } - - /** - * Suspend VPS - * - * @param $order - * @return boolean - */ - public function suspend($order, $model) - { - if(!is_object($model)) { - throw new \Box_Exception('Could not activate order. Service was not created', null, 7456); - } - - $this->_getApi()->partner_order_suspend($model->vserverid); - $model->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($model); - return true; - } - - /** - * @param $order - * @return boolean - */ - public function unsuspend($order, $model) - { - if(!is_object($model)) { - throw new \Box_Exception('Could not activate order. Service was not created', null, 7456); - } - - $this->_getApi()->partner_order_unsuspend($model->vserverid); - $model->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($model); - return true; - } - - /** - * @param $order - * @return boolean - */ - public function delete($order, $model) - { - if(is_object($model)) { - $this->_getApi()->partner_order_delete($model->vserverid); - $this->di['db']->trash($model); - } - return true; - } - - public function reset($order, $model) - { - $this->_getApi()->partner_order_reset($model->f1); - return true; - } - - public function becomePartner() - { - $data = array( - 'agree'=> true, - ); - $this->_getApi()->partner_signup($data); - } - - public function licenseDetails($model) - { - $data = array( - 'order_id'=> $model->oid, - ); - try { - return $this->_getApi()->partner_order_get($data); - } catch(\Exception $e) { - error_log($e->getMessage()); - } - return array(); - } - - public function licenseReset($model) - { - $data = array( - 'order_id'=> $model->oid, - ); - return $this->_getApi()->partner_order_reset($data); - } - - public function testApiConnection() - { - try { - $this->_getApi()->client_get(); - } catch (\Exception $e) { - error_log($e); - throw new \Exception('Unable to connect to BoxBilling API. Make sure API key is valid.'); - } - return true; - } - - private function _getApi() - { - $config = $this->getModuleConfig(); - return $this->di['service_boxbilling']($config); - } - - public function toApiArray($model, $deep = false, $identity = null) - { - return array( - 'id' => $model->id, - 'oid' => $model->oid, - ); - } -} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/ServiceBoxbilling.php b/src/bb-modules/Serviceboxbillinglicense/ServiceBoxbilling.php deleted file mode 100644 index 1e3492e74..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/ServiceBoxbilling.php +++ /dev/null @@ -1,134 +0,0 @@ -di = $di; - } - - public function getDi() - { - return $this->di; - } - /** - * Api URL - * - * @example https://www.boxbilling.com/api - * @var string - */ - protected $_api_url = 'http://www.boxbilling.com/api'; - - /** - * Api key is found in BoxBilling profile page - * - * @example e4yny7yjy5u3yhyhepumuqaquva3y4as - * @var string - */ - protected $_api_key = NULL; - - /** - * Same service can be used to control BoxBilling as client and guest - * - * @example guest - * @example admin - * @example client - * @var string - */ - protected $_api_role = 'client'; - - /** - * Path to cookie to save session for requests. - * - * @var string - path to cookie. Must be writable - */ - protected $_cookie = NULL; - - public function __construct($options) - { - if (!extension_loaded('curl')) { - throw new \Exception('cURL extension is not enabled'); - } - - if (isset($options['api_key'])) { - $this->_api_key = $options['api_key']; - } - - if (isset($options['api_url'])) { - $this->_api_url = $options['api_url']; - } - - if (isset($options['api_role'])) { - $this->_api_role = $options['api_role']; - } - - $this->_cookie = sys_get_temp_dir() . '/bbcookie.txt'; - } - - public function __call($method, $arguments) - { - $data = array(); - if (isset($arguments[0]) && is_array($arguments[0])) { - $data = $arguments[0]; - } - - $module = substr($method, 0, strpos($method, '_')); - $m = substr($method, strpos($method, '_') + 1); - - $url = $this->_api_url . '/' . $this->_api_role . '/' . $module . '/' . $m; - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $this->_api_role . ":" . $this->_api_key); - curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_cookie); - curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_cookie); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - - $result = curl_exec($ch); - - if ($result === false) { - $e = new \Exception(sprintf('Curl Error: "%s"', curl_error($ch))); - curl_close($ch); - throw $e; - } - - curl_close($ch); - - $json = json_decode($result, 1); - - if (!is_array($json)) { - throw new \Exception(sprintf('BoxBilling API: Invalid Response "%s"', $result)); - } - - if (isset($json['error']) && !empty($json['error'])) { - throw new \Exception($json['error']['message'], $json['error']['code']); - } - - if (!isset($json['result'])) { - throw new \Exception(sprintf('BoxBilling API: Invalid Response "%s"', $result)); - } - - return $json['result']; - } - -} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/html_admin/mod_serviceboxbillinglicense_manage.phtml b/src/bb-modules/Serviceboxbillinglicense/html_admin/mod_serviceboxbillinglicense_manage.phtml deleted file mode 100644 index c1a3605e2..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/html_admin/mod_serviceboxbillinglicense_manage.phtml +++ /dev/null @@ -1,85 +0,0 @@ -
-

{% trans 'BoxBilling license management' %}

-
- -
-
-
- -
- -
-
-
- - - -
-
- -{% set info = admin.serviceboxbillinglicense_order_info({"order_id":order.id}) %} - -{% if info %} - -
-

{% trans 'License details' %}

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{% trans 'Order status' %}:{{ info.status|title }}
{% trans 'License key' %}:{{ info.license_key }}
{% trans 'Created at' %}:{{ info.created_at|bb_date }}
{% trans 'Updated at' %}:{{ info.updated_at|bb_date }}
{% trans 'Expires at' %}:{{ info.expires_at|bb_date }}
{% trans 'Valid IPs' %}:{% for v in info.ips %}{{ v }}{{constant("PHP_EOL")}}{%else%}All IPs{% endfor %}
{% trans 'Valid hostnames' %}:{% for v in info.hosts %}{{ v }}{{constant("PHP_EOL")}}{%else%}All hostnames{% endfor %}
{% trans 'Valid versions' %}:{% for v in info.versions %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any version{% endfor %}
{% trans 'Valid install paths' %}:{% for v in info.paths %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any install path{% endfor %}
-
- Reset -
-
- -{% else %} - -
-
-

{% trans 'INFORMATION' %}: {% trans 'Order is not activated or not found' %}

-
-
-{% endif %} diff --git a/src/bb-modules/Serviceboxbillinglicense/html_admin/mod_serviceboxbillinglicense_settings.phtml b/src/bb-modules/Serviceboxbillinglicense/html_admin/mod_serviceboxbillinglicense_settings.phtml deleted file mode 100644 index 6e9524cd3..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/html_admin/mod_serviceboxbillinglicense_settings.phtml +++ /dev/null @@ -1,75 +0,0 @@ -{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %} -{% set active_menu = 'system' %} -{% block meta_title %}{% trans 'BoxBilling license' %}{% endblock %} - -{% block breadcrumbs %} - -{% endblock %} - - -{% block content %} - -
-
-
{% trans 'BoxBilling license' %}
-
- -
-

{% trans '1. Configure API' %}

-
- - {% set params = admin.serviceboxbillinglicense_config_get %} -
-
-
- -
- - - -
-
-
-
-
- -
-

{% trans '2. Become partner' %}

-

Click here to become partner

-

Go to partnership program page for more information.

-
- -
-

{% trans '3. Create license product' %}

-

Create BoxBilling license product

-

You can sell licenses for any price you want or even give it for free. All money collected from your clients stays for you.

-

BoxBilling will start charging you only for active licenses after 14 days. This gives you ability to make revenue before you even spend money.

-

Thats it. Remember the more you sell the lower the price you receive.

-
-
- -{% endblock %} - -{% block js %} -{% autoescape "js" %} - -{% endautoescape %} -{% endblock %} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/html_client/mod_serviceboxbillinglicense_manage.phtml b/src/bb-modules/Serviceboxbillinglicense/html_client/mod_serviceboxbillinglicense_manage.phtml deleted file mode 100644 index ed48a0af7..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/html_client/mod_serviceboxbillinglicense_manage.phtml +++ /dev/null @@ -1,46 +0,0 @@ -{% if order.status == 'active' %} -{% set info = admin.serviceboxbillinglicense_order_info({"order_id":order.id}) %} - -
-
-
-
-

{{ order.title }}

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{% trans 'License key' %}:{{ info.license_key }}
{% trans 'Valid IPs' %}:{% for v in info.ips %}{{ v }}{{constant("PHP_EOL")}}{%else%}All IPs{% endfor %}
{% trans 'Valid hostnames' %}:{% for v in info.hosts %}{{ v }}{{constant("PHP_EOL")}}{%else%}All hostnames{% endfor %}
{% trans 'Valid versions' %}:{% for v in info.versions %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any version{% endfor %}
{% trans 'Valid install paths' %}:{% for v in info.paths %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any install path{% endfor %}
- {% trans 'Reset' %} -
-
-
-
-
-{% endif %} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/html_client/mod_serviceboxbillinglicense_order.phtml b/src/bb-modules/Serviceboxbillinglicense/html_client/mod_serviceboxbillinglicense_order.phtml deleted file mode 100644 index d74e57261..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/html_client/mod_serviceboxbillinglicense_order.phtml +++ /dev/null @@ -1 +0,0 @@ -{% include "mod_order_product.phtml" %} \ No newline at end of file diff --git a/src/bb-modules/Serviceboxbillinglicense/icon.png b/src/bb-modules/Serviceboxbillinglicense/icon.png deleted file mode 100644 index 38b2cff32..000000000 Binary files a/src/bb-modules/Serviceboxbillinglicense/icon.png and /dev/null differ diff --git a/src/bb-modules/Serviceboxbillinglicense/manifest.json b/src/bb-modules/Serviceboxbillinglicense/manifest.json deleted file mode 100644 index d334f8cff..000000000 --- a/src/bb-modules/Serviceboxbillinglicense/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "serviceboxbillinglicense", - "type": "mod", - "name": "BoxBilling license product", - "description": "Sell BoxBiling licenses and get paid. The more you sell - more profit you make", - "icon_url": "icon.png", - "homepage_url": "http://github.com/boxbilling/", - "author": "BoxBilling", - "author_url": "http://extensions.boxbilling.com/", - "license": "http://www.boxbilling.com/license.txt", - "version": "1.0.0" -} \ No newline at end of file diff --git a/src/install/content.sql b/src/install/content.sql index b04caa21a..1b0e03c37 100644 --- a/src/install/content.sql +++ b/src/install/content.sql @@ -363,7 +363,7 @@ VALUES (2,'company_name','Company Name',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (3,'company_email','company@email.com',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (4,'company_signature','BoxBilling.com - Client Management, Invoice and Support Software',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), - (5,'company_logo','https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), + (5,'company_logo','/bb-themes/boxbilling/assets/images/logo.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (6,'company_address_1','Demo address line 1',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (7,'company_address_2','Demo address line 2',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (8,'company_address_3','Demo address line 3',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), diff --git a/src/install/content_test.sql b/src/install/content_test.sql index bbbe71d11..ea9004111 100644 --- a/src/install/content_test.sql +++ b/src/install/content_test.sql @@ -572,7 +572,7 @@ VALUES (2,'company_name','Demo BoxBilling.com',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (3,'company_email','my@mycompany.com',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (4,'company_signature','BoxBilling.com - Client Management, Invoice and Support Software',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), - (5,'company_logo','https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), + (5,'company_logo','/bb-themes/boxbilling/assets/images/logo.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (6,'company_address_1','Demo address line 1',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (7,'company_address_2','Demo address line 2',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), (8,'company_address_3','Demo address line 3',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'), diff --git a/src/install/layout.phtml b/src/install/layout.phtml index 05649f8fb..5782d6513 100644 --- a/src/install/layout.phtml +++ b/src/install/layout.phtml @@ -10,7 +10,7 @@