function createPostXML($row) { global $site_url, $image_folder, $thumbnail_url, $post, $misc; $parent_id = $row['parent']; if ($parent_id == 0) { $parent_id = ''; } $has_notes = $post->has_notes($row['id']); if ($has_notes) { $has_notes = 'true'; } else { $has_notes = 'false'; } $has_comments = !empty($row['last_comment']); if ($has_comments) { $has_comments = 'true'; } else { $has_comments = 'false'; } $has_children = $post->has_children($row['id']); if ($has_children) { $has_children = 'true'; } else { $has_children = 'false'; } $file_url = $site_url . '/' . $image_folder . '/' . $row['directory'] . '/' . $row['image']; return '<post height="' . $row['height'] . '" score="' . $row['score'] . '" file_url="' . $file_url . '" parent_id="' . $parent_id . '" sample_url="' . $file_url . '" sample_width="' . $row['width'] . '" sample_height="' . $row['height'] . '" preview_url="' . $thumbnail_url . $misc->getThumb($row['image'], $row['directory']) . '" rating="' . strtolower(substr($row['rating'], 0, 1)) . '" tags="' . fixTags($row['tags']) . '" id="' . $row['id'] . '" width="' . $row['width'] . '" change="UNIMPLEMENTED" md5="' . $row['hash'] . '" creator_id="' . getUserID($row['owner']) . '" has_children="' . $has_children . '" created_at="' . $row['creation_date'] . '" status="UNIMPLEMENTED" source="' . $row['source'] . '" has_notes="' . $has_notes . '" has_comments="' . $has_comments . '" preview_width="150" preview_height="150"/>' . "\r\n"; }
function preparsecode(&$message, $previewing = false) { global $user_info, $modSettings, $context; // This line makes all languages *theoretically* work even with the wrong charset ;). //$message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); // Clean up after nobbc ;). $message = preg_replace('~\\[nobbc\\](.+?)\\[/nobbc\\]~ie', '\'[nobbc]\' . strtr(\'$1\', array(\'[\' => \'[\', \']\' => \']\', \':\' => \':\', \'@\' => \'@\')) . \'[/nobbc]\'', $message); // Remove \r's... they're evil! $message = strtr($message, array("\r" => '')); // You won't believe this - but too many periods upsets apache it seems! $message = preg_replace('~\\.{100,}~', '...', $message); // Trim off trailing quotes - these often happen by accident. while (substr($message, -7) == '[quote]') { $message = substr($message, 0, -7); } while (substr($message, 0, 8) == '[/quote]') { $message = substr($message, 8); } // Check if all code tags are closed. $codeopen = preg_match_all('~(\\[code(?:=[^\\]]+)?\\])~is', $message, $dummy); $codeclose = preg_match_all('~(\\[/code\\])~is', $message, $dummy); // Close/open all code tags... if ($codeopen > $codeclose) { $message .= str_repeat('[/code]', $codeopen - $codeclose); } elseif ($codeclose > $codeopen) { $message = str_repeat('[code]', $codeclose - $codeopen) . $message; } // Now that we've fixed all the code tags, let's fix the img and url tags... $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); // The regular expression non breaking space has many versions. $non_breaking_space = $context['utf8'] ? $context['server']['complex_preg_chars'] ? '\\x{A0}' : pack('C*', 0xc2, 0xa0) : '\\xA0'; // Only mess with stuff outside [code] tags. for ($i = 0, $n = count($parts); $i < $n; $i++) { // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. if ($i % 4 == 0) { fixTags($parts[$i]); // Replace /me.+?\n with [me=name]dsf[/me]\n. if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { $parts[$i] = preg_replace('~(?:\\A|\\n)/me(?: | )([^\\n]*)(?:\\z)?~i', '[me="' . $user_info['name'] . '"]$1[/me]', $parts[$i]); } else { $parts[$i] = preg_replace('~(?:\\A|\\n)/me(?: | )([^\\n]*)(?:\\z)?~i', '[me=' . $user_info['name'] . ']$1[/me]', $parts[$i]); } if (!$previewing && strpos($parts[$i], '[html]') !== false) { if (allowedTo('admin_forum')) { $parts[$i] = preg_replace('~\\[html\\](.+?)\\[/html\\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\\n" => \' \', \' \' => \'  \')) . \'[/html]\'', $parts[$i]); } else { while (strpos($parts[$i], '[html]') !== false) { $parts[$i] = preg_replace('~\\[[/]?html\\]~i', '', $parts[$i]); } } } // Let's look at the time tags... $parts[$i] = preg_replace('~\\[time(=(absolute))*\\](.+?)\\[/time\\]~ie', '\'[time]\' . (is_numeric(\'$3\') || @strtotime(\'$3\') == 0 ? \'$3\' : strtotime(\'$3\') - (\'$2\' == \'absolute\' ? 0 : (($modSettings[\'time_offset\'] + $user_info[\'time_offset\']) * 3600))) . \'[/time]\'', $parts[$i]); $list_open = substr_count($parts[$i], '[list]') + substr_count($parts[$i], '[list '); $list_close = substr_count($parts[$i], '[/list]'); if ($list_close - $list_open > 0) { $parts[$i] = str_repeat('[list]', $list_close - $list_open) . $parts[$i]; } if ($list_open - $list_close > 0) { $parts[$i] = $parts[$i] . str_repeat('[/list]', $list_open - $list_close); } // Make sure all tags are lowercase. $parts[$i] = preg_replace('~\\[([/]?)(list|li|table|tr|td)((\\s[^\\]]+)*)\\]~ie', '\'[$1\' . strtolower(\'$2\') . \'$3]\'', $parts[$i]); $mistake_fixes = array('~\\[table\\](?![\\s' . $non_breaking_space . ']*\\[tr\\])~s' . ($context['utf8'] ? 'u' : '') => '[table][tr]', '~\\[tr\\](?![\\s' . $non_breaking_space . ']*\\[td\\])~s' . ($context['utf8'] ? 'u' : '') => '[tr][td]', '~\\[/td\\](?![\\s' . $non_breaking_space . ']*(?:\\[td\\]|\\[/tr\\]|\\[/table\\]))~s' . ($context['utf8'] ? 'u' : '') => '[/td][/tr]', '~\\[/tr\\](?![\\s' . $non_breaking_space . ']*(?:\\[tr\\]|\\[/table\\]))~s' . ($context['utf8'] ? 'u' : '') => '[/tr][/table]', '~\\[/td\\][\\s' . $non_breaking_space . ']*\\[/table\\]~s' . ($context['utf8'] ? 'u' : '') => '[/td][/tr][/table]', '~\\[(table|tr|/td)\\]([\\s' . $non_breaking_space . ']*)\\[td\\]~s' . ($context['utf8'] ? 'u' : '') => '[$1]$2[_td_]', '~\\[td\\]~s' => '[tr][td]', '~\\[(table|/tr)\\]([\\s' . $non_breaking_space . ']*)\\[tr\\]~s' . ($context['utf8'] ? 'u' : '') => '[$1]$2[_tr_]', '~\\[tr\\]~s' => '[table][tr]', '~\\[/td\\]([\\s' . $non_breaking_space . ']*)\\[/tr\\]~s' . ($context['utf8'] ? 'u' : '') => '[/td]$1[_/tr_]', '~\\[/tr\\]~s' => '[/td][/tr]', '~\\[li\\]([^\\[\\]]+?)\\[li\\]~s' => '[li]$1[_/li_][_li_]', '~\\[li\\]([^\\[\\]]+?)$~s' => '[li]$1[/li]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[/list\\]~s' . ($context['utf8'] ? 'u' : '') => '[_/li_]$1[/list]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~s' . ($context['utf8'] ? 'u' : '') => '[_/li_]$1[_li_]', '~\\[(list(?: [^\\]]*?)?|/li)\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~s' . ($context['utf8'] ? 'u' : '') => '[$1]$2[_li_]', '~\\[li\\]~' => '[list][li]', '~\\[/li\\]~' => '[/li][/list]', '~\\[_(li|/li|td|tr|/tr)_\\]~' => '[$1]'); // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) for ($j = 0; $j < 3; $j++) { $parts[$i] = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $parts[$i]); } } } // Put it back together! if (!$previewing) { $message = strtr(implode('', $parts), array(' ' => ' ', "\n" => '<br />', $context['utf8'] ? "Â " : " " => ' ')); } else { $message = strtr(implode('', $parts), array(' ' => ' ', $context['utf8'] ? "Â " : " " => ' ')); } // Now let's quickly clean up things that will slow our parser (which are common in posted code.) $message = strtr($message, array('[]' => '[]', '['' => '['')); }
/** * Takes a message and parses it, returning the prepared message as a reference. * * - Cleans up links (javascript, etc.) and code/quote sections. * - Won't convert \n's and a few other things if previewing is true. * * @param string $message * @param boolean $previewing = false */ public function parse(&$message, $previewing = false) { $this->message = $message; // Remove \r's... they're evil! $this->message = str_replace(array("\r"), array(''), $this->message); // @todo sanitizeMSCutPaste()? $this->fixWrongCharset(); // You won't believe this - but too many periods upsets apache it seems! $this->message = preg_replace('~\\.{100,}~', '...', $this->message); // Hoping this makes parsing faster $has = array('nobbc' => strpos($this->message, '[nobbc') !== false, 'quote' => strpos($this->message, '[quote') !== false, 'code' => strpos($this->message, '[code') !== false, 'html' => strpos($this->message, '[html') !== false, 'list' => strpos($this->message, '[list') !== false, 'table' => strpos($this->message, '[table') !== false, 'color' => strpos($this->message, '[color') !== false, 'me' => strpos($this->message, '/me') !== false); call_integration_hook('integrate_preparse_code_has', array(&$has, $this->message, $previewing)); // Clean up after nobbc ;). if ($has['nobbc']) { $this->fixNoBBC(); } if ($has['quote']) { $this->fixTrailingQuotes(); } if ($has['code']) { $this->fixCode(); } // @todo only split if we have code tag? // Now that we've fixed all the code tags, let's fix the img and url tags... $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $this->message, -1, PREG_SPLIT_DELIM_CAPTURE); // Only mess with stuff outside [code] tags. for ($i = 0, $n = count($parts); $i < $n; $i++) { // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. if ($i % 4 == 0) { fixTags($parts[$i]); // Replace /me.+?\n with [me=name]dsf[/me]\n. if ($has['me']) { $this->doMe($parts[$i]); } // @todo this doesn't really make a difference with the parser since it lowercases the tags anyway. Maybe get rid of it? // Make sure all tags are lowercase. $this->lowercaseTags($parts[$i]); if ($has['list']) { $this->fixLists($parts[$i]); } // @todo why 3? // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) for ($j = 0; $j < 3; $j++) { $parts[$i] = preg_replace($this->fix_search, $this->fix_replace, $parts[$i]); } // Remove empty bbc from the sections outside the code tags $this->removeEmpty($parts[$i]); // Fix color tags of many forms so they parse properly if ($has['color']) { $this->fixColors($parts[$i]); } } // @todo I feel like cases where this call is in a loop we could save an isset() if we just got the function calls call_integration_hook('integrate_preparse_code', array(&$parts[$i], $i, $previewing)); } // Put it back together! if (!$previewing) { $this->message = strtr(implode('', $parts), array(' ' => ' ', "\n" => '<br />', " " => ' ')); } else { $this->message = strtr(implode('', $parts), array(' ' => ' ', " " => ' ')); } // Now we're going to do full scale table checking... if ($has['table']) { $this->table(); } // @todo can this be moved earlier? Like to the first str_replace()? // Now let's quickly clean up things that will slow our parser (which are common in posted code.) $this->message = strtr($this->message, array('[]' => '[]', '['' => '['')); $message = $this->message; }
/** * Takes a message and parses it, returning the prepared message as a referance. * * - Cleans up links (javascript, etc.) and code/quote sections. * - Won't convert \n's and a few other things if previewing is true. * * @package Posts * @param string $message * @param boolean $previewing */ function preparsecode(&$message, $previewing = false) { global $user_info; // This line makes all languages *theoretically* work even with the wrong charset ;). $message = preg_replace('~&#(\\d{4,5}|[2-9]\\d{2,4}|1[2-9]\\d);~', '&#$1;', $message); // Clean up after nobbc ;). $message = preg_replace_callback('~\\[nobbc\\](.+?)\\[/nobbc\\]~i', 'preparsecode_nobbc_callback', $message); // Remove \r's... they're evil! $message = strtr($message, array("\r" => '')); // You won't believe this - but too many periods upsets apache it seems! $message = preg_replace('~\\.{100,}~', '...', $message); // Trim off trailing quotes - these often happen by accident. while (substr($message, -7) == '[quote]') { $message = trim(substr($message, 0, -7)); } while (substr($message, 0, 8) == '[/quote]') { $message = trim(substr($message, 8)); } // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. $in_tag = false; $had_tag = false; $codeopen = 0; if (preg_match_all('~(\\[(/)*code(?:=[^\\]]+)?\\])~is', $message, $matches)) { foreach ($matches[0] as $index => $dummy) { // Closing? if (!empty($matches[2][$index])) { // If it's closing and we're not in a tag we need to open it... if (!$in_tag) { $codeopen = true; } // Either way we ain't in one any more. $in_tag = false; } else { $had_tag = true; // If we're in a tag don't do nought! if (!$in_tag) { $in_tag = true; } } } } // If we have an open tag, close it. if ($in_tag) { $message .= '[/code]'; } // Open any ones that need to be open, only if we've never had a tag. if ($codeopen && !$had_tag) { $message = '[code]' . $message; } // Now that we've fixed all the code tags, let's fix the img and url tags... $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); // The regular expression non breaking space. $non_breaking_space = '\\x{A0}'; // Only mess with stuff outside [code] tags. for ($i = 0, $n = count($parts); $i < $n; $i++) { // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. if ($i % 4 == 0) { fixTags($parts[$i]); // Replace /me.+?\n with [me=name]dsf[/me]\n. if (preg_match('~[\\[\\]\\"]~', $user_info['name']) !== false) { $parts[$i] = preg_replace('~(\\A|\\n)/me(?: | )([^\\n]*)(?:\\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $parts[$i]); $parts[$i] = preg_replace('~(\\[footnote\\])/me(?: | )([^\\n]*?)(\\[\\/footnote\\])~i', '$1[me="' . $user_info['name'] . '"]$2[/me]$3', $parts[$i]); } else { $parts[$i] = preg_replace('~(\\A|\\n)/me(?: | )([^\\n]*)(?:\\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $parts[$i]); $parts[$i] = preg_replace('~(\\[footnote\\])/me(?: | )([^\\n]*?)(\\[\\/footnote\\])~i', '$1[me=' . $user_info['name'] . ']$2[/me]$3', $parts[$i]); } // Make sure all tags are lowercase. $parts[$i] = preg_replace_callback('~\\[([/]?)(list|li|table|tr|td|th)((\\s[^\\]]+)*)\\]~i', 'preparsecode_lowertags_callback', $parts[$i]); $list_open = substr_count($parts[$i], '[list]') + substr_count($parts[$i], '[list '); $list_close = substr_count($parts[$i], '[/list]'); if ($list_close - $list_open > 0) { $parts[$i] = str_repeat('[list]', $list_close - $list_open) . $parts[$i]; } if ($list_open - $list_close > 0) { $parts[$i] = $parts[$i] . str_repeat('[/list]', $list_open - $list_close); } $mistake_fixes = array('~\\[table\\](?![\\s' . $non_breaking_space . ']*\\[tr\\])~su' => '[table][tr]', '~\\[tr\\](?![\\s' . $non_breaking_space . ']*\\[t[dh]\\])~su' => '[tr][td]', '~\\[/t([dh])\\](?![\\s' . $non_breaking_space . ']*(?:\\[t[dh]\\]|\\[/tr\\]|\\[/table\\]))~su' => '[/t$1][/tr]', '~\\[/tr\\](?![\\s' . $non_breaking_space . ']*(?:\\[tr\\]|\\[/table\\]))~su' => '[/tr][/table]', '~\\[/t([dh])\\][\\s' . $non_breaking_space . ']*\\[/table\\]~su' => '[/t$1][/tr][/table]', '~\\[(table|tr|/td)\\]([\\s' . $non_breaking_space . ']*)\\[td\\]~su' => '[$1]$2[_td_]', '~\\[td\\]~s' => '[tr][td]', '~\\[(table|/tr)\\]([\\s' . $non_breaking_space . ']*)\\[tr\\]~su' => '[$1]$2[_tr_]', '~\\[tr\\]~s' => '[table][tr]', '~\\[/t([dh])\\]([\\s' . $non_breaking_space . ']*)\\[/tr\\]~su' => '[/t$1]$2[_/tr_]', '~\\[/tr\\]~s' => '[/td][/tr]', '~\\[li\\]([^\\[\\]]+?)\\[li\\]~s' => '[li]$1[_/li_][_li_]', '~\\[li\\]([^\\[\\]]+?)\\[/list\\]~s' => '[_li_]$1[_/li_][/list]', '~\\[li\\]([^\\[\\]]+?)$~s' => '[li]$1[/li]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[/list\\]~su' => '[_/li_]$1[/list]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~su' => '[_/li_]$1[_li_]', '~\\[(list(?: [^\\]]*?)?|/li)\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~su' => '[$1]$2[_li_]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[list\\]~u' => '[_/li_]$1[list]', '~\\[/list\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~u' => '[/list]$1[_li_]', '~\\[li\\]~' => '[list][li]', '~\\[/li\\]~' => '[/li][/list]', '~\\[_(li|/li|td|tr|/tr)_\\]~' => '[$1]', '~\\[img\\]https?://.{0,7}\\[/img\\]~' => ''); // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) for ($j = 0; $j < 3; $j++) { $parts[$i] = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $parts[$i]); } // Remove empty bbc from the sections outside the code tags $parts[$i] = preg_replace('~\\[[bisu]\\]\\s*\\[/[bisu]\\]~', '', $parts[$i]); $parts[$i] = preg_replace('~\\[quote\\]\\s*\\[/quote\\]~', '', $parts[$i]); // Fix color tags of many forms so they parse properly $parts[$i] = preg_replace('~\\[color=(?:#[\\da-fA-F]{3}|#[\\da-fA-F]{6}|[A-Za-z]{1,20}|rgb\\(\\d{1,3}, ?\\d{1,3}, ?\\d{1,3}\\))\\]\\s*\\[/color\\]~', '', $parts[$i]); // Font tags with multiple fonts (copy&paste in the WYSIWYG by some browsers). $parts[$i] = preg_replace_callback('~\\[font=([^\\]]*)\\](.*?(?:\\[/font\\]))~s', 'preparsecode_font_callback', $parts[$i]); } call_integration_hook('integrate_preparse_code', array(&$parts[$i], $i, $previewing)); } // Put it back together! if (!$previewing) { $message = strtr(implode('', $parts), array(' ' => ' ', "\n" => '<br />', " " => ' ')); } else { $message = strtr(implode('', $parts), array(' ' => ' ', " " => ' ')); } // Now we're going to do full scale table checking... $message = preparsetable($message); // Now let's quickly clean up things that will slow our parser (which are common in posted code.) $message = strtr($message, array('[]' => '[]', '['' => '['')); }
/** * import children to the dom * * @param mixed[] $vars the child to be adopted * @param DOMNode $parent the parent element */ protected function importChildren($vars, $parent) { foreach ($vars as $k => $v) { if (is_array($v)) { $childparent = $this->appendParentChild($parent, is_numeric($k) ? 'rs' : $k); $this->importChildren(is_string($v) ? fixTags($v) : $v, $childparent); } else { $v = ($k == 'pubdate' || $k == 'date') && $this->neatDate ? neatDate($v) : $v; $this->appendChild($parent, is_numeric($k) ? 'rs' : $k, is_string($v) ? fixTags($v) : $v); } } }
function preparsecode(&$message, $previewing = false) { global $user_info, $context, $modSettings; // This line makes all languages *theoretically* work even with the wrong charset ;). $message = preg_replace('~&#(\\d{4,5}|[2-9]\\d{2,4}|1[2-9]\\d);~', '&#$1;', $message); // Clean up after nobbc ;). $message = preg_replace('~\\[nobbc\\](.+?)\\[/nobbc\\]~ie', '\'[nobbc]\' . strtr(\'$1\', array(\'[\' => \'[\', \']\' => \']\', \':\' => \':\', \'@\' => \'@\')) . \'[/nobbc]\'', $message); // Remove \r's... they're evil! $message = strtr($message, array("\r" => '')); // You won't believe this - but too many periods upsets apache it seems! $message = preg_replace('~\\.{100,}~', '...', $message); // Trim off trailing quotes - these often happen by accident. while (substr($message, -7) == '[quote]') { $message = substr($message, 0, -7); } while (substr($message, 0, 8) == '[/quote]') { $message = substr($message, 8); } // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. $in_tag = false; $had_tag = false; $codeopen = 0; if (preg_match_all('~(\\[(/)*code(?:=[^\\]]+)?\\])~is', $message, $matches)) { foreach ($matches[0] as $index => $dummy) { // Closing? if (!empty($matches[2][$index])) { // If it's closing and we're not in a tag we need to open it... if (!$in_tag) { $codeopen = true; } // Either way we ain't in one any more. $in_tag = false; } else { $had_tag = true; // If we're in a tag don't do nought! if (!$in_tag) { $in_tag = true; } } } } // If we have an open tag, close it. if ($in_tag) { $message .= '[/code]'; } // Open any ones that need to be open, only if we've never had a tag. if ($codeopen && !$had_tag) { $message = '[code]' . $message; } // Now that we've fixed all the code tags, let's fix the img and url tags... $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); // The regular expression non breaking space has many versions. $non_breaking_space = $context['server']['complex_preg_chars'] ? '\\x{A0}' : " "; // Only mess with stuff outside [code] tags. for ($i = 0, $n = count($parts); $i < $n; $i++) { // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. if ($i % 4 == 0) { fixTags($parts[$i]); // Replace /me.+?\n with [me=name]dsf[/me]\n. if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { $parts[$i] = preg_replace('~(\\A|\\n)/me(?: | )([^\\n]*)(?:\\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $parts[$i]); } else { $parts[$i] = preg_replace('~(\\A|\\n)/me(?: | )([^\\n]*)(?:\\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $parts[$i]); } if (!$previewing && strpos($parts[$i], '[html]') !== false) { if (allowedTo('admin_forum')) { $parts[$i] = preg_replace('~\\[html\\](.+?)\\[/html\\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\\n" => \' \', \' \' => \'  \', \'[\' => \'[\', \']\' => \']\')) . \'[/html]\'', $parts[$i]); } else { while (strpos($parts[$i], '[html]') !== false) { $parts[$i] = preg_replace('~\\[[/]?html\\]~i', '', $parts[$i]); } } } // Let's look at the time tags... $parts[$i] = preg_replace('~\\[time(?:=(absolute))*\\](.+?)\\[/time\\]~ie', '\'[time]\' . (is_numeric(\'$2\') || @strtotime(\'$2\') == 0 ? \'$2\' : strtotime(\'$2\') - (\'$1\' == \'absolute\' ? 0 : (($modSettings[\'time_offset\'] + $user_info[\'time_offset\']) * 3600))) . \'[/time]\'', $parts[$i]); // Change the color specific tags to [color=the color]. $parts[$i] = preg_replace('~\\[(black|blue|green|red|white)\\]~', '[color=$1]', $parts[$i]); // First do the opening tags. $parts[$i] = preg_replace('~\\[/(black|blue|green|red|white)\\]~', '[/color]', $parts[$i]); // And now do the closing tags // Make sure all tags are lowercase. $parts[$i] = preg_replace('~\\[([/]?)(list|li|table|tr|td)((\\s[^\\]]+)*)\\]~ie', '\'[$1\' . strtolower(\'$2\') . \'$3]\'', $parts[$i]); $list_open = substr_count($parts[$i], '[list]') + substr_count($parts[$i], '[list '); $list_close = substr_count($parts[$i], '[/list]'); if ($list_close - $list_open > 0) { $parts[$i] = str_repeat('[list]', $list_close - $list_open) . $parts[$i]; } if ($list_open - $list_close > 0) { $parts[$i] = $parts[$i] . str_repeat('[/list]', $list_open - $list_close); } $mistake_fixes = array('~\\[table\\](?![\\s' . $non_breaking_space . ']*\\[tr\\])~su' => '[table][tr]', '~\\[tr\\](?![\\s' . $non_breaking_space . ']*\\[td\\])~su' => '[tr][td]', '~\\[/td\\](?![\\s' . $non_breaking_space . ']*(?:\\[td\\]|\\[/tr\\]|\\[/table\\]))~su' => '[/td][/tr]', '~\\[/tr\\](?![\\s' . $non_breaking_space . ']*(?:\\[tr\\]|\\[/table\\]))~su' => '[/tr][/table]', '~\\[/td\\][\\s' . $non_breaking_space . ']*\\[/table\\]~su' => '[/td][/tr][/table]', '~\\[(table|tr|/td)\\]([\\s' . $non_breaking_space . ']*)\\[td\\]~su' => '[$1]$2[_td_]', '~\\[td\\]~s' => '[tr][td]', '~\\[(table|/tr)\\]([\\s' . $non_breaking_space . ']*)\\[tr\\]~su' => '[$1]$2[_tr_]', '~\\[tr\\]~s' => '[table][tr]', '~\\[/td\\]([\\s' . $non_breaking_space . ']*)\\[/tr\\]~su' => '[/td]$1[_/tr_]', '~\\[/tr\\]~s' => '[/td][/tr]', '~\\[li\\]([^\\[\\]]+?)\\[li\\]~s' => '[li]$1[_/li_][_li_]', '~\\[li\\]([^\\[\\]]+?)\\[/list\\]~s' => '[_li_]$1[_/li_][/list]', '~\\[li\\]([^\\[\\]]+?)$~s' => '[li]$1[/li]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[/list\\]~su' => '[_/li_]$1[/list]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~su' => '[_/li_]$1[_li_]', '~\\[(list(?: [^\\]]*?)?|/li)\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~su' => '[$1]$2[_li_]', '~\\[/li\\]([\\s' . $non_breaking_space . ']*)\\[list\\]~u' => '[_/li_]$1[list]', '~\\[/list\\]([\\s' . $non_breaking_space . ']*)\\[li\\]~u' => '[/list]$1[_li_]', '~\\[li\\]~' => '[list][li]', '~\\[/li\\]~' => '[/li][/list]', '~\\[_(li|/li|td|tr|/tr)_\\]~' => '[$1]', '~\\[img\\]https?://.{0,7}\\[/img\\]~' => ''); // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) for ($j = 0; $j < 3; $j++) { $parts[$i] = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $parts[$i]); } // Now we're going to do full scale table checking... $table_check = $parts[$i]; $table_offset = 0; $table_array = array(); $table_order = array('table' => 'td', 'tr' => 'table', 'td' => 'tr'); while (preg_match('~\\[(/)*(table|tr|td)\\]~', $table_check, $matches) != false) { // Keep track of where this is. $offset = strpos($table_check, $matches[0]); $remove_tag = false; // Is it opening? if ($matches[1] != '/') { // If the previous table tag isn't correct simply remove it. if (!empty($table_array) && $table_array[0] != $table_order[$matches[2]] || empty($table_array) && $matches[2] != 'table') { $remove_tag = true; } else { array_unshift($table_array, $matches[2]); } } else { // Only keep the tag if it's closing the right thing. if (empty($table_array) || $table_array[0] != $matches[2]) { $remove_tag = true; } else { array_shift($table_array); } } // Removing? if ($remove_tag) { $parts[$i] = substr($parts[$i], 0, $table_offset + $offset) . substr($parts[$i], $table_offset + strlen($matches[0]) + $offset); // We've lost some data. $table_offset -= strlen($matches[0]); } // Remove everything up to here. $table_offset += $offset + strlen($matches[0]); $table_check = substr($table_check, $offset + strlen($matches[0])); } // Close any remaining table tags. foreach ($table_array as $tag) { $parts[$i] .= '[/' . $tag . ']'; } } } // Put it back together! if (!$previewing) { $message = strtr(implode('', $parts), array(' ' => ' ', "\n" => '<br />', " " => ' ')); } else { $message = strtr(implode('', $parts), array(' ' => ' ', " " => ' ')); } // Now let's quickly clean up things that will slow our parser (which are common in posted code.) $message = strtr($message, array('[]' => '[]', '['' => '['')); }
<h4><?php if (isset($obj['Byline'])) { echo $obj['Byline']; } ?> </h4> </div> <div class="content_item2"> <?php //HOME $fields = array('Title', 'Description', 'Thumbnail', 'URL', 'Section'); $order[] = array('field' => 'Title', 'direction' => SORT_ASC); $query = new KORA_Clause("Section", "=", "Home"); $obj = KORA_Search(token, $projID, $sectionID, $query, $fields, $order); if (isset($obj) && !empty($obj)) { foreach ($obj as $value) { if (!empty($value['Description'])) { echo "<p>" . fixTags($value['Description']) . "</p>"; } } } ?> <?php require_once 'highlights.php'; ?> </div> <?php require_once 'includes/footer.php';
// Get thumb from KORA echo '<a href="' . $value['URL'] . '"><img class="moduleImg" width="' . $thumbWidth . '" height="' . $thumbHeight . '" src="' . $image . '" alt="' . htmlChars($value['Title']) . '" /></a><br />'; } else { //Create thumb if needed if (!empty($hi_obj['Image']['localName'])) { createthumb(getFullPathFromFileName($value['Image']['localName']), 'thumbs/' . $value['Image']['localName'], 100, 100); echo '<a href="' . $value['URL'] . '"><img src="' . baseURL . 'thumbs/' . $value['Image']['localName'] . '" alt="' . htmlChars($value['Title']) . '" /></a><br />'; } } if (!empty($value['Date'])) { foreach ($value['Date'] as $date) { if (!empty($date)) { if ($date == "CE") { break; } echo $date . "<br/>"; } } } if (!empty($value['Description'])) { echo fixTags($value['Description']) . "<br />"; } ?> </div> <?php } ?> </div><?php }
echo '<h4><a href="' . baseURL . pfolder . 'object/' . $value['kid'] . '/b/">' . $value['Title'] . '</a></h4>'; } if (is_array($value['Date Original'])) { echo '<strong>Date: </strong>' . formatDate($value['Date Original']['month'], $value['Date Original']['day'], $value['Date Original']['year']) . '<br />'; } else { if (is_array($value['Date Range'])) { echo "<strong>Date Range: </strong>"; foreach ($value['Date Range'] as $date) { if (!empty($date)) { if ($date == "CE") { break; } echo $date . "<br/>"; } } } } if (!empty($value['Description'])) { echo fixTags($value['Description']) . '<br />'; } ?> </div><?php } } //end main essay object display ?> </div></div></div> <?php require_once 'includes/footer.php';
<?php require_once "inc/global.php"; $usrObj = new User(); /* switch ($_REQUEST['task']) { case "userAdd": $usrObj->userAdd($_POST["submit"]); break; }*/ if (isset($_POST['submit'])) { $username = fixTags(trim($_POST['username'])); $password = fixTags(trim(md5(sha1($_POST['password'])))); $email = $_POST['username']; if ($usrObj->login($username, $password, $email)) { if ($usrObj->isLoggedIn() != "") { $userId = $_SESSION['user_session']; $userInfo = $usrObj->getOneUser($userId); if ($userInfo["user_position"] == 1) { redirect('admin.php'); } elseif ($userInfo["user_position"] == 2) { redirect('products.php'); } else { redirect('index.php'); } } } else { $usrObj->redirect('login.php?error=login'); } } else { $usrObj->redirect('login.php'); }
<?php if (!empty($value['Creator'])) { echo '<div class="desc"><strong>Creator: </strong>'; foreach ($value['Creator'] as $creator) { echo $creator . '<br />'; } echo '</div>'; } if (!empty($value['Biography'])) { echo '<div class="desc"><strong>Biography: </strong>' . $value['Biography'] . '</div>'; } if (!empty($value['Description'])) { echo '<div class="desc"><strong>Description: </strong>'; $descP = explode(PHP_EOL, $value['Description']); foreach ($descP as $p) { echo fixTags($p) . "<br>"; } echo "</div>"; } if (!empty($value['Subject'])) { // var_dump($value['Subject']); if (is_array($value['Subject'])) { echo '<div class = "desc"><strong>Subject: </strong>'; foreach ($value['Subject'] as $val) { ?> <a href = "<?php echo baseURL . pfolder; ?> subjects.php?subject=<?php echo $val; ?>
$mail = fixTags(trim($_POST['email'])); //yeni kayıtta email $fullname = fixTags(trim($_POST['name'])); $userPosition = fixTags(trim($_POST['userPosition'])); if (!$username || !preg_match("/^\\S+@\\S+\$/", $mail) || !$fullname || !$userPosition) { redirect('userList.php?msg=error'); } else { $reg = $usrObj->registerUser($username, $password, $mail, $fullname, $userPosition); if ($reg) { redirect('userList.php?msg=success'); } else { redirect('userList.php?msg=error'); } } break; case "userEdit": $username = fixTags(trim($_POST['username'])); $mail = fixTags(trim($_POST['email'])); $fullname = fixTags(trim($_POST['name'])); $userPosition = fixTags(trim($_POST['userPosition'])); $usrObj->userUpdate($_GET["userId"], $username, $mail, $fullname, $userPosition); redirect('userList.php'); break; case "userDelete": $usrObj->userDelete($_GET["id"]); redirect('userList.php'); break; } } else { $usrObj->redirect('login.php'); }