public function setSources(array $sources, array $sourceNames = null) { foreach ($sources as $langId => $source) { if ($this->type == 'url') { $source = \FWValidator::getUrl($source); if (preg_match('#^[a-z]+://([^/]+)#i', $source, $arrMatch)) { $this->source_names[$langId] = $arrMatch[1]; } else { $this->source_names[$langId] = $source; } $this->fileTypes[$langId] = \FWValidator::isUri($source) ? 'HTML' : null; } else { $this->fileTypes[$langId] = pathinfo($source, PATHINFO_EXTENSION); $this->source_names[$langId] = isset($sourceNames[$langId]) ? $sourceNames[$langId] : basename($source); } // set source of interface language if ($langId == LANG_ID) { $this->source = $source; $this->source_name = $this->source_names[$langId]; $this->fileType = $this->fileTypes[$langId]; } } $this->sources = $sources; }
/** * Save the cam's settings * */ function saveCam() { global $objDatabase; $id = intval($_POST['id']); if (!$id) { return false; } $currentImagePath = \Cx\Lib\FileSystem\FileSystem::sanitizePath(contrexx_input2raw($_POST['currentImagePath'])); if (!\FWValidator::isUri($currentImagePath) && strpos($currentImagePath, '/') !== 0) { $currentImagePath = '/' . $currentImagePath; } $maxImageWidth = intval($_POST['maxImageWidth']); $archivePath = \Cx\Lib\FileSystem\FileSystem::sanitizePath(contrexx_input2raw($_POST['archivePath'])); if (!\FWValidator::isUri($archivePath) && strpos($archivePath, '/') !== 0) { $archivePath = '/' . $archivePath; } $thumbnailPath = \Cx\Lib\FileSystem\FileSystem::sanitizePath(contrexx_input2raw($_POST['thumbnailPath'])); if (!\FWValidator::isUri($thumbnailPath) && strpos($thumbnailPath, '/') !== 0) { $thumbnailPath = '/' . $thumbnailPath; } $thumbMaxSize = intval($_POST['thumbMaxSize']); $shadowboxActivate = intval($_POST['shadowboxActivate']); $hourFrom = intval($_POST['hourFrom']); $hourTill = intval($_POST['hourTill']); $minuteFrom = intval($_POST['minuteFrom']); $minuteTill = intval($_POST['minuteTill']); $showFrom = mktime($hourFrom, $minuteFrom); $showTill = mktime($hourTill, $minuteTill); $query = " UPDATE " . DBPREFIX . "module_livecam\n SET currentImagePath = '" . contrexx_raw2db($currentImagePath) . "',\n maxImageWidth = " . $maxImageWidth . ",\n archivePath = '" . contrexx_raw2db($archivePath) . "',\n thumbnailPath = '" . contrexx_raw2db($thumbnailPath) . "',\n thumbMaxSize = " . $thumbMaxSize . ",\n shadowboxActivate = '" . $shadowboxActivate . "',\n showFrom = {$showFrom},\n showTill = {$showTill}\n WHERE id = " . $id; if ($objDatabase->Execute($query) === false) { // return a 500 or so header("HTTP/1.0 500 Internal Server Error"); die; } die; }
/** * Gets the news details * * @global array * @global ADONewConnection * @global array * @return string parsed content */ private function getDetails() { global $_CONFIG, $objDatabase, $_ARRAYLANG; $newsid = intval($_GET['newsid']); if (!$newsid) { header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('News')); exit; } $whereStatus = ''; $newsAccess = \Permission::checkAccess(10, 'static', true); $newsPreview = !empty($_GET['newsPreview']) ? intval($_GET['newsPreview']) : 0; $base64Redirect = base64_encode(\Env::get('cx')->getRequest()->getUrl()); if ($newsPreview && !$newsAccess) { \Permission::noAccess($base64Redirect); } else { if (!$newsAccess) { $whereStatus = 'news.status = 1 AND'; } } // TODO: add error handler to load the fallback-language version of the news message // in case the message doesn't exist in the requested language. But only try load the // the message in the fallback-language in case the associated news-detail content page // is setup to use the content of the fallback-language $objResult = $objDatabase->SelectLimit('SELECT news.id AS id, news.userid AS userid, news.redirect AS redirect, news.source AS source, news.changelog AS changelog, news.url1 AS url1, news.url2 AS url2, news.date AS date, news.publisher AS publisher, news.publisher_id AS publisherid, news.author AS author, news.author_id AS authorid, news.changelog AS changelog, news.teaser_image_path AS newsimage, news.enable_related_news AS enableRelatedNews, news.enable_tags AS enableTags, news.teaser_image_thumbnail_path AS newsThumbImg, news.typeid AS typeid, news.allow_comments AS commentactive, locale.text, locale.title AS title, locale.teaser_text FROM ' . DBPREFIX . 'module_news AS news INNER JOIN ' . DBPREFIX . 'module_news_locale AS locale ON news.id = locale.news_id WHERE ' . $whereStatus . ' news.id = ' . $newsid . ' AND locale.is_active=1 AND locale.lang_id =' . FRONTEND_LANG_ID . (!$newsPreview ? ' AND (news.startdate <= \'' . date('Y-m-d H:i:s') . '\' OR news.startdate="0000-00-00 00:00:00") AND (news.enddate >= \'' . date('Y-m-d H:i:s') . '\' OR news.enddate="0000-00-00 00:00:00")' : '') . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid = " . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : ''), 1); if (!$objResult || $objResult->EOF) { header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('News')); exit; } $newsCommentActive = $objResult->fields['commentactive']; $lastUpdate = $objResult->fields['changelog']; $text = $objResult->fields['text']; $redirect = contrexx_raw2xhtml($objResult->fields['redirect']); $sourceHref = contrexx_raw2xhtml($objResult->fields['source']); $url1Href = contrexx_raw2xhtml($objResult->fields['url1']); $url2Href = contrexx_raw2xhtml($objResult->fields['url2']); $source = contrexx_raw2xhtml($objResult->fields['source']); $url1 = contrexx_raw2xhtml($objResult->fields['url1']); $url2 = contrexx_raw2xhtml($objResult->fields['url2']); $newsUrl = ''; $newsSource = ''; $newsLastUpdate = ''; if (!empty($url1)) { $strUrl1 = contrexx_raw2xhtml($objResult->fields['url1']); if (strlen($strUrl1) > 40) { $strUrl1 = substr($strUrl1, 0, 26) . '...' . substr($strUrl1, strrpos($strUrl1, '.')); } $newsUrl = $_ARRAYLANG['TXT_IMPORTANT_HYPERLINKS'] . '<br /><a target="_blank" href="' . $url1Href . '" title="' . $url1 . '">' . $strUrl1 . '</a><br />'; } if (!empty($url2)) { $strUrl2 = contrexx_raw2xhtml($objResult->fields['url2']); if (strlen($strUrl2) > 40) { $strUrl2 = substr($strUrl2, 0, 26) . '...' . substr($strUrl2, strrpos($strUrl2, '.')); } $newsUrl .= '<a target="_blank" href="' . $url2Href . '" title="' . $url2 . '">' . $strUrl2 . '</a><br />'; } if (!empty($source)) { $strSource = contrexx_raw2xhtml($objResult->fields['source']); if (strlen($strSource) > 40) { $strSource = substr($strSource, 0, 26) . '...' . substr($strSource, strrpos($strSource, '.')); } $newsSource = $_ARRAYLANG['TXT_NEWS_SOURCE'] . '<br /><a target="_blank" href="' . $sourceHref . '" title="' . $source . '">' . $strSource . '</a><br />'; } if (!empty($lastUpdate)) { $newsLastUpdate = $_ARRAYLANG['TXT_LAST_UPDATE'] . '<br />' . date(ASCMS_DATE_FORMAT, $objResult->fields['changelog']); } $this->newsTitle = $objResult->fields['title']; $newstitle = $this->newsTitle; $newsTeaser = nl2br($objResult->fields['teaser_text']); \LinkGenerator::parseTemplate($newsTeaser); $objSubResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $newsid); //Get the Category list $newsCategories = $this->getCategoriesByNewsId($newsid); if (!empty($newsCategories) && $this->_objTpl->blockExists('news_category_list')) { foreach ($newsCategories as $catId => $catTitle) { $this->_objTpl->setVariable(array('NEWS_CATEGORY_TITLE' => contrexx_raw2xhtml($catTitle), 'NEWS_CATEGORY_ID' => contrexx_input2int($catId))); $this->_objTpl->parse('news_category'); } } $this->_objTpl->setVariable(array('NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => $newstitle, 'NEWS_TEASER_TEXT' => $newsTeaser, 'NEWS_LASTUPDATE' => $newsLastUpdate, 'NEWS_SOURCE' => $newsSource, 'NEWS_URL' => $newsUrl, 'NEWS_CATEGORY_NAME' => implode(', ', contrexx_raw2xhtml($newsCategories)), 'NEWS_COUNT_COMMENTS' => $newsCommentActive && $this->arrSettings['news_comments_activated'] ? contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']) : '')); if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) { if ($this->_objTpl->blockExists('news_comments_count')) { $this->_objTpl->hideBlock('news_comments_count'); } } if ($this->arrSettings['news_use_teaser_text'] != '1' && $this->_objTpl->blockExists('news_use_teaser_text')) { $this->_objTpl->hideBlock('news_use_teaser_text'); } // parse author self::parseUserAccountData($this->_objTpl, $objResult->fields['authorid'], $objResult->fields['author'], 'news_author'); // parse publisher self::parseUserAccountData($this->_objTpl, $objResult->fields['publisherid'], $objResult->fields['publisher'], 'news_publisher'); // show comments $this->parseMessageCommentForm($newsid, $newstitle, $newsCommentActive); $this->parseCommentsOfMessage($newsid, $newsCommentActive); // Show related_messages $this->parseRelatedMessagesOfMessage($newsid, 'category', array_keys($newsCategories)); $this->parseRelatedMessagesOfMessage($newsid, 'type', $objResult->fields['typeid']); $this->parseRelatedMessagesOfMessage($newsid, 'publisher', $objResult->fields['publisherid']); $this->parseRelatedMessagesOfMessage($newsid, 'author', $objResult->fields['authorid']); /* * save the teaser text. * purpose of this: @link news::getTeaser() */ $this->_teaser = contrexx_raw2xhtml($newsTeaser); if (!empty($this->arrSettings['news_use_tags']) && !empty($objResult->fields['enableTags'])) { $this->parseNewsTags($this->_objTpl, $newsid); } if (!empty($this->arrSettings['use_related_news']) && !empty($objResult->fields['enableRelatedNews'])) { $this->parseRelatedNews($this->_objTpl, $newsid, FRONTEND_LANG_ID, 'related_news', 3); } if (!empty($objResult->fields['newsimage'])) { $this->_objTpl->setVariable(array('NEWS_IMAGE' => '<img src="' . $objResult->fields['newsimage'] . '" alt="' . $newstitle . '" />', 'NEWS_IMAGE_SRC' => $objResult->fields['newsimage'], 'NEWS_IMAGE_ALT' => $newstitle)); if ($this->_objTpl->blockExists('news_image')) { $this->_objTpl->parse('news_image'); } } else { if ($this->_objTpl->blockExists('news_image')) { $this->_objTpl->hideBlock('news_image'); } } self::parseImageBlock($this->_objTpl, $objResult->fields['newsThumbImg'], $newstitle, $newsUrl, 'image_thumbnail'); self::parseImageBlock($this->_objTpl, $objResult->fields['newsimage'], $newstitle, $newsUrl, 'image_detail'); //previous next newslink if ($this->_objTpl->blockExists('previousNextLink')) { $this->parseNextAndPreviousLinks($this->_objTpl); } if (empty($redirect)) { $text = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $text); $newsTeaser = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $newsTeaser); \LinkGenerator::parseTemplate($text); $this->_objTpl->setVariable('NEWS_TEXT', $text); if ($this->_objTpl->blockExists('news_text')) { $this->_objTpl->parse('news_text'); } if ($this->_objTpl->blockExists('news_redirect')) { $this->_objTpl->hideBlock('news_redirect'); } } else { if (\FWValidator::isUri($redirect)) { $redirectName = preg_replace('#^https?://#', '', $redirect); //} elseif (\FWValidator::isEmail($redirect)) { //$redirectName } else { $redirectName = basename($redirect); } $this->_objTpl->setVariable(array('TXT_NEWS_REDIRECT_INSTRUCTION' => $_ARRAYLANG['TXT_NEWS_REDIRECT_INSTRUCTION'], 'NEWS_REDIRECT_URL' => $redirect, 'NEWS_REDIRECT_NAME' => $redirectName)); if ($this->_objTpl->blockExists('news_redirect')) { $this->_objTpl->parse('news_redirect'); } if ($this->_objTpl->blockExists('news_text')) { $this->_objTpl->hideBlock('news_text'); } } $this->countNewsMessageView($newsid); $objResult->MoveNext(); return $this->_objTpl->get(); }
/** * Does the resolving work, extends $this->url with targetPath and params. */ public function resolvePage($internal = false) { // Abort here in case we're handling a legacy request. // The legacy request will be handled by $this->legacyResolve(). // Important: We must check for $internal == FALSE here, to abort the resolving process // only when we're resolving the initial (original) request. // Internal resolving requests might be called by $this->legacyResolve() // and shall therefore be processed. if (!$internal && isset($_REQUEST['section'])) { throw new ResolverException('Legacy request'); } $path = $this->url->getSuggestedTargetPath(); if (!$this->page || $internal) { if ($this->pagePreview) { if (!empty($this->sessionPage) && !empty($this->sessionPage['pageId'])) { $this->getPreviewPage(); } } //(I) see what the model has for us $result = $this->pageRepo->getPagesAtPath($this->url->getLangDir() . '/' . $path, null, $this->lang, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_PAGES_ONLY); if (isset($result['page']) && $result['page'] && $this->pagePreview) { if (empty($this->sessionPage)) { if (\Permission::checkAccess(6, 'static', true)) { $result['page']->setActive(true); $result['page']->setDisplay(true); if ($result['page']->getEditingStatus() == 'hasDraft' || $result['page']->getEditingStatus() == 'hasDraftWaiting') { $logEntries = $this->logRepo->getLogEntries($result['page']); $this->logRepo->revert($result['page'], $logEntries[1]->getVersion()); } } } } //(II) sort out errors if (!$result) { throw new ResolverException('Unable to locate page (tried path ' . $path . ').'); } if (!$result['page']) { throw new ResolverException('Unable to locate page for this language. (tried path ' . $path . ').'); } if (!$result['page']->isActive()) { throw new ResolverException('Page found, but it is not active.'); } // if user has no rights to see this page, we redirect to login $this->checkPageFrontendProtection($result['page']); // If an older revision was requested, revert to that in-place: if (!empty($this->historyId) && \Permission::checkAccess(6, 'static', true)) { $this->logRepo->revert($result['page'], $this->historyId); } //(III) extend our url object with matched path / params $this->url->setTargetPath($result['matchedPath'] . $result['unmatchedPath']); $this->url->setParams($this->url->getSuggestedParams()); $this->page = $result['page']; } /* the page we found could be a redirection. in this case, the URL object is overwritten with the target details and resolving starts over again. */ $target = $this->page->getTarget(); $isRedirection = $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT; $isAlias = $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS; //handles alias redirections internal / disables external redirection $this->forceInternalRedirection = $this->forceInternalRedirection || $isAlias; if ($target && ($isRedirection || $isAlias)) { // Check if page is a internal redirection and if so handle it if ($this->page->isTargetInternal()) { //TODO: add check for endless/circular redirection (a -> b -> a -> b ... and more complex) $nId = $this->page->getTargetNodeId(); $lId = $this->page->getTargetLangId(); $module = $this->page->getTargetModule(); $cmd = $this->page->getTargetCmd(); $qs = $this->page->getTargetQueryString(); $langId = $lId ? $lId : $this->lang; // try to find the redirection target page if ($nId) { $targetPage = $this->pageRepo->findOneBy(array('node' => $nId, 'lang' => $langId)); // revert to default language if we could not retrieve the specified langauge by the redirection. // so lets try to load the redirection of the current language if (!$targetPage) { if ($langId != 0) { //make sure we weren't already retrieving the default language $targetPage = $this->pageRepo->findOneBy(array('node' => $nId, 'lang' => $this->lang)); $langId = $this->lang; } } } else { $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $cmd, $langId); // in case we were unable to find the requested page, this could mean that we are // trying to retrieve a module page that uses a string with an ID (STRING_ID) as CMD. // therefore, lets try to find the module by using the string in $cmd and INT in $langId as CMD. // in case $langId is really the requested CMD then we will have to set the // resolved language back to our original language $this->lang. if (!$targetPage) { $targetPage = $this->pageRepo->findOneBymoduleCmdLang($module, $cmd . '_' . $langId, $this->lang); if ($targetPage) { $langId = $this->lang; } } // try to retrieve a module page that uses only an ID as CMD. // lets try to find the module by using the INT in $langId as CMD. // in case $langId is really the requested CMD then we will have to set the // resolved language back to our original language $this->lang. if (!$targetPage) { $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $langId, $this->lang); $langId = $this->lang; } // revert to default language if we could not retrieve the specified langauge by the redirection. // so lets try to load the redirection of the current language if (!$targetPage) { if ($langId != 0) { //make sure we weren't already retrieving the default language $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $cmd, $this->lang); $langId = $this->lang; } } } //check whether we have a page now. if (!$targetPage) { $this->page = null; return; } // the redirection page is located within a different language. // therefore, we must set $this->lang to the target's language of the redirection. // this is required because we will next try to resolve the redirection target if ($langId != $this->lang) { $this->lang = $langId; $this->url->setLangDir(\FWLanguage::getLanguageCodeById($langId)); $this->pathOffset = ASCMS_INSTANCE_OFFSET; } $targetPath = substr($targetPage->getPath(), 1); $this->url->setTargetPath($targetPath . $qs); $this->url->setPath($targetPath . $qs); $this->isRedirection = true; $this->resolvePage(true); } else { //external target - redirect via HTTP 302 if (\FWValidator::isUri($target)) { header('Location: ' . $target); exit; } else { if ($target[0] == '/') { $target = substr($target, 1); } $langDir = ''; if (!file_exists(ASCMS_INSTANCE_PATH . ASCMS_INSTANCE_OFFSET . '/' . $target)) { $langCode = \FWLanguage::getLanguageCodeById($this->lang); if (!empty($langCode)) { $langDir = '/' . $langCode; } } header('Location: ' . ASCMS_INSTANCE_OFFSET . $langDir . '/' . $target); exit; } } } //if we followed one or more redirections, the user shall be redirected by 302. if ($this->isRedirection && !$this->forceInternalRedirection) { $params = $this->url->getSuggestedParams(); header('Location: ' . $this->page->getURL($this->pathOffset, $params)); exit; } // in case the requested page is of type fallback, we will now handle/load this page $this->handleFallbackContent($this->page, !$internal); // set legacy <section> and <cmd> in case the requested page is an application if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION || $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) { $this->command = $this->page->getCmd(); $this->section = $this->page->getModule(); } }
/** * Save an entry * * @global ADONewConnection * @global array * @return string $status */ function _store() { global $objDatabase, $_ARRAYLANG; $error = ''; if (!empty($_POST['forename']) and !empty($_POST['name'])) { $forename = contrexx_addslashes(strip_tags($_POST['forename'])); $name = contrexx_addslashes(strip_tags($_POST['name'])); $gender = contrexx_addslashes(strip_tags($_POST['malefemale'])); $mail = isset($_POST['email']) ? contrexx_addslashes($_POST['email']) : ''; $url = isset($_POST['url']) && strlen($_POST['url']) > 7 ? contrexx_addslashes(strip_tags($_POST['url'])) : ''; $comment = contrexx_addslashes(nl2br($this->addHyperlinking(strip_tags($_POST['comment'])))); $location = contrexx_addslashes(strip_tags($_POST['location'])); $ip = empty($_POST['ip']) ? $_SERVER['REMOTE_ADDR'] : contrexx_addslashes(strip_tags($_POST['ip'])); if (!empty($url)) { if (!\FWValidator::isUri($url)) { $error .= $_ARRAYLANG['TXT_INVALID_INTERNET_ADDRESS'] . "<br />"; } } if (!\FWValidator::isEmail($mail)) { $error .= $_ARRAYLANG['TXT_INVALID_EMAIL_ADDRESS'] . "<br />"; } if (empty($error)) { $query = "\n INSERT INTO " . DBPREFIX . "module_guestbook (\n forename, name, gender,\n url, datetime, email, comment,\n ip, location, lang_id\n ) VALUES (\n '{$forename}', '{$name}', '{$gender}',\n '{$url}', '" . date('Y-m-d H:i:s') . "', '{$mail}', '{$comment}',\n '{$ip}', '{$location}', '{$this->langId}'\n )"; $objDatabase->Execute($query); $this->strOkMessage = $_ARRAYLANG['TXT_GUESTBOOK_RECORD_STORED_SUCCESSFUL']; } else { $this->strErrMessage = $error; } } else { $this->strErrMessage = $_ARRAYLANG['TXT_FILL_OUT_ALL_REQUIRED_FIELDS']; } }
/** * Gets the icon for the file * * @param string $file The File Path * @param string $fileType (optional) The File type * * @return string The Icon name */ public static function _getIcon($file, $fileType = null) { $icon = ''; if (isset($fileType)) { $icon = strtoupper($fileType); } elseif (is_file($file)) { $info = pathinfo($file); $icon = strtoupper($info['extension']); } $arrImageExt = array('JPEG', 'JPG', 'TIFF', 'GIF', 'BMP', 'PNG'); $arrVideoExt = array('3GP', 'AVI', 'DAT', 'FLV', 'FLA', 'M4V', 'MOV', 'MPEG', 'MPG', 'OGG', 'WMV', 'SWF'); $arrAudioExt = array('WAV', 'WMA', 'AMR', 'MP3', 'AAC'); $arrPresentationExt = array('ODP', 'PPT', 'PPTX'); $arrSpreadsheetExt = array('CSV', 'ODS', 'XLS', 'XLSX'); $arrDocumentsExt = array('DOC', 'DOCX', 'ODT', 'RTF'); $arrWebDocumentExt = array('HTML', 'HTM'); switch (true) { case $icon == 'TXT': $icon = 'Text'; break; case $icon == 'PDF': $icon = 'Pdf'; break; case in_array($icon, $arrImageExt): $icon = 'Image'; break; case in_array($icon, $arrVideoExt): $icon = 'Video'; break; case in_array($icon, $arrAudioExt): $icon = 'Audio'; break; case in_array($icon, $arrPresentationExt): $icon = 'Presentation'; break; case in_array($icon, $arrSpreadsheetExt): $icon = 'Spreadsheet'; break; case in_array($icon, $arrDocumentsExt): $icon = 'TextDocument'; break; case in_array($icon, $arrWebDocumentExt): case \FWValidator::isUri($file): $icon = 'WebDocument'; break; default: $icon = 'Unknown'; break; } if (is_dir($file)) { $icon = 'Folder'; } if (!file_exists(self::_getIconPath() . $icon . '.png') or !isset($icon)) { $icon = '_blank'; } return $icon; }
function OpenTag($tag, $attr) { //! @return void // What this gets: < $tag $attr['WIDTH']="90px" > does not get content here </closeTag here> // check if the current tag is hidden and shall therefore be hidden if (!$this->isInHiddenTag) { $classAndTagBasedCSSProperties = array(); $inlineCSSProperties = array(); // get html-tag CSS definitions if (isset($this->CSS[strtolower($tag)])) { $classAndTagBasedCSSProperties = $this->CSS[strtolower($tag)]; } // get class CSS definitions if (!empty($attr['CLASS'])) { $assignedCssClasses = array_map('trim', explode(' ', $attr['CLASS'])); foreach ($assignedCssClasses as $assignedCssClass) { if (isset($this->CSS[$assignedCssClass])) { $classAndTagBasedCSSProperties = array_merge($classAndTagBasedCSSProperties, $this->CSS[$assignedCssClass]); } } } // get inline CSS definitions if (!empty($attr['STYLE'])) { $inlineCSSProperties = $this->readInlineCSS($attr['STYLE']); } $cssProperties = $this->mergeCSSProperties($classAndTagBasedCSSProperties, $inlineCSSProperties); // check if tag is hidden (through display:none) if (isset($cssProperties['DISPLAY']) && preg_match('/none/i', $cssProperties['DISPLAY'])) { $this->isInHiddenTag = true; $this->hiddenTagNestedDimensionPosition = 0; } } // don't draw hidden stuff if ($this->isInHiddenTag) { if ($this->isBlockTag($tag)) { $this->hiddenTagNestedDimensionPosition++; } return; } $align = array('left' => 'L', 'center' => 'C', 'right' => 'R', 'top' => 'T', 'middle' => 'M', 'bottom' => 'B', 'justify' => 'J'); $this->blockjustfinished = false; //Opening tag switch ($tag) { case 'PAGE_BREAK': //custom-tag //custom-tag case 'NEWPAGE': //custom-tag $this->blockjustfinished = true; $this->AddPage(); break; case 'OUTLINE': //custom-tag (CSS2 property - browsers don't support it yet - Jan2005) //Usage: (default: width=normal color=white) //<outline width="(thin|medium|thick)" color="(usualcolorformat)" >Text</outline> //Mix this tag with the <font color="(usualcolorformat)"> tag to get mixed colors on outlined text! $this->buffer_on = true; if (isset($attr['COLOR'])) { $this->outlineparam['COLOR'] = ConvertColor($attr['COLOR']); } else { $this->outlineparam['COLOR'] = array('R' => 255, 'G' => 255, 'B' => 255); } //white $this->outlineparam['OLDWIDTH'] = $this->LineWidth; if (isset($attr['WIDTH'])) { switch (strtoupper($attr['WIDTH'])) { case 'THIN': $this->outlineparam['WIDTH'] = 0.75 * $this->LineWidth; break; case 'MEDIUM': $this->outlineparam['WIDTH'] = $this->LineWidth; break; case 'THICK': $this->outlineparam['WIDTH'] = 1.75 * $this->LineWidth; break; } } else { $this->outlineparam['WIDTH'] = $this->LineWidth; } //width == oldwidth break; case 'BDO': if (isset($attr['DIR']) and strtoupper($attr['DIR']) == 'RTL') { $this->divrevert = true; } break; case 'S': case 'STRIKE': case 'DEL': $this->strike = true; break; case 'SUB': $this->SUB = true; break; case 'SUP': $this->SUP = true; break; case 'CENTER': $this->buffer_on = true; if ($this->tdbegin) { $this->cell[$this->row][$this->col]['a'] = $align['center']; } else { $this->divalign = $align['center']; if ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } } break; case 'ADDRESS': $this->buffer_on = true; $this->SetStyle('I', true); if (!$this->tdbegin and $this->x != $this->lMargin) { $this->Ln($this->lineheight); } break; case 'TABLE': // TABLE-BEGIN if ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } $this->tablestart = true; $this->table['nc'] = $this->table['nr'] = 0; if (isset($attr['REPEAT_HEADER']) and $attr['REPEAT_HEADER'] == true) { $this->UseTableHeader(true); } if (isset($attr['WIDTH'])) { $this->table['w'] = ConvertSize($attr['WIDTH'], $this->pgwidth); } if (isset($attr['HEIGHT'])) { $this->table['h'] = ConvertSize($attr['HEIGHT'], $this->pgwidth); } if (isset($attr['ALIGN'])) { $this->table['a'] = $align[strtolower($attr['ALIGN'])]; } if (isset($attr['BORDER'])) { $this->table['border'] = $attr['BORDER']; } if (isset($attr['BGCOLOR'])) { $this->table['bgcolor'][-1] = $attr['BGCOLOR']; } break; case 'TR': $this->row++; $this->table['nr']++; $this->col = -1; if (isset($attr['BGCOLOR'])) { $this->table['bgcolor'][$this->row] = $attr['BGCOLOR']; } break; case 'TH': $this->SetStyle('B', true); if (!isset($attr['ALIGN'])) { $attr['ALIGN'] = "center"; } case 'TD': $this->tdbegin = true; $this->col++; while (isset($this->cell[$this->row][$this->col])) { $this->col++; } //Update number column if ($this->table['nc'] < $this->col + 1) { $this->table['nc'] = $this->col + 1; } $this->cell[$this->row][$this->col] = array(); $this->cell[$this->row][$this->col]['text'] = array(); $this->cell[$this->row][$this->col]['s'] = 3; if (isset($attr['WIDTH'])) { $this->cell[$this->row][$this->col]['w'] = ConvertSize($attr['WIDTH'], $this->pgwidth); } if (isset($attr['HEIGHT'])) { $this->cell[$this->row][$this->col]['h'] = ConvertSize($attr['HEIGHT'], $this->pgwidth); } if (isset($attr['ALIGN'])) { $this->cell[$this->row][$this->col]['a'] = $align[strtolower($attr['ALIGN'])]; } if (isset($attr['VALIGN'])) { $this->cell[$this->row][$this->col]['va'] = $align[strtolower($attr['VALIGN'])]; } if (isset($attr['BORDER'])) { $this->cell[$this->row][$this->col]['border'] = $attr['BORDER']; } if (isset($attr['BGCOLOR'])) { $this->cell[$this->row][$this->col]['bgcolor'] = $attr['BGCOLOR']; } $cs = $rs = 1; if (isset($attr['COLSPAN']) && $attr['COLSPAN'] > 1) { $cs = $this->cell[$this->row][$this->col]['colspan'] = $attr['COLSPAN']; } if (isset($attr['ROWSPAN']) && $attr['ROWSPAN'] > 1) { $rs = $this->cell[$this->row][$this->col]['rowspan'] = $attr['ROWSPAN']; } //Chiem dung vi tri de danh cho cell span (¿mais hein?) for ($k = $this->row; $k < $this->row + $rs; $k++) { for ($l = $this->col; $l < $this->col + $cs; $l++) { if ($k - $this->row || $l - $this->col) { $this->cell[$k][$l] = 0; } } } if (isset($attr['NOWRAP'])) { $this->cell[$this->row][$this->col]['nowrap'] = 1; } break; case 'OL': if (!isset($attr['TYPE']) or $attr['TYPE'] == '') { $this->listtype = '1'; } else { $this->listtype = $attr['TYPE']; } // ol and ul types are mixed here // ol and ul types are mixed here case 'UL': if ((!isset($attr['TYPE']) or $attr['TYPE'] == '') and $tag == 'UL') { //Insert UL defaults if ($this->listlvl == 0) { $this->listtype = 'disc'; } elseif ($this->listlvl == 1) { $this->listtype = 'circle'; } else { $this->listtype = 'square'; } } elseif (isset($attr['TYPE']) and $tag == 'UL') { $this->listtype = $attr['TYPE']; } $this->buffer_on = false; if ($this->listlvl == 0) { //First of all, skip a line if (!$this->pjustfinished) { if ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } $this->Ln($this->lineheight); } $this->oldx = $this->x; $this->listlvl++; // first depth level $this->listnum = 0; // reset $this->listoccur[$this->listlvl] = 1; $this->listlist[$this->listlvl][1] = array('TYPE' => $this->listtype, 'MAXNUM' => $this->listnum); } else { if (!empty($this->textbuffer)) { $this->listitem[] = array($this->listlvl, $this->listnum, $this->textbuffer, $this->listoccur[$this->listlvl]); $this->listnum++; } $this->textbuffer = array(); $occur = $this->listoccur[$this->listlvl]; $this->listlist[$this->listlvl][$occur]['MAXNUM'] = $this->listnum; //save previous lvl's maxnum $this->listlvl++; $this->listnum = 0; // reset if ($this->listoccur[$this->listlvl] == 0) { $this->listoccur[$this->listlvl] = 1; } else { $this->listoccur[$this->listlvl]++; } $occur = $this->listoccur[$this->listlvl]; $this->listlist[$this->listlvl][$occur] = array('TYPE' => $this->listtype, 'MAXNUM' => $this->listnum); } break; case 'LI': //Observation: </LI> is ignored if ($this->listlvl == 0) { //First of all, skip a line if (!$this->pjustfinished and $this->x != $this->lMargin) { $this->Ln(2 * $this->lineheight); } $this->oldx = $this->x; $this->listlvl++; // first depth level $this->listnum = 0; // reset $this->listoccur[$this->listlvl] = 1; $this->listlist[$this->listlvl][1] = array('TYPE' => 'disc', 'MAXNUM' => $this->listnum); } if ($this->listnum == 0) { $this->buffer_on = true; //activate list 'bufferization' $this->listnum++; $this->textbuffer = array(); } else { $this->buffer_on = true; //activate list 'bufferization' if (!empty($this->textbuffer)) { $this->listitem[] = array($this->listlvl, $this->listnum, $this->textbuffer, $this->listoccur[$this->listlvl]); $this->listnum++; } $this->textbuffer = array(); } break; case 'H1': // 2 * fontsize // 2 * fontsize case 'H2': // 1.5 * fontsize // 1.5 * fontsize case 'H3': // 1.17 * fontsize // 1.17 * fontsize case 'H4': // 1 * fontsize // 1 * fontsize case 'H5': // 0.83 * fontsize // 0.83 * fontsize case 'H6': // 0.67 * fontsize //Values obtained from: http://www.w3.org/TR/REC-CSS2/sample.html if (isset($attr['ALIGN'])) { $this->divalign = $align[strtolower($attr['ALIGN'])]; } $this->buffer_on = true; if ($this->x != $this->lMargin) { $this->Ln(2 * $this->lineheight); } elseif (!$this->pjustfinished) { $this->Ln($this->lineheight); } $this->SetStyle('B', true); switch ($tag) { case 'H1': $this->SetFontSize(2 * $this->FontSizePt); $this->lineheight *= 2; break; case 'H2': $this->SetFontSize(1.5 * $this->FontSizePt); $this->lineheight *= 1.5; break; case 'H3': $this->SetFontSize(1.17 * $this->FontSizePt); $this->lineheight *= 1.17; break; case 'H4': $this->SetFontSize($this->FontSizePt); break; case 'H5': $this->SetFontSize(0.83 * $this->FontSizePt); $this->lineheight *= 0.83; break; case 'H6': $this->SetFontSize(0.67 * $this->FontSizePt); $this->lineheight *= 0.67; break; } break; case 'HR': //Default values: width=100% align=center color=gray //Skip a line, if needed if ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } $this->Ln(0.2 * $this->lineheight); $hrwidth = $this->pgwidth; $hralign = 'C'; $hrcolor = array('R' => 200, 'G' => 200, 'B' => 200); if ($attr['WIDTH'] != '') { $hrwidth = ConvertSize($attr['WIDTH'], $this->pgwidth); } if ($attr['ALIGN'] != '') { $hralign = $align[strtolower($attr['ALIGN'])]; } if ($attr['COLOR'] != '') { $hrcolor = ConvertColor($attr['COLOR']); } $this->SetDrawColor($hrcolor['R'], $hrcolor['G'], $hrcolor['B']); $x = $this->x; $y = $this->y; switch ($hralign) { case 'L': case 'J': break; case 'C': $empty = $this->pgwidth - $hrwidth; $empty /= 2; $x += $empty; break; case 'R': $empty = $this->pgwidth - $hrwidth; $x += $empty; break; } $oldlinewidth = $this->LineWidth; $this->SetLineWidth(0.3); $this->Line($x, $y, $x + $hrwidth, $y); $this->SetLineWidth($oldlinewidth); $this->Ln(0.2 * $this->lineheight); $this->SetDrawColor(0); $this->blockjustfinished = true; //Eliminate exceeding left-side spaces break; case 'INS': $this->SetStyle('U', true); break; case 'SMALL': $newsize = $this->FontSizePt - 1; $this->SetFontSize($newsize); break; case 'BIG': $newsize = $this->FontSizePt + 1; $this->SetFontSize($newsize); case 'STRONG': $this->SetStyle('B', true); break; case 'CITE': case 'EM': $this->SetStyle('I', true); break; case 'TITLE': $this->titulo = true; break; case 'B': case 'I': case 'U': if (isset($attr['CLASS']) or isset($attr['ID']) or isset($attr['STYLE'])) { $this->cssbegin = true; if (isset($attr['CLASS'])) { $properties = $this->CSS[$attr['CLASS']]; } elseif (isset($attr['ID'])) { $properties = $this->CSS[$attr['ID']]; } //Read Inline CSS if (isset($attr['STYLE'])) { $properties = $this->readInlineCSS($attr['STYLE']); } //Look for name in the $this->CSS array $this->backupcss = $properties; if (!empty($properties)) { $this->setCSS($properties); } //name found in the CSS array! } $this->SetStyle($tag, true); break; case 'A': if (isset($attr['NAME']) and $attr['NAME'] != '') { $this->textbuffer[] = array('', '', '', array(), '', false, false, $attr['NAME']); } //an internal link (adds a space for recognition) if (isset($attr['HREF'])) { $this->HREF = $attr['HREF']; } break; case 'DIV': //in case of malformed HTML code. Example:(...)</div><li>Content</li><div>DIV1</div>(...) if ($this->listlvl > 0) { $this->buffer_on = false; if (!empty($this->textbuffer)) { $this->listitem[] = array($this->listlvl, $this->listnum, $this->textbuffer, $this->listoccur[$this->listlvl]); } $this->textbuffer = array(); $this->listlvl--; $this->printlistbuffer(); $this->pjustfinished = true; //act as if a paragraph just ended } $this->divbegin = true; if ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } if (isset($attr['ALIGN']) and $attr['ALIGN'] != '') { $this->divalign = $align[strtolower($attr['ALIGN'])]; } if (isset($attr['CLASS']) or isset($attr['ID']) or isset($attr['STYLE'])) { $this->cssbegin = true; if (isset($attr['CLASS'])) { $properties = $this->CSS[$attr['CLASS']]; } elseif (isset($attr['ID'])) { $properties = $this->CSS[$attr['ID']]; } //Read Inline CSS if (isset($attr['STYLE'])) { $properties = $this->readInlineCSS($attr['STYLE']); } //Look for name in the $this->CSS array if (!empty($properties)) { $this->setCSS($properties); } //name found in the CSS array! } break; case 'IMG': if (!empty($this->textbuffer) and !$this->tablestart) { //Output previously buffered content and output image below //Set some default values $olddivwidth = $this->divwidth; $olddivheight = $this->divheight; if ($this->divwidth == 0) { $this->divwidth = $this->pgwidth - $this->x + $this->lMargin; } if ($this->divheight == 0) { $this->divheight = $this->lineheight; } //Print content $this->printbuffer($this->textbuffer, true); $this->textbuffer = array(); //Reset values $this->divwidth = $olddivwidth; $this->divheight = $olddivheight; $this->textbuffer = array(); $this->Ln($this->lineheight); } if (isset($attr['SRC'])) { $srcpath = html_entity_decode($attr['SRC'], ENT_QUOTES, CONTREXX_CHARSET); if (!FWValidator::isUri($srcpath)) { // Set absolute path of image source /*if (strpos($srcpath, ASCMS_DOCUMENT_ROOT) === 0) { // probably impossible that the $srcpath would contain ASCMS_DOCUMENT_ROOT, therefore we can ignore this case } else*/ if (ASCMS_PATH_OFFSET && strpos($srcpath, ASCMS_PATH_OFFSET) === 0) { $srcpath = ASCMS_PATH . $srcpath; } elseif (strpos($srcpath, '/') === 0) { $srcpath = ASCMS_DOCUMENT_ROOT . $srcpath; } else { $srcpath = ASCMS_DOCUMENT_ROOT . '/' . $srcpath; } } if (isset($attr['STYLE'])) { $inlineCSSProperties = $this->readInlineCSS($attr['STYLE']); if (isset($inlineCSSProperties['WIDTH'])) { //$attr['WIDTH'] = ConvertSize($inlineCSSProperties['WIDTH'],$this->pgwidth); $attr['WIDTH'] = intval($inlineCSSProperties['WIDTH']); } if (isset($inlineCSSProperties['HEIGHT'])) { //$attr['HEIGHT'] = ConvertSize($inlineCSSProperties['HEIGHT'],$this->pgwidth); $attr['HEIGHT'] = intval($inlineCSSProperties['HEIGHT']); } } if (!isset($attr['WIDTH'])) { $attr['WIDTH'] = 0; } else { $attr['WIDTH'] = ConvertSize($attr['WIDTH'], $this->pgwidth); } //$attr['WIDTH'] /= 4; if (!isset($attr['HEIGHT'])) { $attr['HEIGHT'] = 0; } else { $attr['HEIGHT'] = ConvertSize($attr['HEIGHT'], $this->pgwidth); } //$attr['HEIGHT'] /= 4; if ($this->tdbegin) { // WITHIN TD (TABLE) //DBG::msg("IMG within (TABLE/TD)"); $bak_x = $this->x; $bak_y = $this->y; //Check whether image exists locally or on the URL if (!FWValidator::isUri($srcpath) && !fopen($srcpath, 'rb')) { if (!$this->shownoimg) { break; } $srcpath = $this->noimgsrc; } $sizesarray = $this->Image($srcpath, $this->GetX(), $this->GetY(), $attr['WIDTH'], $attr['HEIGHT'], '', '', false); $this->y = $bak_y; $this->x = $bak_x; } elseif ($this->pbegin or $this->divbegin) { // WITHIN DIV or P //DBG::msg("IMG within DIV|P"); //In order to support <div align='center'><img ...></div> $ypos = 0; $bak_x = $this->x; $bak_y = $this->y; //Check whether image exists locally or on the URL if (!FWValidator::isUri($srcpath) && !fopen($srcpath, 'rb')) { if (!$this->shownoimg) { break; } $srcpath = $this->noimgsrc; } $sizesarray = $this->Image($srcpath, $this->GetX(), $this->GetY(), $attr['WIDTH'], $attr['HEIGHT'], '', '', false); $this->y = $bak_y; $this->x = $bak_x; $xpos = ''; switch ($this->divalign) { case "C": $spacesize = $this->CurrentFont['cw'][' '] * ($this->FontSizePt / 1000); $empty = ($this->pgwidth - $sizesarray['WIDTH']) / 2; $xpos = 'xpos=' . $empty . ','; break; case "R": $spacesize = $this->CurrentFont['cw'][' '] * ($this->FontSizePt / 1000); $empty = $this->pgwidth - $sizesarray['WIDTH']; $xpos = 'xpos=' . $empty . ','; break; default: break; } $numberoflines = (int) ceil($sizesarray['HEIGHT'] / $this->lineheight); $ypos = $numberoflines * $this->lineheight; $this->textbuffer[] = array("»¤¬" . "type=image,ypos={$ypos},{$xpos}width=" . $sizesarray['WIDTH'] . ",height=" . $sizesarray['HEIGHT'] . "»¤¬" . $sizesarray['OUTPUT']); while ($numberoflines) { $this->textbuffer[] = array("\n", $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); $numberoflines--; } } else { // WITHIN EVERYTHING ELSE //DBG::msg("IMG (standalone)"); $imgborder = 0; if (isset($attr['BORDER'])) { $imgborder = ConvertSize($attr['BORDER'], $this->pgwidth); } //Check whether image exists locally or on the URL if (!FWValidator::isUri($srcpath) && !fopen($srcpath, 'rb')) { if (!$this->shownoimg) { break; } $srcpath = $this->noimgsrc; } $sizesarray = $this->Image($srcpath, $this->GetX(), $this->GetY(), $attr['WIDTH'], $attr['HEIGHT'], '', $this->HREF); //Output Image $ini_x = $sizesarray['X']; $ini_y = $sizesarray['Y']; if ($imgborder) { $oldlinewidth = $this->LineWidth; $this->SetLineWidth($imgborder); $this->Rect($ini_x, $ini_y, $sizesarray['WIDTH'], $sizesarray['HEIGHT']); $this->SetLineWidth($oldlinewidth); } } if ($sizesarray['X'] < $this->x) { $this->x = $this->lMargin; } if ($this->tablestart) { $this->cell[$this->row][$this->col]['textbuffer'][] = array("»¤¬" . "type=image,width=" . $sizesarray['WIDTH'] . ",height=" . $sizesarray['HEIGHT'] . "»¤¬" . $sizesarray['OUTPUT']); $this->cell[$this->row][$this->col]['s'] += $sizesarray['WIDTH'] + 1; // +1 == margin $this->cell[$this->row][$this->col]['form'] = true; // in order to make some width adjustments later if (!isset($this->cell[$this->row][$this->col]['w'])) { $this->cell[$this->row][$this->col]['w'] = $sizesarray['WIDTH'] + 3; } if (!isset($this->cell[$this->row][$this->col]['h'])) { $this->cell[$this->row][$this->col]['h'] = $sizesarray['HEIGHT'] + 3; } } } break; case 'BLOCKQUOTE': case 'BR': if ($this->tablestart) { $this->cell[$this->row][$this->col]['textbuffer'][] = array("\n", $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); $this->cell[$this->row][$this->col]['text'][] = "\n"; if (!isset($this->cell[$this->row][$this->col]['maxs'])) { $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'] + 2; } elseif ($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) { $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'] + 2; } //+2 == margin $this->cell[$this->row][$this->col]['s'] = 0; // reset } elseif ($this->divbegin or $this->pbegin or $this->buffer_on) { $this->textbuffer[] = array("\n", $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); } else { $this->Ln($this->lineheight); $this->blockjustfinished = true; } break; case 'P': //in case of malformed HTML code. Example:(...)</p><li>Content</li><p>Paragraph1</p>(...) if ($this->listlvl > 0) { $this->buffer_on = false; if (!empty($this->textbuffer)) { $this->listitem[] = array($this->listlvl, $this->listnum, $this->textbuffer, $this->listoccur[$this->listlvl]); } $this->textbuffer = array(); $this->listlvl--; $this->printlistbuffer(); $this->pjustfinished = true; //act as if a paragraph just ended } if ($this->tablestart) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); $this->cell[$this->row][$this->col]['text'][] = "\n"; break; } $this->pbegin = true; if ($this->x != $this->lMargin) { $this->Ln(2 * $this->lineheight); } elseif (!$this->pjustfinished) { $this->Ln($this->lineheight); } //Save x,y coords in case we need to print borders... $this->oldx = $this->x; $this->oldy = $this->y; if (isset($attr['ALIGN'])) { $this->divalign = $align[strtolower($attr['ALIGN'])]; } if (isset($attr['CLASS']) or isset($attr['ID']) or isset($attr['STYLE'])) { $this->cssbegin = true; if (isset($attr['CLASS'])) { $properties = $this->CSS[$attr['CLASS']]; } elseif (isset($attr['ID'])) { $properties = $this->CSS[$attr['ID']]; } //Read Inline CSS if (isset($attr['STYLE'])) { $properties = $this->readInlineCSS($attr['STYLE']); } //Look for name in the $this->CSS array $this->backupcss = $properties; if (!empty($properties)) { $this->setCSS($properties); } //name(id/class/style) found in the CSS array! } break; case 'SPAN': $this->buffer_on = true; //Save x,y coords in case we need to print borders... $this->oldx = $this->x; $this->oldy = $this->y; if (isset($attr['CLASS']) or isset($attr['ID']) or isset($attr['STYLE'])) { $this->cssbegin = true; if (isset($attr['CLASS'])) { $properties = $this->CSS[$attr['CLASS']]; } elseif (isset($attr['ID'])) { $properties = $this->CSS[$attr['ID']]; } //Read Inline CSS if (isset($attr['STYLE'])) { $properties = $this->readInlineCSS($attr['STYLE']); } //Look for name in the $this->CSS array $this->backupcss = $properties; if (!empty($properties)) { $this->setCSS($properties); } //name found in the CSS array! } break; case 'PRE': if ($this->tablestart) { $this->cell[$this->row][$this->col]['textbuffer'][] = array("\n", $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); $this->cell[$this->row][$this->col]['text'][] = "\n"; } elseif ($this->divbegin or $this->pbegin or $this->buffer_on) { $this->textbuffer[] = array("\n", $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); } else { if ($this->x != $this->lMargin) { $this->Ln(2 * $this->lineheight); } elseif (!$this->pjustfinished) { $this->Ln($this->lineheight); } $this->buffer_on = true; //Save x,y coords in case we need to print borders... $this->oldx = $this->x; $this->oldy = $this->y; if (isset($attr['ALIGN'])) { $this->divalign = $align[strtolower($attr['ALIGN'])]; } if (isset($attr['CLASS']) or isset($attr['ID']) or isset($attr['STYLE'])) { $this->cssbegin = true; if (isset($attr['CLASS'])) { $properties = $this->CSS[$attr['CLASS']]; } elseif (isset($attr['ID'])) { $properties = $this->CSS[$attr['ID']]; } //Read Inline CSS if (isset($attr['STYLE'])) { $properties = $this->readInlineCSS($attr['STYLE']); } //Look for name in the $this->CSS array $this->backupcss = $properties; if (!empty($properties)) { $this->setCSS($properties); } //name(id/class/style) found in the CSS array! } } case 'TT': case 'KBD': case 'SAMP': case 'CODE': $this->SetFont('courier'); $this->currentfont = 'courier'; break; case 'TEXTAREA': $this->buffer_on = true; $colsize = 20; //HTML default value $rowsize = 2; //HTML default value if (isset($attr['COLS'])) { $colsize = $attr['COLS']; } if (isset($attr['ROWS'])) { $rowsize = $attr['ROWS']; } if (!$this->tablestart) { if ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } $this->col = $colsize; $this->row = $rowsize; } else { $this->specialcontent = "type=textarea,lines={$rowsize},width=" . (2.2 * $colsize + 3); //Activate form info in order to paint FORM elements within table $this->cell[$this->row][$this->col]['s'] += 2.2 * $colsize + 6; // +6 == margin if (!isset($this->cell[$this->row][$this->col]['h'])) { $this->cell[$this->row][$this->col]['h'] = 1.1 * $this->lineheight * $rowsize + 2.5; } } break; case 'SELECT': $this->specialcontent = "type=select"; //Activate form info in order to paint FORM elements within table break; case 'OPTION': $this->selectoption['ACTIVE'] = true; if (empty($this->selectoption)) { $this->selectoption['MAXWIDTH'] = ''; $this->selectoption['SELECTED'] = ''; } if (isset($attr['SELECTED'])) { $this->selectoption['SELECTED'] = ''; } break; case 'FORM': if ($this->tablestart) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray); $this->cell[$this->row][$this->col]['text'][] = "\n"; } elseif ($this->x != $this->lMargin) { $this->Ln($this->lineheight); } //Skip a line, if needed break; case 'INPUT': if (!isset($attr['TYPE'])) { $attr['TYPE'] == ''; } //in order to allow default 'TEXT' form (in case of malformed HTML code) if (!$this->tablestart) { switch (strtoupper($attr['TYPE'])) { case 'CHECKBOX': //Draw Checkbox $checked = false; if (isset($attr['CHECKED'])) { $checked = true; } $this->SetFillColor(235, 235, 235); $this->x += 3; $this->Rect($this->x, $this->y + 1, 3, 3, 'DF'); if ($checked) { $this->Line($this->x, $this->y + 1, $this->x + 3, $this->y + 1 + 3); $this->Line($this->x, $this->y + 1 + 3, $this->x + 3, $this->y + 1); } $this->SetFillColor(255); $this->x += 3.5; break; case 'RADIO': //Draw Radio button $checked = false; if (isset($attr['CHECKED'])) { $checked = true; } $this->x += 4; $this->Circle($this->x, $this->y + 2.2, 1, 'D'); $this->_out('0.000 g'); if ($checked) { $this->Circle($this->x, $this->y + 2.2, 0.4, 'DF'); } $this->Write(5, $texto, $this->x); $this->x += 2; break; case 'BUTTON': // Draw a button // Draw a button case 'SUBMIT': case 'RESET': $texto = ''; if (isset($attr['VALUE'])) { $texto = $attr['VALUE']; } $nihil = 2.5; $this->x += 2; $this->SetFillColor(190, 190, 190); $this->Rect($this->x, $this->y, $this->GetStringWidth($texto) + 2 * $nihil, 4.5, 'DF'); // 4.5 in order to avoid overlapping $this->x += $nihil; $this->Write(5, $texto, $this->x); $this->x += $nihil; $this->SetFillColor(255); break; case 'PASSWORD': if (isset($attr['VALUE'])) { $num_stars = strlen($attr['VALUE']); $attr['VALUE'] = str_repeat('*', $num_stars); } case 'TEXT': //Draw TextField //Draw TextField default: //default == TEXT $texto = ''; if (isset($attr['VALUE'])) { $texto = $attr['VALUE']; } $tamanho = 20; if (isset($attr['SIZE']) and ctype_digit($attr['SIZE'])) { $tamanho = $attr['SIZE']; } $this->SetFillColor(235, 235, 235); $this->x += 2; $this->Rect($this->x, $this->y, 2 * $tamanho, 4.5, 'DF'); // 4.5 in order to avoid overlapping if ($texto != '') { $this->x += 1; $this->Write(5, $texto, $this->x); $this->x -= $this->GetStringWidth($texto); } $this->SetFillColor(255); $this->x += 2 * $tamanho; break; } } else { $this->cell[$this->row][$this->col]['form'] = true; // in order to make some width adjustments later $type = ''; $text = ''; $height = 0; $width = 0; switch (strtoupper($attr['TYPE'])) { case 'CHECKBOX': //Draw Checkbox $checked = false; if (isset($attr['CHECKED'])) { $checked = true; } $text = $checked; $type = 'CHECKBOX'; $width = 4; $this->cell[$this->row][$this->col]['textbuffer'][] = array("»¤¬" . "type=input,subtype={$type},width={$width},height={$height}" . "»¤¬" . $text); $this->cell[$this->row][$this->col]['s'] += $width; if (!isset($this->cell[$this->row][$this->col]['h'])) { $this->cell[$this->row][$this->col]['h'] = $this->lineheight; } break; case 'RADIO': //Draw Radio button $checked = false; if (isset($attr['CHECKED'])) { $checked = true; } $text = $checked; $type = 'RADIO'; $width = 3; $this->cell[$this->row][$this->col]['textbuffer'][] = array("»¤¬" . "type=input,subtype={$type},width={$width},height={$height}" . "»¤¬" . $text); $this->cell[$this->row][$this->col]['s'] += $width; if (!isset($this->cell[$this->row][$this->col]['h'])) { $this->cell[$this->row][$this->col]['h'] = $this->lineheight; } break; case 'BUTTON': $type = 'BUTTON'; // Draw a button // Draw a button case 'SUBMIT': if ($type == '') { $type = 'SUBMIT'; } case 'RESET': if ($type == '') { $type = 'RESET'; } $texto = ''; if (isset($attr['VALUE'])) { $texto = " " . $attr['VALUE'] . " "; } $text = $texto; $width = $this->GetStringWidth($texto) + 3; $this->cell[$this->row][$this->col]['textbuffer'][] = array("»¤¬" . "type=input,subtype={$type},width={$width},height={$height}" . "»¤¬" . $text); $this->cell[$this->row][$this->col]['s'] += $width; if (!isset($this->cell[$this->row][$this->col]['h'])) { $this->cell[$this->row][$this->col]['h'] = $this->lineheight + 2; } break; case 'PASSWORD': if (isset($attr['VALUE'])) { $num_stars = strlen($attr['VALUE']); $attr['VALUE'] = str_repeat('*', $num_stars); } $type = 'PASSWORD'; case 'TEXT': //Draw TextField //Draw TextField default: //default == TEXT $texto = ''; if (isset($attr['VALUE'])) { $texto = $attr['VALUE']; } $tamanho = 20; if (isset($attr['SIZE']) and ctype_digit($attr['SIZE'])) { $tamanho = $attr['SIZE']; } $text = $texto; $width = 2 * $tamanho; if ($type == '') { $type = 'TEXT'; } $this->cell[$this->row][$this->col]['textbuffer'][] = array("»¤¬" . "type=input,subtype={$type},width={$width},height={$height}" . "»¤¬" . $text); $this->cell[$this->row][$this->col]['s'] += $width; if (!isset($this->cell[$this->row][$this->col]['h'])) { $this->cell[$this->row][$this->col]['h'] = $this->lineheight + 2; } break; } } break; case 'FONT': //Font size is ignored for now if (isset($attr['COLOR']) and $attr['COLOR'] != '') { $cor = ConvertColor($attr['COLOR']); //If something goes wrong switch color to black $cor['R'] = isset($cor['R']) ? $cor['R'] : 0; $cor['G'] = isset($cor['G']) ? $cor['G'] : 0; $cor['B'] = isset($cor['B']) ? $cor['B'] : 0; $this->colorarray = $cor; $this->SetTextColor($cor['R'], $cor['G'], $cor['B']); $this->issetcolor = true; } if (isset($attr['FACE']) and in_array(strtolower($attr['FACE']), $this->fontlist)) { $this->SetFont(strtolower($attr['FACE'])); $this->issetfont = true; } //'If' disabled in this version due lack of testing (you may enable it if you want) // if (isset($attr['FACE']) and in_array(strtolower($attr['FACE']), $this->fontlist) and isset($attr['SIZE']) and $attr['SIZE']!='') { // $this->SetFont(strtolower($attr['FACE']),'',$attr['SIZE']); // $this->issetfont=true; // } break; } //end of switch $this->pjustfinished = false; }
/** * Checks the url * * @param string $string * @return boolean result */ function isUrl($string) { return \FWValidator::isUri($string); }
function _parsejpg($file) { $width = 0; $height = 0; $colspace = 'DeviceRGB'; $bpc = 8; $data = null; if (FWValidator::isUri($file)) { // Image is a remote ressource require_once ASCMS_LIBRARY_PATH . '/PEAR/HTTP/Request2.php'; try { $request = new HTTP_Request2($file); $data = $request->send()->getBody(); $img = imagecreatefromstring($data); $width = imagesx($img); $height = imagesy($img); unset($img); } catch (Exception $e) { DBG::msg($e->getMessage()); return false; } } else { // Image is a local ressource $imageInfo = getimagesize($file); if (!$imageInfo) { DBG::msg('Missing or incorrect image file: ' . $file); return false; } list($width, $height, $imageType) = $imageInfo; if ($imageType != IMAGETYPE_JPEG) { DBG::msg('Not a JPEG file: ' . $file); return false; } if (!isset($imageInfo['channels']) || $imageInfo['channels'] == 3) { $colspace = 'DeviceRGB'; } elseif ($imageInfo['channels'] == 4) { $colspace = 'DeviceCMYK'; } else { $colspace = 'DeviceGray'; } if (isset($imageInfo['bits'])) { $bpc = $imageInfo['bits']; } //Read whole file $f = fopen($file, 'rb'); $data = ''; while (!feof($f)) { $data .= fread($f, 4096); } fclose($f); } return array('w' => $width, 'h' => $height, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data); }
$ipn = false; foreach ($_POST as $name => $value) { if ($name == 'cancel_return') { if (!FWValidator::isUri($value)) { continue; } $paypalUriNok = $value; continue; } elseif ($name == 'return') { if (!FWValidator::isUri($value)) { continue; } $paypalUriOk = $value; continue; } elseif ($name == 'notify_url') { if (!FWValidator::isUri($value)) { continue; } $paypalUriIpn = $value; continue; } elseif ($name == 'cmd') { if ($value == '_notify-validate') { die("VERIFIED"); } continue; } addParam($name, $value); } function addParam($name, $value) { global $strForm;
/** * 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); }
function loadFile($lpszFileName, $iIndex) { if ($iIndex < 0) { return false; } // READ FILE if (FWValidator::isUri($lpszFileName)) { // Image is a remote ressource require_once ASCMS_LIBRARY_PATH . '/PEAR/HTTP/Request2.php'; try { $request = new HTTP_Request2($lpszFileName); $contents = $request->send()->getBody(); } catch (Exception $e) { DBG::msg($e->getMessage()); return false; } } elseif (!($fh = @fOpen($lpszFileName, "rb"))) { return false; } else { $contents = @fread($fh, @filesize($lpszFileName)); fClose($fh); //echo($contents); } $this->m_lpData = $contents; // $this->m_lpData = @fRead($fh, @fileSize($lpszFileName)); //header ("Content-type: image/gif"); //echo($this->m_lpData); // GET FILE HEADER if (!$this->m_gfh->load($this->m_lpData, $len)) { return false; } $this->m_lpData = substr($this->m_lpData, $len); do { if (!$this->m_img->load($this->m_lpData, $imgLen)) { return false; } $this->m_lpData = substr($this->m_lpData, $imgLen); } while ($iIndex-- > 0); $this->m_bLoaded = true; return true; }