Exemplo n.º 1
0
 private function fetchSubmittedData()
 {
     // set default values
     $data['newsText'] = '';
     $data['newsTeaserText'] = '';
     $data['newsTitle'] = '';
     $data['newsRedirect'] = 'http://';
     $data['newsSource'] = 'http://';
     $data['newsUrl1'] = 'http://';
     $data['newsUrl2'] = 'http://';
     $data['newsCat'] = '';
     $data['newsType'] = '';
     $data['newsTypeRedirect'] = 0;
     if (!isset($_POST['submitNews'])) {
         return array(false, $data);
     }
     $objValidator = new \FWValidator();
     // set POST data
     $data['newsTitle'] = contrexx_input2raw(html_entity_decode($_POST['newsTitle'], ENT_QUOTES, CONTREXX_CHARSET));
     $data['newsTeaserText'] = contrexx_input2raw(html_entity_decode($_POST['newsTeaserText'], ENT_QUOTES, CONTREXX_CHARSET));
     $data['newsRedirect'] = $objValidator->getUrl(contrexx_input2raw(html_entity_decode($_POST['newsRedirect'], ENT_QUOTES, CONTREXX_CHARSET)));
     $data['newsText'] = contrexx_remove_script_tags($this->filterBodyTag(contrexx_input2raw(html_entity_decode($_POST['newsText'], ENT_QUOTES, CONTREXX_CHARSET))));
     $data['newsSource'] = $objValidator->getUrl(contrexx_input2raw(html_entity_decode($_POST['newsSource'], ENT_QUOTES, CONTREXX_CHARSET)));
     $data['newsUrl1'] = $objValidator->getUrl(contrexx_input2raw(html_entity_decode($_POST['newsUrl1'], ENT_QUOTES, CONTREXX_CHARSET)));
     $data['newsUrl2'] = $objValidator->getUrl(contrexx_input2raw(html_entity_decode($_POST['newsUrl2'], ENT_QUOTES, CONTREXX_CHARSET)));
     $data['newsCat'] = !empty($_POST['newsCat']) ? contrexx_input2raw($_POST['newsCat']) : array();
     $data['newsType'] = !empty($_POST['newsType']) ? intval($_POST['newsType']) : 0;
     $data['newsTypeRedirect'] = !empty($_POST['newsTypeRedirect']) ? true : false;
     $data['enableRelatedNews'] = !empty($this->arrSettings['use_related_news']) ? 1 : 0;
     $data['relatedNews'] = !empty($_POST['relatedNews']) ? contrexx_input2raw($_POST['relatedNews']) : array();
     $data['enableTags'] = !empty($this->arrSettings['news_use_tags']) ? 1 : 0;
     $data['newsTags'] = !empty($_POST['newsTags']) ? contrexx_input2raw($_POST['newsTags']) : array();
     return array(true, $data);
 }
