/**
  * Event handler to add logs
  * 
  * We need to do this with an event handler so there's no dependency to this component
  * @param string $eventName Name of triggered event, should always be static::EVENT_NAME
  * @param array $eventArgs Supplied arguments, should be an array (see DBG message below)
  */
 public function onEvent($eventName, array $eventArgs)
 {
     if ($eventName != static::EVENT_NAME) {
         return;
     }
     if (empty($eventArgs['severity']) || empty($eventArgs['message']) || empty($eventArgs['data'])) {
         \DBG::msg('Triggered event "SysLog/Add" with wrong arguments. I need an array with non-empty values for the keys "severity", "message" and "data"');
         return;
     }
     $this->addSysLog(new \Cx\Core_Modules\SysLog\Model\Entity\Log($eventArgs['severity'], $eventArgs['message'], $eventArgs['data']));
 }
 /**
  * Convert idn to utf8 format
  * 
  * @param string $name
  * 
  * @return string
  */
 public static function convertIdnToUtf8Format($name)
 {
     if (empty($name)) {
         return;
     }
     if (!function_exists('idn_to_utf8')) {
         \DBG::msg('Idn is not supported in this system.');
     } else {
         $name = idn_to_utf8($name);
     }
     return $name;
 }
Ejemplo n.º 3
0
 public static function set($prop, &$val)
 {
     switch ($prop) {
         case 'cx':
             // set is only used for installerCx. Normal cx class will load with \Env::get('cx')
             self::$props[$prop] = $val;
             \DBG::msg(__METHOD__ . ": Setting '{$prop}' is deprecated. Use only for installer, otherwise use \\Env::('{$prop}')");
             \DBG::stack();
             break;
         case 'em':
             self::$props[$prop] = $val;
             \DBG::msg(__METHOD__ . ": Setting '{$prop}' is deprecated. Env::get({$prop}) always returns the active/preferred instance of {$prop}.");
             \DBG::stack();
             break;
         default:
             self::$props[$prop] = $val;
             break;
     }
 }
