public function getClientServiceInfo($service, $package) { $row = $this->getModuleRow($package->module_row); $this->view = new View("client_service_info", "default"); $this->view->base_uri = $this->base_uri; $this->view->setDefaultView("components" . DS . "modules" . DS . "tastycpanelmodule" . DS); Loader::loadHelpers($this, array("Form", "Html")); $this->view->set("module_row", $row); $this->view->set("package", $package); $this->view->set("service", $service); $this->view->set("service_fields", $this->serviceFieldsToObject($service->fields)); return $this->view->fetch(); }
/** * Returns all HTML markup required to render an authorization and capture payment form * * @param array $contact_info An array of contact info including: * - id The contact ID * - client_id The ID of the client this contact belongs to * - user_id The user ID this contact belongs to (if any) * - contact_type The type of contact * - contact_type_id The ID of the contact type * - first_name The first name on the contact * - last_name The last name on the contact * - title The title of the contact * - company The company name of the contact * - address1 The address 1 line of the contact * - address2 The address 2 line of the contact * - city The city of the contact * - state An array of state info including: * - code The 2 or 3-character state code * - name The local name of the country * - country An array of country info including: * - alpha2 The 2-character country code * - alpha3 The 3-cahracter country code * - name The english name of the country * - alt_name The local name of the country * - zip The zip/postal code of the contact * @param float $amount The amount to charge this contact * @param array $invoice_amounts An array of invoices, each containing: * - id The ID of the invoice being processed * - amount The amount being processed for this invoice (which is included in $amount) * @param array $options An array of options including: * - description The Description of the charge * - return_url The URL to redirect users to after a successful payment * - recur An array of recurring info including: * - amount The amount to recur * - term The term to recur * - period The recurring period (day, week, month, year, onetime) used in conjunction with term in order to determine the next recurring payment * @return string HTML markup required to render an authorization and capture payment form */ public function buildProcess(array $contact_info, $amount, array $invoice_amounts = null, array $options = null) { $this->view = $this->makeView("process", "default", str_replace(ROOTWEBDIR, "", dirname(__FILE__) . DS)); // Load the helpers required for this view Loader::loadHelpers($this, array("Form", "Html")); $fields = array(); $post_to = ""; # # TODO: Define all form fields and the $post_to fields # $this->view->set("post_to", $post_to); $this->view->set("fields", $fields); return $this->view->fetch(); }
/** * Registers Ladybug_Autoloader as an SPL autoloader. * @static */ public static function register() { ini_set('unserialize_callback_func', 'spl_autoload_call'); spl_autoload_register(array(new self(), 'autoload')); Loader::loadHelpers(); }
public function getAdminEditFields($package, $vars = null) { Loader::loadHelpers($this, array("Html")); $fields = new ModuleFields(); $domain = $fields->label(Language::_("Digitaloceanmodule.hostname", true), "hostname"); $domain->attach($fields->fieldText("hostname", $this->Html->ifSet($vars->hostname, $this->Html->ifSet($vars->hostname)), array('id' => "hostname"))); $fields->setField($domain); return $fields; }
/** * Create and return the view content required to modify the settings of this gateway * * @param array $meta An array of meta (settings) data belonging to this gateway * @return string HTML content containing the fields to update the meta data for this gateway */ public function getSettings(array $meta = null) { $this->view = $this->makeView("settings", "default", str_replace(ROOTWEBDIR, "", dirname(__FILE__) . DS)); // Load the helpers required for this view Loader::loadHelpers($this, array("Form", "Html")); $this->view->set("meta", $meta); return $this->view->fetch(); }
/** * Tab Console * * /DONE/ */ public function tabConsole($package, $service, array $get = null, array $post = null) { $this->view = new View("tab_console", "default"); $this->view->base_uri = $this->base_uri; // Load the helpers required for this view Loader::loadHelpers($this, array("Form", "Html")); $this->view->set("view", $this->view->view); $this->view->setDefaultView("components" . DS . "modules" . DS . "proxmoxv2" . DS); return $this->view->fetch(); }
/** * @name generateCSR Generates a CSR request and passes back as json * @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 generateCSR($request, $dataRequest) { //load our helpers Loader::loadHelpers($this, array("Html")); //load models Loader::loadModels($this, array("Services")); //load our lib $lib = $this->getLib(); //pass our requests $postRequest = $request['postRequest']; $getRequest = $request['getRequest']; //set our packages and services $package = $dataRequest['package']; $service = $dataRequest['service']; //get service_fields $service_fields = $this->serviceFieldsToObject($service->fields); $requires = array("gogetssl_csr_fqdn", "gogetssl_csr_country", "gogetssl_csr_state", "gogetssl_csr_locality", "gogetssl_csr_organization", "gogetssl_csr_organization_unit", "gogetssl_csr_email"); $cert_details = $lib->getRequests($getRequest, $requires); //if any of our fields failed check if they are manditory fields /* if ($cert_details['failed'] != false){ $response['fields'] = $cert_details['failed']; $response['message'] = "missing or empty fields"; $lib->sendAjax($response,false); } */ //we can use generate ourselfs or use API $row = $this->getModuleRow($package->module_row); $api = $this->api($row); //@issue gossl sandbox does not support SHA2 for some reason $SHA = $row->meta->sandbox == "true" ? "SHA1" : "SHA2"; $data = array("csr_commonname" => $cert_details['gogetssl_csr_fqdn'], "csr_organization" => $lib->ifSet($cert_details['gogetssl_csr_organization'], "NA"), "csr_department" => $lib->ifSet($cert_details['gogetssl_csr_organization_unit'], "NA"), "csr_city" => $lib->ifSet($cert_details['gogetssl_csr_locality'], "NA"), "csr_state" => $lib->ifSet($cert_details['gogetssl_csr_state'], "NA"), "csr_country" => $lib->ifSet($cert_details['gogetssl_csr_country'], "NA"), "csr_email" => $cert_details['gogetssl_csr_email'], "signature_hash" => "SHA1"); //generate CSR $response = $api->generateCSR($data); //pass hash used $response['hash'] = $SHA; //catch the error as we may have already generated CSR with gogetssl if (isset($response['error']) && $response['error'] == true) { //if we have already generated CSR details we will retrieve this if ($response['message'] == 'CSR Exist') { if (preg_match('/CSR ID is: .(\\d+)./', $response['description'], $matches)) { $csr_id = $matches[1]; $response = $api->getCSR($csr_id, $cert_details['gogetssl_csr_fqdn']); } } else { //we have a different error lets pass back $lib->sendAjax($response, false); } } //we will end up here with a valid response->csr_code //Update our gogetssl_csr records. $csr_update = array("gogetssl_csr" => $this->Html->ifSet($response['csr_code'])); //update our csr code $service_fields_update = $this->ourServiceFields($lib->serviceFieldMerge($service_fields, $csr_update), $service_fields->gogetssl_orderid); $this->Services->setFields($service->id, $service_fields_update); $lib->sendAjax($response); }
public function getClientServiceInfo($service, $package) { $row = $this->getModuleRow($package->module_row); // Load the view into this object, so helpers can be automatically added to the view $this->view = new View("client_service_info", "default"); $this->view->base_uri = $this->base_uri; $this->view->setDefaultView("components" . DS . "modules" . DS . "tastyinterworxmodule" . DS); // Load the helpers required for this view Loader::loadHelpers($this, array("Form", "Html")); $this->view->set("module_row", $row); $this->view->set("package", $package); $this->view->set("service", $service); $this->view->set("service_fields", $this->serviceFieldsToObject($service->fields)); return $this->view->fetch(); }
/** * @param $response */ private function processTransaction($response) { $transaction_id = ''; // If a response was given, record the transaction if (is_array($response)) { Loader::loadModels($this, array('Transactions', 'Clients', 'Companies', 'Emails')); Loader::loadHelpers($this, array('Date', 'CurrencyFormat')); $trans_data = array('client_id' => $response['client_id'], 'amount' => $response['amount'], 'currency' => $response['currency'], 'type' => "other", 'gateway_id' => $response['gateway_id'], 'transaction_id' => isset($response['transaction_id']) ? $response['transaction_id'] : null, 'reference_id' => isset($response['reference_id']) ? $response['reference_id'] : null, 'parent_transaction_id' => isset($response['parent_transaction_id']) ? $response['parent_transaction_id'] : null, 'status' => $response['status']); // If the transaction exists, update it if ($trans_data['transaction_id'] && ($transaction = $this->Transactions->getByTransactionId($trans_data['transaction_id'], null, $response['gateway_id']))) { // Don't update client_id to prevent transaction from being reassigned unset($trans_data['client_id']); $this->Transactions->edit($transaction->id, $trans_data); $transaction_id = $transaction->id; } else { $transaction_id = $this->Transactions->add($trans_data); } } elseif ($errors = $this->errors()) { $this->Input->setErrors($errors); die('Transaction invalid!'); } // Set any errors with adding the transaction if ($errors = $this->Transactions->errors()) { $this->Input->setErrors($errors); die('Cannot process transaction #' . $transaction_id); } else { // Apply the transaction to the invoices given (if any) if (isset($response['invoices']) && is_array($response['invoices'])) { // Format invoices into something suitable for Transactions::apply() foreach ($response['invoices'] as &$invoice) { $invoice['invoice_id'] = $invoice['id']; unset($invoice['id']); } if (!empty($response['invoices']) && $response['status'] == "approved") { $this->Transactions->apply($transaction_id, array('amounts' => $response['invoices'])); } } $transaction = $this->Transactions->get($transaction_id); // Send an email regarding the non-merchant payment received if (isset($response['status']) && isset($response['client_id']) && $response['status'] == "approved" && $transaction && ($client = $this->Clients->get($response['client_id']))) { // Set date helper info $this->Date->setTimezone("UTC", Configure::get("Blesta.company_timezone")); $this->Date->setFormats(array('date_time' => $this->Companies->getSetting($response['company_id'], "datetime_format")->value)); $amount = $this->CurrencyFormat->format($transaction->amount, $transaction->currency); $tags = array('contact' => $client, 'transaction' => $transaction, 'date_added' => $this->Date->cast($transaction->date_added, "date_time")); $this->Emails->send("payment_nonmerchant_approved", $response['company_id'], $client->settings['language'], $client->email, $tags, null, null, null, array('to_client_id' => $client->id)); } die('OK'); } }
/** * 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(); } }
/** * 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); }