Exemplo n.º 2
0
 public function setWebsite($website)
 {
     $this->website = \FWValidator::getUrl($website);
 }
 /**
  * Parse the registration related palceholders
  * $hostUri and $hostTarget should be set before calling this method
  *
  * @param \Cx\Core\Html\Sigma                           $objTpl         Template instance
  * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event          Event instance
  * @param string                                        $hostUri        Host uri of the event(internal/external)
  * @param string                                        $hostTarget     Host uri target type (_blank/null)
  *
  * @return null
  */
 public function parseRegistrationPlaceholders(\Cx\Core\Html\Sigma $objTpl, CalendarEvent $event, $hostUri = '', $hostTarget = '')
 {
     global $_ARRAYLANG;
     $numRegistrations = contrexx_input2int($event->getRegistrationCount());
     $numDeregistration = contrexx_input2int($event->getCancellationCount());
     $objEscortManager = new \Cx\Modules\Calendar\Controller\CalendarRegistrationManager($event, true, false);
     $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $numRegistrations, $this->moduleLangVar . '_EVENT_COUNT_SIGNOFF' => $numDeregistration, $this->moduleLangVar . '_EVENT_COUNT_SUBSCRIBER' => $objEscortManager->getEscortData(), $this->moduleLangVar . '_REGISTRATIONS_SUBSCRIBER' => $event->numSubscriber));
     // Only link to registration form if event registration is set up and event lies in the future
     if (!$event->registration || time() > $event->startDate->getTimestamp()) {
         $objTpl->hideBlock('calendarEventRegistration');
         return;
     }
     // Only show registration form if event accepts registrations.
     // Event accepts registrations, if
     //     - no attendee limit is set
     //     - or if there are still free places available
     $registrationOpen = true;
     $regLinkTarget = '_self';
     if ($event->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL && !$event->registrationExternalFullyBooked || $event->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL && (empty($event->numSubscriber) || !\FWValidator::isEmpty($event->getFreePlaces()))) {
         if ($event->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL) {
             $regLinkSrc = \FWValidator::getUrl($event->registrationExternalLink);
             $regLinkTarget = '_blank';
         } elseif ($hostUri) {
             $regLinkSrc = $hostUri . '/' . CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&cmd=register&id=' . $event->id . '&date=' . $event->startDate->getTimestamp();
         } else {
             $params = array('id' => $event->id, 'date' => $event->startDate->getTimestamp());
             $regLinkSrc = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', FRONTEND_LANG_ID, $params)->toString();
         }
         $regLink = '<a href="' . $regLinkSrc . '" ' . $hostTarget . '>' . $_ARRAYLANG['TXT_CALENDAR_REGISTRATION'] . '</a>';
     } else {
         $regLink = '<i>' . $_ARRAYLANG['TXT_CALENDAR_EVENT_FULLY_BLOCKED'] . '</i>';
         $regLinkSrc = '';
         $registrationOpen = false;
     }
     $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_REGISTRATION_LINK' => $regLink, $this->moduleLangVar . '_EVENT_REGISTRATION_LINK_SRC' => $regLinkSrc, $this->moduleLangVar . '_EVENT_REGISTRATION_LINK_TARGET' => $regLinkTarget));
     if ($objTpl->blockExists('calendarEventRegistrationOpen')) {
         if ($registrationOpen) {
             $objTpl->touchBlock('calendarEventRegistrationOpen');
         } else {
             $objTpl->hideBlock('calendarEventRegistrationOpen');
         }
     }
     if ($objTpl->blockExists('calendarEventRegistrationClosed')) {
         if (!$registrationOpen) {
             $objTpl->touchBlock('calendarEventRegistrationClosed');
         } else {
             $objTpl->hideBlock('calendarEventRegistrationClosed');
         }
     }
     $objTpl->parse('calendarEventRegistration');
 }
