function csp_po_ajax_handle_dlg_show_source() { csp_po_check_security(); load_plugin_textdomain(CSP_PO_TEXTDOMAIN, PLUGINDIR.'/codestyling-localization','codestyling-localization'); list($file, $match_line) = explode(':', $_POST['file']); $l = filesize($_POST['path'].$file); $handle = fopen($_POST['path'].$file,'rb'); $content = str_replace(array("\r","\\$"),array('','$'), fread($handle, $l)); fclose($handle); $msgid = $_POST['msgid']; $msgid = csp_po_convert_js_input_for_source($msgid); if (strlen($msgid) > 0) { if (strpos($msgid, "\00") > 0) $msgid = explode("\00", $msgid); else $msgid = explode("\01", $msgid); //opera fix foreach($msgid as $item) { if (strpos($content, $item) === false) { //difficult to separate between real \n notation and LF brocken strings also \t $test = str_replace("\n", '\n', $item); if (strpos($content, $test) === false) { $test2 = str_replace('\t', "\t", $item); if (strpos($content, $test2) === false) { $test2 = str_replace('\t', "\t", $test); if (strpos($content, $test2) === true) { $item = $test2; } }else{ $item = $test2; } }else { $item = $test; } } $content = str_replace($item, "\1".$item."\2", $content); } } $content = htmlentities($content); $content = str_replace("\t"," ",$content); $content = preg_split("/\n/", $content); $c=0; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html><head><?php do_action('admin_head'); ?></head> <body onload="init();" style="margin:0; padding:0;font-family:monospace;font-size:13px;"> <table id="php_source" cellspacing="0" width="100%" style="padding:0; margin:0;"> <?php $open = 0; $closed = 0; foreach($content as $line) { $c++; $style = $c % 2 == 1 ? "#fff" : "#eee"; $open += substr_count($line,"\1"); $closed += substr_count($line,"\2"); $contained = preg_match("/(\1|\2)/", $line) || ($c == $match_line) || ($open != $closed); if ($contained) $style="#FFEF3F"; if (!preg_match("/(\01|\02)/", $line) && $contained) $line = "<span style='background-color:#f00; color:#fff;padding:0 3px;'>".$line."</span>"; if((substr_count($line,"\1") < substr_count($line,"\2")) && ($open == $closed)) $line = "<span style='background-color:#f00; color:#fff;padding:0 3px;'>".$line; if(substr_count($line,"\1") > substr_count($line,"\2")) $line .= "</span>"; $line = str_replace("\1", "<span style='background-color:#f00; color:#fff;padding:0 3px;'>", $line); $line = str_replace("\2", "</span>", $line); echo "<tr id=\"l-$c\" style=\"background-color:$style;\"><td align=\"right\" style=\"background-color:#888;padding-right:5px;\">$c</td><td nowrap=\"nowrap\" style=\"padding-left:5px;\">$line</td></tr>\n"; } ?> </table> <script type="text/javascript"> /* <![CDATA[ */ function init() { try{ window.scrollTo(0,document.getElementById('l-'+<?php echo max($match_line-15,1); ?>).offsetTop); }catch(e) { //silently kill errors if *.po files line numbers comes out of an outdated file and exceed the line range } } /* ]]> */ </script> </body> </html> <?php exit(); }
function csp_po_ajax_handle_dlg_show_source() { csp_po_check_security(); load_plugin_textdomain(CSP_PO_TEXTDOMAIN, PLUGINDIR . '/codestyling-localization/languages', 'codestyling-localization/languages'); list($file, $match_line) = explode(':', $_POST['file']); $l = filesize(strip_tags($_POST['path']) . $file); $handle = fopen(strip_tags($_POST['path']) . $file, 'rb'); $content = str_replace(array("\r", "\\\$"), array('', '$'), fread($handle, $l)); fclose($handle); $msgid = $_POST['msgid']; $msgid = csp_po_convert_js_input_for_source($msgid); if (strlen($msgid) > 0) { if (strpos($msgid, "") > 0) { $msgid = explode("", $msgid); } else { $msgid = explode("", $msgid); } //opera fix foreach ($msgid as $item) { if (strpos($content, $item) === false) { //difficult to separate between real \n notation and LF brocken strings also \t $test = str_replace("\n", '\\n', $item); if (strpos($content, $test) === false) { $test2 = str_replace('\\t', "\t", $item); if (strpos($content, $test2) === false) { $test2 = str_replace('\\t', "\t", $test); if (strpos($content, $test2) === true) { $item = $test2; } } else { $item = $test2; } } else { $item = $test; } } $content = str_replace($item, "" . $item . "", $content); } } $tmp = htmlentities($content, ENT_COMPAT, 'UTF-8'); if (empty($tmp)) { $tmp = htmlentities($content, ENT_COMPAT); } $content = str_replace("\t", " ", $tmp); $content = preg_split("/\n/", $content); $c = 0; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head> <body style="margin:0; padding:0;font-family:monospace;font-size:13px;"> <table id="php_source" cellspacing="0" width="100%" style="padding:0; margin:0;"> <?php $open = 0; $closed = 0; foreach ($content as $line) { $c++; $style = $c % 2 == 1 ? "#fff" : "#eee"; $open += substr_count($line, ""); $closed += substr_count($line, ""); $contained = preg_match("/(|)/", $line) || $c == $match_line || $open != $closed; if ($contained) { $style = "#FFEF3F"; } if (!preg_match("/(|)/", $line) && $contained) { $line = "<span style='background-color:#f00; color:#fff;padding:0 3px;'>" . $line . "</span>"; } if (substr_count($line, "") < substr_count($line, "") && $open == $closed) { $line = "<span style='background-color:#f00; color:#fff;padding:0 3px;'>" . $line; } if (substr_count($line, "") > substr_count($line, "")) { $line .= "</span>"; } $line = str_replace("", "<span style='background-color:#f00; color:#fff;padding:0 3px;'>", $line); $line = str_replace("", "</span>", $line); echo "<tr id=\"l-{$c}\" style=\"background-color:{$style};\"><td align=\"right\" style=\"background-color:#888;padding-right:5px;\">{$c}</td><td nowrap=\"nowrap\" style=\"padding-left:5px;\">{$line}</td></tr>\n"; } ?> </table> <script type="text/javascript"> /* <![CDATA[ */ function init() { try{ window.scrollTo(0,document.getElementById('l-'+<?php echo max($match_line - 15, 1); ?> ).offsetTop); }catch(e) { //silently kill errors if *.po files line numbers comes out of an outdated file and exceed the line range } } if (typeof Event == 'undefined') Event = new Object(); Event.domReady = { add: function(fn) { //----------------------------------------------------------- // Already loaded? //----------------------------------------------------------- if (Event.domReady.loaded) return fn(); //----------------------------------------------------------- // Observers //----------------------------------------------------------- var observers = Event.domReady.observers; if (!observers) observers = Event.domReady.observers = []; // Array#push is not supported by Mac IE 5 observers[observers.length] = fn; //----------------------------------------------------------- // domReady function //----------------------------------------------------------- if (Event.domReady.callback) return; Event.domReady.callback = function() { if (Event.domReady.loaded) return; Event.domReady.loaded = true; if (Event.domReady.timer) { clearInterval(Event.domReady.timer); Event.domReady.timer = null; } var observers = Event.domReady.observers; for (var i = 0, length = observers.length; i < length; i++) { var fn = observers[i]; observers[i] = null; fn(); // make 'this' as window } Event.domReady.callback = Event.domReady.observers = null; }; //----------------------------------------------------------- // Emulates 'onDOMContentLoaded' //----------------------------------------------------------- var ie = !!(window.attachEvent && !window.opera); var webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1; if (document.readyState && webkit) { // Apple WebKit (Safari, OmniWeb, ...) Event.domReady.timer = setInterval(function() { var state = document.readyState; if (state == 'loaded' || state == 'complete') { Event.domReady.callback(); } }, 50); } else if (document.readyState && ie) { // Windows IE var src = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)'; document.write( '<script type="text/javascript" defer="defer" src="' + src + '" ' + 'onreadystatechange="if (this.readyState == \'complete\') Event.domReady.callback();"' + '><\/script>'); } else { if (window.addEventListener) { // for Mozilla browsers, Opera 9 document.addEventListener("DOMContentLoaded", Event.domReady.callback, false); // Fail safe window.addEventListener("load", Event.domReady.callback, false); } else if (window.attachEvent) { window.attachEvent('onload', Event.domReady.callback); } else { // Legacy browsers (e.g. Mac IE 5) var fn = window.onload; window.onload = function() { Event.domReady.callback(); if (fn) fn(); } } } } } Event.domReady.add(init); /* ]]> */ </script> </body> </html> <?php exit; }