mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-03 05:41:52 +09:00
Merge pull request #25 from boxbilling/master
boxbilling/boxbilling into timothygwebb/boxbilling
This commit is contained in:
26 files changed
+932
-36
No files matched your search
@@ -46,6 +46,7 @@
|
||||
<exclude name="bb-library/Server/Manager/Directadmin.php"/>
|
||||
<exclude name="bb-library/Server/Manager/Ispconfig3.php"/>
|
||||
<exclude name="bb-library/Server/Manager/Plesk.php"/>
|
||||
<exclude name="bb-library/Server/Manager/MOFH.php"/>
|
||||
<exclude name="bb-library/Server/Manager/Virtualmin.php"/>
|
||||
|
||||
<exclude name="bb-library/Registrar/includes/**"/>
|
||||
|
||||
@@ -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]
|
||||
|
||||
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|phtml|sql)$">
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
use \InfinityFree\MofhClient\Client;
|
||||
class Server_Manager_MOFH extends Server_Manager
|
||||
{
|
||||
// First, let's start with some information.
|
||||
//
|
||||
// MyOwnFreeHost has it's own (and weird) system of storing user identifiers.
|
||||
// When making API calls, you *must* use the 8-digit username that you've generated and submitted to MOFH while creating the account (a1b2c3d4)
|
||||
// Then, it generates *another* username, which is basically like "<3 lettered reseller identifier>_<another, and different 8 char integer>" (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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Custompages\Api;
|
||||
|
||||
class Admin extends \Api_Abstract
|
||||
{
|
||||
/**
|
||||
* Get paginated list of custom pages
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_list($data)
|
||||
{
|
||||
$search = $this->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']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Custompages\Controller;
|
||||
|
||||
class Admin implements \Box\InjectionAwareInterface
|
||||
{
|
||||
protected $di;
|
||||
|
||||
/**
|
||||
* @param mixed $di
|
||||
*/
|
||||
public function setDi($di)
|
||||
{
|
||||
$this->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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file connects BoxBilling client area interface and API
|
||||
* Class does not extend any other class
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Custompages\Controller;
|
||||
|
||||
class Client implements \Box\InjectionAwareInterface
|
||||
{
|
||||
protected $di;
|
||||
|
||||
/**
|
||||
* @param mixed $di
|
||||
*/
|
||||
public function setDi($di)
|
||||
{
|
||||
$this->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('')));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Custompages;
|
||||
|
||||
class Service
|
||||
{
|
||||
protected $di;
|
||||
|
||||
public function setDi($di)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@@ -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 %}
|
||||
<div class="widget simpleTabs">
|
||||
|
||||
<ul class="tabs">
|
||||
<li><a href="#tab-index">{% trans 'Custom Pages' %}</a></li>
|
||||
<li><a href="#tab-new">{% trans 'New Custom Page' %}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tabs_container">
|
||||
|
||||
<div class="fix"></div>
|
||||
<div class="tab_content nopadding" id="tab-index">
|
||||
{{ mf.table_search }}
|
||||
<table class="tableStatic wide">
|
||||
<thead>
|
||||
<tr>
|
||||
<td style="width: 2%"><input type="checkbox" class="batch-delete-master-checkbox"/></td>
|
||||
<td>{% trans 'ID' %}</td>
|
||||
<td>{% trans 'Title' %}</td>
|
||||
<td>{% trans 'Slug' %}</td>
|
||||
<td width="13%"> </td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% set pages = admin.custompages_get_list({"per_page":30, "page":request.page}|merge(request)) %}
|
||||
{% for page in pages.list %}
|
||||
<tr>
|
||||
<td><input type="checkbox" class="batch-delete-checkbox" data-item-id="{{ page.id }}"/></td>
|
||||
<td>{{ page.id }}</td>
|
||||
<td>{{ page.title }}</td>
|
||||
<td>{{ page.slug }}</td>
|
||||
<td>
|
||||
<a class="btn14" href="{{ 'page'|link }}/{{ page.slug }}" title="{% trans 'View' %}"><img src="images/icons/dark/view.png" alt=""></a>
|
||||
<a class="btn14" href="{{ 'custompages'|alink }}/{{ page.id }}" title="{% trans 'Edit' %}"><img src="images/icons/dark/pencil.png" alt=""></a>
|
||||
<a class="btn14 bb-rm-tr api-link" href="{{ 'api/admin/custompages/delete'|link({'id' : page.id}) }}" title="{% trans 'Delete' %}" data-api-confirm="Are you sure?" data-api-reload="1"><img src="images/icons/dark/trash.png" alt=""></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="7">{% trans 'The list is empty' %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% include "partial_batch_delete.phtml" with {'action' : 'admin/custompages/batch_delete'} %}
|
||||
{% include "partial_pagination.phtml" with {'list': pages, 'url':'custompages'} %}
|
||||
</div>
|
||||
|
||||
<div class="fix"></div>
|
||||
|
||||
<div class="tab_content nopadding" id="tab-new">
|
||||
|
||||
<form method="post" action="{{ 'api/admin/custompages/create'|link }}" class="mainForm api-form save" data-api-redirect="{{ 'custompages'|alink }}">
|
||||
<fieldset>
|
||||
<div class="rowElem noborder">
|
||||
<label>{% trans 'Title' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="title" value="{{request.title}}" required="required" placeholder="{% trans 'Enter page title here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Meta Description' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="description" value="{{request.description}}" placeholder="{% trans 'Enter page meta description here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Meta Keywords' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="keywords" value="{{request.keywords}}" placeholder="{% trans 'Enter page meta keywords here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Content' %}:</label>
|
||||
<div class="formRight">
|
||||
<textarea class="bb-textarea" name="content" cols="5" rows="5" required="required" placeholder="{% trans 'Enter page content here.' %}"></textarea>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<input type="submit" value="{% trans 'Create' %}" class="greyishBtn submitForm" />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %}
|
||||
@@ -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 %}
|
||||
<ul>
|
||||
<li class="firstB"><a href="{{ '/'|alink }}">{% trans 'Home' %}</a></li>
|
||||
<li><a href="{{ 'custompages'|alink }}">{% trans 'Custom Pages' %}</a></li>
|
||||
<li class="lastB">{{ page.title}}</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
{% if page.id > 0 %}
|
||||
|
||||
|
||||
<div class="widget">
|
||||
|
||||
<div class="head">
|
||||
<h5>{{ page.title}}</h5>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ 'api/admin/custompages/update'|link }}" class="mainForm save api-form" data-api-msg="{% trans 'Custom page updated' %}">
|
||||
<input type="hidden" name="id" value="{{ page.id }}">
|
||||
<fieldset>
|
||||
<div class="rowElem noborder">
|
||||
<label>{% trans 'Title' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="title" value="{{ page.title }}" required="required" placeholder="{% trans 'Enter page title here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Meta Description' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="description" value="{{ page.description }}" placeholder="{% trans 'Enter page meta description here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Meta Keywords' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="keywords" value="{{ page.keywords }}" placeholder="{% trans 'Enter page meta keywords here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Slug' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="slug" value="{{ page.slug }}" required="required" placeholder="{% trans 'Enter page slug here.' %}"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Content' %}:</label>
|
||||
<div class="formRight">
|
||||
<textarea class="bb-textarea" name="content" cols="5" rows="5" required="required" placeholder="{% trans 'Enter page content here.' %}">{{ page.content }}</textarea>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<input type="submit" value="{% trans 'Update' %}" class="greyishBtn submitForm" />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
{% else %}
|
||||
<script>location.href = "{{ 'custompages'|alink }}"</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %}
|
||||
@@ -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 %} <li class="active">{% trans 'Example module' %}</li>{% endblock %}
|
||||
{% block page_header %}
|
||||
<article class="page-header">
|
||||
<h1>{% trans 'Example module title' %}</h1>
|
||||
</article>
|
||||
{% endblock%}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<article class="span12 data-block">
|
||||
<div class="data-container">
|
||||
<header>
|
||||
<h1>{{ page.title }}</h1>
|
||||
</header>
|
||||
<section>
|
||||
{{ page.content | bbmd }}
|
||||
</section>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 487 B |
@@ -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"
|
||||
}
|
||||
@@ -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'];
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
</div>
|
||||
<div class="body">
|
||||
<h5 class="pt12">Data from API and passed to template from controller</h5>
|
||||
<pre>{% debug list_from_controller %}</pre>
|
||||
<pre>{{ dump(list_from_controller) }}</pre>
|
||||
|
||||
<h5 class="pt12">Data from API accessed directly from template file</h5>
|
||||
{% set list = admin.example_get_something({"microsoft":1}) %}
|
||||
<pre>{% debug list %}</pre>
|
||||
<pre>{{ dump(list) }}</pre>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -236,7 +236,6 @@
|
||||
</li>
|
||||
{% 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 %}
|
||||
<li><a href="http://www.boxbilling.com" title="Billing Software" target="_blank">{% trans 'Powered by BoxBilling' %}</a></li>
|
||||
{% endif %}
|
||||
@@ -251,4 +250,4 @@
|
||||
<!-- /.container -->
|
||||
<noscript>NOTE: Many features on BoxBilling require Javascript and cookies. You can enable both via your browser's preference settings.</noscript>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -214,8 +214,6 @@
|
||||
<div class="box">
|
||||
<div class="block">
|
||||
<p>
|
||||
{# Removing this link is allowed only for BoxBilling PRO license owners. #}
|
||||
{#<a href="http://www.boxbilling.com" title="Billing Software" target="_blank" style="float:right">Powered by BoxBilling</a>#}
|
||||
© {{ now|date('Y') }} {{ company.signature }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -229,4 +227,4 @@
|
||||
<noscript>NOTE: Many features on BoxBilling require Javascript and cookies. You can enable both via your browser's preference settings.</noscript>
|
||||
{% include 'partial_pending_messages.phtml' ignore missing %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -247,7 +247,6 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{# Removing this link is allowed only for BoxBilling PRO license owners. #}
|
||||
{% if guest.extension_is_on({"mod":'branding'}) %}
|
||||
<li>
|
||||
<a href="http://www.boxbilling.com" title="Billing Software" target="_blank">{% trans 'Powered by BoxBilling' %}</a>
|
||||
@@ -279,4 +278,4 @@
|
||||
{% endif %}
|
||||
{% include 'partial_pending_messages.phtml' ignore missing %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -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()
|
||||
|
||||
+2
-1
@@ -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": "*"
|
||||
|
||||
Generated
+44
-2
@@ -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"
|
||||
}
|
||||
+25
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
<p>Even though BoxBilling was installed successfully, you must take a few more actions.</p>
|
||||
|
||||
<h2 class="pt20">Remove installation module</h2>
|
||||
<p>For security reasons, you <b>have to</b> delete the installer from your web server before getting started.</p>
|
||||
<p>Normally, <b>install</b> folder should be automatically deleted. But if it still exists, you <b>have to</b> delete the installer from your web server before getting started.</p>
|
||||
<pre>{{ install_module_path }}</pre>
|
||||
|
||||
<h2 class="pt20">Change configuration file permissions</h2>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user