Ejemplo n.º 4
0
 public static function makeWritable($path)
 {
     try {
         $objFile = new \Cx\Lib\FileSystem\File($path);
         $objFile->makeWritable();
         return true;
     } catch (FileSystemException $e) {
         \DBG::msg($e->getMessage());
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * Shows the image manipulation component.
  *
  * @global  array   $_ARRAYLANG
  * @return  string  Parsed content.
  */
 function editMedia()
 {
     global $_ARRAYLANG;
     $this->_objTpl->loadTemplateFile('module_media_edit.html', true, true);
     $this->pageTitle = $_ARRAYLANG['TXT_MEDIA_EDIT_FILE'];
     if (isset($_GET['saveError']) && $_GET['saveError'] === 'true') {
         $this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_ERROR_MESSAGE' => $_ARRAYLANG['TXT_MEDIA_CANNOT_SAVE_IMAGE']));
         $this->_objTpl->parse('mediaErrorFile');
         return;
     }
     // Activate cx
     \JS::activate('cx');
     // Activate jQuery and imgAreaSelect
     \JS::activate('jquery');
     \JS::activate('jquery-imgareaselect');
     try {
         // Get quality options from the settings
         $arrImageSettings = $this->getImageSettings();
     } catch (\Exception $e) {
         \DBG::msg('Could not query image settings: ' . $e->getMessage());
     }
     $check = true;
     empty($this->getFile) ? $check = false : '';
     empty($this->getPath) ? $check = false : '';
     !file_exists($this->path . $this->getFile) ? $check = false : '';
     if ($check) {
         // File exists
         $this->_objTpl->setVariable(array('TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_SAVE_AS' => $_ARRAYLANG['TXT_MEDIA_SAVE_AS'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET'], 'TXT_MEDIA_PREVIEW' => $_ARRAYLANG['TXT_PREVIEW'], 'MEDIA_EDIT_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=editImage&path=' . $this->webPath, 'MEDIA_DIR' => $this->webPath, 'MEDIA_FILE' => $this->getFile));
         $icon = $this->_getIcon($this->path . $this->getFile);
         $info = pathinfo($this->getFile);
         $fileExt = $info['extension'];
         $ext = !empty($fileExt) ? '.' . $fileExt : '';
         $fileName = substr($this->getFile, 0, strlen($this->getFile) - strlen($ext));
         // Icon, file & extension name
         $this->_objTpl->setVariable(array('MEDIA_FILE_ICON' => self::_getIconWebPath() . $icon . '.png', 'MEDIA_FILE_DIR' => $this->webPath, 'MEDIA_FILE_NAME' => $fileName, 'MEDIA_FILE_EXT' => $fileExt));
         // Edit image
         $imageSize = @getimagesize($this->path . $this->getFile);
         $this->_objTpl->setVariable(array('TXT_MEDIA_IMAGE_MANIPULATION' => $_ARRAYLANG['TXT_MEDIA_IMAGE_MANIPULATION'], 'TXT_MEDIA_WIDTH' => $_ARRAYLANG['TXT_MEDIA_WIDTH'], 'TXT_MEDIA_HEIGHT' => $_ARRAYLANG['TXT_MEDIA_HEIGHT'], 'TXT_MEDIA_BALANCE' => $_ARRAYLANG['TXT_MEDIA_BALANCE'], 'TXT_MEDIA_QUALITY' => $_ARRAYLANG['TXT_MEDIA_QUALITY'], 'TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET'], 'TXT_MEDIA_SET_IMAGE_NAME' => $_ARRAYLANG['TXT_MEDIA_SET_IMAGE_NAME'], 'TXT_MEDIA_CONFIRM_REPLACE_IMAGE' => $_ARRAYLANG['TXT_MEDIA_CONFIRM_REPLACE_IMAGE'], 'TXT_MEDIA_REPLACE' => $_ARRAYLANG['TXT_MEDIA_REPLACE'], 'TXT_MEDIA_OR' => $_ARRAYLANG['TXT_MEDIA_OR'], 'TXT_MEDIA_SAVE_NEW_COPY' => $_ARRAYLANG['TXT_MEDIA_SAVE_NEW_COPY'], 'TXT_MEDIA_CROP' => $_ARRAYLANG['TXT_MEDIA_CROP'], 'TXT_MEDIA_CROP_INFO' => $_ARRAYLANG['TXT_MEDIA_CROP_INFO'], 'TXT_MEDIA_CANCEL' => $_ARRAYLANG['TXT_MEDIA_CANCEL'], 'TXT_MEDIA_ROTATE' => $_ARRAYLANG['TXT_MEDIA_ROTATE'], 'TXT_MEDIA_ROTATE_INFO' => $_ARRAYLANG['TXT_MEDIA_ROTATE_INFO'], 'TXT_MEDIA_SCALE_COMPRESS' => $_ARRAYLANG['TXT_MEDIA_SCALE_COMPRESS'], 'TXT_MEDIA_SCALE_INFO' => $_ARRAYLANG['TXT_MEDIA_SCALE_INFO'], 'TXT_MEDIA_PREVIEW' => $_ARRAYLANG['TXT_MEDIA_PREVIEW'], 'MEDIA_IMG_WIDTH' => $imageSize[0], 'MEDIA_IMG_HEIGHT' => $imageSize[1]));
         foreach ($this->arrImageQualityValues as $value) {
             $this->_objTpl->setVariable(array('IMAGE_QUALITY_VALUE' => $value, 'IMAGE_QUALITY_OPTION_CHECKED' => $value == $arrImageSettings['image_compression'] ? 'selected="selected"' : ''));
             $this->_objTpl->parse('mediaEditImageQualityOptions');
         }
         $this->_objTpl->parse('mediaEditImage');
     } else {
         // File doesn't exist
         $this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_ERROR_MESSAGE' => $_ARRAYLANG['TXT_MEDIA_FILE_DONT_EXISTS']));
         $this->_objTpl->parse('mediaErrorFile');
     }
     // Variables
     $this->_objTpl->setVariable(array('CSRF' => \Cx\Core\Csrf\Controller\Csrf::param(), 'MEDIA_EDIT_AJAX_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=editImage&path=' . $this->webPath, 'MEDIA_EDIT_REDIRECT' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath, 'MEDIA_BACK_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath, 'MEDIA_FILE_IMAGE_SRC' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=getImage&path=' . $this->webPath . '&file=' . $this->getFile . '&' . \Cx\Core\Csrf\Controller\Csrf::param(), 'MEDIA_IMAGE_WIDTH' => !empty($imageSize) ? intval($imageSize[0]) : 0, 'MEDIA_IMAGE_HEIGHT' => !empty($imageSize) ? intval($imageSize[1]) : 0, 'MEDIA_IMAGE_CROP_WIDTH' => $arrImageSettings['image_cut_width'], 'MEDIA_IMAGE_CROP_HEIGHT' => $arrImageSettings['image_cut_height'], 'MEDIA_IMAGE_RESIZE_QUALITY' => $arrImageSettings['image_compression']));
 }
Ejemplo n.º 6
0
 /**
  * This function saves an entity to the database
  *
  * @param string $entityWithNS class name including namespace
  * @access protected
  * @global array $_ARRAYLANG array containing the language variables
  */
 protected function saveEntry($entityWithNS)
 {
     global $_ARRAYLANG;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $em = $cx->getDb()->getEntityManager();
     // if entityId is a number the user edited an existing entry. If it is null we create a new one
     $entityId = contrexx_input2raw($this->getEntryId());
     $this->renderFormForEntry($entityId);
     // if the form is not valid in any case, we stay in this view and do not save anything, because we can not be
     // sure that everything is alright
     if (!$this->validateForm()) {
         return;
     }
     // if there are no data submitted, we stay on this view, because we have nothing to save
     if (!$this->checkBlankPostRequest()) {
         return;
     }
     $entityClassMetadata = $em->getClassMetadata($entityWithNS);
     $associationMappings = $entityClassMetadata->getAssociationMappings();
     // if we have a entityId, we came from edit mode and so we try to load the existing entry
     if ($entityId != 0) {
         $entity = $em->getRepository($entityWithNS)->find($entityId);
         $entityArray = array();
         // This array is used for the existing values
         if ($this->object->entryExists($entityId)) {
             $entityArray = $this->object->getEntry($entityId);
         }
         if (empty($entityArray)) {
             \Message::add($_ARRAYLANG['TXT_CORE_RECORD_NO_SUCH_ENTRY'], \Message::CLASS_ERROR);
             return;
         }
     } else {
         // create new entity without calling the constructor TODO: this might break certain entities!
         $entity = $entityClassMetadata->newInstance();
     }
     $classMethods = get_class_methods($entity);
     // this array is used to store all oneToMany associated entities, because we need to persist them for doctrine,
     // but we can not persist them before the main entity, so we need to buffer them
     $associatedEntityToPersist = array();
     foreach ($associationMappings as $name => $value) {
         /* if we can not find the class name or the function to save the association we skip the entry, because there
            is now way to store it without these information */
         if (empty($value['targetEntity'])) {
             \Message::add(sprintf($_ARRAYLANG['TXT_CORE_RECORD_CLASS_NOT_FOUND'], $name), \Message::CLASS_ERROR);
             continue;
         }
         /* this variable is the name of the field where we saved the values of the one to many associations
            because css does not support \ in class name */
         $relatedClassInputFieldName = str_replace('\\', '_', strtolower($value["targetEntity"]));
         if (!empty($relatedClassInputFieldName) && !empty($_POST[$relatedClassInputFieldName]) && $em->getClassMetadata($entityWithNS)->isCollectionValuedAssociation($name)) {
             // store one to many associated entries
             $associatedEntityClassMetadata = $em->getClassMetadata($value["targetEntity"]);
             foreach ($_POST[$relatedClassInputFieldName] as $relatedPostData) {
                 $entityData = array();
                 parse_str($relatedPostData, $entityData);
                 // if we have already an entry (on update) we take the existing one and update it.
                 // Otherwise we create a new one
                 if (isset($entityData['id']) && $entityData['id'] != 0) {
                     // update/edit case
                     $associatedClassRepo = $em->getRepository($value["targetEntity"]);
                     $associatedEntity = $associatedClassRepo->find($entityData['id']);
                 } else {
                     // add case
                     $associatedEntity = $associatedEntityClassMetadata->newInstance();
                 }
                 // if there are any entries which the user wants to delete, we delete them here
                 if (isset($entityData['delete']) && $entityData['delete'] == 1) {
                     $em->remove($associatedEntity);
                 }
                 // save the "n" associated class data to its class
                 $this->savePropertiesToClass($associatedEntity, $associatedEntityClassMetadata, $entityData, $entityWithNS);
                 // Linking 1: link the associated entity to the main entity for doctrine
                 $methodName = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
                 if (!in_array($methodName, $classMethods)) {
                     \Message::add(sprintf($_ARRAYLANG['TXT_CORE_RECORD_FUNCTION_NOT_FOUND'], $name, $methodName), \Message::CLASS_ERROR);
                     continue;
                 }
                 $entity->{$methodName}($associatedEntity);
                 // Linking 2: link the main entity to its associated entity. This should normally be done by
                 // 'Linking 1' but because not all components have implemented this, we do it here by ourselves
                 $method = 'set' . ucfirst($value["mappedBy"]);
                 if (method_exists($associatedEntity, $method)) {
                     $associatedEntity->{$method}($entity);
                 }
                 // buffer entity, so we can persist it later
                 $associatedEntityToPersist[] = $associatedEntity;
             }
         }
     }
     if ($entityId != 0) {
         // edit case
         // update the main entry in doctrine so we can store it over doctrine to database later
         $this->savePropertiesToClass($entity, $entityClassMetadata);
         $param = 'editid';
         $successMessage = $_ARRAYLANG['TXT_CORE_RECORD_UPDATED_SUCCESSFUL'];
     } else {
         // add case
         // save main formular class data to its class over $_POST
         $this->savePropertiesToClass($entity, $entityClassMetadata);
         $param = 'add';
         $successMessage = $_ARRAYLANG['TXT_CORE_RECORD_ADDED_SUCCESSFUL'];
     }
     $showSuccessMessage = false;
     if ($entity instanceof \Cx\Core\Model\Model\Entity\YamlEntity) {
         // Save the yaml entities
         $entityRepository = $em->getRepository($entityWithNS);
         if (!$entityRepository->isManaged($entity)) {
             $entityRepository->add($entity);
         }
         $entityRepository->flush();
         $showSuccessMessage = true;
     } else {
         if ($entity instanceof \Cx\Model\Base\EntityBase) {
             /* We try to store the prepared em. This may fail if (for example) we have a one to many association which
                can not be null but was not set in the post request. This cases should be caught here. */
             try {
                 // persist main entity. This must be done first, otherwise saving oneToManyAssociated entities won't work
                 $em->persist($entity);
                 // now we can persist the associated entities. We need to do this, because otherwise it will fail,
                 // if yaml does not contain a cascade option
                 foreach ($associatedEntityToPersist as $associatedEntity) {
                     $em->persist($associatedEntity);
                 }
                 $em->flush();
                 $showSuccessMessage = true;
             } catch (\Cx\Core\Error\Model\Entity\ShinyException $e) {
                 /* Display the message from the exception. If this message is empty, we output a general message,
                    so the user knows what to do in every case */
                 if ($e->getMessage() != "") {
                     \Message::add($e->getMessage(), \Message::CLASS_ERROR);
                 } else {
                     \Message::add($_ARRAYLANG['TXT_CORE_RECORD_UNKNOWN_ERROR'], \Message::CLASS_ERROR);
                 }
                 return;
             } catch (\Exception $e) {
                 echo $e->getMessage();
                 die;
             }
         } else {
             \Message::add($_ARRAYLANG['TXT_CORE_RECORD_VALIDATION_FAILED'], \Message::CLASS_ERROR);
             \DBG::msg('Unkown entity model ' . get_class($entity) . '! Trying to persist using entity manager...');
         }
     }
     if ($showSuccessMessage) {
         \Message::add($successMessage);
     }
     // get the proper action url and redirect the user
     $actionUrl = clone $cx->getRequest()->getUrl();
     $actionUrl->setParam($param, null);
     \Cx\Core\Csrf\Controller\Csrf::redirect($actionUrl);
 }
Ejemplo n.º 7
0
 /**
  * Fetches a json response via HTTP request
  * @todo Support cookies (to allow login and similiar features)
  * @param string $url URL to get json from
  * @param array $data (optional) HTTP post data
  * @param boolean $secure (optional) Wheter to verify peer using SSL or not, default false
  * @param string $certificateFile (optional) Local certificate file for non public SSL certificates
  * @param array Set an optional HTTP Authentication method and supply its login credentials.
  *              The supplied array must comply with the following structure:
  * <pre class="brush: php">
  *              $httpAuth = array(
  *                  'httpAuthMethod'   => 'none|basic|disgest',
  *                  'httpAuthUsername' => '<username>',
  *                  'httpAuthPassword' => '<password>',
  *              );
  * </pre>
  * @return mixed Decoded JSON on success, false otherwise
  */
 public function getJson($url, $data = array(), $secure = false, $certificateFile = '', $httpAuth = array(), $files = array())
 {
     $request = new \HTTP_Request2($url, \HTTP_Request2::METHOD_POST);
     if (!empty($httpAuth)) {
         switch ($httpAuth['httpAuthMethod']) {
             case 'basic':
                 $request->setAuth($httpAuth['httpAuthUsername'], $httpAuth['httpAuthPassword'], \HTTP_Request2::AUTH_BASIC);
                 break;
             case 'disgest':
                 $request->setAuth($httpAuth['httpAuthUsername'], $httpAuth['httpAuthPassword'], \HTTP_Request2::AUTH_DIGEST);
                 break;
             case 'none':
             default:
                 break;
         }
     }
     foreach ($data as $name => $value) {
         $request->addPostParameter($name, $value);
     }
     if (!empty($files)) {
         foreach ($files as $fieldId => $file) {
             $request->addUpload($fieldId, $file);
         }
     }
     if ($this->sessionId !== null) {
         $request->addCookie(session_name(), $this->sessionId);
     }
     $request->setConfig(array('ssl_verify_host' => false, 'ssl_verify_peer' => false, 'follow_redirects' => true, 'strict_redirects' => true));
     $response = $request->send();
     //echo '<pre>';var_dump($response->getBody());echo '<br /><br />';
     $cookies = $response->getCookies();
     foreach ($cookies as &$cookie) {
         if ($cookie['name'] === session_name()) {
             $this->sessionId = $cookie['value'];
             break;
         }
     }
     if ($response->getStatus() != 200) {
         \DBG::msg(__METHOD__ . ' Request failed! Status: ' . $response->getStatus());
         \DBG::msg('URL: ' . $url);
         \DBG::dump($data);
         return false;
     }
     $body = json_decode($response->getBody());
     if ($body === NULL) {
         \DBG::msg(__METHOD__ . ' failed!');
         \DBG::dump($response->getBody());
     }
     return $body;
 }
Ejemplo n.º 8
0
 /**
  * Create a new Order 
  * 
  * @param integer $productId            productId
  * @param object  $objUser              \User object
  * @param string  $transactionReference transactionReference
  * @param array   $subscriptionOptions  subscriptionOptions
  * 
  * @return boolean
  * @throws OrderRepositoryException
  */
 public function createOrder($productId, \Cx\Modules\Crm\Model\Entity\Currency $currency, \User $objUser, $transactionReference, $subscriptionOptions = array())
 {
     if (\FWValidator::isEmpty($productId) || \FWValidator::isEmpty($subscriptionOptions) || \FWValidator::isEmpty($transactionReference) || \FWValidator::isEmpty($currency)) {
         return;
     }
     $contactId = $objUser->getCrmUserId();
     if (\FWValidator::isEmpty($contactId)) {
         return;
     }
     try {
         $order = new \Cx\Modules\Order\Model\Entity\Order();
         $order->setContactId($contactId);
         $order->setCurrency($currency);
         $productRepository = \Env::get('em')->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Product');
         $product = $productRepository->findOneBy(array('id' => $productId));
         //create subscription
         $subscription = $order->createSubscription($product, $subscriptionOptions);
         // set discount price for first payment period of subscription
         if (!empty($subscriptionOptions['oneTimeSalePrice'])) {
             $subscription->setPaymentAmount($subscriptionOptions['oneTimeSalePrice']);
         }
         $order->billSubscriptions();
         $invoices = $order->getInvoices();
         if (!empty($invoices)) {
             \DBG::msg(__METHOD__ . ": order has invoices");
             $paymentRepo = \Env::get('em')->getRepository('\\Cx\\Modules\\Order\\Model\\Entity\\Payment');
             foreach ($invoices as $invoice) {
                 if (!$invoice->getPaid()) {
                     \DBG::msg(__METHOD__ . ": lookup payment with transaction-reference {$transactionReference} and amount " . $invoice->getAmount());
                     $payment = $paymentRepo->findOneByCriteria(array('amount' => $invoice->getAmount(), 'transactionReference' => $transactionReference, 'invoice' => null));
                     if ($payment) {
                         \DBG::msg(__METHOD__ . ": payment found");
                         //set subscription-id to Subscription::$externalSubscriptionId
                         if ($subscription) {
                             \DBG::msg(__METHOD__ . ": trying to link to new subscription to the external subscription ID");
                             $referenceArry = explode('|', $payment->getTransactionReference());
                             if (isset($referenceArry[4]) && !empty($referenceArry[4])) {
                                 $subscription->setExternalSubscriptionId($referenceArry[4]);
                             }
                         }
                         $transactionData = $payment->getTransactionData();
                         if (!\FWValidator::isEmpty($transactionData) && isset($transactionData['contact']) && isset($transactionData['contact']['id'])) {
                             \DBG::msg(__METHOD__ . ": set externalPaymentCustomerIdProfileAttributeId of user to " . $transactionData['contact']['id']);
                             $objUser->setProfile(array(\Cx\Core\Setting\Controller\Setting::getValue('externalPaymentCustomerIdProfileAttributeId', 'MultiSite') => array(0 => $transactionData['contact']['id'])), true);
                             if (!$objUser->store()) {
                                 \DBG::msg('Order::createOrder() Updating user failed: ' . $objUser->getErrorMsg());
                             }
                         }
                         $invoice->addPayment($payment);
                         $payment->setInvoice($invoice);
                         \Env::get('em')->persist($invoice);
                         \Env::get('em')->persist($payment);
                         break;
                     }
                 }
             }
         }
         \Env::get('em')->persist($order);
         \Env::get('em')->flush();
         return $order;
     } catch (\Exception $e) {
         throw new OrderRepositoryException($e->getMessage());
     }
 }
Ejemplo n.º 9
0
    /**
     * Get uploader code
     * 
     * @param string  $fieldKey       uploadFieldKey
     * @param string  $fieldName      uploadFieldName
     * @param string  $uploadCallBack upload callback function
     * @param boolean $allowImageOnly allow only images files
     * 
     * @return string uploaderCode
     * @throws \Exception
     */
    protected function getUploaderCode($fieldKey, $fieldName, $uploadCallBack = "uploadFinished", $allowImageOnly = true)
    {
        \cmsSession::getInstance();
        $cx = \Cx\Core\Core\Controller\Cx::instanciate();
        try {
            $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
            $uploaderId = $uploader->getId();
            $uploadOptions = array('id' => 'calendarUploader_' . $uploaderId, 'style' => 'display: none');
            if ($allowImageOnly) {
                $uploadOptions['allowed-extensions'] = array('gif', 'jpg', 'png', 'jpeg');
            }
            $uploader->setCallback($fieldName . 'JsCallback');
            $uploader->setUploadLimit(1);
            $uploader->setOptions($uploadOptions);
            $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Calendar/Controller/Calendar.class.php', '\\Cx\\Modules\\Calendar\\Controller\\Calendar', $uploadCallBack));
            $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploaderId);
            $this->_objTpl->setVariable(array(strtoupper($fieldName) . '_WIDGET_CODE' => $folderWidget->getXHtml(), "{$this->moduleLangVar}_" . strtoupper($fieldKey) => $uploaderId));
            $strJs = <<<JAVASCRIPT
{$uploader->getXHtml()}
<script type="text/javascript">
    cx.ready(function() {
        //called if user clicks on the field
        jQuery('#{$fieldName}').bind('click', function() {
            jQuery('#calendarUploader_{$uploaderId}').trigger('click');
            return false;
        });
    });

//uploader javascript callback function
function {$fieldName}JsCallback(callback) {
        angular.element('#mediaBrowserfolderWidget_{$folderWidget->getId()}').scope().refreshBrowser();
}
</script>
JAVASCRIPT;
            return $strJs;
        } catch (\Exception $e) {
            \DBG::msg('<!-- failed initializing uploader -->');
            throw new \Exception("failed initializing uploader");
        }
    }
Ejemplo n.º 10
0
 /**
  * checks whether the entered string matches the captcha.
  * if the check is already done the result will be returned.
  *
  * @return boolean
  */
 public function check()
 {
     if (empty($this->securityCheck)) {
         if ($this->isValidCode()) {
             $this->securityCheck = true;
         } else {
             $this->securityCheck = false;
             if (!empty($_POST['coreCaptchaCode'])) {
                 \DBG::msg('Captcha: The entered security code was incorrect.');
             }
         }
     }
     return $this->securityCheck;
 }
Ejemplo n.º 11
0
 /**
  * Handles a list
  * @param mixed $entities Entity class name as string or callback function
  * @param array $crit (optional) Doctrine style criteria array to use
  * @param array $options (Unused)
  */
 public function __construct($entities, $crit = array(), $options = array())
 {
     if (isset($options['paging'])) {
         $this->paging = $options['paging'];
     }
     if (isset($options['order'])) {
         $this->order = $options['order'];
     }
     // init handlers (filtering, paging and sorting)
     $this->handlers[] = new FilteringController();
     if (!empty($options['sorting'])) {
         $this->handlers[] = new SortingController();
     }
     $this->handlers[] = new PagingController();
     if (is_callable($entities)) {
         \DBG::msg('Init ListingController using callback function');
         $this->callback = $entities;
     } else {
         if ($entities instanceof \Cx\Core_Modules\Listing\Model\Entity\DataSet) {
             \DBG::msg('Init ListingController using DataSet');
             $this->entityClass = $entities;
         } else {
             \DBG::msg('Init ListingController using entity class');
             $this->entityClass = $entities;
         }
     }
     $this->criteria = $crit;
     // todo: allow multiple listing controllers per page request
     $this->args = contrexx_input2raw($_GET);
 }
Ejemplo n.º 12
0
function _writeNewConfigurationFile()
{
    global $_CORELANG, $_ARRAYLANG, $_DBCONFIG, $_PATHCONFIG, $_FTPCONFIG, $_CONFIGURATION, $_CONFIG;
    $ftpStatus = $_FTPCONFIG['is_activated'] ? 'true' : 'false';
    $charset = 'UTF-8';
    $dbCharset = 'utf8';
    $_FTPCONFIG['port'] = intval($_FTPCONFIG['port']);
    $configurationTpl = <<<CONFIG_TPL
<?php
global \$_DBCONFIG, \$_PATHCONFIG, \$_FTPCONFIG, \$_CONFIG;
/**
* @exclude
*
* Cloudrexx CMS Web Installer
* Please use the Cloudrexx CMS installer to configure this file
* or edit this file and configure the parameters for your site and
* database manually.
*/

/**
* -------------------------------------------------------------------------
* Set installation status
* -------------------------------------------------------------------------
*/
define('CONTREXX_INSTALLED', true);

/**
* -------------------------------------------------------------------------
* Database configuration section
* -------------------------------------------------------------------------
*/
\$_DBCONFIG['host'] = '{$_DBCONFIG['host']}'; // This is normally set to localhost
\$_DBCONFIG['database'] = '{$_DBCONFIG['database']}'; // Database name
\$_DBCONFIG['tablePrefix'] = '{$_DBCONFIG['tablePrefix']}'; // Database table prefix
\$_DBCONFIG['user'] = '******'user']}'; // Database username
\$_DBCONFIG['password'] = '******'password']}'; // Database password
\$_DBCONFIG['dbType'] = '{$_DBCONFIG['dbType']}';    // Database type (e.g. mysql,postgres ..)
\$_DBCONFIG['charset'] = '{$dbCharset}'; // Charset (default, latin1, utf8, ..)
\$_DBCONFIG['timezone'] = '{$_CONFIG['timezone']}'; // Controller's timezone for model
\$_DBCONFIG['collation'] = '{$_DBCONFIG['collation']}';

/**
* -------------------------------------------------------------------------
* Site path specific configuration
* -------------------------------------------------------------------------
*/
\$_PATHCONFIG['ascms_root'] = '';
\$_PATHCONFIG['ascms_root_offset'] = ''; // example: '/cms';
\$_PATHCONFIG['ascms_installation_root'] = \$_PATHCONFIG['ascms_root'];
\$_PATHCONFIG['ascms_installation_offset'] = \$_PATHCONFIG['ascms_root_offset']; // example: '/cms';

/**
* -------------------------------------------------------------------------
* Ftp specific configuration
* -------------------------------------------------------------------------
*/
\$_FTPCONFIG['is_activated'] = {$ftpStatus}; // Ftp support true or false
\$_FTPCONFIG['host']    = '{$_FTPCONFIG['host']}';// This is normally set to localhost
\$_FTPCONFIG['port'] = {$_FTPCONFIG['port']}; // Ftp remote port
\$_FTPCONFIG['username'] = '******'username']}'; // Ftp login username
\$_FTPCONFIG['password']    = '******'password']}'; // Ftp login password
\$_FTPCONFIG['path']    = '{$_FTPCONFIG['path']}'; // Ftp path to cms (must not include ascms_root_offset)

/**
* -------------------------------------------------------------------------
* Base setup (altering might break the system!)
* -------------------------------------------------------------------------
*/
// Set character encoding
\$_CONFIG['coreCharacterEncoding'] = 'UTF-8'; // example 'UTF-8'

CONFIG_TPL;
    // write settings
    try {
        $objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/configuration.php');
        $objFile->makeWritable();
        $objFile->write($configurationTpl);
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        \DBG::msg($e->getMessage());
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php'));
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        return false;
    }
    return true;
}
Ejemplo n.º 13
0
 public function makeWritable()
 {
     // abort process in case the file is already writable
     if (is_writable($this->filePath)) {
         return true;
     }
     $parentDirectory = dirname($this->filePath);
     if (!is_writable($parentDirectory)) {
         if (strpos($parentDirectory, \Env::get('cx')->getWebsiteDocumentRootPath()) === 0) {
             // parent directory lies within the Contrexx installation directory,
             // therefore, we shall try to make it writable
             \Cx\Lib\FileSystem\FileSystem::makeWritable($parentDirectory);
         } else {
             throw new FileSystemFileException('Parent directory ' . $parentDirectory . ' lies outside of Contrexx installation and can therefore not be made writable!');
         }
     }
     // fetch current permissions on loaded file
     $filePerms = $this->getFilePermissions();
     // set write access to file owner
     $filePerms |= \Cx\Lib\FileSystem\FileSystem::CHMOD_USER_WRITE;
     // log file permissions into the humand readable chmod() format
     \DBG::msg('CHMOD: ' . substr(sprintf('%o', $filePerms), -4));
     if (!@chmod($this->filePath, $filePerms)) {
         throw new FileSystemFileException('Unable to set write access to file ' . $this->filePath . '!');
     }
 }
Ejemplo n.º 14
0
 /**
  * Adds an attachment from a path on the filesystem.
  * Returns false if the file could not be found
  * or accessed.
  * @param string $path Path to the attachment.
  * @param string $name Overrides the attachment name.
  * @param string $encoding File encoding (see $Encoding).
  * @param string $type File extension (MIME) type.
  * @return bool
  */
 public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream')
 {
     try {
         if (!@is_file($path)) {
             throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
         }
         $filename = basename($path);
         if ($name == '') {
             $name = $filename;
         }
         $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => 'attachment', 7 => 0);
     } catch (phpmailerException $e) {
         $this->SetError($e->getMessage());
         if ($this->exceptions) {
             throw $e;
         }
         DBG::msg($e->getMessage());
         if ($e->getCode() == self::STOP_CRITICAL) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 15
0
 /**
  * Write all settings into the config-file
  *
  */
 function _createSettingsFile()
 {
     global $_ARRLANG;
     $objDb = $this->_getDbObject($statusMsg);
     if ($objDb === false) {
         return $statusMsg;
     } else {
         $strSettingsFile = $_SESSION['installer']['config']['documentRoot'] . $_SESSION['installer']['config']['offsetPath'] . '/config/settings.php';
         if (!\Cx\Lib\FileSystem\FileSystem::touch($strSettingsFile) || !\Cx\Lib\FileSystem\FileSystem::makeWritable($strSettingsFile)) {
             return sprintf($_ARRLANG['TXT_SETTINGS_ERROR_WRITABLE'], $strSettingsFile);
         }
         //Header & Footer
         $strHeader = "<?php\n";
         $strHeader .= "/**\n";
         $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
         $strHeader .= "* Do not try to edit it manually!\n";
         $strHeader .= "*/\n\n";
         $strFooter = "\n";
         //Get module-names
         $objResult = $objDb->Execute("SELECT id, name FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "modules`");
         if ($objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 $arrModules[$objResult->fields['id']] = $objResult->fields['name'];
                 $objResult->MoveNext();
             }
         }
         //Get values
         $objResult = $objDb->Execute("SELECT setname, setmodule, setvalue FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "settings` ORDER BY    setmodule ASC, setname ASC");
         $intMaxLen = 0;
         if ($objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen;
                 $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue'];
                 $objResult->MoveNext();
             }
         }
         $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
         //needed for formatted output
         //Write values
         $data = $strHeader;
         $strBody = '';
         foreach ($arrValues as $intModule => $arrInner) {
             $strBody .= "/**\n";
             $strBody .= "* -------------------------------------------------------------------------\n";
             $strBody .= "* " . ucfirst(isset($arrModules[$intModule]) ? $arrModules[$intModule] : '') . "\n";
             $strBody .= "* -------------------------------------------------------------------------\n";
             $strBody .= "*/\n";
             foreach ($arrInner as $strName => $strValue) {
                 $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']');
                 $strBody .= "= ";
                 $strBody .= (is_numeric($strValue) ? $strValue : '"' . str_replace('"', '\\"', $strValue) . '"') . ";\n";
             }
             $strBody .= "\n";
         }
         $data .= $strBody;
         $data .= $strFooter;
         try {
             $objFile = new \Cx\Lib\FileSystem\File($strSettingsFile);
             $objFile->write($data);
             return true;
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             DBG::msg($e->getMessage());
         }
         return false;
     }
 }
Ejemplo n.º 16
0
 /**
  *
  * @param Cx\Core_Modules\Listing\Model\ExportInterface $exportInterface
  * @param type $filename 
  * @throws \Cx\Lib\FileSystem\FileSystemException
  */
 public function exportToFile(\Cx\Core_Modules\Listing\Model\Entity\Exportable $exportInterface, $filename)
 {
     try {
         $objFile = new \Cx\Lib\FileSystem\File($filename);
         $objFile->touch();
         $objFile->write($this->export($exportInterface));
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
         \DBG::msg($e->getMessage());
         throw new DataSetException("Failed to export data to file {$filename}!");
     }
 }
Ejemplo n.º 17
0
 /**
  * Fixes database errors.
  *
  * @global array $_CONFIG
  *
  * @return boolean
  * @throws SupportException
  */
 static function errorHandler()
 {
     global $_CONFIG;
     try {
         \Cx\Core\Setting\Controller\Setting::init('Support', '', 'Yaml');
         //setup group
         \Cx\Core\Setting\Controller\Setting::init('Support', 'setup', 'Yaml');
         if (!\Cx\Core\Setting\Controller\Setting::isDefined('faqUrl') && !\Cx\Core\Setting\Controller\Setting::add('faqUrl', 'https://www.cloudrexx.com/FAQ', 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'setup')) {
             throw new SupportException("Failed to add Setting entry for faq url");
         }
         if (!\Cx\Core\Setting\Controller\Setting::isDefined('recipientMailAddress') && !\Cx\Core\Setting\Controller\Setting::add('recipientMailAddress', $_CONFIG['coreAdminEmail'], 2, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'setup')) {
             throw new SupportException("Failed to add Setting entry for recipient mail address");
         }
     } catch (\Exception $e) {
         \DBG::msg($e->getMessage());
     }
     // Always!
     return false;
 }
Ejemplo n.º 18
0
 /**
  * Tries to find a matching DataAccess entity for the given criteria
  * @param \Cx\Core_Modules\DataAccess\Controller\OutputController $outputModule Output module to use for parsing
  * @param \Cx\Core\DataSource\Model\Entity\DataSource $dataSource Requested data source
  * @param string $method Request method (get, post, ...)
  * @param string $requestApiKey API key used in request
  * @return \Cx\Core_Modules\DataAccess\Model\Entity\DataAccess Matching DataAccess object or null
  */
 public function getAccess($outputModule, $dataSource, $method, $requestApiKey)
 {
     $requestReadonly = in_array($method, array('options', 'head', 'get'));
     // do we have a DataAccess for this DataSource?
     $dataAccesses = $dataSource->getDataAccesses();
     if (!$dataAccesses->count()) {
         \DBG::msg('This DataSource has no DataAccess!');
         return null;
     }
     // does our apiKey match with one or more of the DataAccesses?
     $validApiKeys = array();
     foreach ($dataAccesses as $dataAccess) {
         $apiKeys = $dataAccess->getDataAccessApiKeys();
         foreach ($apiKeys as $apiKey) {
             // if write access is needed (!$requestReadonly): does the api key allow write?
             if (!$requestReadonly && $apiKey->getReadOnly()) {
                 continue;
             }
             if ($apiKey->getApiKey()->getApiKey() != $requestApiKey) {
                 continue;
             }
             $validApiKeys[] = $apiKey;
         }
     }
     // $validApiKeys now contains all DataAccessApiKey entities that allow
     // this request. If there's at least one, this user has access to this
     // DataAccess object.
     if (!count($validApiKeys)) {
         \DBG::msg('There\'s no DataAccess with a matching API key!');
         return null;
     }
     // Now let's check if one of the remaining data access objects allow
     // access:
     foreach ($validApiKeys as $apiKey) {
         $dataAccess = $apiKey->getDataAccess();
         $permission = null;
         if ($requestReadonly) {
             $permission = $dataAccess->getReadPermission();
         } else {
             $permission = $dataAccess->getWritePermission();
         }
         if (!$permission || $permission->hasAccess()) {
             return $dataAccess;
         }
     }
     \DBG::msg('Your API key does not allow access to this DataSource!');
     return null;
 }
Ejemplo n.º 19
0
 public function setMode($mode)
 {
     if ($mode == 'frontend' || $mode == 'backend') {
         $this->mode = $mode;
     } else {
         \DBG::msg('URL: Invalid url mode "' . $mode . '"');
     }
 }
Ejemplo n.º 20
0
 /**
  * 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;
 }
Ejemplo n.º 21
0
function _newsletterUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_category', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'status'), 'notification_email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'name')), array('name' => array('fields' => array('name'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_confirm_mail', array('id' => array('type' => 'INT(1)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'content' => array('type' => 'longtext', 'after' => 'title'), 'recipients' => array('type' => 'text', 'after' => 'content')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'template' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'subject'), 'content' => array('type' => 'text', 'after' => 'template'), 'attachment' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'priority' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'attachment'), 'sender_email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'priority'), 'sender_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'sender_email'), 'return_path' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'sender_name'), 'smtp_server' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'return_path'), 'status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'smtp_server'), 'count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'status'), 'recipient_count' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'count'), 'date_create' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'recipient_count'), 'date_sent' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'date_create'), 'tmp_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'date_sent')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    DBG::msg("Done checking tables.. going to check settings");
    //the two values notifyOnUnsubscribe and notificationUnsubscribe have been merged into the latter.
    $unsubscribeVal = 1;
    try {
        DBG::msg("Retrieving old unsubscribe value if set.");
        $res = \Cx\Lib\UpdateUtil::sql("SELECT setvalue FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notifyOnUnsubscribe'");
        if (!$res->EOF) {
            $unsubscribeVal = $res->fields['setvalue'];
        } else {
            DBG::msg("Not found. Retrieving new unsubscribe value if set.");
            $res = \Cx\Lib\UpdateUtil::sql("SELECT setvalue FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notificatonUnsubscribe'");
            if (!$res->EOF) {
                $unsubscribeVal = $res->fields['setvalue'];
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $settings = array('sender_mail' => array('setid' => 1, 'setname' => 'sender_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'sender_name' => array('setid' => 2, 'setname' => 'sender_name', 'setvalue' => 'admin', 'status' => 1), 'reply_mail' => array('setid' => 3, 'setname' => 'reply_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'mails_per_run' => array('setid' => 4, 'setname' => 'mails_per_run', 'setvalue' => '30', 'status' => 1), 'text_break_after' => array('setid' => 5, 'setname' => 'text_break_after', 'setvalue' => '100', 'status' => 1), 'test_mail' => array('setid' => 6, 'setname' => 'test_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'overview_entries_limit' => array('setid' => 7, 'setname' => 'overview_entries_limit', 'setvalue' => '10', 'status' => 1), 'rejected_mail_operation' => array('setid' => 8, 'setname' => 'rejected_mail_operation', 'setvalue' => 'delete', 'status' => 1), 'defUnsubscribe' => array('setid' => 9, 'setname' => 'defUnsubscribe', 'setvalue' => '0', 'status' => 1), 'notificationSubscribe' => array('setid' => 11, 'setname' => 'notificationSubscribe', 'setvalue' => '1', 'status' => 1), 'notificationUnsubscribe' => array('setid' => 10, 'setname' => 'notificationUnsubscribe', 'setvalue' => $unsubscribeVal, 'status' => 1), 'recipient_attribute_status' => array('setid' => 12, 'setname' => 'recipient_attribute_status', 'setvalue' => '{"recipient_sex":{"active":true,"required":false},"recipient_salutation":{"active":true,"required":false},"recipient_title":{"active":false,"required":false},"recipient_firstname":{"active":true,"required":false},"recipient_lastname":{"active":true,"required":false},"recipient_position":{"active":false,"required":false},"recipient_company":{"active":true,"required":false},"recipient_industry":{"active":false,"required":false},"recipient_address":{"active":true,"required":false},"recipient_city":{"active":true,"required":false},"recipient_zip":{"active":true,"required":false},"recipient_country":{"active":true,"required":false},"recipient_phone":{"active":true,"required":false},"recipient_private":{"active":false,"required":false},"recipient_mobile":{"active":false,"required":false},"recipient_fax":{"active":false,"required":false},"recipient_birthday":{"active":true,"required":false},"recipient_website":{"active":false,"required":false}}', 'status' => 1), 'reject_info_mail_text' => array('setid' => 13, 'setname' => 'reject_info_mail_text', 'setvalue' => 'Der Newsletter konnte an folgende E-Mail-Adresse nicht versendet werden:\\r\\n[[EMAIL]]\\r\\n\\r\\nUm die E-Mail Adresse zu bearbeiten, klicken Sie bitte auf den folgenden Link:\\r\\n[[LINK]]', 'status' => 1));
    try {
        DBG::msg("Reading current settings");
        $res = \Cx\Lib\UpdateUtil::sql("SELECT * FROM " . DBPREFIX . "module_newsletter_settings");
        while (!$res->EOF) {
            $field = $res->fields['setname'];
            DBG::msg("...merging {$field} with default settings");
            if (isset($settings[$field])) {
                //do we have another value for this?
                $settings[$field]['setvalue'] = $res->fields['setvalue'];
            }
            $res->MoveNext();
        }
        DBG::msg("Updating settings");
        foreach ($settings as $entry) {
            $setid = intval($entry['setid']);
            $field = addslashes($entry['setname']);
            $value = addslashes($entry['setvalue']);
            $status = intval($entry['status']);
            DBG::msg("...deleting field {$field}");
            \Cx\Lib\UpdateUtil::sql("DELETE FROM " . DBPREFIX . "module_newsletter_settings WHERE setid = '{$setid}' OR setname = '{$field}'");
            DBG::msg("...rewriting field {$field}");
            \Cx\Lib\UpdateUtil::sql("\n                INSERT INTO " . DBPREFIX . "module_newsletter_settings\n                    (setid, setname, setvalue, status)\n                VALUES (\n                    '{$setid}', '{$field}', '{$value}', '{$status}'\n                );\n            ");
        }
        DBG::msg("Deleting old unsubscribe key if set");
        \Cx\Lib\UpdateUtil::sql("DELETE FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notifyOnUnsubscribe'");
        DBG::msg("Done with newsletter update");
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        DBG::msg("Setting recipient count");
        $objResult = \Cx\Lib\UpdateUtil::sql("SELECT `newsletter`, COUNT(1) AS recipient_count FROM `" . DBPREFIX . "module_newsletter_tmp_sending` GROUP BY `newsletter`");
        if ($objResult->RecordCount()) {
            while (!$objResult->EOF) {
                \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter` SET `recipient_count` = " . $objResult->fields['recipient_count'] . " WHERE `id`=" . $objResult->fields['newsletter']);
                $objResult->MoveNext();
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // Add notification recipients to confirm_mail table
    try {
        $objResult = \Cx\Lib\UpdateUtil::sql("SELECT id FROM `" . DBPREFIX . "module_newsletter_confirm_mail` WHERE id='3'");
        if ($objResult->RecordCount() == 0) {
            DBG::msg("inserting standard confirm mails");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_newsletter_confirm_mail` (`id` ,`title` ,`content` ,`recipients`) VALUES ('3', '[[url]] - Neue Newsletter Empfänger [[action]]', 'Hallo Admin Eine neue Empfänger [[action]] in ihrem Newsletter System. Automatisch generierte Nachricht [[date]]', '');");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_access_user', array('accessUserID' => array('type' => 'INT(5)', 'unsigned' => true), 'newsletterCategoryID' => array('type' => 'INT(11)', 'after' => 'accessUserID'), 'code' => array('type' => 'VARCHAR(255)', 'after' => 'newsletterCategoryID', 'notnull' => true, 'default' => '')), array('rel' => array('fields' => array('accessUserID', 'newsletterCategoryID'), 'type' => 'UNIQUE'), 'accessUserID' => array('fields' => array('accessUserID'))));
        // set random newsletter code for access recipients
        \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_newsletter_access_user SET `code` = SUBSTR(MD5(RAND()),1,12) WHERE `code` = \'\'');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_rel_usergroup_newsletter', array('userGroup' => array('type' => 'INT(10)', 'unsigned' => true), 'newsletter' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'userGroup')), array('uniq' => array('fields' => array('userGroup', 'newsletter'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_settings', array('setid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(250)', 'after' => 'setid', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'text', 'after' => 'setname'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'setvalue')), array('setname' => array('fields' => array('setname'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_tmp_sending', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'newsletter' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'email' => array('type' => 'VARCHAR(255)', 'after' => 'newsletter', 'notnull' => true, 'default' => ''), 'sendt' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email'), 'type' => array('type' => 'ENUM(\'access\',\'newsletter\',\'core\')', 'notnull' => true, 'default' => 'newsletter', 'after' => 'sendt'), 'code' => array('type' => 'VARCHAR(10)', 'after' => 'type')), array('unique_email' => array('fields' => array('newsletter', 'email'), 'type' => 'UNIQUE'), 'email' => array('fields' => array('email'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_email_link', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'email_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'id'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'email_id'), 'url' => array('type' => 'VARCHAR(255)', 'after' => 'title')), array('email_id' => array('fields' => array('email_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_email_link_feedback', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'link_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'id'), 'email_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'link_id'), 'recipient_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'email_id'), 'recipient_type' => array('type' => 'ENUM(\'access\',\'newsletter\')', 'after' => 'recipient_id')), array('link_id' => array('fields' => array('link_id', 'email_id', 'recipient_id', 'recipient_type'), 'type' => 'UNIQUE'), 'email_id' => array('fields' => array('email_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_template', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'name'), 'html' => array('type' => 'text', 'after' => 'description'), 'required' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'html'), 'type' => array('type' => 'ENUM(\'e-mail\',\'news\')', 'notnull' => true, 'default' => 'e-mail', 'after' => 'required')));
        // migrate country field
        if (newsletter_migrate_country_field() == 'timeout') {
            return 'timeout';
        }
        // IMPORTANT: the table definition statement of module_newsletter_user must be AFTER newsletter_migrate_country_field() has been called!
        // fix missing columns & rename old columns if required
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_user', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'code'), 'uri' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'email'), 'sex' => array('type' => 'ENUM(\'m\',\'f\')', 'notnull' => false, 'after' => 'uri'), 'salutation' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sex', 'renamefrom' => 'title'), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'salutation'), 'lastname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'firstname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lastname'), 'position' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'firstname'), 'company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'position'), 'industry_sector' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'company'), 'address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'industry_sector', 'renamefrom' => 'street'), 'zip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'address'), 'city' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'zip'), 'country_id' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'city'), 'phone_office' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'country_id', 'renamefrom' => 'phone'), 'phone_private' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_office'), 'phone_mobile' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_private'), 'fax' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_mobile'), 'notes' => array('type' => 'text', 'after' => 'fax'), 'birthday' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '00-00-0000', 'after' => 'notes'), 'status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'birthday'), 'emaildate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'status'), 'language' => array('type' => 'INT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'emaildate')), array('email' => array('fields' => array('email'), 'type' => 'UNIQUE'), 'status' => array('fields' => array('status'))));
        // fix user's SALUTATION of previews updates
        if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0') && $objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
            // set user's SALUTATION based of previews updates
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `salutation` = `title`, `title` = '' WHERE `salutation` = '0' AND `title` REGEXP '^[0-9]+\$'");
            // clear all user's TITLE attribute that consist only of a number (it is most likely not the case that a user's TITLE is a number,
            // so we assume that it is a left over of the preview update bug, which did not migrate the user's TITLE attribute to the user's SALUTATION attribute
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `title` = '' WHERE `title` REGEXP '^[0-9]+\$'");
        }
        // switch to source mode for all newsletter content pages
        \Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'newsletter'), '3.0.1');
        // replace several placeholders that have changed
        $search = array('/TXT_NEWSLETTER_URI/', '/NEWSLETTER_URI/', '/TXT_NEWSLETTER_STREET/', '/NEWSLETTER_STREET/');
        $replace = array('TXT_NEWSLETTER_WEBSITE', 'NEWSLETTER_WEBSITE', 'TXT_NEWSLETTER_ADDRESS', 'NEWSLETTER_ADDRESS');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'newsletter'), $search, $replace, array('content'), '3.0.1');
        // sorry, brainfuck coming up...
        // this adds the missing template block newsletter_list as well as the placeholder [[NEWSLETTER_LIST_SELECTED]]
        $search = array('/(<!--\\s+BEGIN\\s+newsletter_lists\\s+-->)(.*)(<!--\\s+END\\s+newsletter_lists\\s+-->)/ms');
        $callback = function ($matches) {
            if (preg_match('/^(.*)(<[^>]+[\'"]list\\[\\{NEWSLETTER_LIST_ID\\}\\][\'"])([^>]*>)(.*)$/ms', $matches[2], $listMatches)) {
                if (strpos($listMatches[2] . $listMatches[3], '{NEWSLETTER_LIST_SELECTED}') === false) {
                    $matches[2] = $listMatches[1] . $listMatches[2] . ' {NEWSLETTER_LIST_SELECTED} ' . $listMatches[3] . $listMatches[4];
                } else {
                    $matches[2] = $listMatches[1] . $listMatches[2] . $listMatches[3] . $listMatches[4];
                }
            }
            if (!preg_match('/<!--\\s+BEGIN\\s+newsletter_list\\s+-->.*<!--\\s+END\\s+newsletter_list\\s+-->/ms', $matches[2])) {
                return $matches[1] . '<!-- BEGIN newsletter_list -->' . $matches[2] . '<!-- END newsletter_list -->' . $matches[3];
            } else {
                return $matches[1] . $matches[2] . $matches[3];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
        // this adds the missing placeholders [[SELECTED_DAY]], [[SELECTED_MONTH]], [[SELECTED_YEAR]]
        $search = array('/(<option[^>]+\\{USERS_BIRTHDAY_(DAY|MONTH|YEAR)\\}[\'"])([^>]*>)/ms');
        $callback = function ($matches) {
            if (strpos($matches[1] . $matches[3], '{SELECTED_' . $matches[2] . '}') === false) {
                return $matches[1] . ' {SELECTED_' . $matches[2] . '} ' . $matches[3];
            } else {
                return $matches[1] . $matches[3];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
        // replace [[TXT_NEWSLETTER_TITLE]] to [[TXT_NEWSLETTER_SALUTATION]]
        // replace [[NEWSLETTER_TITLE]] to [[NEWSLETTER_SALUTATION]]
        $search = array('/.*\\{NEWSLETTER_TITLE\\}.*/ms');
        $callback = function ($matches) {
            if (!preg_match('/<!--\\s+BEGIN\\s+recipient_title\\s+-->.*\\{NEWSLETTER_TITLE\\}.*<!--\\s+END\\s+recipient_title\\s+-->/ms', $matches[0]) && !preg_match('/<!--\\s+BEGIN\\s+recipient_salutation\\s+-->/ms', $matches[0]) && !preg_match('/\\{NEWSLETTER_SALUTATION\\}/ms', $matches[0])) {
                return str_replace(array('TXT_NEWSLETTER_TITLE', '{NEWSLETTER_TITLE}'), array('TXT_NEWSLETTER_SALUTATION', '{NEWSLETTER_SALUTATION}'), $matches[0]);
            } else {
                return $matches[0];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3') && empty($_SESSION['contrexx_update']['newsletter_links_decoded'])) {
        try {
            $objResult = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `url` FROM `' . DBPREFIX . 'module_newsletter_email_link`');
            if ($objResult !== false && $objResult->RecordCount() > 0) {
                while (!$objResult->EOF) {
                    \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_newsletter_email_link` SET `url` = ? WHERE `id` = ?', array(html_entity_decode($objResult->fields['url'], ENT_QUOTES, CONTREXX_CHARSET), $objResult->fields['id']));
                    $objResult->MoveNext();
                }
            }
            $_SESSION['contrexx_update']['newsletter_links_decoded'] = true;
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
        // add access to access ids 152/171/172/174/175/176 for user groups which had access to access id 25
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 25 GROUP BY group_id");
            if ($result !== false) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                VALUES\n                                                (152, " . intval($result->fields['group_id']) . "),\n                                                (171, " . intval($result->fields['group_id']) . "),\n                                                (172, " . intval($result->fields['group_id']) . "),\n                                                (174, " . intval($result->fields['group_id']) . "),\n                                                (175, " . intval($result->fields['group_id']) . "),\n                                                (176, " . intval($result->fields['group_id']) . ")\n                                                ");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    // add access id 176 for user groups which had access to 172 if version is older than 3.1.0
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 172 GROUP BY `group_id`");
            if ($result !== false) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                VALUES (176, " . intval($result->fields['group_id']) . ")");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Ejemplo n.º 22
0
 /**
  * Upload Finished callback
  *
  * This is called as soon as uploads have finished.
  * takes care of moving them to the right folder
  *
  * @param string $tempPath    Path to the temporary directory containing the files at this moment
  * @param string $tempWebPath Points to the same folder as tempPath, but relative to the webroot
  * @param array  $data        Data given to setData() when creating the uploader
  * @param string $uploadId    unique session id for the current upload
  * @param array  $fileInfos   uploaded file informations
  * @param array  $response    uploaded status
  *
  * @return array path and webpath
  */
 public static function uploadFinished($tempPath, $tempWebPath, $data, $uploadId, $fileInfos, $response)
 {
     $path = $data['path'];
     $webPath = $data['webPath'];
     $objCategory = Category::getCategory($data['category_id']);
     // check for sufficient permissions
     if ($objCategory->getAddFilesAccessId() && !\Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != \FWUser::getFWUserObject()->objUser->getId()) {
         return;
     }
     //we remember the names of the uploaded files here. they are stored in the session afterwards,
     //so we can later display them highlighted.
     $arrFiles = array();
     $uploadFiles = array();
     //rename files, delete unwanted
     $arrFilesToRename = array();
     //used to remember the files we need to rename
     $h = opendir($tempPath);
     if (!$h) {
         return array($path, $webPath);
     }
     while (false !== ($file = readdir($h))) {
         //skip . and ..
         if ($file == '.' || $file == '..') {
             continue;
         }
         try {
             //delete potentially malicious files
             $objTempFile = new \Cx\Lib\FileSystem\File($tempPath . '/' . $file);
             if (!\FWValidator::is_file_ending_harmless($file)) {
                 $objTempFile->delete();
                 continue;
             }
             $cleanFile = \Cx\Lib\FileSystem\FileSystem::replaceCharacters($file);
             if ($cleanFile != $file) {
                 $objTempFile->rename($tempPath . '/' . $cleanFile, false);
                 $file = $cleanFile;
             }
             $info = pathinfo($file);
             //check if file needs to be renamed
             $newName = '';
             $suffix = '';
             if (file_exists($path . '/' . $file)) {
                 $suffix = '_' . time();
                 $newName = $info['filename'] . $suffix . '.' . $info['extension'];
                 $arrFilesToRename[$file] = $newName;
                 array_push($arrFiles, $newName);
             }
             if (!isset($arrFilesToRename[$file])) {
                 array_push($uploadFiles, $file);
             }
             //rename files where needed
             foreach ($arrFilesToRename as $oldName => $newName) {
                 $objTempFile = new \Cx\Lib\FileSystem\File($tempPath . '/' . $oldName);
                 $objTempFile->rename($tempPath . '/' . $newName, false);
                 array_push($uploadFiles, $newName);
             }
             //move file from temp path into target folder
             $objImage = new \ImageManager();
             foreach ($uploadFiles as $fileName) {
                 $objFile = new \Cx\Lib\FileSystem\File($tempPath . '/' . $fileName);
                 $objFile->move($path . '/' . $fileName, false);
                 \Cx\Core\Core\Controller\Cx::instanciate()->getMediaSourceManager()->getThumbnailGenerator()->createThumbnailFromPath($path . '/' . $fileName);
             }
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
         }
         $objDownloads = new downloads('');
         $objDownloads->addDownloadFromUpload($info['filename'], $info['extension'], $suffix, $objCategory, $objDownloads, $fileInfos['name']);
     }
     return array($path, $webPath);
 }
Ejemplo n.º 23
0
/**
 * Cloudrexx
 *
 * @link      http://www.cloudrexx.com
 * @copyright Cloudrexx AG 2007-2015
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
function _utf8Update()
{
    global $objUpdate, $_DBCONFIG, $objDatabase, $_ARRAYLANG, $_CORELANG;
    $preferedCollation = 'utf8_unicode_ci';
    $usedCollation = '';
    $result = true;
    // fetch currently used collation
    try {
        $objResult = \Cx\Lib\UpdateUtil::sql('SHOW CREATE TABLE `' . DBPREFIX . 'access_users`');
        if ($objResult->EOF) {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
            return false;
        }
        $createStatement = $objResult->fields['Create Table'];
        // note: if charset latin1 is used, collation won't be set
        $matches = array();
        if (preg_match('/COLLATE=([a-z_0-9]*)/', $createStatement, $matches)) {
            $usedCollation = $matches[1];
        }
        \DBG::dump('Currently used collation: ' . $usedCollation);
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // fetch available collations
    $arrCollations = _getUtf8Collations();
    if (!is_array($arrCollations)) {
        return $arrCollations;
    }
    if (!isset($_SESSION['contrexx_update']['update']['core'])) {
        $_SESSION['contrexx_update']['update']['core'] = array();
    }
    // note: $usedCollation is the currently used collation.
    // in case $usedCollation is non-utf8, then the following var
    // won't be set. This will cause the update system to ask the user
    // to select an utf8 collation.
    if (in_array($usedCollation, $arrCollations)) {
        $_SESSION['contrexx_update']['update']['core']['utf8_collation'] = $usedCollation;
    }
    if (isset($_DBCONFIG['charset']) && $_DBCONFIG['charset'] == 'utf8') {
        // do not update templates if they should be utf8 already
        $_SESSION['contrexx_update']['update']['utf'] = true;
    }
    // show dialog to select utf8 collation
    if (empty($_SESSION['contrexx_update']['update']['core']['utf8_collation'])) {
        if (isset($_POST['dbCollation']) && in_array($objUpdate->stripslashes($_POST['dbCollation']), $arrCollations)) {
            $_SESSION['contrexx_update']['update']['core']['utf8_collation'] = $objUpdate->stripslashes($_POST['dbCollation']);
        } else {
            $collationMenu = '<select name="dbCollation">';
            foreach ($arrCollations as $collation) {
                $collationMenu .= '<option value="' . $collation . '"' . ($collation == $preferedCollation ? ' selected="selected"' : '') . '>' . $collation . '</option>';
            }
            $collationMenu .= '</select><br />';
            setUpdateMsg($_ARRAYLANG['TXT_SELECT_DB_COLLATION'], 'title');
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_SELECT_DB_COLLATION_MSG'] . '<br /><br />', $collationMenu), 'msg');
            setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
            return false;
        }
    }
    // WRITE COLLATION TO CONFIG FILE IF NECESSARY
    if (empty($_DBCONFIG['collation'])) {
        \DBG::msg('New collation set in _utf8Update(): ' . $_SESSION['contrexx_update']['update']['core']['utf8_collation']);
        // configuration.php will get written by core.php's _writeNewConfigurationFile()
        $_DBCONFIG['collation'] = $_SESSION['contrexx_update']['update']['core']['utf8_collation'];
        // IMPORTANT!
        // setting result to 'charset_changed' will cause a reinitialization of the update system
        // to ensure that the db-connections use the proper charset/collation
        $result = 'charset_changed';
    }
    // SET DATABASE CHARSET AND COLLATION
    try {
        $objDbStatement = \Cx\Lib\UpdateUtil::sql("SHOW CREATE DATABASE `" . $_DBCONFIG['database'] . "`");
        if (!preg_match('#DEFAULT\\sCHARACTER\\sSET\\sutf8\\sCOLLATE\\s' . $_SESSION['contrexx_update']['update']['core']['utf8_collation'] . '#s', $objDbStatement->fields['Create Database'])) {
            \Cx\Lib\UpdateUtil::sql("ALTER DATABASE `" . $_DBCONFIG['database'] . "` DEFAULT CHARACTER SET utf8 COLLATE " . $objUpdate->addslashes($_SESSION['contrexx_update']['update']['core']['utf8_collation']));
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // CHANGE TABLE CHARSET AND COLLATION
    $arrContrexxTables = array(DBPREFIX . 'access_group_dynamic_ids', DBPREFIX . 'access_group_static_ids', DBPREFIX . 'access_rel_user_group', DBPREFIX . 'access_settings', DBPREFIX . 'access_users', DBPREFIX . 'access_user_attribute', DBPREFIX . 'access_user_attribute_name', DBPREFIX . 'access_user_attribute_value', DBPREFIX . 'access_user_core_attribute', DBPREFIX . 'access_user_groups', DBPREFIX . 'access_user_mail', DBPREFIX . 'access_user_network', DBPREFIX . 'access_user_profile', DBPREFIX . 'access_user_title', DBPREFIX . 'access_user_validity', DBPREFIX . 'module_block_blocks', DBPREFIX . 'module_block_categories', DBPREFIX . 'module_block_rel_lang_content', DBPREFIX . 'module_block_rel_pages', DBPREFIX . 'module_block_settings', DBPREFIX . 'module_blog_categories', DBPREFIX . 'module_blog_comments', DBPREFIX . 'module_blog_messages', DBPREFIX . 'module_blog_messages_lang', DBPREFIX . 'module_blog_message_to_category', DBPREFIX . 'module_blog_networks', DBPREFIX . 'module_blog_networks_lang', DBPREFIX . 'module_blog_settings', DBPREFIX . 'module_blog_votes', DBPREFIX . 'module_calendar', DBPREFIX . 'module_calendar_categories', DBPREFIX . 'module_calendar_form_data', DBPREFIX . 'module_calendar_form_fields', DBPREFIX . 'module_calendar_registrations', DBPREFIX . 'module_calendar_settings', DBPREFIX . 'module_calendar_style', DBPREFIX . 'module_checkout_settings_general', DBPREFIX . 'module_checkout_settings_mails', DBPREFIX . 'module_checkout_settings_yellowpay', DBPREFIX . 'module_checkout_transactions', DBPREFIX . 'module_contact_form', DBPREFIX . 'module_contact_form_data', DBPREFIX . 'module_contact_form_field', DBPREFIX . 'module_contact_form_field_lang', DBPREFIX . 'module_contact_form_lang', DBPREFIX . 'module_contact_form_submit_data', DBPREFIX . 'module_contact_recipient', DBPREFIX . 'module_contact_recipient_lang', DBPREFIX . 'module_contact_settings', DBPREFIX . 'backend_areas', DBPREFIX . 'backups', DBPREFIX . 'content_node', DBPREFIX . 'content_page', DBPREFIX . 'core_country', DBPREFIX . 'core_mail_template', DBPREFIX . 'core_setting', DBPREFIX . 'core_text', DBPREFIX . 'ids', DBPREFIX . 'languages', DBPREFIX . 'lib_country', DBPREFIX . 'log', DBPREFIX . 'log_entry', DBPREFIX . 'modules', DBPREFIX . 'module_repository', DBPREFIX . 'sessions', DBPREFIX . 'settings', DBPREFIX . 'settings_image', DBPREFIX . 'settings_smtp', DBPREFIX . 'skins', DBPREFIX . 'module_data_categories', DBPREFIX . 'module_data_messages', DBPREFIX . 'module_data_messages_lang', DBPREFIX . 'module_data_message_to_category', DBPREFIX . 'module_data_placeholders', DBPREFIX . 'module_data_settings', DBPREFIX . 'module_directory_categories', DBPREFIX . 'module_directory_dir', DBPREFIX . 'module_directory_inputfields', DBPREFIX . 'module_directory_levels', DBPREFIX . 'module_directory_mail', DBPREFIX . 'module_directory_rel_dir_cat', DBPREFIX . 'module_directory_rel_dir_level', DBPREFIX . 'module_directory_settings', DBPREFIX . 'module_directory_settings_google', DBPREFIX . 'module_directory_vote', DBPREFIX . 'module_docsys', DBPREFIX . 'module_docsys_categories', DBPREFIX . 'module_docsys_entry_category', DBPREFIX . 'module_downloads_category', DBPREFIX . 'module_downloads_category_locale', DBPREFIX . 'module_downloads_download', DBPREFIX . 'module_downloads_download_locale', DBPREFIX . 'module_downloads_group', DBPREFIX . 'module_downloads_group_locale', DBPREFIX . 'module_downloads_rel_download_category', DBPREFIX . 'module_downloads_rel_download_download', DBPREFIX . 'module_downloads_rel_group_category', DBPREFIX . 'module_downloads_settings', DBPREFIX . 'module_ecard_ecards', DBPREFIX . 'module_ecard_settings', DBPREFIX . 'module_egov_configuration', DBPREFIX . 'module_egov_orders', DBPREFIX . 'module_egov_products', DBPREFIX . 'module_egov_product_calendar', DBPREFIX . 'module_egov_product_fields', DBPREFIX . 'module_egov_settings', DBPREFIX . 'module_feed_category', DBPREFIX . 'module_feed_news', DBPREFIX . 'module_feed_newsml_association', DBPREFIX . 'module_feed_newsml_categories', DBPREFIX . 'module_feed_newsml_documents', DBPREFIX . 'module_feed_newsml_providers', DBPREFIX . 'module_filesharing', DBPREFIX . 'module_filesharing_mail_template', DBPREFIX . 'module_forum_access', DBPREFIX . 'module_forum_categories', DBPREFIX . 'module_forum_categories_lang', DBPREFIX . 'module_forum_notification', DBPREFIX . 'module_forum_postings', DBPREFIX . 'module_forum_rating', DBPREFIX . 'module_forum_settings', DBPREFIX . 'module_forum_statistics', DBPREFIX . 'module_gallery_categories', DBPREFIX . 'module_gallery_comments', DBPREFIX . 'module_gallery_language', DBPREFIX . 'module_gallery_language_pics', DBPREFIX . 'module_gallery_pictures', DBPREFIX . 'module_gallery_settings', DBPREFIX . 'module_gallery_votes', DBPREFIX . 'module_guestbook', DBPREFIX . 'module_guestbook_settings', DBPREFIX . 'module_jobs', DBPREFIX . 'module_jobs_categories', DBPREFIX . 'module_jobs_location', DBPREFIX . 'module_jobs_rel_loc_jobs', DBPREFIX . 'module_jobs_settings', DBPREFIX . 'module_knowledge_articles', DBPREFIX . 'module_knowledge_article_content', DBPREFIX . 'module_knowledge_categories', DBPREFIX . 'module_knowledge_categories_content', DBPREFIX . 'module_knowledge_settings', DBPREFIX . 'module_knowledge_tags', DBPREFIX . 'module_knowledge_tags_articles', DBPREFIX . 'module_livecam', DBPREFIX . 'module_livecam_settings', DBPREFIX . 'module_market', DBPREFIX . 'module_market_categories', DBPREFIX . 'module_market_mail', DBPREFIX . 'module_market_paypal', DBPREFIX . 'module_market_settings', DBPREFIX . 'module_market_spez_fields', DBPREFIX . 'module_media_settings', DBPREFIX . 'module_mediadir_categories', DBPREFIX . 'module_mediadir_categories_names', DBPREFIX . 'module_mediadir_comments', DBPREFIX . 'module_mediadir_entries', DBPREFIX . 'module_mediadir_forms', DBPREFIX . 'module_mediadir_form_names', DBPREFIX . 'module_mediadir_inputfields', DBPREFIX . 'module_mediadir_inputfield_names', DBPREFIX . 'module_mediadir_inputfield_types', DBPREFIX . 'module_mediadir_inputfield_verifications', DBPREFIX . 'module_mediadir_levels', DBPREFIX . 'module_mediadir_level_names', DBPREFIX . 'module_mediadir_mails', DBPREFIX . 'module_mediadir_mail_actions', DBPREFIX . 'module_mediadir_masks', DBPREFIX . 'module_mediadir_order_rel_forms_selectors', DBPREFIX . 'module_mediadir_rel_entry_categories', DBPREFIX . 'module_mediadir_rel_entry_inputfields', DBPREFIX . 'module_mediadir_rel_entry_levels', DBPREFIX . 'module_mediadir_settings', DBPREFIX . 'module_mediadir_settings_num_categories', DBPREFIX . 'module_mediadir_settings_num_entries', DBPREFIX . 'module_mediadir_settings_num_levels', DBPREFIX . 'module_mediadir_settings_perm_group_forms', DBPREFIX . 'module_mediadir_votes', DBPREFIX . 'module_memberdir_directories', DBPREFIX . 'module_memberdir_name', DBPREFIX . 'module_memberdir_settings', DBPREFIX . 'module_memberdir_values', DBPREFIX . 'module_news', DBPREFIX . 'module_news_categories', DBPREFIX . 'module_news_categories_locale', DBPREFIX . 'module_news_comments', DBPREFIX . 'module_news_locale', DBPREFIX . 'module_news_settings', DBPREFIX . 'module_news_settings_locale', DBPREFIX . 'module_news_stats_view', DBPREFIX . 'module_news_teaser_frame', DBPREFIX . 'module_news_teaser_frame_templates', DBPREFIX . 'module_news_ticker', DBPREFIX . 'module_news_types', DBPREFIX . 'module_news_types_locale', DBPREFIX . 'module_newsletter', DBPREFIX . 'module_newsletter_access_user', DBPREFIX . 'module_newsletter_attachment', DBPREFIX . 'module_newsletter_category', DBPREFIX . 'module_newsletter_confirm_mail', DBPREFIX . 'module_newsletter_email_link', DBPREFIX . 'module_newsletter_email_link_feedback', DBPREFIX . 'module_newsletter_rel_cat_news', DBPREFIX . 'module_newsletter_rel_usergroup_newsletter', DBPREFIX . 'module_newsletter_rel_user_cat', DBPREFIX . 'module_newsletter_settings', DBPREFIX . 'module_newsletter_template', DBPREFIX . 'module_newsletter_tmp_sending', DBPREFIX . 'module_newsletter_user', DBPREFIX . 'module_newsletter_user_title', DBPREFIX . 'module_podcast_category', DBPREFIX . 'module_podcast_medium', DBPREFIX . 'module_podcast_rel_category_lang', DBPREFIX . 'module_podcast_rel_medium_category', DBPREFIX . 'module_podcast_settings', DBPREFIX . 'module_podcast_template', DBPREFIX . 'module_recommend', DBPREFIX . 'module_shop_article_group', DBPREFIX . 'module_shop_attribute', DBPREFIX . 'module_shop_categories', DBPREFIX . 'module_shop_currencies', DBPREFIX . 'module_shop_customer_group', DBPREFIX . 'module_shop_discountgroup_count_name', DBPREFIX . 'module_shop_discountgroup_count_rate', DBPREFIX . 'module_shop_discount_coupon', DBPREFIX . 'module_shop_importimg', DBPREFIX . 'module_shop_lsv', DBPREFIX . 'module_shop_manufacturer', DBPREFIX . 'module_shop_option', DBPREFIX . 'module_shop_orders', DBPREFIX . 'module_shop_order_attributes', DBPREFIX . 'module_shop_order_items', DBPREFIX . 'module_shop_payment', DBPREFIX . 'module_shop_payment_processors', DBPREFIX . 'module_shop_pricelists', DBPREFIX . 'module_shop_products', DBPREFIX . 'module_shop_rel_countries', DBPREFIX . 'module_shop_rel_customer_coupon', DBPREFIX . 'module_shop_rel_discount_group', DBPREFIX . 'module_shop_rel_payment', DBPREFIX . 'module_shop_rel_product_attribute', DBPREFIX . 'module_shop_rel_shipper', DBPREFIX . 'module_shop_shipment_cost', DBPREFIX . 'module_shop_shipper', DBPREFIX . 'module_shop_vat', DBPREFIX . 'module_shop_zones', DBPREFIX . 'stats_browser', DBPREFIX . 'stats_colourdepth', DBPREFIX . 'stats_config', DBPREFIX . 'stats_country', DBPREFIX . 'stats_hostname', DBPREFIX . 'stats_javascript', DBPREFIX . 'stats_operatingsystem', DBPREFIX . 'stats_referer', DBPREFIX . 'stats_requests', DBPREFIX . 'stats_requests_summary', DBPREFIX . 'stats_screenresolution', DBPREFIX . 'stats_search', DBPREFIX . 'stats_spiders', DBPREFIX . 'stats_spiders_summary', DBPREFIX . 'stats_visitors', DBPREFIX . 'stats_visitors_summary', DBPREFIX . 'module_u2u_address_list', DBPREFIX . 'module_u2u_message_log', DBPREFIX . 'module_u2u_sent_messages', DBPREFIX . 'module_u2u_settings', DBPREFIX . 'module_u2u_user_log', DBPREFIX . 'voting_additionaldata', DBPREFIX . 'voting_email', DBPREFIX . 'voting_rel_email_system', DBPREFIX . 'voting_results', DBPREFIX . 'voting_system', DBPREFIX . 'module_feed_newsml_content_item', DBPREFIX . 'module_newsletter_system', DBPREFIX . 'module_newsletter_config', DBPREFIX . 'module_shop_shipment');
    // fetch table collations
    try {
        $objInstalledTable = \Cx\Lib\UpdateUtil::sql("SHOW TABLE STATUS LIKE '" . DBPREFIX . "%'");
        while (!$objInstalledTable->EOF) {
            $arrInstalledTables[$objInstalledTable->fields['Name']] = $objInstalledTable->fields['Collation'];
            $objInstalledTable->MoveNext();
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // remove existing constraints
    $arrInstalledTableNames = array_keys($arrInstalledTables);
    if (!isset($_SESSION['contrexx_update']['update']['core']['constraints'])) {
        $_SESSION['contrexx_update']['update']['core']['constraints'] = array();
    }
    try {
        foreach ($arrInstalledTableNames as $table) {
            // fetch constraints
            $constraints = \Cx\Lib\UpdateUtil::get_constraints($table);
            // check if any constraints are set
            if (!count($constraints)) {
                continue;
            }
            // backup constraint definition (will be restored after the data has been migrated)
            $_SESSION['contrexx_update']['update']['core']['constraints'][$table] = $constraints;
            // remove constraints
            \Cx\Lib\UpdateUtil::set_constraints($table, array());
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // migrate tables to utf8 collation
    try {
        foreach ($arrContrexxTables as $table) {
            $converted = false;
            if (in_array($table, $arrInstalledTableNames)) {
                if ($arrInstalledTables[$table] == $_SESSION['contrexx_update']['update']['core']['utf8_collation']) {
                    continue;
                } else {
                    \DBG::msg('UTF-8: Migrate DB-Table: ' . $table);
                    if (!in_array($table . '_new', $arrInstalledTableNames)) {
                        $objTableStructure = \Cx\Lib\UpdateUtil::sql("SHOW CREATE TABLE `" . $table . "`");
                        $objTableStructure->fields['Create Table'] = preg_replace(array('/TABLE `' . $table . '/', '/collate[\\s|=][a-z0-9_]+_bin/i', '/default current_timestamp on update current_timestamp/i', '/character\\s+set[\\s|=][a-z0-9_]+/i', '/collate[\\s|=][a-z0-9_]+/i', '/default charset=[a-z0-9_]+/i'), array('TABLE `' . $table . '_new', 'BINARY', '', '', '', ''), $objTableStructure->fields['Create Table']);
                        \Cx\Lib\UpdateUtil::sql($objTableStructure->fields['Create Table'] . " DEFAULT CHARSET=utf8 COLLATE=" . $objUpdate->addslashes($_SESSION['contrexx_update']['update']['core']['utf8_collation']) . ";\n");
                    }
                    $objResult = \Cx\Lib\UpdateUtil::sql("SELECT COUNT(1) AS rowCount FROM `" . $table . "`");
                    $oriCount = $objResult->fields['rowCount'];
                    $objResult = \Cx\Lib\UpdateUtil::sql("SELECT COUNT(1) AS rowCount FROM `" . $table . "_new`");
                    $newCount = $objResult->fields['rowCount'];
                    if ($oriCount !== $newCount) {
                        // migrate data
                        \Cx\Lib\UpdateUtil::sql("TRUNCATE TABLE `" . $table . "_new`");
                        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . $table . "_new` SELECT * FROM `" . $table . "`");
                    }
                    \Cx\Lib\UpdateUtil::sql("DROP TABLE `" . $table . "`");
                    $converted = true;
                }
            }
            if (in_array($table . '_new', $arrInstalledTableNames) || $converted) {
                \Cx\Lib\UpdateUtil::sql("RENAME TABLE `" . $table . "_new`  TO `" . $table . "`");
            }
            if (!checkTimeoutLimit()) {
                return 'timeout';
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // reset constraints
    try {
        foreach ($_SESSION['contrexx_update']['update']['core']['constraints'] as $table => $constraints) {
            // set constraints
            \Cx\Lib\UpdateUtil::set_constraints($table, $constraints);
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // migrate themes to utf8
    if (!isset($_SESSION['contrexx_update']['update']['utf'])) {
        if (_convertThemes2UTF()) {
            $_SESSION['contrexx_update']['update']['utf'] = true;
        } else {
            return false;
        }
    }
    // $result is either TRUE or 'charset_changed' in case the charset/collation has been changed
    return $result;
}
Ejemplo n.º 24
0
 /**
  * Adds a placeholder for the CSRF code to the given template.
  * This is so you can easily patch javascript code that handles
  * URLs, as this cannot be done by add_code().
  * @param   \Cx\Core\Html\Sigma     $tpl    Template object
  */
 public static function add_placeholder($tpl)
 {
     if (!self::__is_logged_in()) {
         return true;
     }
     // do not add placeholder in case current request is an AJAX request.  They're secure
     // by definition and also, they're much more delicate in
     // what can be returned - and they usually exceed the
     // request amount limit pretty quickly (see active_decrease etc)
     if (self::__is_ajax()) {
         return;
     }
     if (!is_object($tpl)) {
         \DBG::msg("self::add_placeholder(): fix this call, that ain't a template object! (Stack follows)");
         \DBG::stack();
     }
     $code = self::__get_code();
     $tpl->setGlobalVariable(array("CSRF_PARAM" => self::param(), "CSRF_KEY" => "{$code}"));
     return true;
 }
Ejemplo n.º 25
0
 /**
  * Handle the calendar image upload
  * 
  * @param string $id unique form id
  * 
  * @return string image path
  */
 function _handleUpload($fieldName, $id)
 {
     $tup = self::getTemporaryUploadPath($fieldName, $id);
     $tmpUploadDir = \Env::get('cx')->getWebsitePath() . $tup[1] . '/' . $tup[2] . '/';
     //all the files uploaded are in here
     $depositionTarget = $this->uploadImgPath;
     //target folder
     $pic = '';
     //move all files
     if (!\Cx\Lib\FileSystem\FileSystem::exists($tmpUploadDir)) {
         throw new \Exception("could not find temporary upload directory '{$tmpUploadDir}'");
     }
     $h = opendir($tmpUploadDir);
     if ($h) {
         while (false !== ($f = readdir($h))) {
             // skip folders and thumbnails
             if ($f == '..' || $f == '.' || preg_match("/(?:\\.(?:thumb_thumbnail|thumb_medium|thumb_large)\\.[^.]+\$)|(?:\\.thumb)\$/i", $f)) {
                 continue;
             }
             //do not overwrite existing files.
             $prefix = '';
             while (file_exists($depositionTarget . $prefix . $f)) {
                 if (empty($prefix)) {
                     $prefix = 0;
                 }
                 $prefix++;
             }
             // move file
             try {
                 $objFile = new \Cx\Lib\FileSystem\File($tmpUploadDir . $f);
                 $fileInfo = pathinfo($tmpUploadDir . $f);
                 $objFile->move($depositionTarget . $prefix . $f, false);
                 $imageName = $prefix . $f;
                 if (in_array($fileInfo['extension'], array('gif', 'jpg', 'jpeg', 'png'))) {
                     $objImage = new \ImageManager();
                     $objImage->_createThumb($this->uploadImgPath, $this->uploadImgWebPath, $imageName, 180);
                 }
                 $pic = contrexx_input2raw($this->uploadImgWebPath . $imageName);
                 // abort after one file has been fetched, as all event upload
                 // fields do allow a single file only anyway
                 break;
             } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                 \DBG::msg($e->getMessage());
             }
         }
     }
     return $pic;
 }
Ejemplo n.º 26
0
 /**
  * Saves the new image wherever you want
  * @todo    In case the PHP script has no write access to the location set by $this->newImageFile,
  *          the image shall be sent to the output buffer and then be put into the new file
  *          location using the FileSystemFile object.
  * @access  public
  * @param   string    $file             The path for the image file to be written.
  * @param   booelan   $forceOverwrite   Force overwriting existing files if true.
  * @return  boolean                     True on success, false otherwise.
  */
 public function saveNewImage($file, $forceOverwrite = false)
 {
     // TODO: Add some sort of diagnostics (Message) here and elsewhere in this class
     if (!$this->imageCheck) {
         return false;
     }
     if (empty($this->newImage)) {
         return false;
     }
     if (file_exists($file)) {
         if (!$forceOverwrite) {
             return false;
         }
         \Cx\Lib\FileSystem\FileSystem::makeWritable($file);
     } else {
         try {
             $objFile = new \Cx\Lib\FileSystem\File($file);
             $objFile->touch();
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
         }
     }
     // TODO: Unfortunately, the functions imagegif(), imagejpeg() and imagepng() can't use the Contrexx FileSystem wrapper,
     //       therefore we need to set the global write access image files.
     //       This issue might be solved by using the output-buffer and write the image manually afterwards.
     //
     //       IMPORTANT: In case something went wrong (see bug #1441) and the path $strPathNew.$strFileNew refers to a directory
     //       we must abort the operation here, otherwise we would remove the execution flag on a directory, which would
     //       cause to remove any browsing access to the directory.
     if (is_dir($file)) {
         return false;
     }
     \Cx\Lib\FileSystem\FileSystem::chmod($file, 0666);
     //\Cx\Lib\FileSystem\FileSystem::CHMOD_FILE);
     $this->newImageFile = $file;
     if ($this->newImageType == self::IMG_TYPE_PNG) {
         $this->setTransparency();
     }
     switch ($this->newImageType) {
         case self::IMG_TYPE_GIF:
             $function = 'imagegif';
             if (!function_exists($function)) {
                 $function = 'imagejpeg';
             }
             break;
         case self::IMG_TYPE_JPEG:
             $function = 'imagejpeg';
             break;
         case self::IMG_TYPE_PNG:
             // make a jpeg thumbnail, too
             $function = 'imagepng';
             break;
         default:
             return false;
     }
     // Only adjust quality, if it is set.
     if ($this->newImageQuality != '') {
         $function($this->newImage, $this->newImageFile, $this->getQuality());
     } else {
         $function($this->newImage, $this->newImageFile);
     }
     return true;
 }
Ejemplo n.º 27
0
 private function processUpdate()
 {
     global $_CORELANG, $_CONFIG, $_ARRAYLANG;
     $this->objTemplate->addBlockfile('CONTENT', 'process', 'process.html');
     if (($return = $this->_loadUpdateLanguage()) !== true) {
         $this->objTemplate->setVariable('UPDATE_ERROR_MSG', $return);
         $this->objTemplate->parse('updateProcessError');
     } elseif (($arrVersions = $this->getAvailabeVersions()) === false || !@(include_once UPDATE_UPDATES . '/' . $_SESSION['contrexx_update']['version'] . '/' . $arrVersions[$_SESSION['contrexx_update']['version']]['script'])) {
         $this->objTemplate->setVariable('UPDATE_ERROR_MSG', $_CORELANG['TXT_UPDATE_UNABLE_TO_START']);
         $this->objTemplate->parse('updateProcessError');
     } else {
         if (!$this->_isNewerVersion($_CONFIG['coreCmsVersion'], $_SESSION['contrexx_update']['version'])) {
             $result = true;
         } else {
             if (!empty($_POST['execution_time'])) {
                 $_SESSION['contrexx_update']['max_execution_time'] = intval($_POST['execution_time']);
                 if (intval($_POST['execution_time']) < 20) {
                     setUpdateMsg('<div class="message-warning">' . $_CORELANG['TXT_UPDATE_EXECUTION_TIME'] . '</div>', 'msg');
                     setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
                     $result = false;
                 } else {
                     die('{"time": ' . intval($_POST['execution_time']) . '}');
                 }
             } else {
                 try {
                     if (!activateDebugging()) {
                         throw new \Exception("The debugging file couldn't be created.");
                     }
                     $result = true;
                 } catch (\Exception $e) {
                     setUpdateMsg($_CORELANG['TXT_UPDATE_DBG_FILE'], 'msg');
                     setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="skipDebugMsg" id="skipDebugMsg" value="skipDebugMsg" />', 'button');
                     if (empty($_POST['skipDebugMsg'])) {
                         $result = false;
                     }
                 }
                 if ($result !== false) {
                     DBG::msg('-------------------------------------------------------------');
                     DBG::msg('CLOUDREXX UPDATE - NEW REQUEST');
                     DBG::msg('Date: ' . date('d.m.Y H:i:s'));
                     DBG::msg('Get-Params:');
                     DBG::dump($_GET);
                     DBG::msg('User: '******'contrexx_update']['username']);
                     DBG::msg('-------------------------------------------------------------');
                     $result = executeContrexxUpdate();
                 }
             }
         }
         if ($result !== true) {
             if (!empty($this->arrStatusMsg['error'])) {
                 $this->objTemplate->setVariable('UPDATE_ERROR_MSG', implode('<br />', $this->arrStatusMsg['error']));
                 $this->objTemplate->parse('updateProcessError');
             }
             if (empty($this->arrStatusMsg['title'])) {
                 $this->arrStatusMsg['title'] = 'Update Fehler';
             }
             if (empty($this->arrStatusMsg['button'])) {
                 $this->arrStatusMsg['button'] = '<input type="submit" value="' . $_CORELANG['TXT_UPDATE_TRY_AGAIN'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />';
             }
             if (!empty($this->arrStatusMsg['dialog']) && empty($this->arrStatusMsg['error'])) {
                 $this->objTemplate->hideBlock('processStatus');
                 $dialogContent = implode('<br />', $this->arrStatusMsg['msg']);
                 if (!$this->ajax) {
                     $dialogContent = str_replace(array('\'', "\r\n"), array('\\\'', ''), $dialogContent);
                 }
                 $this->objTemplate->setVariable('PROCESS_DIALOG_CONTENT', $dialogContent);
                 if ($this->ajax) {
                     $this->html['dialog'] = $this->arrStatusMsg['dialog'];
                     $this->objTemplate->parse('ajaxDialogContent');
                 } else {
                     $this->objTemplate->parse('dialogContent');
                 }
             } else {
                 if (!empty($this->arrStatusMsg['timeout']) && empty($this->arrStatusMsg['error'])) {
                     $this->html['timeout'] = $this->arrStatusMsg['timeout'];
                 } else {
                     $this->objTemplate->hideBlock('dialogContent');
                     $this->objTemplate->hideBlock('ajaxDialogContent');
                     $this->objTemplate->setVariable(array('UPDATE_PROCESS_TITLE' => $_CORELANG['TXT_UPDATE_UPDATE_PROCESS'], 'UPDATE_STATUS_TITLE' => $this->arrStatusMsg['title'], 'UPDATE_STATUS' => str_replace('[[SQL_INFO_TITLE]]', $this->arrStatusMsg['title'], implode('<br />', $this->arrStatusMsg['msg']))));
                     $this->setNavigation($this->arrStatusMsg['button']);
                 }
             }
         } else {
             $this->objTemplate->hideBlock('dialogContent');
             $this->objTemplate->hideBlock('ajaxDialogContent');
             $this->objTemplate->hideBlock('processStatus');
             $urlFrontend = ASCMS_PATH_OFFSET !== '' ? ASCMS_PATH_OFFSET : '/';
             if (!empty($_SESSION['contrexx_update']['modified_files']) && count($_SESSION['contrexx_update']['modified_files'])) {
                 foreach ($_SESSION['contrexx_update']['modified_files'] as $arrFile) {
                     $this->objTemplate->setVariable(array('BACKUP_FILE_SRC' => $arrFile['src'], 'BACKUP_FILE_DST' => $arrFile['dst']));
                     $this->objTemplate->parse('backed_file');
                 }
                 $this->objTemplate->parse('backed_files');
             } else {
                 $this->objTemplate->hideblock('backed_files');
             }
             if (!empty($_SESSION['contrexx_update']['modified_cmds']) && count($_SESSION['contrexx_update']['modified_cmds'])) {
                 foreach ($_SESSION['contrexx_update']['modified_cmds'] as $arrCmds) {
                     $this->objTemplate->setVariable(array('CHANGED_CMD_PAGE_TITLE' => $arrCmds['pageTitle'], 'CHANGED_CMD_ORIG_CMD' => $arrCmds['origCmd'], 'CHANGED_CMD_NEW_CMD' => $arrCmds['newCmd']));
                     $this->objTemplate->parse('changed_cmd');
                 }
                 $this->objTemplate->parse('changed_cmds');
             } else {
                 $this->objTemplate->hideblock('changed_cmds');
             }
             $this->objTemplate->setVariable(array('TXT_UPDATE_UPDATE_FINISHED' => $_CORELANG['TXT_UPDATE_UPDATE_FINISHED'], 'URL_FRONTEND' => $urlFrontend, 'URL_BACKEND' => ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH, 'UPDATE_VERSION_INSTALLED' => $this->getLiteralRepresentationOfVersion($_SESSION['contrexx_update']['version']), 'UPDATE_VERSION_NUMBER' => $_SESSION['contrexx_update']['version']));
             $this->objTemplate->parse('finish');
             $_SESSION['contrexx_update']['step'] = 0;
             $_SESSION['contrexx_update']['update'] = array();
         }
     }
     $this->objTemplate->parse('process');
     if ($this->ajax) {
         $this->html['content'] = $this->objTemplate->get('process');
     }
 }
 /**
  * Find the url exists or not
  * 
  * @param string $url url
  * 
  * @return boolean true on url exists, false otherwise
  */
 function urlfind($url)
 {
     if (!ini_get('allow_url_fopen')) {
         ini_set('allow_url_fopen', 'On');
     }
     if (ini_get('allow_url_fopen')) {
         if ($url) {
             $file = @fopen($url . '/modules/Calendar/Controller/CalendarWebserviceServer.class.php', "r");
         }
         if ($file) {
             fclose($file);
             return true;
         } else {
             return false;
         }
     } else {
         try {
             $request = new \HTTP_Request2($url . 'modules/Calendar/Controller/CalendarWebserviceServer.class.php');
             $response = $request->send();
             if (404 == $response->getStatus()) {
                 return false;
             } else {
                 return true;
             }
         } catch (Exception $e) {
             \DBG::msg($e->getMessage());
             return false;
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * Handle uploads
  * @see Contact::_uploadFilesLegacy()
  * @param array $arrFields
  * @param boolean move should the files be moved or
  *                do we just want an array of filenames?
  *                defaults to false. no effect in legacy mode.
  * @return array A list of files that have been stored successfully in the system
  */
 protected function _uploadFiles($arrFields, $move = false)
 {
     /* the field unique_id has been introduced with the new uploader.
      * it helps us to tell whether we're handling an form generated
      * before the new uploader using the classic input fields or
      * if we have to treat the files already uploaded by the uploader.
      */
     if ($this->legacyMode) {
         //legacy function for old uploader
         return $this->_uploadFilesLegacy($arrFields);
     } else {
         //new uploader used
         if (!$this->hasFileField) {
             //nothing to do for us, no files
             return array();
         }
         $arrFiles = array();
         //we'll collect name => path of all files here and return this
         $documentRootPath = \Env::get('cx')->getWebsiteDocumentRootPath();
         foreach ($arrFields as $fieldId => $arrField) {
             // skip non-upload fields
             if (!in_array($arrField['type'], array('file', 'multi_file'))) {
                 continue;
             }
             $tup = self::getTemporaryUploadPath($this->submissionId, $fieldId);
             $tmpUploadDir = $tup[1] . '/' . $tup[2] . '/';
             //all the files uploaded are in here
             $depositionTarget = "";
             //target folder
             //on the first call, _uploadFiles is called with move=false.
             //this is done in order to get an array of the moved files' names, but
             //the files are left in place.
             //the second call is done with move=true - here we finally move the
             //files.
             //
             //the target folder is created in the first call, because if we can't
             //create the folder, the target path is left pointing at the path
             //specified by $arrSettings['fileUploadDepositionPath'].
             //
             //to remember the target folder for the second call, it is stored in
             //$this->depositionTarget.
             if (!$move) {
                 //first call - create folder
                 //determine where form uploads are stored
                 $arrSettings = $this->getSettings();
                 $depositionTarget = $arrSettings['fileUploadDepositionPath'] . '/';
                 //find an unique folder name for the uploaded files
                 $folderName = date("Ymd") . '_' . $fieldId;
                 $suffix = "";
                 if (file_exists($documentRootPath . $depositionTarget . $folderName)) {
                     $suffix = 1;
                     while (file_exists($documentRootPath . $depositionTarget . $folderName . '-' . $suffix)) {
                         $suffix++;
                     }
                     $suffix = '-' . $suffix;
                 }
                 $folderName .= $suffix;
                 //try to make the folder and change target accordingly on success
                 if (\Cx\Lib\FileSystem\FileSystem::make_folder($documentRootPath . $depositionTarget . $folderName)) {
                     \Cx\Lib\FileSystem\FileSystem::makeWritable($documentRootPath . $depositionTarget . $folderName);
                     $depositionTarget .= $folderName . '/';
                 }
                 $this->depositionTarget[$fieldId] = $depositionTarget;
             } else {
                 $depositionTarget = $this->depositionTarget[$fieldId];
             }
             //move all files
             if (!\Cx\Lib\FileSystem\FileSystem::exists($tmpUploadDir)) {
                 throw new \Cx\Core_Modules\Contact\Controller\ContactException("could not find temporary upload directory '{$tmpUploadDir}'");
             }
             $h = opendir(\Env::get('cx')->getWebsitePath() . $tmpUploadDir);
             while (false !== ($f = readdir($h))) {
                 if ($f != '..' && $f != '.') {
                     //do not overwrite existing files.
                     $prefix = '';
                     while (file_exists($documentRootPath . $depositionTarget . $prefix . $f)) {
                         if (empty($prefix)) {
                             $prefix = 0;
                         }
                         $prefix++;
                     }
                     if ($move) {
                         // move file
                         try {
                             $objFile = new \Cx\Lib\FileSystem\File($tmpUploadDir . $f);
                             $objFile->move($documentRootPath . $depositionTarget . $prefix . $f, false);
                         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                             \DBG::msg($e->getMessage());
                         }
                     }
                     $arrFiles[$fieldId][] = array('name' => $f, 'path' => $depositionTarget . $prefix . $f);
                 }
             }
         }
         //cleanup
         //TODO: this does not work for certain reloads - add cleanup routine
         //@rmdir($tmpUploadDir);
         return $arrFiles;
     }
 }
Ejemplo n.º 30
0
 /**
  * Validates the submitted comment data and writes it to the databse if valid.
  * Additionally, a notification is send out to the administration about the comment
  * by e-mail (only if the corresponding configuration option is set to do so). 
  *
  * @param   integer News message ID for which the comment shall be stored
  * @param   string  Title of the news message for which the comment shall be stored.
  *                  The title will be used in the notification e-mail
  * @param   string  The poster's name of the comment
  * @param   string  The comment's title
  * @param   string  The comment's message text
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @global    array
  * @return  array   Returns an array of two elements. The first is either TRUE on success or FALSE on failure.
  *                  The second element contains an error message on failure.  
  */
 private function storeMessageComment($newsMessageId, $newsMessageTitle, $name, $title, $message)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     if (!isset($_SESSION['news'])) {
         $_SESSION['news'] = array();
         $_SESSION['news']['comments'] = array();
     }
     // just comment
     if ($this->checkForCommentFlooding($newsMessageId)) {
         return array(false, sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_INTERVAL_MSG'], $this->arrSettings['news_comments_timeout']));
     }
     if (empty($title)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_TITLE']);
     }
     if (empty($message)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_MESSAGE']);
     }
     $date = time();
     $userId = 0;
     if (\FWUser::getFWUserObject()->objUser->login()) {
         $userId = \FWUser::getFWUserObject()->objUser->getId();
         $name = \FWUser::getParsedUserTitle($userId);
     } elseif ($this->arrSettings['news_comments_anonymous'] == '1') {
         // deny comment if the poster did not specify his name
         if (empty($name)) {
             return array(false, $_ARRAYLANG['TXT_NEWS_POSTER_NAME_MISSING']);
         }
         // check CAPTCHA for anonymous posters
         if (!\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             return array(false, null);
         }
     } else {
         // Anonymous comments are not allowed
         return array(false, null);
     }
     $isActive = $this->arrSettings['news_comments_autoactivate'];
     $ipAddress = contrexx_input2raw($_SERVER['REMOTE_ADDR']);
     $objResult = $objDatabase->Execute("\n            INSERT INTO `" . DBPREFIX . "module_news_comments` \n                    SET `title` = '" . contrexx_raw2db($title) . "',\n                        `text` = '" . contrexx_raw2db($message) . "',\n                        `newsid` = '" . contrexx_raw2db($newsMessageId) . "',\n                        `date` = '" . contrexx_raw2db($date) . "',\n                        `poster_name` = '" . contrexx_raw2db($name) . "',\n                        `userid` = '" . contrexx_raw2db($userId) . "',\n                        `ip_address` = '" . contrexx_raw2db($ipAddress) . "',\n                        `is_active` = '" . contrexx_raw2db($isActive) . "'");
     if (!$objResult) {
         return array(false, $_ARRAYLANG['TXT_NEWS_COMMENT_SAVE_ERROR']);
     }
     /* Prevent comment flooding from same user:
        Either user is authenticated or had to validate a CAPTCHA.
        In either way, a Contrexx session had been initialized,
        therefore we are able to use the $_SESSION to log this comment */
     $_SESSION['news']['comments'][$newsMessageId] = $date;
     // Don't send a notification e-mail to the administrator
     if (!$this->arrSettings['news_comments_notification']) {
         return array(true, null);
     }
     // Send a notification e-mail to administrator
     if (!@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         \DBG::msg('Unable to send e-mail notification to admin');
         //DBG::stack();
         return array(true, null);
     }
     $objMail = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->From = $_CONFIG['coreAdminEmail'];
     $objMail->FromName = $_CONFIG['coreGlobalPageTitle'];
     $objMail->IsHTML(false);
     $objMail->Subject = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_SUBJECT'], $newsMessageTitle);
     $manageCommentsUrl = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? NULL : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=News&act=comments&newsId=' . $newsMessageId;
     $activateCommentTxt = $this->arrSettings['news_comments_autoactivate'] ? '' : sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_LINK'], $manageCommentsUrl);
     $objMail->Body = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_BODY'], $_CONFIG['domainUrl'], $newsMessageTitle, \FWUser::getParsedUserTitle($userId, $name), $title, nl2br($message), $activateCommentTxt);
     $objMail->AddAddress($_CONFIG['coreAdminEmail']);
     if (!$objMail->Send()) {
         \DBG::msg('Sending of notification e-mail failed');
         //DBG::stack();
     }
     return array(true, null);
 }