/** * Redirect to specific URL (header redirection). * * Usually URLs passed to this function are escaped so they can be printed in templates and * not break the validator (& problem) so this functions undo htmlspecialchars() first * * @param string $to Redirect to this URL * @param boolean $die Die when finished * @return void */ function redirect_to($to, $die = true) { $to = undo_htmlspecialchars($to); header('Location: ' . $to); if ($die) { die; } // if }
} } settype($submitP, 'string'); if ($submitP) { $acc = "editpost"; $title = stripslashes($subject); $message = stripslashes(make_clickable($message)); include "preview.php"; } else { $image_subject = $myrow['image']; $title = stripslashes($title); $message = $myrow['post_text']; if ($forum_type != 6 and $forum_type != 5) { $message = str_replace("<br />", "\n", $message); $message = smile($message); $message = undo_htmlspecialchars($message, ENT_COMPAT | ENT_HTML401, cur_charset); } else { $message = htmlspecialchars($message, ENT_COMPAT | ENT_HTML401, cur_charset); } $message = stripslashes($message); } if (($Mmod or $userdata[0] == $myrow['uid']) and $forum_access != 9) { echo ' <h4>' . translate("Editing Post") . ' de ' . $myrow['uname'] . '</h4>'; echo '<form action="editpost.php" method="post" name="coolsus">'; if ($Mmod) { echo ' <div class="form-group row"> <div class="col-sm-3"> <label class="form-control-label" for="subject">' . translate("Title") . '</label> </div>
} } else { break; } } else { if (Localization::instance()->lang_exists('field ' . $object->getObjectManagerName() . ' ' . $context['column_name'])) { echo lang('field ' . $object->getObjectManagerName() . ' ' . $context['column_name']); } else { echo clean($context['column_name']); } } ?> : </b> <span class='desc'><?php if ($object instanceof ProjectFileRevision) { echo undo_htmlspecialchars($context['context']); } else { echo $context['context']; } ?> </span></td> </tr> <?php } // if } // foreach context ?> <?php } // foreach row
/** * Populate feed object with activity log entries * * @param Angie_Feed * @param array $activity_log * @return Angie_Feed */ private function populateFeedFromLog(Angie_Feed $feed, $activity_log) { if (is_array($activity_log)) { foreach ($activity_log as $activity_log_entry) { $item = $feed->addItem(new Angie_Feed_Item($activity_log_entry->getText(), undo_htmlspecialchars($activity_log_entry->getObjectUrl()), '', $activity_log_entry->getCreatedOn())); $taken_by = $activity_log_entry->getTakenBy(); if ($taken_by instanceof User) { $item->setAuthor(new Angie_Feed_Author($taken_by->getDisplayName(), $taken_by->getEmail())); } // if } // foreach } // if return $feed; }
<tr> <!-- Checkbox --> <?php if ($task->canChangeStatus(logged_user())) { if ($on_list_page) { ?> <td class="taskCheckbox"><?php echo checkbox_link($task->getCompleteUrl(), false, lang('mark task as completed')); ?> </td> <?php } else { ?> <td class="taskCheckbox"><?php echo checkbox_link($task->getCompleteUrl(undo_htmlspecialchars($task_list->getOverviewUrl())), false, lang('mark task as completed')); ?> </td> <?php } // if } else { ?> <td class="taskCheckbox"><img src="<?php echo icon_url('not-checked.jpg'); ?> " alt="<?php echo lang('open task'); ?> " /></td> <?php
/** * Populate feed object with activity log entries * * @param Angie_Feed * @param array $activity_log * @return Angie_Feed */ private function populateFeedFromLog(Angie_Feed $feed, $activity_log) { $this->addHelper('textile'); if (is_array($activity_log)) { foreach ($activity_log as $activity_log_entry) { tpl_assign('object', $activity_log_entry->getObject()); $description = 'no object attached'; if ($activity_log_entry->getObject()) { $object_type = str_replace(" ", "_", strtolower($activity_log_entry->getObject()->getObjectTypeName())); if (file_exists(get_template_path('render_' . $object_type, 'feed'))) { $description = tpl_fetch(get_template_path('render_' . $object_type, 'feed')); } else { $description = tpl_fetch(get_template_path('render_object', 'feed')); } } $item = $feed->addItem(new Angie_Feed_Item($activity_log_entry->getText(), undo_htmlspecialchars($activity_log_entry->getObjectUrl()), $description, $activity_log_entry->getCreatedOn())); $taken_by = $activity_log_entry->getTakenBy(); if ($taken_by instanceof User) { $item->setAuthor(new Angie_Feed_Author($taken_by->getDisplayName(), $taken_by->getEmail())); } // if } // foreach } // if return $feed; }
trigger_error('XS_SH_NO_TOPIC'); } $db->sql_freeresult($result); // Define some variables for later use $code_filename = ''; $code_text = ''; define('EXTRACT_CODE', $code_id); // Compile the Post / PM $bbcode_uid = $posttext['bbcode_uid']; $sh_bbcode->allow_bbcode = true; $sh_bbcode->allow_smilies = $config['allow_smilies'] && $posttext['enable_smilies'] ? true : false; $sh_bbcode->code_post_id = $mode == 'pm' ? $posttext['msg_id'] : $posttext['post_id']; $message = $sh_bbcode->parse($mode == 'pm' ? $posttext['message_text'] : $posttext['post_text'], $bbcode_uid); $sh_bbcode->code_post_id = 0; if (!strlen($sh_bbcode->code_text)) { trigger_error('XS_SH_NO_CONTENT'); } $code_text = undo_htmlspecialchars($sh_bbcode->code_text, true); if (empty($sh_bbcode->code_filename)) { $code_filename = 'code_' . $post_id . ($code_id ? '_' . $code_id : '') . '.txt'; } else { $code_filename = $sh_bbcode->code_filename; } // Send the Data to the user for download header('Content-Type: application/force-download'); header('Content-Length: ' . strlen($code_text)); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Disposition: attachment; filename="' . $code_filename . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); echo $code_text;
/** * function: geshi_highlight * ------------------------- * Takes the language to highlight and the sourcecode, and highlights it. * Also replaces some things like <br />'s because they're added later * by future phpBB code. */ function geshi_highlight($source, $language, $uid) { global $phpbb_root_path, $phpEx, $board_config, $syntax_config; include_once $phpbb_root_path . 'includes/geshi.' . $phpEx; // // Check to see if this language is an alias. Also catches attempts // to use the language file name as language name // $lang_name = ''; foreach ($syntax_config as $row) { if (stripslashes($row['lang_identifier']) == $language) { $lang_name = substr(stripslashes($row['language_file_name']), 0, strpos(stripslashes($row['language_file_name']), '.')); break; } } $language = strtolower($lang_name); // Firstly, we're going to see if this code is cached. $cache_file = $phpbb_root_path . 'cache/syntax/' . md5($source . $language) . '.dat'; if ($board_config['syntax_enable_cache'] && is_readable($cache_file)) { // This source must have been cached. Good for us, this will speed things up. // We simply get the cached content and return it return implode('', file($cache_file)); } else { // Oh dear, it can't be cached. Never mind, let's compile it and // cache it for next time $source = str_replace("\\\"", "\"", $source); if ($board_config['syntax_status'] == 2) { // // We want to look for important lines (signified by >>>line...<<<) // $array = array(); $source_lines = explode("\n", str_replace("\r", '', $source)); $i = 0; foreach ($source_lines as $line) { $i++; if (substr($line, 0, 12) == '>>>' && substr($line, strlen($line) - 12, 12) == '<<<') { $array[] = $i; $source_lines[$i - 1] = substr($line, 12, strlen($line) - 24); } } $source = implode("\n", $source_lines); unset($source_lines); // Create the new GeSHi object, passing relevant stuff $geshi =& new GeSHi(undo_htmlspecialchars($source), $language, $phpbb_root_path . 'includes/geshi/'); // Enclose the code in a <div> $geshi->set_header_type(GESHI_HEADER_DIV); // Turn CSS classes on to reduce output code size $geshi->enable_classes(); // Turn on line numbers if required if ($board_config['syntax_enable_line_numbers'] && !$geshi->error() && $source != '') { $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); } // Turn off URLs if not wanted if (!$board_config['syntax_enable_urls']) { for ($i = 1; $i < 6; $i++) { $geshi->set_url_for_keyword_group($i, ''); } } // Assign the important lines we set up earlier $geshi->highlight_lines_extra($array); // Make links to documentation open in a new window $geshi->set_link_target('_blank'); // Disable important blocks $geshi->enable_important_blocks(false); // Parse the code $source = $geshi->parse_code(); // Remove <br />'s added by GeSHi - they are added by phpBB later anyway $source = str_replace('<br />', '', $source); // Add "important" markers if there was an error highlighting if ($geshi->error()) { $i = 0; $source_lines = explode("\n", str_replace("\r", '', $source)); foreach ($source_lines as $line) { if (in_array(++$i, $array)) { $line = '<div class="ln-xtra">' . $line . '</div>'; } $source_lines[$i - 1] = $line; } $source = implode("\n", $source_lines); unset($source_lines); } // Remove wierd endline... if ($board_config['syntax_enable_line_numbers'] && !$geshi->error()) { $source = str_replace("\n", '', $source); $source = str_replace('<li><div class="de1"> </div></li></ol></div>', '</ol></div>', $source); } else { $source = str_replace(' </div>', '</div>', $source); $source = str_replace("</div>\n", '</div>', $source); $source = str_replace('<div class="ln-xtra"></div>', '<div class="ln-xtra"> </div>', $source); } // Remove uids from bbcode... $source = str_replace(':' . $uid, '', $source); // Make normal endlines $source = str_replace("\r", '', $source); $source = str_replace("\n", "\r\n", $source); } else { // Just perform normal indentation $source = str_replace(' ', ' ', $source); $source = str_replace(' ', ' ', $source); $source = str_replace("\t", ' ', $source); $source = preg_replace('/^ {1}/m', ' ', $source); // And highlight important lines $source = preg_replace("#>>>(.*?)<<<(\r\n)?#si", '<div class="ln-xtra">\\1</div>', $source); $source = str_replace('<div class="ln-xtra"></div>', '<div class="ln-xtra"> </div>', $source); } if ($board_config['syntax_enable_cache']) { // Perform cache maintenance $source_len = strlen($source); syntax_cache_maintenance($source_len); if (get_dir_size($phpbb_root_path . 'cache/syntax/') + $source_len <= $board_config['syntax_cache_dir_size'] || $board_config['syntax_cache_dir_size'] == 0) { // Now to put it into cache $fh = @fopen($cache_file, 'w') or message_die(GENERAL_ERROR, 'Syntax Highlighter cache file could not be written: CHMOD the cache/syntax directory to 777'); @flock($fh, LOCK_EX); @fputs($fh, $source); @flock($fh, LOCK_UN); @fclose($fh); } } return $source; } }
if ($post['post_id'] != $post['topic_first_post_id']) { $topic_title = 'RE: ' . $topic_title; } // Variable reassignment and reformatting for author $author = $post['username']; $author0 = $author; if ($post['user_id'] != -1) { $author = '<a href="' . $index_url . 'profile.' . $phpEx . '?mode=viewprofile&u=' . $post['user_id'] . '" target="_blank">' . $author . '</a>'; } else { // Uncomment next string if you want or $author0=='Anonymus'. // $author0= $post['post_username']; $author = $post['post_username']; } $author = make_clickable($author); // Assign "item" variables to template $template->assign_block_vars('post_item', array('POST_URL' => $viewpost_url . '?' . POST_POST_URL . '=' . $post['post_id'] . '#' . $post['post_id'], 'FIRST_POST_URL' => $viewpost_url . '?' . POST_POST_URL . '=' . $post['topic_first_post_id'] . '#' . $post['topic_first_post_id'], 'REPLY_URL' => $replypost_url . "&" . POST_POST_URL . "=" . $post['post_id'], 'TOPIC_TITLE' => htmlspecialchars(undo_htmlspecialchars($topic_title)), 'AUTHOR0' => htmlspecialchars($author0), 'AUTHOR' => htmlspecialchars($author), 'POST_TIME' => create_date($board_config['default_dateformat'], $post['post_time'], $board_config['board_timezone']) . ' (GMT ' . $board_config['board_timezone'] . ')', 'ATOM_TIME' => gmdate("Y-m-d\\TH:i:s", $post['post_time']) . "Z", 'ATOM_TIME_M' => $post['post_edit_time'] != "" ? gmdate("Y-m-d\\TH:i:s", $post['post_edit_time']) . "Z" : gmdate("Y-m-d\\TH:i:s", $post['post_time']) . "Z", 'POST_SUBJECT' => $post_subject, 'FORUM_NAME' => htmlspecialchars($post['forum_name']), 'UTF_TIME' => RSSTimeFormat($post['post_time'], $userdata['user_timezone']), 'POST_TEXT' => htmlspecialchars(preg_replace('|[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1f]|', '', $message)), 'USER_SIG' => htmlspecialchars($user_sig), 'TOPIC_REPLIES' => $post['topic_replies'])); } // // END "item" loop // if ($user_id != ANONYMOUS && UPDATE_VIEW_COUNT) { $updlist = ''; foreach ($SeenTopics as $topic_id => $tcount) { $updlist .= empty($updlist) ? $topic_id : "," . $topic_id; if (defined('TOPIC_VIEW_TABLE') and AUTO_WVT_MOD) { $sql = 'UPDATE ' . TOPIC_VIEW_TABLE . ' SET topic_id="' . $topic_id . '", view_time="' . time() . '", view_count=view_count+1 WHERE topic_id=' . $topic_id . ' AND user_id=' . $user_id; if (!$db->sql_query($sql) || !$db->sql_affectedrows()) { $sql = 'INSERT IGNORE INTO ' . TOPIC_VIEW_TABLE . ' (topic_id, user_id, view_time,view_count) VALUES (' . $topic_id . ', "' . $user_id . '", "' . time() . '","1")'; if (!$db->sql_query($sql)) { ExitWithHeader("500 Internal Server Error", 'Error create user view topic information');
/** * xml2array() will convert the given XML text to an array in the XML * structure. Link: http://www.bin-co.com/php/scripts/xml2array/ * * If $get_attributes is 1 the function will get the attributes as well as the * tag values - this results in a different array structure in the return * value * * This is because in specific cases we need that element to be array of * arrays, otherwise we'd always need to check for an exception in analyzing * the array * * @param string $contents * @param boolean $get_attributes * @param string $on_element_make_parent_array * @return array */ function xml2array($contents, $get_attributes = 1, $on_element_make_parent_array = array()) { if (!extension_loaded('xml') || !function_exists('xml_parser_create')) { return new Error('XML extension is not available in your PHP setup (http://www.php.net/manual/en/ref.xml.php)', true); } // if if (!$contents) { return array(); } // if //Get the XML parser of PHP - PHP must have this module for the parser to work $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $contents, $xml_values); xml_parser_free($parser); if (!$xml_values) { return; } //Hmm... //Initializations $xml_array = array(); $parents = array(); $opened_tags = array(); $arr = array(); $current =& $xml_array; //Go through the tags. foreach ($xml_values as $data) { unset($attributes, $value); //Remove existing values, or there will be trouble //This command will extract these variables into the foreach scope // tag(string), type(string), level(int), attributes(array). extract($data); //We could use the array by itself, but this cooler. $result = ''; if ($get_attributes) { //The second argument of the function decides this. $result = array(); if (isset($value)) { $result['value'] = undo_htmlspecialchars($value); } // if //Set the attributes too. if (isset($attributes)) { foreach ($attributes as $attr => $val) { if ($get_attributes == 1) { $result['attr'][$attr] = undo_htmlspecialchars($val); } //Set all the attributes in a array called 'attr' /** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */ } } } elseif (isset($value)) { $result = undo_htmlspecialchars($value); } //See tag status and do the needed. if ($type == "open") { //The starting of the tag '<tag>' $parent[$level - 1] =& $current; if (!is_array($current) or !in_array($tag, array_keys($current))) { //Insert New tag if (in_array($tag, $on_element_make_parent_array)) { // blame Oliver $current[$tag][0] = $result; $current =& $current[$tag][0]; } else { $current[$tag] = $result; $current =& $current[$tag]; } } else { //There was another element with the same tag name if (isset($current[$tag][0])) { array_push($current[$tag], $result); } else { $current[$tag] = array($current[$tag], $result); } $last = count($current[$tag]) - 1; $current =& $current[$tag][$last]; } } elseif ($type == "complete") { //Tags that ends in 1 line '<tag />' //See if the key is already taken. if (!isset($current[$tag])) { //New Key if (in_array($tag, $on_element_make_parent_array)) { // blame Oliver, too $current[$tag]['0'] = $result; } else { $current[$tag] = $result; } } else { //If taken, put all things inside a list(array) if (is_array($current[$tag]) and $get_attributes == 0 or isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1) { array_push($current[$tag], $result); // ...push the new element into that array. } else { //If it is not an array... $current[$tag] = array($current[$tag], $result); //...Make it an array using using the existing value and the new value } } } elseif ($type == 'close') { //End of tag '</tag>' $current =& $parent[$level - 1]; } } return $xml_array; }