Exemplo n.º 4
0
 /**
  * Updates the values for an existing network.
  *
  * @global  ADONewConnection
  * @global  array
  */
 function updateNetwork()
 {
     global $objDatabase, $_ARRAYLANG;
     $intNetworkId = intval($_POST['frmEditNetwork_Id']);
     $strName = contrexx_addslashes($_POST['frmEditNetwork_Name']);
     $strWWW = contrexx_addslashes($_POST['frmEditNetwork_WWW']);
     $strSubmitUrl = contrexx_addslashes($_POST['frmEditNetwork_SubmitUrl']);
     $strIcon = contrexx_addslashes($_POST['frmEditNetwork_Icon']);
     $arrLanguages = $_POST['frmAddNetwork_Languages'];
     if ($intNetworkId > 0 && !empty($strName) && !empty($strSubmitUrl)) {
         $objValidator = new \FWValidator();
         $strWWW = $objValidator->getUrl($strWWW);
         $strSubmitUrl = $objValidator->getUrl($strSubmitUrl);
         $objDatabase->Execute(' UPDATE  ' . DBPREFIX . 'module_blog_networks
                                 SET     name="' . $strName . '",
                                         url="' . $strWWW . '",
                                         url_link="' . $strSubmitUrl . '",
                                         icon="' . $strIcon . '"
                                 WHERE   network_id=' . $intNetworkId . '
                                 LIMIT   1
                             ');
         $objDatabase->Execute(' DELETE
                                 FROM ' . DBPREFIX . 'module_blog_networks_lang
                                 WHERE `network_id` = ' . $intNetworkId . '
                             ');
         if (is_array($arrLanguages) && count($arrLanguages) > 0) {
             foreach ($arrLanguages as $intLanguageId) {
                 $objDatabase->Execute(' INSERT
                                         INTO    ' . DBPREFIX . 'module_blog_networks_lang
                                         SET     network_id=' . $intNetworkId . ',
                                                 lang_id=' . $intLanguageId . '
                                     ');
             }
         }
         $this->_strOkMessage = $_ARRAYLANG['TXT_BLOG_NETWORKS_UPDATE_SUCCESSFULL'];
     } else {
         $this->_strErrMessage = $_ARRAYLANG['TXT_BLOG_NETWORKS_UPDATE_ERROR'];
     }
 }
Exemplo n.º 5
0
 /**
  * Update news
  *
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @param     integer   $newsid
  * @return    boolean   result
  */
 function update()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     if (!$this->hasCategories()) {
         return $this->manageCategories();
     }
     if (isset($_POST['newsId'])) {
         $objFWUser = \FWUser::getFWUserObject();
         $id = intval($_POST['newsId']);
         $userId = $objFWUser->objUser->getId();
         $changelog = mktime();
         $date = $this->dateFromInput($_POST['newsDate']);
         $redirect = !empty($_POST['newsRedirect']) && $_POST['newsTypeRadio'] == 'redirect' ? contrexx_strip_tags($_POST['newsRedirect']) : '';
         $source = \FWValidator::getUrl(contrexx_strip_tags($_POST['newsSource']));
         $url1 = \FWValidator::getUrl(contrexx_strip_tags($_POST['newsUrl1']));
         $url2 = \FWValidator::getUrl(contrexx_strip_tags($_POST['newsUrl2']));
         $newsPublisherName = !empty($_POST['newsPublisherName']) ? contrexx_input2raw($_POST['newsPublisherName']) : '';
         $newsAuthorName = !empty($_POST['newsAuthorName']) ? contrexx_input2raw($_POST['newsAuthorName']) : '';
         $newsPublisherId = !empty($_POST['newsPublisherId']) ? contrexx_input2raw($_POST['newsPublisherId']) : '0';
         $newsAuthorId = !empty($_POST['newsAuthorId']) ? contrexx_input2raw($_POST['newsAuthorId']) : '0';
         $newsCategories = !empty($_POST['newsCat']) ? contrexx_input2raw($_POST['newsCat']) : array();
         $typeId = !empty($_POST['newsType']) ? intval($_POST['newsType']) : 0;
         $newsScheduledActive = !empty($_POST['newsScheduled']) ? intval($_POST['newsScheduled']) : 0;
         $status = empty($_POST['status']) ? $status = 0 : intval($_POST['status']);
         $newsTeaserOnly = isset($_POST['newsUseOnlyTeaser']) ? intval($_POST['newsUseOnlyTeaser']) : 0;
         $newsTeaserShowLink = isset($_POST['newsTeaserShowLink']) ? intval($_POST['newsTeaserShowLink']) : 0;
         $newsTeaserImagePath = contrexx_addslashes($_POST['newsTeaserImagePath']);
         $newsTeaserImageThumbnailPath = contrexx_addslashes($_POST['newsTeaserImageThumbnailPath']);
         $newsTeaserFrames = '';
         $newsComments = !empty($_POST['allowComment']) ? intval($_POST['allowComment']) : 0;
         if (isset($_POST['newsTeaserFramesAsso']) && count($_POST['newsTeaserFramesAsso']) > 0) {
             foreach ($_POST['newsTeaserFramesAsso'] as $frameId) {
                 intval($frameId) > 0 ? $newsTeaserFrames .= ';' . intval($frameId) : false;
             }
         }
         $startDate = $this->dateFromInput($_POST['startDate']);
         $endDate = $this->dateFromInput($_POST['endDate']);
         $newsFrontendAccess = !empty($_POST['news_read_access']);
         $newsFrontendGroups = $newsFrontendAccess && isset($_POST['news_read_access_associated_groups']) && is_array($_POST['news_read_access_associated_groups']) ? array_map('intval', $_POST['news_read_access_associated_groups']) : array();
         $newsBackendAccess = !empty($_POST['news_modify_access']);
         $newsBackendGroups = $newsBackendAccess && isset($_POST['news_modify_access_associated_groups']) && is_array($_POST['news_modify_access_associated_groups']) ? array_map('intval', $_POST['news_modify_access_associated_groups']) : array();
         $objResult = $objDatabase->SelectLimit('SELECT `frontend_access_id`, `backend_access_id`, `userid` FROM `' . DBPREFIX . 'module_news` WHERE `id` = ' . $id, 1);
         if ($objResult && $objResult->RecordCount() == 1) {
             $newsFrontendAccessId = $objResult->fields['frontend_access_id'];
             $newsBackendAccessId = $objResult->fields['backend_access_id'];
             $newsUserId = $objResult->fields['userid'];
         } else {
             $newsFrontendAccessId = 0;
             $newsBackendAccessId = 0;
             $newsUserId = 0;
         }
         if ($this->arrSettings['news_message_protection'] == '1') {
             if ($newsBackendAccessId && !\Permission::hasAllAccess() && !\Permission::checkAccess($newsBackendAccessId, 'dynamic', true) && $newsUserId != $objFWUser->objUser->getId()) {
                 return false;
             }
             if ($newsFrontendAccess) {
                 if ($newsFrontendAccessId) {
                     $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $newsFrontendAccessId));
                     $arrFormerFrontendGroupIds = $objGroup ? $objGroup->getLoadedGroupIds() : array();
                     $arrNewGroups = array_diff($newsFrontendGroups, $arrFormerFrontendGroupIds);
                     $arrRemovedGroups = array_diff($arrFormerFrontendGroupIds, $newsFrontendGroups);
                     if ($this->arrSettings['news_message_protection_restricted'] == '1' && !\Permission::hasAllAccess()) {
                         $arrUserGroupIds = $objFWUser->objUser->getAssociatedGroupIds();
                         $arrUnknownNewGroups = array_diff($arrNewGroups, $arrUserGroupIds);
                         foreach ($arrUnknownNewGroups as $groupId) {
                             if (!in_array($groupId, $arrFormerFrontendGroupIds)) {
                                 unset($arrNewGroups[array_search($groupId, $arrNewGroups)]);
                             }
                         }
                         $arrUnknownRemovedGroups = array_diff($arrRemovedGroups, $arrUserGroupIds);
                         foreach ($arrUnknownRemovedGroups as $groupId) {
                             if (in_array($groupId, $arrFormerFrontendGroupIds)) {
                                 unset($arrRemovedGroups[array_search($groupId, $arrRemovedGroups)]);
                             }
                         }
                     }
                     if (count($arrRemovedGroups)) {
                         \Permission::removeAccess($newsFrontendAccessId, 'dynamic', $arrRemovedGroups);
                     }
                     if (count($arrNewGroups)) {
                         \Permission::setAccess($newsFrontendAccessId, 'dynamic', $arrNewGroups);
                     }
                 } else {
                     if ($this->arrSettings['news_message_protection_restricted'] == '1' && !\Permission::hasAllAccess()) {
                         $arrUserGroupIds = $objFWUser->objUser->getAssociatedGroupIds();
                         $newsFrontendGroups = array_intersect($newsFrontendGroups, $arrUserGroupIds);
                     }
                     $newsFrontendAccessId = \Permission::createNewDynamicAccessId();
                     if (count($newsFrontendGroups)) {
                         \Permission::setAccess($newsFrontendAccessId, 'dynamic', $newsFrontendGroups);
                     }
                 }
             } else {
                 if ($newsFrontendAccessId) {
                     \Permission::removeAccess($newsFrontendAccessId, 'dynamic');
                 }
                 $newsFrontendAccessId = 0;
             }
             if ($newsBackendAccess) {
                 if ($newsBackendAccessId) {
                     $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $newsBackendAccessId));
                     $arrFormerBackendGroupIds = $objGroup ? $objGroup->getLoadedGroupIds() : array();
                     $arrNewGroups = array_diff($newsBackendGroups, $arrFormerBackendGroupIds);
                     $arrRemovedGroups = array_diff($arrFormerBackendGroupIds, $newsBackendGroups);
                     if ($this->arrSettings['news_message_protection_restricted'] == '1' && !\Permission::hasAllAccess()) {
                         $arrUserGroupIds = $objFWUser->objUser->getAssociatedGroupIds();
                         $arrUnknownNewGroups = array_diff($arrNewGroups, $arrUserGroupIds);
                         foreach ($arrUnknownNewGroups as $groupId) {
                             if (!in_array($groupId, $arrFormerBackendGroupIds)) {
                                 unset($arrNewGroups[array_search($groupId, $arrNewGroups)]);
                             }
                         }
                         $arrUnknownRemovedGroups = array_diff($arrRemovedGroups, $arrUserGroupIds);
                         foreach ($arrUnknownRemovedGroups as $groupId) {
                             if (in_array($groupId, $arrFormerBackendGroupIds)) {
                                 unset($arrRemovedGroups[array_search($groupId, $arrRemovedGroups)]);
                             }
                         }
                     }
                     if (count($arrRemovedGroups)) {
                         \Permission::removeAccess($newsBackendAccessId, 'dynamic', $arrRemovedGroups);
                     }
                     if (count($arrNewGroups)) {
                         \Permission::setAccess($newsBackendAccessId, 'dynamic', $arrNewGroups);
                     }
                 } else {
                     if ($this->arrSettings['news_message_protection_restricted'] == '1' && !\Permission::hasAllAccess()) {
                         $arrUserGroupIds = $objFWUser->objUser->getAssociatedGroupIds();
                         $newsBackendGroups = array_intersect($newsBackendGroups, $arrUserGroupIds);
                     }
                     $newsBackendAccessId = \Permission::createNewDynamicAccessId();
                     if (count($newsBackendGroups)) {
                         \Permission::setAccess($newsBackendAccessId, 'dynamic', $newsBackendGroups);
                     }
                 }
             } else {
                 if ($newsBackendAccessId) {
                     \Permission::removeAccess($newsBackendAccessId, 'dynamic');
                 }
                 $newsBackendAccessId = 0;
             }
         }
         $objFWUser->objUser->getDynamicPermissionIds(true);
         // find out original user's id
         $orig_user_sql = "\n                SELECT userid\n                FROM " . DBPREFIX . "module_news\n                WHERE id = '{$id}'\n            ";
         $orig_user_rs = $objDatabase->Execute($orig_user_sql);
         if ($orig_user_rs == false) {
             \DBG::msg("We're in trouble! sql failure: {$orig_user_sql}");
         } else {
             $orig_userid = $orig_user_rs->fields['userid'];
         }
         $set_userid = $orig_userid ? $orig_userid : $userId;
         // $finishednewstext = $newstext.'<br>'.$_ARRAYLANG['TXT_LAST_EDIT'].': '.$date;
         $activeLanguages = isset($_POST['newsManagerLanguages']) ? $_POST['newsManagerLanguages'] : array();
         if (count(\FWLanguage::getActiveFrontendLanguages()) == 1) {
             $activeLanguages = \FWLanguage::getActiveFrontendLanguages();
         }
         $locales = array('active' => $activeLanguages, 'title' => $_POST['newsTitle'], 'text' => $_POST['news_text'], 'teaser_text' => isset($_POST['newsTeaserText']) ? $_POST['newsTeaserText'] : array());
         if (!$this->validateNews($locales, $newsCategories)) {
             return $this->edit();
         }
         // store locales
         $localesSaving = $this->storeLocales($id, $locales);
         $categoryManipulation = $this->manipulateCategories($newsCategories, $id);
         $relatedNews = !empty($_POST['relatedNews']) ? contrexx_input2raw($_POST['relatedNews']) : array();
         $enableRelatedNews = !empty($_POST['enableRelatedNews']) ? 1 : 0;
         $realtedNewsManipulation = $this->manipulateRelatedNews($relatedNews, $id);
         $newsTags = !empty($_POST['newsTags']) ? contrexx_input2raw($_POST['newsTags']) : array();
         $enableTags = !empty($_POST['enableTags']) ? intval($_POST['enableTags']) : 0;
         //Update Tags
         $tagManipulation = $this->manipulateTags($newsTags, $id);
         // Set start and end dates as NULL if newsScheduled checkbox is not checked
         if ($newsScheduledActive == 0) {
             $startDate = NULL;
             $endDate = NULL;
         }
         $objResult = $objDatabase->Execute("UPDATE  " . DBPREFIX . "module_news\n                                                SET     date='" . $date . "',\n                                                        redirect='" . $redirect . "',\n                                                        source='" . $source . "',\n                                                        url1='" . $url1 . "',\n                                                        url2='" . $url2 . "',\n                                                        publisher='" . contrexx_raw2db($newsPublisherName) . "',\n                                                        publisher_id=" . intval($newsPublisherId) . ",\n                                                        author='" . contrexx_raw2db($newsAuthorName) . "',\n                                                        author_id=" . intval($newsAuthorId) . ",\n                                                        typeid='" . $typeId . "',\n                                                        userid = '" . $set_userid . "',\n                                                        status = '" . $status . "',\n                                                        " . (isset($_POST['validate']) ? "validated='1'," : "") . "\n                                                        startdate = " . $this->dbFromDate($startDate) . ",\n                                                        enddate = " . $this->dbFromDate($endDate) . ",\n                                                        frontend_access_id = '" . $newsFrontendAccessId . "',\n                                                        backend_access_id = '" . $newsBackendAccessId . "',\n                                                        " . ($_CONFIG['newsTeasersStatus'] == '1' ? "teaser_only = '" . $newsTeaserOnly . "',\n                                                        teaser_frames = '" . $newsTeaserFrames . "'," : "") . "\n                                                        teaser_show_link = " . $newsTeaserShowLink . ",\n                                                        teaser_image_path = '" . $newsTeaserImagePath . "',\n                                                        teaser_image_thumbnail_path = '" . $newsTeaserImageThumbnailPath . "',\n                                                        changelog = '" . $changelog . "',\n                                                        allow_comments = '" . $newsComments . "',\n                                                        enable_related_news='" . $enableRelatedNews . "',\n                                                        enable_tags='" . $enableTags . "'\n                                                WHERE   id = '" . $id . "'");
         if ($objResult === false || $localesSaving === false || $categoryManipulation === false || $realtedNewsManipulation === false || $tagManipulation === false) {
             $this->strErrMessage = empty($this->errMsg) ? $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'] : implode('<br>', $this->errMsg);
         } else {
             $this->createRSS();
             $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL'];
         }
     }
     return $this->overview();
 }
