SHOW:
|
|
- or go back to the newest paste.
| 1 | - | <? |
| 1 | + | <? |
| 2 | - | // конвертер таблиц в html код, просто копируете таблицу в буфер обмена из любого источника и вставляете в поле ввода /skray/ |
| 2 | + | // конвертер таблиц в html код, просто копируете таблицу в буфер обмена из любого источника и вставляете в поле ввода /skray/ |
| 3 | - | |
| 3 | + | |
| 4 | - | echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> |
| 4 | + | echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> |
| 5 | - | <html> |
| 5 | + | <html> |
| 6 | - | <head> |
| 6 | + | <head> |
| 7 | - | <title>csvhtml</title> |
| 7 | + | <title>csvhtml</title> |
| 8 | - | <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\"> |
| 8 | + | <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\"> |
| 9 | - | </head><body> |
| 9 | + | </head><body> |
| 10 | - | <form method=POST > |
| 10 | + | <form method=POST > |
| 11 | - | <textarea style=\"font-size:10px;FONT-FAMILY:arial; width:600px; height:500px;\" name=\"file\" >$post</textarea> |
| 11 | + | <textarea style=\"font-size:10px;FONT-FAMILY:arial; width:600px; height:500px;\" name=\"file\" >$post</textarea> |
| 12 | - | <input type=\"hidden\" name=\"conv\" value=\"1\"> |
| 12 | + | <input type=\"hidden\" name=\"conv\" value=\"1\"> |
| 13 | - | <input type=\"hidden\" name=\"opi\"> |
| 13 | + | <input type=\"hidden\" name=\"opi\"> |
| 14 | - | <input type=\"submit\" value=\"submit\"> |
| 14 | + | <input type=\"submit\" value=\"submit\"> |
| 15 | - | </form> |
| 15 | + | </form> |
| 16 | - | </td><td valign=\"top\">"; |
| 16 | + | </td><td valign=\"top\">"; |
| 17 | - | |
| 17 | + | |
| 18 | - | $file=isset($_POST['file'])?explode("\r\n",$_POST['file']):""; |
| 18 | + | $file=isset($_POST['file'])?explode("\r\n",$_POST['file']):"";
|
| 19 | - | |
| 19 | + | |
| 20 | - | $count=count($file); |
| 20 | + | $count=count($file); |
| 21 | - | echo'<!-- подсветка синтаксиса --> |
| 21 | + | echo'<!-- подсветка синтаксиса --> |
| 22 | - | <script type="text/javascript" src="http://yandex.st/highlightjs/5.12/highlight.min.js"></script> |
| 22 | + | <script type="text/javascript" src="http://yandex.st/highlightjs/5.12/highlight.min.js"></script> |
| 23 | - | <link rel="stylesheet" href="http://yandex.st/highlightjs/5.12/styles/vs.min.css" /> |
| 23 | + | <link rel="stylesheet" href="http://yandex.st/highlightjs/5.12/styles/vs.min.css" /> |
| 24 | - | <script type="text/javascript"> |
| 24 | + | <script type="text/javascript"> |
| 25 | - | hljs.initHighlightingOnLoad(); |
| 25 | + | hljs.initHighlightingOnLoad(); |
| 26 | - | </script> |
| 26 | + | </script> |
| 27 | - | <!-- /подсветка синтаксиса --> |
| 27 | + | <!-- /подсветка синтаксиса --> |
| 28 | - | '; |
| 28 | + | '; |
| 29 | - | echo "<pre><code><table><br>"; |
| 29 | + | echo "<pre><code><table><br>"; |
| 30 | - | for($i=0;$i<$count;$i++) |
| 30 | + | for($i=0;$i<$count;$i++) |
| 31 | - | { |
| 31 | + | {
|
| 32 | - | $ff=preg_replace("/\"/","",$file[$i]); |
| 32 | + | $ff=preg_replace("/\"/","",$file[$i]);
|
| 33 | - | $ff=preg_replace("/</","<",$ff); |
| 33 | + | $ff=preg_replace("/</","<",$ff);
|
| 34 | - | $ff=preg_replace("/>/",">",$ff); |
| 34 | + | $ff=preg_replace("/>/",">",$ff);
|
| 35 | - | $td=explode("\t",$ff); |
| 35 | + | $td=explode("\t",$ff);
|
| 36 | - | $counttd=count($td); |
| 36 | + | $counttd=count($td); |
| 37 | - | $fd="";$odd=""; |
| 37 | + | $fd="";$odd=""; |
| 38 | - | $fdr="<tr>"; |
| 38 | + | $fdr="<tr>"; |
| 39 | - | for($r=0;$r<$counttd;$r++) |
| 39 | + | for($r=0;$r<$counttd;$r++) |
| 40 | - | { |
| 40 | + | {
|
| 41 | - | $trm=$td[$r]; |
| 41 | + | $trm=$td[$r]; |
| 42 | - | $fd.=$trm; |
| 42 | + | $fd.=$trm; |
| 43 | - | $fdr.="<td>$trm</td>"; |
| 43 | + | $fdr.="<td>$trm</td>"; |
| 44 | - | $odd.=$r==0?"<tr class=\"odd\"><td colspan=$counttd>$trm</td></tr><br>":""; |
| 44 | + | $odd.=$r==0?"<tr class=\"odd\"><td colspan=$counttd>$trm</td></tr><br>":""; |
| 45 | - | } |
| 45 | + | } |
| 46 | - | $fdr.="</tr><br>"; |
| 46 | + | $fdr.="</tr><br>"; |
| 47 | - | $td0=trim($td[0]); |
| 47 | + | $td0=trim($td[0]); |
| 48 | - | $fd0=trim($fd); |
| 48 | + | $fd0=trim($fd); |
| 49 | - | if(empty($td0)) continue; |
| 49 | + | if(empty($td0)) continue; |
| 50 | - | echo $fd0==$td0?$odd:$fdr; |
| 50 | + | echo $fd0==$td0?$odd:$fdr; |
| 51 | - | } |
| 51 | + | } |
| 52 | - | echo "</table></code></pre>"; |
| 52 | + | echo "</table></code></pre>"; |
| 53 | - | echo' </td> |
| 53 | + | echo' </td> |
| 54 | - | </tr> |
| 54 | + | </tr> |
| 55 | - | </table> |
| 55 | + | </table> |
| 56 | - | </body> |
| 56 | + | </body> |
| 57 | - | </html> |
| 57 | + | </html> |
| 58 | - | '; |
| 58 | + | '; |
| 59 | ?> |