/**
  * Controller List
  */
 public function ListControllers()
 {
     $result = null;
     $controller_name = null;
     // Scan Core Controllers
     $controller_dir = array_diff(scandir(CONTROLLERDIR), array('..', '.'));
     // Begin Core Controllers List
     $controller_name[] = Language::_("CssJavascriptToolboxPlugin.root.system", true);
     foreach ($controller_dir as $dirfile) {
         $file_path = CONTROLLERDIR . $dirfile;
         $controller = strstr($dirfile, '.', true);
         if (file_exists($file_path)) {
             if (!in_array($controller, $this->ExcludeControllers())) {
                 require_once $file_path;
                 $class_methods = get_class_methods(Loader::toCamelCase($controller));
                 if (is_array($class_methods)) {
                     foreach ($class_methods as $method_name => $value) {
                         if (!in_array($value, $this->ExcludeFunctions())) {
                             $action = "_" . strtolower($value);
                             if ($controller == "admin_main" and $action == "_index") {
                                 $controller_name[$controller] = Language::_("CssJavascriptToolboxPlugin.root.admin_dashboard", true);
                             } else {
                                 if ($controller == "client_main" and $action == "_index") {
                                     $controller_name[$controller] = Language::_("CssJavascriptToolboxPlugin.root.client_dashboard", true);
                                 } else {
                                     if ($action == "_index") {
                                         $controller_name[$controller] = $controller;
                                     } else {
                                         $controller_name[$controller . $action] = $controller . $action;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Scan Plugins Controllers
     // $plugins_dir = array_diff(scandir(PLUGINDIR), array('..', '.'));
     // foreach ($plugins_dir as $dirfile) {
     // $file_path = PLUGINDIR . $dirfile . DS . "controllers";
     // $controller =  strstr($dirfile, '.', true);
     // $controller_name[] .= Language::_("CssJavascriptToolboxPlugin.root.system", true);
     // if (file_exists($file_path)) {
     // if (!in_array($controller, $this->ExcludeControllers())) {
     // require_once($file_path);
     // $class_methods = get_class_methods(Loader::toCamelCase($controller));
     // if (is_array($class_methods)) {
     // foreach ($class_methods as $method_name => $value) {
     // if (!in_array($value, $this->ExcludeFunctions()))
     // $controller_name[$controller ."_". $value] = $controller ."_". $value;
     // }
     // }
     // }
     // }
     // }
     return $controller_name;
 }
Ejemplo n.º 2
0
    public function FinalTemplate($Header = null, $HtmlDir = null, $HtmlTitle = null, $RtlCss = null, $drawBackground = null, $drawLogo = null, $drawPaidWatermark = null, $drawInvoiceType = null, $drawInvoiceInfo = null, $drawReturnAddress = null, $drawAddress = null, $drawLineHeader = null, $drawInvoice = null, $SubTotals = null, $Taxes = array(), $Totals = null, $PublicNotes = null, $drawPayments = null, $drawTerms = null, $Footer = null, $PrintBtn = null, $DownloadBtn = null, $PaymentBtn = null, $EditBtn = null)
    {
        /*
        *
        NOTE , The $Header include all the header 
        *
        */
        // print_r($drawInvoiceInfo['invoice_view']);
        if (strpos($_SERVER['REQUEST_URI'], Configure::get("Route.admin"))) {
            $return_rl = WEBDIR . Configure::get("Route.admin") . "/clients/view/" . $drawInvoiceInfo['client_view'] . "/";
            $payment_btn = '
				<div class="btn-group">
					<button type="button" class="btn btn-warning btn-lg dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
						<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.add_payment", true) . ' <span class="caret"></span>
					</button>
					<ul class="dropdown-menu" role="menu">
						<li><a href="' . WEBDIR . Configure::get("Route.admin") . '/clients/makepayment/' . $drawInvoiceInfo['client_view'] . '/' . $drawInvoiceInfo['invoice_view'] . '"><span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.pay_invoice", true) . '</a></li>
						<li class="divider"></li>
						<li><a href="' . WEBDIR . Configure::get("Route.admin") . '/clients/recordpayment/' . $drawInvoiceInfo['client_view'] . '/' . $drawInvoiceInfo['invoice_view'] . '"><span class="glyphicon glyphicon-usd" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.record_invoice", true) . '</a></li>							
					</ul>
				</div>';
            $edit_btn = '
				<button type="button" class="btn btn-info btn-lg " onclick="window.location.href=\'' . WEBDIR . Configure::get("Route.admin") . '/clients/editinvoice/' . $drawInvoiceInfo['client_view'] . '/' . $drawInvoiceInfo['invoice_view'] . '\'"> 
					<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.edit_invoice", true) . '
				</button>';
        } else {
            $return_rl = WEBDIR . Configure::get("Route.client") . "/";
            $payment_btn = '
				<button type="button" class="btn btn-warning btn-lg" onclick="window.location.href=\'' . WEBDIR . Configure::get("Route.client") . '/pay/method/' . $drawInvoiceInfo['invoice_view'] . '/\'">
				  <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.pay_invoice", true) . '
				</button>';
            $edit_btn = '';
        }
        $paid_watermark = '
				<button type="button" class="btn btn-success btn-lg active" >
					<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.watermark_paid", true) . '
				</button>';
        $unpaid_watermark = '
				<button type="button" class="btn btn-danger btn-lg active" >
					<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.watermark_unpaid", true) . '
				</button>';
        $download_btn = '
				<button type="button" class="btn btn-primary btn-lg " onclick="window.location.href=\'' . $_SERVER['REQUEST_URI'] . '/pdf/\'"> 
					<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.download_invoice", true) . '
				</button>';
        $print_btn = '
				<button type="button" class="btn btn-primary btn-lg" onclick="javascript:window.print();" >
				  <span class="glyphicon glyphicon-print" aria-hidden="true"></span> ' . Language::_("HtmlInvoice.print_invoice", true) . '
				</button>';
        $draw_terms = '
				<div class="row">
					<div class="col-xs-12">
						<h3><span class="label label-default">' . Language::_("HtmlInvoice.terms_heading", true) . '</span></h3>
						
						<div class="well well-sm">' . nl2br($drawTerms) . '</div>						
					</div>
				</div>';
        $taxe_line = "";
        foreach ($Taxes as $Taxe) {
            $taxe_line .= '
				<tr>
					<th colspan="2" class="warning text-right"><h4>' . $Taxe['label'] . '</h4></th>
					<th class="warning text-right"><h4>' . $Taxe['value'] . '</h4></th>
				</tr>';
        }
        $content = '
		<!doctype html>
		<html dir="' . $HtmlDir . '">
			<head>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				<meta name="viewport" content="width=device-width, initial-scale=1.0">	
				<title>' . $HtmlTitle . ' </title>				
				<!-- Latest compiled and minified CSS -->
				<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
				<!-- Optional theme -->
				<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">		
				' . (Language::_("AppController.lang.dir", true) == "rtl" ? '<link rel="stylesheet" href="//cdn.rawgit.com/morteza/bootstrap-rtl/master/dist/cdnjs/3.3.1/css/bootstrap-rtl.min.css">' : '') . '
				<style>
					' . $drawBackground . '
					' . $RtlCss . '
					header {margin-top: 70px;}
				</style>				
			</head>
			<body>
				<div class="container">				
					<header class="header">
						<div class="row">
							<div class="col-md-5 col-xs-12 ">
								<div class="thumbnail">
									<div class=" text-left">' . $drawLogo . '</div>
								</div>
							</div>
							<div class="col-md-5 col-xs-12 col-md-offset-2 text-right flip ">
								<h1>' . $drawInvoiceType . '</h1>
								<div class="row">
									<div class="col-md-8 col-md-offset-4 col-xs-12">
										<dl class="dl-horizontal">
											<dt>' . $drawInvoiceType . Language::_("HtmlInvoice.invoice_id_code", true) . '</dt>
											<dd>' . $drawInvoiceInfo['invoice_id'] . '</dd>
											<dt>' . Language::_("HtmlInvoice.client_id_code", true) . '</dt>
											<dd>' . $drawInvoiceInfo['client_id'] . '</dd>
											<dt>' . Language::_("HtmlInvoice.date_billed", true) . '</dt>
											<dd>' . $drawInvoiceInfo['date_billed'] . '</dd>
											<dt>' . Language::_("HtmlInvoice.date_due", true) . '</dt>
											<dd>' . $drawInvoiceInfo['date_due'] . '</dd>									
										</dl>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-5 col-xs-12 ">
								' . $drawReturnAddress . ' 
							</div>
							<div class="col-md-5 col-xs-12  col-md-offset-2 text-right">
								' . $drawAddress . '
							</div>
						</div>
						<!-- / end client details section -->
						<div class="row">
								<div class="col-xs-12 ">									
									' . ($PaymentBtn ? $payment_btn : "") . '
									' . ($EditBtn ? $edit_btn : "") . '
									' . ($PrintBtn ? $print_btn : "") . '
									' . ($DownloadBtn ? $download_btn : "") . '
									<p class="pull-right flip">							
										' . ($drawPaidWatermark ? $paid_watermark : $unpaid_watermark) . '									
									</p>									
								</div>
						</div>
						
					</header>
					<div class="content">						
						<table class="table table-hover table-bordered">
							<thead>
								<tr class="active">' . $drawLineHeader . '</tr>
							</thead>
							<tbody>
								' . $drawInvoice . '
							</tbody>
							<tfoot>
								<tr>
									<th rowspan="6" ></th>
									<th colspan="2" class="active text-right"><h4>' . Language::_("HtmlInvoice.subtotal_heading", true) . '</h4></th>
									<th class="active text-right"><h4>' . $SubTotals . '</h4></th>
								</tr>
								' . $taxe_line . '
								<tr>
									<th colspan="2" class="info text-right"><h4>' . Language::_("HtmlInvoice.total_heading", true) . '</h4></th>
									<th class="info text-right"><h4>' . $Totals . '</h4></th>
								</tr>							
							</tfoot>							
							
							
						</table>
						
						<div class="row">
							<div class="col-md-5 col-xs-12">
								' . $PublicNotes . '
							</div>
							<div class="col-md-7 col-xs-12">
								' . $drawPayments . '	
							</div>
						</div>
						
					</div>
					<footer class="footer">		
						' . ($drawTerms ? $draw_terms : "") . '
						' . $Footer . '
					</footer>
					<nav>
						<ul class="pager">
							<li><a href="' . $return_rl . '"><span aria-hidden="true">&larr;</span> ' . Language::_("HtmlInvoice.back", true) . '</a></li>
							<li><a href="' . $_SERVER['REQUEST_URI'] . '/pdf/">' . Language::_("HtmlInvoice.download_invoice", true) . '</a></li>
							<li><a href="#">' . Language::_("HtmlInvoice.close", true) . '</a></li>
						</ul>
					</nav>					
				</div>
				<!-- jQuery -->
				<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>				
				<!-- Latest compiled and minified JavaScript -->
				<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>						
			</body>
		</html>';
        return $content;
    }
Ejemplo n.º 3
0
 /**
  * Validates the given meta (settings) data to be updated for this gateway
  *
  * @param array $meta An array of meta (settings) data to be updated for this gateway
  * @return array The meta data to be updated in the database for this gateway, or reset into the form on failure
  */
 public function editSettings(array $meta)
 {
     // Verify meta data is valid
     $rules = array('key' => array('valid' => array('rule' => array("betweenLength", 16, 16), 'message' => Language::_("NonmerchantDemo.!error.key.valid", true))));
     $this->Input->setRules($rules);
     // Validate the given meta data to ensure it meets the requirements
     $this->Input->validates($meta);
     // Return the meta data, no changes required regardless of success or failure for this gateway
     return $meta;
 }
 private function getPackageRules($vars)
 {
     $rules = array('meta[package]' => array('valid' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("tastycpanel.error.package.package", true))), 'meta[type]' => array('valid' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("tastycpanel.error.package.type", true))));
     return $rules;
 }
 private function getRowRules(&$vars)
 {
     $rules = array('name' => array('valid' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("Digitaloceanmodule.error.row.name", true))), 'apiKey' => array('valid' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("Digitaloceanmodule.error.row.apiK_key", true))), 'apiKey' => array('valid_connection' => array('rule' => array(array($this, "validateConnection")), 'message' => Language::_("Digitaloceanmodule.error.row.connection", true))));
     return $rules;
 }
 /**
  * Edit FIle
  */
 public function delete()
 {
     $this->init();
     if (isset($this->post['file'])) {
         if (!file_exists($this->dir . $this->post['file'])) {
             $this->parent->setMessage("error", Language::_("CssJavascriptToolbox.!error.delete_file", true, $this->post['file']));
         } else {
             // Success
             $this->Toolbox->deleteFile($this->post['file']);
             $this->parent->flashMessage("message", Language::_("CssJavascriptToolbox.!success.delete_file", true, $this->post['file']));
             $this->redirect($this->base_uri . "settings/company/plugins/manage/" . $this->plugin_id . "/");
         }
     }
     $this->redirect($this->base_uri . "settings/company/plugins/manage/" . $this->plugin_id . "/");
 }
Ejemplo n.º 7
0
 private function actionsTab($package, $service, $client = false, array $get = null, array $post = null)
 {
     // Get the service fields
     $service_fields = $this->serviceFieldsToObject($service->fields);
     $module_row = $this->getModuleRow($package->module_row);
     $get_key = "3";
     if ($client) {
         $get_key = "2";
     }
     $result = null;
     $params = array();
     $command = "post";
     if (!empty($post)) {
         $path = "nodes/" . $service_fields->options['node'] . "/" . $service_fields->options['type'] . "/" . $service_fields->vmid . "/status/" . $post['action'];
         switch ($post['action']) {
             case "start":
                 $result = $this->SendCommand($module_row, $command, $path, $params);
                 if (empty($result)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 break;
             case "stop":
                 $result = $this->SendCommand($module_row, $command, $path, $params);
                 if (empty($result)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 break;
             case "shutdown":
                 $result = $this->SendCommand($module_row, $command, $path, $params);
                 if (empty($result)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 break;
             case "reboot":
                 // stop the vps
                 $path = "nodes/" . $service_fields->options['node'] . "/" . $service_fields->options['type'] . "/" . $service_fields->vmid . "/status/stop";
                 $result = $this->SendCommand($module_row, $command, $path, $params);
                 if (empty($result)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 // be sure that the vps is stopped
                 $finished = false;
                 while (!$finished) {
                     $task = $this->Task($module_row, $service_fields->options['node'], $result);
                     if ($task['status'] == "running") {
                         $finished = false;
                     } else {
                         $finished = true;
                     }
                     sleep(1);
                 }
                 // start the vps again
                 $path = "nodes/" . $service_fields->options['node'] . "/" . $service_fields->options['type'] . "/" . $service_fields->vmid . "/status/start";
                 $result = $this->SendCommand($module_row, $command, $path, $params);
                 if (empty($result)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 break;
             case "umount":
                 $result = $this->SendCommand($module_row, $command, $path, $params);
                 if (empty($result)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 break;
             case "hostname":
                 $params['hostname'] = $post['hostname'];
                 $path = "nodes/" . $service_fields->options['node'] . "/" . $service_fields->options['type'] . "/" . $service_fields->vmid . "/config";
                 $response = $this->SendCommand($module_row, "put", $path, $params);
                 if (empty($response)) {
                     $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action']))));
                 }
                 break;
                 // case "settings":
                 // unset($post['action']) ;
                 // $params = $post ;
                 // $path = "nodes/" . $service_fields->options['node'] . "/" . $service_fields->options['type'] . "/" . $service_fields->vmid . "/config";
                 // $response = $this->SendCommand($module_row , "put" , $path , $params);
                 // if(empty($response)){
                 // $this->Input->setErrors(array('api' => array('internal' => Language::_("Proxmoxv2.!error.api.internal.action", true, $post['action'] ))));
                 // }
                 // break;
         }
     }
     // Get the vps Status
     $vps = $this->SendCommand($module_row, "get", "nodes/" . $service_fields->options['node'] . "/" . $service_fields->options['type'] . "/" . $service_fields->vmid . "/status/current");
     return $vps;
 }
Ejemplo n.º 8
0
 /**
  * Renders the terms of this document
  */
 private function drawTerms()
 {
     $data = array(array(Language::_("PdfInvoice.terms_heading", true)), array($this->meta['terms']));
     $options = array('font_size' => self::$font_size_alt, 'border' => 0, 'x_pos' => 48, 'y_pos' => -119, 'col' => array(array('height' => 12)), 'row' => array(array('font_style' => "B")));
     $this->drawTable($data, $options);
 }
Ejemplo n.º 9
0
 /**
  * @param $request                  This contains the GET & POST requests as an Array
  * @param $dataRequest              This contains the package & service requests as an Array
  * @throws GoGetSSLAuthException
  * @return                          JSON of email Authorisation
  */
 public function emailAuthorisation($request, $dataRequest)
 {
     //parse our request
     $postRequest = $request['postRequest'];
     $getRequest = $request['getRequest'];
     //get service & packages
     $package = $dataRequest['package'];
     $service = $dataRequest['service'];
     $service_fields = $this->serviceFieldsToObject($service->fields);
     $domain = $service_fields->gogetssl_fqdn;
     $lib = $this->getLib();
     //@todo only want to store email_auth during swapping between CSR Generation & domain renew will save as services
     //@disabled for now due to https://github.com/lukesUbuntu/gogetsslv2/issues/1
     if (isset($_SESSION[$domain]['email_auth']) && !empty($_SESSION[$domain]['email_auth'])) {
         $lib->sendAjax($_SESSION[$domain]['email_auth']);
     }
     if (empty($domain)) {
         $lib->sendAjax("domain failed empty", false);
     }
     $row = $this->getModuleRow($package->module_row);
     $api = $this->api($row);
     $this->log($row->meta->api_username . "|ssl-domain-emails", serialize($domain), "input", true);
     $gogetssl_approver_emails = array();
     try {
         $response = $api->getDomainEmails($domain);
         $gogetssl_approver_emails = $this->parseResponse($response, $row);
     } catch (Exception $e) {
         // Error, invalid authorization
         $this->Input->setErrors(array('api' => array('internal' => Language::_("GoGetSSLv2.!error.api.internal", true))));
     }
     //error checking response
     if ($this->Input->errors()) {
         $lib->sendAjax($response, false);
     }
     $emails = array();
     if ($this->isComodoCert($api, $package) && isset($gogetssl_approver_emails['ComodoApprovalEmails'])) {
         $emails = $gogetssl_approver_emails['ComodoApprovalEmails'];
     } elseif (isset($gogetssl_approver_emails['GeotrustApprovalEmails'])) {
         $emails = $gogetssl_approver_emails['GeotrustApprovalEmails'];
     }
     $formatted_emails = array();
     foreach ($emails as $email) {
         $formatted_emails[$email] = $email;
     }
     $_SESSION[$domain]['email_auth'] = $formatted_emails;
     $lib->sendAjax($formatted_emails);
 }
Ejemplo n.º 10
0
    private function drawPayments()
    {
        if (!empty($this->meta['display_payments']) && $this->meta['display_payments'] == "true") {
            // Set the payment rows
            $rows = array();
            $payment = '';
            for ($i = 0; $i < count($this->invoice->applied_transactions); $i++) {
                // Only show approved transactions
                if ($this->invoice->applied_transactions[$i]->status != "approved") {
                    continue;
                }
                $rows[] = array('applied_date' => $this->Date->cast($this->invoice->applied_transactions[$i]->applied_date, $this->invoice->client->settings['date_format']), 'type_name' => $this->invoice->applied_transactions[$i]->type_real_name, 'transaction_id' => $this->invoice->applied_transactions[$i]->transaction_id, 'applied_amount' => $this->CurrencyFormat->format($this->invoice->applied_transactions[$i]->applied_amount, $this->invoice->applied_transactions[$i]->currency, self::$standard_num_options));
            }
            // Don't draw the table if there are no payments
            if (empty($rows)) {
                return "";
            }
            foreach ($rows as $item) {
                $payment .= '
				<tr>
					<th>' . $item['applied_date'] . '</th>
					<th>' . $item['type_name'] . '</th>
					<th>' . $item['transaction_id'] . '</th>
					<th class="text-right">' . $item['applied_amount'] . '</th>			
				</tr>';
            }
            // Set balance due at bottom of table
            $class = $this->invoice->due == "0" ? "" : "danger";
            $balance = '
				<tr >
					<th colspan="3" class="text-right" >' . Language::_("HtmlInvoice.balance_heading", true) . '</th>
					<th class="' . $class . ' text-right">' . $this->CurrencyFormat->format($this->invoice->due, $this->invoice->currency) . '</th>			
				</tr>';
            $buffer = '	
			<div class="panel panel-success">
				<div class="panel-heading">
					' . Language::_("HtmlInvoice.payments_heading", true) . '
				</div>
				<div class="panel-body">
					<table class="table table-hover table-bordered table-condensed ">
						<thead>
							<tr>
								<th>' . Language::_("HtmlInvoice.payments_applied_date", true) . '</th>
								<th>' . Language::_("HtmlInvoice.payments_type_name", true) . '</th>
								<th>' . Language::_("HtmlInvoice.payments_transaction_id", true) . '</th>
								<th>' . Language::_("HtmlInvoice.payments_applied_amount", true) . '</th>
							</tr>
						</thead>
						<tbody>
							' . $payment . '
						</tbody>
						<tfoot>
							' . $balance . '
						</tfoot>
					</table>	
				</div>
			</div>';
            return $buffer;
        }
    }
Ejemplo n.º 11
0
 /**
  * Returns the name of this invoice PDF template
  */
 public function getName()
 {
     return Language::_("HtmlInvoice.name", true);
 }
Ejemplo n.º 12
0
 /**
  * Validates the given meta (settings) data to be updated for this gateway
  *
  * @param array $meta An array of meta (settings) data to be updated for this gateway
  * @return array The meta data to be updated in the database for this gateway, or reset into the form on failure
  */
 public function editSettings(array $meta)
 {
     // Verify meta data is valid
     $rules = array('project_key' => array('empty' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("Paymentwall.!error.project_key.valid", true), 'post_format' => 'trim')), 'secret_key' => array('empty' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("Paymentwall.!error.secret_key.valid", true), 'post_format' => 'trim')), 'widget_code' => array('empty' => array('rule' => "isEmpty", 'negate' => true, 'message' => Language::_("Paymentwall.!error.widget_code.valid", true), 'post_format' => 'trim')), 'test_mode' => array('valid' => array('rule' => array("in_array", array('true', 'false')), 'message' => Language::_("Paymentwall.!error.test_mode.valid", true))));
     // Set checkbox if not set
     if (!isset($meta['test_mode'])) {
         $meta['test_mode'] = "false";
     }
     $this->Input->setRules($rules);
     // Validate the given meta data to ensure it meets the requirements
     $this->Input->validates($meta);
     // Return the meta data, no changes required regardless of success or failure for this gateway
     return $meta;
 }
Ejemplo n.º 13
0
    /**
     * Allow you to manage and create your backups.
     *
     * @param type $package
     * @param type $service
     * @param array $vars
     * @param array $post
     */
    public function backups($package, $service, array $get = null, array $post = null, array $files = null)
    {
        if (isset($get[2])) {
            if ($get[2] === "addnew") {
                if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                    $this->view = new View("backups", "default");
                    $this->view->setDefaultView("components" . DS . "modules" . DS . "cpanelextended" . DS);
                    $view_dir = str_replace('client/', '', $this->base_uri) . $this->view->view_path . 'views/' . $this->view->view . '/';
                    Loader::loadHelpers($this, array("Form", "Html"));
                    $fields = $this->serviceFieldsToObject($service->fields);
                    $row = $this->getModuleRow();
                    $api = $this->getApiByMeta($row->meta, $fields);
                    if (isset($post) && !empty($post)) {
                        if ($post['dest'] !== "") {
                            $input = array("dest" => $post['dest'], "server" => $post['server'], "user" => $post['user'], "pass" => $post['pass'], "email" => $post['email'], "port" => $post['port'], "rdir" => $post['rdir']);
                            if ($post['dest'] !== "homedir") {
                                if ($post['server'] !== "" && $post['user'] !== "" && $post['pass'] !== "" && $post['port'] !== "" && $post['rdir'] !== "") {
                                    Loader::loadModels($this, array("Services"));
                                    $add_new = $api->sendApi1Request("Fileman", "fullbackup", $input);
                                    $this->log($row->meta->host_name . "|Generate New Backup", serialize("fullbackup"), "input", true);
                                    echo "<div class='alert alert-success alert-dismissable' style='margin-top: 0px;'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>" . Language::_("Cpe.misc.success", true) . "</p>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>";
                                } else {
                                    $error = array(0 => array("result" => Language::_("Cpe.!error.api.internal", true)));
                                    echo "<div class='alert alert-danger alert-dismissable' style='margin-top: 0px;'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>{$error[0]['result']}</p>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>";
                                }
                            } else {
                                Loader::loadModels($this, array("Services"));
                                $add_new = $api->sendApi1Request("Fileman", "fullbackup", $input);
                                $this->log($row->meta->host_name . "|Generate New Backup", serialize("fullbackup"), "input", true);
                                echo "<div class='alert alert-success alert-dismissable' style='margin-top: 0px;'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>" . Language::_("Cpe.misc.success", true) . "</p>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>";
                            }
                        } else {
                            $error = array(0 => array("result" => Language::_("Cpe.!error.api.internal", true)));
                            echo "<div class='alert alert-danger alert-dismissable' style='margin-top: 0px;'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>{$error[0]['result']}</p>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>";
                        }
                    } else {
                        $this->Form->create("", array('onsubmit' => 'return false', 'id' => 'addform', 'autocomplete' => "off"));
                        echo "\n\t\t\t\t\t\t\t\t<script type='text/javascript' src='" . $view_dir . "javascript/main.js'></script>\n\t\t\t\t\t\t\t\t<div class='modal-body'>\n\t\t\t\t\t\t\t\t<div class='div_response'></div>";
                        echo '<div class="form-group">
								   <label>' . Language::_("Cpe.label.email", true) . '</label>
								    <input type="email" class="form-control" value="" id="email" name="email" placeholder=""></div>
								<div class="form-group">
								   <label>' . Language::_("Cpe.label.destination", true) . '</label>
								<select name="dest" id="dest" class="form-control">
								                <option value="homedir" selected="selected">Home Directory</option>
								                <option value="ftp">Remote FTP Server</option>
								                <option value="passiveftp">Remote FTP Server (passive mode transfer):</option>
								                <option value="scp">Secure Copy (SCP)</option>
								</select>
								</div>
								<div id="access_data" style="display:none;">
								<div class="form-group">
								   <label>' . Language::_("Cpe.service_info.server", true) . '</label>
								    <input type="text" class="form-control" value="" id="server" name="server" placeholder=""></div>
								<div class="form-group">
								   <label>' . Language::_("Cpe.label.username", true) . '</label>
								    <input type="text" class="form-control" value="" id="user" name="user" placeholder=""></div>
								<div class="form-group">
								   <label>' . Language::_("Cpe.label.password", true) . '</label>
								    <input type="password" class="form-control" value="" id="pass" name="pass" placeholder=""></div>
								<div class="form-group">
								   <label>' . Language::_("Cpe.label.port", true) . '</label>
								    <input type="text" class="form-control" value="" id="port" name="port" placeholder=""></div>
								<div class="form-group">
								   <label>' . Language::_("Cpe.label.directory", true) . '</label>
								    <input type="text" class="form-control" value="" id="rdir" name="rdir" placeholder=""></div>
								</div>
								</div>
								<div class="modal-footer">
								<button type="button" name="cancel" class="btn btn-default" data-dismiss="modal"><i class="fa fa-ban"></i> ' . Language::_("Cpe.label.close", true) . '</button>
								<button type="button" class="btn btn-primary" name="add_new" id="addnewsubmit"><i class="fa fa-plus-circle"></i> ' . Language::_("Cpe.label.generate_backup", true) . '</button>
								</div>

								<script type="text/javascript">
								    $(document).ready(function() {
								        $("#addnewsubmit").click(function () {
								    var form = $("#addform").serialize();
								    doAjaxPost("' . $this->base_uri . "services/manage/" . $service->id . "/backups/addnew/?" . '"+ form, form);
								        });
								        $("#dest").change(function () {
								        if($(this).val() !== "homedir"){
								    $("#access_data").css("display","block");
								    } else {
								    $("#access_data").css("display","none");
								    }
								        });
								    });
								</script>';
                        $this->Form->end();
                    }
                    exit;
                }
            }
        } else {
            $this->view = new View("backups", "default");
            $this->view->base_uri = $this->base_uri;
            Loader::loadHelpers($this, array("Form", "Html"));
            $fields = $this->serviceFieldsToObject($service->fields);
            $row = $this->getModuleRow();
            $api = $this->getApiByMeta($row->meta, $fields);
            $backups_list = $api->sendApi2Request("Backups", "listfullbackups")->getResponse();
            $this->view->set("module_row", $row);
            $this->view->set("service_fields", $fields);
            $this->view->set("backups_list", $backups_list->cpanelresult->data);
            $this->view->set("type", $package->meta->type);
            $this->view->set("service_id", $service->id);
            $this->view->setDefaultView("components" . DS . "modules" . DS . "cpanelextended" . DS);
            return $this->view->fetch();
        }
    }
Ejemplo n.º 14
0
 /**
  * Builds and retrieves a list of common cron settings
  *
  * @return array A list of nested common cron settings
  */
 private function getCommonCronSettings()
 {
     if (!isset($this->Date)) {
         Loader::loadHelpers($this, array("Date"));
     }
     $all = array('--' => Language::_("Cpe.cron.commonsettings", true), '* * * * *' => Language::_("Cpe.cron.everyminute", true), '*/5 * * * *' => Language::_("Cpe.cron.everyfive", true), '0,30 * * * *' => Language::_("Cpe.cron.twicehour", true), '0 * * * *' => Language::_("Cpe.cron.oncehour", true), '0 0,12 * * *' => Language::_("Cpe.cron.twiceday", true), '0 0 * * *' => Language::_("Cpe.cron.onceday", true), '0 0 * * 0' => Language::_("Cpe.cron.onceweek", true), '0 0 1,15 * *' => Language::_("Cpe.cron.firstand15th", true), '0 0 1 * *' => Language::_("Cpe.cron.oncemonth", true), '0 0 1 1 *' => Language::_("Cpe.cron.onceyear", true));
     $minute = array('--' => Language::_("Cpe.cron.commonsettings", true), '*' => Language::_("Cpe.cron.minute.everyminute", true), '*/2' => Language::_("Cpe.cron.minute.otherminute", true), '*/5' => Language::_("Cpe.cron.minute.everyfive", true), '*/10' => Language::_("Cpe.cron.minute.everyten", true), '*/15' => Language::_("Cpe.cron.minute.every15", true), '0,30' => Language::_("Cpe.cron.minute.every30", true), '' => Language::_("Cpe.cron.minute.minutes", true));
     for ($i = 0; $i < 60; $i++) {
         $label = "";
         if ($i % 15 == 0) {
             if ($i == 0) {
                 $label = Language::_("Cpe.cron.minute.top", true);
             } elseif ($i == 15) {
                 $label = Language::_("Cpe.cron.minute.quarterpast", true);
             } elseif ($i == 30) {
                 $label = Language::_("Cpe.cron.minute.halfpast", true);
             } elseif ($i == 45) {
                 $label = Language::_("Cpe.cron.minute.quartertil", true);
             }
         }
         $minute[$i] = Language::_("Cpe.cron.minute.label", true, str_pad($i, 2, "0", STR_PAD_LEFT), $label, $i);
     }
     $hour = array('--' => Language::_("Cpe.cron.commonsettings", true), '*' => Language::_("Cpe.cron.hour.everyhour", true), '*/2' => Language::_("Cpe.cron.hour.otherhour", true), '*/3' => Language::_("Cpe.cron.hour.everythree", true), '*/4' => Language::_("Cpe.cron.hour.everyfour", true), '*/6' => Language::_("Cpe.cron.hour.everysix", true), '0,12' => Language::_("Cpe.cron.hour.everytwelve", true), '' => Language::_("Cpe.cron.hour.hours", true));
     for ($i = 0; $i < 24; $i++) {
         $hour[$i] = Language::_("Cpe.cron.hour.label", true, $this->Date->cast(str_pad($i, 2, "0", STR_PAD_LEFT) . ":00:00", "g:i A"), $i == 0 ? "midnight" : ($i == 12 ? "noon" : ""), $i);
     }
     $day = array('--' => Language::_("Cpe.cron.commonsettings", true), '*' => Language::_("Cpe.cron.day.everyday", true), '*/2' => Language::_("Cpe.cron.day.everyother", true), '1,15' => Language::_("Cpe.cron.day.twicemonth", true), '' => Language::_("Cpe.cron.day.days", true));
     for ($i = 1; $i <= 31; $i++) {
         $ordinal = "th";
         if ($i % 10 == 1 && substr($i, -2, 2) != "11") {
             $ordinal = "st";
         } elseif ($i % 10 == 2 && substr($i, -2, 2) != "12") {
             $ordinal = "nd";
         } elseif ($i % 10 == 3 && substr($i, -2, 2) != "13") {
             $ordinal = "rd";
         }
         $day[$i] = Language::_("Cpe.cron.day.label", true, $i, $ordinal);
     }
     $month = array('--' => Language::_("Cpe.cron.commonsettings", true), '*' => Language::_("Cpe.cron.month.everymonth", true), '*/2' => Language::_("Cpe.cron.month.everyother", true), '*/4' => Language::_("Cpe.cron.month.everythree", true), '1,7' => Language::_("Cpe.cron.month.everysix", true), '' => Language::_("Cpe.cron.month.months", true));
     $months = $this->Date->getMonths(1, 12, "n", "F");
     for ($i = 1; $i <= 12; $i++) {
         $month[$i] = Language::_("Cpe.cron.month.month", true, isset($months[$i]) ? $months[$i] : "", $i);
     }
     $week_day = array('--' => Language::_("Cpe.cron.commonsettings", true), '*' => Language::_("Cpe.cron.weekday.everyday", true), '1-5' => Language::_("Cpe.cron.weekday.monfri", true), '0,6' => Language::_("Cpe.cron.weekday.weekend", true), '1,3,5' => Language::_("Cpe.cron.weekday.monwedfri", true), '2,4' => Language::_("Cpe.cron.weekday.tuethu", true), '' => Language::_("Cpe.cron.weekday.weekday", true));
     $days = array(0 => Language::_("Cpe.sunday", true), 1 => Language::_("Cpe.monday", true), 2 => Language::_("Cpe.tuesday", true), 3 => Language::_("Cpe.wednesday", true), 4 => Language::_("Cpe.thursday", true), 5 => Language::_("Cpe.friday", true), 6 => Language::_("Cpe.saturday", true));
     for ($i = 0; $i < 7; $i++) {
         $week_day[$i] = Language::_("Cpe.cron.weekday.label", true, $days[$i], $i);
     }
     return array('all' => $all, 'minute' => $minute, 'hour' => $hour, 'day' => $day, 'month' => $month, 'weekday' => $week_day);
 }