noalyss Version-9
function_javascript.php
Go to the documentation of this file.
1<?php
2//This file is part of NOALYSS and is under GPL
3//see licence.txt
4
5/*
6PHP URL encoding/decoding functions for Javascript interaction V3.0
7(C) 2006 www.captain.at - all rights reserved
8License: GPL
9*/
10/*!
11 *\brief create the HTML for including of a javascript file
12 * if a file is included twice, the second time it will be discarded
13 * there is an alert if the file doesn't exist
14 *\param $p_string name of the file
15 *\return the HTML script
16 */
17function js_include($p_string)
18{
19 global $version_noalyss;
20 static $ajs=array(); /* avoid to add twice the same script */
21 static $seq=0;
22 if ( in_array($p_string,$ajs)) return '';
23 $ajs[$seq]=$p_string;
24 $seq++;
25
26 if ( ! file_exists('js/'.$p_string))
27 alert("Erreur js/$p_string n existe pas");
28 $script='<script type="text/javascript" charset="utf-8" language="javascript" src="js/'.$p_string.'?version='.$version_noalyss.'"></script>';
29 // debug
30
31 return $script;
32
33}
34/*!
35 *\brief create the HTML for adding the script tags around of the script
36 *\param $p_string source codename of the file
37 *\return the HTML script
38 */
39function create_script($p_string)
40{
41 $script='<script type="text/javascript" charset="utf-8" language="javascript">'.$p_string.' </script>';
42 return $script;
43
44}
46{
47 $result = "";
48 for ($i = 0; $i < strlen($string); $i++)
49 {
51 }
52 return $result;
53}
54
56{
57 if ($char == "+")
58 {
59 return "%20";
60 }
61 if ($char == "%21")
62 {
63 return "!";
64 }
65 if ($char == "%27")
66 {
67 return '"';
68 }
69 if ($char == "%28")
70 {
71 return "(";
72 }
73 if ($char == "%29")
74 {
75 return ")";
76 }
77 if ($char == "%2A")
78 {
79 return "*";
80 }
81 if ($char == "%7E")
82 {
83 return "~";
84 }
85 if ($char == "%80")
86 {
87 return "%E2%82%AC";
88 }
89 if ($char == "%81")
90 {
91 return "%C2%81";
92 }
93 if ($char == "%82")
94 {
95 return "%E2%80%9A";
96 }
97 if ($char == "%83")
98 {
99 return "%C6%92";
100 }
101 if ($char == "%84")
102 {
103 return "%E2%80%9E";
104 }
105 if ($char == "%85")
106 {
107 return "%E2%80%A6";
108 }
109 if ($char == "%86")
110 {
111 return "%E2%80%A0";
112 }
113 if ($char == "%87")
114 {
115 return "%E2%80%A1";
116 }
117 if ($char == "%88")
118 {
119 return "%CB%86";
120 }
121 if ($char == "%89")
122 {
123 return "%E2%80%B0";
124 }
125 if ($char == "%8A")
126 {
127 return "%C5%A0";
128 }
129 if ($char == "%8B")
130 {
131 return "%E2%80%B9";
132 }
133 if ($char == "%8C")
134 {
135 return "%C5%92";
136 }
137 if ($char == "%8D")
138 {
139 return "%C2%8D";
140 }
141 if ($char == "%8E")
142 {
143 return "%C5%BD";
144 }
145 if ($char == "%8F")
146 {
147 return "%C2%8F";
148 }
149 if ($char == "%90")
150 {
151 return "%C2%90";
152 }
153 if ($char == "%91")
154 {
155 return "%E2%80%98";
156 }
157 if ($char == "%92")
158 {
159 return "%E2%80%99";
160 }
161 if ($char == "%93")
162 {
163 return "%E2%80%9C";
164 }
165 if ($char == "%94")
166 {
167 return "%E2%80%9D";
168 }
169 if ($char == "%95")
170 {
171 return "%E2%80%A2";
172 }
173 if ($char == "%96")
174 {
175 return "%E2%80%93";
176 }
177 if ($char == "%97")
178 {
179 return "%E2%80%94";
180 }
181 if ($char == "%98")
182 {
183 return "%CB%9C";
184 }
185 if ($char == "%99")
186 {
187 return "%E2%84%A2";
188 }
189 if ($char == "%9A")
190 {
191 return "%C5%A1";
192 }
193 if ($char == "%9B")
194 {
195 return "%E2%80%BA";
196 }
197 if ($char == "%9C")
198 {
199 return "%C5%93";
200 }
201 if ($char == "%9D")
202 {
203 return "%C2%9D";
204 }
205 if ($char == "%9E")
206 {
207 return "%C5%BE";
208 }
209 if ($char == "%9F")
210 {
211 return "%C5%B8";
212 }
213 if ($char == "%A0")
214 {
215 return "%C2%A0";
216 }
217 if ($char == "%A1")
218 {
219 return "%C2%A1";
220 }
221 if ($char == "%A2")
222 {
223 return "%C2%A2";
224 }
225 if ($char == "%A3")
226 {
227 return "%C2%A3";
228 }
229 if ($char == "%A4")
230 {
231 return "%C2%A4";
232 }
233 if ($char == "%A5")
234 {
235 return "%C2%A5";
236 }
237 if ($char == "%A6")
238 {
239 return "%C2%A6";
240 }
241 if ($char == "%A7")
242 {
243 return "%C2%A7";
244 }
245 if ($char == "%A8")
246 {
247 return "%C2%A8";
248 }
249 if ($char == "%A9")
250 {
251 return "%C2%A9";
252 }
253 if ($char == "%AA")
254 {
255 return "%C2%AA";
256 }
257 if ($char == "%AB")
258 {
259 return "%C2%AB";
260 }
261 if ($char == "%AC")
262 {
263 return "%C2%AC";
264 }
265 if ($char == "%AD")
266 {
267 return "%C2%AD";
268 }
269 if ($char == "%AE")
270 {
271 return "%C2%AE";
272 }
273 if ($char == "%AF")
274 {
275 return "%C2%AF";
276 }
277 if ($char == "%B0")
278 {
279 return "%C2%B0";
280 }
281 if ($char == "%B1")
282 {
283 return "%C2%B1";
284 }
285 if ($char == "%B2")
286 {
287 return "%C2%B2";
288 }
289 if ($char == "%B3")
290 {
291 return "%C2%B3";
292 }
293 if ($char == "%B4")
294 {
295 return "%C2%B4";
296 }
297 if ($char == "%B5")
298 {
299 return "%C2%B5";
300 }
301 if ($char == "%B6")
302 {
303 return "%C2%B6";
304 }
305 if ($char == "%B7")
306 {
307 return "%C2%B7";
308 }
309 if ($char == "%B8")
310 {
311 return "%C2%B8";
312 }
313 if ($char == "%B9")
314 {
315 return "%C2%B9";
316 }
317 if ($char == "%BA")
318 {
319 return "%C2%BA";
320 }
321 if ($char == "%BB")
322 {
323 return "%C2%BB";
324 }
325 if ($char == "%BC")
326 {
327 return "%C2%BC";
328 }
329 if ($char == "%BD")
330 {
331 return "%C2%BD";
332 }
333 if ($char == "%BE")
334 {
335 return "%C2%BE";
336 }
337 if ($char == "%BF")
338 {
339 return "%C2%BF";
340 }
341 if ($char == "%C0")
342 {
343 return "%C3%80";
344 }
345 if ($char == "%C1")
346 {
347 return "%C3%81";
348 }
349 if ($char == "%C2")
350 {
351 return "%C3%82";
352 }
353 if ($char == "%C3")
354 {
355 return "%C3%83";
356 }
357 if ($char == "%C4")
358 {
359 return "%C3%84";
360 }
361 if ($char == "%C5")
362 {
363 return "%C3%85";
364 }
365 if ($char == "%C6")
366 {
367 return "%C3%86";
368 }
369 if ($char == "%C7")
370 {
371 return "%C3%87";
372 }
373 if ($char == "%C8")
374 {
375 return "%C3%88";
376 }
377 if ($char == "%C9")
378 {
379 return "%C3%89";
380 }
381 if ($char == "%CA")
382 {
383 return "%C3%8A";
384 }
385 if ($char == "%CB")
386 {
387 return "%C3%8B";
388 }
389 if ($char == "%CC")
390 {
391 return "%C3%8C";
392 }
393 if ($char == "%CD")
394 {
395 return "%C3%8D";
396 }
397 if ($char == "%CE")
398 {
399 return "%C3%8E";
400 }
401 if ($char == "%CF")
402 {
403 return "%C3%8F";
404 }
405 if ($char == "%D0")
406 {
407 return "%C3%90";
408 }
409 if ($char == "%D1")
410 {
411 return "%C3%91";
412 }
413 if ($char == "%D2")
414 {
415 return "%C3%92";
416 }
417 if ($char == "%D3")
418 {
419 return "%C3%93";
420 }
421 if ($char == "%D4")
422 {
423 return "%C3%94";
424 }
425 if ($char == "%D5")
426 {
427 return "%C3%95";
428 }
429 if ($char == "%D6")
430 {
431 return "%C3%96";
432 }
433 if ($char == "%D7")
434 {
435 return "%C3%97";
436 }
437 if ($char == "%D8")
438 {
439 return "%C3%98";
440 }
441 if ($char == "%D9")
442 {
443 return "%C3%99";
444 }
445 if ($char == "%DA")
446 {
447 return "%C3%9A";
448 }
449 if ($char == "%DB")
450 {
451 return "%C3%9B";
452 }
453 if ($char == "%DC")
454 {
455 return "%C3%9C";
456 }
457 if ($char == "%DD")
458 {
459 return "%C3%9D";
460 }
461 if ($char == "%DE")
462 {
463 return "%C3%9E";
464 }
465 if ($char == "%DF")
466 {
467 return "%C3%9F";
468 }
469 if ($char == "%E0")
470 {
471 return "%C3%A0";
472 }
473 if ($char == "%E1")
474 {
475 return "%C3%A1";
476 }
477 if ($char == "%E2")
478 {
479 return "%C3%A2";
480 }
481 if ($char == "%E3")
482 {
483 return "%C3%A3";
484 }
485 if ($char == "%E4")
486 {
487 return "%C3%A4";
488 }
489 if ($char == "%E5")
490 {
491 return "%C3%A5";
492 }
493 if ($char == "%E6")
494 {
495 return "%C3%A6";
496 }
497 if ($char == "%E7")
498 {
499 return "%C3%A7";
500 }
501 if ($char == "%E8")
502 {
503 return "%C3%A8";
504 }
505 if ($char == "%E9")
506 {
507 return "%C3%A9";
508 }
509 if ($char == "%EA")
510 {
511 return "%C3%AA";
512 }
513 if ($char == "%EB")
514 {
515 return "%C3%AB";
516 }
517 if ($char == "%EC")
518 {
519 return "%C3%AC";
520 }
521 if ($char == "%ED")
522 {
523 return "%C3%AD";
524 }
525 if ($char == "%EE")
526 {
527 return "%C3%AE";
528 }
529 if ($char == "%EF")
530 {
531 return "%C3%AF";
532 }
533 if ($char == "%F0")
534 {
535 return "%C3%B0";
536 }
537 if ($char == "%F1")
538 {
539 return "%C3%B1";
540 }
541 if ($char == "%F2")
542 {
543 return "%C3%B2";
544 }
545 if ($char == "%F3")
546 {
547 return "%C3%B3";
548 }
549 if ($char == "%F4")
550 {
551 return "%C3%B4";
552 }
553 if ($char == "%F5")
554 {
555 return "%C3%B5";
556 }
557 if ($char == "%F6")
558 {
559 return "%C3%B6";
560 }
561 if ($char == "%F7")
562 {
563 return "%C3%B7";
564 }
565 if ($char == "%F8")
566 {
567 return "%C3%B8";
568 }
569 if ($char == "%F9")
570 {
571 return "%C3%B9";
572 }
573 if ($char == "%FA")
574 {
575 return "%C3%BA";
576 }
577 if ($char == "%FB")
578 {
579 return "%C3%BB";
580 }
581 if ($char == "%FC")
582 {
583 return "%C3%BC";
584 }
585 if ($char == "%FD")
586 {
587 return "%C3%BD";
588 }
589 if ($char == "%FE")
590 {
591 return "%C3%BE";
592 }
593 if ($char == "%FF")
594 {
595 return "%C3%BF";
596 }
597 return $char;
598}
599
601{
602 $result = "";
603 for ($i = 0; $i < strlen($string); $i++)
604 {
605 $decstr = "";
606 for ($p = 0; $p <= 8; $p++)
607 {
608 $decstr .= $string[$i+$p];
609 }
610 list($decodedstr, $num) = decodeURIComponentbycharacter($decstr);
611 $result .= urldecode($decodedstr);
612 $i += $num ;
613 }
614 return $result;
615}
616
618{
619
620 $char = $str;
621
622 if ($char == "%E2%82%AC")
623 {
624 return array("%80", 8);
625 }
626 if ($char == "%E2%80%9A")
627 {
628 return array("%82", 8);
629 }
630 if ($char == "%E2%80%9E")
631 {
632 return array("%84", 8);
633 }
634 if ($char == "%E2%80%A6")
635 {
636 return array("%85", 8);
637 }
638 if ($char == "%E2%80%A0")
639 {
640 return array("%86", 8);
641 }
642 if ($char == "%E2%80%A1")
643 {
644 return array("%87", 8);
645 }
646 if ($char == "%E2%80%B0")
647 {
648 return array("%89", 8);
649 }
650 if ($char == "%E2%80%B9")
651 {
652 return array("%8B", 8);
653 }
654 if ($char == "%E2%80%98")
655 {
656 return array("%91", 8);
657 }
658 if ($char == "%E2%80%99")
659 {
660 return array("%92", 8);
661 }
662 if ($char == "%E2%80%9C")
663 {
664 return array("%93", 8);
665 }
666 if ($char == "%E2%80%9D")
667 {
668 return array("%94", 8);
669 }
670 if ($char == "%E2%80%A2")
671 {
672 return array("%95", 8);
673 }
674 if ($char == "%E2%80%93")
675 {
676 return array("%96", 8);
677 }
678 if ($char == "%E2%80%94")
679 {
680 return array("%97", 8);
681 }
682 if ($char == "%E2%84%A2")
683 {
684 return array("%99", 8);
685 }
686 if ($char == "%E2%80%BA")
687 {
688 return array("%9B", 8);
689 }
690
691 $char = substr($str, 0, 6);
692
693 if ($char == "%C2%81")
694 {
695 return array("%81", 5);
696 }
697 if ($char == "%C6%92")
698 {
699 return array("%83", 5);
700 }
701 if ($char == "%CB%86")
702 {
703 return array("%88", 5);
704 }
705 if ($char == "%C5%A0")
706 {
707 return array("%8A", 5);
708 }
709 if ($char == "%C5%92")
710 {
711 return array("%8C", 5);
712 }
713 if ($char == "%C2%8D")
714 {
715 return array("%8D", 5);
716 }
717 if ($char == "%C5%BD")
718 {
719 return array("%8E", 5);
720 }
721 if ($char == "%C2%8F")
722 {
723 return array("%8F", 5);
724 }
725 if ($char == "%C2%90")
726 {
727 return array("%90", 5);
728 }
729 if ($char == "%CB%9C")
730 {
731 return array("%98", 5);
732 }
733 if ($char == "%C5%A1")
734 {
735 return array("%9A", 5);
736 }
737 if ($char == "%C5%93")
738 {
739 return array("%9C", 5);
740 }
741 if ($char == "%C2%9D")
742 {
743 return array("%9D", 5);
744 }
745 if ($char == "%C5%BE")
746 {
747 return array("%9E", 5);
748 }
749 if ($char == "%C5%B8")
750 {
751 return array("%9F", 5);
752 }
753 if ($char == "%C2%A0")
754 {
755 return array("%A0", 5);
756 }
757 if ($char == "%C2%A1")
758 {
759 return array("%A1", 5);
760 }
761 if ($char == "%C2%A2")
762 {
763 return array("%A2", 5);
764 }
765 if ($char == "%C2%A3")
766 {
767 return array("%A3", 5);
768 }
769 if ($char == "%C2%A4")
770 {
771 return array("%A4", 5);
772 }
773 if ($char == "%C2%A5")
774 {
775 return array("%A5", 5);
776 }
777 if ($char == "%C2%A6")
778 {
779 return array("%A6", 5);
780 }
781 if ($char == "%C2%A7")
782 {
783 return array("%A7", 5);
784 }
785 if ($char == "%C2%A8")
786 {
787 return array("%A8", 5);
788 }
789 if ($char == "%C2%A9")
790 {
791 return array("%A9", 5);
792 }
793 if ($char == "%C2%AA")
794 {
795 return array("%AA", 5);
796 }
797 if ($char == "%C2%AB")
798 {
799 return array("%AB", 5);
800 }
801 if ($char == "%C2%AC")
802 {
803 return array("%AC", 5);
804 }
805 if ($char == "%C2%AD")
806 {
807 return array("%AD", 5);
808 }
809 if ($char == "%C2%AE")
810 {
811 return array("%AE", 5);
812 }
813 if ($char == "%C2%AF")
814 {
815 return array("%AF", 5);
816 }
817 if ($char == "%C2%B0")
818 {
819 return array("%B0", 5);
820 }
821 if ($char == "%C2%B1")
822 {
823 return array("%B1", 5);
824 }
825 if ($char == "%C2%B2")
826 {
827 return array("%B2", 5);
828 }
829 if ($char == "%C2%B3")
830 {
831 return array("%B3", 5);
832 }
833 if ($char == "%C2%B4")
834 {
835 return array("%B4", 5);
836 }
837 if ($char == "%C2%B5")
838 {
839 return array("%B5", 5);
840 }
841 if ($char == "%C2%B6")
842 {
843 return array("%B6", 5);
844 }
845 if ($char == "%C2%B7")
846 {
847 return array("%B7", 5);
848 }
849 if ($char == "%C2%B8")
850 {
851 return array("%B8", 5);
852 }
853 if ($char == "%C2%B9")
854 {
855 return array("%B9", 5);
856 }
857 if ($char == "%C2%BA")
858 {
859 return array("%BA", 5);
860 }
861 if ($char == "%C2%BB")
862 {
863 return array("%BB", 5);
864 }
865 if ($char == "%C2%BC")
866 {
867 return array("%BC", 5);
868 }
869 if ($char == "%C2%BD")
870 {
871 return array("%BD", 5);
872 }
873 if ($char == "%C2%BE")
874 {
875 return array("%BE", 5);
876 }
877 if ($char == "%C2%BF")
878 {
879 return array("%BF", 5);
880 }
881 if ($char == "%C3%80")
882 {
883 return array("%C0", 5);
884 }
885 if ($char == "%C3%81")
886 {
887 return array("%C1", 5);
888 }
889 if ($char == "%C3%82")
890 {
891 return array("%C2", 5);
892 }
893 if ($char == "%C3%83")
894 {
895 return array("%C3", 5);
896 }
897 if ($char == "%C3%84")
898 {
899 return array("%C4", 5);
900 }
901 if ($char == "%C3%85")
902 {
903 return array("%C5", 5);
904 }
905 if ($char == "%C3%86")
906 {
907 return array("%C6", 5);
908 }
909 if ($char == "%C3%87")
910 {
911 return array("%C7", 5);
912 }
913 if ($char == "%C3%88")
914 {
915 return array("%C8", 5);
916 }
917 if ($char == "%C3%89")
918 {
919 return array("%C9", 5);
920 }
921 if ($char == "%C3%8A")
922 {
923 return array("%CA", 5);
924 }
925 if ($char == "%C3%8B")
926 {
927 return array("%CB", 5);
928 }
929 if ($char == "%C3%8C")
930 {
931 return array("%CC", 5);
932 }
933 if ($char == "%C3%8D")
934 {
935 return array("%CD", 5);
936 }
937 if ($char == "%C3%8E")
938 {
939 return array("%CE", 5);
940 }
941 if ($char == "%C3%8F")
942 {
943 return array("%CF", 5);
944 }
945 if ($char == "%C3%90")
946 {
947 return array("%D0", 5);
948 }
949 if ($char == "%C3%91")
950 {
951 return array("%D1", 5);
952 }
953 if ($char == "%C3%92")
954 {
955 return array("%D2", 5);
956 }
957 if ($char == "%C3%93")
958 {
959 return array("%D3", 5);
960 }
961 if ($char == "%C3%94")
962 {
963 return array("%D4", 5);
964 }
965 if ($char == "%C3%95")
966 {
967 return array("%D5", 5);
968 }
969 if ($char == "%C3%96")
970 {
971 return array("%D6", 5);
972 }
973 if ($char == "%C3%97")
974 {
975 return array("%D7", 5);
976 }
977 if ($char == "%C3%98")
978 {
979 return array("%D8", 5);
980 }
981 if ($char == "%C3%99")
982 {
983 return array("%D9", 5);
984 }
985 if ($char == "%C3%9A")
986 {
987 return array("%DA", 5);
988 }
989 if ($char == "%C3%9B")
990 {
991 return array("%DB", 5);
992 }
993 if ($char == "%C3%9C")
994 {
995 return array("%DC", 5);
996 }
997 if ($char == "%C3%9D")
998 {
999 return array("%DD", 5);
1000 }
1001 if ($char == "%C3%9E")
1002 {
1003 return array("%DE", 5);
1004 }
1005 if ($char == "%C3%9F")
1006 {
1007 return array("%DF", 5);
1008 }
1009 if ($char == "%C3%A0")
1010 {
1011 return array("%E0", 5);
1012 }
1013 if ($char == "%C3%A1")
1014 {
1015 return array("%E1", 5);
1016 }
1017 if ($char == "%C3%A2")
1018 {
1019 return array("%E2", 5);
1020 }
1021 if ($char == "%C3%A3")
1022 {
1023 return array("%E3", 5);
1024 }
1025 if ($char == "%C3%A4")
1026 {
1027 return array("%E4", 5);
1028 }
1029 if ($char == "%C3%A5")
1030 {
1031 return array("%E5", 5);
1032 }
1033 if ($char == "%C3%A6")
1034 {
1035 return array("%E6", 5);
1036 }
1037 if ($char == "%C3%A7")
1038 {
1039 return array("%E7", 5);
1040 }
1041 if ($char == "%C3%A8")
1042 {
1043 return array("%E8", 5);
1044 }
1045 if ($char == "%C3%A9")
1046 {
1047 return array("%E9", 5);
1048 }
1049 if ($char == "%C3%AA")
1050 {
1051 return array("%EA", 5);
1052 }
1053 if ($char == "%C3%AB")
1054 {
1055 return array("%EB", 5);
1056 }
1057 if ($char == "%C3%AC")
1058 {
1059 return array("%EC", 5);
1060 }
1061 if ($char == "%C3%AD")
1062 {
1063 return array("%ED", 5);
1064 }
1065 if ($char == "%C3%AE")
1066 {
1067 return array("%EE", 5);
1068 }
1069 if ($char == "%C3%AF")
1070 {
1071 return array("%EF", 5);
1072 }
1073 if ($char == "%C3%B0")
1074 {
1075 return array("%F0", 5);
1076 }
1077 if ($char == "%C3%B1")
1078 {
1079 return array("%F1", 5);
1080 }
1081 if ($char == "%C3%B2")
1082 {
1083 return array("%F2", 5);
1084 }
1085 if ($char == "%C3%B3")
1086 {
1087 return array("%F3", 5);
1088 }
1089 if ($char == "%C3%B4")
1090 {
1091 return array("%F4", 5);
1092 }
1093 if ($char == "%C3%B5")
1094 {
1095 return array("%F5", 5);
1096 }
1097 if ($char == "%C3%B6")
1098 {
1099 return array("%F6", 5);
1100 }
1101 if ($char == "%C3%B7")
1102 {
1103 return array("%F7", 5);
1104 }
1105 if ($char == "%C3%B8")
1106 {
1107 return array("%F8", 5);
1108 }
1109 if ($char == "%C3%B9")
1110 {
1111 return array("%F9", 5);
1112 }
1113 if ($char == "%C3%BA")
1114 {
1115 return array("%FA", 5);
1116 }
1117 if ($char == "%C3%BB")
1118 {
1119 return array("%FB", 5);
1120 }
1121 if ($char == "%C3%BC")
1122 {
1123 return array("%FC", 5);
1124 }
1125 if ($char == "%C3%BD")
1126 {
1127 return array("%FD", 5);
1128 }
1129 if ($char == "%C3%BE")
1130 {
1131 return array("%FE", 5);
1132 }
1133 if ($char == "%C3%BF")
1134 {
1135 return array("%FF", 5);
1136 }
1137
1138 $char = substr($str, 0, 3);
1139 if ($char == "%20")
1140 {
1141 return array("+", 2);
1142 }
1143
1144 $char = substr($str, 0, 1);
1145
1146 if ($char == "!")
1147 {
1148 return array("%21", 0);
1149 }
1150 if ($char == "\"")
1151 {
1152 return array("%27", 0);
1153 }
1154 if ($char == "(")
1155 {
1156 return array("%28", 0);
1157 }
1158 if ($char == ")")
1159 {
1160 return array("%29", 0);
1161 }
1162 if ($char == "*")
1163 {
1164 return array("%2A", 0);
1165 }
1166 if ($char == "~")
1167 {
1168 return array("%7E", 0);
1169 }
1170
1171 if ($char == "%")
1172 {
1173 return array(substr($str, 0, 3), 2);
1174 }
1175 else
1176 {
1177 return array($char, 0);
1178 }
1179}
1180
1182{
1183 $result = "";
1184 for ($i = 0; $i < strlen($string); $i++)
1185 {
1186 $result .= encodeURIbycharacter(urlencode($string[$i]));
1187 }
1188 return $result;
1189}
1190
1192{
1193 if ($char == "+")
1194 {
1195 return "%20";
1196 }
1197 if ($char == "%21")
1198 {
1199 return "!";
1200 }
1201 if ($char == "%23")
1202 {
1203 return "#";
1204 }
1205 if ($char == "%24")
1206 {
1207 return "$";
1208 }
1209 if ($char == "%26")
1210 {
1211 return "&";
1212 }
1213 if ($char == "%27")
1214 {
1215 return "\"";
1216 }
1217 if ($char == "%28")
1218 {
1219 return "(";
1220 }
1221 if ($char == "%29")
1222 {
1223 return ")";
1224 }
1225 if ($char == "%2A")
1226 {
1227 return "*";
1228 }
1229 if ($char == "%2B")
1230 {
1231 return "+";
1232 }
1233 if ($char == "%2C")
1234 {
1235 return ",";
1236 }
1237 if ($char == "%2F")
1238 {
1239 return "/";
1240 }
1241 if ($char == "%3A")
1242 {
1243 return ":";
1244 }
1245 if ($char == "%3B")
1246 {
1247 return ";";
1248 }
1249 if ($char == "%3D")
1250 {
1251 return "=";
1252 }
1253 if ($char == "%3F")
1254 {
1255 return "?";
1256 }
1257 if ($char == "%40")
1258 {
1259 return "@";
1260 }
1261 if ($char == "%7E")
1262 {
1263 return "~";
1264 }
1265 if ($char == "%80")
1266 {
1267 return "%E2%82%AC";
1268 }
1269 if ($char == "%81")
1270 {
1271 return "%C2%81";
1272 }
1273 if ($char == "%82")
1274 {
1275 return "%E2%80%9A";
1276 }
1277 if ($char == "%83")
1278 {
1279 return "%C6%92";
1280 }
1281 if ($char == "%84")
1282 {
1283 return "%E2%80%9E";
1284 }
1285 if ($char == "%85")
1286 {
1287 return "%E2%80%A6";
1288 }
1289 if ($char == "%86")
1290 {
1291 return "%E2%80%A0";
1292 }
1293 if ($char == "%87")
1294 {
1295 return "%E2%80%A1";
1296 }
1297 if ($char == "%88")
1298 {
1299 return "%CB%86";
1300 }
1301 if ($char == "%89")
1302 {
1303 return "%E2%80%B0";
1304 }
1305 if ($char == "%8A")
1306 {
1307 return "%C5%A0";
1308 }
1309 if ($char == "%8B")
1310 {
1311 return "%E2%80%B9";
1312 }
1313 if ($char == "%8C")
1314 {
1315 return "%C5%92";
1316 }
1317 if ($char == "%8D")
1318 {
1319 return "%C2%8D";
1320 }
1321 if ($char == "%8E")
1322 {
1323 return "%C5%BD";
1324 }
1325 if ($char == "%8F")
1326 {
1327 return "%C2%8F";
1328 }
1329 if ($char == "%90")
1330 {
1331 return "%C2%90";
1332 }
1333 if ($char == "%91")
1334 {
1335 return "%E2%80%98";
1336 }
1337 if ($char == "%92")
1338 {
1339 return "%E2%80%99";
1340 }
1341 if ($char == "%93")
1342 {
1343 return "%E2%80%9C";
1344 }
1345 if ($char == "%94")
1346 {
1347 return "%E2%80%9D";
1348 }
1349 if ($char == "%95")
1350 {
1351 return "%E2%80%A2";
1352 }
1353 if ($char == "%96")
1354 {
1355 return "%E2%80%93";
1356 }
1357 if ($char == "%97")
1358 {
1359 return "%E2%80%94";
1360 }
1361 if ($char == "%98")
1362 {
1363 return "%CB%9C";
1364 }
1365 if ($char == "%99")
1366 {
1367 return "%E2%84%A2";
1368 }
1369 if ($char == "%9A")
1370 {
1371 return "%C5%A1";
1372 }
1373 if ($char == "%9B")
1374 {
1375 return "%E2%80%BA";
1376 }
1377 if ($char == "%9C")
1378 {
1379 return "%C5%93";
1380 }
1381 if ($char == "%9D")
1382 {
1383 return "%C2%9D";
1384 }
1385 if ($char == "%9E")
1386 {
1387 return "%C5%BE";
1388 }
1389 if ($char == "%9F")
1390 {
1391 return "%C5%B8";
1392 }
1393 if ($char == "%A0")
1394 {
1395 return "%C2%A0";
1396 }
1397 if ($char == "%A1")
1398 {
1399 return "%C2%A1";
1400 }
1401 if ($char == "%A2")
1402 {
1403 return "%C2%A2";
1404 }
1405 if ($char == "%A3")
1406 {
1407 return "%C2%A3";
1408 }
1409 if ($char == "%A4")
1410 {
1411 return "%C2%A4";
1412 }
1413 if ($char == "%A5")
1414 {
1415 return "%C2%A5";
1416 }
1417 if ($char == "%A6")
1418 {
1419 return "%C2%A6";
1420 }
1421 if ($char == "%A7")
1422 {
1423 return "%C2%A7";
1424 }
1425 if ($char == "%A8")
1426 {
1427 return "%C2%A8";
1428 }
1429 if ($char == "%A9")
1430 {
1431 return "%C2%A9";
1432 }
1433 if ($char == "%AA")
1434 {
1435 return "%C2%AA";
1436 }
1437 if ($char == "%AB")
1438 {
1439 return "%C2%AB";
1440 }
1441 if ($char == "%AC")
1442 {
1443 return "%C2%AC";
1444 }
1445 if ($char == "%AD")
1446 {
1447 return "%C2%AD";
1448 }
1449 if ($char == "%AE")
1450 {
1451 return "%C2%AE";
1452 }
1453 if ($char == "%AF")
1454 {
1455 return "%C2%AF";
1456 }
1457 if ($char == "%B0")
1458 {
1459 return "%C2%B0";
1460 }
1461 if ($char == "%B1")
1462 {
1463 return "%C2%B1";
1464 }
1465 if ($char == "%B2")
1466 {
1467 return "%C2%B2";
1468 }
1469 if ($char == "%B3")
1470 {
1471 return "%C2%B3";
1472 }
1473 if ($char == "%B4")
1474 {
1475 return "%C2%B4";
1476 }
1477 if ($char == "%B5")
1478 {
1479 return "%C2%B5";
1480 }
1481 if ($char == "%B6")
1482 {
1483 return "%C2%B6";
1484 }
1485 if ($char == "%B7")
1486 {
1487 return "%C2%B7";
1488 }
1489 if ($char == "%B8")
1490 {
1491 return "%C2%B8";
1492 }
1493 if ($char == "%B9")
1494 {
1495 return "%C2%B9";
1496 }
1497 if ($char == "%BA")
1498 {
1499 return "%C2%BA";
1500 }
1501 if ($char == "%BB")
1502 {
1503 return "%C2%BB";
1504 }
1505 if ($char == "%BC")
1506 {
1507 return "%C2%BC";
1508 }
1509 if ($char == "%BD")
1510 {
1511 return "%C2%BD";
1512 }
1513 if ($char == "%BE")
1514 {
1515 return "%C2%BE";
1516 }
1517 if ($char == "%BF")
1518 {
1519 return "%C2%BF";
1520 }
1521 if ($char == "%C0")
1522 {
1523 return "%C3%80";
1524 }
1525 if ($char == "%C1")
1526 {
1527 return "%C3%81";
1528 }
1529 if ($char == "%C2")
1530 {
1531 return "%C3%82";
1532 }
1533 if ($char == "%C3")
1534 {
1535 return "%C3%83";
1536 }
1537 if ($char == "%C4")
1538 {
1539 return "%C3%84";
1540 }
1541 if ($char == "%C5")
1542 {
1543 return "%C3%85";
1544 }
1545 if ($char == "%C6")
1546 {
1547 return "%C3%86";
1548 }
1549 if ($char == "%C7")
1550 {
1551 return "%C3%87";
1552 }
1553 if ($char == "%C8")
1554 {
1555 return "%C3%88";
1556 }
1557 if ($char == "%C9")
1558 {
1559 return "%C3%89";
1560 }
1561 if ($char == "%CA")
1562 {
1563 return "%C3%8A";
1564 }
1565 if ($char == "%CB")
1566 {
1567 return "%C3%8B";
1568 }
1569 if ($char == "%CC")
1570 {
1571 return "%C3%8C";
1572 }
1573 if ($char == "%CD")
1574 {
1575 return "%C3%8D";
1576 }
1577 if ($char == "%CE")
1578 {
1579 return "%C3%8E";
1580 }
1581 if ($char == "%CF")
1582 {
1583 return "%C3%8F";
1584 }
1585 if ($char == "%D0")
1586 {
1587 return "%C3%90";
1588 }
1589 if ($char == "%D1")
1590 {
1591 return "%C3%91";
1592 }
1593 if ($char == "%D2")
1594 {
1595 return "%C3%92";
1596 }
1597 if ($char == "%D3")
1598 {
1599 return "%C3%93";
1600 }
1601 if ($char == "%D4")
1602 {
1603 return "%C3%94";
1604 }
1605 if ($char == "%D5")
1606 {
1607 return "%C3%95";
1608 }
1609 if ($char == "%D6")
1610 {
1611 return "%C3%96";
1612 }
1613 if ($char == "%D7")
1614 {
1615 return "%C3%97";
1616 }
1617 if ($char == "%D8")
1618 {
1619 return "%C3%98";
1620 }
1621 if ($char == "%D9")
1622 {
1623 return "%C3%99";
1624 }
1625 if ($char == "%DA")
1626 {
1627 return "%C3%9A";
1628 }
1629 if ($char == "%DB")
1630 {
1631 return "%C3%9B";
1632 }
1633 if ($char == "%DC")
1634 {
1635 return "%C3%9C";
1636 }
1637 if ($char == "%DD")
1638 {
1639 return "%C3%9D";
1640 }
1641 if ($char == "%DE")
1642 {
1643 return "%C3%9E";
1644 }
1645 if ($char == "%DF")
1646 {
1647 return "%C3%9F";
1648 }
1649 if ($char == "%E0")
1650 {
1651 return "%C3%A0";
1652 }
1653 if ($char == "%E1")
1654 {
1655 return "%C3%A1";
1656 }
1657 if ($char == "%E2")
1658 {
1659 return "%C3%A2";
1660 }
1661 if ($char == "%E3")
1662 {
1663 return "%C3%A3";
1664 }
1665 if ($char == "%E4")
1666 {
1667 return "%C3%A4";
1668 }
1669 if ($char == "%E5")
1670 {
1671 return "%C3%A5";
1672 }
1673 if ($char == "%E6")
1674 {
1675 return "%C3%A6";
1676 }
1677 if ($char == "%E7")
1678 {
1679 return "%C3%A7";
1680 }
1681 if ($char == "%E8")
1682 {
1683 return "%C3%A8";
1684 }
1685 if ($char == "%E9")
1686 {
1687 return "%C3%A9";
1688 }
1689 if ($char == "%EA")
1690 {
1691 return "%C3%AA";
1692 }
1693 if ($char == "%EB")
1694 {
1695 return "%C3%AB";
1696 }
1697 if ($char == "%EC")
1698 {
1699 return "%C3%AC";
1700 }
1701 if ($char == "%ED")
1702 {
1703 return "%C3%AD";
1704 }
1705 if ($char == "%EE")
1706 {
1707 return "%C3%AE";
1708 }
1709 if ($char == "%EF")
1710 {
1711 return "%C3%AF";
1712 }
1713 if ($char == "%F0")
1714 {
1715 return "%C3%B0";
1716 }
1717 if ($char == "%F1")
1718 {
1719 return "%C3%B1";
1720 }
1721 if ($char == "%F2")
1722 {
1723 return "%C3%B2";
1724 }
1725 if ($char == "%F3")
1726 {
1727 return "%C3%B3";
1728 }
1729 if ($char == "%F4")
1730 {
1731 return "%C3%B4";
1732 }
1733 if ($char == "%F5")
1734 {
1735 return "%C3%B5";
1736 }
1737 if ($char == "%F6")
1738 {
1739 return "%C3%B6";
1740 }
1741 if ($char == "%F7")
1742 {
1743 return "%C3%B7";
1744 }
1745 if ($char == "%F8")
1746 {
1747 return "%C3%B8";
1748 }
1749 if ($char == "%F9")
1750 {
1751 return "%C3%B9";
1752 }
1753 if ($char == "%FA")
1754 {
1755 return "%C3%BA";
1756 }
1757 if ($char == "%FB")
1758 {
1759 return "%C3%BB";
1760 }
1761 if ($char == "%FC")
1762 {
1763 return "%C3%BC";
1764 }
1765 if ($char == "%FD")
1766 {
1767 return "%C3%BD";
1768 }
1769 if ($char == "%FE")
1770 {
1771 return "%C3%BE";
1772 }
1773 if ($char == "%FF")
1774 {
1775 return "%C3%BF";
1776 }
1777 return $char;
1778}
1779
1781{
1782 $result = "";
1783 for ($i = 0; $i < strlen($string); $i++)
1784 {
1785 $decstr = "";
1786 for ($p = 0; $p <= 8; $p++)
1787 {
1788 $decstr .= $string[$i+$p];
1789 }
1790 list($decodedstr, $num) = decodeURIbycharacter($decstr);
1791 $result .= urldecode($decodedstr);
1792 $i += $num ;
1793 }
1794 return $result;
1795}
1796
1798{
1799
1800 $char = $str;
1801
1802 if ($char == "%E2%82%AC")
1803 {
1804 return array("%80", 8);
1805 }
1806 if ($char == "%E2%80%9A")
1807 {
1808 return array("%82", 8);
1809 }
1810 if ($char == "%E2%80%9E")
1811 {
1812 return array("%84", 8);
1813 }
1814 if ($char == "%E2%80%A6")
1815 {
1816 return array("%85", 8);
1817 }
1818 if ($char == "%E2%80%A0")
1819 {
1820 return array("%86", 8);
1821 }
1822 if ($char == "%E2%80%A1")
1823 {
1824 return array("%87", 8);
1825 }
1826 if ($char == "%E2%80%B0")
1827 {
1828 return array("%89", 8);
1829 }
1830 if ($char == "%E2%80%B9")
1831 {
1832 return array("%8B", 8);
1833 }
1834 if ($char == "%E2%80%98")
1835 {
1836 return array("%91", 8);
1837 }
1838 if ($char == "%E2%80%99")
1839 {
1840 return array("%92", 8);
1841 }
1842 if ($char == "%E2%80%9C")
1843 {
1844 return array("%93", 8);
1845 }
1846 if ($char == "%E2%80%9D")
1847 {
1848 return array("%94", 8);
1849 }
1850 if ($char == "%E2%80%A2")
1851 {
1852 return array("%95", 8);
1853 }
1854 if ($char == "%E2%80%93")
1855 {
1856 return array("%96", 8);
1857 }
1858 if ($char == "%E2%80%94")
1859 {
1860 return array("%97", 8);
1861 }
1862 if ($char == "%E2%84%A2")
1863 {
1864 return array("%99", 8);
1865 }
1866 if ($char == "%E2%80%BA")
1867 {
1868 return array("%9B", 8);
1869 }
1870
1871 $char = substr($str, 0, 6);
1872
1873 if ($char == "%C2%81")
1874 {
1875 return array("%81", 5);
1876 }
1877 if ($char == "%C6%92")
1878 {
1879 return array("%83", 5);
1880 }
1881 if ($char == "%CB%86")
1882 {
1883 return array("%88", 5);
1884 }
1885 if ($char == "%C5%A0")
1886 {
1887 return array("%8A", 5);
1888 }
1889 if ($char == "%C5%92")
1890 {
1891 return array("%8C", 5);
1892 }
1893 if ($char == "%C2%8D")
1894 {
1895 return array("%8D", 5);
1896 }
1897 if ($char == "%C5%BD")
1898 {
1899 return array("%8E", 5);
1900 }
1901 if ($char == "%C2%8F")
1902 {
1903 return array("%8F", 5);
1904 }
1905 if ($char == "%C2%90")
1906 {
1907 return array("%90", 5);
1908 }
1909 if ($char == "%CB%9C")
1910 {
1911 return array("%98", 5);
1912 }
1913 if ($char == "%C5%A1")
1914 {
1915 return array("%9A", 5);
1916 }
1917 if ($char == "%C5%93")
1918 {
1919 return array("%9C", 5);
1920 }
1921 if ($char == "%C2%9D")
1922 {
1923 return array("%9D", 5);
1924 }
1925 if ($char == "%C5%BE")
1926 {
1927 return array("%9E", 5);
1928 }
1929 if ($char == "%C5%B8")
1930 {
1931 return array("%9F", 5);
1932 }
1933 if ($char == "%C2%A0")
1934 {
1935 return array("%A0", 5);
1936 }
1937 if ($char == "%C2%A1")
1938 {
1939 return array("%A1", 5);
1940 }
1941 if ($char == "%C2%A2")
1942 {
1943 return array("%A2", 5);
1944 }
1945 if ($char == "%C2%A3")
1946 {
1947 return array("%A3", 5);
1948 }
1949 if ($char == "%C2%A4")
1950 {
1951 return array("%A4", 5);
1952 }
1953 if ($char == "%C2%A5")
1954 {
1955 return array("%A5", 5);
1956 }
1957 if ($char == "%C2%A6")
1958 {
1959 return array("%A6", 5);
1960 }
1961 if ($char == "%C2%A7")
1962 {
1963 return array("%A7", 5);
1964 }
1965 if ($char == "%C2%A8")
1966 {
1967 return array("%A8", 5);
1968 }
1969 if ($char == "%C2%A9")
1970 {
1971 return array("%A9", 5);
1972 }
1973 if ($char == "%C2%AA")
1974 {
1975 return array("%AA", 5);
1976 }
1977 if ($char == "%C2%AB")
1978 {
1979 return array("%AB", 5);
1980 }
1981 if ($char == "%C2%AC")
1982 {
1983 return array("%AC", 5);
1984 }
1985 if ($char == "%C2%AD")
1986 {
1987 return array("%AD", 5);
1988 }
1989 if ($char == "%C2%AE")
1990 {
1991 return array("%AE", 5);
1992 }
1993 if ($char == "%C2%AF")
1994 {
1995 return array("%AF", 5);
1996 }
1997 if ($char == "%C2%B0")
1998 {
1999 return array("%B0", 5);
2000 }
2001 if ($char == "%C2%B1")
2002 {
2003 return array("%B1", 5);
2004 }
2005 if ($char == "%C2%B2")
2006 {
2007 return array("%B2", 5);
2008 }
2009 if ($char == "%C2%B3")
2010 {
2011 return array("%B3", 5);
2012 }
2013 if ($char == "%C2%B4")
2014 {
2015 return array("%B4", 5);
2016 }
2017 if ($char == "%C2%B5")
2018 {
2019 return array("%B5", 5);
2020 }
2021 if ($char == "%C2%B6")
2022 {
2023 return array("%B6", 5);
2024 }
2025 if ($char == "%C2%B7")
2026 {
2027 return array("%B7", 5);
2028 }
2029 if ($char == "%C2%B8")
2030 {
2031 return array("%B8", 5);
2032 }
2033 if ($char == "%C2%B9")
2034 {
2035 return array("%B9", 5);
2036 }
2037 if ($char == "%C2%BA")
2038 {
2039 return array("%BA", 5);
2040 }
2041 if ($char == "%C2%BB")
2042 {
2043 return array("%BB", 5);
2044 }
2045 if ($char == "%C2%BC")
2046 {
2047 return array("%BC", 5);
2048 }
2049 if ($char == "%C2%BD")
2050 {
2051 return array("%BD", 5);
2052 }
2053 if ($char == "%C2%BE")
2054 {
2055 return array("%BE", 5);
2056 }
2057 if ($char == "%C2%BF")
2058 {
2059 return array("%BF", 5);
2060 }
2061 if ($char == "%C3%80")
2062 {
2063 return array("%C0", 5);
2064 }
2065 if ($char == "%C3%81")
2066 {
2067 return array("%C1", 5);
2068 }
2069 if ($char == "%C3%82")
2070 {
2071 return array("%C2", 5);
2072 }
2073 if ($char == "%C3%83")
2074 {
2075 return array("%C3", 5);
2076 }
2077 if ($char == "%C3%84")
2078 {
2079 return array("%C4", 5);
2080 }
2081 if ($char == "%C3%85")
2082 {
2083 return array("%C5", 5);
2084 }
2085 if ($char == "%C3%86")
2086 {
2087 return array("%C6", 5);
2088 }
2089 if ($char == "%C3%87")
2090 {
2091 return array("%C7", 5);
2092 }
2093 if ($char == "%C3%88")
2094 {
2095 return array("%C8", 5);
2096 }
2097 if ($char == "%C3%89")
2098 {
2099 return array("%C9", 5);
2100 }
2101 if ($char == "%C3%8A")
2102 {
2103 return array("%CA", 5);
2104 }
2105 if ($char == "%C3%8B")
2106 {
2107 return array("%CB", 5);
2108 }
2109 if ($char == "%C3%8C")
2110 {
2111 return array("%CC", 5);
2112 }
2113 if ($char == "%C3%8D")
2114 {
2115 return array("%CD", 5);
2116 }
2117 if ($char == "%C3%8E")
2118 {
2119 return array("%CE", 5);
2120 }
2121 if ($char == "%C3%8F")
2122 {
2123 return array("%CF", 5);
2124 }
2125 if ($char == "%C3%90")
2126 {
2127 return array("%D0", 5);
2128 }
2129 if ($char == "%C3%91")
2130 {
2131 return array("%D1", 5);
2132 }
2133 if ($char == "%C3%92")
2134 {
2135 return array("%D2", 5);
2136 }
2137 if ($char == "%C3%93")
2138 {
2139 return array("%D3", 5);
2140 }
2141 if ($char == "%C3%94")
2142 {
2143 return array("%D4", 5);
2144 }
2145 if ($char == "%C3%95")
2146 {
2147 return array("%D5", 5);
2148 }
2149 if ($char == "%C3%96")
2150 {
2151 return array("%D6", 5);
2152 }
2153 if ($char == "%C3%97")
2154 {
2155 return array("%D7", 5);
2156 }
2157 if ($char == "%C3%98")
2158 {
2159 return array("%D8", 5);
2160 }
2161 if ($char == "%C3%99")
2162 {
2163 return array("%D9", 5);
2164 }
2165 if ($char == "%C3%9A")
2166 {
2167 return array("%DA", 5);
2168 }
2169 if ($char == "%C3%9B")
2170 {
2171 return array("%DB", 5);
2172 }
2173 if ($char == "%C3%9C")
2174 {
2175 return array("%DC", 5);
2176 }
2177 if ($char == "%C3%9D")
2178 {
2179 return array("%DD", 5);
2180 }
2181 if ($char == "%C3%9E")
2182 {
2183 return array("%DE", 5);
2184 }
2185 if ($char == "%C3%9F")
2186 {
2187 return array("%DF", 5);
2188 }
2189 if ($char == "%C3%A0")
2190 {
2191 return array("%E0", 5);
2192 }
2193 if ($char == "%C3%A1")
2194 {
2195 return array("%E1", 5);
2196 }
2197 if ($char == "%C3%A2")
2198 {
2199 return array("%E2", 5);
2200 }
2201 if ($char == "%C3%A3")
2202 {
2203 return array("%E3", 5);
2204 }
2205 if ($char == "%C3%A4")
2206 {
2207 return array("%E4", 5);
2208 }
2209 if ($char == "%C3%A5")
2210 {
2211 return array("%E5", 5);
2212 }
2213 if ($char == "%C3%A6")
2214 {
2215 return array("%E6", 5);
2216 }
2217 if ($char == "%C3%A7")
2218 {
2219 return array("%E7", 5);
2220 }
2221 if ($char == "%C3%A8")
2222 {
2223 return array("%E8", 5);
2224 }
2225 if ($char == "%C3%A9")
2226 {
2227 return array("%E9", 5);
2228 }
2229 if ($char == "%C3%AA")
2230 {
2231 return array("%EA", 5);
2232 }
2233 if ($char == "%C3%AB")
2234 {
2235 return array("%EB", 5);
2236 }
2237 if ($char == "%C3%AC")
2238 {
2239 return array("%EC", 5);
2240 }
2241 if ($char == "%C3%AD")
2242 {
2243 return array("%ED", 5);
2244 }
2245 if ($char == "%C3%AE")
2246 {
2247 return array("%EE", 5);
2248 }
2249 if ($char == "%C3%AF")
2250 {
2251 return array("%EF", 5);
2252 }
2253 if ($char == "%C3%B0")
2254 {
2255 return array("%F0", 5);
2256 }
2257 if ($char == "%C3%B1")
2258 {
2259 return array("%F1", 5);
2260 }
2261 if ($char == "%C3%B2")
2262 {
2263 return array("%F2", 5);
2264 }
2265 if ($char == "%C3%B3")
2266 {
2267 return array("%F3", 5);
2268 }
2269 if ($char == "%C3%B4")
2270 {
2271 return array("%F4", 5);
2272 }
2273 if ($char == "%C3%B5")
2274 {
2275 return array("%F5", 5);
2276 }
2277 if ($char == "%C3%B6")
2278 {
2279 return array("%F6", 5);
2280 }
2281 if ($char == "%C3%B7")
2282 {
2283 return array("%F7", 5);
2284 }
2285 if ($char == "%C3%B8")
2286 {
2287 return array("%F8", 5);
2288 }
2289 if ($char == "%C3%B9")
2290 {
2291 return array("%F9", 5);
2292 }
2293 if ($char == "%C3%BA")
2294 {
2295 return array("%FA", 5);
2296 }
2297 if ($char == "%C3%BB")
2298 {
2299 return array("%FB", 5);
2300 }
2301 if ($char == "%C3%BC")
2302 {
2303 return array("%FC", 5);
2304 }
2305 if ($char == "%C3%BD")
2306 {
2307 return array("%FD", 5);
2308 }
2309 if ($char == "%C3%BE")
2310 {
2311 return array("%FE", 5);
2312 }
2313 if ($char == "%C3%BF")
2314 {
2315 return array("%FF", 5);
2316 }
2317
2318 $char = substr($str, 0, 3);
2319 if ($char == "%20")
2320 {
2321 return array("+", 2);
2322 }
2323
2324 $char = substr($str, 0, 1);
2325
2326 if ($char == "!")
2327 {
2328 return array("%21", 0);
2329 }
2330 if ($char == "#")
2331 {
2332 return array("%23", 0);
2333 }
2334 if ($char == "$")
2335 {
2336 return array("%24", 0);
2337 }
2338 if ($char == "&")
2339 {
2340 return array("%26", 0);
2341 }
2342 if ($char == "\"")
2343 {
2344 return array("%27", 0);
2345 }
2346 if ($char == "(")
2347 {
2348 return array("%28", 0);
2349 }
2350 if ($char == ")")
2351 {
2352 return array("%29", 0);
2353 }
2354 if ($char == "*")
2355 {
2356 return array("%2A", 0);
2357 }
2358 if ($char == "+")
2359 {
2360 return array("%2B", 0);
2361 }
2362 if ($char == ",")
2363 {
2364 return array("%2C", 0);
2365 }
2366 if ($char == "/")
2367 {
2368 return array("%2F", 0);
2369 }
2370 if ($char == ":")
2371 {
2372 return array("%3A", 0);
2373 }
2374 if ($char == ";")
2375 {
2376 return array("%3B", 0);
2377 }
2378 if ($char == "=")
2379 {
2380 return array("%3D", 0);
2381 }
2382 if ($char == "?")
2383 {
2384 return array("%3F", 0);
2385 }
2386 if ($char == "@")
2387 {
2388 return array("%40", 0);
2389 }
2390 if ($char == "~")
2391 {
2392 return array("%7E", 0);
2393 }
2394
2395 if ($char == "%")
2396 {
2397 return array(substr($str, 0, 3), 2);
2398 }
2399 else
2400 {
2401 return array($char, 0);
2402 }
2403}
2404
2406{
2407 $result = "";
2408 for ($i = 0; $i < strlen($string); $i++)
2409 {
2410 $result .= escapebycharacter(urlencode($string[$i]));
2411 }
2412 return $result;
2413}
2414
2415function escapebycharacter($char)
2416{
2417 if ($char == '+')
2418 {
2419 return '%20';
2420 }
2421 if ($char == '%2A')
2422 {
2423 return '*';
2424 }
2425 if ($char == '%2B')
2426 {
2427 return '+';
2428 }
2429 if ($char == '%2F')
2430 {
2431 return '/';
2432 }
2433 if ($char == '%40')
2434 {
2435 return '@';
2436 }
2437 if ($char == '%80')
2438 {
2439 return '%u20AC';
2440 }
2441 if ($char == '%82')
2442 {
2443 return '%u201A';
2444 }
2445 if ($char == '%83')
2446 {
2447 return '%u0192';
2448 }
2449 if ($char == '%84')
2450 {
2451 return '%u201E';
2452 }
2453 if ($char == '%85')
2454 {
2455 return '%u2026';
2456 }
2457 if ($char == '%86')
2458 {
2459 return '%u2020';
2460 }
2461 if ($char == '%87')
2462 {
2463 return '%u2021';
2464 }
2465 if ($char == '%88')
2466 {
2467 return '%u02C6';
2468 }
2469 if ($char == '%89')
2470 {
2471 return '%u2030';
2472 }
2473 if ($char == '%8A')
2474 {
2475 return '%u0160';
2476 }
2477 if ($char == '%8B')
2478 {
2479 return '%u2039';
2480 }
2481 if ($char == '%8C')
2482 {
2483 return '%u0152';
2484 }
2485 if ($char == '%8E')
2486 {
2487 return '%u017D';
2488 }
2489 if ($char == '%91')
2490 {
2491 return '%u2018';
2492 }
2493 if ($char == '%92')
2494 {
2495 return '%u2019';
2496 }
2497 if ($char == '%93')
2498 {
2499 return '%u201C';
2500 }
2501 if ($char == '%94')
2502 {
2503 return '%u201D';
2504 }
2505 if ($char == '%95')
2506 {
2507 return '%u2022';
2508 }
2509 if ($char == '%96')
2510 {
2511 return '%u2013';
2512 }
2513 if ($char == '%97')
2514 {
2515 return '%u2014';
2516 }
2517 if ($char == '%98')
2518 {
2519 return '%u02DC';
2520 }
2521 if ($char == '%99')
2522 {
2523 return '%u2122';
2524 }
2525 if ($char == '%9A')
2526 {
2527 return '%u0161';
2528 }
2529 if ($char == '%9B')
2530 {
2531 return '%u203A';
2532 }
2533 if ($char == '%9C')
2534 {
2535 return '%u0153';
2536 }
2537 if ($char == '%9E')
2538 {
2539 return '%u017E';
2540 }
2541 if ($char == '%9F')
2542 {
2543 return '%u0178';
2544 }
2545 return $char;
2546}
2547
2549{
2550 $result = "";
2551 for ($i = 0; $i < strlen($string); $i++)
2552 {
2553 $decstr = "";
2554 for ($p = 0; $p <= 5; $p++)
2555 {
2556 $decstr .= $string[$i+$p];
2557 }
2558 list($decodedstr, $num) = unescapebycharacter($decstr);
2559 $result .= urldecode($decodedstr);
2560 $i += $num ;
2561 }
2562 return $result;
2563}
2564
2566{
2567
2568 $char = $str;
2569
2570 if ($char == '%u20AC')
2571 {
2572 return array("%80", 5);
2573 }
2574 if ($char == '%u201A')
2575 {
2576 return array("%82", 5);
2577 }
2578 if ($char == '%u0192')
2579 {
2580 return array("%83", 5);
2581 }
2582 if ($char == '%u201E')
2583 {
2584 return array("%84", 5);
2585 }
2586 if ($char == '%u2026')
2587 {
2588 return array("%85", 5);
2589 }
2590 if ($char == '%u2020')
2591 {
2592 return array("%86", 5);
2593 }
2594 if ($char == '%u2021')
2595 {
2596 return array("%87", 5);
2597 }
2598 if ($char == '%u02C6')
2599 {
2600 return array("%88", 5);
2601 }
2602 if ($char == '%u2030')
2603 {
2604 return array("%89", 5);
2605 }
2606 if ($char == '%u0160')
2607 {
2608 return array("%8A", 5);
2609 }
2610 if ($char == '%u2039')
2611 {
2612 return array("%8B", 5);
2613 }
2614 if ($char == '%u0152')
2615 {
2616 return array("%8C", 5);
2617 }
2618 if ($char == '%u017D')
2619 {
2620 return array("%8E", 5);
2621 }
2622 if ($char == '%u2018')
2623 {
2624 return array("%91", 5);
2625 }
2626 if ($char == '%u2019')
2627 {
2628 return array("%92", 5);
2629 }
2630 if ($char == '%u201C')
2631 {
2632 return array("%93", 5);
2633 }
2634 if ($char == '%u201D')
2635 {
2636 return array("%94", 5);
2637 }
2638 if ($char == '%u2022')
2639 {
2640 return array("%95", 5);
2641 }
2642 if ($char == '%u2013')
2643 {
2644 return array("%96", 5);
2645 }
2646 if ($char == '%u2014')
2647 {
2648 return array("%97", 5);
2649 }
2650 if ($char == '%u02DC')
2651 {
2652 return array("%98", 5);
2653 }
2654 if ($char == '%u2122')
2655 {
2656 return array("%99", 5);
2657 }
2658 if ($char == '%u0161')
2659 {
2660 return array("%9A", 5);
2661 }
2662 if ($char == '%u203A')
2663 {
2664 return array("%9B", 5);
2665 }
2666 if ($char == '%u0153')
2667 {
2668 return array("%9C", 5);
2669 }
2670 if ($char == '%u017E')
2671 {
2672 return array("%9E", 5);
2673 }
2674 if ($char == '%u0178')
2675 {
2676 return array("%9F", 5);
2677 }
2678
2679 $char = substr($str, 0, 3);
2680 if ($char == "%20")
2681 {
2682 return array("+", 2);
2683 }
2684
2685 $char = substr($str, 0, 1);
2686
2687 if ($char == '*')
2688 {
2689 return array("%2A", 0);
2690 }
2691 if ($char == '+')
2692 {
2693 return array("%2B", 0);
2694 }
2695 if ($char == '/')
2696 {
2697 return array("%2F", 0);
2698 }
2699 if ($char == '@')
2700 {
2701 return array("%40", 0);
2702 }
2703
2704 if ($char == "%")
2705 {
2706 return array(substr($str, 0, 3), 2);
2707 }
2708 else
2709 {
2710 return array($char, 0);
2711 }
2712}
2713/**
2714 * @brief When data are transfered thanks ajax in a xml document, the xml
2715 * can not contains some character, to escape those characters, we must use this
2716 * function
2717 *@param $p_xml the xml to escape
2718 *@return the xml string with the forbidden char escaped
2719 *@see ajax_card.js ajaxFid
2720 */
2721function escape_xml($p_xml)
2722{
2723 $xml=$p_xml??"";
2724 $xml=noalyss_str_replace('&','&amp;',$xml);
2725 $xml=noalyss_str_replace('<','&lt;',$xml);
2726 $xml=noalyss_str_replace('>','&gt;',$xml);
2727 $xml=noalyss_str_replace("'",'&apos;',$xml);
2728 $xml=noalyss_str_replace('"','&quot;',$xml);
2729 return $xml;
2730}
2731/**
2732 * @brief
2733 * replace special char
2734 *@param $p_xml the xml to escape
2735 *@return the xml string with the forbidden char escaped
2736 *@see ajax_card.js ajaxFid
2737 *@see escape_xml
2738 */
2739function unescape_xml($p_xml)
2740{
2741 $xml=$p_xml??"";
2742 $xml=noalyss_str_replace('&amp;','&',$xml);
2743 $xml=noalyss_str_replace('&lt;','<',$xml);
2744 $xml=noalyss_str_replace('&gt;','>',$xml);
2745 $xml=noalyss_str_replace('&apos;',"'",$xml);
2746 $xml=noalyss_str_replace('&quot;','"',$xml);
2747 return $xml;
2748}
2749/**
2750 *load all the javascript only one time
2751 *
2752 */
2754{
2755 // check not called twiced
2756 static $already_call=0;
2757 if ( $already_call==1)return;
2758 $already_call=1;
2759
2760 include_once NOALYSS_INCLUDE."/lib/message_javascript.php";
2761 echo JS_INFOBULLE;
2762 echo js_include("jquery-3.6.0.min.js");
2763 echo <<<EOF
2764 <script>jQuery.noConflict();</script>
2765EOF;
2766 echo js_include('smoke.js');
2767 echo js_include('prototype.js');
2768 echo js_include('scriptaculous.js');
2769 echo js_include('noalyss_script.js');
2770 echo js_include('acc_ledger.js');
2771 echo js_include('accounting_item.js');
2772 echo js_include('ajax_fiche.js');
2773 echo js_include('anc_script.js');
2774 echo js_include('calc.js');
2775 echo js_include('card.js');
2776 echo js_include('compute_direct.js');
2777 echo js_include('compute.js');
2778 echo js_include('gestion.js');
2779 echo js_include('todo_list.js');
2780 echo js_include('anc_script.js');
2781 echo js_include('sorttable.js');
2782 echo js_include('nicEdit.js');
2783 echo js_include('managetable.js');
2784 echo js_include('acc_currency.js');
2785 echo js_include('taggroup.js');
2786 echo js_include('noalyss_checkbox.js');
2787
2788
2789}
2790/**
2791 * @brief Send header and json object
2792 * @param array $p_answer this array will be converted to json object
2793 * @see json_encode
2794 */
2795function json_response($p_answer)
2796{
2797 header("Content-type: application/json; charset: utf8", true);
2798 echo json_encode($p_answer,
2799 JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
2800}
2801
2802/**
2803 * @brief build a string with the attribute that javascript can use , that string must be included in a DOM element.
2804 * @note IMPORTANT : special chars will be translated(see htmlspecialchars function) : quote, double-quote , ampersand...
2805 * @param $pa_attribute array of pair key => value
2806 * @see htmlspecialchars()
2807 * @return HTML string
2808 */
2809function build_javascript_attribute($pa_attribute)
2810{
2811 $str_javascript_attr="";
2812 if (! empty ($pa_attribute)) {
2813 foreach ($pa_attribute as $key=>$value) {
2814 $str_javascript_attr.=sprintf(' "%s"="%s" ',h($key),h($value));
2815 }
2816 }
2817 return $str_javascript_attr;
2818}
2819
2820?>
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
else $num
h( $row[ 'oa_description'])
switch($op2) $xml
Definition: ajax_card.php:806
$p
Definition: array.php:34
const JS_INFOBULLE(!defined('MULTI'))
Definition: constant.php:320
global $version_noalyss
Definition: constant.php:26
$str
Definition: fiche.inc.php:91
load_all_script()
load all the javascript only one time
build_javascript_attribute($pa_attribute)
build a string with the attribute that javascript can use , that string must be included in a DOM ele...
decodeURIComponentbycharacter($str)
encodeURIComponentbycharacter($char)
encodeURIComponent($string)
decodeURIbycharacter($str)
js_include($p_string)
create the HTML for including of a javascript file if a file is included twice, the second time it wi...
create_script($p_string)
create the HTML for adding the script tags around of the script
encodeURIbycharacter($char)
unescape($string)
escape($string)
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...
decodeURI($string)
decodeURIComponent($string)
unescape_xml($p_xml)
replace special char
unescapebycharacter($str)
json_response($p_answer)
Send header and json object.
encodeURI($string)
escapebycharacter($char)
$script
Definition: popup.php:125