diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index dcb9ba090..abe6f467d 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -14,13 +14,6 @@ require_once CONFIG_PATH . "constants.php"; Logging::setLogPath(LIBRETIME_LOG_DIR . '/zendphp.log'); -// We need to manually route because we can't load Zend without the database being initialized first. -if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) { - $provisioningHelper = new ProvisioningHelper($CC_CONFIG["apiKey"][0]); - $provisioningHelper->createAction(); - die(); -} - Zend_Session::setOptions(array('strict' => true)); Config::setAirtimeVersion(); require_once (CONFIG_PATH . 'navigation.php'); @@ -29,7 +22,6 @@ Zend_Validate::setDefaultNamespaces("Zend"); $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new RabbitMqPlugin()); -$front->registerPlugin(new Zend_Controller_Plugin_ConversionTracking()); $front->throwExceptions(false); /* The bootstrap class should only be used to initialize actions that return a view. diff --git a/airtime_mvc/application/common/Billing.php b/airtime_mvc/application/common/Billing.php deleted file mode 100644 index 18648f0bc..000000000 --- a/airtime_mvc/application/common/Billing.php +++ /dev/null @@ -1,439 +0,0 @@ - array( - "bandwidth_limit" => 3298534883328 - ), - "hobbyist" => array( - "bandwidth_limit" => 1099511627776 - ), - "starter" => array( - "bandwidth_limit" => 3298534883328 - ), - "starter2" => array( - "bandwidth_limit" => 3298534883328 - ), - "plus" => array( - "bandwidth_limit" => 10995116277760 - ), - "plus2" => array( - "bandwidth_limit" => 10995116277760 - ), - "premium" => array( - "bandwidth_limit" => 43980465111040 - ), - "premium2" => array( - "bandwidth_limit" => 43980465111040 - ), - "enterprise" => array( - "bandwidth_limit" => 164926744166400 - ), - "complimentary" => array( - "bandwidth_limit" => 32985348833280 - ), - "sida" => array( - "bandwidth_limit" => 32985348833280 - ), - "custom" => array( - "bandwidth_limit" => 10995116277760 - ), - "awesome-hobbyist-2015" => array( - "bandwidth_limit" => 1099511627776 - ), - "awesome-starter-2015" => array( - "bandwidth_limit" => 3298534883328 - ), - "awesome-plus-2015" => array( - "bandwidth_limit" => 10995116277760 - ), - "awesome-premium-2015" => array( - "bandwidth_limit" => 43980465111040 - ), - ); - - public static function getAPICredentials() - { - return array( - "username" => $_SERVER["WHMCS_USERNAME"], - "password" => $_SERVER["WHMCS_PASSWORD"], - "url" => "https://account.sourcefabric.com/includes/api.php?accesskey=".$_SERVER["WHMCS_ACCESS_KEY"], - ); - } - - /** Get the Airtime instance ID of the instance the customer is currently viewing. */ - public static function getClientInstanceId() - { - //$currentProduct = Billing::getClientCurrentAirtimeProduct(); - //return $currentProduct["id"]; - //XXX: Major hack attack. Since this function gets called often, rather than querying WHMCS - // we're just going to extract it from airtime.conf since it's the same as the rabbitmq username. - $CC_CONFIG = Config::getConfig(); - $instanceId = $CC_CONFIG['rabbitmq']['user']; - if (!is_numeric($instanceId)) { - throw new Exception("Invalid instance id in " . __FUNCTION__ . ": " . $instanceId); - } - return $instanceId; - } - - public static function getProducts() - { - //Making this static to cache the products during a single HTTP request. - //This saves us roundtrips to WHMCS if getProducts() is called multiple times. - static $products = array(); - if (!empty($products)) - { - return $products; - } - - $credentials = self::getAPICredentials(); - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "getproducts"; - $postfields["responsetype"] = "json"; - //gid is the Airtime product group id on whmcs - $postfields["gid"] = WHMCS_AIRTIME_GROUP_ID; - - $query_string = ""; - foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - $result = self::makeRequest($credentials["url"], $query_string); - //Logging::info($result["products"]["product"]); - $products = $result["products"]["product"]; - - //Blacklist all free plans - //Hide the promo plans - we will tell the user if they are eligible for a promo plan - foreach ($products as $k => $p) { - if ($p["paytype"] === "free" || strpos($p["name"], "Awesome August 2015") !== false) - { - unset($products[$k]); - } - } - - return $products; - } - - public static function getProductPricesAndTypes() - { - $products = Billing::getProducts(); - $productPrices = array(); - $productTypes = array(); - - foreach ($products as $k => $p) { - $productPrices[$p["name"]] = array( - "monthly" => $p["pricing"]["USD"]["monthly"], - "annually" => $p["pricing"]["USD"]["annually"] - ); - $productTypes[$p["pid"]] = $p["name"] . " ($" . $productPrices[$p['name']]['monthly'] . "/mo)"; - } - return array($productPrices, $productTypes); - } - - /** Get the plan (or product in WHMCS lingo) that the customer is currently on. - * @return An associative array containing the fields for the product - * */ - public static function getClientCurrentAirtimeProduct() - { - static $airtimeProduct = null; - //Ghetto caching to avoid multiple round trips to WHMCS - if ($airtimeProduct) { - return $airtimeProduct; - } - $credentials = self::getAPICredentials(); - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "getclientsproducts"; - $postfields["responsetype"] = "json"; - $postfields["clientid"] = Application_Model_Preference::GetClientId(); - - $query_string = ""; - foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - $result = self::makeRequest($credentials["url"], $query_string); - - //XXX: Debugging / local testing - if ($_SERVER['SERVER_NAME'] == "localhost") { - $_SERVER['SERVER_NAME'] = "bananas.airtime.pro"; - } - - //This code must run on airtime.pro for it to work... it's trying to match - //the server's hostname with the client subdomain. Once it finds a match - //between the product and the server's hostname/subdomain, then it - //returns the ID of that product (aka. the service ID of an Airtime instance) - foreach ($result["products"]["product"] as $product) - { - if (strpos($product["groupname"], "Airtime") === FALSE) - { - //Ignore non-Airtime products - continue; - } - else - { - if ($product["status"] === "Active" || - $product["status"] === "Suspended") { - $airtimeProduct = $product; - $subdomain = ''; - - foreach ($airtimeProduct['customfields']['customfield'] as $customField) { - if ($customField['name'] === SUBDOMAIN_WHMCS_CUSTOM_FIELD_NAME) { - $subdomain = $customField['value']; - if (($subdomain . ".airtime.pro") === $_SERVER['SERVER_NAME']) { - return $airtimeProduct; - } - } - } - } - } - } - throw new Exception("Unable to match subdomain to a service ID"); - } - - public static function getClientDetails() - { - try { - $credentials = self::getAPICredentials(); - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "getclientsdetails"; - $postfields["stats"] = true; - $postfields["clientid"] = Application_Model_Preference::GetClientId(); - $postfields["responsetype"] = "json"; - - $query_string = ""; - foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - $arr = self::makeRequest($credentials["url"], $query_string); - return $arr["client"]; - } catch (Exception $e) { - Logging::info($e->getMessage()); - } - return array(); - } - - public static function makeRequest($url, $query_string) { - try { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); //Aggressive 5 second timeout - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - $jsondata = curl_exec($ch); - if (curl_error($ch)) { - //die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); - throw new Exception("WHMCS server down or invalid request."); - } - curl_close($ch); - - return json_decode($jsondata, true); - } catch (Exception $e) { - Logging::info($e->getMessage()); - } - return array(); - } - - public static function ensureClientIdIsValid() - { - if (Application_Model_Preference::GetClientId() == null) - { - throw new Exception("Invalid client ID: " . Application_Model_Preference::GetClientId()); - } - } - - - /** - * @return True if VAT should be applied to the order, false otherwise. - */ - public static function checkIfVatShouldBeApplied($vatNumber, $countryCode) - { - if ($countryCode === 'UK') { - $countryCode = 'GB'; //VIES database has it as GB - } - //We don't charge you VAT if you're not in the EU - if (!Billing::isCountryInEU($countryCode)) - { - return false; - } - - //So by here, we know you're in the EU. - - //No VAT number? Then we charge you VAT. - if (empty($vatNumber)) { - return true; - } - //Check if VAT number is valid - return Billing::validateVATNumber($vatNumber, $countryCode); - } - - public static function isCountryInEU($countryCode) - { - $euCountryCodes = array('BE', 'BG', 'CZ', 'DK', 'DE', 'EE', 'IE', 'EL', 'ES', 'FR', - 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT', 'NL', 'AT', - 'PL', 'PT', 'RO', 'SI', 'SK', 'FI', 'SE', 'UK', 'GB'); - - if (!in_array($countryCode, $euCountryCodes)) { - return false; - } - return true; - } - - /** - * Check if an EU VAT number is valid, using the EU VIES validation web API. - * - * @param string $vatNumber - A VAT identifier (number), with or without the two letter country code at the - * start (either one works) . - * @param string $countryCode - A two letter country code - * @return boolean true if the VAT number is valid, false otherwise. - */ - public static function validateVATNumber($vatNumber, $countryCode) - { - $vatNumber = str_replace(array(' ', '.', '-', ',', ', '), '', trim($vatNumber)); - - //If the first two letters are a country code, use that as the country code and remove those letters. - $firstTwoCharacters = substr($vatNumber, 0, 2); - if (preg_match("/[a-zA-Z][a-zA-Z]/", $firstTwoCharacters) === 1) { - $countryCode = strtoupper($firstTwoCharacters); //The country code from the VAT number overrides your country. - $vatNumber = substr($vatNumber, 2); - } - $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"); - - if($client){ - $params = array('countryCode' => $countryCode, 'vatNumber' => $vatNumber); - try{ - $r = $client->checkVat($params); - if($r->valid == true){ - // VAT-ID is valid - return true; - } else { - // VAT-ID is NOT valid - return false; - } - } catch(SoapFault $e) { - Logging::error('VIES EU VAT validation error: '.$e->faultstring); - if ($e->faultstring == "INVALID_INPUT") { - return false; - } - //If there was another error with the VAT validation service, we allow - //the VAT number to pass. (eg. SERVER_BUSY, MS_UNAVAILABLE, TIMEOUT, SERVICE_UNAVAILABLE) - return true; - } - } else { - // Connection to host not possible, europe.eu down? - Logging::error('VIES EU VAT validation error: Host unreachable'); - //If there was an error with the VAT validation service, we allow - //the VAT number to pass. - return true; - } - return false; - } - - - public static function addVatToInvoice($invoice_id) - { - $credentials = self::getAPICredentials(); - - //First we need to get the invoice details: sub total, and total - //so we can calcuate the amount of VAT to add - $invoicefields = array(); - $invoicefields["username"] = $credentials["username"]; - $invoicefields["password"] = md5($credentials["password"]); - $invoicefields["action"] = "getinvoice"; - $invoicefields["invoiceid"] = $invoice_id; - $invoicefields["responsetype"] = "json"; - - $invoice_query_string = ""; - foreach ($invoicefields as $k=>$v) $invoice_query_string .= "$k=".urlencode($v)."&"; - - //TODO: error checking - $result = Billing::makeRequest($credentials["url"], $invoice_query_string); - - $vat_amount = $result["subtotal"] * (VAT_RATE/100); - $invoice_total = $result["total"] + $vat_amount; - - //Second, update the invoice with the VAT amount and updated total - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "updateinvoice"; - $postfields["invoiceid"] = $invoice_id; - $postfields["tax"] = "$vat_amount"; - $postfields["taxrate"] = strval(VAT_RATE); - $postfields["total"] = "$invoice_total"; - $postfields["responsetype"] = "json"; - - $query_string = ""; - foreach ($postfields as $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - //TODO: error checking - $result = Billing::makeRequest($credentials["url"], $query_string); - } - - public static function getInvoices() - { - Billing::ensureClientIdIsValid(); - $credentials = Billing::getAPICredentials(); - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "getinvoices"; - $postfields["responsetype"] = "json"; - $postfields["userid"] = Application_Model_Preference::GetClientId(); - - $query_string = ""; - foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - $result = Billing::makeRequest($credentials["url"], $query_string); - - $invoices = array(); - if ($result["invoices"]) { - $invoices = $result["invoices"]["invoice"]; - } - return $invoices; - } - - /** - * Checks if the customer has any unpaid invoices and if so, returns - * the ID of one of them. Returns 0 otherwise. - */ - public static function checkForUnpaidInvoice() { - $invoices = self::getInvoices(); - $unpaidInvoice = 0; - $unpaidInvoices = 0; - foreach ($invoices as $invoice) - { - if ($invoice['status'] == 'Unpaid') { - $unpaidInvoices += 1; - $unpaidInvoice = $invoice; - } - } - if ($unpaidInvoices > 0) { - return $unpaidInvoice; - } else { - return 0; - } - } - - public static function isStationPodcastAllowed() { - $planLevel = Application_Model_Preference::GetPlanLevel(); - if ($planLevel == "hobbyist") { - return false; - } else { - return true; - } - } -} diff --git a/airtime_mvc/application/common/GoogleAnalytics.php b/airtime_mvc/application/common/GoogleAnalytics.php deleted file mode 100644 index 77a36f44a..000000000 --- a/airtime_mvc/application/common/GoogleAnalytics.php +++ /dev/null @@ -1,104 +0,0 @@ -sub($trialDuration); - $interval = $today->diff($accountCreationDate); - $accountDuration = $interval->days; - } - - $code = "$( document ).ready(function() { - dataLayer.push({ - 'UserID': '" . $clientId . "', - 'Customer': 'Customer', - 'PlanType': '" . $plan . "', - 'Trial': '" . $isTrial . "', - 'AccountDuration': '" . strval($accountDuration) . "' - }); - });"; - //No longer sending these variables because we used to make a query to WHMCS - //to fetch them, which was slow. - // 'ZipCode': '" . $postcode . "', - // 'Country': '" . $country . "', - - } catch (Exception $e) { - Logging::error($e); - return ""; - } - return $code; - } - - /** Generate the JavaScript snippet that logs a trial to paid conversion */ - public static function generateConversionTrackingJavaScript() - { - $code = ""; - if (LIBRETIME_ENABLE_GOOGLE_ANALYTICS !== true) { - return $code; - } - - $newPlan = Application_Model_Preference::GetPlanLevel(); - $oldPlan = Application_Model_Preference::GetOldPlanLevel(); - - $code = "dataLayer.push({'event': 'Conversion', - 'Conversion': 'Trial to Paid', - 'Old Plan' : '$oldPlan', - 'New Plan' : '$newPlan'});"; - return $code; - } - - /** Return true if the user used to be on a trial plan and was just converted to a paid plan. */ - public static function didPaidConversionOccur($request) - { - if (LIBRETIME_ENABLE_GOOGLE_ANALYTICS !== true) { - return false; - } - - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - if ($userInfo) { - $user = new Application_Model_User($userInfo->id); - } else { - return; - } - - $oldPlan = Application_Model_Preference::GetOldPlanLevel(); - - if ($user->isSuperAdmin() && - !$user->isSourcefabricAdmin() && - $request->getControllerKey() !== "thank-you") - { - //Only tracking trial->paid conversions for now. - if ($oldPlan == "trial") - { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/airtime_mvc/application/common/LocaleHelper.php b/airtime_mvc/application/common/LocaleHelper.php index 8b1ff12ec..82c5b243a 100644 --- a/airtime_mvc/application/common/LocaleHelper.php +++ b/airtime_mvc/application/common/LocaleHelper.php @@ -2,10 +2,6 @@ // Global functions for translating domain-specific strings -function _pro($str) { - return dgettext("pro", $str); -} - class Application_Common_LocaleHelper { /** diff --git a/airtime_mvc/application/common/ProvisioningHelper.php b/airtime_mvc/application/common/ProvisioningHelper.php deleted file mode 100644 index 80a73b960..000000000 --- a/airtime_mvc/application/common/ProvisioningHelper.php +++ /dev/null @@ -1,242 +0,0 @@ -apikey = $apikey; - } - - /** - * Endpoint for setting up and installing the Airtime database. This all has to be done without Zend - * which is why the code looks so old school (eg. http_response_code). (We can't currently bootstrap our - * Zend app without the database unfortunately.) - */ - public function createAction() - { - $apikey = ""; - if (isset($_SERVER['PHP_AUTH_USER'])) - { - $apikey = $_SERVER['PHP_AUTH_USER']; - } - if ($apikey != $this->apikey) { - Logging::info("Invalid API Key: $apikey"); - http_response_code(403); - echo "ERROR: Incorrect API key"; - return; - } - - try { - - $this->parsePostParams(); - - //For security, the Airtime Pro provisioning system creates the database for the user. - if ($this->dbhost && !empty($this->dbhost)) { - $this->setNewDatabaseConnection(); - - if (!$this->checkDatabaseExists()) { - throw new DatabaseDoesNotExistException("ERROR: $this->dbname database does not exist."); - } - - //We really want to do this check because all the Propel-generated SQL starts with "DROP TABLE IF EXISTS". - //If we don't check, then a second call to this API endpoint would wipe all the tables! - if ($this->checkTablesExist()) { - throw new DatabaseAlreadyExistsException(); - } - - $this->createDatabaseTables(); - $this->initializeMusicDirsTable($this->instanceId); - } - - //$this->createDatabase(); - - //All we need to do is create the database tables. - - $this->initializePrefs(); - } catch (DatabaseDoesNotExistException $e) { - http_response_code(400); - Logging::error($e->getMessage()); - echo $e->getMessage() . PHP_EOL; - return; - } catch (DatabaseAlreadyExistsException $e) { - // When we recreate a terminated instance, the process will fail - // if we return a 40x response here. In order to circumvent this, - // just return a 200; we still avoid dropping the existing tables - http_response_code(200); - Logging::info($e->getMessage()); - echo $e->getMessage() . PHP_EOL; - return; - } - - http_response_code(201); - } - - /** - * Check if the database settings and credentials given are valid - * @return boolean true if the database given exists and the user is valid and can access it - */ - private function checkDatabaseExists() - { - $statement = self::$dbh->prepare("SELECT datname FROM pg_database WHERE datname = :dbname"); - $statement->execute(array(":dbname" => $this->dbname)); - $result = $statement->fetch(); - return isset($result[0]); - } - - private function checkTablesExist() - { - try { - $result = self::$dbh->query("SELECT 1 FROM cc_files LIMIT 1"); - } catch (Exception $e) { - // We got an exception == table not found - echo($e . PHP_EOL); - return FALSE; - } - - // Result is either boolean FALSE (no table found) or PDOStatement Object (table found) - return $result !== FALSE; - } - - private function parsePostParams() - { - $this->dbuser = $_POST['dbuser']; - $this->dbpass = $_POST['dbpass']; - $this->dbname = $_POST['dbname']; - $this->dbhost = $_POST['dbhost']; - $this->dbowner = $_POST['dbowner']; - $this->instanceId = $_POST['instanceid']; - - if (isset($_POST['station_name'])) { - $this->stationName = $_POST['station_name']; - } - if (isset($_POST['description'])) { - $this->description = $_POST['description']; - } - if (isset($_POST['icecast_pass'])) { - $this->defaultIcecastPassword = $_POST['icecast_pass']; - } - if (isset($_POST['bandwidth_limit'])) { - $this->bandwidthLimit = $_POST['bandwidth_limit']; - } - } - - /** - * Set up a new database connection based on the parameters in the request - * @throws PDOException upon failure to connect - */ - private function setNewDatabaseConnection() - { - self::$dbh = new PDO("pgsql:host=" . $this->dbhost - . ";dbname=" . $this->dbname - . ";port=5432" . ";user=" . $this->dbuser - . ";password=" . $this->dbpass); - //Turn on PDO exceptions because they're off by default. - //self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $err = self::$dbh->errorInfo(); - if ($err[1] != null) { - throw new PDOException("ERROR: Could not connect to database"); - } - } - - /** - * Creates the Airtime database using the given credentials - * @throws Exception - */ - private function createDatabase() - { - Logging::info("Creating database..."); - $statement = self::$dbh->prepare("CREATE DATABASE " . pg_escape_string($this->dbname) - . " WITH ENCODING 'UTF8' TEMPLATE template0" - . " OWNER " . pg_escape_string($this->dbowner)); - if (!$statement->execute()) { - throw new Exception("ERROR: Failed to create Airtime database"); - } - } - - /** - * Install the Airtime database - * @throws Exception - */ - private function createDatabaseTables() - { - Logging::info("Creating database tables..."); - $sqlDir = dirname(APPLICATION_PATH) . "/build/sql/"; - $files = array("schema.sql", "sequences.sql", "views.sql", "triggers.sql", "defaultdata.sql"); - foreach ($files as $f) { - /* - * Unfortunately, we need to use exec here due to PDO's lack of support for importing - * multi-line .sql files. PDO->exec() almost works, but any SQL errors stop the import, - * so the necessary DROPs on non-existent tables make it unusable. Prepared statements - * have multiple issues; they similarly die on any SQL errors, fail to read in multi-line - * commands, and fail on any unescaped ? or $ characters. - */ - exec("PGPASSWORD=$this->dbpass psql -U $this->dbuser --dbname $this->dbname -h $this->dbhost -f $sqlDir$f", $out, $status); - if ($status != 0) { - throw new Exception("ERROR: Failed to create database tables"); - } - } - } - - private function initializeMusicDirsTable($instanceId) - { - if (!is_string($instanceId) || empty($instanceId) || !is_numeric($instanceId)) - { - throw new Exception("Invalid instance id: " . $instanceId); - } - - $instanceIdPrefix = $instanceId[0]; - - //Reinitialize Propel, just in case... - Propel::init(__DIR__."/../configs/airtime-conf-production.php"); - - //Create the cc_music_dir entry - $musicDir = new CcMusicDirs(); - $musicDir->setType("stor"); - $musicDir->setExists(true); - $musicDir->setWatched(true); - $musicDir->setDirectory("/mnt/airtimepro/instances/$instanceIdPrefix/$instanceId/srv/airtime/stor/"); - $musicDir->save(); - } - - /** - * Initialize preference values passed from the dashboard (if any exist) - */ - private function initializePrefs() { - if ($this->stationName) { - Application_Model_Preference::SetStationName($this->stationName); - } - if ($this->description) { - Application_Model_Preference::SetStationDescription($this->description); - } - if (isset($this->defaultIcecastPassword)) { - Application_Model_Preference::setDefaultIcecastPassword($this->defaultIcecastPassword); - } - if (isset($this->bandwidthLimit)) { - Application_Model_Preference::setBandwidthLimit($this->bandwidthLimit); - } - } - -} - -class DatabaseAlreadyExistsException extends Exception { - private static $_defaultMessage = "ERROR: airtime tables already exists"; - public function __construct($message = null, $code = 0, Exception $previous = null) { - $message = _((is_null($message) ? self::$_defaultMessage : $message)); - parent::__construct($message, $code, $previous); - } -} - -class DatabaseDoesNotExistException extends Exception {} - diff --git a/airtime_mvc/application/common/UsabilityHints.php b/airtime_mvc/application/common/UsabilityHints.php index 7acf92446..6ec5fc6de 100644 --- a/airtime_mvc/application/common/UsabilityHints.php +++ b/airtime_mvc/application/common/UsabilityHints.php @@ -103,13 +103,6 @@ class Application_Common_UsabilityHints "", ""); } - } else if (LIBRETIME_ENABLE_BILLING === true && $userIsOnShowbuilderPage && $userIsSuperAdmin) { - $unpaidInvoice = Billing::checkForUnpaidInvoice(); - if ($unpaidInvoice != null) { - $invoiceUrl = "/billing/invoice?invoiceid=" . $unpaidInvoice['id']; - $amount = $unpaidInvoice['currencyprefix'] . $unpaidInvoice['total']; - return _pro(sprintf("You have an unpaid invoice for %s due soon. Please pay it to keep your station on the air.", $amount, $invoiceUrl));; - } } return ""; } @@ -225,4 +218,4 @@ class Application_Common_UsabilityHints return false; } } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index be904e86e..917e70abc 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -14,7 +14,6 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('user')) ->add(new Zend_Acl_Resource('error')) ->add(new Zend_Acl_Resource('login')) - ->add(new Zend_Acl_Resource('whmcs-login')) ->add(new Zend_Acl_Resource('playlist')) ->add(new Zend_Acl_Resource('plupload')) ->add(new Zend_Acl_Resource('schedule')) @@ -38,9 +37,6 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('rest:podcast')) ->add(new Zend_Acl_Resource('rest:podcast-episodes')) ->add(new Zend_Acl_Resource('podcast')) - ->add(new Zend_Acl_Resource('billing')) - ->add(new Zend_Acl_Resource('thank-you')) - ->add(new Zend_Acl_Resource('provisioning')) ->add(new Zend_Acl_Resource('player')) ->add(new Zend_Acl_Resource('render')) ->add(new Zend_Acl_Resource('soundcloud')) @@ -51,7 +47,6 @@ $ccAcl->add(new Zend_Acl_Resource('library')) /** Creating permissions */ $ccAcl->allow('G', 'index') ->allow('G', 'login') - ->allow('G', 'whmcs-login') ->allow('G', 'error') ->allow('G', 'user', 'edit-user') ->allow('G', 'showbuilder') @@ -63,7 +58,6 @@ $ccAcl->allow('G', 'index') ->allow('G', 'webstream') ->allow('G', 'locale') ->allow('G', 'upgrade') - ->allow('G', 'provisioning') ->allow('G', 'downgrade') ->allow('G', 'rest:show-image', 'get') ->allow('G', 'rest:media', 'get') @@ -89,9 +83,7 @@ $ccAcl->allow('G', 'index') ->allow('A', 'playouthistorytemplate') ->allow('A', 'user') ->allow('A', 'systemstatus') - ->allow('A', 'preference') - ->allow('S', 'thank-you') - ->allow('S', 'billing'); + ->allow('A', 'preference'); $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index 269c79534..df7e45d1c 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -106,25 +106,9 @@ define('UI_PLAYLISTCONTROLLER_OBJ_SESSNAME', 'PLAYLISTCONTROLLER_OBJ'); /*define('UI_PLAYLIST_SESSNAME', 'PLAYLIST'); define('UI_BLOCK_SESSNAME', 'BLOCK');*/ -// Google Analytics integration -define('LIBRETIME_ENABLE_GOOGLE_ANALYTICS', false); - -//WHMCS integration -define('LIBRETIME_ENABLE_WHMCS', false); -define('WHMCS_PASSWORD_RESET_URL', 'https://account.example.com/pwreset.php'); -define('WHMCS_API_URL' , 'https://account.example.org/includes/api.php'); -define('SUBDOMAIN_WHMCS_CUSTOM_FIELD_NAME', 'Choose your domain'); - -//LiveChat integration -define('LIBRETIME_ENABLE_LIVECHAT', false); - //Sentry error logging define('SENTRY_CONFIG_PATH', LIBRETIME_CONF_DIR . '/sentry.airtime_web.ini'); -//Provisioning status -define('PROVISIONING_STATUS_SUSPENDED' , 'Suspended'); -define('PROVISIONING_STATUS_ACTIVE' , 'Active'); - //TuneIn integration define("TUNEIN_API_URL", "http://air.radiotime.com/Playing.ashx"); @@ -150,6 +134,3 @@ define('STATION_PODCAST_SERVICE_NAME', 'station_podcast'); //define('IMPORTED_PODCAST', 1); define('ITUNES_XML_NAMESPACE_URL', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); - -// Billing configuration -define('LIBRETIME_ENABLE_BILLING', false); diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index fb666613c..271ffae3f 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -148,38 +148,6 @@ $pages[] = array( ) ); -if (LIBRETIME_ENABLE_BILLING === true) { - $pages[] = array( - 'label' => (Application_Model_Preference::GetPlanLevel()=="trial") ? ""._('Upgrade')."" : ""._('Billing'), - 'controller' => 'billing', - 'action' => 'upgrade', - 'resource' => 'billing', - 'title' => 'Billing', - 'pages' => array( - array( - 'label' => _('Account Plans'), - 'module' => 'default', - 'controller' => 'billing', - 'action' => 'upgrade', - 'resource' => 'billing' - ), - array( - 'label' => _('Account Details'), - 'module' => 'default', - 'controller' => 'billing', - 'action' => 'client', - 'resource' => 'billing' - ), - array( - 'label' => _('View Invoices'), - 'module' => 'default', - 'controller' => 'billing', - 'action' => 'invoices', - 'resource' => 'billing' - ) - ) - ); -} $pages[] = array( 'label' => _('Help'), 'controller' => 'dashboard', diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 1f8283720..1d070f1f4 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -57,7 +57,6 @@ class ApiController extends Zend_Controller_Action ->addActionContext('status' , 'json') ->addActionContext('register-component' , 'json') ->addActionContext('update-liquidsoap-status' , 'json') - ->addActionContext('live-chat' , 'json') ->addActionContext('update-file-system-mount' , 'json') ->addActionContext('handle-watched-dir-missing' , 'json') ->addActionContext('rabbitmq-do-push' , 'json') diff --git a/airtime_mvc/application/controllers/BillingController.php b/airtime_mvc/application/controllers/BillingController.php deleted file mode 100644 index 5a5f7e452..000000000 --- a/airtime_mvc/application/controllers/BillingController.php +++ /dev/null @@ -1,301 +0,0 @@ -_helper->getHelper('AjaxContext'); - $ajaxContext->addActionContext('vat-validator', 'json') - ->addActionContext('is-country-in-eu', 'json') - ->initContext(); - } - - public function indexAction() - { - $this->_redirect('billing/upgrade'); - } - - public function upgradeAction() - { - //If you're not on a trial and you're suspended, we don't let you access the plans page and redirect you to the invoices - //page to force you to pay your bills first. - $isTrial = (Application_Model_Preference::GetPlanLevel() == 'trial'); - if (!$isTrial && (Application_Model_Preference::getProvisioningStatus() == PROVISIONING_STATUS_SUSPENDED)) { - $this->_redirect('billing/invoices'); - } - - Zend_Layout::getMvcInstance()->assign('parent_page', 'Billing'); - - $CC_CONFIG = Config::getConfig(); - $baseUrl = Application_Common_OsPath::getBaseDir(); - $this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']); - Billing::ensureClientIdIsValid(); - - //Zend's CSRF token element requires the session to be open for writing - SessionHelper::reopenSessionForWriting(); - - $request = $this->getRequest(); - $form = new Application_Form_BillingUpgradeDowngrade(); - - if ($request->isPost()) { - - $formData = $request->getPost(); - - if ($form->isValid($formData)) { - - $credentials = Billing::getAPICredentials(); - - //Check if VAT should be applied or not to this invoice. - if (in_array("7", $formData["customfields"])) { - $apply_vat = Billing::checkIfVatShouldBeApplied($formData["customfields"]["7"], $formData["country"]); - } else { - $apply_vat = false; - } - - $placeAnUpgradeOrder = true; - - $currentPlanProduct = Billing::getClientCurrentAirtimeProduct(); - $currentPlanProductId = $currentPlanProduct["pid"]; - $currentPlanProductBillingCycle = strtolower($currentPlanProduct["billingcycle"]); - //If there's been no change in the plan or the billing cycle, we should not - //place an upgrade order. WHMCS doesn't allow this in its web interface, - //and it freaks out and does the wrong thing if we do it via the API - //so we have to do avoid that. - if (($currentPlanProductId == $formData["newproductid"]) && - ($currentPlanProductBillingCycle == $formData["newproductbillingcycle"]) - ) { - $placeAnUpgradeOrder = false; - } - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "upgradeproduct"; - $postfields["clientid"] = Application_Model_Preference::GetClientId(); - - $postfields["serviceid"] = Billing::getClientInstanceId(); - $postfields["type"] = "product"; - $postfields["newproductid"] = $formData["newproductid"]; - $postfields["newproductbillingcycle"] = $formData["newproductbillingcycle"]; - $postfields["paymentmethod"] = $formData["paymentmethod"]; - $postfields["responsetype"] = "json"; - - $upgrade_query_string = ""; - foreach ($postfields AS $k => $v) $upgrade_query_string .= "$k=" . urlencode($v) . "&"; - - //update client info - - $clientfields = array(); - $clientfields["username"] = $credentials["username"]; - $clientfields["password"] = md5($credentials["password"]); - $clientfields["action"] = "updateclient"; - $clientfields["clientid"] = Application_Model_Preference::GetClientId(); - $clientfields["customfields"] = base64_encode(serialize($formData["customfields"])); - unset($formData["customfields"]); - $clientfields["responsetype"] = "json"; - unset($formData["newproductid"]); - unset($formData["newproductbillingcycle"]); - unset($formData["paymentmethod"]); - unset($formData["action"]); - $clientfields = array_merge($clientfields, $formData); - unset($clientfields["password2verify"]); - unset($clientfields["submit"]); - $client_query_string = ""; - foreach ($clientfields AS $k => $v) $client_query_string .= "$k=" . urlencode($v) . "&"; - - //Update the client details in WHMCS first - $result = Billing::makeRequest($credentials["url"], $client_query_string); - Logging::info($result); - if ($result["result"] == "error") { - $this->setErrorMessage(); - $this->view->form = $form; - return; - } - - //If there were no changes to the plan or billing cycle, we just redirect you to the - //invoices screen and show a message. - if (!$placeAnUpgradeOrder) { - $this->_redirect('billing/invoices?planupdated'); - return; - } - - //Then place an upgrade order in WHMCS - $result = Billing::makeRequest($credentials["url"], $upgrade_query_string); - if ($result["result"] == "error") { - Logging::info($_SERVER['HTTP_HOST'] . " - Account upgrade failed. - " . $result["message"]); - $this->setErrorMessage(); - $this->view->form = $form; - } else { - Logging::info($_SERVER['HTTP_HOST'] . "Account plan upgrade request:"); - Logging::info($result); - - // Disable the view and the layout here, squashes an error. - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - if ($apply_vat) { - Billing::addVatToInvoice($result["invoiceid"]); - } - - // there may not be an invoice created if the client is downgrading - if (!empty($result["invoiceid"])) { - self::viewInvoice($result["invoiceid"]); - } else { - $this->_redirect('billing/invoices?planupdated'); - return; - } - } - } else { - $this->view->form = $form; - } - } else { - $this->view->form = $form; - } - } - - - public function isCountryInEuAction() - { - // Disable the view and the layout - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $request = $this->getRequest(); - if (!$request->isPost()) { - throw new Exception("Must POST data to isCountryInEuAction."); - } - $formData = $request->getPost(); - - //Set the return JSON value - $this->_helper->json(array("result"=>Billing::isCountryInEU($formData["country"]))); - } - - public function vatValidatorAction() - { - // Disable the view and the layout - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $request = $this->getRequest(); - if (!$request->isPost()) { - throw new Exception("Must POST data to vatValidatorAction."); - } - $formData = $request->getPost(); - - $vatNumber = trim($formData["vatnumber"]); - if (empty($vatNumber)) { - $this->_helper->json(array("result"=>false)); - } - - //Set the return JSON value - $this->_helper->json(array("result"=>Billing::checkIfVatShouldBeApplied($vatNumber, $formData["country"]))); - } - - - private function setErrorMessage($msg=null) - { - if (!is_null($msg)) { - $this->view->errorMessage = $msg; - } else { - $this->view->errorMessage = "An error occurred and we could not update your account. Please contact support for help."; - } - } - - private function setSuccessMessage($msg=null) - { - if (!is_null($msg)) { - $this->view->successMessage = $msg; - } else { - $this->view->successMessage = "Your account has been updated."; - } - } - - private static function viewInvoice($invoice_id) - { - $whmcsurl = "https://account.sourcefabric.com/dologin.php"; - $autoauthkey = $_SERVER["WHMCS_AUTOAUTH_KEY"]; - $timestamp = time(); //whmcs timezone? - $client = Billing::getClientDetails(); - $email = $client["email"]; - $hash = sha1($email.$timestamp.$autoauthkey); - $goto = "viewinvoice.php?id=".$invoice_id; - header("Location: ".$whmcsurl."?email=$email×tamp=$timestamp&hash=$hash&goto=$goto"); - } - - public function clientAction() - { - Zend_Layout::getMvcInstance()->assign('parent_page', 'Billing'); - - $CC_CONFIG = Config::getConfig(); - $baseUrl = Application_Common_OsPath::getBaseDir(); - $this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']); - - //Zend's CSRF token element requires the session to be open for writing - SessionHelper::reopenSessionForWriting(); - - $request = $this->getRequest(); - $form = new Application_Form_BillingClient(); - Billing::ensureClientIdIsValid(); - if ($request->isPost()) { - $formData = $request->getPost(); - if ($form->isValid($formData)) { - - $credentials = Billing::getAPICredentials(); - - $postfields = array(); - $postfields["username"] = $credentials["username"]; - $postfields["password"] = md5($credentials["password"]); - $postfields["action"] = "updateclient"; - - $postfields["customfields"] = base64_encode(serialize($formData["customfields"])); - unset($formData["customfields"]); - - $postfields["clientid"] = Application_Model_Preference::GetClientId(); - $postfields["responsetype"] = "json"; - $postfields = array_merge($postfields, $formData); - unset($postfields["password2verify"]); - unset($postfields["submit"]); - - $query_string = ""; - foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; - - $result = Billing::makeRequest($credentials["url"], $query_string); - - if ($result["result"] == "error") { - $this->setErrorMessage(); - } else { - $form = new Application_Form_BillingClient(); - $this->setSuccessMessage(); - } - - $this->view->form = $form; - } else { - $this->view->form = $form; - } - } else { - $this->view->form = $form; - } - } - - public function invoicesAction() - { - Zend_Layout::getMvcInstance()->assign('parent_page', 'Billing'); - - $CC_CONFIG = Config::getConfig(); - $baseUrl = Application_Common_OsPath::getBaseDir(); - $this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']); - - $this->view->invoices = Billing::getInvoices(); - } - - public function invoiceAction() - { - Billing::ensureClientIdIsValid(); - $request = $this->getRequest(); - $invoice_id = $request->getParam('invoiceid'); - self::viewInvoice($invoice_id); - } -} diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index aefad2114..21543e24e 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -485,13 +485,6 @@ class LibraryController extends Zend_Controller_Action public function publishDialogAction() { $this->_helper->layout->disableLayout(); - - - if (LIBRETIME_ENABLE_BILLING === true && !Billing::isStationPodcastAllowed()) { - $this->renderScript("podcast/featureupgrade-pane.phtml"); - } - - //This just spits out publish-dialog.phtml! } } diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index 8065b637d..c29c0113a 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -88,21 +88,6 @@ class LoginController extends Zend_Controller_Action Application_Model_Preference::SetUserLocale($locale); $this->_redirect('showbuilder'); - } elseif (LIBRETIME_ENABLE_WHMCS) { - $email = $form->getValue('username'); - $authAdapter = new WHMCS_Auth_Adapter("admin", $email, $password); - $auth = Zend_Auth::getInstance(); - $result = $auth->authenticate($authAdapter); - if ($result->isValid()) { - Zend_Session::regenerateId(); - //set the user locale in case user changed it in when logging in - Application_Model_Preference::SetUserLocale($locale); - - $this->_redirect('showbuilder'); - } - else { - $form = $this->loginError($username); - } } else { $form = $this->loginError($username); } @@ -175,18 +160,7 @@ class LoginController extends Zend_Controller_Action $form->email->addError($this->view->translate(_("Email could not be sent. Check your mail server settings and ensure it has been configured properly."))); } } else { - if (!LIBRETIME_ENABLE_WHMCS) { - $form->email->addError($this->view->translate(_("That username or email address could not be found."))); - } else { - $form->email->addError( - $this->view->translate( - sprintf( - _pro("That username or email address could not be found. If you are the station owner, you should reset your here."), - WHMCS_PASSWORD_RESET_URL - ) - ) - ); - } + $form->email->addError($this->view->translate(_("That username or email address could not be found."))); } } else { //Form is not valid $form->email->addError($this->view->translate(_("There was a problem with the username or email address you entered."))); diff --git a/airtime_mvc/application/controllers/PodcastController.php b/airtime_mvc/application/controllers/PodcastController.php index d826f666b..628baf319 100644 --- a/airtime_mvc/application/controllers/PodcastController.php +++ b/airtime_mvc/application/controllers/PodcastController.php @@ -27,15 +27,10 @@ class PodcastController extends Zend_Controller_Action { */ public function stationAction() { - if (LIBRETIME_ENABLE_BILLING === true && !Billing::isStationPodcastAllowed()) { - $this->render("featureupgrade-page"); - return; - } - $stationPodcastId = Application_Model_Preference::getStationPodcastId(); $podcast = Application_Service_PodcastService::getPodcastById($stationPodcastId); $this->view->podcast = json_encode($podcast); $this->view->form = new Application_Form_StationPodcast(); } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 5c1baf132..803c81409 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -71,7 +71,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::setTuneinPartnerId($values["tunein_partner_id"]); // SoundCloud Preferences - if (Billing::isStationPodcastAllowed() && array_key_exists('SoundCloudLicense', $values)) { + if (array_key_exists('SoundCloudLicense', $values)) { Application_Model_Preference::setDefaultSoundCloudLicenseType($values["SoundCloudLicense"]); Application_Model_Preference::setDefaultSoundCloudSharingType($values["SoundCloudSharing"]); } diff --git a/airtime_mvc/application/controllers/ProvisioningController.php b/airtime_mvc/application/controllers/ProvisioningController.php deleted file mode 100644 index 4bc090ac1..000000000 --- a/airtime_mvc/application/controllers/ProvisioningController.php +++ /dev/null @@ -1,89 +0,0 @@ -view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - if (!RestAuth::verifyAuth(true, false, $this)) { - return; - } - - try { - // This is hacky and should be genericized - if (isset($_POST['station_name'])) { - Application_Model_Preference::SetStationName($_POST['station_name']); - } - if (isset($_POST['description'])) { - Application_Model_Preference::SetStationDescription($_POST['description']); - } - if (isset($_POST['provisioning_status'])) { - Application_Model_Preference::setProvisioningStatus($_POST['provisioning_status']); - } - if (isset($_POST['icecast_pass'])) { - Application_Model_Preference::setDefaultIcecastPassword($_POST['icecast_pass']); - } - if (isset($_POST['bandwidth_limit'])) { - Application_Model_Preference::setBandwidthLimit($_POST['bandwidth_limit']); - } - } catch (Exception $e) { - $this->getResponse() - ->setHttpResponseCode(400) - ->appendBody("ERROR: " . $e->getMessage()); - Logging::error($e->getMessage()); - echo $e->getMessage() . PHP_EOL; - return; - } - - $this->getResponse() - ->setHttpResponseCode(200) - ->appendBody("OK"); - } - - /** - * Delete the Airtime Pro station's files from Amazon S3 - * - * FIXME: When we deploy this next time, we should ensure that - * this function can only be accessed with POST requests! - */ - public function terminateAction() - { - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - if (!RestAuth::verifyAuth(true, false, $this)) { - return; - } - - $CC_CONFIG = Config::getConfig(); - - foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) { - $proxyStorageBackend = new ProxyStorageBackend($storageBackend); - $proxyStorageBackend->deleteAllCloudFileObjects(); - } - - $this->getResponse() - ->setHttpResponseCode(200) - ->appendBody("OK"); - } - -} diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 5a8067345..82fa27b64 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -25,7 +25,6 @@ class ShowbuilderController extends Zend_Controller_Action //$this->_helper->layout->setLayout("showbuilder"); $this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );"); - $this->view->headScript()->appendScript(Application_Common_GoogleAnalytics::generateGoogleTagManagerDataLayerJavaScript()); $this->view->headLink()->appendStylesheet($baseUrl . 'css/redmond/jquery-ui-1.8.8.custom.css?' . $CC_CONFIG['airtime_version']); diff --git a/airtime_mvc/application/controllers/ThankYouController.php b/airtime_mvc/application/controllers/ThankYouController.php deleted file mode 100644 index 86a57a54c..000000000 --- a/airtime_mvc/application/controllers/ThankYouController.php +++ /dev/null @@ -1,48 +0,0 @@ -view->stationUrl = Application_Common_HTTPHelper::getStationUrl(); - $this->view->conversionUrl = Application_Common_HTTPHelper::getStationUrl() . 'thank-you/confirm-conversion'; - $this->view->gaEventTrackingJsCode = ""; //Google Analytics event tracking code that logs an event. - - // Embed the Google Analytics conversion tracking code if the - // user is a super admin and old plan level is set to trial. - if (Application_Common_GoogleAnalytics::didPaidConversionOccur($this->getRequest())) { - $this->view->gaEventTrackingJsCode = Application_Common_GoogleAnalytics::generateConversionTrackingJavaScript(); - } - - $csrf_namespace = new Zend_Session_Namespace('csrf_namespace'); - $csrf_element = new Zend_Form_Element_Hidden('csrf'); - $csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label'); - $csrf_form = new Zend_Form(); - $csrf_form->addElement($csrf_element); - $this->view->form = $csrf_form; - } - - /** Confirm that a conversion was tracked. */ - public function confirmConversionAction() - { - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $current_namespace = new Zend_Session_Namespace('csrf_namespace'); - $observed_csrf_token = $this->_getParam('csrf_token'); - $expected_csrf_token = $current_namespace->authtoken; - - if($observed_csrf_token != $expected_csrf_token) { - Logging::info("Invalid CSRF token"); - return; - } - - if ($this->getRequest()->isPost()) { - Logging::info("Goal conversion from trial to paid."); - // Clear old plan level so we prevent duplicate events. - // This should only be called from AJAX. See thank-you/index.phtml - Application_Model_Preference::ClearOldPlanLevel(); - } - } -} \ No newline at end of file diff --git a/airtime_mvc/application/controllers/WhmcsLoginController.php b/airtime_mvc/application/controllers/WhmcsLoginController.php deleted file mode 100644 index 92b554de6..000000000 --- a/airtime_mvc/application/controllers/WhmcsLoginController.php +++ /dev/null @@ -1,262 +0,0 @@ -getRequest(); - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $username = "admin"; //This is just for appearance in your session. It shows up in the corner of the Airtime UI. - $email = $_POST["email"]; - $password = $_POST["password"]; - - Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', 'en_CA')); - if (Zend_Auth::getInstance()->hasIdentity()) - { - $this->_redirect('showbuilder'); - } - - $authAdapter = new WHMCS_Auth_Adapter($username, $email, $password); - - $auth = Zend_Auth::getInstance(); - $result = $auth->authenticate($authAdapter); - if ($result->isValid()) { - //all info about this user from the login table omit only the password - //$userInfo = $authAdapter->getResultRowObject(null, 'password'); - - //the default storage is a session with namespace Zend_Auth - /* - [id] => 1 - [login] => admin - [pass] => hashed password - [type] => A - [first_name] => - [last_name] => - [lastlogin] => - [lastfail] => - [skype_contact] => - [jabber_contact] => - [email] => asdfasdf@asdasdf.com - [cell_phone] => - [login_attempts] => 0 - */ - - //Zend_Auth already does this for us, it's not needed: - //$authStorage = $auth->getStorage(); - //$authStorage->write($result->getIdentity()); //$userInfo); - - //set the user locale in case user changed it in when logging in - //$locale = $form->getValue('locale'); - //Application_Model_Preference::SetUserLocale($locale); - - $this->_redirect('showbuilder'); - } - else { - echo("Sorry, that username or password was incorrect."); - } - - return; - } -} - -class WHMCS_Auth_Adapter implements Zend_Auth_Adapter_Interface { - private $username; - private $password; - private $email; - - function __construct($username, $email, $password) { - $this->username = $username; - $this->password = $password; - $this->email = $email; - $this->identity = null; - } - - function authenticate() { - list($credentialsValid, $clientId) = $this->validateCredentialsWithWHMCS($this->email, $this->password); - if (!$credentialsValid) - { - return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, null); - } - if (!$this->verifyClientSubdomainOwnership($clientId)) - { - return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, null); - } - - $identity = array(); - - //TODO: Get identity of the first admin user! - - /* - $identity["id"] = 1; - $identity["type"] = "S"; - $identity["login"] = $this->username; //admin"; - $identity["email"] = $this->email;*/ - $identity = $this->getSuperAdminIdentity(); - if (is_null($identity)) { - Logging::error("No super admin user found"); - return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null); - } - $identity = (object)$identity; //Convert the array into an stdClass object - - try { - return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity); - } catch (Exception $e) { - // exception occured - return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null); - } - } - - private function getSuperAdminIdentity() - { - $firstSuperAdminUser = CcSubjsQuery::create() - ->filterByDbType('S') - ->orderByDbId() - ->findOne(); - if (!$firstSuperAdminUser) { - //If there's no super admin users, get the first regular admin user! - $firstSuperAdminUser = CcSubjsQuery::create() - ->filterByDbType('A') - ->orderByDbId() - ->findOne(); - if (!$firstSuperAdminUser) { - return null; - } - } - $identity["id"] = $firstSuperAdminUser->getDbId(); - $identity["type"] = "S"; //Super Admin - $identity["login"] = $firstSuperAdminUser->getDbLogin(); - $identity["email"] = $this->email; - return $identity; - } - - //Returns an array! Read the code carefully: - private function validateCredentialsWithWHMCS($email, $password) - { - $client_postfields = array(); - $client_postfields["username"] = $_SERVER['WHMCS_USERNAME']; //WHMCS API username - $client_postfields["password"] = md5($_SERVER['WHMCS_PASSWORD']); //WHMCS API password - $client_postfields["action"] ="validatelogin"; - $client_postfields["responsetype"] = "json"; - - $client_postfields["email"] = $email; - $client_postfields["password2"] = $password; - - $query_string = ""; - foreach ($client_postfields as $k => $v) $query_string .= "$k=".urlencode($v)."&"; - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, WHMCS_API_URL); - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); - curl_setopt($ch, CURLOPT_FAILONERROR, 1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - $jsondata = curl_exec($ch); - if (curl_error($ch)) { - Logging::error("Failed to reach WHMCS server in " . __FUNCTION__ . ": " - . curl_errno($ch) . ' - ' . curl_error($ch) . ' - ' . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); - //die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); - } - curl_close($ch); - - $arr = json_decode($jsondata, true); # Decode JSON String - - if ($arr["result"] != "success") { - return array(false, -1); - } - $clientId = $arr["userid"]; - - return array(true, $clientId); - } - - function verifyClientSubdomainOwnership($clientId) - { - //Do a quick safety check to ensure the client ID we're authenticating - //matches up to the owner of this instance. - if ($clientId != Application_Model_Preference::GetClientId()) - { - return false; - } - $client_postfields = array(); - $client_postfields["username"] = $_SERVER['WHMCS_USERNAME']; - $client_postfields["password"] = md5($_SERVER['WHMCS_PASSWORD']); - $client_postfields["action"] ="getclientsproducts"; - $client_postfields["responsetype"] = "json"; - - $client_postfields["clientid"] = $clientId; - //$client_postfields["stats"] = "true"; - - $query_string = ""; - foreach ($client_postfields as $k => $v) $query_string .= "$k=".urlencode($v)."&"; - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, WHMCS_API_URL); - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); - curl_setopt($ch, CURLOPT_FAILONERROR, 1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - $jsondata = curl_exec($ch); - if (curl_error($ch)) { - Logging::error("Failed to reach WHMCS server in " . __FUNCTION__ . ": " - . curl_errno($ch) . ' - ' . curl_error($ch) . ' - ' . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); - //die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); - } - curl_close($ch); - - $arr = json_decode($jsondata, true); # Decode JSON String - //$client_id = $arr["clientid"]; - //print_r($arr); - if ($arr["result"] != "success") { - die("Sorry, that email address or password was incorrect."); - } - - $doesAirtimeProductExist = false; - $isAirtimeAccountSuspended = true; - $airtimeProduct = null; - - foreach ($arr["products"]["product"] as $product) - { - if (strpos($product["groupname"], "Airtime") === FALSE) - { - //Ignore non-Airtime products - continue; - } - else - { - if (($product["status"] === "Active") || ($product["status"] === "Suspended")) { - $airtimeProduct = $product; - $subdomain = ''; - - foreach ($airtimeProduct['customfields']['customfield'] as $customField) - { - if ($customField['name'] === SUBDOMAIN_WHMCS_CUSTOM_FIELD_NAME) - { - $subdomain = $customField['value']; - if (($subdomain . ".airtime.pro") === $_SERVER['SERVER_NAME']) - { - return true; - } - } - } - } - } - } - return false; - } -} diff --git a/airtime_mvc/application/controllers/plugins/Acl_plugin.php b/airtime_mvc/application/controllers/plugins/Acl_plugin.php index 9f9293434..5a6b5dcc5 100644 --- a/airtime_mvc/application/controllers/plugins/Acl_plugin.php +++ b/airtime_mvc/application/controllers/plugins/Acl_plugin.php @@ -118,8 +118,6 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract "error", "locale", "upgrade", - 'whmcs-login', - "provisioning", "embed", "feeds" ))) diff --git a/airtime_mvc/application/controllers/plugins/ConversionTracking.php b/airtime_mvc/application/controllers/plugins/ConversionTracking.php deleted file mode 100644 index ae0fc2781..000000000 --- a/airtime_mvc/application/controllers/plugins/ConversionTracking.php +++ /dev/null @@ -1,25 +0,0 @@ -getControllerName() != 'thank-you') - { - $request->setModuleName('default') - ->setControllerName('thank-you') - ->setActionName('index') - ->setDispatched(true); - } - } - } - -} \ No newline at end of file diff --git a/airtime_mvc/application/controllers/plugins/PageLayoutInitPlugin.php b/airtime_mvc/application/controllers/plugins/PageLayoutInitPlugin.php index 05447c8f6..f6a46be5d 100644 --- a/airtime_mvc/application/controllers/plugins/PageLayoutInitPlugin.php +++ b/airtime_mvc/application/controllers/plugins/PageLayoutInitPlugin.php @@ -33,8 +33,6 @@ class PageLayoutInitPlugin extends Zend_Controller_Plugin_Abstract "auth", "error", "upgrade", - 'whmcs-login', - "provisioning", "embed", "feeds" )) @@ -223,29 +221,12 @@ class PageLayoutInitPlugin extends Zend_Controller_Plugin_Abstract } $view->headScript()->appendScript("var userType = '$userType';"); - if (LIBRETIME_ENABLE_LIVECHAT === true - && array_key_exists('REQUEST_URI', $_SERVER) //Doesn't exist for unit tests - && strpos($_SERVER['REQUEST_URI'], 'Dashboard/stream-player') === false - && strpos($_SERVER['REQUEST_URI'], 'audiopreview') === false - && $_SERVER['REQUEST_URI'] != "/") { - $plan_level = strval(Application_Model_Preference::GetPlanLevel()); - // Since the Hobbyist plan doesn't come with Live Chat support, don't enable it - if (Application_Model_Preference::GetLiveChatEnabled() && $plan_level !== 'hobbyist') { - $client_id = strval(Application_Model_Preference::GetClientId()); - $station_url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; - $view->headScript()->appendScript("var livechat_client_id = '$client_id';\n" . - "var livechat_plan_type = '$plan_level';\n" . - "var livechat_station_url = 'http://$station_url';"); - $view->headScript()->appendFile($baseUrl . 'js/airtime/common/livechat.js?' . $CC_CONFIG['airtime_version'], 'text/javascript'); - } - } } protected function _initViewHelpers() { $view = $this->_bootstrap->getResource('view'); $view->addHelperPath(APPLICATION_PATH . 'views/helpers', 'Airtime_View_Helper'); - $view->assign('suspended', (Application_Model_Preference::getProvisioningStatus() == PROVISIONING_STATUS_SUSPENDED)); } protected function _initTitle() diff --git a/airtime_mvc/application/forms/BillingClient.php b/airtime_mvc/application/forms/BillingClient.php deleted file mode 100644 index de5371082..000000000 --- a/airtime_mvc/application/forms/BillingClient.php +++ /dev/null @@ -1,199 +0,0 @@ -setDecorators(array( - array('ViewScript', array('viewScript' => 'form/billing-purchase.phtml'))));*/ - $client = Billing::getClientDetails(); - $this->setAttrib("id", "clientdetails_form"); - - $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); - $emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator(); - - $firstname = new Zend_Form_Element_Text('firstname'); - $firstname->setLabel(_pro('First Name:')) - ->setValue($client["firstname"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($firstname); - - $lastname = new Zend_Form_Element_Text('lastname'); - $lastname->setLabel(_pro('Last Name:')) - ->setValue($client["lastname"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($lastname); - - $companyname = new Zend_Form_Element_Text('companyname'); - $companyname->setLabel(_pro('Company Name:')) - ->setValue($client["companyname"]) - ->setAttrib('class', 'input_text') - ->setRequired(false) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($companyname); - - $email = new Zend_Form_Element_Text('email'); - $email->setLabel(_pro('Email Address:')) - ->setValue($client["email"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->setAttrib('readonly', 'readonly') - ->addValidator($emailValidator) - ->addFilter('StringTrim'); - $this->addElement($email); - - $address1 = new Zend_Form_Element_Text('address1'); - $address1->setLabel(_pro('Address 1:')) - ->setValue($client["address1"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($address1); - - $address2 = new Zend_Form_Element_Text('address2'); - $address2->setLabel(_pro('Address 2:')) - ->setValue($client["address2"]) - ->setAttrib('class', 'input_text') - ->addFilter('StringTrim'); - $this->addElement($address2); - - $city = new Zend_Form_Element_Text('city'); - $city->setLabel(_pro('City:')) - ->setValue($client["city"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($city); - - //TODO: get list from whmcs? - $state = new Zend_Form_Element_Text('state'); - $state->setLabel(_pro('State/Region:')) - ->setValue($client["state"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($state); - - $postcode = new Zend_Form_Element_Text('postcode'); - $postcode->setLabel(_pro('Zip Code / Postal Code:')) - ->setValue($client["postcode"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($postcode); - - $locale = new Zend_Locale('en_US'); - $countries = $locale->getTranslationList('Territory', 'en', 2); - asort($countries, SORT_LOCALE_STRING); - - $country = new Zend_Form_Element_Select('country'); - $country->setLabel(_pro('Country:')) - ->setValue($client["country"]) - ->setAttrib('class', 'input_text') - ->setMultiOptions($countries) - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($country); - - $phonenumber = new Zend_Form_Element_Text('phonenumber'); - $phonenumber->setLabel(_pro('Phone Number:')) - ->setValue($client["phonenumber"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($phonenumber); - - $securityqid = new Zend_Form_Element_Select('securityqid'); - $securityqid->setLabel(_pro('Please choose a security question:')) - ->setValue($client["securityqid"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->setMultiOptions(array( - "1" => _("What is the name of your favorite childhood friend?"), - "3" => _("What school did you attend for sixth grade?"), - "4" => _("In what city did you meet your spouse/significant other?"), - "5" => _("What street did you live on in third grade?"), - "6" => _("What is the first name of the boy or girl that you first kissed?"), - "7" => _("In what city or town was your first job?"))); - $this->addElement($securityqid); - - $securityqans = new Zend_Form_Element_Text('securityqans'); - $securityqans->setLabel(_pro('Please enter an answer:')) - ->setValue($client["securityqans"]) - ->setAttrib('class', 'input_text') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($securityqans); - - foreach ($client["customfields"] as $field) { - if ($field["id"] == "7") { - $vatvalue = $field["value"]; - } elseif ($field["id"] == "71") { - $subscribevalue = $field["value"]; - } - } - - $vat = new Zend_Form_Element_Text("7"); - $vat->setLabel(_pro('VAT/Tax ID (EU only)')) - ->setBelongsTo('customfields') - ->setValue($vatvalue) - ->setAttrib('class', 'input_text') - //->setRequired(true) - //->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($vat); - - $subscribe = new Zend_Form_Element_Checkbox('71'); - $subscribe->setLabel(_pro('Subscribe to Sourcefabric newsletter')) - ->setValue($subscribevalue) - ->setBelongsTo('customfields') - ->setAttrib('class', 'billing-details-checkbox') - ->setRequired(true) - ->addValidator($notEmptyValidator) - ->addFilter('StringTrim'); - $this->addElement($subscribe); - - $password = new Zend_Form_Element_Password('password2'); - $password->setLabel(_pro('Password:')); - $password->setAttrib('class', 'input_text'); - $password->setValue("xxxxxx"); - $password->setRequired(true); - $password->addFilter('StringTrim'); - $password->addValidator($notEmptyValidator); - $this->addElement($password); - - $passwordVerify = new Zend_Form_Element_Password('password2verify'); - $passwordVerify->setLabel(_pro('Verify Password:')); - $passwordVerify->setAttrib('class', 'input_text'); - $passwordVerify->setValue("xxxxxx"); - $passwordVerify->setRequired(true); - $passwordVerify->addFilter('StringTrim'); - //$passwordVerify->addValidator($notEmptyValidator); - $passwordVerify->addValidator('Identical', false, array('token' => 'password2')); - $passwordVerify->addValidator($notEmptyValidator); - $this->addElement($passwordVerify); - - $this->addElement('hash', 'csrf_client', array( - 'salt' => 'unique' - )); - - $submit = new Zend_Form_Element_Submit("submit"); - $submit->setIgnore(true) - ->setLabel(_pro("Save")); - $this->addElement($submit); - } -} \ No newline at end of file diff --git a/airtime_mvc/application/forms/BillingUpgradeDowngrade.php b/airtime_mvc/application/forms/BillingUpgradeDowngrade.php deleted file mode 100644 index f0a37ab8d..000000000 --- a/airtime_mvc/application/forms/BillingUpgradeDowngrade.php +++ /dev/null @@ -1,57 +0,0 @@ -addElement('hash', 'csrf_upgrade', array( //Needs a unique ID (csrf_upgrade) so it doesn't conflict with other tokens in subforms - 'salt' => 'unique' - )); - - $productPrices = array(); - $productTypes = array(); - list($productPrices, $productTypes) = Billing::getProductPricesAndTypes(); - - $currentPlanProduct = Billing::getClientCurrentAirtimeProduct(); - $currentPlanProductId = $currentPlanProduct["pid"]; - - $currentPlanProductBillingCycle = $currentPlanProduct["billingcycle"]; - $pid = new Zend_Form_Element_Radio('newproductid'); - $pid->setLabel(_('Plan type:')) - ->setMultiOptions($productTypes) - ->setRequired(true) - ->setValue($currentPlanProductId); - $this->addElement($pid); - - //Logging::info(BillingController::getClientCurrentAirtimeProduct()); - $billingcycle = new Zend_Form_Element_Radio('newproductbillingcycle'); - $billingCycleOptionMap = array('monthly' => 'Monthly', 'annually' => 'Annually (Holiday Promo)'); - if (!array_key_exists($currentPlanProductBillingCycle, $billingCycleOptionMap)) { - $currentPlanProductBillingCycle = 'monthly'; - } - $billingcycle->setLabel(_('Billing cycle:')) - ->setMultiOptions($billingCycleOptionMap) - ->setRequired(true) - ->setValue($currentPlanProductBillingCycle); - - $this->addElement($billingcycle); - - $paymentmethod = new Zend_Form_Element_Radio('paymentmethod'); - $paymentmethod->setLabel(_('Payment method:')) - ->setRequired(true) - ->setMultiOptions(array( - 'paypal' => _('PayPal'), - 'tco' => _('Credit Card via 2Checkout'))) - ->setValue('paypal'); - $this->addElement($paymentmethod); - - /*$submit = new Zend_Form_Element_Submit("submit"); - $submit->setIgnore(true) - ->setLabel(_("Save")); - $this->addElement($submit);*/ - - $client = new Application_Form_BillingClient(); - $client->removeElement("password2"); - $client->removeElement("password2verify"); - $this->addSubForm($client, 'billing_client_info'); - } -} diff --git a/airtime_mvc/application/forms/EditUser.php b/airtime_mvc/application/forms/EditUser.php index cfe6ca790..e262118ce 100644 --- a/airtime_mvc/application/forms/EditUser.php +++ b/airtime_mvc/application/forms/EditUser.php @@ -130,18 +130,6 @@ class Application_Form_EditUser extends Zend_Form $timezone->setValue($userTz == $stationTz ? null : $userTz); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); - - if (LIBRETIME_ENABLE_BILLING === true && Application_Model_User::getCurrentUser()->isSuperAdmin()) { - $elemsToDisable = array($password, $passwordVerify, $email, $firstName, $lastName, - $cellPhone, $skype, $jabber); - foreach ($elemsToDisable as $element) { - //$this->_redirect('billing/client'); - $element->setAttrib('disabled', 'disabled'); - $element->setAttrib('readonly', 'readonly'); - $element->setRequired(false); - } - } - } public function validateLogin($p_login, $p_userId) { diff --git a/airtime_mvc/application/forms/Login.php b/airtime_mvc/application/forms/Login.php index d9713852a..5e7cfef25 100644 --- a/airtime_mvc/application/forms/Login.php +++ b/airtime_mvc/application/forms/Login.php @@ -11,7 +11,7 @@ class Application_Form_Login extends Zend_Form $this->setMethod('post'); //If the request comes from an origin we consider safe, we disable the CSRF - //token checking ONLY for the login page. We do this to allow logins from WHMCS to work. + //token checking ONLY for the login page. $request = Zend_Controller_Front::getInstance()->getRequest(); if ($request) { $refererUrl = $request->getHeader('referer'); diff --git a/airtime_mvc/application/layouts/scripts/audio-player.phtml b/airtime_mvc/application/layouts/scripts/audio-player.phtml index f4ce75a59..c748ea0a8 100644 --- a/airtime_mvc/application/layouts/scripts/audio-player.phtml +++ b/airtime_mvc/application/layouts/scripts/audio-player.phtml @@ -5,7 +5,6 @@