Plugin Directory

Changeset 2685023


Ignore:
Timestamp:
02/25/2022 02:25:46 PM (4 years ago)
Author:
melkarim
Message:

implement internal redirect

Location:
addefend-easy-integration
Files:
1 added
1 deleted
6 edited
9 copied

Legend:

Unmodified
Added
Removed
  • addefend-easy-integration/tags/1.10/Components/proxy_integration.php

    r2588683 r2685023  
    11<?php
    22
    3 register_activation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_insert_rewrite_rules');
    4 register_deactivation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_remove_rewrite_rules');
     3register_activation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_insert_rules');
     4register_deactivation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_remove_rules');
    55
    66
    7 function addefend_insert_rewrite_rules() {
    8     $htaccess = ABSPATH.".htaccess";
    9     addefend_log('ADDEFEND -- TRACE : htaccess file path '.$htaccess);
    10     $proxy_URL = get_option( 'addefend_proxy_URL' );
    11     $image_dir = get_option( 'addefend_image_dir', '/wp-content' );
     7function addefend_insert_rules() {
     8    $content_proxy = get_option( 'addefend_content_proxy' );
     9    if ($content_proxy == 'apache') {
     10        $htaccess = ABSPATH.'.htaccess';
     11        addefend_log('ADDEFEND -- TRACE : htaccess file path '.$htaccess);
     12        $proxy_url = get_option( 'addefend_proxy_URL' );
     13        $image_dir = get_option( 'addefend_image_dir', '/wp-content' );
    1214
    13     $lines = array();
    14     $lines[] = '<IfModule mod_rewrite.c>';
    15     $lines[] = 'RewriteEngine On';
    16     $lines[] = 'RewriteBase /';
    17     $lines[] = 'RewriteCond %{REQUEST_URI} ^' . $image_dir;
    18     $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
    19     $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
    20     $lines[] = 'RewriteRule ^(.*)$ ' . $proxy_URL . '/$1 [P,L]';
    21     $lines[] = '</IfModule>';
     15        $lines = array();
     16        $lines[] = '<IfModule mod_rewrite.c>';
     17        $lines[] = 'RewriteEngine On';
     18        $lines[] = 'RewriteBase /';
     19        $lines[] = 'RewriteCond %{REQUEST_URI} ^' . $image_dir;
     20        $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
     21        $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
     22        $lines[] = 'RewriteRule ^(.*)$ ' . $proxy_url . '/$1 [P,L]';
     23        $lines[] = '</IfModule>';
    2224
    23     // Check the validity of the proxy URL
    24     if(preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxy_URL)) {
    25         addefend_log('ADDEFEND -- INFO : using '.$proxy_URL.' as the proxy URL');
    26         $addefend_content_proxy = addefend_insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER, $lines);
    27         if($addefend_content_proxy){
    28             addefend_log('ADDEFEND -- TRACE : Rewrite rules inserted successfully');
    29         }else{
    30             addefend_log('ADDEFEND -- ERROR : Rewrite rules could not be inserted');
     25        // Check the validity of the proxy URL
     26        if (preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxy_url)) {
     27            addefend_log('ADDEFEND -- INFO : using '.$proxy_url.' as the proxy URL');
     28            $addefend_content_proxy = addefend_insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER, $lines);
     29            if ($addefend_content_proxy) {
     30                addefend_log('ADDEFEND -- TRACE : Rewrite rules inserted successfully');
     31            } else {
     32                addefend_log('ADDEFEND -- ERROR : Rewrite rules could not be inserted');
     33            }
    3134        }
    3235    }
    3336}
    3437
    35 function addefend_remove_rewrite_rules() {
     38function addefend_remove_rules() {
     39    // Clean Apache-Config
    3640    $htaccess = ABSPATH.".htaccess";
    37     insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER,'');
     41    insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER, '');
    3842}
  • addefend-easy-integration/tags/1.10/Utils/misc.php

    r1852443 r2685023  
    116116    return false;
    117117}
     118
     119function getHeaders() {
     120    $out = [];
     121    foreach ($_SERVER as $key => $value) {
     122        if (substr($key, 0, 5) == "HTTP_") {
     123            $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", "", substr($key, 5)))));
     124        }
     125        $out[$key] = $value;
     126    }
     127    return $out;
     128}
  • addefend-easy-integration/tags/1.10/View/options.php

    r2588683 r2685023  
    1111    delete_option('addefend_proxy_URL');
    1212    delete_option('addefend_image_dir');
     13    delete_option('addefend_content_proxy');
    1314}
    1415
     
    1819    }
    1920
    20     $script_URL = get_option( 'addefend_script_URL', '' );
    21     $proxy_URL = get_option( 'addefend_proxy_URL', '' );
    22     $image_dir = get_option( 'addefend_image_dir', '/wp-content' );
    23 
    24     if( isset($_POST[ 'submited' ]) && $_POST[ 'submited' ] == 'Y' ) {
     21    $scriptUrl = get_option( 'addefend_script_URL' , '' );
     22    $proxyUrl = get_option( 'addefend_proxy_URL' , '' );
     23    $imageDir = get_option( 'addefend_image_dir' , '/wp-content' );
     24    $contentProxy = get_option( 'addefend_content_proxy', 'apache');
     25
     26    if (isset($_POST[ 'submitted' ]) && $_POST[ 'submitted' ] == 'config_form') {
    2527        check_admin_referer('submit_addefend_integration_parameters');
    2628        $nonce = $_POST['_wpnonce'];
     
    2830            exit; // Get out of here, the nonce is rotten!
    2931        }
    30         $script_URL = esc_url($_POST['script_URL']);
    31         $proxy_URL = esc_url($_POST['proxy_URL']);
    32         $image_dir = $_POST['image_dir'];
    33         $valid_script_URL = True;
    34         $valid_proxy_URL = True;
     32        $contentProxyType = $_POST['selected_content_proxy'];
     33        $scriptUrl = esc_url($_POST['script_URL']);
     34        $proxyUrl = esc_url($_POST['proxy_URL']);
     35        $imageDir = $_POST['image_dir'];
     36        $validScriptUrl = true;
     37        $validProxyUrl = true;
    3538
    3639        // always save the new input
    37         update_option('addefend_script_URL', $script_URL);
    38         update_option('addefend_proxy_URL', $proxy_URL);
    39         if($image_dir === ''){
    40             $image_dir = ADDEFEND_DEFAULT_IMAGE_DIRECTORY;
    41         }
    42         update_option('addefend_image_dir', $image_dir);
    43 
    44         // test the input parameters
    45         if(wp_remote_retrieve_response_code(wp_remote_get($script_URL)) == 404){
    46             $valid_script_URL = False;
     40        update_option('addefend_script_URL', $scriptUrl);
     41        update_option('addefend_proxy_URL', $proxyUrl);
     42        if ($imageDir === '') {
     43            $imageDir = ADDEFEND_DEFAULT_IMAGE_DIRECTORY;
     44        }
     45        update_option('addefend_image_dir', $imageDir);
     46
     47        if (wp_remote_retrieve_response_code(wp_remote_get($scriptUrl)) == 404) {
     48            $validScriptUrl = False;
    4749            echo '<div class="error"><p><strong>Script URL is invalid</strong></p></div>';
    4850        }
    49         if(!preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxy_URL)){
    50             $valid_proxy_URL = False;
     51        if (!preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxyUrl)) {
     52            $validProxyUrl = False;
    5153            echo '<div class="error"><p><strong>Proxy URL is invalid</strong></p></div>';
    52             addefend_remove_rewrite_rules();
    53         }
    54         if($valid_proxy_URL && $valid_script_URL){
     54            addefend_remove_rules();
     55        }
     56        if ($validProxyUrl && $validScriptUrl) {
    5557            download_addefend_script();
    56             addefend_insert_rewrite_rules();
    57             echo '<div class="updated"><p><strong>settings saved</strong></p></div>';
     58            addefend_insert_rules();
     59            echo '<div class="updated"><p><strong>Settings saved for: '.$contentProxyType.'</strong></p></div>';
    5860        }
    5961    }
    60 
    61     echo    '<h1>AdDefend Integration Parameters</h1>';
    62     echo    '<form method="post" action="">';
    63     wp_nonce_field( 'submit_addefend_integration_parameters' );
    64     echo        '<input type="hidden" name="submited" value="Y">';
    65     echo        '<style>';
    66     echo            '.addefend_table {border-collapse: collapse;}';
    67     echo            '.addefend_table td {border: 1px solid black; padding: 10px;}';
    68     echo            '.addefend_table td * {margin: auto !important;}';
    69     echo            '.addefend_table li {list-style-type: none;}';
    70     echo            '.addefend_table td > div {height : 20px; width : 140px;}';
    71     echo            '.addefend_table td > div > p {text-align: center; color: white; font-weight: bold;}';
    72     echo            '.addefend_table td > label {font-weight: bold;}';
    73     echo        '</style>';
    74     echo        '<table class="addefend_table">';
    75     //////////////// Script URL ////////////////////////////////////////////////////////////////////////////////////////
    76     echo            '<tr>' .
    77                         '<td>' .
    78                             '<label for="script_URL_field_id">Script URL : </label>' .
    79                         '</td><' .
    80                         'td>' .
    81                             '<input type="text" id="script_URL_field_id" name="script_URL" value="'.esc_attr($script_URL).'" size="70">' .
    82                         '</td>' .
    83                     '</tr>';
    84     //////////////// Proxy URL /////////////////////////////////////////////////////////////////////////////////////////
    85     echo            '<tr>' .
    86                         '<td>' .
    87                             '<label for="proxy_URL_field_id">Proxy URL : </label>' .
    88                         '</td>' .
    89                         '<td>' .
    90                             '<input type="text" id="proxy_URL_field_id" name="proxy_URL" value="'.esc_attr($proxy_URL).'" size="70">' .
    91                         '</td>' .
    92                     '</tr>';
    93     //////////////// Images Directory //////////////////////////////////////////////////////////////////////////////////
    94     echo            '<tr>' .
    95                         '<td>' .
    96                             '<label for="image_dir_id">Images Directory : </label>' .
    97                         '</td>' .
    98                         '<td>' .
    99                             '<input type="text" id="image_dir_id" name="image_dir" value="'.esc_attr($image_dir).'" size="40">' .
    100                         '</td>' .
    101                     '</tr>';
    102     //////////////// AdDefend Script Caching ///////////////////////////////////////////////////////////////////////////
    103     echo            '<tr>' .
    104                         '<td>' .
    105                             '<label>AdDefend Script Caching : </label>' .
    106                         '</td>' .
    107                         '<td>';
    108     global $wpdb;
    109     $addefend_script = $wpdb->get_var('SELECT script FROM '.ADDEFEND_TABLE_NAME.' WHERE (id = \'1\')');
    110     if(!$addefend_script){
    111         echo                '<div style="background-color : red;">' .
    112                                 '<p>Not Working</p>' .
    113                             '</div>';
    114     }else{
    115         echo                '<div style="background-color : green;">' .
    116                                 '<p>Working</p>' .
    117                             '</div>';
     62    if (isset($_POST["selected_content_proxy"])) {
     63        $newContentProxy = $_POST["selected_content_proxy"];
     64        update_option("addefend_content_proxy", $newContentProxy);
     65        $contentProxy = $newContentProxy;
    11866    }
    119     echo                '</td>' .
    120                     '</tr>';
    121     //////////////// Apache Rewrite Module /////////////////////////////////////////////////////////////////////////////
    122     echo            '<tr>' .
    123                         '<td>' .
    124                             '<label>Apache Rewrite Module : </label>' .
    125                         '</td>' .
    126                         '<td>';
    127     if(!got_mod_rewrite()){
    128         echo                '<div style="background-color : red;">' .
    129                                 '<p>Not Loaded</p>' .
    130                             '</div>';
    131     }else{
    132         echo                '<div style="background-color : green;">' .
    133                                 '<p>Loaded</p>' .
    134                             '</div>';
    135     }
    136     echo                '</td>' .
    137                     '</tr>';
    138     //////////////// Apache SSL Module /////////////////////////////////////////////////////////////////////////////////
    139     echo            '<tr>' .
    140                         '<td>' .
    141                             '<label>Apache SSL Module : </label>' .
    142                         '</td>' .
    143                         '<td>';
    144     if(!apache_mod_loaded('mod_ssl')){
    145         echo                '<div style="background-color : red;">' .
    146                                 '<p>Not Loaded</p>' .
    147                             '</div>';
    148     }else{
    149         echo                '<div style="background-color : green;">' .
    150                                 '<p>Loaded</p>' .
    151                             '</div>';
    152     }
    153     echo                '</td>' .
    154                     '</tr>';
    155     //////////////// AdDefend Content-Proxy ////////////////////////////////////////////////////////////////////////////
    156     echo            '<tr>' .
    157                         '<td>' .
    158                             '<label>AdDefend Content-Proxy : </label>' .
    159                         '</td>' .
    160                         '<td>';
    161     $htaccess = ABSPATH.'.htaccess';
    162     $addefend_rules = addefend_extract_from_markers( $htaccess, ADDEFEND_HTACCESS_MARKER );
    163     if(sizeof($addefend_rules) < 3){
    164         echo                '<div style="background-color : red;">' .
    165                                 '<p>Not Configured</p>' .
    166                             '</div>';
    167     }else{
    168         echo                '<div style="background-color : green;">' .
    169                                 '<p>Configured</p>' .
    170                             '</div>';
    171     }
    172     echo                '</td>' .
    173                     '</tr>';
    174     //////////////// AdDefend Config Fragment Index ////////////////////////////////////////////////////////////////////
    175     if(sizeof($addefend_rules) >= 3){
    176         echo        '<tr>' .
    177                         '<td>' .
    178                             '<label>AdDefend Config Fragment Index : </label>' .
    179                         '</td>' .
    180                         '<td>' .
    181                             '<p>'.get_line_from_file($htaccess, ADDEFEND_HTACCESS_MARKER).'</p>' .
    182                         '</td>' .
    183                     '</tr>' .
    184                     '<tr>' .
    185                         '<td>' .
    186                             '<label>AdDefend Config Fragment : </label>' .
    187                         '</td>' .
    188                         '<td>';
    189         foreach ($addefend_rules as $value):
    190             echo            '<li>'.htmlspecialchars($value).'</li>';
    191         endforeach;
    192         echo            '</td>' .
    193                     '</tr>';
    194     }
    195     //////////////// Wordpress Root Directory //////////////////////////////////////////////////////////////////////////
    196     echo            '<tr>' .
    197                         '<td>' .
    198                             '<label>Wordpress Root Directory : </label>' .
    199                         '</td>' .
    200                         '<td>' .
    201                             '<p>'.get_home_path().'</p>' .
    202                         '</td>' .
    203                     '</tr>';
    204     //////////////// Wordpress Sub-Directory ///////////////////////////////////////////////////////////////////////////
    205     if(get_home_path() !== ABSPATH){
    206         echo        '<tr>' .
    207                         '<td>' .
    208                             '<label>Wordpress Sub-Directory : </label>' .
    209                         '</td>' .
    210                         '<td>' .
    211                             '<p>'.ABSPATH.'</p>' .
    212                         '</td>' .
    213                     '</tr>';
    214     }
    215     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    216     echo        '</table>' .
    217                 '<p class="submit">' .
    218                     '<input type="submit" name="Submit" class="button-primary" value="Save Changes"/>' .
    219                 '</p>' .
    220             '</form>';
    221 }
     67    ?>
     68
     69    <h1>AdDefend Integration Parameters</h1>
     70    <p>
     71    <form method="post" action="">
     72        <label for="select_content_proxy">Content-Proxy:</label>
     73        <select id="select_content_proxy" name="selected_content_proxy" onchange="this.form.submit()">
     74            <option value="apache" <?= $contentProxy == "apache" ? "selected": "" ?>>Apache</option>
     75            <option value="intern" <?= $contentProxy == "intern" ? "selected": "" ?>>Internal Proxy</option>
     76        </select>
     77    </form>
     78    </p>
     79
     80    <form method="post" action="">
     81        <?= wp_nonce_field("submit_addefend_integration_parameters" ) ?>
     82        <input type="hidden" name="submitted" value="config_form">
     83        <input type="hidden" name="selected_content_proxy" value="<?= esc_attr($contentProxy) ?>">
     84        <style>
     85            .addefend_table {border-collapse: collapse;}
     86            .addefend_table td {border: 1px solid black; padding: 10px;}
     87            .addefend_table td * {margin: auto !important;}
     88            .addefend_table li {list-style-type: none;}
     89            .addefend_table td > div {height : 20px; width : 140px;}
     90            .addefend_table td > div > p {text-align: center; color: white; font-weight: bold;}
     91            .addefend_table td > label {font-weight: bold;}
     92            .addefend_table td:first-child { width: 185px; }
     93        </style>
     94        <table class="addefend_table">
     95            <!-- Script URL -->
     96            <tr>
     97                <td>
     98                    <label for="script_URL_field_id">Script URL: </label>
     99                </td>
     100                <td>
     101                    <input type="text" id="script_URL_field_id" name="script_URL" value="<?= esc_attr($scriptUrl) ?>" size="70">
     102                </td>
     103            </tr>
     104            <!-- Proxy URL -->
     105            <tr>
     106                <td>
     107                    <label for="proxy_URL_field_id">Proxy URL:  </label>
     108                </td>
     109                <td>
     110                    <input type="text" id="proxy_URL_field_id" name="proxy_URL" value="<?= esc_attr($proxyUrl) ?>" size="70">
     111                </td>
     112            </tr>
     113            <!-- Image Directory -->
     114            <tr>
     115                <td>
     116                    <label for="image_dir_id">Images Directory: </label>
     117                </td>
     118                <td>
     119                    <input type="text" id="image_dir_id" name="image_dir" value="<?= esc_attr($imageDir) ?>" size="70">
     120                </td>
     121            </tr>
     122            <!-- AdDefend Script Caching -->
     123            <tr>
     124                <td>
     125                    <label>AdDefend Script Caching: </label>
     126                </td>
     127                <td>
     128                    <?php
     129                    global $wpdb;
     130                    $addefend_script = $wpdb->get_var('SELECT script FROM '.ADDEFEND_TABLE_NAME.' WHERE (id = \'1\')');
     131                    if ($addefend_script): ?>
     132                        <div style="background-color: green;">
     133                            <p>Working</p>
     134                        </div>
     135                    <?php else: ?>
     136                        <div style="background-color: red;">
     137                            <p>Not Working</p>
     138                        </div>
     139                    <?php endif; ?>
     140                </td>
     141            </tr>
     142            <?php if ($contentProxy == "apache"): ?>
     143                <!-- Apache Rewrite Module -->
     144                <tr>
     145                    <td>
     146                        <label>Apache Rewrite Module: </label>
     147                    </td>
     148                    <td>
     149                        <?php if (!got_mod_rewrite()): ?>
     150                            <div style="background-color: red;">
     151                                <p>Not Loaded</p>
     152                            </div>
     153                        <?php else: ?>
     154                            <div style="background-color: green;">
     155                                <p>Loaded</p>
     156                            </div>
     157                        <?php endif; ?>
     158                    </td>
     159                </tr>
     160                <!-- Apache SSL Module  -->
     161                <tr>
     162                    <td>
     163                        <label>Apache SSL Module:</label>
     164                    </td>
     165                    <td>
     166                        <?php if (!apache_mod_loaded("mod_ssl")): ?>
     167                            <div style="background-color: red;">
     168                                <p>Not Loaded</p>
     169                            </div>
     170                        <?php else: ?>
     171                            <div style="background-color: green;">
     172                                <p>Loaded</p>
     173                            </div>
     174                        <?php endif; ?>
     175                    </td>
     176                </tr>
     177                <!-- AdDefend Content-Proxy Apache -->
     178                <tr>
     179                    <td>
     180                        <label>AdDefend Content-Proxy:</label>
     181                    </td>
     182                    <td>
     183                        <?php
     184                        $htaccess = ABSPATH.'.htaccess';
     185                        $addefend_rules = addefend_extract_from_markers($htaccess, ADDEFEND_HTACCESS_MARKER );
     186                        ?>
     187                        <?php if (sizeof($addefend_rules) < 5): ?>
     188                            <div style="background-color: red;">
     189                                <p>Not Configured</p>
     190                            </div>
     191                        <?php else: ?>
     192                            <div style="background-color: green;">
     193                                <p>Configured</p>
     194                            </div>
     195                        <?php endif; ?>
     196                    </td>
     197                </tr>
     198                <?php if (sizeof($addefend_rules) >= 5): ?>
     199                    <!-- AdDefend Config Fragment Index -->
     200                    <tr>
     201                        <td>
     202                            <label>AdDefend Config Fragment Index: </label>
     203                        </td>
     204                        <td>
     205                            <p><?= get_line_from_file($htaccess, ADDEFEND_HTACCESS_MARKER); ?></p>
     206                        </td>
     207                    </tr>
     208                    <!-- AdDefend Config Fragment Index -->
     209                    <tr>
     210                        <td>
     211                            <label>AdDefend Config Fragment: </label>
     212                        </td>
     213                        <td>
     214                            <?php foreach ($addefend_rules as $value): ?>
     215                                <li><?= htmlspecialchars($value); ?></li>
     216                            <?php endforeach; ?>
     217                        </td>
     218                    </tr>
     219                    <!-- Wordpress Root Directory -->
     220                    <tr>
     221                        <td>
     222                            <label>Wordpress Root Directory: </label>
     223                        </td>
     224                        <td>
     225                            <p><?= get_home_path() ?></p>
     226                        </td>
     227                    </tr>
     228                <?php endif; ?>
     229                <?php if (get_home_path() !== ABSPATH): ?>
     230                    <!-- Wordpress Sub-Directory -->
     231                    <tr>
     232                        <td>
     233                            <label>Wordpress Sub-Directory: </label>
     234                        </td>
     235                        <td>
     236                            <p><?= ABSPATH ?></p>
     237                        </td>
     238                    </tr>
     239                <?php endif; ?>
     240            <?php endif; ?>
     241            <?php if ($contentProxy == "intern"): ?>
     242                <tr>
     243                    <td>
     244                        <label>Internal Proxy Status:</label>
     245                    </td>
     246                    <td>
     247                        <?php
     248                        $isInternalRedirectActionRegistered = has_action('template_redirect', 'addefend_internal_redirect');
     249                        ?>
     250                        <?php if ($isInternalRedirectActionRegistered): ?>
     251                            <div style="background-color: green;">
     252                                <p>Active</p>
     253                            </div>
     254                        <?php else: ?>
     255                            <div style="background-color: red;">
     256                                <p>Inactive</p>
     257                            </div>
     258                        <?php endif; ?>
     259                        <div class="primary" style="display: none;"
     260                    </td>
     261                </tr>
     262            <?php endif; ?>
     263        </table>
     264        <?php if ($contentProxy == "intern"): ?>
     265            <p><strong>Expected behaviour:</strong> If the image results in 404, the request will be forwarded to the specified 'Proxy URL'!</p>
     266            <table class="addefend_table">
     267                <tr>
     268                    <td>
     269                        <label>Example Image URL:</label>
     270                    </td>
     271                    <td>
     272                        <input type="text" id="example_url_publisher" value="" size="70" readonly>
     273                    </td>
     274                </tr>
     275                <tr>
     276                    <td>
     277                        <label>Example Forwarded URL:</label>
     278                    </td>
     279                    <td>
     280                        <input type="text" id="example_url_forwarded" value="" size="70" readonly>
     281                    </td>
     282                </tr>
     283            </table>
     284        <?php endif; ?>
     285        <p class="submit">
     286            <input type="submit" name="Submit" class="button-primary" value="Save Changes">
     287        </p>
     288    </form>
     289    <script>
     290        window.addEventListener("DOMContentLoaded", function() {
     291            if (document.querySelector("input[name=selected_content_proxy]").value !== "intern") return;
     292
     293            var exampleUrlPublisherElement = document.querySelector("#example_url_publisher");
     294            var exampleUrlProxiedElement = document.querySelector("#example_url_forwarded");
     295            var proxyUrlElement = document.querySelector("#proxy_URL_field_id");
     296            var imagesDirectoryElement = document.querySelector("#image_dir_id");
     297
     298            var exampleUrlPublisher = "", exampleUrlProxied = "";
     299            exampleUrlPublisher = location.protocol + "//" + location.host + imagesDirectoryElement.value + "/example/file.jpg";
     300
     301            exampleUrlPublisherElement.value = exampleUrlPublisher;
     302            exampleUrlProxiedElement.value = proxyUrlElement.value + imagesDirectoryElement.value + "/example/file.jpg";
     303        });
     304    </script>
     305<?php } ?>
  • addefend-easy-integration/tags/1.10/addefend-easy-integration.php

    r2588683 r2685023  
    44Plugin URI: https://wordpress.org/plugins/addefend-easy-integration/
    55Description: The AdDefend Easy Intregration plug-in supports publishers in integrating the AdDefend anti-adblock solution.
    6 Version: 1.9
     6Version: 1.10
    77Author: AdDefend GmbH
    88Author URI: https://www.addefend.com/
     
    2525define( 'ADDEFEND_PLUGIN_PHP_FILE', __FILE__ );
    2626define( 'ADDEFEND_PLUGIN_ROOT_DIR', plugin_dir_path( __FILE__ ) );
     27define( 'ADDEFEND_MARKER', 'AdDefend' );
    2728define( 'ADDEFEND_HTACCESS_MARKER', 'AdDefend' );
    2829define( 'ADDEFEND_DEFAULT_IMAGE_DIRECTORY', '/wp-content');
     
    3233include ADDEFEND_PLUGIN_ROOT_DIR.'Components/script_integration.php';
    3334include ADDEFEND_PLUGIN_ROOT_DIR.'Components/proxy_integration.php';
     35include ADDEFEND_PLUGIN_ROOT_DIR.'Components/proxy_internal_forwarding.php';
  • addefend-easy-integration/tags/1.10/readme.txt

    r2588683 r2685023  
    33Tags: unblock, unblockable, ads, addefend, ad recovery, recover ads, anti-adblocker, online advertising, digital advertising, ad reinsertion, counter block, block adblock, ad block blocker, adblock advertising
    44Requires at least: 4.2
    5 Tested up to: 5.8
    6 Stable tag: 1.9
     5Tested up to: 5.9
     6Stable tag: 1.10
    77License: GPLv3
    88License URI: https://www.gnu.org/licenses/gpl.html
     
    5252== Changelog ==
    5353
     54= 1.10 =
     55* content-proxy should now work on any server
     56* show more info in the plugin settings page
     57
    5458= 1.9 =
    5559* cleaned-up the settings page
  • addefend-easy-integration/trunk/Components/proxy_integration.php

    r2588683 r2685023  
    11<?php
    22
    3 register_activation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_insert_rewrite_rules');
    4 register_deactivation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_remove_rewrite_rules');
     3register_activation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_insert_rules');
     4register_deactivation_hook( ADDEFEND_PLUGIN_PHP_FILE, 'addefend_remove_rules');
    55
    66
    7 function addefend_insert_rewrite_rules() {
    8     $htaccess = ABSPATH.".htaccess";
    9     addefend_log('ADDEFEND -- TRACE : htaccess file path '.$htaccess);
    10     $proxy_URL = get_option( 'addefend_proxy_URL' );
    11     $image_dir = get_option( 'addefend_image_dir', '/wp-content' );
     7function addefend_insert_rules() {
     8    $content_proxy = get_option( 'addefend_content_proxy' );
     9    if ($content_proxy == 'apache') {
     10        $htaccess = ABSPATH.'.htaccess';
     11        addefend_log('ADDEFEND -- TRACE : htaccess file path '.$htaccess);
     12        $proxy_url = get_option( 'addefend_proxy_URL' );
     13        $image_dir = get_option( 'addefend_image_dir', '/wp-content' );
    1214
    13     $lines = array();
    14     $lines[] = '<IfModule mod_rewrite.c>';
    15     $lines[] = 'RewriteEngine On';
    16     $lines[] = 'RewriteBase /';
    17     $lines[] = 'RewriteCond %{REQUEST_URI} ^' . $image_dir;
    18     $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
    19     $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
    20     $lines[] = 'RewriteRule ^(.*)$ ' . $proxy_URL . '/$1 [P,L]';
    21     $lines[] = '</IfModule>';
     15        $lines = array();
     16        $lines[] = '<IfModule mod_rewrite.c>';
     17        $lines[] = 'RewriteEngine On';
     18        $lines[] = 'RewriteBase /';
     19        $lines[] = 'RewriteCond %{REQUEST_URI} ^' . $image_dir;
     20        $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
     21        $lines[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
     22        $lines[] = 'RewriteRule ^(.*)$ ' . $proxy_url . '/$1 [P,L]';
     23        $lines[] = '</IfModule>';
    2224
    23     // Check the validity of the proxy URL
    24     if(preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxy_URL)) {
    25         addefend_log('ADDEFEND -- INFO : using '.$proxy_URL.' as the proxy URL');
    26         $addefend_content_proxy = addefend_insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER, $lines);
    27         if($addefend_content_proxy){
    28             addefend_log('ADDEFEND -- TRACE : Rewrite rules inserted successfully');
    29         }else{
    30             addefend_log('ADDEFEND -- ERROR : Rewrite rules could not be inserted');
     25        // Check the validity of the proxy URL
     26        if (preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxy_url)) {
     27            addefend_log('ADDEFEND -- INFO : using '.$proxy_url.' as the proxy URL');
     28            $addefend_content_proxy = addefend_insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER, $lines);
     29            if ($addefend_content_proxy) {
     30                addefend_log('ADDEFEND -- TRACE : Rewrite rules inserted successfully');
     31            } else {
     32                addefend_log('ADDEFEND -- ERROR : Rewrite rules could not be inserted');
     33            }
    3134        }
    3235    }
    3336}
    3437
    35 function addefend_remove_rewrite_rules() {
     38function addefend_remove_rules() {
     39    // Clean Apache-Config
    3640    $htaccess = ABSPATH.".htaccess";
    37     insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER,'');
     41    insert_with_markers($htaccess, ADDEFEND_HTACCESS_MARKER, '');
    3842}
  • addefend-easy-integration/trunk/Utils/misc.php

    r1852443 r2685023  
    116116    return false;
    117117}
     118
     119function getHeaders() {
     120    $out = [];
     121    foreach ($_SERVER as $key => $value) {
     122        if (substr($key, 0, 5) == "HTTP_") {
     123            $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", "", substr($key, 5)))));
     124        }
     125        $out[$key] = $value;
     126    }
     127    return $out;
     128}
  • addefend-easy-integration/trunk/View/options.php

    r2588683 r2685023  
    1111    delete_option('addefend_proxy_URL');
    1212    delete_option('addefend_image_dir');
     13    delete_option('addefend_content_proxy');
    1314}
    1415
     
    1819    }
    1920
    20     $script_URL = get_option( 'addefend_script_URL', '' );
    21     $proxy_URL = get_option( 'addefend_proxy_URL', '' );
    22     $image_dir = get_option( 'addefend_image_dir', '/wp-content' );
    23 
    24     if( isset($_POST[ 'submited' ]) && $_POST[ 'submited' ] == 'Y' ) {
     21    $scriptUrl = get_option( 'addefend_script_URL' , '' );
     22    $proxyUrl = get_option( 'addefend_proxy_URL' , '' );
     23    $imageDir = get_option( 'addefend_image_dir' , '/wp-content' );
     24    $contentProxy = get_option( 'addefend_content_proxy', 'apache');
     25
     26    if (isset($_POST[ 'submitted' ]) && $_POST[ 'submitted' ] == 'config_form') {
    2527        check_admin_referer('submit_addefend_integration_parameters');
    2628        $nonce = $_POST['_wpnonce'];
     
    2830            exit; // Get out of here, the nonce is rotten!
    2931        }
    30         $script_URL = esc_url($_POST['script_URL']);
    31         $proxy_URL = esc_url($_POST['proxy_URL']);
    32         $image_dir = $_POST['image_dir'];
    33         $valid_script_URL = True;
    34         $valid_proxy_URL = True;
     32        $contentProxyType = $_POST['selected_content_proxy'];
     33        $scriptUrl = esc_url($_POST['script_URL']);
     34        $proxyUrl = esc_url($_POST['proxy_URL']);
     35        $imageDir = $_POST['image_dir'];
     36        $validScriptUrl = true;
     37        $validProxyUrl = true;
    3538
    3639        // always save the new input
    37         update_option('addefend_script_URL', $script_URL);
    38         update_option('addefend_proxy_URL', $proxy_URL);
    39         if($image_dir === ''){
    40             $image_dir = ADDEFEND_DEFAULT_IMAGE_DIRECTORY;
    41         }
    42         update_option('addefend_image_dir', $image_dir);
    43 
    44         // test the input parameters
    45         if(wp_remote_retrieve_response_code(wp_remote_get($script_URL)) == 404){
    46             $valid_script_URL = False;
     40        update_option('addefend_script_URL', $scriptUrl);
     41        update_option('addefend_proxy_URL', $proxyUrl);
     42        if ($imageDir === '') {
     43            $imageDir = ADDEFEND_DEFAULT_IMAGE_DIRECTORY;
     44        }
     45        update_option('addefend_image_dir', $imageDir);
     46
     47        if (wp_remote_retrieve_response_code(wp_remote_get($scriptUrl)) == 404) {
     48            $validScriptUrl = False;
    4749            echo '<div class="error"><p><strong>Script URL is invalid</strong></p></div>';
    4850        }
    49         if(!preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxy_URL)){
    50             $valid_proxy_URL = False;
     51        if (!preg_match('/.*:\/\/.*\..*\/.*\/.*\/.*\/.*/', $proxyUrl)) {
     52            $validProxyUrl = False;
    5153            echo '<div class="error"><p><strong>Proxy URL is invalid</strong></p></div>';
    52             addefend_remove_rewrite_rules();
    53         }
    54         if($valid_proxy_URL && $valid_script_URL){
     54            addefend_remove_rules();
     55        }
     56        if ($validProxyUrl && $validScriptUrl) {
    5557            download_addefend_script();
    56             addefend_insert_rewrite_rules();
    57             echo '<div class="updated"><p><strong>settings saved</strong></p></div>';
     58            addefend_insert_rules();
     59            echo '<div class="updated"><p><strong>Settings saved for: '.$contentProxyType.'</strong></p></div>';
    5860        }
    5961    }
    60 
    61     echo    '<h1>AdDefend Integration Parameters</h1>';
    62     echo    '<form method="post" action="">';
    63     wp_nonce_field( 'submit_addefend_integration_parameters' );
    64     echo        '<input type="hidden" name="submited" value="Y">';
    65     echo        '<style>';
    66     echo            '.addefend_table {border-collapse: collapse;}';
    67     echo            '.addefend_table td {border: 1px solid black; padding: 10px;}';
    68     echo            '.addefend_table td * {margin: auto !important;}';
    69     echo            '.addefend_table li {list-style-type: none;}';
    70     echo            '.addefend_table td > div {height : 20px; width : 140px;}';
    71     echo            '.addefend_table td > div > p {text-align: center; color: white; font-weight: bold;}';
    72     echo            '.addefend_table td > label {font-weight: bold;}';
    73     echo        '</style>';
    74     echo        '<table class="addefend_table">';
    75     //////////////// Script URL ////////////////////////////////////////////////////////////////////////////////////////
    76     echo            '<tr>' .
    77                         '<td>' .
    78                             '<label for="script_URL_field_id">Script URL : </label>' .
    79                         '</td><' .
    80                         'td>' .
    81                             '<input type="text" id="script_URL_field_id" name="script_URL" value="'.esc_attr($script_URL).'" size="70">' .
    82                         '</td>' .
    83                     '</tr>';
    84     //////////////// Proxy URL /////////////////////////////////////////////////////////////////////////////////////////
    85     echo            '<tr>' .
    86                         '<td>' .
    87                             '<label for="proxy_URL_field_id">Proxy URL : </label>' .
    88                         '</td>' .
    89                         '<td>' .
    90                             '<input type="text" id="proxy_URL_field_id" name="proxy_URL" value="'.esc_attr($proxy_URL).'" size="70">' .
    91                         '</td>' .
    92                     '</tr>';
    93     //////////////// Images Directory //////////////////////////////////////////////////////////////////////////////////
    94     echo            '<tr>' .
    95                         '<td>' .
    96                             '<label for="image_dir_id">Images Directory : </label>' .
    97                         '</td>' .
    98                         '<td>' .
    99                             '<input type="text" id="image_dir_id" name="image_dir" value="'.esc_attr($image_dir).'" size="40">' .
    100                         '</td>' .
    101                     '</tr>';
    102     //////////////// AdDefend Script Caching ///////////////////////////////////////////////////////////////////////////
    103     echo            '<tr>' .
    104                         '<td>' .
    105                             '<label>AdDefend Script Caching : </label>' .
    106                         '</td>' .
    107                         '<td>';
    108     global $wpdb;
    109     $addefend_script = $wpdb->get_var('SELECT script FROM '.ADDEFEND_TABLE_NAME.' WHERE (id = \'1\')');
    110     if(!$addefend_script){
    111         echo                '<div style="background-color : red;">' .
    112                                 '<p>Not Working</p>' .
    113                             '</div>';
    114     }else{
    115         echo                '<div style="background-color : green;">' .
    116                                 '<p>Working</p>' .
    117                             '</div>';
     62    if (isset($_POST["selected_content_proxy"])) {
     63        $newContentProxy = $_POST["selected_content_proxy"];
     64        update_option("addefend_content_proxy", $newContentProxy);
     65        $contentProxy = $newContentProxy;
    11866    }
    119     echo                '</td>' .
    120                     '</tr>';
    121     //////////////// Apache Rewrite Module /////////////////////////////////////////////////////////////////////////////
    122     echo            '<tr>' .
    123                         '<td>' .
    124                             '<label>Apache Rewrite Module : </label>' .
    125                         '</td>' .
    126                         '<td>';
    127     if(!got_mod_rewrite()){
    128         echo                '<div style="background-color : red;">' .
    129                                 '<p>Not Loaded</p>' .
    130                             '</div>';
    131     }else{
    132         echo                '<div style="background-color : green;">' .
    133                                 '<p>Loaded</p>' .
    134                             '</div>';
    135     }
    136     echo                '</td>' .
    137                     '</tr>';
    138     //////////////// Apache SSL Module /////////////////////////////////////////////////////////////////////////////////
    139     echo            '<tr>' .
    140                         '<td>' .
    141                             '<label>Apache SSL Module : </label>' .
    142                         '</td>' .
    143                         '<td>';
    144     if(!apache_mod_loaded('mod_ssl')){
    145         echo                '<div style="background-color : red;">' .
    146                                 '<p>Not Loaded</p>' .
    147                             '</div>';
    148     }else{
    149         echo                '<div style="background-color : green;">' .
    150                                 '<p>Loaded</p>' .
    151                             '</div>';
    152     }
    153     echo                '</td>' .
    154                     '</tr>';
    155     //////////////// AdDefend Content-Proxy ////////////////////////////////////////////////////////////////////////////
    156     echo            '<tr>' .
    157                         '<td>' .
    158                             '<label>AdDefend Content-Proxy : </label>' .
    159                         '</td>' .
    160                         '<td>';
    161     $htaccess = ABSPATH.'.htaccess';
    162     $addefend_rules = addefend_extract_from_markers( $htaccess, ADDEFEND_HTACCESS_MARKER );
    163     if(sizeof($addefend_rules) < 3){
    164         echo                '<div style="background-color : red;">' .
    165                                 '<p>Not Configured</p>' .
    166                             '</div>';
    167     }else{
    168         echo                '<div style="background-color : green;">' .
    169                                 '<p>Configured</p>' .
    170                             '</div>';
    171     }
    172     echo                '</td>' .
    173                     '</tr>';
    174     //////////////// AdDefend Config Fragment Index ////////////////////////////////////////////////////////////////////
    175     if(sizeof($addefend_rules) >= 3){
    176         echo        '<tr>' .
    177                         '<td>' .
    178                             '<label>AdDefend Config Fragment Index : </label>' .
    179                         '</td>' .
    180                         '<td>' .
    181                             '<p>'.get_line_from_file($htaccess, ADDEFEND_HTACCESS_MARKER).'</p>' .
    182                         '</td>' .
    183                     '</tr>' .
    184                     '<tr>' .
    185                         '<td>' .
    186                             '<label>AdDefend Config Fragment : </label>' .
    187                         '</td>' .
    188                         '<td>';
    189         foreach ($addefend_rules as $value):
    190             echo            '<li>'.htmlspecialchars($value).'</li>';
    191         endforeach;
    192         echo            '</td>' .
    193                     '</tr>';
    194     }
    195     //////////////// Wordpress Root Directory //////////////////////////////////////////////////////////////////////////
    196     echo            '<tr>' .
    197                         '<td>' .
    198                             '<label>Wordpress Root Directory : </label>' .
    199                         '</td>' .
    200                         '<td>' .
    201                             '<p>'.get_home_path().'</p>' .
    202                         '</td>' .
    203                     '</tr>';
    204     //////////////// Wordpress Sub-Directory ///////////////////////////////////////////////////////////////////////////
    205     if(get_home_path() !== ABSPATH){
    206         echo        '<tr>' .
    207                         '<td>' .
    208                             '<label>Wordpress Sub-Directory : </label>' .
    209                         '</td>' .
    210                         '<td>' .
    211                             '<p>'.ABSPATH.'</p>' .
    212                         '</td>' .
    213                     '</tr>';
    214     }
    215     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    216     echo        '</table>' .
    217                 '<p class="submit">' .
    218                     '<input type="submit" name="Submit" class="button-primary" value="Save Changes"/>' .
    219                 '</p>' .
    220             '</form>';
    221 }
     67    ?>
     68
     69    <h1>AdDefend Integration Parameters</h1>
     70    <p>
     71    <form method="post" action="">
     72        <label for="select_content_proxy">Content-Proxy:</label>
     73        <select id="select_content_proxy" name="selected_content_proxy" onchange="this.form.submit()">
     74            <option value="apache" <?= $contentProxy == "apache" ? "selected": "" ?>>Apache</option>
     75            <option value="intern" <?= $contentProxy == "intern" ? "selected": "" ?>>Internal Proxy</option>
     76        </select>
     77    </form>
     78    </p>
     79
     80    <form method="post" action="">
     81        <?= wp_nonce_field("submit_addefend_integration_parameters" ) ?>
     82        <input type="hidden" name="submitted" value="config_form">
     83        <input type="hidden" name="selected_content_proxy" value="<?= esc_attr($contentProxy) ?>">
     84        <style>
     85            .addefend_table {border-collapse: collapse;}
     86            .addefend_table td {border: 1px solid black; padding: 10px;}
     87            .addefend_table td * {margin: auto !important;}
     88            .addefend_table li {list-style-type: none;}
     89            .addefend_table td > div {height : 20px; width : 140px;}
     90            .addefend_table td > div > p {text-align: center; color: white; font-weight: bold;}
     91            .addefend_table td > label {font-weight: bold;}
     92            .addefend_table td:first-child { width: 185px; }
     93        </style>
     94        <table class="addefend_table">
     95            <!-- Script URL -->
     96            <tr>
     97                <td>
     98                    <label for="script_URL_field_id">Script URL: </label>
     99                </td>
     100                <td>
     101                    <input type="text" id="script_URL_field_id" name="script_URL" value="<?= esc_attr($scriptUrl) ?>" size="70">
     102                </td>
     103            </tr>
     104            <!-- Proxy URL -->
     105            <tr>
     106                <td>
     107                    <label for="proxy_URL_field_id">Proxy URL:  </label>
     108                </td>
     109                <td>
     110                    <input type="text" id="proxy_URL_field_id" name="proxy_URL" value="<?= esc_attr($proxyUrl) ?>" size="70">
     111                </td>
     112            </tr>
     113            <!-- Image Directory -->
     114            <tr>
     115                <td>
     116                    <label for="image_dir_id">Images Directory: </label>
     117                </td>
     118                <td>
     119                    <input type="text" id="image_dir_id" name="image_dir" value="<?= esc_attr($imageDir) ?>" size="70">
     120                </td>
     121            </tr>
     122            <!-- AdDefend Script Caching -->
     123            <tr>
     124                <td>
     125                    <label>AdDefend Script Caching: </label>
     126                </td>
     127                <td>
     128                    <?php
     129                    global $wpdb;
     130                    $addefend_script = $wpdb->get_var('SELECT script FROM '.ADDEFEND_TABLE_NAME.' WHERE (id = \'1\')');
     131                    if ($addefend_script): ?>
     132                        <div style="background-color: green;">
     133                            <p>Working</p>
     134                        </div>
     135                    <?php else: ?>
     136                        <div style="background-color: red;">
     137                            <p>Not Working</p>
     138                        </div>
     139                    <?php endif; ?>
     140                </td>
     141            </tr>
     142            <?php if ($contentProxy == "apache"): ?>
     143                <!-- Apache Rewrite Module -->
     144                <tr>
     145                    <td>
     146                        <label>Apache Rewrite Module: </label>
     147                    </td>
     148                    <td>
     149                        <?php if (!got_mod_rewrite()): ?>
     150                            <div style="background-color: red;">
     151                                <p>Not Loaded</p>
     152                            </div>
     153                        <?php else: ?>
     154                            <div style="background-color: green;">
     155                                <p>Loaded</p>
     156                            </div>
     157                        <?php endif; ?>
     158                    </td>
     159                </tr>
     160                <!-- Apache SSL Module  -->
     161                <tr>
     162                    <td>
     163                        <label>Apache SSL Module:</label>
     164                    </td>
     165                    <td>
     166                        <?php if (!apache_mod_loaded("mod_ssl")): ?>
     167                            <div style="background-color: red;">
     168                                <p>Not Loaded</p>
     169                            </div>
     170                        <?php else: ?>
     171                            <div style="background-color: green;">
     172                                <p>Loaded</p>
     173                            </div>
     174                        <?php endif; ?>
     175                    </td>
     176                </tr>
     177                <!-- AdDefend Content-Proxy Apache -->
     178                <tr>
     179                    <td>
     180                        <label>AdDefend Content-Proxy:</label>
     181                    </td>
     182                    <td>
     183                        <?php
     184                        $htaccess = ABSPATH.'.htaccess';
     185                        $addefend_rules = addefend_extract_from_markers($htaccess, ADDEFEND_HTACCESS_MARKER );
     186                        ?>
     187                        <?php if (sizeof($addefend_rules) < 5): ?>
     188                            <div style="background-color: red;">
     189                                <p>Not Configured</p>
     190                            </div>
     191                        <?php else: ?>
     192                            <div style="background-color: green;">
     193                                <p>Configured</p>
     194                            </div>
     195                        <?php endif; ?>
     196                    </td>
     197                </tr>
     198                <?php if (sizeof($addefend_rules) >= 5): ?>
     199                    <!-- AdDefend Config Fragment Index -->
     200                    <tr>
     201                        <td>
     202                            <label>AdDefend Config Fragment Index: </label>
     203                        </td>
     204                        <td>
     205                            <p><?= get_line_from_file($htaccess, ADDEFEND_HTACCESS_MARKER); ?></p>
     206                        </td>
     207                    </tr>
     208                    <!-- AdDefend Config Fragment Index -->
     209                    <tr>
     210                        <td>
     211                            <label>AdDefend Config Fragment: </label>
     212                        </td>
     213                        <td>
     214                            <?php foreach ($addefend_rules as $value): ?>
     215                                <li><?= htmlspecialchars($value); ?></li>
     216                            <?php endforeach; ?>
     217                        </td>
     218                    </tr>
     219                    <!-- Wordpress Root Directory -->
     220                    <tr>
     221                        <td>
     222                            <label>Wordpress Root Directory: </label>
     223                        </td>
     224                        <td>
     225                            <p><?= get_home_path() ?></p>
     226                        </td>
     227                    </tr>
     228                <?php endif; ?>
     229                <?php if (get_home_path() !== ABSPATH): ?>
     230                    <!-- Wordpress Sub-Directory -->
     231                    <tr>
     232                        <td>
     233                            <label>Wordpress Sub-Directory: </label>
     234                        </td>
     235                        <td>
     236                            <p><?= ABSPATH ?></p>
     237                        </td>
     238                    </tr>
     239                <?php endif; ?>
     240            <?php endif; ?>
     241            <?php if ($contentProxy == "intern"): ?>
     242                <tr>
     243                    <td>
     244                        <label>Internal Proxy Status:</label>
     245                    </td>
     246                    <td>
     247                        <?php
     248                        $isInternalRedirectActionRegistered = has_action('template_redirect', 'addefend_internal_redirect');
     249                        ?>
     250                        <?php if ($isInternalRedirectActionRegistered): ?>
     251                            <div style="background-color: green;">
     252                                <p>Active</p>
     253                            </div>
     254                        <?php else: ?>
     255                            <div style="background-color: red;">
     256                                <p>Inactive</p>
     257                            </div>
     258                        <?php endif; ?>
     259                        <div class="primary" style="display: none;"
     260                    </td>
     261                </tr>
     262            <?php endif; ?>
     263        </table>
     264        <?php if ($contentProxy == "intern"): ?>
     265            <p><strong>Expected behaviour:</strong> If the image results in 404, the request will be forwarded to the specified 'Proxy URL'!</p>
     266            <table class="addefend_table">
     267                <tr>
     268                    <td>
     269                        <label>Example Image URL:</label>
     270                    </td>
     271                    <td>
     272                        <input type="text" id="example_url_publisher" value="" size="70" readonly>
     273                    </td>
     274                </tr>
     275                <tr>
     276                    <td>
     277                        <label>Example Forwarded URL:</label>
     278                    </td>
     279                    <td>
     280                        <input type="text" id="example_url_forwarded" value="" size="70" readonly>
     281                    </td>
     282                </tr>
     283            </table>
     284        <?php endif; ?>
     285        <p class="submit">
     286            <input type="submit" name="Submit" class="button-primary" value="Save Changes">
     287        </p>
     288    </form>
     289    <script>
     290        window.addEventListener("DOMContentLoaded", function() {
     291            if (document.querySelector("input[name=selected_content_proxy]").value !== "intern") return;
     292
     293            var exampleUrlPublisherElement = document.querySelector("#example_url_publisher");
     294            var exampleUrlProxiedElement = document.querySelector("#example_url_forwarded");
     295            var proxyUrlElement = document.querySelector("#proxy_URL_field_id");
     296            var imagesDirectoryElement = document.querySelector("#image_dir_id");
     297
     298            var exampleUrlPublisher = "", exampleUrlProxied = "";
     299            exampleUrlPublisher = location.protocol + "//" + location.host + imagesDirectoryElement.value + "/example/file.jpg";
     300
     301            exampleUrlPublisherElement.value = exampleUrlPublisher;
     302            exampleUrlProxiedElement.value = proxyUrlElement.value + imagesDirectoryElement.value + "/example/file.jpg";
     303        });
     304    </script>
     305<?php } ?>
  • addefend-easy-integration/trunk/addefend-easy-integration.php

    r2588683 r2685023  
    44Plugin URI: https://wordpress.org/plugins/addefend-easy-integration/
    55Description: The AdDefend Easy Intregration plug-in supports publishers in integrating the AdDefend anti-adblock solution.
    6 Version: 1.9
     6Version: 1.10
    77Author: AdDefend GmbH
    88Author URI: https://www.addefend.com/
     
    2525define( 'ADDEFEND_PLUGIN_PHP_FILE', __FILE__ );
    2626define( 'ADDEFEND_PLUGIN_ROOT_DIR', plugin_dir_path( __FILE__ ) );
     27define( 'ADDEFEND_MARKER', 'AdDefend' );
    2728define( 'ADDEFEND_HTACCESS_MARKER', 'AdDefend' );
    2829define( 'ADDEFEND_DEFAULT_IMAGE_DIRECTORY', '/wp-content');
     
    3233include ADDEFEND_PLUGIN_ROOT_DIR.'Components/script_integration.php';
    3334include ADDEFEND_PLUGIN_ROOT_DIR.'Components/proxy_integration.php';
     35include ADDEFEND_PLUGIN_ROOT_DIR.'Components/proxy_internal_forwarding.php';
  • addefend-easy-integration/trunk/readme.txt

    r2588683 r2685023  
    33Tags: unblock, unblockable, ads, addefend, ad recovery, recover ads, anti-adblocker, online advertising, digital advertising, ad reinsertion, counter block, block adblock, ad block blocker, adblock advertising
    44Requires at least: 4.2
    5 Tested up to: 5.8
    6 Stable tag: 1.9
     5Tested up to: 5.9
     6Stable tag: 1.10
    77License: GPLv3
    88License URI: https://www.gnu.org/licenses/gpl.html
     
    5252== Changelog ==
    5353
     54= 1.10 =
     55* content-proxy should now work on any server
     56* show more info in the plugin settings page
     57
    5458= 1.9 =
    5559* cleaned-up the settings page
Note: See TracChangeset for help on using the changeset viewer.