/** * Fix any URLs posted - ie. remove 'javascript:'. * * - Used by preparsecode, fixes links in message and returns nothing. * * @package Posts * @param string $message */ function fixTags(&$message) { global $modSettings; // WARNING: Editing the below can cause large security holes in your forum. // Edit only if you are sure you know what you are doing. $fixArray = array(array('tag' => 'img', 'protocols' => array('http', 'https'), 'embeddedUrl' => false, 'hasEqualSign' => false, 'hasExtra' => true), array('tag' => 'url', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => false), array('tag' => 'url', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => true), array('tag' => 'iurl', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => false), array('tag' => 'iurl', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => true)); call_integration_hook('integrate_fixtags', array(&$fixArray, &$message)); // Fix each type of tag. foreach ($fixArray as $param) { fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); } // Now fix possible security problems with images loading links automatically... $message = preg_replace_callback('~(\\[img.*?\\])(.+?)\\[/img\\]~is', 'fixTags_img_callback', $message); // Limit the size of images posted? if (!empty($modSettings['max_image_width']) || !empty($modSettings['max_image_height'])) { resizeBBCImages($message); } }
function fixTags(&$message) { global $modSettings; // WARNING: Editing the below can cause large security holes in your forum. // Edit only if you are sure you know what you are doing. $fixArray = array(array('tag' => 'img', 'protocols' => array('http', 'https'), 'embeddedUrl' => false, 'hasEqualSign' => false, 'hasExtra' => true), array('tag' => 'url', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => false), array('tag' => 'url', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => true), array('tag' => 'iurl', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => false), array('tag' => 'iurl', 'protocols' => array('http', 'https'), 'embeddedUrl' => true, 'hasEqualSign' => true), array('tag' => 'ftp', 'protocols' => array('ftp', 'ftps'), 'embeddedUrl' => true, 'hasEqualSign' => false), array('tag' => 'ftp', 'protocols' => array('ftp', 'ftps'), 'embeddedUrl' => true, 'hasEqualSign' => true), array('tag' => 'flash', 'protocols' => array('http', 'https'), 'embeddedUrl' => false, 'hasEqualSign' => false, 'hasExtra' => true)); // Fix each type of tag. foreach ($fixArray as $param) { fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); } // Now fix possible security problems with images loading links automatically... $message = preg_replace('~(\\[img.*?\\])(.+?)\\[/img\\]~eis', '\'$1\' . preg_replace(\'~action(=|%3d)(?!dlattach)~i\', \'action-\', \'$2\') . \'[/img]\'', $message); // Limit the size of images posted? if (!empty($modSettings['max_image_width']) || !empty($modSettings['max_image_height'])) { // Find all the img tags - with or without width and height. preg_match_all('~\\[img(\\s+width=\\d+)?(\\s+height=\\d+)?(\\s+width=\\d+)?\\](.+?)\\[/img\\]~is', $message, $matches, PREG_PATTERN_ORDER); $replaces = array(); foreach ($matches[0] as $match => $dummy) { // If the width was after the height, handle it. $matches[1][$match] = !empty($matches[3][$match]) ? $matches[3][$match] : $matches[1][$match]; // Now figure out if they had a desired height or width... $desired_width = !empty($matches[1][$match]) ? (int) substr(trim($matches[1][$match]), 6) : 0; $desired_height = !empty($matches[2][$match]) ? (int) substr(trim($matches[2][$match]), 7) : 0; // One was omitted, or both. We'll have to find its real size... if (empty($desired_width) || empty($desired_height)) { list($width, $height) = url_image_size(un_htmlspecialchars($matches[4][$match])); // They don't have any desired width or height! if (empty($desired_width) && empty($desired_height)) { $desired_width = $width; $desired_height = $height; } elseif (empty($desired_width) && !empty($height)) { $desired_width = (int) ($desired_height * $width / $height); } elseif (!empty($width)) { $desired_height = (int) ($desired_width * $height / $width); } } // If the width and height are fine, just continue along... if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) { continue; } // Too bad, it's too wide. Make it as wide as the maximum. if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width'])) { $desired_height = (int) ($modSettings['max_image_width'] * $desired_height / $desired_width); $desired_width = $modSettings['max_image_width']; } // Now check the height, as well. Might have to scale twice, even... if ($desired_height > $modSettings['max_image_height'] && !empty($modSettings['max_image_height'])) { $desired_width = (int) ($modSettings['max_image_height'] * $desired_width / $desired_height); $desired_height = $modSettings['max_image_height']; } $replaces[$matches[0][$match]] = '[img' . (!empty($desired_width) ? ' width=' . $desired_width : '') . (!empty($desired_height) ? ' height=' . $desired_height : '') . ']' . $matches[4][$match] . '[/img]'; } // If any img tags were actually changed... if (!empty($replaces)) { $message = strtr($message, $replaces); } } }
<span style="margin-top: 10px;margin-bottom: 10px;display: block;">Document: <b>' . $row['divtype'] . '</b></span> <span style="font-style: italic;">"' . $matchingText . '"</span><br /> </div>'; } else { if ($row['type'] != '') { echo '<div style="background: #eee;padding: 15px;border-radius: 8px;border: 1px solid #aaa;margin-bottom: 10px;"> <span style="font-size: 18px;color: #609;"><a href="' . $row['url'] . '">' . $row['title'] . '</a></span><br /> <span style="margin-top: 10px;display: block;">Document: <b>' . $row['divtype'] . '</b></span> <span style="display: block;margin-bottom: 10px;">Keyword: <b>' . fixTag($row['tag'], false, false) . ' (' . fixTag($row['type'], false, false) . ')</b></span> <span style="font-style: italic;">"' . $matchingText . '"</span><br /> </div>'; } else { echo '<div style="background: #eee;padding: 15px;border-radius: 8px;border: 1px solid #aaa;margin-bottom: 10px;"> <span style="font-size: 18px;color: #609;"><a href="' . $row['url'] . '">' . $row['title'] . '</a></span><br /> <span style="margin-top: 10px;display: block;">Document: <b>' . $row['divtype'] . '</b></span> <span style="display: block;margin-bottom: 10px;">Keyword: <b>' . fixTag($row['tag'], false, false) . '</b></span> <span style="font-style: italic;">"' . $matchingText . '"</span><br /> </div>'; } } } echo '<div class="searchPages">'; $totalPages = ceil($numberOfResults['result'] / $resultsPerPage); if ($totalPages > 0) { $newGET = ''; foreach ($_GET as $key => $value) { if ($key == 'page') { continue; } $newGET .= $key . '=' . htmlspecialchars($value) . '&'; }