/** * AJAX script for returning realtime-rain data. */ function realtime_rain_script() { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past @ini_set('ocproducts.xss_detect', '0'); header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="' . get_charset() . '"?' . '>'; echo '<request><result>'; require_code('realtime_rain'); require_lang('realtime_rain'); $time_now = time(); $from = get_param_integer('from', $time_now - 10); $to = get_param_integer('to', $time_now); if (get_param_integer('keep_realtime_test', 0) == 1) { $types = array('post', 'news', 'recommend', 'polls', 'ecommerce', 'actionlog', 'security', 'chat', 'stats', 'join', 'calendar', 'search', 'point_charges', 'banners', 'point_gifts'); shuffle($types); $events = array(); $cnt = count($types); for ($i = 0; $i < max($cnt, 5); $i++) { $timestamp = mt_rand($from, $to); $type = array_pop($types); $event = rain_get_special_icons(get_ip_address(), $timestamp) + array('TYPE' => $type, 'FROM_MEMBER_ID' => NULL, 'TO_MEMBER_ID' => NULL, 'TITLE' => 'Test', 'IMAGE' => rain_get_country_image(get_ip_address()), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => NULL, 'IS_POSITIVE' => $type == 'ecommerce' || $type == 'join', 'IS_NEGATIVE' => $type == 'security' || $type == 'point_charges', 'FROM_ID' => NULL, 'TO_ID' => NULL, 'GROUP_ID' => 'example_' . strval(mt_rand(0, 4))); $event['SPECIAL_ICON'] = 'email-icon'; $event['MULTIPLICITY'] = '10'; $events[] = $event; } } else { $events = get_realtime_events($from, $to); } shuffle($events); $out = new ocp_tempcode(); foreach ($events as $event) { $out->attach(do_template('REALTIME_RAIN_BUBBLE', $event)); } $out->evaluate_echo(); echo '</result></request>'; }
/** * Show results of running a validation function. * * @param string The data validated * @param array Error information * @param boolean Whether we are opening up an XHTML-fragment in a preview box * @param boolean Whether to return Tempcode * @return string Returned result (won't return it $ret is false) */ function display_validation_results($out, $error, $preview_mode = false, $ret = false) { global $KEEP_MARKERS, $SHOW_EDIT_LINKS; $KEEP_MARKERS = false; $SHOW_EDIT_LINKS = false; global $XHTML_SPIT_OUT; $XHTML_SPIT_OUT = 1; if (function_exists('set_time_limit')) { @set_time_limit(280); } require_css('adminzone'); if (!$ret) { $echo = do_header($preview_mode); $echo->evaluate_echo(); } else { ob_start(); } $title = get_page_title('VALIDATION_ERROR'); // Escape and colourfy $i = 0; // Output header if (count($_POST) == 0) { $messy_url = get_param_integer('keep_markers', 0) == 1 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'special_page_type' => 'code', 'keep_markers' => 1), '_SELF', NULL, true); $ignore_url = build_url(array('page' => '_SELF', 'keep_novalidate' => 1), '_SELF', NULL, true); $ignore_url_2 = build_url(array('page' => '_SELF', 'novalidate' => 1), '_SELF', NULL, true); } else { $messy_url = new ocp_tempcode(); $ignore_url = new ocp_tempcode(); $ignore_url_2 = new ocp_tempcode(); } $error_lines = array(); $return_url = new ocp_tempcode(); if (count($error['errors']) != 0) { $errorst = new ocp_tempcode(); foreach ($error['errors'] as $j => $_error) { $errorst->attach(do_template('VALIDATE_ERROR', array('_GUID' => '2239470f4b9bd38fcb570689cecaedd2', 'I' => strval($j), 'LINE' => integer_format($_error['line']), 'POS' => integer_format($_error['pos']), 'ERROR' => $_error['error']))); $error_lines[$_error['line']] = 1; } $errors = $errorst->evaluate(); $echo = do_template('VALIDATE_ERROR_SCREEN', array('_GUID' => 'db6c362632471e7c856380d32da91054', 'MSG' => do_lang_tempcode('_NEXT_ITEM_BACK'), 'RETURN_URL' => $return_url, 'TITLE' => $title, 'IGNORE_URL_2' => $ignore_url_2, 'IGNORE_URL' => $ignore_url, 'MESSY_URL' => $messy_url, 'ERRORS' => $errorst, 'RET' => $ret)); unset($errorst); $echo->evaluate_echo(); } else { $echo = do_template('VALIDATE_SCREEN', array('_GUID' => 'd8de848803287e4c592418d57450b7db', 'MSG' => do_lang_tempcode('_NEXT_ITEM_BACK'), 'RETURN_URL' => $return_url, 'TITLE' => get_page_title('VIEWING_SOURCE'), 'MESSY_URL' => $messy_url, 'RET' => $ret)); $echo->evaluate_echo(); } $level_ranges = $error['level_ranges']; $tag_ranges = $error['tag_ranges']; $value_ranges = $error['value_ranges']; $current_range = 0; $current_tag = 0; $current_value = 0; $number = 1; $in_at = false; for ($i = 0; $i < strlen($out); ++$i) { if (isset($level_ranges[$current_range])) { $level = $level_ranges[$current_range][0]; $start = $level_ranges[$current_range][1]; if ($start == 0) { $start = 1; } // Hack for when error starts before a line, messing up our output if ($i == $start) { $x = 8; if ($level % $x == 0) { $colour = 'teal'; } if ($level % $x == 1) { $colour = 'blue'; } if ($level % $x == 2) { $colour = 'purple'; } if ($level % $x == 3) { $colour = 'gray'; } if ($level % $x == 4) { $colour = 'red'; } if ($level % $x == 5) { $colour = 'maroon'; } if ($level % $x == 6) { $colour = 'navy'; } if ($level % $x == 7) { $colour = 'olive'; } $previous = $i == 0 ? '' : $out[$i - 1]; $string = new ocp_tempcode(); if ($previous == ' ' || $previous == chr(10) || $previous == chr(13)) { $string->attach(str_pad('', $level * 3 * 6, ' ')); } $string->attach(do_template('VALIDATE_TAG_START', array('_GUID' => '3a4c99283d32006143fc688ce8f2cadc', 'COLOUR' => $colour))); $string->evaluate_echo(); } } if (isset($tag_ranges[$current_tag])) { $start = $tag_ranges[$current_tag][0]; if ($i == $start) { $string = do_template('VALIDATE_TAG_NAME_START'); $string->evaluate_echo(); } } if (isset($value_ranges[$current_value])) { $start = $value_ranges[$current_value][0]; if ($i == $start) { $in_at = true; $string = do_template('VALIDATE_ATTRIBUTE_START'); $string->evaluate_echo(); } } $char = $out[$i]; if ($char == chr(10) || $i == 0) { if ($number > 1) { $escaped_code = do_template('VALIDATE_LINE_END'); $escaped_code->evaluate_echo(); } if (isset($error_lines[$number])) { $markers = new ocp_tempcode(); foreach ($error['errors'] as $j => $_error) { if ($number == $_error['line']) { $markers->attach(do_template('VALIDATE_MARKER', array('_GUID' => '4b1898d5f1e0f56d18a47561659da3bb', 'I' => strval($j), 'ERROR' => $_error['error']))); } } $escaped_code = do_template('VALIDATE_LINE_ERROR', array('_GUID' => '2ffa5c26090d3d814206e3a9e46c7b4e', 'MARKERS' => $markers, 'NUMBER' => integer_format($number))); $escaped_code->evaluate_echo(); } else { $escaped_code = do_template('VALIDATE_LINE', array('_GUID' => '4994f4748c3cd0cbf4e9278ca0e9b1fc', 'NUMBER' => integer_format($number))); $escaped_code->evaluate_echo(); } ++$number; } // Marker $end_markers = new ocp_tempcode(); if (isset($error_lines[$number])) { foreach ($error['errors'] as $_error) { if ($i == $_error['global_pos']) { $_text = do_template('VALIDATE_MARKER_START'); $_text->evaluate_echo(); if ($char == chr(13) || $char == chr(10)) { $__text = '!' . do_lang('HERE') . '!'; if (function_exists('ocp_mark_as_escaped')) { ocp_mark_as_escaped($__text); } echo $__text; } $end_markers->attach(do_template('VALIDATE_MARKER_END')); } } } // Escaping if ($char == '&') { $char = '&'; } if ($char == '<') { $char = '<'; } if ($char == '>') { $char = '>'; } if ($char == '"') { $char = '"'; } if ($char == '\'') { $char = '''; } if (is_null($level_ranges) && $char == ' ') { $char = ' '; } if (is_null($level_ranges) && $char == "\t") { $char = ' '; } // if ($char==' ') $char=' '; if (function_exists('ocp_mark_as_escaped')) { ocp_mark_as_escaped($char); } echo $char; // Marker $end_markers->evaluate_echo(); if (isset($value_ranges[$current_value])) { $end = $value_ranges[$current_value][1]; if ($i == $end - 1) { if ($in_at) { $text = do_template('VALIDATE_ATTRIBUTE_END'); $text->evaluate_echo(); } $in_at = false; ++$current_value; } } if (isset($level_ranges[$current_range])) { $end = $level_ranges[$current_range][2]; if ($i == $end - 1) { $string = do_template('VALIDATE_TAG_END'); $string->evaluate_echo(); ++$current_range; while (isset($level_ranges[$current_range]) && $level_ranges[$current_range][1] <= $i) { ++$current_range; } } } if (isset($tag_ranges[$current_tag])) { $end = $tag_ranges[$current_tag][1]; if ($i == $end - 1) { $string = do_template('VALIDATE_TAG_NAME_END'); $string->evaluate_echo(); ++$current_tag; } } } if ($number > 1) { $escaped_code = do_template('VALIDATE_LINE_END'); $escaped_code->evaluate_echo(); } $echo = do_template('VALIDATE_SCREEN_END', array('_GUID' => '739514a06ae65252293fc62b1c7cec40', 'RET' => $ret)); $echo->evaluate_echo(); if (!$ret) { $echo = do_footer(); $echo->evaluate_echo(); exit; } $out = ob_get_contents(); ob_end_clean(); return $out; }