/** * Show all the runs and last runs detail * * @global array $_ARRAYLANG */ public function showCrawlerRuns() { global $_ARRAYLANG; //show the last runs details $lastRunResult = $this->crawlerRepository->getLatestRunDetails(); if ($lastRunResult) { $this->template->setVariable(array($this->moduleNameLang . '_LAST_RUN_STARTTIME' => \Cx\Core_Modules\LinkManager\Controller\DateTime::formattedDateAndTime($lastRunResult[0]->getStartTime()), $this->moduleNameLang . '_LAST_RUN_ENDTIME' => \Cx\Core_Modules\LinkManager\Controller\DateTime::formattedDateAndTime($lastRunResult[0]->getEndTime()), $this->moduleNameLang . '_LAST_RUN_DURATION' => \Cx\Core_Modules\LinkManager\Controller\DateTime::diffTime($lastRunResult[0]->getStartTime(), $lastRunResult[0]->getEndTime()), $this->moduleNameLang . '_LAST_RUN_TOTAL_LINKS' => $lastRunResult[0]->getTotalLinks(), $this->moduleNameLang . '_LAST_RUN_BROKEN_LINKS' => $lastRunResult[0]->getTotalBrokenLinks())); } else { if ($this->template->blockExists('showLastRun')) { $this->template->hideBlock('showLastRun'); } } //show Crawler Runs table //get parameters $pos = isset($_GET['pos']) ? $_GET['pos'] : 0; $langArray = \FWLanguage::getLanguageArray(); //set the settings value from DB \Cx\Core\Setting\Controller\Setting::init('LinkManager', 'config'); $pageLimit = \Cx\Core\Setting\Controller\Setting::getValue('entriesPerPage', 'LinkManager'); $parameter = './index.php?cmd=' . $this->moduleName; $this->template->setVariable('ENTRIES_PAGING', \Paging::get($parameter, $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_LINKS'], $this->crawlerRepository->crawlerEntryCount(), $pageLimit, true, $pos, 'pos')); $crawlers = $this->crawlerRepository->getCrawlerRunEntries($pos, $pageLimit); $i = 1; if ($crawlers && $crawlers->count() > 0) { foreach ($crawlers as $crawler) { $this->template->setVariable(array($this->moduleNameLang . '_CRAWLER_RUN_ID' => $crawler->getId(), $this->moduleNameLang . '_CRAWLER_RUN_LANGUAGE' => $langArray[$crawler->getLang()]['name'], $this->moduleNameLang . '_CRAWLER_RUN_STARTTIME' => \Cx\Core_Modules\LinkManager\Controller\DateTime::formattedDateAndTime($crawler->getStartTime()), $this->moduleNameLang . '_CRAWLER_RUN_ENDTIME' => \Cx\Core_Modules\LinkManager\Controller\DateTime::formattedDateAndTime($crawler->getEndTime()), $this->moduleNameLang . '_CRAWLER_RUN_DURATION' => \Cx\Core_Modules\LinkManager\Controller\DateTime::diffTime($crawler->getStartTime(), $crawler->getEndTime()), $this->moduleNameLang . '_CRAWLER_RUN_TOTAL_LINKS' => $crawler->getTotalLinks(), $this->moduleNameLang . '_CRAWLER_RUN_BROKEN_LINKS' => $crawler->getTotalBrokenLinks(), $this->moduleNameLang . '_CRAWLER_RUN_STATUS' => ucfirst($crawler->getRunStatus()), $this->moduleNameLang . '_CRAWLER_RUN_ROW' => 'row' . (++$i % 2 + 1))); $this->template->parse($this->moduleName . 'CrawlerRuns'); } $this->template->hideBlock($this->moduleName . 'NoCrawlerRunsFound'); } else { $this->template->touchBlock($this->moduleName . 'NoCrawlerRunsFound'); } }
/** * Sends an email with the contact details to the responsible persons * * This methode sends an email to all email addresses that are defined in the * option "Receiver address(es)" of the requested contact form. * @access private * @global array * @global array * @param array Details of the contact request * @see _getEmailAdressOfString(), phpmailer::From, phpmailer::FromName, phpmailer::AddReplyTo(), phpmailer::Subject, phpmailer::IsHTML(), phpmailer::Body, phpmailer::AddAddress(), phpmailer::Send(), phpmailer::ClearAddresses() */ private function sendMail($arrFormData) { global $_ARRAYLANG, $_CONFIG; $plaintextBody = ''; $replyAddress = ''; $firstname = ''; $lastname = ''; $senderName = ''; $isHtml = $arrFormData['htmlMail'] == 1 ? true : false; // stop send process in case no real data had been submitted if (!isset($arrFormData['data']) && !isset($arrFormData['uploadedFiles'])) { return false; } // check if we shall send the email as multipart (text/html) if ($isHtml) { // setup html mail template $objTemplate = new \Cx\Core\Html\Sigma('.'); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $objTemplate->setTemplate($arrFormData['mailTemplate']); $objTemplate->setVariable(array('DATE' => date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']), 'HOSTNAME' => contrexx_raw2xhtml($arrFormData['meta']['host']), 'IP_ADDRESS' => contrexx_raw2xhtml($arrFormData['meta']['ipaddress']), 'BROWSER_LANGUAGE' => contrexx_raw2xhtml($arrFormData['meta']['lang']), 'BROWSER_VERSION' => contrexx_raw2xhtml($arrFormData['meta']['browser']))); } // TODO: check if we have to excape $arrRecipients later in the code $arrRecipients = $this->getRecipients(intval($_GET['cmd'])); // calculate the longest field label. // this will be used to correctly align all user submitted data in the plaintext e-mail // TODO: check if the label of upload-fields are taken into account as well $maxlength = 0; foreach ($arrFormData['fields'] as $arrField) { $length = strlen($arrField['lang'][FRONTEND_LANG_ID]['name']); $maxlength = $maxlength < $length ? $length : $maxlength; } // try to fetch a user submitted e-mail address to which we will send a copy to if (!empty($arrFormData['fields'])) { foreach ($arrFormData['fields'] as $fieldId => $arrField) { // check if field validation is set to e-mail if ($arrField['check_type'] == '2') { $mail = trim($arrFormData['data'][$fieldId]); if (\FWValidator::isEmail($mail)) { $replyAddress = $mail; break; } } if ($arrField['type'] == 'special') { switch ($arrField['special_type']) { case 'access_firstname': $firstname = trim($arrFormData['data'][$fieldId]); break; case 'access_lastname': $lastname = trim($arrFormData['data'][$fieldId]); break; default: break; } } } } if ($arrFormData['useEmailOfSender'] == 1 && (!empty($firstname) || !empty($lastname))) { $senderName = trim($firstname . ' ' . $lastname); } else { $senderName = $_CONFIG['coreGlobalPageTitle']; } // a recipient mail address which has been picked by sender $chosenMailRecipient = null; // fill the html and plaintext body with the submitted form data foreach ($arrFormData['fields'] as $fieldId => $arrField) { if ($fieldId == 'unique_id') { //generated for uploader. no interesting mail content. continue; } $htmlValue = ''; $plaintextValue = ''; $textAreaKeys = array(); switch ($arrField['type']) { case 'label': case 'fieldset': // TODO: parse TH row instead // TODO: parse TH row instead case 'horizontalLine': // TODO: add visual horizontal line // we need to use a 'continue 2' here to first break out of the switch and then move over to the next iteration of the foreach loop continue 2; break; case 'file': case 'multi_file': $htmlValue = ""; $plaintextValue = ""; if (isset($arrFormData['uploadedFiles'][$fieldId])) { $htmlValue = "<ul>"; foreach ($arrFormData['uploadedFiles'][$fieldId] as $file) { $htmlValue .= "<li><a href='" . ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . contrexx_raw2xhtml($file['path']) . "' >" . contrexx_raw2xhtml($file['name']) . "</a></li>"; $plaintextValue .= ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . $file['path'] . "\r\n"; } $htmlValue .= "</ul>"; } break; case 'checkbox': $plaintextValue = !empty($arrFormData['data'][$fieldId]) ? $_ARRAYLANG['TXT_CONTACT_YES'] : $_ARRAYLANG['TXT_CONTACT_NO']; $htmlValue = $plaintextValue; break; case 'recipient': // TODO: check for XSS $plaintextValue = $arrRecipients[$arrFormData['data'][$fieldId]]['lang'][FRONTEND_LANG_ID]; $htmlValue = $plaintextValue; $chosenMailRecipient = $arrRecipients[$arrFormData['data'][$fieldId]]['email']; break; case 'textarea': //we need to know all textareas - they're indented differently then the rest of the other field types $textAreaKeys[] = $fieldId; default: $plaintextValue = isset($arrFormData['data'][$fieldId]) ? $arrFormData['data'][$fieldId] : ''; $htmlValue = contrexx_raw2xhtml($plaintextValue); break; } $fieldLabel = $arrField['lang'][FRONTEND_LANG_ID]['name']; // try to fetch an e-mail address from submitted form date in case we were unable to fetch one from an input type with e-mail validation if (empty($replyAddress)) { $mail = $this->_getEmailAdressOfString($plaintextValue); if (\FWValidator::isEmail($mail)) { $replyAddress = $mail; } } // parse html body if ($isHtml) { if (!empty($htmlValue)) { if ($objTemplate->blockExists('field_' . $fieldId)) { // parse field specific template block $objTemplate->setVariable(array('FIELD_' . $fieldId . '_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_' . $fieldId . '_VALUE' => $htmlValue)); $objTemplate->parse('field_' . $fieldId); } elseif ($objTemplate->blockExists('form_field')) { // parse regular field template block $objTemplate->setVariable(array('FIELD_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_VALUE' => $htmlValue)); $objTemplate->parse('form_field'); } } elseif ($objTemplate->blockExists('field_' . $fieldId)) { // hide field specific template block, if present $objTemplate->hideBlock('field_' . $fieldId); } } // parse plaintext body $tabCount = $maxlength - strlen($fieldLabel); $tabs = $tabCount == 0 ? 1 : $tabCount + 1; // TODO: what is this all about? - $value is undefined if ($arrFormData['fields'][$fieldId]['type'] == 'recipient') { $value = $arrRecipients[$value]['lang'][FRONTEND_LANG_ID]; } if (in_array($fieldId, $textAreaKeys)) { // we're dealing with a textarea, don't indent value $plaintextBody .= $fieldLabel . ":\n" . $plaintextValue . "\n"; } else { $plaintextBody .= $fieldLabel . str_repeat(" ", $tabs) . ": " . $plaintextValue . "\n"; } } $arrSettings = $this->getSettings(); // TODO: this is some fixed plaintext message data -> must be ported to html body $message = $_ARRAYLANG['TXT_CONTACT_TRANSFERED_DATA_FROM'] . " " . $_CONFIG['domainUrl'] . "\n\n"; if ($arrSettings['fieldMetaDate']) { $message .= $_ARRAYLANG['TXT_CONTACT_DATE'] . " " . date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']) . "\n\n"; } $message .= $plaintextBody . "\n\n"; if ($arrSettings['fieldMetaHost']) { $message .= $_ARRAYLANG['TXT_CONTACT_HOSTNAME'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['host']) . "\n"; } if ($arrSettings['fieldMetaIP']) { $message .= $_ARRAYLANG['TXT_CONTACT_IP_ADDRESS'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['ipaddress']) . "\n"; } if ($arrSettings['fieldMetaLang']) { $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_LANGUAGE'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['lang']) . "\n"; } $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_VERSION'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['browser']) . "\n"; if (@(include_once \Env::get('cx')->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) { $objMail = new \phpmailer(); if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once \Env::get('cx')->getCodeBaseCorePath() . '/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 = $senderName; if (!empty($replyAddress)) { $objMail->AddReplyTo($replyAddress); if ($arrFormData['sendCopy'] == 1) { $objMail->AddAddress($replyAddress); } if ($arrFormData['useEmailOfSender'] == 1) { $objMail->From = $replyAddress; } } $objMail->Subject = $arrFormData['subject']; if ($isHtml) { $objMail->Body = $objTemplate->get(); $objMail->AltBody = $message; } else { $objMail->IsHTML(false); $objMail->Body = $message; } // attach submitted files to email if (count($arrFormData['uploadedFiles']) > 0 && $arrFormData['sendAttachment'] == 1) { foreach ($arrFormData['uploadedFiles'] as $arrFilesOfField) { foreach ($arrFilesOfField as $file) { $objMail->AddAttachment(\Env::get('cx')->getWebsiteDocumentRootPath() . $file['path'], $file['name']); } } } if ($chosenMailRecipient !== null) { if (!empty($chosenMailRecipient)) { $objMail->AddAddress($chosenMailRecipient); $objMail->Send(); $objMail->ClearAddresses(); } } else { foreach ($arrFormData['emails'] as $sendTo) { if (!empty($sendTo)) { $objMail->AddAddress($sendTo); $objMail->Send(); $objMail->ClearAddresses(); } } } } return true; }
/** * send a mail to the email with the message * * @static * @param integer $uploadId the upload id * @param string $subject the subject of the mail for the recipient * @param string $email the recipient's mail address * @param null|string $message the message for the recipient */ public static function sendMail($uploadId, $subject, $emails, $message = null) { global $objDatabase, $_CONFIG; /** * get all file ids from the last upload */ $objResult = $objDatabase->Execute("SELECT `id` FROM " . DBPREFIX . "module_filesharing WHERE `upload_id` = '" . intval($uploadId) . "'"); if ($objResult !== false && $objResult->RecordCount() > 0) { while (!$objResult->EOF) { $files[] = $objResult->fields["id"]; $objResult->MoveNext(); } } if (!is_int($uploadId) && empty($files)) { $files[] = $uploadId; } /** * init mail data. Mail template, Mailsubject and PhpMailer */ $objMail = $objDatabase->SelectLimit("SELECT `subject`, `content` FROM " . DBPREFIX . "module_filesharing_mail_template WHERE `lang_id` = " . FRONTEND_LANG_ID, 1, -1); $content = str_replace(array(']]', '[['), array('}', '{'), $objMail->fields["content"]); if (empty($subject)) { $subject = $objMail->fields["subject"]; } $cx = \Cx\Core\Core\Controller\Cx::instanciate(); if (\Env::get('ClassLoader')->loadFile($cx->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) { $objMail = new \phpmailer(); /** * Load mail template and parse it */ $objTemplate = new \Cx\Core\Html\Sigma('.'); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $objTemplate->setTemplate($content); $objTemplate->setVariable(array("DOMAIN" => $_CONFIG["domainUrl"], 'MESSAGE' => $message)); if ($objTemplate->blockExists('filesharing_file')) { foreach ($files as $file) { $objTemplate->setVariable(array('FILE_DOWNLOAD' => self::getDownloadLink($file))); $objTemplate->parse('filesharing_file'); } } if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile($cx->getCodeBaseCorePath() . '/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->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']); $objMail->Subject = $subject; $objMail->Body = $objTemplate->get(); foreach ($emails as $email) { $objMail->AddAddress($email); $objMail->Send(); $objMail->ClearAddresses(); } } }
/** * Sets up the JavsScript cart * * Searches all $themesPages elements for the first occurrence of the * "shopJsCart" template block. * Generates the structure of the Javascript cart, puts it in the template, * and registers all required JS code. * Note that this is only ever called when the JS cart is enabled in the * extended settings! * @access public * @global array $_ARRAYLANG Language array * @global array $themesPages Theme template array * @return void * @static */ static function setJsCart() { global $_ARRAYLANG, $themesPages; if (!\Cx\Core\Setting\Controller\Setting::getValue('use_js_cart', 'Shop')) { return; } $objTemplate = new \Cx\Core\Html\Sigma('.'); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $match = null; $div_cart = $div_product = ''; foreach ($themesPages as $index => $content) { //\DBG::log("Shop::setJsCart(): Section $index"); $objTemplate->setTemplate($content, false, false); if (!$objTemplate->blockExists('shopJsCart')) { continue; } //\DBG::log("Shop::setJsCart(): In themespage $index: {$themesPages[$index]}"); $objTemplate->setCurrentBlock('shopJsCart'); // Set all language entries and replace formats $objTemplate->setGlobalVariable($_ARRAYLANG); if ($objTemplate->blockExists('shopJsCartProducts')) { $objTemplate->parse('shopJsCartProducts'); $div_product = $objTemplate->get('shopJsCartProducts'); //\DBG::log("Shop::setJsCart(): Got Product: $div_product"); $objTemplate->replaceBlock('shopJsCartProducts', '[[SHOP_JS_CART_PRODUCTS]]'); } $objTemplate->touchBlock('shopJsCart'); $objTemplate->parse('shopJsCart'); $div_cart = $objTemplate->get('shopJsCart'); //\DBG::log("Shop::setJsCart(): Got Cart: $div_cart"); if (preg_match('#^([\\n\\r]?[^<]*<.*id=["\']shopJsCart["\'][^>]*>)(([\\n\\r].*)*)(</[^>]*>[^<]*[\\n\\r]?)$#', $div_cart, $match)) { //\DBG::log("Shop::setJsCart(): Matched DIV {$match[1]}, content: {$match[2]}"); $themesPages[$index] = preg_replace('@(<!--\\s*BEGIN\\s+(shopJsCart)\\s*-->.*?<!--\\s*END\\s+\\2\\s*-->)@s', $match[1] . $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'] . $match[4], $content); /* // Template use won't work, because it kills the remaining <!-- blocks -->! $objTemplate->setTemplate($content, false, false); $objTemplate->replaceBlock('shopJsCart', $match[1]. $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING']. $match[4]); $themesPages[$index] = $objTemplate->get(); */ //\DBG::log("Shop::setJsCart(): Out themespage $index: {$themesPages[$index]}"); } // One instance only (mind that there's a unique id attribute) self::$use_js_cart = true; break; } if (!self::$use_js_cart) { return; } self::registerJavascriptCode(); \ContrexxJavascript::getInstance()->setVariable('TXT_SHOP_CART_IS_LOADING', $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'], 'shop/cart'); \ContrexxJavascript::getInstance()->setVariable('TXT_SHOP_COULD_NOT_LOAD_CART', $_ARRAYLANG['TXT_SHOP_COULD_NOT_LOAD_CART'], 'shop/cart'); \ContrexxJavascript::getInstance()->setVariable('TXT_EMPTY_SHOPPING_CART', $_ARRAYLANG['TXT_EMPTY_SHOPPING_CART'], 'shop/cart'); \ContrexxJavascript::getInstance()->setVariable("url", (string) \Cx\Core\Routing\URL::fromModuleAndCMd('Shop' . MODULE_INDEX, 'cart', FRONTEND_LANG_ID, array('remoteJs' => 'addProduct')), 'shop/cart'); \JS::registerJS(substr(\Cx\Core\Core\Controller\Cx::instanciate()->getModuleFolderName() . '/Shop/View/Script/cart.js', 1)); \JS::registerCode("cartTpl = '" . preg_replace(array('/\'/', '/[\\n\\r]/', '/\\//'), array('\\\'', '\\n', '\\/'), $div_cart) . "';\n" . "cartProductsTpl = '" . preg_replace(array('/\'/', '/[\\n\\r]/', '/\\//'), array('\\\'', '\\n', '\\/'), $div_product) . "';\n"); }
/** * Ensures that a valid template is available * * Die()s if the template given is invalid, and Form.html cannot be * loaded to replace it. * @param \Cx\Core\Html\Sigma $objTemplateLocal The template, * by reference */ static function verify_template(&$objTemplateLocal) { //"instanceof" considers subclasses of Sigma to be a Sigma, too! if (!$objTemplateLocal instanceof \Cx\Core\Html\Sigma) { $objTemplateLocal = new \Cx\Core\Html\Sigma(\Env::get('cx')->getCodeBaseDocumentRootPath() . '/core/Setting/View/Template/Generic'); } if (!$objTemplateLocal->blockExists('core_setting_row')) { $objTemplateLocal->setRoot(\Env::get('cx')->getCodeBaseDocumentRootPath() . '/core/Setting/View/Template/Generic'); //$objTemplateLocal->setCacheRoot('.'); if (!$objTemplateLocal->loadTemplateFile('Form.html')) { die("Failed to load template Form.html"); } //die(nl2br(contrexx_raw2xhtml(var_export($objTemplateLocal, true)))); } }
/** * Show the picture with the id $intPicId (with popup) * * @global ADONewConnection * @global array * @param integer $intPicId: The id of the picture which should be shown */ function showPicture($intPicId) { global $objDatabase, $_ARRAYLANG; $arrPictures = array(); $intPicId = intval($intPicId); // Never used // $intCatId = intval($_GET['cid']); // we need to read the category id out of the database to prevent abusement $intCatId = $this->getCategoryId($intPicId); $categoryProtected = $this->categoryIsProtected($intCatId); if ($categoryProtected > 0) { if (!\Permission::checkAccess($categoryProtected, 'dynamic', true)) { $link = base64_encode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']); \Cx\Core\Csrf\Controller\Csrf::header("Location: " . CONTREXX_DIRECTORY_INDEX . "?section=Login&cmd=noaccess&redirect=" . $link); exit; } } // POPUP Code $objTpl = new \Cx\Core\Html\Sigma(ASCMS_MODULE_PATH . '/Gallery/View/Template/Backend'); $objTpl->loadTemplateFile('module_gallery_show_picture.html', true, true); // get category description $objResult = $objDatabase->Execute("SELECT value FROM " . DBPREFIX . "module_gallery_language " . "WHERE gallery_id={$intCatId} AND lang_id={$this->langId} " . "AND name='desc' LIMIT 1"); $strCategoryComment = ''; if ($objResult && $objResult->RecordCount()) { $strCategoryComment = $objResult->fields['value']; } $objResult = $objDatabase->Execute("SELECT comment, voting " . "FROM " . DBPREFIX . "module_gallery_categories " . "WHERE id={$intCatId}"); $boolComment = ''; $boolVoting = ''; if ($objResult && $objResult->RecordCount()) { $boolComment = $objResult->fields['comment']; $boolVoting = $objResult->fields['voting']; } // get picture informations $objResult = $objDatabase->Execute("SELECT id, path, link, size_show " . "FROM " . DBPREFIX . "module_gallery_pictures " . "WHERE id={$intPicId}"); $objSubResult = $objDatabase->Execute("SELECT p.name, p.desc FROM " . DBPREFIX . "module_gallery_language_pics p " . "WHERE picture_id={$intPicId} AND lang_id={$this->langId} LIMIT 1"); while (!$objResult->EOF) { $imageReso = getimagesize($this->strImagePath . $objResult->fields['path']); $strImagePath = $this->strImageWebPath . $objResult->fields['path']; $imageName = $objSubResult->fields['name']; $imageDesc = $objSubResult->fields['desc']; //show image size based on the settings of "Show image size" $showImageSize = $this->arrSettings['show_image_size'] == 'on' && $objResult->fields['size_show']; $imageSize = $showImageSize ? round(filesize($this->strImagePath . $objResult->fields['path']) / 1024, 2) : ''; $strImageWebPath = ASCMS_PROTOCOL . '://' . $_SERVER['SERVER_NAME'] . CONTREXX_SCRIPT_PATH . '?section=Gallery' . $this->strCmd . '&cid=' . $intCatId . '&pId=' . $intPicId; $objResult->MoveNext(); } // get pictures of the current category $objResult = $objDatabase->Execute("SELECT id FROM " . DBPREFIX . "module_gallery_pictures " . "WHERE status='1' AND validated='1' AND catid={$intCatId} " . "ORDER BY sorting, id"); if ($objResult && $objResult->RecordCount()) { while (!$objResult->EOF) { array_push($arrPictures, $objResult->fields['id']); $objResult->MoveNext(); } } // get next picture id if (array_key_exists(array_search($intPicId, $arrPictures) + 1, $arrPictures)) { $intPicIdNext = $arrPictures[array_search($intPicId, $arrPictures) + 1]; } else { $intPicIdNext = $arrPictures[0]; } // get previous picture id if (array_key_exists(array_search($intPicId, $arrPictures) - 1, $arrPictures)) { $intPicIdPrevious = $arrPictures[array_search($intPicId, $arrPictures) - 1]; } else { $intPicIdPrevious = end($arrPictures); } $strImageTitle = substr(strrchr($strImagePath, '/'), 1); // chop the file extension if the settings tell us to do so if ($this->arrSettings['show_ext'] == 'off') { $strImageTitle = substr($strImageTitle, 0, strrpos($strImageTitle, '.')); } // set language variables $objTpl->setVariable(array('TXT_CLOSE_WINDOW' => $_ARRAYLANG['TXT_CLOSE_WINDOW'], 'TXT_ZOOM_OUT' => $_ARRAYLANG['TXT_ZOOM_OUT'], 'TXT_ZOOM_IN' => $_ARRAYLANG['TXT_ZOOM_IN'], 'TXT_CHANGE_BG_COLOR' => $_ARRAYLANG['TXT_CHANGE_BG_COLOR'], 'TXT_PRINT' => $_ARRAYLANG['TXT_PRINT'], 'TXT_PREVIOUS_IMAGE' => $_ARRAYLANG['TXT_PREVIOUS_IMAGE'], 'TXT_NEXT_IMAGE' => $_ARRAYLANG['TXT_NEXT_IMAGE'], 'TXT_USER_DEFINED' => $_ARRAYLANG['TXT_USER_DEFINED'])); $imageSize = $showImageSize ? $_ARRAYLANG['TXT_FILESIZE'] . ': ' . $imageSize . ' kB<br />' : ''; // set variables $objTpl->setVariable(array('CONTREXX_CHARSET' => CONTREXX_CHARSET, 'GALLERY_WINDOW_WIDTH' => $imageReso[0] < 420 ? 500 : $imageReso[0] + 80, 'GALLERY_WINDOW_HEIGHT' => $imageReso[1] + 120, 'GALLERY_PICTURE_ID' => $intPicId, 'GALLERY_CATEGORY_ID' => $intCatId, 'GALLERY_TITLE' => $strCategoryComment, 'IMAGE_THIS' => $strImagePath, 'IMAGE_PREVIOUS' => '?section=Gallery' . $this->strCmd . '&cid=' . $intCatId . '&pId=' . $intPicIdPrevious, 'IMAGE_NEXT' => '?section=Gallery' . $this->strCmd . '&cid=' . $intCatId . '&pId=' . $intPicIdNext, 'IMAGE_WIDTH' => $imageReso[0], 'IMAGE_HEIGHT' => $imageReso[1], 'IMAGE_LINK' => $strImageWebPath, 'IMAGE_NAME' => $strImageTitle, 'IMAGE_DESCRIPTION' => $_ARRAYLANG['TXT_IMAGE_NAME'] . ': ' . $imageName . '<br />' . $imageSize . $_ARRAYLANG['TXT_RESOLUTION'] . ': ' . $imageReso[0] . 'x' . $imageReso[1] . ' Pixel', 'IMAGE_DESC' => !empty($imageDesc) ? $imageDesc . '<br /><br />' : '')); $objTpl->setGlobalVariable('CONTREXX_DIRECTORY_INDEX', CONTREXX_DIRECTORY_INDEX); //voting if ($objTpl->blockExists('votingTab')) { if ($this->arrSettings['show_voting'] == 'on' && $boolVoting) { $objTpl->setVariable(array('TXT_VOTING_TITLE' => $_ARRAYLANG['TXT_VOTING_TITLE'], 'TXT_VOTING_STATS_ACTUAL' => $_ARRAYLANG['TXT_VOTING_STATS_ACTUAL'], 'TXT_VOTING_STATS_WITH' => $_ARRAYLANG['TXT_VOTING_STATS_WITH'], 'TXT_VOTING_STATS_VOTES' => $_ARRAYLANG['TXT_VOTING_STATS_VOTES'])); if (isset($_COOKIE["Gallery_Voting_{$intPicId}"])) { $objTpl->hideBlock('showVotingBar'); $objTpl->setVariable(array('TXT_VOTING_ALREADY_VOTED' => $_ARRAYLANG['TXT_VOTING_ALREADY_VOTED'], 'VOTING_ALREADY_VOTED_MARK' => intval($_COOKIE['Gallery_Voting_' . $intPicId]))); } else { $objTpl->setVariable(array('TXT_VOTING_ALREADY_VOTED' => '', 'VOTING_ALREADY_VOTED_MARK' => '')); for ($i = 1; $i <= 10; $i++) { $objTpl->setVariable(array('VOTING_BAR_SRC' => ASCMS_MODULE_WEB_PATH . '/Gallery/View/Media/voting/' . $i . '.gif', 'VOTING_BAR_ALT' => $_ARRAYLANG['TXT_VOTING_RATE'] . ': ' . $i, 'VOTING_BAR_MARK' => $i, 'VOTING_BAR_CID' => $intCatId, 'VOTING_BAR_PICID' => $intPicId)); $objTpl->parse('showVotingBar'); } } $objResult = $objDatabase->Execute("SELECT mark FROM " . DBPREFIX . "module_gallery_votes " . "WHERE picid={$intPicId}"); if ($objResult->RecordCount() > 0) { $intCount = 0; $intMark = 0; while (!$objResult->EOF) { $intCount++; $intMark = $intMark + intval($objResult->fields['mark']); $objResult->MoveNext(); } $objTpl->setVariable(array('VOTING_STATS_MARK' => number_format(round($intMark / $intCount, 1), 1, '.', '\''), 'VOTING_STATS_VOTES' => $intCount)); } else { $objTpl->setVariable(array('VOTING_STATS_MARK' => 0, 'VOTING_STATS_VOTES' => 0)); } } else { $objTpl->hideBlock('votingTab'); } } //comments if ($this->arrSettings['show_comments'] == 'on' && $boolComment) { $objResult = $objDatabase->Execute("SELECT date, name, email, www, comment FROM " . DBPREFIX . "module_gallery_comments " . "WHERE picid={$intPicId} ORDER BY date ASC"); $objTpl->setVariable(array('TXT_COMMENTS_TITLE' => $objResult->RecordCount() . ' ' . $_ARRAYLANG['TXT_COMMENTS_TITLE'], 'TXT_COMMENTS_ADD_TITLE' => $_ARRAYLANG['TXT_COMMENTS_ADD_TITLE'], 'TXT_COMMENTS_ADD_NAME' => $_ARRAYLANG['TXT_COMMENTS_ADD_NAME'], 'TXT_COMMENTS_ADD_EMAIL' => $_ARRAYLANG['TXT_COMMENTS_ADD_EMAIL'], 'TXT_COMMENTS_ADD_HOMEPAGE' => $_ARRAYLANG['TXT_COMMENTS_ADD_HOMEPAGE'], 'TXT_COMMENTS_ADD_TEXT' => $_ARRAYLANG['TXT_COMMENTS_ADD_TEXT'], 'TXT_COMMENTS_ADD_SUBMIT' => $_ARRAYLANG['TXT_COMMENTS_ADD_SUBMIT'])); if ($objResult->RecordCount() == 0) { // no comments, hide the block $objTpl->hideBlock('showComments'); } else { $i = 0; while (!$objResult->EOF) { if ($i % 2 == 0) { $intRowClass = '1'; } else { $intRowClass = '2'; } if ($objResult->fields['www'] != '') { $strWWW = '<a href="' . $objResult->fields['www'] . '"><img alt="' . $objResult->fields['www'] . '" src="' . ASCMS_MODULE_WEB_PATH . '/Gallery/View/Media/www.gif" align="baseline" border="0" /></a>'; } else { $strWWW = '<img src="' . ASCMS_MODULE_WEB_PATH . '/Gallery/View/Media/pixel.gif" width="16" height="16" alt="" align="baseline" border="0" />'; } if ($objResult->fields['email'] != '') { $strEmail = '<a href="mailto:' . $objResult->fields['email'] . '"><img alt="' . $objResult->fields['email'] . '" src="' . ASCMS_MODULE_WEB_PATH . '/Gallery/View/Media/email.gif" align="baseline" border="0" /></a>'; } else { $strEmail = '<img src="' . ASCMS_MODULE_WEB_PATH . '/Gallery/View/Media/pixel.gif" width="16" height="16" alt="" align="baseline" border="0" />'; } $objTpl->setVariable(array('COMMENTS_NAME' => html_entity_decode($objResult->fields['name']), 'COMMENTS_DATE' => date($_ARRAYLANG['TXT_COMMENTS_DATEFORMAT'], $objResult->fields['date']), 'COMMENTS_WWW' => $strWWW, 'COMMENTS_EMAIL' => $strEmail, 'COMMENTS_TEXT' => nl2br($objResult->fields['comment']), 'COMMENTS_ROWCLASS' => $intRowClass)); $objTpl->parse('showComments'); $objResult->MoveNext(); $i++; } } } else { $objTpl->hideBlock('commentTab'); } $objTpl->show(); die; }
/** * Parses all available ordering options into the blocks available * * Lower case $blockBase is the base for all template block names. * The UPPERCASE version of $blockBase is the name of the (only) * placeholder. * * Examples for $blockBase = 'shop_product_order': * * Standard sorting headers, alternating between ascending and descending. * Includes all available criteria. * The block name is shop_product_order, the placeholder SHOP_PRODUCT_ORDER. * * <div class="product_orders"> * <!-- BEGIN shop_product_order --> * <div class="product_order">{SHOP_PRODUCT_ORDER}</div> * <!-- END shop_product_order --> * </div> * * Custom sorting headers, fixed or alternating * Column and functionality are determined by the block name: * "shop_product_order_" + field name [ + "_" + optional fixed direction ] * Note that non-letter characters in the field name (index) are replaced * by underscores, e.g. an order field declaration of "`product`.`ord`" * is stripped of the backticks by getFieldIndex(), resulting in * "product.ord" stored in the field array, then substituted by * "product_ord" in this method. * * <div class="product_orders"> * <!-- BEGIN shop_product_order_product_ord --> * <div class="product_order">{SHOP_PRODUCT_ORDER}</div> * <!-- END shop_product_order_product_ord --> * <!-- BEGIN shop_product_order_name_asc --> * <div class="product_order">{SHOP_PRODUCT_ORDER}</div> * <!-- END shop_product_order_name_asc --> * <!-- BEGIN shop_product_order_name_desc --> * <div class="product_order">{SHOP_PRODUCT_ORDER}</div> * <!-- END shop_product_order_name_desc --> * <!-- BEGIN shop_product_order_bestseller_desc --> * <div class="product_order">{SHOP_PRODUCT_ORDER}</div> * <!-- END shop_product_order_bestseller_desc --> * </div> * * Note that invalid field names (not matching REGEX_ORDER_FIELD), * as well as empty string names (labels) are skipped. * @param Cx\Core\Html\Sigma $template The Template * @param string $blockBase The block base name */ public function parseHeaders(Cx\Core\Html\Sigma $template, $blockBase) { $blockBase = strtolower($blockBase); $placeholder = strtoupper($blockBase); foreach ($this->getHeaderArray() as $header) { if ($template->blockExists($blockBase)) { $template->setVariable($placeholder, $header); $template->parse($blockBase); } } foreach (array_keys($this->arrField) as $field) { $index = $this->getFieldindex($field); $block = $blockBase . '_' . preg_replace('/\\W/', '_', $index); if ($template->blockExists($block)) { //\DBG::log("Sorting index $index, block $block FOUND"); $template->setVariable($placeholder, $this->getHeaderForField($field)); $template->parse($block); } foreach (array('asc', 'desc') as $direction) { $block_directed = $block . '_' . $direction; //\DBG::log("Sorting index $index, block $block_directed"); if ($template->blockExists($block_directed)) { //\DBG::log("Sorting index $index, block $block_directed FOUND"); $template->setVariable($placeholder, $this->getHeaderForField($field, $direction)); $template->parse($block_directed); } } } }
/** * This should only be executed when updating from version 2.2.6 or older * Fix for the following tickets: * http://bugs.contrexx.com/contrexx/ticket/1412 * http://bugs.contrexx.com/contrexx/ticket/1043 * @see http://helpdesk.comvation.com/131276-Die-Navigation-meiner-Seite-wird-nicht-mehr-korrekt-angezeigt * * Adds placeholder {LEVELS_FULL} to all non-empty subnavbars * Adds placeholder {LEVELS_BRANCH} to all navbars having a block named 'navigation' but none 'level_1' */ function _updateNavigations() { global $objDatabase, $_CORELANG; $navbars = array('navbar', 'navbar2', 'navbar3'); $subnavbars = array('subnavbar', 'subnavbar2', 'subnavbar3'); // Find all themes $result = $objDatabase->Execute('SELECT `themesname`, `foldername` FROM `' . DBPREFIX . 'skins`'); if ($result->EOF) { \DBG::msg('No themes, really?'); return false; } // Update navigations for all themes $errorMessages = ''; while (!$result->EOF) { if (!is_dir(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'])) { \DBG::msg('Skipping theme "' . $result->fields['themesname'] . '"; No such folder!'); $errorMessages .= '<div class="message-warning">' . sprintf($_CORELANG['TXT_CSS_UPDATE_MISSING_FOLDER'], $result->fields['themesname']) . '</div>'; $result->moveNext(); continue; } \DBG::msg('Updating navigations for theme "' . $result->fields['themesname'] . '" (' . $type . ')'); // add {LEVELS_FULL} to all non-empty subnavbars foreach ($subnavbars as $subnavbar) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'] . '/' . $subnavbar . '.html'); $content = $objFile->getData(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } if (trim($content) == '') { continue; } $content = '{LEVELS_FULL}' . "\r\n" . $content; try { $objFile->write($content); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } \DBG::msg('Updated file ' . $subnavbar . '.html for theme ' . $result->fields['themesname']); } // add {LEVELS_BRANCH} to all navbars matching the following criterias: // 1. blockExists('navigation') // 2. !blockExists('level_1') foreach ($navbars as $navbar) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'] . '/' . $navbar . '.html'); $content = $objFile->getData(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } if (trim($content) == '') { continue; } $template = new \Cx\Core\Html\Sigma('.'); $template->setTemplate($content); if (!$template->blockExists('navigation')) { continue; } if ($template->blockExists('level_1')) { continue; } $content = '{LEVELS_BRANCH}' . "\r\n" . $content; try { $objFile->write($content); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } \DBG::msg('Updated file ' . $navbar . '.html for theme ' . $result->fields['themesname']); } $result->moveNext(); } if (!empty($errorMessages)) { setUpdateMsg($errorMessages, 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); $_SESSION['contrexx_update']['update']['done'][] = 'navigations'; return false; } return true; }