Exemplo n.º 6
0
 /**
  * Insert a new comment for a message into database, if the function is activated. Furthermore, all input values are validated.
  * Sends also the notification mail to the administrator, if it is enabled in options.
  *
  * @global  ADONewConnection
  * @global  array
  * @global  array
  */
 function addComment()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     \Cx\Core\Csrf\Controller\Csrf::check_code();
     $this->initUserId();
     //Check for activated function
     if (!$this->_arrSettings['blog_comments_activated']) {
         $this->_strErrorMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_ACTIVATED'];
         return;
     }
     if ($this->hasUserJustCommented()) {
         $this->_strErrorMessage = str_replace('[SECONDS]', intval($this->_arrSettings['blog_comments_timeout']), $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_TIMEOUT']);
         return;
     }
     //Create validator-object
     $objValidator = new \FWValidator();
     //Get general-input
     $intMessageId = intval($_POST['frmAddComment_MessageId']);
     $strSubject = contrexx_addslashes(strip_tags($_POST['frmAddComment_Subject']));
     $strComment = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($_POST['frmAddComment_Comment']);
     //Get specified-input
     if ($this->_intCurrentUserId == 0) {
         $intUserId = 0;
         $strName = contrexx_addslashes(strip_tags($_POST['frmAddComment_Name']));
         $strEMail = contrexx_addslashes(strip_tags($_POST['frmAddComment_EMail']));
         $strWWW = contrexx_addslashes(strip_tags($objValidator->getUrl($_POST['frmAddComment_WWW'])));
     } else {
         $intUserId = $this->_intCurrentUserId;
         $strName = '';
         $strEMail = '';
         $strWWW = '';
     }
     //Get options
     $intIsActive = intval($this->_arrSettings['blog_comments_autoactivate']);
     $intIsNotification = intval($this->_arrSettings['blog_comments_notification']);
     //Validate general-input
     if ($intMessageId <= 0) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MID']);
     }
     if (empty($strSubject)) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_SUBJECT']);
     }
     if (empty($strComment)) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_COMMENT']);
     }
     //Validate specified-input
     if ($this->_intCurrentUserId == 0) {
         if (empty($strName)) {
             $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_NAME']);
         }
         if (!$objValidator->isEmail($strEMail)) {
             $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_EMAIL']);
         }
     }
     $captchaCheck = true;
     if (!\FWUser::getFWUserObject()->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
         $captchaCheck = false;
     }
     //Now check error-string
     if (empty($this->_strErrorMessage) && $captchaCheck) {
         //No errors, insert entry
         $objDatabase->Execute(' INSERT INTO ' . DBPREFIX . 'module_blog_comments
                                 SET     message_id = ' . $intMessageId . ',
                                         lang_id = ' . $this->_intLanguageId . ',
                                         is_active = "' . $intIsActive . '",
                                         time_created = ' . time() . ',
                                         ip_address = "' . $_SERVER['REMOTE_ADDR'] . '",
                                         user_id = ' . $intUserId . ',
                                         user_name = "' . $strName . '",
                                         user_mail = "' . $strEMail . '",
                                         user_www = "' . $strWWW . '",
                                         subject = "' . $strSubject . '",
                                         comment = "' . $strComment . '"
                             ');
         //Set a cookie with the current timestamp. Avoids flooding.
         setcookie('BlogCommentLast', time(), 0, ASCMS_PATH_OFFSET . '/');
         $this->_strStatusMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_SUCCESS'];
         $this->writeCommentRSS();
         if ($intIsNotification) {
             //Send notification to administrator
             if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                 $objMail = new \phpmailer();
                 if ($_CONFIG['coreSmtpServer'] > 0) {
                     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'];
                     }
                 }
                 if ($this->_intCurrentUserId > 0) {
                     $objFWUser = \FWUser::getFWUserObject();
                     $strName = htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET);
                 }
                 $strMailSubject = str_replace('[SUBJECT]', $strSubject, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_SUBJECT']);
                 $strMailBody = str_replace('[USERNAME]', $strName, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_BODY']);
                 $strMailBody = str_replace('[DOMAIN]', ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, $strMailBody);
                 $strMailBody = str_replace('[SUBJECT]', $strSubject, $strMailBody);
                 $strMailBody = str_replace('[COMMENT]', $strComment, $strMailBody);
                 $objMail->CharSet = CONTREXX_CHARSET;
                 $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
                 $objMail->AddAddress($_CONFIG['coreAdminEmail']);
                 $objMail->Subject = $strMailSubject;
                 $objMail->IsHTML(false);
                 $objMail->Body = $strMailBody;
                 $objMail->Send();
             }
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Stores a Manufacturer
  * @param   string    $name     The Manufacturer name
  * @param   string    $url      The Manufacturer URL
  * @param   integer   $id       The optional Manufacturer ID
  * @return  boolean             True on success, false otherwise
  * @static
  *
  */
 static function store($name, $url, $id = null)
 {
     global $objDatabase, $_ARRAYLANG;
     // Make sure that only a valid URL is stored
     if ($url != '') {
         $url = \FWValidator::getUrl($url);
         if (!\FWValidator::isUri($url)) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_MANUFACTURER_ERROR_URL_INVALID']);
         }
     }
     if (self::record_exists($id)) {
         return self::update($name, $url, $id);
     }
     return self::insert($name, $url);
 }