public function preResolve(\Cx\Core\Routing\Url $url) { if ($this->cx->getMode() != \Cx\Core\Core\Controller\Cx::MODE_FRONTEND) { return; } $em = $this->cx->getDb()->getEntityManager(); $rewriteRuleRepo = $em->getRepository($this->getNamespace() . '\\Model\\Entity\\RewriteRule'); $rewriteRules = $rewriteRuleRepo->findAll(array(), array('order' => 'asc')); $last = false; $originalUrl = clone $url; foreach ($rewriteRules as $rewriteRule) { try { $url = $rewriteRule->resolve($url, $last); } catch (\Exception $e) { // This is thrown if the regex of the rule is not valid } if ($last) { break; } } if ($originalUrl->toString() != $url->toString()) { if ($rewriteRule->getRewriteStatusCode() != \Cx\Core\Routing\Model\Entity\RewriteRule::REDIRECTION_TYPE_INTERN) { $headers = array('Location' => $url->toString()); if ($rewriteRule->getRewriteStatusCode() == 301) { array_push($headers, $_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently'); } $this->getComponent('Cache')->writeCacheFileForRequest(null, $headers, ''); \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . $url->toString(), true, $rewriteRule->getRewriteStatusCode()); die; } try { \DBG::log('Fetching content from ' . $url->toString()); $request = new \HTTP_Request2($url->toString(), \HTTP_Request2::METHOD_GET); $request->setConfig(array('follow_redirects' => true)); $response = $request->send(); $content = $response->getBody(); foreach ($response->getHeader() as $key => $value) { if (in_array($key, array('content-encoding', 'transfer-encoding'))) { continue; } \Cx\Core\Csrf\Controller\Csrf::header($key . ':' . $value); } $continue = false; die($content); } catch (\HTTP_Request2_Exception $e) { \DBG::dump($e); } } }
/** * Clears a cache page * @param string $urlPattern Drop all pages that match the pattern, for exact format, make educated guesses * @param string $domain Domain name to drop cache page of * @param int $port Port to drop cache page of */ protected function clearCachePageForDomainAndPort($urlPattern, $domain, $port) { $errno = 0; $errstr = ''; $varnishSocket = fsockopen($this->hostname, $this->port, $errno, $errstr); if (!$varnishSocket) { \DBG::log('Varnish error: ' . $errstr . ' (' . $errno . ') on server ' . $this->hostname . ':' . $this->port); } $domainOffset = ASCMS_PATH_OFFSET; $request = 'BAN ' . $domainOffset . $urlPattern . " HTTP/1.0\r\n"; $request .= 'Host: ' . $domain . ':' . $port . "\r\n"; $request .= "User-Agent: Cloudrexx Varnish Cache Clear\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($varnishSocket, $request); fclose($varnishSocket); }
public static function processRequest($token, $arrOrder) { global $_CONFIG; if (empty($token)) { return array('status' => 'error', 'message' => 'invalid token'); } $testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0; $apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_private_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_private_key', 'Shop'); if ($token) { try { $request = new Paymill\Request($apiKey); $transaction = new Paymill\Models\Request\Transaction(); $transaction->setAmount($arrOrder['amount'])->setCurrency($arrOrder['currency'])->setToken($token)->setDescription($arrOrder['note'])->setSource('contrexx_' . $_CONFIG['coreCmsVersion']); DBG::log("Transactoin created with token:" . $token); $response = $request->create($transaction); $paymentId = $response->getId(); DBG::log("Payment ID" . $paymentId); return array('status' => 'success', 'payment_id' => $paymentId); } catch (\Paymill\Services\PaymillException $e) { //Do something with the error informations below return array('status' => 'error', 'response_code' => $e->getResponseCode(), 'status_code' => $e->getStatusCode(), 'message' => $e->getErrorMessage()); } } }
/** * Returns a string to display the table header for the given field name. * * Uses the order currently stored in the object, as set by setOrder(). * The optional $direction overrides the current state of the * order direction. * @param string $field The field name * @param string $direction The optional direction * @return string The string for a clickable table * header field. * @author Reto Kohli <*****@*****.**> */ function getHeaderForField($field, $direction = null) { global $_CORELANG; //\DBG::log("Sorting::getHeaderForField(field=$field): field names: ".var_export($this->arrField, true)); // The field may consist of the database field name // enclosed in backticks, plus optional direction $index = self::getFieldindex($field); //\DBG::log("Sorting::getHeaderForField($field): Fixed"); if (empty($index)) { \DBG::log("Sorting::getHeaderForField({$field}): WARNING: Cannot make index for {$field}"); return ''; } $direction_orig = null; if ($direction) { $direction_orig = $this->orderDirection; $this->setOrderDirection($direction); $direction = $this->getOrderDirection(); // Fixed case! } //\DBG::log("Sorting::getHeaderForField($field): direction $direction, direction_orig $direction_orig, orderDirection $this->orderDirection"); $uri = $this->baseUri; Html::replaceUriParameter($uri, $direction ? $this->getOrderUriEncoded($field) : $this->getOrderReverseUriEncoded($field)); //\DBG::log("Sorting::getHeaderForField($field): URI $uri"); $strHeader = Html::getLink($uri, ($direction ? sprintf($_CORELANG['TXT_CORE_SORTING_FORMAT_' . $this->orderDirection], $this->arrField[$index]) : $this->arrField[$index]) . ($this->orderField == $index && ($direction === null || $direction === $direction_orig) ? ' ' . $this->getOrderDirectionImage() : '')); //echo("Sorting::getHeaderForField(fieldName=$field): made header: ".htmlentities($strHeader)."<br />"); if ($direction_orig) { $this->orderDirection = $direction_orig; } return $strHeader; }
private function checkModRewrite() { global $_CONFIG; if ($this->_isNewerVersion('3.0.0', $_CONFIG['coreCmsVersion'])) { return true; } if (function_exists('apache_get_modules')) { $apacheModules = apache_get_modules(); $modRewrite = in_array('mod_rewrite', $apacheModules); } else { try { include_once UPDATE_LIB . '/PEAR/HTTP/Request2.php'; $request = new HTTP_Request2('http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['SCRIPT_NAME'], 0, -9) . 'rewrite_test/'); $objResponse = $request->send(); $arrHeaders = $objResponse->getHeader(); } catch (\HTTP_Request2_Exception $e) { \DBG::log($e->getMessage()); } if (empty($arrHeaders['location'])) { $modRewrite = 'warning'; } else { if (strpos($arrHeaders['location'], 'weiterleitungen_funktionieren') !== false) { $modRewrite = true; } else { $modRewrite = false; } } } return $modRewrite; }
/** * Generate a component.yml for each theme available on the system * only used in update process for fixing invalid themes */ public function convertAllThemesToComponent() { foreach ($this->findAll() as $theme) { if ($theme->isComponent()) { continue; } try { $this->convertThemeToComponent($theme); } catch (\Exception $ex) { \DBG::log($ex->getMessage()); \DBG::log($theme->getThemesname() . ' : Unable to convert theme to component'); } } }
/** * Updates a setting * * If the setting name exists and the new value is not equal to * the old one, it is updated, and $changed set to true. * Otherwise, nothing happens, and false is returned * @see init(), updateAll() * @param string $name The settings name * @param string $value The settings value * @return boolean True if the value has been changed, * false otherwise, null on noop */ public function set($name, $value) { if (!isset($this->arrSettings[$name])) { \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\Engine::set({$name}, {$value}): Unknown, changed: " . $this->changed); return false; } if ($this->arrSettings[$name]['value'] == $value) { \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\Engine::set({$name}, {$value}): Identical, changed: " . $this->changed); return null; } $this->changed = true; $this->arrSettings[$name]['value'] = $value; \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\Engine::set({$name}, {$value}): Added/updated, changed: " . $this->changed); return true; }
/** * Get the news ID list based on the category * * @param integer $categoryId * * @global object $objDatabase * * @return mixed boolean|array */ public function getCategoryRelNews($categoryId) { global $objDatabase; if (empty($categoryId)) { return false; } $query = 'SELECT `news_id` FROM `' . DBPREFIX . 'module_news_rel_categories` WHERE `category_id` = "' . $categoryId . '"'; $objCategoryNewsList = $objDatabase->Execute($query); if (!$objCategoryNewsList) { \DBG::log('No News entries found on the category ID: ' . $categoryId); return false; } $newsIdList = array(); while (!$objCategoryNewsList->EOF) { $newsIdList[] = $objCategoryNewsList->fields['news_id']; $objCategoryNewsList->MoveNext(); } return $newsIdList; }
/** * Crawler spider -> crawl all the links present in the sitemap file. * * @return null */ public function crawlerSpider() { try { //initialize $runStartTime = new \DateTime('now'); $inputArray = array('lang' => contrexx_raw2db($this->langId), 'startTime' => $runStartTime, 'endTime' => $runStartTime, 'totalLinks' => 0, 'totalBrokenLinks' => 0, 'runStatus' => contrexx_raw2db(self::RUN_STATUS_RUNNING)); $lastInsertedRunId = $this->modifyCrawler($inputArray); $request = new \HTTP_Request2(); $sitemapPath = ASCMS_DOCUMENT_ROOT . '/sitemap_' . $this->langName . '.xml'; if (file_exists($sitemapPath)) { $sitemapXml = simplexml_load_file($sitemapPath); foreach ($sitemapXml->children() as $child) { foreach ($child as $value) { if ($value->getName() == 'loc') { $page = $this->isModulePage((string) $value); if ($page && $page->getType() == self::TYPE_CONTENT) { $this->initializeScript((string) $value, $request, $page->getId()); $this->checkMemoryLimit($lastInsertedRunId); //$this->checkTimeoutLimit($lastInsertedRunId); } } } } } else { $this->updateCrawlerStatus($lastInsertedRunId, self::RUN_STATUS_INCOMPLETE); \DBG::log('No sitemap found for language ' . $this->langName . '. Please save a page so the sitemap can be build.'); return; } //move the uncalled links from link table to history table $this->updateHistory($this->langId, $lastInsertedRunId); //get the total links and total broken links $totalLinks = $this->linkRepo->getLinksCountByLang($runStartTime->format(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME), $this->langId); $totalBrokenLinks = $this->linkRepo->brokenLinkCountByLang($this->langId); //save the run details $crawlerRuns = $this->crawlerRepo->findOneBy(array('id' => $lastInsertedRunId)); if ($crawlerRuns) { $inputArray = array('lang' => contrexx_raw2db($this->langId), 'startTime' => $runStartTime, 'totalLinks' => contrexx_raw2db($totalLinks), 'totalBrokenLinks' => contrexx_raw2db($totalBrokenLinks), 'runStatus' => contrexx_raw2db(self::RUN_STATUS_COMPLETED)); $crawlerRuns->updateEndTime(); $this->modifyCrawler($inputArray, $crawlerRuns); } } catch (\Exception $error) { $this->updateCrawlerStatus('', self::RUN_STATUS_INCOMPLETE); die('Error occurred' . $error); } }
/** * Processes the Order * * Verifies all data, updates and stores it in the database, and * initializes payment * @return boolean True on successs, false otherwise */ static function process() { global $objDatabase, $_ARRAYLANG; // FOR TESTING ONLY (repeatedly process/store the order, also disable self::destroyCart()) //$_SESSION['shop']['order_id'] = NULL; // Verify that the order hasn't yet been saved // (and has thus not yet been confirmed) if (isset($_SESSION['shop']['order_id'])) { return \Message::error($_ARRAYLANG['TXT_ORDER_ALREADY_PLACED']); } // No more confirmation self::$objTemplate->hideBlock('shopConfirm'); // Store the customer, register the order $customer_ip = $_SERVER['REMOTE_ADDR']; $customer_host = substr(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 0, 100); $customer_browser = substr(getenv('HTTP_USER_AGENT'), 0, 100); $new_customer = false; //\DBG::log("Shop::process(): E-Mail: ".$_SESSION['shop']['email']); if (self::$objCustomer) { //\DBG::log("Shop::process(): Existing User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']); } else { // Registered Customers are required to be logged in! self::$objCustomer = Customer::getRegisteredByEmail($_SESSION['shop']['email']); if (self::$objCustomer) { \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_REGISTERED_EMAIL']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'confirm'))); } // Unregistered Customers are stored as well, as their information is needed // nevertheless. Their active status, however, is set to false. self::$objCustomer = Customer::getUnregisteredByEmail($_SESSION['shop']['email']); if (!self::$objCustomer) { self::$objCustomer = new Customer(); // Currently, the e-mail address is set as the user name $_SESSION['shop']['username'] = $_SESSION['shop']['email']; //\DBG::log("Shop::process(): New User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']); self::$objCustomer->username($_SESSION['shop']['username']); self::$objCustomer->email($_SESSION['shop']['email']); // Note that the password is unset when the Customer chooses // to order without registration. The generated one // defaults to length 8, fulfilling the requirements for // complex passwords. And it's kept absolutely secret. $password = empty($_SESSION['shop']['password']) ? \User::make_password() : $_SESSION['shop']['password']; //\DBG::log("Password: $password (session: {$_SESSION['shop']['password']})"); if (!self::$objCustomer->password($password)) { \Message::error($_ARRAYLANG['TXT_INVALID_PASSWORD']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account')); } self::$objCustomer->active(empty($_SESSION['shop']['dont_register'])); $new_customer = true; } } // Update the Customer object from the session array // (whether new or not -- it may have been edited) self::$objCustomer->gender($_SESSION['shop']['gender']); self::$objCustomer->firstname($_SESSION['shop']['firstname']); self::$objCustomer->lastname($_SESSION['shop']['lastname']); self::$objCustomer->company($_SESSION['shop']['company']); self::$objCustomer->address($_SESSION['shop']['address']); self::$objCustomer->city($_SESSION['shop']['city']); self::$objCustomer->zip($_SESSION['shop']['zip']); self::$objCustomer->country_id($_SESSION['shop']['countryId']); self::$objCustomer->phone($_SESSION['shop']['phone']); self::$objCustomer->fax($_SESSION['shop']['fax']); $arrGroups = self::$objCustomer->getAssociatedGroupIds(); $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); if (empty($usergroup_id)) { //\DBG::log("Shop::process(): ERROR: Missing reseller group"); \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')); } if (!in_array($usergroup_id, $arrGroups)) { //\DBG::log("Shop::process(): Customer is not in Reseller group (ID $usergroup_id)"); // Not a reseller. See if she's a final customer $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); if (empty($usergroup_id)) { //\DBG::log("Shop::process(): ERROR: Missing final customer group"); \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')); } if (!in_array($usergroup_id, $arrGroups)) { //\DBG::log("Shop::process(): Customer is not in final customer group (ID $usergroup_id), either"); // Neither one, add to the final customer group (default) $arrGroups[] = $usergroup_id; self::$objCustomer->setGroups($arrGroups); //\DBG::log("Shop::process(): Added Customer to final customer group (ID $usergroup_id): ".var_export(self::$objCustomer->getAssociatedGroupIds(), true)); } else { //\DBG::log("Shop::process(): Customer is a final customer (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true)); } } else { //\DBG::log("Shop::process(): Customer is a Reseller (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true)); } // Insert or update the customer //\DBG::log("Shop::process(): Storing Customer: ".var_export(self::$objCustomer, true)); if (!self::$objCustomer->store()) { return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']); } // Authenticate new Customer if ($new_customer) { // Fails for "unregistered" Customers! if (self::$objCustomer->auth($_SESSION['shop']['username'], $_SESSION['shop']['password'], false, true)) { if (!self::_authenticate()) { return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']); } } } //die(); // Clear the ship-to country if there is no shipping if (!Cart::needs_shipment()) { $_SESSION['shop']['countryId2'] = 0; } $shipper_id = empty($_SESSION['shop']['shipperId']) ? null : $_SESSION['shop']['shipperId']; $payment_id = empty($_SESSION['shop']['paymentId']) ? null : $_SESSION['shop']['paymentId']; $objOrder = new Order(); $objOrder->customer_id(self::$objCustomer->id()); $objOrder->billing_gender($_SESSION['shop']['gender']); $objOrder->billing_firstname($_SESSION['shop']['firstname']); $objOrder->billing_lastname($_SESSION['shop']['lastname']); $objOrder->billing_company($_SESSION['shop']['company']); $objOrder->billing_address($_SESSION['shop']['address']); $objOrder->billing_city($_SESSION['shop']['city']); $objOrder->billing_zip($_SESSION['shop']['zip']); $objOrder->billing_country_id($_SESSION['shop']['countryId']); $objOrder->billing_phone($_SESSION['shop']['phone']); $objOrder->billing_fax($_SESSION['shop']['fax']); $objOrder->billing_email($_SESSION['shop']['email']); $objOrder->currency_id($_SESSION['shop']['currencyId']); $objOrder->sum($_SESSION['shop']['grand_total_price']); $objOrder->date_time(date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME)); $objOrder->status(0); $objOrder->company($_SESSION['shop']['company2']); $objOrder->gender($_SESSION['shop']['gender2']); $objOrder->firstname($_SESSION['shop']['firstname2']); $objOrder->lastname($_SESSION['shop']['lastname2']); $objOrder->address($_SESSION['shop']['address2']); $objOrder->city($_SESSION['shop']['city2']); $objOrder->zip($_SESSION['shop']['zip2']); $objOrder->country_id($_SESSION['shop']['countryId2']); $objOrder->phone($_SESSION['shop']['phone2']); $objOrder->vat_amount($_SESSION['shop']['vat_price']); $objOrder->shipment_amount($_SESSION['shop']['shipment_price']); $objOrder->shipment_id($shipper_id); $objOrder->payment_id($payment_id); $objOrder->payment_amount($_SESSION['shop']['payment_price']); $objOrder->ip($customer_ip); $objOrder->host($customer_host); $objOrder->lang_id(FRONTEND_LANG_ID); $objOrder->browser($customer_browser); $objOrder->note($_SESSION['shop']['note']); if (!$objOrder->insert()) { // $order_id is unset! return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_STORING']); } $order_id = $objOrder->id(); $_SESSION['shop']['order_id'] = $order_id; // The products will be tested one by one below. // If any single one of them requires delivery, this // flag will be set to true. // This is used to determine the order status at the // end of the shopping process. $_SESSION['shop']['isDelivery'] = false; // Try to redeem the Coupon, if any $coupon_code = isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : null; //\DBG::log("Cart::update(): Coupon Code: $coupon_code"); $items_total = 0; // Suppress Coupon messages (see Coupon::available()) \Message::save(); foreach (Cart::get_products_array() as $arrProduct) { $objProduct = Product::getById($arrProduct['id']); if (!$objProduct) { unset($_SESSION['shop']['order_id']); return \Message::error($_ARRAYLANG['TXT_ERROR_LOOKING_UP_ORDER']); } $product_id = $arrProduct['id']; $name = $objProduct->name(); $priceOptions = !empty($arrProduct['optionPrice']) ? $arrProduct['optionPrice'] : 0; $quantity = $arrProduct['quantity']; $price = $objProduct->get_custom_price(self::$objCustomer, $priceOptions, $quantity); $item_total = $price * $quantity; $items_total += $item_total; $productVatId = $objProduct->vat_id(); $vat_rate = $productVatId && Vat::getRate($productVatId) ? Vat::getRate($productVatId) : '0.00'; // Test the distribution method for delivery $productDistribution = $objProduct->distribution(); if ($productDistribution == 'delivery') { $_SESSION['shop']['isDelivery'] = true; } $weight = $productDistribution == 'delivery' ? $objProduct->weight() : 0; // grams if ($weight == '') { $weight = 0; } // Add to order items table $result = $objOrder->insertItem($order_id, $product_id, $name, $price, $quantity, $vat_rate, $weight, $arrProduct['options']); if (!$result) { unset($_SESSION['shop']['order_id']); // TODO: Verify error message set by Order::insertItem() return false; } // Store the Product Coupon, if applicable. // Note that it is not redeemed yet (uses=0)! if ($coupon_code) { $objCoupon = Coupon::available($coupon_code, $item_total, self::$objCustomer->id(), $product_id, $payment_id); if ($objCoupon) { //\DBG::log("Shop::process(): Got Coupon for Product ID $product_id: ".var_export($objCoupon, true)); if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $price * $quantity, 0)) { // TODO: Do something if the Coupon does not work \DBG::log("Shop::process(): ERROR: Failed to store Coupon for Product ID {$product_id}"); } $coupon_code = null; } } } // foreach product in cart // Store the Global Coupon, if applicable. // Note that it is not redeemed yet (uses=0)! //\DBG::log("Shop::process(): Looking for global Coupon $coupon_code"); if ($coupon_code) { $objCoupon = Coupon::available($coupon_code, $items_total, self::$objCustomer->id(), null, $payment_id); if ($objCoupon) { //\DBG::log("Shop::process(): Got global Coupon: ".var_export($objCoupon, true)); if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $items_total, 0)) { \DBG::log("Shop::process(): ERROR: Failed to store global Coupon"); } } } \Message::restore(); $processor_id = Payment::getProperty($_SESSION['shop']['paymentId'], 'processor_id'); $processor_name = PaymentProcessing::getPaymentProcessorName($processor_id); // other payment methods PaymentProcessing::initProcessor($processor_id); // TODO: These arguments are no longer valid. Set them up later? // Currency::getActiveCurrencyCode(), // FWLanguage::getLanguageParameter(FRONTEND_LANG_ID, 'lang')); // if the processor is Internal_LSV, and there is account information, // store the information. if ($processor_name == 'internal_lsv') { if (!self::lsv_complete()) { // Missing mandatory data; return to payment unset($_SESSION['shop']['order_id']); \Message::error($_ARRAYLANG['TXT_ERROR_ACCOUNT_INFORMATION_NOT_AVAILABLE']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment')); } $query = "\n INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv (\n order_id, holder, bank, blz\n ) VALUES (\n {$order_id},\n '" . contrexx_raw2db($_SESSION['shop']['account_holder']) . "',\n '" . contrexx_raw2db($_SESSION['shop']['account_bank']) . "',\n '" . contrexx_raw2db($_SESSION['shop']['account_blz']) . "'\n )"; $objResult = $objDatabase->Execute($query); if (!$objResult) { // Return to payment unset($_SESSION['shop']['order_id']); \Message::error($_ARRAYLANG['TXT_ERROR_INSERTING_ACCOUNT_INFORMATION']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment')); } } $_SESSION['shop']['order_id_checkin'] = $order_id; $strProcessorType = PaymentProcessing::getCurrentPaymentProcessorType(); // Test whether the selected payment method can be // considered an instant or deferred one. // This is used to set the order status at the end // of the shopping process. // TODO: Invert this flag, as it may no longer be present after paying // online using one of the external payment methods! Ensure that it is set // instead when paying "deferred". $_SESSION['shop']['isInstantPayment'] = false; if ($strProcessorType == 'external') { // For the sake of simplicity, all external payment // methods are considered to be 'instant'. // All currently implemented internal methods require // further action from the merchant, and thus are // considered to be 'deferred'. $_SESSION['shop']['isInstantPayment'] = true; } // Send the Customer login separately, as the password possibly // won't be available later if (!empty($_SESSION['shop']['password'])) { self::sendLogin(self::$objCustomer->email(), $_SESSION['shop']['password']); } // Show payment processing page. // Note that some internal payments are redirected away // from this page in checkOut(): // 'internal', 'internal_lsv' self::$objTemplate->setVariable('SHOP_PAYMENT_PROCESSING', PaymentProcessing::checkOut()); // Clear the order ID. // The order may be resubmitted and the payment retried. unset($_SESSION['shop']['order_id']); // Custom. // Enable if Discount class is customized and in use. //self::showCustomerDiscount(Cart::get_price()); return true; }
function paymentYellowpay($order_id, $amount) { global $_ARRAYLANG, $_LANGID; // Prepare payment using current settings and customer selection $product_id = self::GetOrderValue('order_product', $order_id); if (empty($product_id)) { return 'alert("' . $_ARRAYLANG['TXT_EGOV_ERROR_PROCESSING_ORDER'] . "\");\n"; } $quantity = self::GetProduktValue('product_per_day', $product_id) == 'yes' ? intval($_REQUEST['contactFormField_Quantity']) : 1; $product_amount = !empty($amount) ? $amount : self::GetProduktValue('product_price', $product_id) * $quantity; \Cx\Core\Setting\Controller\Setting::init('Egov', 'config'); $arrOrder = array('ORDERID' => $order_id, 'AMOUNT' => $product_amount, 'CURRENCY' => self::GetProduktValue('product_paypal_currency', $product_id), 'PARAMPLUS' => 'section=Egov&order_id=' . $order_id . '&handler=yellowpay', 'COM' => self::GetProduktValue('product_name', $product_id)); $_POST = contrexx_input2raw($_POST); // Note that none of these fields is present in the post in the current // implementation! The meaning cannot be guessed from the actual field // names (i.e. "contactFormField_17"). $arrOrder['CN'] = ''; if (!empty($_POST['Vorname'])) { $arrOrder['CN'] = $_POST['Vorname']; } if (!empty($_POST['Nachname'])) { $arrOrder['CN'] .= ($arrOrder['CN'] ? ' ' : '') . $_POST['Nachname']; } if (!empty($_POST['Adresse'])) { $arrOrder['OWNERADDRESS'] = $_POST['Adresse']; } if (!empty($_POST['PLZ'])) { $arrOrder['OWNERZIP'] = $_POST['PLZ']; } if (!empty($_POST['Ort'])) { $arrOrder['OWNERTOWN'] = $_POST['Ort']; } if (!empty($_POST['Land'])) { $arrOrder['OWNERCTY'] = $_POST['Land']; } if (!empty($_POST['Telefon'])) { $arrOrder['OWNERTELNO'] = $_POST['Telefon']; } if (!empty($_POST['EMail'])) { $arrOrder['EMAIL'] = $_POST['EMail']; } $landingPage = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneByModuleCmdLang('Egov', '', FRONTEND_LANG_ID); $yellowpayForm = \Yellowpay::getForm($arrOrder, 'Send', false, null, $landingPage); if (count(\Yellowpay::$arrError)) { \DBG::log("Yellowpay could not be initialized:\n" . join("\n", \Yellowpay::$arrError)); die; } die("<!DOCTYPE html>\n<html>\n <head>\n <title>Yellowpay</title>\n </head>\n <body>\n{$yellowpayForm}\n </body>\n</html>\n"); // Test/debug: die(htmlentities($yellowpayForm)); }
public function testDeleteGroupFromFileSystem() { \DBG::log('*** testDeleteGroupFromFileSystem ***'); $this->addValuesFileSystem(); Setting::init('MultiSiteTest', 'testgroup7', 'FileSystem'); Setting::delete(null, 'testgroup7'); Setting::flush(); $this->assertNull(Setting::getValue('key7.1')); $this->assertNull(Setting::getValue('key7.2')); $this->deleteValuesFileSystem(); }
/** * Clears Varnish cache */ private function clearVarnishCache() { global $_CONFIG; if (!isset($_CONFIG['cacheVarnishStatus']) || $_CONFIG['cacheVarnishStatus'] != 'on') { return; } $varnishConfiguration = $this->getVarnishConfiguration(); $varnishSocket = fsockopen($varnishConfiguration['ip'], $varnishConfiguration['port'], $errno, $errstr); if (!$varnishSocket) { \DBG::log("Varnish error: {$errstr} ({$errno}) on server {$varnishConfiguration['ip']}:{$varnishConfiguration['port']}"); } $requestDomain = $_CONFIG['domainUrl']; $domainOffset = ASCMS_PATH_OFFSET; $request = "BAN {$domainOffset} HTTP/1.0\r\n"; $request .= "Host: {$requestDomain}\r\n"; $request .= "User-Agent: Cloudrexx Varnish Cache Clear\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($varnishSocket, $request); fclose($varnishSocket); }
/** * Checking memory limit * * @param type $requiredMemoryLimit required memory limit * * @return boolean */ function checkMemoryLimit($requiredMemoryLimit) { if (empty($this->memoryLimit)) { $memoryLimit = \FWSystem::getBytesOfLiteralSizeFormat(@ini_get('memory_limit')); //if memory limit is empty then set default php memory limit of 8MiBytes $this->memoryLimit = !empty($memoryLimit) ? $memoryLimit : self::MiB2 * 4; } $potentialRequiredMemory = memory_get_usage() + $requiredMemoryLimit; if ($potentialRequiredMemory > $this->memoryLimit) { // try to set a higher memory_limit if (!@ini_set('memory_limit', $potentialRequiredMemory)) { \DBG::log('The link spider script is interrupted due to insufficient memory is available.'); return false; } } return true; }
/** * Store the website details into the YML file * * @param string $folderPath * @param string $filePath * @param array $ymlContent * * @return null */ public function storeUpdateWebsiteDetailsToYml($folderPath, $filePath, $ymlContent) { if (empty($folderPath) || empty($filePath)) { return; } try { if (!file_exists($folderPath)) { \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath); } $file = new \Cx\Lib\FileSystem\File($filePath); $file->touch(); $yaml = new \Symfony\Component\Yaml\Yaml(); $file->write($yaml->dump(array('PendingCodeBaseChanges' => $ymlContent))); } catch (\Exception $e) { \DBG::log($e->getMessage()); } }
/** * Get the client record * * @return GeoIp2\Model\Country */ public function getClientRecord() { if ($this->clientRecord) { return $this->clientRecord; } //skip the process incase mode is not frontend or GeoIp is deactivated if (!$this->isGeoIpEnabled()) { return null; } // Get stats controller to get client ip $statsComponentContoller = $this->getComponent('Stats'); if (!$statsComponentContoller) { return null; } //Get the country name and code by using the ipaddress through GeoIp2 library $countryDb = $this->getDirectory() . '/Data/GeoLite2-Country.mmdb'; $activeLocale = \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID); $locale = in_array($activeLocale, $this->availableLocale) ? $activeLocale : $this->defaultLocale; try { $reader = new \GeoIp2\Database\Reader($countryDb, array($locale)); $this->clientRecord = $reader->country($statsComponentContoller->getCounterInstance()->getClientIp()); return $this->clientRecord; } catch (\Exception $e) { \DBG::log($e->getMessage()); return null; } }
/** * Add a new record to the settings * * The class *MUST* have been initialized by calling {@see init()} * or {@see getArray()} before this method is called. * The present $group stored in the class is used as a default. * If the current class $group is empty, it *MUST* be specified in the call. * @param string $name The setting name * @param string $value The value * @param integer $ord The ordinal value for sorting, * defaults to 0 * @param string $type The element type for displaying, * defaults to 'text' * @param string $values The values for type 'dropdown', * defaults to the empty string * @param string $group The optional group * @return boolean True on success, false otherwise */ function add($name, $value, $ord = false, $type = 'text', $values = '', $group = null) { global $objDatabase; if (!isset($this->section)) { // TODO: Error message \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\DbEngine::add(): ERROR: Empty section!"); return false; } // Fail if the name is invalid if (empty($name)) { \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\DbEngine::add(): ERROR: Empty name!"); return false; } // This can only be done with a non-empty group! // Use the current group, if present, otherwise fail if (!$group) { if (!$this->group) { \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\DbEngine::add(): ERROR: Empty group!"); return false; } $group = $this->group; } // Initialize if necessary if (is_null($this->arrSettings) || $this->group != $group) { $this->init($this->section, $group); } // Such an entry exists already, fail. // Note that getValue() returns null if the entry is not present $old_value = $this->getValue($name); if (isset($old_value)) { \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\DbEngine::add(): ERROR: Setting '{$name}' already exists and is non-empty ({$old_value})"); return false; } // Not present, insert it $query = "\n INSERT INTO `" . DBPREFIX . "core_setting` (\n `section`, `group`, `name`, `value`,\n `type`, `values`, `ord`\n ) VALUES (\n '" . addslashes($this->section) . "',\n '" . addslashes($group) . "',\n '" . addslashes($name) . "',\n '" . addslashes($value) . "',\n '" . addslashes($type) . "',\n '" . addslashes($values) . "',\n " . intval($ord) . "\n )"; $objResult = $objDatabase->Execute($query); if (!$objResult) { \DBG::log("\\Cx\\Core\\Setting\\Model\\Entity\\DbEngine::add(): ERROR: Query failed: {$query}"); return false; } $this->arrSettings[$name] = array('section' => $this->section, 'group' => $group, 'value' => $value, 'type' => $type, 'values' => $values, 'ord' => $ord); return true; }
private static function selectWhereIn($pdo, $what, $from, $in) { DBG::log(__CLASS__, __FUNCTION__, 'before:', array($what, $from, $in)); if (!is_array($in)) { $in = array($in); } $args = self::prepareArgs($in); $statement = 'SELECT ' . $what . ' FROM ' . $from . ' WHERE id IN(' . $args . ')'; $pdostatement = $pdo->prepare($statement); $pdostatement->execute($in); DBG::log(__CLASS__, __FUNCTION__, 'after:', $statement); return $pdostatement; }
static function getOptionPriceSum($attribute_id, $arrOptionId) { if (!is_array(self::$arrAttributes) && !self::initAttributeArray()) { return null; } if (empty(self::$arrAttributes[$attribute_id])) { \DBG::log("Attributes::getOptionPriceSum(): ERROR: unknown Attribute ID {$attribute_id} in Attributes!"); return null; } if (!is_array(self::$arrOptions) && !self::initOptionArray()) { return null; } if (empty(self::$arrOptions[$attribute_id])) { \DBG::log("Attributes::getOptionPriceSum(): ERROR: unknown Attribute ID {$attribute_id} in options!"); return null; } $optionPriceSum = 0; $arrOption = self::$arrOptions[$attribute_id]; // Single value types if (self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_TEXT_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_TEXT_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_UPLOAD_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_UPLOAD_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_TEXTAREA_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_TEXTAREA_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_EMAIL_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_EMAIL_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_URL_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_URL_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_DATE_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_DATE_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_NUMBER_INT_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_NUMBER_INT_MANDATORY || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_NUMBER_FLOAT_OPTIONAL || self::$arrAttributes[$attribute_id]['type'] == Attribute::TYPE_NUMBER_FLOAT_MANDATORY) { $arrOption = current($arrOption); $productOptionPrice = $arrOption['price']; $optionPriceSum += $productOptionPrice; //DBG::log("Attributes::getOptionPriceSum(): Attribute ID $attribute_id: price for text/file option: $productOptionPrice"); } else { // Others may have multiple values foreach ($arrOptionId as $option_id) { if (!is_numeric($option_id)) { \DBG::log("Attributes::getOptionPriceSum(): ERROR: option ID {$option_id} is not numeric!"); //DBG::log("Attributes::getOptionPriceSum(): Options Array #$index: ".var_export($arrOptionId, true)); continue; } $productOptionPrice = $arrOption[$option_id]['price']; $optionPriceSum += $productOptionPrice; //DBG::log("Attributes::getOptionPriceSum(): Attribute ID $attribute_id: price for regular option: $productOptionPrice"); } } return $optionPriceSum; }
/** * Delete Products from the ShopCategory given by its ID. * * If deleting one of the Products fails, aborts and returns false * immediately without trying to delete the remaining Products. * Deleting the ShopCategory after this method failed will most * likely result in Product bodies in the database! * @param integer $category_id The ShopCategory ID * @param boolean $flagDeleteImages Delete images, if true * @param boolean $recursive Delete Products from * subcategories, if true * @return boolean True on success, null on noop, * false otherwise * @static * @author Reto Kohli <*****@*****.**> */ static function deleteByShopCategory($category_id, $flagDeleteImages = false, $recursive = false) { // Verify that the Category still exists $objShopCategory = ShopCategory::getById($category_id); if (!$objShopCategory) { //\DBG::log("Products::deleteByShopCategory($category_id, $flagDeleteImages): Info: Category ID $category_id does not exist"); return null; } $arrProductId = Products::getIdArrayByShopCategory($category_id); if (!is_array($arrProductId)) { //\DBG::log("Products::deleteByShopCategory($category_id, $flagDeleteImages): Failed to get Product IDs in that Category"); return false; } // Look whether this is within a virtual ShopCategory $virtualContainer = ''; $parent_id = $category_id; do { $objShopCategory = ShopCategory::getById($parent_id); if (!$objShopCategory) { //\DBG::log("Products::deleteByShopCategory($category_id, $flagDeleteImages): Failed to get parent Category"); return false; } if ($objShopCategory->virtual()) { // The name of any virtual ShopCategory is used to mark // Products within $virtualContainer = $objShopCategory->name(); break; } $parent_id = $objShopCategory->parent_id(); } while ($parent_id != 0); // Remove the Products in one way or another foreach ($arrProductId as $product_id) { $objProduct = Product::getById($product_id); if (!$objProduct) { //\DBG::log("Products::deleteByShopCategory($category_id, $flagDeleteImages): Failed to get Product IDs $product_id"); return false; } if ($virtualContainer != '' && $objProduct->flags() != '') { // Virtual ShopCategories and their content depends on // the Product objects' flags. foreach ($arrProductId as $objProduct) { $objProduct->removeFlag($virtualContainer); if (!Products::changeFlagsByProductCode($objProduct->code(), $objProduct->flags())) { //\DBG::log("Products::deleteByShopCategory($category_id, $flagDeleteImages): Failed to update Product flags for ID ".$objProduct->id()); return false; } } } else { // Normal, non-virtual ShopCategory. // Remove Products having the same Product code. // Don't delete Products having more than one Category assigned. // Instead, remove them from the chosen Category only. $arrCategoryId = array_flip(preg_split('/\\s*,\\s*/', $objProduct->category_id(), null, PREG_SPLIT_NO_EMPTY)); if (count($arrCategoryId) > 1) { unset($arrCategoryId[$category_id]); $objProduct->category_id(join(',', array_keys($arrCategoryId))); if (!$objProduct->store()) { return false; } } else { // if (!Products::deleteByCode( // $objProduct->getCode(), // $flagDeleteImages) // ) return false; if (!$objProduct->delete()) { return false; } } } } if ($recursive) { $arrCategoryId = ShopCategories::getChildCategoriesById($category_id); foreach ($arrCategoryId as $category_id) { if (!self::deleteByShopCategory($category_id, $flagDeleteImages, $recursive)) { \DBG::log("ERROR: Failed to delete Products in Category ID {$category_id}"); return false; } } } return true; }
/** * Fixes database errors. * * @return boolean False. Always. * @throws \Cx\Lib\Update_DatabaseException */ static function init($configPath = null) { try { //site group \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('systemStatus') && !\Cx\Core\Setting\Controller\Setting::add('systemStatus', 'on', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Page Status"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('languageDetection') && !\Cx\Core\Setting\Controller\Setting::add('languageDetection', 'on', 2, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Auto Detect Language"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreGlobalPageTitle') && !\Cx\Core\Setting\Controller\Setting::add('coreGlobalPageTitle', 'Contrexx Example Website', 3, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Global Page Title"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('mainDomainId') && !\Cx\Core\Setting\Controller\Setting::add('mainDomainId', '0', 4, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '{src:\\' . __CLASS__ . '::getDomains()}', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Main Domain"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('forceDomainUrl') && !\Cx\Core\Setting\Controller\Setting::add('forceDomainUrl', 'off', 5, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Home Page Url"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreListProtectedPages') && !\Cx\Core\Setting\Controller\Setting::add('coreListProtectedPages', 'off', 6, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Protected Pages"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('searchVisibleContentOnly') && !\Cx\Core\Setting\Controller\Setting::add('searchVisibleContentOnly', 'on', 7, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Visible Contents"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('advancedUploadFrontend') && !\Cx\Core\Setting\Controller\Setting::add('advancedUploadFrontend', 'off', 8, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Visible Contents"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('forceProtocolFrontend') && !\Cx\Core\Setting\Controller\Setting::add('forceProtocolFrontend', 'none', 9, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '{src:\\' . __CLASS__ . '::getPortOptions()}', 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Protocol In Use"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('portFrontendHTTP') && !\Cx\Core\Setting\Controller\Setting::add('portFrontendHTTP', 80, 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'site')) { \DBG::log("Failed to add Setting entry for core HTTP Port (Frontend)"); throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for core HTTP Port (Frontend)"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('portFrontendHTTPS') && !\Cx\Core\Setting\Controller\Setting::add('portFrontendHTTPS', 443, 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'site')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for core HTTPS Port (Frontend)"); } //administrationArea group \Cx\Core\Setting\Controller\Setting::init('Config', 'administrationArea', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('dashboardNews') && !\Cx\Core\Setting\Controller\Setting::add('dashboardNews', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Dashboard News"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('dashboardNewsSrc') && !\Cx\Core\Setting\Controller\Setting::add('dashboardNewsSrc', 'http://www.contrexx.com/feed/news_headlines_de.xml', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for dashboardNewsSrc"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('dashboardStatistics') && !\Cx\Core\Setting\Controller\Setting::add('dashboardStatistics', 'on', 2, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Dashboard Statistics"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('advancedUploadBackend') && !\Cx\Core\Setting\Controller\Setting::add('advancedUploadBackend', 'on', 3, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for advanced Upload Tools"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('sessionLifeTime') && !\Cx\Core\Setting\Controller\Setting::add('sessionLifeTime', '3600', 4, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for session Length"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('sessionLifeTimeRememberMe') && !\Cx\Core\Setting\Controller\Setting::add('sessionLifeTimeRememberMe', '1209600', 5, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for session Length Remember"); } if (in_array('SystemInfo', \Env::get('cx')->getLicense()->getLegalComponentsList())) { if (!\Cx\Core\Setting\Controller\Setting::isDefined('dnsServer') && !\Cx\Core\Setting\Controller\Setting::add('dnsServer', 'ns1.contrexxhosting.com', 6, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Dns Server"); } } if (!\Cx\Core\Setting\Controller\Setting::isDefined('timezone') && !\Cx\Core\Setting\Controller\Setting::add('timezone', 'Europe/Zurich', 7, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '{src:\\' . __CLASS__ . '::getTimezoneOptions()}', 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Time zone"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('forceProtocolBackend') && !\Cx\Core\Setting\Controller\Setting::add('forceProtocolBackend', 'none', 8, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '{src:\\' . __CLASS__ . '::getPortOptions()}', 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Protocol In Use Administrator"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('portBackendHTTP') && !\Cx\Core\Setting\Controller\Setting::add('portBackendHTTP', 80, 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for core HTTP Port (Backend)"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('portBackendHTTPS') && !\Cx\Core\Setting\Controller\Setting::add('portBackendHTTPS', 443, 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'administrationArea')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for core HTTPS Port (Backend)"); } //security group \Cx\Core\Setting\Controller\Setting::init('Config', 'security', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreIdsStatus') && !\Cx\Core\Setting\Controller\Setting::add('coreIdsStatus', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'security')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Security system notifications "); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('passwordComplexity') && !\Cx\Core\Setting\Controller\Setting::add('passwordComplexity', 'off', 2, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'security')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Passwords must meet the complexity requirements"); } //contactInformation group \Cx\Core\Setting\Controller\Setting::init('Config', 'contactInformation', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreAdminName') && !\Cx\Core\Setting\Controller\Setting::add('coreAdminName', 'Administrator', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for core Admin Name"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreAdminEmail') && !\Cx\Core\Setting\Controller\Setting::add('coreAdminEmail', '*****@*****.**', 2, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for core Admin Email"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactFormEmail') && !\Cx\Core\Setting\Controller\Setting::add('contactFormEmail', '*****@*****.**', 3, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Form Email"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactCompany') && !\Cx\Core\Setting\Controller\Setting::add('contactCompany', 'Ihr Firmenname', 4, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Company"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactAddress') && !\Cx\Core\Setting\Controller\Setting::add('contactAddress', 'Musterstrasse 12', 5, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Address"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactZip') && !\Cx\Core\Setting\Controller\Setting::add('contactZip', '3600', 6, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Zip"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactPlace') && !\Cx\Core\Setting\Controller\Setting::add('contactPlace', 'Musterhausen', 7, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Place"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactCountry') && !\Cx\Core\Setting\Controller\Setting::add('contactCountry', 'Musterland', 8, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Country"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactPhone') && !\Cx\Core\Setting\Controller\Setting::add('contactPhone', '033 123 45 67', 9, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Phone"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('contactFax') && !\Cx\Core\Setting\Controller\Setting::add('contactFax', '033 123 45 68', 10, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'contactInformation')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for contact Fax"); } //otherConfigurations group \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('xmlSitemapStatus') && !\Cx\Core\Setting\Controller\Setting::add('xmlSitemapStatus', 'on', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for XML Sitemap"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('frontendEditingStatus') && !\Cx\Core\Setting\Controller\Setting::add('frontendEditingStatus', 'on', 2, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Frontend Editing"); } if (in_array('SystemInfo', \Env::get('cx')->getLicense()->getLegalComponentsList())) { if (!\Cx\Core\Setting\Controller\Setting::isDefined('useCustomizings') && !\Cx\Core\Setting\Controller\Setting::add('useCustomizings', 'off', 3, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Customizing"); } } if (!\Cx\Core\Setting\Controller\Setting::isDefined('corePagingLimit') && !\Cx\Core\Setting\Controller\Setting::add('corePagingLimit', '30', 4, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Records per page"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('searchDescriptionLength') && !\Cx\Core\Setting\Controller\Setting::add('searchDescriptionLength', '150', 5, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Number of Characters in Search Results"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('googleMapsAPIKey') && !\Cx\Core\Setting\Controller\Setting::add('googleMapsAPIKey', '', 6, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Google-Map API key "); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('googleAnalyticsTrackingId') && !\Cx\Core\Setting\Controller\Setting::add('googleAnalyticsTrackingId', '', 7, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'otherConfigurations')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for Google Analytics Tracking ID"); } // core \Cx\Core\Setting\Controller\Setting::init('Config', 'core', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreSmtpServer') && !\Cx\Core\Setting\Controller\Setting::add('coreSmtpServer', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'core')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreSmtpServer"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('lastAccessId') && !\Cx\Core\Setting\Controller\Setting::add('lastAccessId', '1', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, '', 'core')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for lastAccessId"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('installationId') && !\Cx\Core\Setting\Controller\Setting::add('installationId', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'core')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for installationId"); } // component \Cx\Core\Setting\Controller\Setting::init('Config', 'component', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('bannerStatus') && !\Cx\Core\Setting\Controller\Setting::add('bannerStatus', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for bannerStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('spamKeywords') && !\Cx\Core\Setting\Controller\Setting::add('spamKeywords', 'sex, viagra', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXTAREA, '', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for spamKeywords"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('newsTeasersStatus') && !\Cx\Core\Setting\Controller\Setting::add('newsTeasersStatus', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for newsTeasersStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('feedNewsMLStatus') && !\Cx\Core\Setting\Controller\Setting::add('feedNewsMLStatus', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for feedNewsMLStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('calendarheadlines') && !\Cx\Core\Setting\Controller\Setting::add('calendarheadlines', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for calendarheadlines"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('calendarheadlinescount') && !\Cx\Core\Setting\Controller\Setting::add('calendarheadlinescount', '5', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, '', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for calendarheadlinescount"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('calendardefaultcount') && !\Cx\Core\Setting\Controller\Setting::add('calendardefaultcount', '16', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, '', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for calendardefaultcount"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('calendarheadlinescat') && !\Cx\Core\Setting\Controller\Setting::add('calendarheadlinescat', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, '', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for calendarheadlinescat"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('blockStatus') && !\Cx\Core\Setting\Controller\Setting::add('blockStatus', '1', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for blockStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('blockRandom') && !\Cx\Core\Setting\Controller\Setting::add('blockRandom', '1', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for blockRandom"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('directoryHomeContent') && !\Cx\Core\Setting\Controller\Setting::add('directoryHomeContent', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for directoryHomeContent"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('forumHomeContent') && !\Cx\Core\Setting\Controller\Setting::add('forumHomeContent', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for forumHomeContent"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('podcastHomeContent') && !\Cx\Core\Setting\Controller\Setting::add('podcastHomeContent', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for podcastHomeContent"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('forumTagContent') && !\Cx\Core\Setting\Controller\Setting::add('forumTagContent', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for forumTagContent"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('dataUseModule') && !\Cx\Core\Setting\Controller\Setting::add('dataUseModule', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for dataUseModule"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('useKnowledgePlaceholders') && !\Cx\Core\Setting\Controller\Setting::add('useKnowledgePlaceholders', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, '1:TXT_ACTIVATED,0:TXT_DEACTIVATED', 'component')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for useKnowledgePlaceholders"); } // release \Cx\Core\Setting\Controller\Setting::init('Config', 'release', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsEdition') && !\Cx\Core\Setting\Controller\Setting::add('coreCmsEdition', 'Open Source', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreCmsEdition"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsVersion') && !\Cx\Core\Setting\Controller\Setting::add('coreCmsVersion', '4.0.0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreCmsVersion"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsCodeName') && !\Cx\Core\Setting\Controller\Setting::add('coreCmsCodeName', 'Nandri', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreCmsCodeName"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsStatus') && !\Cx\Core\Setting\Controller\Setting::add('coreCmsStatus', 'Stable', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreCmsStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsReleaseDate') && !\Cx\Core\Setting\Controller\Setting::add('coreCmsReleaseDate', '1348783200', 1, \Cx\Core\Setting\Controller\Setting::TYPE_DATE, null, 'release')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreCmsReleaseDate"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsName') && !\Cx\Core\Setting\Controller\Setting::add('coreCmsName', 'Contrexx', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for coreCmsName"); } // license \Cx\Core\Setting\Controller\Setting::init('Config', 'license', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseKey') && !\Cx\Core\Setting\Controller\Setting::add('licenseKey', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseKey"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseState') && !\Cx\Core\Setting\Controller\Setting::add('licenseState', 'OK', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseState"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseValidTo') && !\Cx\Core\Setting\Controller\Setting::add('licenseValidTo', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_DATETIME, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseValidTo"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseMessage') && !\Cx\Core\Setting\Controller\Setting::add('licenseMessage', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseMessage"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licensePartner') && !\Cx\Core\Setting\Controller\Setting::add('licensePartner', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licensePartner"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseCustomer') && !\Cx\Core\Setting\Controller\Setting::add('licenseCustomer', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseCustomer"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('upgradeUrl') && !\Cx\Core\Setting\Controller\Setting::add('upgradeUrl', 'http://license.contrexx.com/', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for upgradeUrl"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseGrayzoneMessages') && !\Cx\Core\Setting\Controller\Setting::add('licenseGrayzoneMessages', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseGrayzoneMessages"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseGrayzoneTime') && !\Cx\Core\Setting\Controller\Setting::add('licenseGrayzoneTime', '14', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseGrayzoneTime"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseLockTime') && !\Cx\Core\Setting\Controller\Setting::add('licenseLockTime', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseLockTime"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseUpdateInterval') && !\Cx\Core\Setting\Controller\Setting::add('licenseUpdateInterval', '24', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseUpdateInterval"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseFailedUpdate') && !\Cx\Core\Setting\Controller\Setting::add('licenseFailedUpdate', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseFailedUpdate"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseSuccessfulUpdate') && !\Cx\Core\Setting\Controller\Setting::add('licenseSuccessfulUpdate', '0', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseSuccessfulUpdate"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseCreatedAt') && !\Cx\Core\Setting\Controller\Setting::add('licenseCreatedAt', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_DATE, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseCreatedAt"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseDomains') && !\Cx\Core\Setting\Controller\Setting::add('licenseDomains', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for licenseDomains"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('availableComponents') && !\Cx\Core\Setting\Controller\Setting::add('availableComponents', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for availableComponents"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('dashboardMessages') && !\Cx\Core\Setting\Controller\Setting::add('dashboardMessages', '', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for dashboardMessages"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('isUpgradable') && !\Cx\Core\Setting\Controller\Setting::add('isUpgradable', 'on', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'license')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for isUpgradable"); } // cache if (in_array('SystemInfo', \Env::get('cx')->getLicense()->getLegalComponentsList())) { \Cx\Core\Setting\Controller\Setting::init('Config', 'cache', 'Yaml', $configPath); if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheEnabled') && !\Cx\Core\Setting\Controller\Setting::add('cacheEnabled', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheEnabled"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheExpiration') && !\Cx\Core\Setting\Controller\Setting::add('cacheExpiration', '86400', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheExpiration"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheOpStatus') && !\Cx\Core\Setting\Controller\Setting::add('cacheOpStatus', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheOpStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheDbStatus') && !\Cx\Core\Setting\Controller\Setting::add('cacheDbStatus', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheDbStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheVarnishStatus') && !\Cx\Core\Setting\Controller\Setting::add('cacheVarnishStatus', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheVarnishStatus"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheUserCache') && !\Cx\Core\Setting\Controller\Setting::add('cacheUserCache', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheUserCache"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheOPCache') && !\Cx\Core\Setting\Controller\Setting::add('cacheOPCache', 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:TXT_ACTIVATED,off:TXT_DEACTIVATED', 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheOPCache"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheProxyCacheVarnishConfig') && !\Cx\Core\Setting\Controller\Setting::add('cacheProxyCacheVarnishConfig', '{"ip":"127.0.0.1","port":"8080"}', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheProxyCacheVarnishConfig"); } if (!\Cx\Core\Setting\Controller\Setting::isDefined('cacheUserCacheMemcacheConfig') && !\Cx\Core\Setting\Controller\Setting::add('cacheUserCacheMemcacheConfig', '{"ip":"127.0.0.1","port":11211}', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'cache')) { throw new \Cx\Lib\Update_DatabaseException("Failed to add Setting entry for cacheUserCacheMemcacheConfig"); } } } catch (\Exception $e) { \DBG::msg($e->getMessage()); } // Always return false; }
/** * Returns the Coupon that was used with the Order with the given ID * * If a Coupon was used for that Order, returns it. * Returns false on error, null otherwise (if there is none). * Fails if either the Order or the Customer cannot be found, or if a * query fails. * @param integer $order_id The Order ID * @return Coupon The matching Coupon on success, * false on error, or null otherwise * @static */ static function getByOrderId($order_id) { global $objDatabase; $order_id = intval($order_id); if (!$order_id) { //DBG::log("Coupon::getByOrderId($order_id): Invalid Order ID $order_id"); return false; } $objOrder = Order::getById($order_id); if (!$objOrder) { //DBG::log("Coupon::getByOrderId($order_id): Failed to get Order ID $order_id"); return false; } $customer_id = $objOrder->customer_id(); if (!$customer_id) { //DBG::log("Coupon::getByOrderId($order_id): Invalid Customer ID $customer_id"); return false; } $query = "\n SELECT `coupon`.`code`, `coupon`.`payment_id`,\n `coupon`.`start_time`, `coupon`.`end_time`,\n `coupon`.`minimum_amount`,\n `coupon`.`discount_rate`, `coupon`.`discount_amount`,\n `coupon`.`uses`, `coupon`.`global`,\n `coupon`.`customer_id`, `coupon`.`product_id`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_discount_coupon` AS `coupon`\n JOIN `" . DBPREFIX . "module_shop_rel_customer_coupon` AS `relation`\n ON `coupon`.`code`=`relation`.`code`\n WHERE `order_id`={$order_id}"; $objResult = $objDatabase->Execute($query); // Failure or none found if (!$objResult) { \DBG::log("Coupon::getByOrderId({$order_id}): ERROR: Query failed"); return self::errorHandler(); } if ($objResult->EOF) { //DBG::log("Coupon::getByOrderId($order_id): No Coupon for Order ID $order_id found"); return null; } $objCoupon = new Coupon(); $objCoupon->code($objResult->fields['code']); $objCoupon->payment_id($objResult->fields['payment_id']); $objCoupon->start_time($objResult->fields['start_time']); $objCoupon->end_time($objResult->fields['end_time']); $objCoupon->minimum_amount($objResult->fields['minimum_amount']); $objCoupon->discount_rate($objResult->fields['discount_rate']); $objCoupon->is_global($objResult->fields['global']); $objCoupon->customer_id($objResult->fields['customer_id']); $objCoupon->product_id($objResult->fields['product_id']); // Subtract the number of times the Coupon has been used $objCoupon->uses($objResult->fields['uses']); if ($objCoupon->uses < 1000000000.0) { $objCoupon->uses($objCoupon->uses - $objCoupon->getUsedCount($customer_id)); } // Subtract the amount used with the Coupon $objCoupon->discount_amount($objResult->fields['discount_amount']); if ($objCoupon->uses < 1000000000.0) { $objCoupon->uses($objCoupon->uses - $objCoupon->getUsedCount($customer_id)); } //DBG::log("Coupon::getByOrderId($order_id): Found ".(var_export($objCoupon, true))); return $objCoupon; }
/** * handles the upload of a file * * @param string $inputName name of the HTML input element used to upload the file * * @return array $uploadedFileInfo array containing the properties for the uploaded file, * false when upload has failed */ function _handleUpload($inputName) { global $_ARRAYLANG, $sessionObj; $fileName = isset($_POST[$inputName]) ? contrexx_input2raw($_POST[$inputName]) : ''; if (empty($fileName)) { return array('name' => '', 'path' => '', 'size' => 0); } $uploaderId = isset($_POST['forumUploaderId']) ? contrexx_input2raw($_POST['forumUploaderId']) : ''; if (empty($uploaderId)) { \DBG::log('Uploader id is empty'); return false; } //Re-initialize the $sessionObj if it is empty if (empty($sessionObj)) { $sessionObj = \cmsSession::getInstance(); } $tempPath = $sessionObj->getTempPath() . '/' . $uploaderId . '/' . $fileName; if (!\Cx\Lib\FileSystem\FileSystem::exists($tempPath)) { return false; } $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $filePath = $cx->getWebsiteMediaForumUploadPath() . '/'; $pathinfo = pathinfo($fileName); $i = 1; while (\Cx\Lib\FileSystem\FileSystem::exists($filePath . $fileName)) { $fileName = $pathinfo['filename'] . '_' . $i++ . '.' . $pathinfo['extension']; } if (\Cx\Lib\FileSystem\FileSystem::move($tempPath, $filePath . $fileName, true) === false) { $this->_objTpl->setVariable('TXT_FORUM_ERROR', $filePath . $fileName . ': ' . $_ARRAYLANG['TXT_FORUM_UPLOAD_NOT_MOVABLE']); return false; } return array('name' => contrexx_addslashes($fileName), 'path' => $filePath, 'size' => filesize($filePath . $fileName)); }
public static function setSourceModeOnContentPage($criteria, $changeVersion) { global $objUpdate, $_CONFIG; if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], $changeVersion)) { $em = \Env::get('em'); $pages = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findBy($criteria, true); foreach ($pages as $page) { if ($page) { if (!checkMemoryLimit()) { throw new UpdateException(); } try { // set source mode to content page $page->setSourceMode(true); $page->setUpdatedAtToNow(); $em->persist($page); } catch (\Exception $e) { \DBG::log("Setting source mode to page failed: " . $e->getMessage()); throw new UpdateException('Bei der Migration einer Inhaltsseite trat ein Fehler auf! ' . $e->getMessage()); } } } $em->flush(); } }
/** * Returns an array of SQL snippets to include the selected Text records * in the query. * * Provide a single value for the $key, or an array. * If you use an array, the array keys *MUST* contain distinct alias names * for the respective text keys. * The array returned looks as follows: * array( * 'alias' => The array of Text field aliases: * array(key => field name alias, ...) * Use the alias to access the text content in the resulting * recordset, or if you need to sort the result by that * column. * 'field' => Field snippet to be included in the SQL SELECT, uses * aliased field names for the id ("text_#_id") and text * ("text_#_text") fields. * No leading comma is included! * 'join' => SQL JOIN snippet, the LEFT JOIN with the core_text table * and conditions * ) * The '#' is replaced by a unique integer number. * The '*' may be any descriptive part of the name that disambiguates * multiple foreign keys in a single table, like 'name', or 'value'. * Note that the $lang_id parameter is mandatory and *MUST NOT* be * emtpy. $alias may be null (or omitted), in which case it is ignored, * and the default form "text_<index>" is used, where <index> is an integer * incremented on each use. * @static * @param string $field_id The name of the text ID * foreign key field. Note that this * is not part of the SELECTed fields, * but used in the JOIN only. * @param integer $lang_id The language ID * @param string $section The section * @param mixed $keys A single key, or an array thereof * @return array The array with SQL code parts * @author Reto Kohli <*****@*****.**> */ static function getSqlSnippets($field_id, $lang_id, $section, $keys) { static $table_alias_index = 0; if (empty($field_id)) { DBG::log("Text::getSqlSnippets(): ERROR: Empty field ID"); return false; } if (empty($lang_id)) { DBG::log("Text::getSqlSnippets(): ERROR: Empty language ID"); return false; } if (empty($section)) { DBG::log("Text::getSqlSnippets(): ERROR: Empty section"); return false; } if (empty($keys)) { DBG::log("Text::getSqlSnippets(): ERROR: Empty keys"); return false; } if (!is_array($keys)) { $keys = array($keys); } $query_field = ''; $query_join = ''; $arrSql = array(); foreach ($keys as $alias => $key) { $table_alias = 'text_' . ++$table_alias_index; $field_id_alias = $table_alias . '_id'; $field_text_alias = $alias ? $alias : $table_alias . '_text'; $field_text_name = "`{$table_alias}`.`text`"; $query_field .= ($query_field ? ', ' : '') . "\n `{$table_alias}`.`id` AS `{$field_id_alias}`,\n {$field_text_name} AS `{$field_text_alias}`"; $query_join .= "\n LEFT JOIN `" . DBPREFIX . "core_text` as `{$table_alias}`\n ON `{$table_alias}`.`id`={$field_id}\n AND `{$table_alias}`.`lang_id`={$lang_id}\n AND `{$table_alias}`.`section`" . (isset($section) ? "='" . addslashes($section) . "'" : ' IS NULL') . "\n AND `{$table_alias}`.`key`='" . addslashes($key) . "'"; $arrSql['alias'][$alias] = $field_text_name; } $arrSql['field'] = $query_field; $arrSql['join'] = $query_join; //DBG::log("Text::getSqlSnippets(): field: {$arrSql['field']}"); //DBG::log("Text::getSqlSnippets(): join: {$arrSql['join']}"); return $arrSql; }
/** * Check in the payment processor after the payment is complete. * @return mixed For external payment methods: * The integer order ID, if known, upon success * For internal payment methods: * Boolean true, in order to make these skip the order * status update, as this has already been done. * If the order ID is unknown or upon failure: * Boolean false */ static function checkIn() { //DBG::log("PaymentProcessing::checkIn(): Entered"); //DBG::log("POST: ".var_export($_POST, true)); //DBG::log("GET: ".var_export($_GET, true)); $result = NULL; if (isset($_GET['result'])) { $result = abs(intval($_GET['result'])); if ($result == 0 || $result == 2) { return false; } } if (empty($_REQUEST['handler'])) { return false; } switch ($_REQUEST['handler']) { case 'paymill_cc': case 'paymill_elv': case 'paymill_iban': $arrShopOrder = array('order_id' => $_SESSION['shop']['order_id'], 'amount' => intval(bcmul($_SESSION['shop']['grand_total_price'], 100, 0)), 'currency' => Currency::getActiveCurrencyCode(), 'note' => $_SESSION['shop']['note']); $response = \PaymillHandler::processRequest($_REQUEST['paymillToken'], $arrShopOrder); \DBG::log(var_export($response, true)); if ($response['status'] === 'success') { return true; } else { \DBG::log("PaymentProcessing::checkIn(): WARNING: paymill: Payment verification failed; errors: " . var_export($response, true)); return false; } case 'saferpay': $arrShopOrder = array('ACCOUNTID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_id', 'Shop')); $id = \Saferpay::payConfirm(); if (\Cx\Core\Setting\Controller\Setting::getValue('saferpay_finalize_payment', 'Shop')) { $arrShopOrder['ID'] = $id; $id = \Saferpay::payComplete($arrShopOrder); } //DBG::log("Transaction: ".var_export($transaction, true)); return (bool) $id; case 'paypal': if (empty($_POST['custom'])) { //DBG::log("PaymentProcessing::checkIn(): No custom parameter, returning NULL"); return NULL; } $order_id = \PayPal::getOrderId(); // if (!$order_id) { // $order_id = (isset($_SESSION['shop']['order_id']) // ? $_SESSION['shop']['order_id'] // : (isset ($_SESSION['shop']['order_id_checkin']) // ? $_SESSION['shop']['order_id_checkin'] // : NULL)); // } $order = Order::getById($order_id); $amount = $currency_id = $customer_email = NULL; if ($order) { $amount = $order->sum(); $currency_id = $order->currency_id(); $customer_id = $order->customer_id(); $customer = Customer::getById($customer_id); if ($customer) { $customer_email = $customer->email(); } } $currency_code = Currency::getCodeById($currency_id); return \PayPal::ipnCheck($amount, $currency_code, $order_id, $customer_email, \Cx\Core\Setting\Controller\Setting::getValue('paypal_account_email', 'Shop')); case 'yellowpay': $passphrase = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_hash_signature_out', 'Shop'); return \Yellowpay::checkIn($passphrase); // if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) { // global $_ARRAYLANG; // echo('<font color="red"><b>'. // $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY']. // '</b><br />'. // 'Errors:<br />'. // join('<br />', \Yellowpay::$arrError). // 'Warnings:<br />'. // join('<br />', \Yellowpay::$arrWarning). // '</font>'); // } // if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) { // global $_ARRAYLANG; // echo('<font color="red"><b>'. // $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY']. // '</b><br />'. // 'Errors:<br />'. // join('<br />', \Yellowpay::$arrError). // 'Warnings:<br />'. // join('<br />', \Yellowpay::$arrWarning). // '</font>'); // } case 'payrexx': return \PayrexxProcessor::checkIn(); // Added 20100222 -- Reto Kohli // Added 20100222 -- Reto Kohli case 'mobilesolutions': // A return value of null means: Do not change the order status if (empty($_POST['state'])) { return null; } $result = \PostfinanceMobile::validateSign(); if ($result) { //DBG::log("PaymentProcessing::checkIn(): mobilesolutions: Payment verification successful!"); } else { DBG::log("PaymentProcessing::checkIn(): WARNING: mobilesolutions: Payment verification failed; errors: " . var_export(\PostfinanceMobile::getErrors(), true)); } return $result; // Added 20081117 -- Reto Kohli // Added 20081117 -- Reto Kohli case 'datatrans': return \Datatrans::validateReturn() && \Datatrans::getPaymentResult() == 1; // For the remaining types, there's no need to check in, so we // return true and jump over the validation of the order ID // directly to success! // Note: A backup of the order ID is kept in the session // for payment methods that do not return it. This is used // to cancel orders in all cases where false is returned. // For the remaining types, there's no need to check in, so we // return true and jump over the validation of the order ID // directly to success! // Note: A backup of the order ID is kept in the session // for payment methods that do not return it. This is used // to cancel orders in all cases where false is returned. case 'internal': case 'internal_creditcard': case 'internal_debit': case 'internal_lsv': return true; // Dummy payment. // Dummy payment. case 'dummy': $result = ''; if (isset($_REQUEST['result'])) { $result = $_REQUEST['result']; } // Returns the order ID on success, false otherwise return \Dummy::commit($result); default: break; } // Anything else is wrong. return false; }
/** * Update values from array * * @param Array $newData */ public function updateFromArray($newData) { foreach ($newData as $key => $value) { try { call_user_func(array($this, "set" . ucfirst($key)), $value); } catch (Exception $e) { \DBG::log("\r\nskipped " . $key); } } }
private function initDB($sqlFileName, $conn) { DBG::log(__CLASS__, __FUNCTION__, 'before:', array($sqlFileName, $conn)); $sqlQuery = @fread(@fopen($sqlFileName, 'r'), @filesize($sqlFileName)); $queries = explode(';', $sqlQuery); foreach ($queries as $query) { $conn->exec($query); } DBG::log(__CLASS__, __FUNCTION__, 'after:', $queries); }
/** * Searches the content and returns an array that is built as needed by the search module. * * @param string $searchTerm * * @return array */ public function searchResultsForSearchModule($searchTerm) { $em = \Env::get('cx')->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); // only list results in case the associated page of the module is active $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION)); //If page is not exists or page is inactive then return empty result if (!$page || !$page->isActive()) { return array(); } //get the config site values \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml'); $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config'); $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config'); //get the config otherConfigurations value \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml'); $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config'); $hasPageAccess = true; $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible(); if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) { $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true); } //If the page is invisible and frontend access is denied then return empty result if ($isNotVisible || !$hasPageAccess) { return array(); } //get the media directory entry by the search term $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName); $entries->getEntries(null, null, null, $searchTerm); //if no entries found then return empty result if (empty($entries->arrEntries)) { return array(); } $results = array(); $formEntries = array(); $defaultEntries = null; $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName); $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']); foreach ($entries->arrEntries as $entry) { $pageUrlResult = null; $entryForm = $objForm->arrForms[$entry['entryFormId']]; //Get the entry's link url //check the entry's form detail view exists if not, //check the entry's form overview exists if not, //check the default overview exists if not, dont show the corresponding entry in entry switch (true) { case $entries->checkPageCmd('detail' . $entry['entryFormId']): $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId'])); break; case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']): case $entries->checkPageCmd(''): if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) { $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']); } if (!$pageCmdExists && !isset($defaultEntries)) { $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $defaultEntries->getEntries(); } //get entry's form overview / default page paging position $entriesPerPage = $numOfEntries; if ($pageCmdExists) { $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries; } $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : ''; $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries); $entryPos = array_search($entry['entryId'], $entryKeys); $position = floor($entryPos / $entriesPerPage); $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage)); break; default: break; } //If page url is empty then dont show it in the result if (!$pageUrlResult) { continue; } //Get the search results title and content from the form context field 'title' and 'content' $title = current($entry['entryFields']); $content = ''; $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName); $inputFields = $objInputfields->getInputfields(); foreach ($inputFields as $arrInputfield) { $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : ''; if (!in_array($contextType, array('title', 'content'))) { continue; } $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : ''; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null; $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus); if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) { $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']); \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage()); } } catch (\Exception $e) { \DBG::log($e->getMessage()); continue; } $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE']; if (empty($inputFieldValue)) { continue; } if ($contextType == 'title') { $title = $inputFieldValue; } elseif ($contextType == 'content') { $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength); } } $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString()); } return $results; }
/** * Get the response for the given URL * * @staticvar \HTTP_Request2 $request Request instance * * @param string $url requested page url * * @return mixed \HTTP_Request2_Response | false */ public function getUrlResponse($url) { //If the argument url is empty then return if (empty($url)) { return false; } try { $request = new \HTTP_Request2(); $request->setUrl($url); // ignore ssl issues // otherwise, cloudrexx does not activate 'https' // when the server doesn't have an ssl certificate installed $request->setConfig(array('ssl_verify_peer' => false, 'ssl_verify_host' => false, 'follow_redirects' => true)); return $request->send(); } catch (\Exception $e) { \DBG::log('An url ' . $url . ' is Failed to load, due to: ' . $e->getMessage()); } return false; }