Advertisement
plirof2

daad_php_parser_v005.4

Jun 6th, 2022 (edited)
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // CHECK GITHUB....
  3. /*
  4. 220606 - parser_v005.4
  5. 220604 - parser_v003
  6.  
  7. ToDO:
  8. https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_tooltip
  9. https://github.com/nataliapc/msx2daad/wiki/MSX2DAAD-Wiki%3A-Understanding-DSF-file-format
  10.  
  11. */
  12. $filename="xx5f1.DSF";
  13. $min_height=500; //min_height:500
  14. $min_width="1100";//,min_width:800
  15. $font_size= 18;//font_size: 18
  16. $mtx_array=array();
  17.  
  18.  
  19. $debug=false;
  20. $table_var_array=["CTL","VOC","STX","MTX","OTX","LTX","CON","OBJ","PRO0","PRO1","PRO2","PRO3","PRO4","PRO5","PRO6","PRO7","PRO8","PRO9","PRO10"];
  21. $table_description=["Control section","Vocabulary sectio","System Message Text section","Message Text section","Object Text section","Location Text section","Connections section","Object Definition section","PRO0","PRO1","PRO2","PRO3","PRO4","PRO5","PRO6","PRO7","PRO8","PRO9","PRO10"];
  22.  
  23. for($i = 0; $i <= 18; $i++) {
  24.      
  25.      ${$table_var_array[$i]} = $table_var_array[$i];
  26.      echo " <a href=#${$table_var_array[$i]}>$table_var_array[$i]</a> |";//."<br>";
  27.  
  28. }
  29. //if ($debug) print_r($table_var_array);
  30.  
  31.  
  32.  
  33.  
  34. ?><!DOCTYPE html>
  35. <html>
  36. <head>
  37.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  38.     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  39.     <script src="https://code.jquery.com/jquery-latest.min.js"></script>
  40.  
  41.  <!--  
  42.  
  43. Changes:
  44. -220214 - Edit-Area test002
  45. -201019 - hidesubmit option
  46.  
  47.  
  48. -->
  49. <script language="javascript" type="text/javascript" src="edit_area/edit_area_full.js"></script>
  50.  
  51.  
  52.  
  53.   <script>
  54. <?php
  55.  
  56. for($i = 0; $i <= 18; $i++) {
  57.      
  58.      //${$table_var_array[$i]} = $table_var_array[$i];
  59.      if ($debug)echo "<BR> $table_var_array[$i] = ". ${$table_var_array[$i]}."<br>";
  60.  
  61.      echo '
  62.        
  63.         editAreaLoader.init({
  64.         id : "text_entered_'.${$table_var_array[$i]}.'"     // textarea id
  65.         ,syntax: "basicsinclair"            // syntax to be uses for highgliting
  66.         ,start_highlight: true // to display with highlight mode on start-up
  67.         ,allow_resize:"both"
  68.         ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap,syntax_selection, |, help"
  69.         ,min_height:500
  70.         ,min_width:'.$min_width.'
  71.         ,font_size: 18
  72.  
  73. });
  74.      ';
  75.  
  76.  
  77. }; //END of for($i = 0; $i <= 19; $i++) {
  78.  
  79.  
  80. ?>
  81.  
  82. /*
  83. editAreaLoader.init({
  84.     id : "text_entered_CTL"     // textarea id
  85.     ,syntax: "basicsinclair"            // syntax to be uses for highgliting
  86.     ,start_highlight: true // to display with highlight mode on start-up
  87.     ,allow_resize:"both"
  88.     ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap,syntax_selection, |, help"
  89.     ,min_height:500
  90.     ,min_width:800
  91.     ,font_size: 18
  92.  
  93. });
  94.  
  95. editAreaLoader.init({
  96.     id : "text_entered_VOC"     // textarea id
  97.     ,syntax: "basicsinclair"            // syntax to be uses for highgliting
  98.     ,start_highlight: true // to display with highlight mode on start-up
  99.     ,allow_resize:"both"
  100.     ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap,syntax_selection, |, help"
  101.     ,min_height:500
  102.     ,min_width:800
  103.     ,font_size: 18
  104.  
  105. });
  106. */
  107.  
  108.  
  109.  
  110.  
  111.    
  112.  
  113.  
  114.     function myFunction_CTL (){
  115.  
  116.         //document.getElementById('theForm').submit();
  117.         var x = document.getElementsByName('theForm');
  118.         editAreaLoader.setValue(editAreaLoader.getValue('text_entered'));
  119.         x[0].submit(); // Form submission
  120.     }
  121. </script>
  122. </head>
  123. <body>
  124.  
  125. <?php
  126. $myfile = fopen($filename, "r") or die("Unable to open file!");
  127. $contents=fread($myfile,filesize($filename));
  128. //echo $contents;
  129. fclose($myfile);
  130.  
  131.  
  132. function get_string_between($string, $start, $end){
  133.     $string = " ".$string;
  134.     $ini = strpos($string,$start);
  135.     if ($ini == 0) return "";
  136.     $ini += strlen($start);  
  137.     $len = strpos($string,$end,$ini) - $ini;
  138.     return substr($string,$ini,$len);
  139. }
  140.  
  141. //$fullstring = "this is my [tag]dog[/tag]";
  142. //$parsed = get_string_between($fullstring, "[tag]", "[/tag]");
  143.  
  144. //echo $parsed; // (result = dog)
  145.  
  146.  
  147. $CTL=get_string_between($contents, '/CTL', '/VOC');
  148. $VOC=get_string_between($contents, '/VOC', '/STX');
  149. $STX=get_string_between($contents, '/STX', '/MTX');
  150. $MTX=get_string_between($contents, '/MTX', '/OTX');
  151. $OTX=get_string_between($contents, '/OTX', '/LTX');
  152. $LTX=get_string_between($contents, '/LTX', '/CON');
  153. $CON=get_string_between($contents, '/CON', '/OBJ');
  154. $OBJ=get_string_between($contents, '/OBJ', '/PRO 0');
  155.  
  156. $PRO0=get_string_between($contents, '/PRO 0', '/PRO 1');
  157. $PRO1=get_string_between($contents, '/PRO 1', '/PRO 2');
  158. $PRO2=get_string_between($contents, '/PRO 2', '/PRO 3');
  159. $PRO3=get_string_between($contents, '/PRO 3', '/PRO 4');
  160. $PRO4=get_string_between($contents, '/PRO 4', '/PRO 5');
  161. $PRO5=get_string_between($contents, '/PRO 5', '/PRO 6');
  162. $PRO6=get_string_between($contents, '/PRO 6', '/PRO 7');
  163. $PRO7=get_string_between($contents, '/PRO 7', '/PRO 8');
  164. $PRO8=get_string_between($contents, '/PRO 8', '/PRO 9');
  165. $PRO9=get_string_between($contents, '/PRO 9', '/PRO 10');
  166. $PRO10=get_string_between($contents, '/PRO 10', '/END');
  167.  
  168.  
  169. for($i = 0; $i <= 7; $i++) {
  170.      ${"variable$i"} = "foo";
  171. }
  172.  
  173. //$LNK=get_string_between($contents, '/LNK', '/VOC');
  174. //$OBJ=get_string_between($contents, '/OBJ', '/VOC');
  175. //$OBJ=get_string_between($contents, '/OBJ', '/VOC');
  176.  
  177.  
  178.  
  179.  
  180. //MTX
  181. foreach(preg_split("/((\r?\n)|(\r\n?))/", $MTX) as $line){
  182.     //echo "<h3>MTX : $line</h3>";
  183.     //$MTX
  184.     if(substr($line,0,1)==";") continue; //echo "<br>".$line."KKKKKKKKKKKKK";
  185.     $mtx_idx=get_string_between($line,"/","\""); //echo "<HR>".$line."AAAAAAAAAA=".$mtx_idx;
  186.     //if (is_numeric($mtx_idx)) {
  187.         echo "INSIDE.............................................";
  188.         $mtx_txt=get_string_between($line,'"','"');
  189.         //echo "<HR>".$line."nbbbbbbbbbbb22222=".$mtx_txt;
  190.         $mtx_array[$mtx_idx]=$mtx_txt;
  191.     //}
  192.     //$mtx_array[]
  193.     print_r($mtx_array);
  194.  
  195.     // do stuff with $line
  196. }
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210. ?>
  211.  
  212.     <form action="handle-submit.php" name="theForm" target="emulator_output" id="theForm" method="post" onsubmit="editAreaLoader.getValue('text_entered_CTL')">
  213.  
  214. <!--
  215. <textarea name="text_entered_CTL" id="text_entered_CTL" wrap="hard" >
  216. /CTL
  217. <?php
  218. echo $CTL;
  219. ?>
  220. </textarea>
  221. <BR>
  222.  
  223. -->
  224.  
  225.  
  226.  
  227.     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris rutrum ante nunc. Proin sit amet sem purus
  228.  
  229.  
  230. <?php
  231.  
  232. for($i = 0; $i <= 18; $i++) {
  233.      
  234.      //${$table_var_array[$i]} = $table_var_array[$i];
  235.      if ($debug)echo "<BR> $table_var_array[$i] = ". ${$table_var_array[$i]}."<br>";
  236.  
  237.      echo "<div id=$table_var_array[$i]><h3>/$table_var_array[$i]</h3></div>".'
  238.  
  239. <textarea name="text_entered_'.$table_var_array[$i].'" id="text_entered_'.$table_var_array[$i].'" wrap="hard" >'.
  240. //'/'.$table_var_array[$i].//'<BR>'.
  241. ${"$table_var_array[$i]"}
  242. .'</textarea>
  243. <BR>
  244.  
  245.      ';
  246.  
  247.  
  248. }; //END of for($i = 0; $i <= 19; $i++) {
  249.  
  250. ?>
  251.  
  252.  
  253.  
  254.  
  255.  
  256.         <!--<div id="div-submit" >----------------------------div-submit -->
  257.         <label for="name">filename:</label> <!--SchoolName -->
  258.         <input type="text" id="schoolname" name="schoolname" size=15>
  259.         <br>
  260.         <button onclick="myFunction_CTL()">Click me CTL</button>
  261.         <br>
  262.         <input type="submit" value="ΥΠΟΒΟΛΗ">
  263.         <!--</div>------------------------------------------div-submit -->
  264.     </form>
  265. <pre>
  266. <p class="clickable">
  267.  
  268. <?php
  269. //echo "$contents";
  270.  
  271.  
  272.  
  273. for($i = 0; $i <= 18; $i++) {
  274.      
  275.      //${$table_var_array[$i]} = $table_var_array[$i];
  276.      //if ($debug)echo "<BR> $table_var_array[$i] = ". ${$table_var_array[$i]}."<br>";
  277.  
  278.      echo "/$table_var_array[$i]<BR>".${"$table_var_array[$i]"}.
  279.      '<BR>     ';
  280.  
  281.  
  282. }; //END of for($i = 0; $i <= 19; $i++) {
  283.  
  284.  
  285. ?>
  286.  
  287. </p>
  288. </pre>
  289. <script type="text/javascript">
  290.  
  291.     function strcmp(a, b)
  292.     {  
  293.         return (a<b?-1:(a>b?1:0));  
  294.     }
  295.  
  296.  
  297.     function search_word (str){
  298.         console.log(str);
  299.         //document.getElementById('theForm').submit();
  300.         //var x = document.getElementsByName('theForm');
  301.         //editAreaLoader.setValue(editAreaLoader.getValue('text_entered'));
  302.         //x[0].submit(); // Form submission
  303.         if(strcmp(str,"mes 1") ) alert ("AAAAAAAAAAA");
  304.         alert(str);
  305.     }  
  306. </script>
  307.  
  308. <script type="text/javascript">
  309.     $(".clickable").click(function(e){
  310.          s = window.getSelection();
  311.          var range = s.getRangeAt(0);
  312.          var node = s.anchorNode;
  313.          
  314.          // Find starting point
  315.          while(range.toString().indexOf(' ') != 0) {                
  316.             range.setStart(node,(range.startOffset -1));
  317.          }
  318.          range.setStart(node, range.startOffset +1);
  319.          
  320.          // Find ending point
  321.          do{
  322.            range.setEnd(node,range.endOffset + 1);
  323.  
  324.         }while(range.toString().indexOf(' ') == -1 && range.toString().trim() != '');
  325.        
  326.         // Alert result
  327.         var str = range.toString().trim();
  328.         search_word(str);
  329.        });     
  330.  
  331. </script>
  332. </body>
  333. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement