IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Traducteur php maison


Sujet :

Langage PHP

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut Traducteur php maison
    Bonjour à tous, je cherche un moyen pour faire un traducteur maison; vous rentrez une url, et le script se charge de remplacer les mots "camion" par "voiture", "bouche" par "bec".... à la manière du défunt Ch'timisator (d'ailleurs impossible de trouver son code source et il a disparu du web..)


    Bref je me base sur un script du type générateur de short URL, dans lequel je mets un : require "dico.php"


    mais ensuite dans ce dico.php je ne sais pas par où commencer:

    en mettant ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <?php
     
    str_replace("Entreprise", "boite");
    str_replace("Entre", "sort");
    .....
     
    ?>
    cela ne fonctionne pas.


    Le but du script est de rechercher tous les mots dans la page qui contienne par exemple "camion" et remplacer ce mot.

    Auriez vous une piste??


    Merci à vous.

  2. #2
    Membre émérite
    Avatar de badaze
    Homme Profil pro
    Chef de projets info
    Inscrit en
    Septembre 2002
    Messages
    1 412
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projets info
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2002
    Messages : 1 412
    Points : 2 522
    Points
    2 522
    Par défaut
    Poste le code que tu as car si tu as écrit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    str_replace("Entreprise", "boite");
    c'est sûr que ça ne marchera pas
    Cela ne sert à rien d'optimiser quelque chose qui ne fonctionne pas.

    Mon site : www.emmella.fr

    Je recherche le manuel de l'Olivetti Logos 80B.

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    merci de la réactivité.

    voici index.php ou l'utilisateur rentrera l'url.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    <?php
     
    /*
       +-----------------+------------------------------------------------------------+
       |  Script         | PHProxy                                                    |
       |  Author         | Abdullah Arif                                              |
       |  Last Modified  | 5:27 PM 1/20/2007                                          |
       +-----------------+------------------------------------------------------------+
       |  This program is free software; you can redistribute it and/or               |
       |  modify it under the terms of the GNU General Public License                 |
       |  as published by the Free Software Foundation; either version 2              |
       |  of the License, or (at your option) any later version.                      |
       |                                                                              |
       |  This program is distributed in the hope that it will be useful,             |
       |  but WITHOUT ANY WARRANTY; without even the implied warranty of              |
       |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
       |  GNU General Public License for more details.                                |
       |                                                                              |
       |  You should have received a copy of the GNU General Public License           |
       |  along with this program; if not, write to the Free Software                 |
       |  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
       +------------------------------------------------------------------------------+
    */
     
    error_reporting(E_ALL);
     
    //
    // CONFIGURABLE OPTIONS
    //
     
      // Importations avec require()
      require'dico.php';
     
     
    $_config            = array
                        (
                            'url_var_name'             => 'q',
                            'flags_var_name'           => 'hl',
                            'get_form_name'            => '____pgfa',
                            'basic_auth_var_name'      => '____pbavn',
                            'max_file_size'            => -1,
                            'allow_hotlinking'         => 0,
                            'upon_hotlink'             => 1,
                            'compress_output'          => 0
                        );
    $_flags             = array
                        (
                            'include_form'    => 1, 
                            'remove_scripts'  => 1,
                            'accept_cookies'  => 1,
                            'show_images'     => 1,
                            'show_referer'    => 1,
                            'rotate13'        => 0,
                            'base64_encode'   => 1,
                            'strip_meta'      => 1,
                            'strip_title'     => 0,
                            'session_cookies' => 1
                        );
    $_frozen_flags      = array
                        (
                            'include_form'    => 0, 
                            'remove_scripts'  => 0,
                            'accept_cookies'  => 0,
                            'show_images'     => 0,
                            'show_referer'    => 0,
                            'rotate13'        => 0,
                            'base64_encode'   => 0,
                            'strip_meta'      => 0,
                            'strip_title'     => 0,
                            'session_cookies' => 0
                        );                    
    $_labels            = array
                        (
                            'include_form'    => array('Include Form', 'Include mini URL-form on every page'), 
                            'remove_scripts'  => array('Remove Scripts', 'Remove client-side scripting (i.e JavaScript)'), 
                            'accept_cookies'  => array('Accept Cookies', 'Allow cookies to be stored'), 
                            'show_images'     => array('Show Images', 'Show images on browsed pages'), 
                            'show_referer'    => array('Show Referer', 'Show actual referring Website'), 
                            'rotate13'        => array('Rotate13', 'Use ROT13 encoding on the address'), 
                            'base64_encode'   => array('Base64', 'Use base64 encodng on the address'), 
                            'strip_meta'      => array('Strip Meta', 'Strip meta information tags from pages'), 
                            'strip_title'     => array('Strip Title', 'Strip page title'), 
                            'session_cookies' => array('Session Cookies', 'Store cookies for this session only') 
                        );
     
    $_hosts             = array
                        (
                            '#^127\.|192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\.|localhost#i'
                        );
    $_hotlink_domains   = array();
    $_insert            = array();
     
    //
    // END CONFIGURABLE OPTIONS. The ride for you ends here. Close the file.
    //
     
    $_iflags            = '';
    $_system            = array
                        (
                            'ssl'          => extension_loaded('openssl') && version_compare(PHP_VERSION, '4.3.0', '>='),
                            'uploads'      => ini_get('file_uploads'),
                            'gzip'         => extension_loaded('zlib') && !ini_get('zlib.output_compression'),
                            'stripslashes' => get_magic_quotes_gpc()
                        );
    $_proxify           = array('text/html' => 1, 'application/xml+xhtml' => 1, 'application/xhtml+xml' => 1, 'text/css' => 1);
    $_version           = '0.5b2';
    $_http_host         = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
    $_script_url        = 'http' . ((isset($_ENV['HTTPS']) && $_ENV['HTTPS'] == 'on') || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_http_host . ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'];
    $_script_base       = substr($_script_url, 0, strrpos($_script_url, '/')+1);
    $_url               = '';
    $_url_parts         = array();
    $_base              = array();
    $_socket            = null;
    $_request_method    = $_SERVER['REQUEST_METHOD'];
    $_request_headers   = '';
    $_cookie            = '';
    $_post_body         = '';
    $_response_headers  = array();
    $_response_keys     = array();  
    $_http_version      = '';
    $_response_code     = 0;
    $_content_type      = 'text/html';
    $_content_length    = false;
    $_content_disp      = '';
    $_set_cookie        = array();
    $_retry             = false;
    $_quit              = false;
    $_basic_auth_header = '';
    $_basic_auth_realm  = '';
    $_auth_creds        = array();
    $_response_body     = '';
     
    //
    // FUNCTION DECLARATIONS
    //
     
    function show_report($data)
    {    
        include $data['which'] . '.inc.php';
        exit(0);
    }
     
    function add_cookie($name, $value, $expires = 0)
    {
        return rawurlencode(rawurlencode($name)) . '=' . rawurlencode(rawurlencode($value)) . (empty($expires) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s \G\M\T', $expires)) . '; path=/; domain=.' . $GLOBALS['_http_host'];
    }
     
    function set_post_vars($array, $parent_key = null)
    {
        $temp = array();
     
        foreach ($array as $key => $value)
        {
            $key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, urlencode($key)) : urlencode($key);
            if (is_array($value))
            {
                $temp = array_merge($temp, set_post_vars($value, $key));
            }
            else
            {
                $temp[$key] = urlencode($value);
            }
        }
     
        return $temp;
    }
     
    function set_post_files($array, $parent_key = null)
    {
        $temp = array();
     
        foreach ($array as $key => $value)
        {
            $key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, urlencode($key)) : urlencode($key);
            if (is_array($value))
            {
                $temp = array_merge_recursive($temp, set_post_files($value, $key));
            }
            else if (preg_match('#^([^\[\]]+)\[(name|type|tmp_name)\]#', $key, $m))
            {
                $temp[str_replace($m[0], $m[1], $key)][$m[2]] = $value;
            }
        }
     
        return $temp;
    }
     
    function url_parse($url, & $container)
    {
        $temp = @parse_url($url);
     
        if (!empty($temp))
        {
            $temp['port_ext'] = '';
            $temp['base']     = $temp['scheme'] . '://' . $temp['host'];
     
            if (isset($temp['port']))
            {
                $temp['base'] .= $temp['port_ext'] = ':' . $temp['port'];
            }
            else
            {
                $temp['port'] = $temp['scheme'] === 'https' ? 443 : 80;
            }
     
            $temp['path'] = isset($temp['path']) ? $temp['path'] : '/';
            $path         = array();
            $temp['path'] = explode('/', $temp['path']);
     
            foreach ($temp['path'] as $dir)
            {
                if ($dir === '..')
                {
                    array_pop($path);
                }
                else if ($dir !== '.')
                {
                    for ($dir = rawurldecode($dir), $new_dir = '', $i = 0, $count_i = strlen($dir); $i < $count_i; $new_dir .= strspn($dir{$i}, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$-_.+!*\'(),?:@&;=') ? $dir{$i} : rawurlencode($dir{$i}), ++$i);
                    $path[] = $new_dir;
                }
            }
     
            $temp['path']     = str_replace('/%7E', '/~', '/' . ltrim(implode('/', $path), '/'));
            $temp['file']     = substr($temp['path'], strrpos($temp['path'], '/')+1);
            $temp['dir']      = substr($temp['path'], 0, strrpos($temp['path'], '/'));
            $temp['base']    .= $temp['dir'];
            $temp['prev_dir'] = substr_count($temp['path'], '/') > 1 ? substr($temp['base'], 0, strrpos($temp['base'], '/')+1) : $temp['base'] . '/';
            $container = $temp;
     
            return true;
        }
     
        return false;
    }
     
    function complete_url($url, $proxify = true)
    {
        $url = trim($url);
     
        if ($url === '')
        {
            return '';
        }
     
        $hash_pos = strrpos($url, '#');
        $fragment = $hash_pos !== false ? '#' . substr($url, $hash_pos) : '';
        $sep_pos  = strpos($url, '://');
     
        if ($sep_pos === false || $sep_pos > 5)
        {
            switch ($url{0})
            {
                case '/':
                    $url = substr($url, 0, 2) === '//' ? $GLOBALS['_base']['scheme'] . ':' . $url : $GLOBALS['_base']['scheme'] . '://' . $GLOBALS['_base']['host'] . $GLOBALS['_base']['port_ext'] . $url;
                    break;
                case '?':
                    $url = $GLOBALS['_base']['base'] . '/' . $GLOBALS['_base']['file'] . $url;
                    break;
                case '#':
                    $proxify = false;
                    break;
                case 'm':
                    if (substr($url, 0, 7) == 'mailto:')
                    {
                        $proxify = false;
                        break;
                    }
                default:
                    $url = $GLOBALS['_base']['base'] . '/' . $url;
            }
        }
     
        return $proxify ? "{$GLOBALS['_script_url']}?{$GLOBALS['_config']['url_var_name']}=" . encode_url($url) . $fragment : $url;
    }
     
    function proxify_inline_css($css)
    {
        preg_match_all('#url\s*\(\s*(([^)]*(\\\))*[^)]*)(\)|$)?#i', $css, $matches, PREG_SET_ORDER);
     
        for ($i = 0, $count = count($matches); $i < $count; ++$i)
        {
            $css = str_replace($matches[$i][0], 'url(' . proxify_css_url($matches[$i][1]) . ')', $css);
        }
     
        return $css;
    }
     
    function proxify_css($css)
    {
        $css = proxify_inline_css($css);
     
        preg_match_all("#@import\s*(?:\"([^\">]*)\"?|'([^'>]*)'?)([^;]*)(;|$)#i", $css, $matches, PREG_SET_ORDER);
     
        for ($i = 0, $count = count($matches); $i < $count; ++$i)
        {
            $delim = '"';
            $url   = $matches[$i][2];
     
            if (isset($matches[$i][3]))
            {
                $delim = "'";
                $url = $matches[$i][3];
            }
     
            $css = str_replace($matches[$i][0], '@import ' . $delim . proxify_css_url($matches[$i][1]) . $delim . (isset($matches[$i][4]) ? $matches[$i][4] : ''), $css);
        }
     
        return $css;
    }
     
    function proxify_css_url($url)
    {
        $url   = trim($url);
        $delim = strpos($url, '"') === 0 ? '"' : (strpos($url, "'") === 0 ? "'" : '');
     
        return $delim . preg_replace('#([\(\),\s\'"\\\])#', '\\$1', complete_url(trim(preg_replace('#\\\(.)#', '$1', trim($url, $delim))))) . $delim;
    }
     
    //
    // SET FLAGS
    //
     
    if (isset($_POST[$_config['url_var_name']]) && !isset($_GET[$_config['url_var_name']]) && isset($_POST[$_config['flags_var_name']]))
    {    
        foreach ($_flags as $flag_name => $flag_value)
        {
            $_iflags .= isset($_POST[$_config['flags_var_name']][$flag_name]) ? (string)(int)(bool)$_POST[$_config['flags_var_name']][$flag_name] : ($_frozen_flags[$flag_name] ? $flag_value : '0');
        }
     
        $_iflags = base_convert(($_iflags != '' ? $_iflags : '0'), 2, 16);
    }
    else if (isset($_GET[$_config['flags_var_name']]) && !isset($_GET[$_config['get_form_name']]) && ctype_alnum($_GET[$_config['flags_var_name']]))
    {
        $_iflags = $_GET[$_config['flags_var_name']];
    }
    else if (isset($_COOKIE['flags']) && ctype_alnum($_COOKIE['flags']))
    {
        $_iflags = $_COOKIE['flags'];
    }
     
    if ($_iflags !== '')
    {
        $_set_cookie[] = add_cookie('flags', $_iflags, time()+2419200);
        $_iflags = str_pad(base_convert($_iflags, 16, 2), count($_flags), '0', STR_PAD_LEFT);
        $i = 0;
     
        foreach ($_flags as $flag_name => $flag_value)
        {
            $_flags[$flag_name] = $_frozen_flags[$flag_name] ? $flag_value : (int)(bool)$_iflags{$i};
            $i++;
        }
    }
     
    //
    // DETERMINE URL-ENCODING BASED ON FLAGS
    //
     
    if ($_flags['rotate13'])
    {
        function encode_url($url)
        {
            return rawurlencode(str_rot13($url));
        }
        function decode_url($url)
        {
            return str_replace(array('&amp;', '&'), '&', str_rot13(rawurldecode($url)));
        }
    }
    else if ($_flags['base64_encode'])
    {
        function encode_url($url)
        {
            return rawurlencode(base64_encode($url));
        }
        function decode_url($url)
        {
            return str_replace(array('&amp;', '&'), '&', base64_decode(rawurldecode($url)));
        }
    }
    else
    {
        function encode_url($url)
        {
            return rawurlencode($url);
        }
        function decode_url($url)
        {
            return str_replace(array('&amp;', '&'), '&', rawurldecode($url));
        }
    }
     
    //
    // COMPRESS OUTPUT IF INSTRUCTED
    //
     
    if ($_config['compress_output'] && $_system['gzip'])
    {
        ob_start('ob_gzhandler');
    }
     
    //
    // STRIP SLASHES FROM GPC IF NECESSARY
    //
     
    if ($_system['stripslashes'])
    {
        function _stripslashes($value)
        {
            return is_array($value) ? array_map('_stripslashes', $value) : (is_string($value) ? stripslashes($value) : $value);
        }
     
        $_GET    = _stripslashes($_GET);
        $_POST   = _stripslashes($_POST);
        $_COOKIE = _stripslashes($_COOKIE);
    }
     
    //
    // FIGURE OUT WHAT TO DO (POST URL-form submit, GET form request, regular request, basic auth, cookie manager, show URL-form)
    //
     
    if (isset($_POST[$_config['url_var_name']]) && !isset($_GET[$_config['url_var_name']]))
    {   
        header('Location: ' . $_script_url . '?' . $_config['url_var_name'] . '=' . encode_url($_POST[$_config['url_var_name']]) . '&' . $_config['flags_var_name'] . '=' . base_convert($_iflags, 2, 16));
        exit(0);
    }
     
    if (isset($_GET[$_config['get_form_name']]))
    {
        $_url  = decode_url($_GET[$_config['get_form_name']]);
        $qstr = strpos($_url, '?') !== false ? (strpos($_url, '?') === strlen($_url)-1 ? '' : '&') : '?';
        $arr  = explode('&', $_SERVER['QUERY_STRING']);
     
        if (preg_match('#^\Q' . $_config['get_form_name'] . '\E#', $arr[0]))
        {
            array_shift($arr);
        }
     
        $_url .= $qstr . implode('&', $arr);
    }
    else if (isset($_GET[$_config['url_var_name']]))
    {
        $_url = decode_url($_GET[$_config['url_var_name']]);
    }
    else if (isset($_GET['action']) && $_GET['action'] == 'cookies')
    {
        show_report(array('which' => 'cookies'));
    }
    else
    {
        show_report(array('which' => 'index', 'category' => 'entry_form'));
    }
     
    if (isset($_GET[$_config['url_var_name']], $_POST[$_config['basic_auth_var_name']], $_POST['username'], $_POST['password']))
    {
        $_request_method    = 'GET';
        $_basic_auth_realm  = base64_decode($_POST[$_config['basic_auth_var_name']]);
        $_basic_auth_header = base64_encode($_POST['username'] . ':' . $_POST['password']);
    }
     
    //
    // SET URL
    //
     
    if (strpos($_url, '://') === false)
    {
        $_url = 'http://' . $_url;
    }
     
    if (url_parse($_url, $_url_parts))
    {
        $_base = $_url_parts;
     
        if (!empty($_hosts))
        {
            foreach ($_hosts as $host)
            {
                if (preg_match($host, $_url_parts['host']))
                {
                    show_report(array('which' => 'index', 'category' => 'error', 'group' => 'url', 'type' => 'external', 'error' => 1));
                }
            }
        }
    }
    else
    {
        show_report(array('which' => 'index', 'category' => 'error', 'group' => 'url', 'type' => 'external', 'error' => 2));
    }
     
    //
    // HOTLINKING PREVENTION
    //
     
    if (!$_config['allow_hotlinking'] && isset($_SERVER['HTTP_REFERER']))
    {
        $_hotlink_domains[] = $_http_host;
        $is_hotlinking      = true;
     
        foreach ($_hotlink_domains as $host)
        {
            if (preg_match('#^https?\:\/\/(www)?\Q' . $host  . '\E(\/|\:|$)#i', trim($_SERVER['HTTP_REFERER'])))
            {
                $is_hotlinking = false;
                break;
            }
        }
     
        if ($is_hotlinking)
        {
            switch ($_config['upon_hotlink'])
            {
                case 1:
                    show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'hotlinking'));
                    break;
                case 2:
                    header('HTTP/1.0 404 Not Found');
                    exit(0);
                default:
                    header('Location: ' . $_config['upon_hotlink']);
                    exit(0);
            }
        }
    }
     
    //
    // OPEN SOCKET TO SERVER
    //
     
    do
    {
        $_retry  = false;
        $_socket = @fsockopen(($_url_parts['scheme'] === 'https' && $_system['ssl'] ? 'ssl://' : 'tcp://') . $_url_parts['host'], $_url_parts['port'], $err_no, $err_str, 30);
     
        if ($_socket === false)
        {
            show_report(array('which' => 'index', 'category' => 'error', 'group' => 'url', 'type' => 'internal', 'error' => $err_no));
        }
     
        //
        // SET REQUEST HEADERS
        //
     
        $_request_headers  = $_request_method . ' ' . $_url_parts['path'];
     
        if (isset($_url_parts['query']))
        {
            $_request_headers .= '?';
            $query = preg_split('#([&;])#', $_url_parts['query'], -1, PREG_SPLIT_DELIM_CAPTURE);
            for ($i = 0, $count = count($query); $i < $count; $_request_headers .= implode('=', array_map('urlencode', array_map('urldecode', explode('=', $query[$i])))) . (isset($query[++$i]) ? $query[$i] : ''), $i++);
        }
     
        $_request_headers .= " HTTP/1.0\r\n";
        $_request_headers .= 'Host: ' . $_url_parts['host'] . $_url_parts['port_ext'] . "\r\n";
     
        if (isset($_SERVER['HTTP_USER_AGENT']))
        {
            $_request_headers .= 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
        }
        if (isset($_SERVER['HTTP_ACCEPT']))
        {
            $_request_headers .= 'Accept: ' . $_SERVER['HTTP_ACCEPT'] . "\r\n";
        }
        else
        {
            $_request_headers .= "Accept: */*;q=0.1\r\n";
        }
        if ($_flags['show_referer'] && isset($_SERVER['HTTP_REFERER']) && preg_match('#^\Q' . $_script_url . '?' . $_config['url_var_name'] . '=\E([^&]+)#', $_SERVER['HTTP_REFERER'], $matches))
        {
            $_request_headers .= 'Referer: ' . decode_url($matches[1]) . "\r\n";
        }
        if (!empty($_COOKIE))
        {
            $_cookie  = '';
            $_auth_creds    = array();
     
            foreach ($_COOKIE as $cookie_id => $cookie_content)
            {
                $cookie_id      = explode(';', rawurldecode($cookie_id));
                $cookie_content = explode(';', rawurldecode($cookie_content));
     
                if ($cookie_id[0] === 'COOKIE')
                {
                    $cookie_id[3] = str_replace('_', '.', $cookie_id[3]); //stupid PHP can't have dots in var names
     
                    if (count($cookie_id) < 4 || ($cookie_content[1] == 'secure' && $_url_parts['scheme'] != 'https'))
                    {
                        continue;
                    }
     
                    if ((preg_match('#\Q' . $cookie_id[3] . '\E$#i', $_url_parts['host']) || strtolower($cookie_id[3]) == strtolower('.' . $_url_parts['host'])) && preg_match('#^\Q' . $cookie_id[2] . '\E#', $_url_parts['path']))
                    {
                        $_cookie .= ($_cookie != '' ? '; ' : '') . (empty($cookie_id[1]) ? '' : $cookie_id[1] . '=') . $cookie_content[0];
                    }
                }
                else if ($cookie_id[0] === 'AUTH' && count($cookie_id) === 3)
                {
                    $cookie_id[2] = str_replace('_', '.', $cookie_id[2]);
     
                    if ($_url_parts['host'] . ':' . $_url_parts['port'] === $cookie_id[2])
                    {
                        $_auth_creds[$cookie_id[1]] = $cookie_content[0];
                    }
                }
            }
     
            if ($_cookie != '')
            {
                $_request_headers .= "Cookie: $_cookie\r\n";
            }
        }
        if (isset($_url_parts['user'], $_url_parts['pass']))
        {
            $_basic_auth_header = base64_encode($_url_parts['user'] . ':' . $_url_parts['pass']);
        }
        if (!empty($_basic_auth_header))
        {
            $_set_cookie[] = add_cookie("AUTH;{$_basic_auth_realm};{$_url_parts['host']}:{$_url_parts['port']}", $_basic_auth_header);
            $_request_headers .= "Authorization: Basic {$_basic_auth_header}\r\n";
        }
        else if (!empty($_basic_auth_realm) && isset($_auth_creds[$_basic_auth_realm]))
        {
            $_request_headers  .= "Authorization: Basic {$_auth_creds[$_basic_auth_realm]}\r\n";
        }
        else if (list($_basic_auth_realm, $_basic_auth_header) = each($_auth_creds))
        {
            $_request_headers .= "Authorization: Basic {$_basic_auth_header}\r\n";
        }
        if ($_request_method == 'POST')
        {   
            if (!empty($_FILES) && $_system['uploads'])
            {
                $_data_boundary = '----' . md5(uniqid(rand(), true));
                $array = set_post_vars($_POST);
     
                foreach ($array as $key => $value)
                {
                    $_post_body .= "--{$_data_boundary}\r\n";
                    $_post_body .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
                    $_post_body .= urldecode($value) . "\r\n";
                }
     
                $array = set_post_files($_FILES);
     
                foreach ($array as $key => $file_info)
                {
                    $_post_body .= "--{$_data_boundary}\r\n";
                    $_post_body .= "Content-Disposition: form-data; name=\"$key\"; filename=\"{$file_info['name']}\"\r\n";
                    $_post_body .= 'Content-Type: ' . (empty($file_info['type']) ? 'application/octet-stream' : $file_info['type']) . "\r\n\r\n";
     
                    if (is_readable($file_info['tmp_name']))
                    {
                        $handle = fopen($file_info['tmp_name'], 'rb');
                        $_post_body .= fread($handle, filesize($file_info['tmp_name']));
                        fclose($handle);
                    }
     
                    $_post_body .= "\r\n";
                }
     
                $_post_body       .= "--{$_data_boundary}--\r\n";
                $_request_headers .= "Content-Type: multipart/form-data; boundary={$_data_boundary}\r\n";
                $_request_headers .= "Content-Length: " . strlen($_post_body) . "\r\n\r\n";
                $_request_headers .= $_post_body;
            }
            else
            {
                $array = set_post_vars($_POST);
     
                foreach ($array as $key => $value)
                {
                    $_post_body .= !empty($_post_body) ? '&' : '';
                    $_post_body .= $key . '=' . $value;
                }
                $_request_headers .= "Content-Type: application/x-www-form-urlencoded\r\n";
                $_request_headers .= "Content-Length: " . strlen($_post_body) . "\r\n\r\n";
                $_request_headers .= $_post_body;
                $_request_headers .= "\r\n";
            }
     
            $_post_body = '';
        }
        else
        {
            $_request_headers .= "\r\n";
        }
     
        fwrite($_socket, $_request_headers);
     
        //
        // PROCESS RESPONSE HEADERS
        //
     
        $_response_headers = $_response_keys = array();
     
        $line = fgets($_socket, 8192);
     
        while (strspn($line, "\r\n") !== strlen($line))
        {
            @list($name, $value) = explode(':', $line, 2);
            $name = trim($name);
            $_response_headers[strtolower($name)][] = trim($value);
            $_response_keys[strtolower($name)] = $name;
            $line = fgets($_socket, 8192);
        }
     
        sscanf(current($_response_keys), '%s %s', $_http_version, $_response_code);
     
        if (isset($_response_headers['content-type']))
        {
            list($_content_type, ) = explode(';', str_replace(' ', '', strtolower($_response_headers['content-type'][0])), 2);
        }
        if (isset($_response_headers['content-length']))
        {
            $_content_length = $_response_headers['content-length'][0];
            unset($_response_headers['content-length'], $_response_keys['content-length']);
        }
        if (isset($_response_headers['content-disposition']))
        {
            $_content_disp = $_response_headers['content-disposition'][0];
            unset($_response_headers['content-disposition'], $_response_keys['content-disposition']);
        }
        if (isset($_response_headers['set-cookie']) && $_flags['accept_cookies'])
        {
            foreach ($_response_headers['set-cookie'] as $cookie)
            {
                $name = $value = $expires = $path = $domain = $secure = $expires_time = '';
     
                preg_match('#^\s*([^=;,\s]*)\s*=?\s*([^;]*)#',  $cookie, $match) && list(, $name, $value) = $match;
                preg_match('#;\s*expires\s*=\s*([^;]*)#i',      $cookie, $match) && list(, $expires)      = $match;
                preg_match('#;\s*path\s*=\s*([^;,\s]*)#i',      $cookie, $match) && list(, $path)         = $match;
                preg_match('#;\s*domain\s*=\s*([^;,\s]*)#i',    $cookie, $match) && list(, $domain)       = $match;
                preg_match('#;\s*(secure\b)#i',                 $cookie, $match) && list(, $secure)       = $match;
     
                $expires_time = empty($expires) ? 0 : intval(@strtotime($expires));
                $expires = ($_flags['session_cookies'] && !empty($expires) && time()-$expires_time < 0) ? '' : $expires;
                $path    = empty($path)   ? '/' : $path;
     
                if (empty($domain))
                {
                    $domain = $_url_parts['host'];
                }
                else
                {
                    $domain = '.' . strtolower(str_replace('..', '.', trim($domain, '.')));
     
                    if ((!preg_match('#\Q' . $domain . '\E$#i', $_url_parts['host']) && $domain != '.' . $_url_parts['host']) || (substr_count($domain, '.') < 2 && $domain{0} == '.'))
                    {
                        continue;
                    }
                }
                if (count($_COOKIE) >= 15 && time()-$expires_time <= 0)
                {
                    $_set_cookie[] = add_cookie(current($_COOKIE), '', 1);
                }
     
                $_set_cookie[] = add_cookie("COOKIE;$name;$path;$domain", "$value;$secure", $expires_time);
            }
        }
        if (isset($_response_headers['set-cookie']))
        {
            unset($_response_headers['set-cookie'], $_response_keys['set-cookie']);
        }
        if (!empty($_set_cookie))
        {
            $_response_keys['set-cookie'] = 'Set-Cookie';
            $_response_headers['set-cookie'] = $_set_cookie;
        }
        if (isset($_response_headers['p3p']) && preg_match('#policyref\s*=\s*[\'"]?([^\'"\s]*)[\'"]?#i', $_response_headers['p3p'][0], $matches))
        {
            $_response_headers['p3p'][0] = str_replace($matches[0], 'policyref="' . complete_url($matches[1]) . '"', $_response_headers['p3p'][0]);
        }
        if (isset($_response_headers['refresh']) && preg_match('#([0-9\s]*;\s*URL\s*=)\s*(\S*)#i', $_response_headers['refresh'][0], $matches))
        {
            $_response_headers['refresh'][0] = $matches[1] . complete_url($matches[2]);
        }
        if (isset($_response_headers['location']))
        {   
            $_response_headers['location'][0] = complete_url($_response_headers['location'][0]);
        }
        if (isset($_response_headers['uri']))
        {   
            $_response_headers['uri'][0] = complete_url($_response_headers['uri'][0]);
        }
        if (isset($_response_headers['content-location']))
        {   
            $_response_headers['content-location'][0] = complete_url($_response_headers['content-location'][0]);
        }
        if (isset($_response_headers['connection']))
        {
            unset($_response_headers['connection'], $_response_keys['connection']);
        }
        if (isset($_response_headers['keep-alive']))
        {
            unset($_response_headers['keep-alive'], $_response_keys['keep-alive']);
        }
        if ($_response_code == 401 && isset($_response_headers['www-authenticate']) && preg_match('#basic\s+(?:realm="(.*?)")?#i', $_response_headers['www-authenticate'][0], $matches))
        {
            if (isset($_auth_creds[$matches[1]]) && !$_quit)
            {
                $_basic_auth_realm  = $matches[1];
                $_basic_auth_header = '';
                $_retry = $_quit = true;
            }
            else
            {
                show_report(array('which' => 'index', 'category' => 'auth', 'realm' => $matches[1]));
            }
        }
    }
    while ($_retry);
     
    //
    // OUTPUT RESPONSE IF NO PROXIFICATION IS NEEDED
    //  
     
    if (!isset($_proxify[$_content_type]))
    {
        @set_time_limit(0);
     
        $_response_keys['content-disposition'] = 'Content-Disposition';
        $_response_headers['content-disposition'][0] = empty($_content_disp) ? ($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $_url_parts['file'] . '"' : $_content_disp;
     
        if ($_content_length !== false)
        {
            if ($_config['max_file_size'] != -1 && $_content_length > $_config['max_file_size'])
            {
                show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'file_size'));
            }
     
            $_response_keys['content-length'] = 'Content-Length';
            $_response_headers['content-length'][0] = $_content_length;
        }
     
        $_response_headers   = array_filter($_response_headers);
        $_response_keys      = array_filter($_response_keys);
     
        header(array_shift($_response_keys));
        array_shift($_response_headers);
     
        foreach ($_response_headers as $name => $array)
        {
            foreach ($array as $value)
            {
                header($_response_keys[$name] . ': ' . $value, false);
            }
        }
     
        do
        {
            $data = fread($_socket, 8192);
            echo $data;
        }
        while (isset($data{0}));
     
        fclose($_socket);
        exit(0);
    }
     
    do
    {
        $data = @fread($_socket, 8192); // silenced to avoid the "normal" warning by a faulty SSL connection
        $_response_body .= $data;
    }   
    while (isset($data{0}));
     
    unset($data);
    fclose($_socket);
     
    //
    // MODIFY AND DUMP RESOURCE
    //
     
    if ($_content_type == 'text/css')
    {
        $_response_body = proxify_css($_response_body);
    }
    else
    {
        if ($_flags['strip_title'])
        {
            $_response_body = preg_replace('#(<\s*title[^>]*>)(.*?)(<\s*/title[^>]*>)#is', '$1$3', $_response_body);
        }
        if ($_flags['remove_scripts'])
        {
            $_response_body = preg_replace('#<\s*script[^>]*?>.*?<\s*/\s*script\s*>#si', '', $_response_body);
            $_response_body = preg_replace("#(\bon[a-z]+)\s*=\s*(?:\"([^\"]*)\"?|'([^']*)'?|([^'\"\s>]*))?#i", '', $_response_body);
            $_response_body = preg_replace('#<noscript>(.*?)</noscript>#si', "$1", $_response_body);
        }
        if (!$_flags['show_images'])
        {
            $_response_body = preg_replace('#<(img|image)[^>]*?>#si', '', $_response_body);
        }
     
        //
        // PROXIFY HTML RESOURCE
        //
     
        $tags = array
        (
            'a'          => array('href'),
            'img'        => array('src', 'longdesc'),
            'image'      => array('src', 'longdesc'),
            'body'       => array('background'),
            'base'       => array('href'),
            'frame'      => array('src', 'longdesc'),
            'iframe'     => array('src', 'longdesc'),
            'head'       => array('profile'),
            'layer'      => array('src'),
            'input'      => array('src', 'usemap'),
            'form'       => array('action'),
            'area'       => array('href'),
            'link'       => array('href', 'src', 'urn'),
            'meta'       => array('content'),
            'param'      => array('value'),
            'applet'     => array('codebase', 'code', 'object', 'archive'),
            'object'     => array('usermap', 'codebase', 'classid', 'archive', 'data'),
            'script'     => array('src'),
            'select'     => array('src'),
            'hr'         => array('src'),
            'table'      => array('background'),
            'tr'         => array('background'),
            'th'         => array('background'),
            'td'         => array('background'),
            'bgsound'    => array('src'),
            'blockquote' => array('cite'),
            'del'        => array('cite'),
            'embed'      => array('src'),
            'fig'        => array('src', 'imagemap'),
            'ilayer'     => array('src'),
            'ins'        => array('cite'),
            'note'       => array('src'),
            'overlay'    => array('src', 'imagemap'),
            'q'          => array('cite'),
            'ul'         => array('src')
        );
     
        preg_match_all('#(<\s*style[^>]*>)(.*?)(<\s*/\s*style[^>]*>)#is', $_response_body, $matches, PREG_SET_ORDER);
     
        for ($i = 0, $count_i = count($matches); $i < $count_i; ++$i)
        {
            $_response_body = str_replace($matches[$i][0], $matches[$i][1]. proxify_css($matches[$i][2]) .$matches[$i][3], $_response_body);
        }
     
        preg_match_all("#<\s*([a-zA-Z\?-]+)([^>]+)>#S", $_response_body, $matches);
     
        for ($i = 0, $count_i = count($matches[0]); $i < $count_i; ++$i)
        {
            if (!preg_match_all("#([a-zA-Z\-\/]+)\s*(?:=\s*(?:\"([^\">]*)\"?|'([^'>]*)'?|([^'\"\s]*)))?#S", $matches[2][$i], $m, PREG_SET_ORDER))
            {
                continue;
            }
     
            $rebuild    = false;
            $extra_html = $temp = '';
            $attrs      = array();
     
            for ($j = 0, $count_j = count($m); $j < $count_j; $attrs[strtolower($m[$j][1])] = (isset($m[$j][4]) ? $m[$j][4] : (isset($m[$j][3]) ? $m[$j][3] : (isset($m[$j][2]) ? $m[$j][2] : false))), ++$j);
     
            if (isset($attrs['style']))
            {
                $rebuild = true;
                $attrs['style'] = proxify_inline_css($attrs['style']);
            }
     
            $tag = strtolower($matches[1][$i]);
     
            if (isset($tags[$tag]))
            {
                switch ($tag)
                {
                    case 'a':
                        if (isset($attrs['href']))
                        {
                            $rebuild = true;
                            $attrs['href'] = complete_url($attrs['href']);
                        }
                        break;
                    case 'img':
                        if (isset($attrs['src']))
                        {
                            $rebuild = true;
                            $attrs['src'] = complete_url($attrs['src']);
                        }
                        if (isset($attrs['longdesc']))
                        {
                            $rebuild = true;
                            $attrs['longdesc'] = complete_url($attrs['longdesc']);
                        }
                        break;
                    case 'form':
                        if (isset($attrs['action']))
                        {
                            $rebuild = true;
     
                            if (trim($attrs['action']) === '')
                            {
                                $attrs['action'] = $_url_parts['path'];
                            }
                            if (!isset($attrs['method']) || strtolower(trim($attrs['method'])) === 'get')
                            {
                                $extra_html = '<input type="hidden" name="' . $_config['get_form_name'] . '" value="' . encode_url(complete_url($attrs['action'], false)) . '" />';
                                $attrs['action'] = '';
                                break;
                            }
     
                            $attrs['action'] = complete_url($attrs['action']);
                        }
                        break;
                    case 'base':
                        if (isset($attrs['href']))
                        {
                            $rebuild = true;  
                            url_parse($attrs['href'], $_base);
                            $attrs['href'] = complete_url($attrs['href']);
                        }
                        break;
                    case 'meta':
                        if ($_flags['strip_meta'] && isset($attrs['name']))
                        {
                            $_response_body = str_replace($matches[0][$i], '', $_response_body);
                        }
                        if (isset($attrs['http-equiv'], $attrs['content']) && preg_match('#\s*refresh\s*#i', $attrs['http-equiv']))
                        {
                            if (preg_match('#^(\s*[0-9]*\s*;\s*url=)(.*)#i', $attrs['content'], $content))
                            {                 
                                $rebuild = true;
                                $attrs['content'] =  $content[1] . complete_url(trim($content[2], '"\''));
                            }
                        }
                        break;
                    case 'head':
                        if (isset($attrs['profile']))
                        {
                            $rebuild = true;
                            $attrs['profile'] = implode(' ', array_map('complete_url', explode(' ', $attrs['profile'])));
                        }
                        break;
                    case 'applet':
                        if (isset($attrs['codebase']))
                        {
                            $rebuild = true;
                            $temp = $_base;
                            url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base);
                            unset($attrs['codebase']);
                        }
                        if (isset($attrs['code']) && strpos($attrs['code'], '/') !== false)
                        {
                            $rebuild = true;
                            $attrs['code'] = complete_url($attrs['code']);
                        }
                        if (isset($attrs['object']))
                        {
                            $rebuild = true;
                            $attrs['object'] = complete_url($attrs['object']);
                        }
                        if (isset($attrs['archive']))
                        {
                            $rebuild = true;
                            $attrs['archive'] = implode(',', array_map('complete_url', preg_split('#\s*,\s*#', $attrs['archive'])));
                        }
                        if (!empty($temp))
                        {
                            $_base = $temp;
                        }
                        break;
                    case 'object':
                        if (isset($attrs['usemap']))
                        {
                            $rebuild = true;
                            $attrs['usemap'] = complete_url($attrs['usemap']);
                        }
                        if (isset($attrs['codebase']))
                        {
                            $rebuild = true;
                            $temp = $_base;
                            url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base);
                            unset($attrs['codebase']);
                        }
                        if (isset($attrs['data']))
                        {
                            $rebuild = true;
                            $attrs['data'] = complete_url($attrs['data']);
                        }
                        if (isset($attrs['classid']) && !preg_match('#^clsid:#i', $attrs['classid']))
                        {
                            $rebuild = true;
                            $attrs['classid'] = complete_url($attrs['classid']);
                        }
                        if (isset($attrs['archive']))
                        {
                            $rebuild = true;
                            $attrs['archive'] = implode(' ', array_map('complete_url', explode(' ', $attrs['archive'])));
                        }
                        if (!empty($temp))
                        {
                            $_base = $temp;
                        }
                        break;
                    case 'param':
                        if (isset($attrs['valuetype'], $attrs['value']) && strtolower($attrs['valuetype']) == 'ref' && preg_match('#^[\w.+-]+://#', $attrs['value']))
                        {
                            $rebuild = true;
                            $attrs['value'] = complete_url($attrs['value']);
                        }
                        break;
                    case 'frame':
                    case 'iframe':
                        if (isset($attrs['src']))
                        {
                            $rebuild = true;
                            $attrs['src'] = complete_url($attrs['src']) . '&nf=1';
                        }
                        if (isset($attrs['longdesc']))
                        {
                            $rebuild = true;
                            $attrs['longdesc'] = complete_url($attrs['longdesc']);
                        }
                        break;
                    default:
                        foreach ($tags[$tag] as $attr)
                        {
                            if (isset($attrs[$attr]))
                            {
                                $rebuild = true;
                                $attrs[$attr] = complete_url($attrs[$attr]);
                            }
                        }
                        break;
                }
            }
     
            if ($rebuild)
            {
                $new_tag = "<$tag";
                foreach ($attrs as $name => $value)
                {
                    $delim = strpos($value, '"') && !strpos($value, "'") ? "'" : '"';
                    $new_tag .= ' ' . $name . ($value !== false ? '=' . $delim . $value . $delim : '');
                }
     
                $_response_body = str_replace($matches[0][$i], $new_tag . '>' . $extra_html, $_response_body);
            }
        }
     
        if ($_flags['include_form'] && !isset($_GET['nf']))
        {
            $_url_form      = '<div style="width:100%;margin:0;text-align:center;border-bottom:1px solid #725554;color:#000000;background-color:#F2FDF3;font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans,arial,sans-serif;padding:4px;">'
                            . '<form method="post" action="' . $_script_url . '">'
                            . ' <label for="____' . $_config['url_var_name'] . '"><a href="' . $_url . '">Address</a>:</label> <input id="____' . $_config['url_var_name'] . '" type="text" size="80" name="' . $_config['url_var_name'] . '" value="' . $_url . '" />'
                            . ' <input type="submit" name="go" value="Go" />'
                            . ' [go: <a href="' . $_script_url . '?' . $_config['url_var_name'] . '=' . encode_url($_url_parts['prev_dir']) .' ">up one dir</a>, <a href="' . $_script_base . '">main page</a>]'
                            . '<br /><hr />';
     
            foreach ($_flags as $flag_name => $flag_value)
            {
                if (!$_frozen_flags[$flag_name])
                {
                    $_url_form .= '<label><input type="checkbox" name="' . $_config['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' /> ' . $_labels[$flag_name][0] . '</label> ';
                }
            }
     
            $_url_form .= '</form></div>';
            $_response_body = preg_replace('#\<\s*body(.*?)\>#si', "$0\n$_url_form" , $_response_body, 1);
        }
    }
     
    $_response_keys['content-disposition'] = 'Content-Disposition';
    $_response_headers['content-disposition'][0] = empty($_content_disp) ? ($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $_url_parts['file'] . '"' : $_content_disp;
    $_response_keys['content-length'] = 'Content-Length';
    $_response_headers['content-length'][0] = strlen($_response_body);    
    $_response_headers   = array_filter($_response_headers);
    $_response_keys      = array_filter($_response_keys);
     
    header(array_shift($_response_keys));
    array_shift($_response_headers);
     
    foreach ($_response_headers as $name => $array)
    {
        foreach ($array as $value)
        {
            header($_response_keys[$name] . ': ' . $value, false);
        }
    }
     
    echo $_response_body;
    ?>

    et dico.php ou il y aura les str_replace ou preg_replace.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <?php
     
    $string = $url;
     
    $string = str_replace("Entreprise", "Embregerezh", $string);
     
    ?>

  4. #4
    Membre émérite
    Avatar de badaze
    Homme Profil pro
    Chef de projets info
    Inscrit en
    Septembre 2002
    Messages
    1 412
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projets info
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2002
    Messages : 1 412
    Points : 2 522
    Points
    2 522
    Par défaut
    Une question. Est-ce que tu sais à quoi sert le fichier que tu as posté ?

    Quel est le lien entre un script sensé contourner les firewalls et un traducteur ?
    Cela ne sert à rien d'optimiser quelque chose qui ne fonctionne pas.

    Mon site : www.emmella.fr

    Je recherche le manuel de l'Olivetti Logos 80B.

  5. #5
    Invité
    Invité(e)
    Par défaut
    Bonjour,
    Citation Envoyé par Breizhin Voir le message
    ...je me base sur un script du type générateur de short URL, dans lequel je mets un : require "dico.php"....
    C'est quoi ce code ???
    Autant te baser sur la recette du clafoutis aux pommes ou le mode d'emploi d'une tronçonneuse...


    Une méthode simple : str_ireplace() (Version insensible à la casse de str_replace())
    Dernière modification par Invité ; 05/05/2017 à 12h09.

  6. #6
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    C'est un code qui me permet d'avoir le get_url vu que je ne sais pas comment en faire un...et oui je suis un peu débutant!

    je comprends que pour vous ça paraisse insensé, mais je ne sais pas comment faire un get url, le parser et faire du str-replace dessus.

  7. #7
    Invité
    Invité(e)
    Par défaut
    Pour récupérer et parser un document, fais une , ce n'est pas les exemples qui manquent.

    Quant au "traducteur" :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    function dico($chaine)
    {
    	$dico = array(
    		'dans le' => 'dins ch\'',
    		'dans la' => 'dins ch\'',
    		'dans' => 'dins', // (important : à mettre APRES 'dans le','dans la')
    		'tu pleures' => 'té braies',
    		'tu' => 'té',
    		'pleurer' => 'braire',
    		'fois' => 'fos',
    		'en' => 'in',
    		'une' => 'eun',
    		'arrivant' => 'arrivint',
    		'partant' => 'partint',
    		// .......
    	);
     
    	return str_ireplace( array_keys($dico), array_values($dico), $chaine);
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    $chaine = 'Dans le Nord tu pleures deux fois : une fois en arrivant, et une fois en partant.';
    $traduction = dico($chaine);
     
    echo $chaine.'<br/>';
    echo $traduction.'<br/>';
    Dans le Nord tu pleures deux fois : une fois en arrivant, et une fois en partant.
    Dins ch'Nord té braies deux fos : eun fos in arrivint, et eun fos in partint.

  8. #8
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 691
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 691
    Points : 20 222
    Points
    20 222
    Par défaut
    Citation Envoyé par Breizhin Voir le message
    C'est un code qui me permet d'avoir le get_url vu que je ne sais pas comment en faire un...et oui je suis un peu débutant!

    je comprends que pour vous ça paraisse insensé, mais je ne sais pas comment faire un get url, le parser et faire du str-replace dessus.
    Tu ne t'aides pas en recopiant un code que tu ne maîtrise pas et ne comprend pas.

    Si ton but est de récupérer le contenu d'un url , un simple file_get_contents($url) suffit. Ne reste alors plus qu'à trouver le contenu qui t'intéresse dans la chaîne retournée.
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  9. #9
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    Bonjour, le but serait de récuperer une url donnée dans un formulaire en html et l'envoyé dans le dico.

    donc je fais un simple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <html>
    <body>
    <form method="post" action="script.php">
    url:<input type ="texte" name="url" size="12" value="http://">
    <input type="submit" "value="ok">
    </form></body></html>
    mais ensuite comment faire le file gets , comme cela?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <?php 
    $url = file_get_contents['url']; ?>

  10. #10
    Membre émérite
    Avatar de badaze
    Homme Profil pro
    Chef de projets info
    Inscrit en
    Septembre 2002
    Messages
    1 412
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projets info
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2002
    Messages : 1 412
    Points : 2 522
    Points
    2 522
    Par défaut
    Je ne comprends toujours pas ce que tu veux faire. Tu parles de dictionnaire, d'URL, d'envoyer l'URL dans le dico... Quel est le lien entre tout ça ?
    Cela ne sert à rien d'optimiser quelque chose qui ne fonctionne pas.

    Mon site : www.emmella.fr

    Je recherche le manuel de l'Olivetti Logos 80B.

  11. #11
    Invité
    Invité(e)
    Par défaut
    bonjour,

    1/ il faudrait penser à LIRE LA DOC (surtout quand on te fournit le lien)...

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php 
    $url = $_POST['url'];
    if ( !filter_var($url, FILTER_VALIDATE_URL) ) {
       echo 'URL incorrecte';
       exit;
    } else {
       $contenu_html = file_get_contents($url); 
    // ......
    }

    Voilà de nouveaux liens :


    A LIRE donc.


    2/ Pour la suite : "parser HTML"

    3/ [EDIT]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $string = str_replace("Entreprise", "Embregerezh", $string);
    Si j'ai bien compris, c'est un traducteur "Français --> Breton" ?
    Dernière modification par Invité ; 07/05/2017 à 17h07.

  12. #12
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    Oui mais en "direct", on rentrerai une url dans un formulaire, ensuite cela nous montrerait la page (sans toucher au CSS mise en page...) mais en breton.

    pour l'instant je voudrais un truc simple, seulement en mot à mot, à voir pour la suite si je peux évoluer vers une structure grammaticale plus complexe.

    bon le file get contents marche bien, merci beaucoup.

  13. #13
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    Bonjour, du coup j'arrive bien à faire file get content, comment afficher la page html en sortie ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php 
    $url = $_POST['url'];
    if ( !filter_var($url, FILTER_VALIDATE_URL) ) {
       echo 'URL incorrecte';
       exit;
    } else {
       $contenu_html = file_get_contents($url); 
    // ......
    } ?>

  14. #14
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  15. #15
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    Merci ça fonctionne bien

  16. #16
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Mai 2017
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Mai 2017
    Messages : 8
    Points : 1
    Points
    1
    Par défaut
    J'ai encore besoin d'aide, malgré mes recherches partout, j'ai réussi à bien afficher les accents avec header ('content-type: text/html......')

    mais je n'arrive pas à afficher les images, pourtant je l'ai fait avec un header ( type image/png par exemple) mais le résultat me donne un petit carré blanc au mileu de la page!!

  17. #17
    Modérateur
    Avatar de Vil'Coyote
    Homme Profil pro
    Développeur adélia & Web
    Inscrit en
    Février 2008
    Messages
    4 583
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur adélia & Web
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2008
    Messages : 4 583
    Points : 7 503
    Points
    7 503
    Par défaut
    ça semblerais logique puisque tu prend les données du site A pour les afficher sur ton site "B" et si dans la page les lien image sont \imgs\monimages.png si tu n'a pas ces dites image au même endrois cela risque pas de passer.
    la vie n'est pas cirrhose des foies ...

    Avant de poster un message Rechercher n'est pas qu'une option.
    FAQ Web - Tuto Web

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. traducteur en php
    Par falala dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 3
    Dernier message: 19/07/2013, 19h35
  2. Réponses: 13
    Dernier message: 07/06/2012, 19h09
  3. [Conception] Traducteur en ligne en PHP
    Par sonno dans le forum PHP & Base de données
    Réponses: 11
    Dernier message: 28/06/2007, 10h57
  4. [Système] PHP traducteur de séquences d'ADN
    Par maryach dans le forum Langage
    Réponses: 11
    Dernier message: 29/03/2007, 13h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo