Plugin Directory

Changeset 2757457


Ignore:
Timestamp:
07/16/2022 09:52:31 PM (4 years ago)
Author:
linkworth
Message:

Sanitize and escape

Location:
linkworth-wp-plugin/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • linkworth-wp-plugin/trunk/LinkWorth_WordPress.php

    r2754739 r2757457  
    11591159        {
    11601160            //SET DEFAULT VARIABLES
    1161             $current_url = $_SERVER['SERVER_NAME'] . htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');
     1161            $current_url = htmlspecialchars($_SERVER['SERVER_NAME'], ENT_QUOTES, 'UTF-8') . htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');
    11621162            $links = array();
    11631163            $tags = array();
     
    14281428        if( isset( $_POST['linkw-submit'] ) )
    14291429        {
    1430             $options['title'] = strip_tags( stripslashes( htmlspecialchars($_POST['linkw-title'], ENT_QUOTES, 'UTF-8') ) );
     1430            $options['title'] = sanitize_text_field($_POST['linkw-title']);
    14311431            update_option( 'lw_widget', $options );
    14321432        }
     
    14441444?>
    14451445        <p style="text-align:right; white-space:nowrap;">
    1446             <label for="linkw-title">Title: <input style="width: 200px;" id="linkw-title" name="linkw-title" type="text" value="<?php echo $title ?>" /></label>
     1446            <label for="linkw-title">Title: <input style="width: 200px;" id="linkw-title" name="linkw-title" type="text" value="<?php echo esc_html($title) ?>" /></label>
    14471447        </p>
    14481448        <input type="hidden" id="linkw-submit" name="linkw-submit" value="1" />
  • linkworth-wp-plugin/trunk/lw_includes/LinkWorth_MU.php

    r1748971 r2757457  
    7575            @ini_set('default_socket_timeout', 10);
    7676
    77             $lw_blog_string = @file_get_contents('http://www.linkworth.com/act/partner/code/plugin_feed.php?ping=1&web_id=' . LW_SITE_ID . '&hash=' . LW_SITE_HASH);
    78 
    79             if($lw_blog_string)
    80             {
    81                 update_site_option('lw_wpmu_blogs_waiting',1);
    82             }
    83             else
    84             {
    85                 update_site_option('lw_wpmu_blogs_lastblogsupdate',time()-600); //Delay the update for 10 minutes incase of server issues.
    86             }
     77            $url = 'http://www.linkworth.com/act/partner/code/plugin_feed.php?ping=1&web_id=' . LW_SITE_ID . '&hash=' . LW_SITE_HASH;
     78
     79            $lw_blog_string = false;
     80            $response = wp_remote_get($url);
     81            $http_code = wp_remote_retrieve_response_code($response);
     82
     83            if ($http_code == '200') {
     84
     85                $lw_blog_string = wp_remote_retrieve_body($response);
     86
     87                if ($lw_blog_string) {
     88
     89                    update_site_option('lw_wpmu_blogs_waiting',1);
     90
     91                } else {
     92
     93                    update_site_option('lw_wpmu_blogs_lastblogsupdate',time()-600); //Delay the update for 10 minutes incase of server issues.
     94                }
     95
     96            } else {
     97
     98                update_site_option('lw_wpmu_blogs_lastblogsupdate',time()-600); //Delay the update for 10 minutes incase of server issues.
     99            }
    87100        }
    88101    }
     
    99112            @ini_set('default_socket_timeout', 10);
    100113
     114            $lw_blog_string = false;
     115
    101116            //PREVENT FUNCTION CALL IF CONSTANTS ARE NOT SET
    102             if(defined('LW_SITE_ID') && defined('LW_SITE_HASH'))
    103             {
    104                 $$lw_debug_information .= 'http://www.linkworth.com/act/partner/code/plugin_feed.php?web_id=' . LW_SITE_ID . '&hash=' . LW_SITE_HASH . '&format=xml&wpmu=1++';
    105                 $lw_blog_string = @file_get_contents('http://www.linkworth.com/act/partner/code/plugin_feed.php?web_id=' . LW_SITE_ID . '&hash=' . LW_SITE_HASH . '&format=xml&wpmu=1');
    106             }
    107             else
    108             {
     117            if (defined('LW_SITE_ID') && defined('LW_SITE_HASH')) {
     118
     119                $url = 'http://www.linkworth.com/act/partner/code/plugin_feed.php?web_id=' . LW_SITE_ID . '&hash=' . LW_SITE_HASH . '&format=xml&wpmu=1';
     120
     121                $$lw_debug_information .= $url . '++';
     122
     123                $response = wp_remote_get($url);
     124                $http_code = wp_remote_retrieve_response_code($response);
     125
     126                if ($http_code == '200') {
     127
     128                    $lw_blog_string = wp_remote_retrieve_body($response);
     129
     130                    if ($lw_blog_string) {
     131
     132                        update_site_option('lw_wpmu_blogs_waiting',1);
     133                    }
     134                }
     135
     136            } else {
     137
    109138                $lw_debug_information .= 'Constant not set++';
    110139            }
  • linkworth-wp-plugin/trunk/lw_includes/LinkWorth_admin.php

    r2754259 r2757457  
    174174?>
    175175        <div id="message" class="updated fade">
    176             <p><strong>Your host doesn't support <em>file_get_contents</em> or <em>curl</em>. Please ask your host to enable one or the other.</strong></p>
     176            <p><strong>Your host doesn't support <em>wp_remote_get</em> or <em>curl</em>. Please ask your host to enable one or the other.</strong></p>
    177177        </div>
    178178<?php
     
    218218                <tr>
    219219                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;">Does your theme have a sidebar?</td>
    220                     <td><input type="radio" name="lw_ops[lw_sidebar]" id="lw_sidebar-no" value="0" <?php if(!isset($lw_sidebar) || $lw_sidebar == 0) { echo "checked='checked' "; }?>/><label for="lw_sidebar-no"> No </label></td>
    221                     <td><input type="radio" name="lw_ops[lw_sidebar]" id="lw_sidebar-yes" value="1" <?php if($lw_sidebar == 1) { echo "checked='checked' "; }?>/><label for="lw_sidebar-yes"> Yes </label></td>
     220                    <td><input type="radio" name="lw_ops[lw_sidebar]" id="lw_sidebar-no" value="0" <?php if(!isset($lw_sidebar) || $lw_sidebar == 0) { echo esc_attr("checked='checked' "); }?>/><label for="lw_sidebar-no"> No </label></td>
     221                    <td><input type="radio" name="lw_ops[lw_sidebar]" id="lw_sidebar-yes" value="1" <?php if($lw_sidebar == 1) { echo esc_attr("checked='checked' "); }?>/><label for="lw_sidebar-yes"> Yes </label></td>
    222222                </tr>
    223223                <tr>
    224224                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;">Display deals using the widget?</td>
    225                     <td><input type="radio" name="lw_ops[lw_sidebarwidget]" id="lw_sidebarwidget-no" value="0" <?php if(!isset($lw_sidebarwidget) || $lw_sidebarwidget == 0) { echo "checked='checked' "; }?>/><label for="lw_sidebar-no"> No </label></td>
    226                     <td><input type="radio" name="lw_ops[lw_sidebarwidget]" id="lw_sidebarwidget-yes" value="1" <?php if($lw_sidebarwidget == 1) { echo "checked='checked' "; }?>/><label for="lw_sidebar-yes"> Yes </label></td>
     225                    <td><input type="radio" name="lw_ops[lw_sidebarwidget]" id="lw_sidebarwidget-no" value="0" <?php if(!isset($lw_sidebarwidget) || $lw_sidebarwidget == 0) { echo esc_attr("checked='checked' "); }?>/><label for="lw_sidebar-no"> No </label></td>
     226                    <td><input type="radio" name="lw_ops[lw_sidebarwidget]" id="lw_sidebarwidget-yes" value="1" <?php if($lw_sidebarwidget == 1) { echo esc_attr("checked='checked' "); }?>/><label for="lw_sidebar-yes"> Yes </label></td>
    227227                </tr>
    228228                <tr>
    229229                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;">Display styled links?</td>
    230                     <td><input type="radio" name="lw_ops[lw_linktype]" id="lw_regular" onchange="jQuery('#colors').fadeOut('slow');" value="0" <?php if (!isset($lw_linktype) || $lw_linktype == 0) { echo "checked='checked' "; }?>/><label for="lw_regular"> No </label></td>
    231                     <td><input type="radio" name="lw_ops[lw_linktype]" id="lw_cloud" onchange="jQuery('#colors').fadeIn('slow').css('display', 'inline-block');" value="1" <?php if ($lw_linktype == 1) { echo "checked='checked' "; }?>/><label for="lw_cloud"> Yes </label></td>
     230                    <td><input type="radio" name="lw_ops[lw_linktype]" id="lw_regular" onchange="jQuery('#colors').fadeOut('slow');" value="0" <?php if (!isset($lw_linktype) || $lw_linktype == 0) { echo esc_attr("checked='checked' "); }?>/><label for="lw_regular"> No </label></td>
     231                    <td><input type="radio" name="lw_ops[lw_linktype]" id="lw_cloud" onchange="jQuery('#colors').fadeIn('slow').css('display', 'inline-block');" value="1" <?php if ($lw_linktype == 1) { echo esc_attr("checked='checked' "); }?>/><label for="lw_cloud"> Yes </label></td>
    232232                </tr>
    233233<?php
     
    242242                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> Allow WPMU sub blogs manage their own id and hashes?</td>
    243243                    <td colspan="2">
    244                         <input type="checkbox" value="1" name="lw_ops[user_managed]" id="user_managed" <?php if(isset($user_managed) && $user_managed == 1){echo "checked='checked' ";}?>/>
     244                        <input type="checkbox" value="1" name="lw_ops[user_managed]" id="user_managed" <?php if(isset($user_managed) && $user_managed == 1){echo esc_attr("checked='checked' ");}?>/>
    245245                    </td>
    246246                </tr>
     
    248248                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is <span style="color:#FF0000;">MAIN</span> website's ID?</td>
    249249                    <td colspan="2">
    250                         <input type="text" name="lw_ops[site_id]" size="10" id="site_id" value="<?php if(defined('LW_SITE_ID')){echo LW_SITE_ID;} ?>"/>
     250                        <input type="text" name="lw_ops[site_id]" size="10" id="site_id" value="<?php if(defined('LW_SITE_ID')){echo esc_html(LW_SITE_ID);} ?>"/>
    251251                    </td>
    252252                </tr>
     
    254254                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is <span style="color:#FF0000;">MAIN</span> website's HASH ID?</td>
    255255                    <td colspan="2">
    256                         <input type="text" name="lw_ops[site_hash]" size="35" id="site_hash" value="<?php if(defined('LW_SITE_HASH')){echo LW_SITE_HASH;} ?>"/>
     256                        <input type="text" name="lw_ops[site_hash]" size="35" id="site_hash" value="<?php if(defined('LW_SITE_HASH')){echo esc_html(LW_SITE_HASH);} ?>"/>
    257257                    </td>
    258258                </tr>
     
    260260                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is THIS website's ID?</td>
    261261                    <td colspan="2">
    262                         <input type="text" name="lw_ops[website_id]" size="10" id="website_id" value="<?php if(defined('LW_WEBSITE_ID')) { echo LW_WEBSITE_ID; } ?>"/>
     262                        <input type="text" name="lw_ops[website_id]" size="10" id="website_id" value="<?php if(defined('LW_WEBSITE_ID')) { echo esc_html(LW_WEBSITE_ID); } ?>"/>
    263263                    </td>
    264264                </tr>
     
    266266                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is THIS website's HASH ID?</td>
    267267                    <td colspan="2">
    268                         <input type="text" name="lw_ops[website_hash]" size="35" id="website_hash" value="<?php if(defined('LW_HASH')) { echo LW_HASH; } ?>"/>
     268                        <input type="text" name="lw_ops[website_hash]" size="35" id="website_hash" value="<?php if(defined('LW_HASH')) { echo esc_html(LW_HASH); } ?>"/>
    269269                    </td>
    270270                </tr>
     
    284284                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is THIS website's SITE ID?</td>
    285285                    <td colspan="2">
    286                         <input type="text" name="lw_ops[website_id]" size="10" id="website_id" value="<?php if(defined('LW_WEBSITE_ID')) { echo LW_WEBSITE_ID; } ?>"<?php echo esc_attr($disabled_option) ?> />
     286                        <input type="text" name="lw_ops[website_id]" size="10" id="website_id" value="<?php if(defined('LW_WEBSITE_ID')) { echo esc_html(LW_WEBSITE_ID); } ?>"<?php echo esc_attr($disabled_option) ?> />
    287287                    </td>
    288288                </tr>
     
    290290                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is THIS website's HASH ID?</td>
    291291                    <td colspan="2">
    292                         <input type="text" name="lw_ops[website_hash]" size="35" id="website_hash" value="<?php if(defined('LW_HASH')) { echo LW_HASH; } ?>"<?php echo esc_attr($disabled_option) ?> />
     292                        <input type="text" name="lw_ops[website_hash]" size="35" id="website_hash" value="<?php if(defined('LW_HASH')) { echo esc_html(LW_HASH); } ?>"<?php echo esc_attr($disabled_option) ?> />
    293293                    </td>
    294294                </tr>
     
    302302                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is your website's ID?</td>
    303303                    <td colspan="2">
    304                         <input type="text" name="lw_ops[website_id]" size="10" id="website_id" value='<?php if(isset($website_id)) { echo $website_id; } ?>'/>
     304                        <input type="text" name="lw_ops[website_id]" size="10" id="website_id" value='<?php if(isset($website_id)) { echo esc_html($website_id); } ?>'/>
    305305                    </td>
    306306                </tr>
     
    308308                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> What is your website's HASH ID?</td>
    309309                    <td colspan="2">
    310                         <input type="text" name="lw_ops[website_hash]" size="35" id="website_hash" value='<?php if(isset($website_hash)) { echo $website_hash; } ?>'/>
     310                        <input type="text" name="lw_ops[website_hash]" size="35" id="website_hash" value='<?php if(isset($website_hash)) { echo esc_html($website_hash); } ?>'/>
    311311                    </td>
    312312                </tr>
     
    317317                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> Billboard ad base URL?</td>
    318318                    <td colspan="2">
    319                         <input type="text" name="lw_ops[billboard_base]" size="20" id="billboard_base" value='<?php if(isset($billboard_base)) { echo $billboard_base; } ?>'/>
     319                        <input type="text" name="lw_ops[billboard_base]" size="20" id="billboard_base" value='<?php if(isset($billboard_base)) { echo esc_html($billboard_base); } ?>'/>
    320320                    </td>
    321321                </tr>
     
    375375                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA; vertical-align:middle;">Font Size:</td>
    376376                    <td>
    377                         <input name="lw_ops[lw_linksize]" value="<?php echo $lw_linksize ?>" style="width:90px;" /> <span style="font-weight:bold"><?php echo $lw_linkscale ?></span>
     377                        <input name="lw_ops[lw_linksize]" value="<?php echo esc_html($lw_linksize) ?>" style="width:90px;" /> <span style="font-weight:bold"><?php echo esc_html($lw_linkscale) ?></span>
    378378                    </td>
    379379                </tr>
     
    630630        {
    631631            $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
    632             $pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
    633             $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
     632            $script_filename = htmlspecialchars($_SERVER["SCRIPT_FILENAME"], ENT_QUOTES, 'UTF-8');
     633            $pos = strpos($script_filename, $wp_path_rel_to_home);
     634            $home_path = substr($script_filename, 0, $pos);
    634635            $home_path = trailingslashit( $home_path );
    635636        }
     
    664665        <div id="message" class="updated fade">
    665666            <p style="font-weight:bold;">
    666                 Your theme has <?php echo $loop_count ?> loop.
     667                Your theme has <?php echo esc_html($loop_count) ?> loop.
    667668                If you do not have a static page as your home page, your theme could be using more then one instance of 'The Loop.'
    668                 The number of loops could be higher then <?php echo $loop_count ?>.
     669                The number of loops could be higher then <?php echo esc_html($loop_count) ?>.
    669670            </p>
    670671        </div>
     
    675676?>
    676677        <div id="message" class="updated fade">
    677             <p style="font-weight:bold;">Your theme has <?php echo $loop_count ?> loop(s).</p>
     678            <p style="font-weight:bold;">Your theme has <?php echo esc_html($loop_count) ?> loop(s).</p>
    678679        </div>
    679680<?php
     
    709710                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> Add rotating ads after what loop?</td>
    710711                    <td>
    711                         <input type="text" name="lw_ops[loop_number]" size="5" id="loop_number" style="border:1px solid #406680; border-radius:0 0 0 0;" value='<?php if(isset($loop_number) && $loop_number > 0){ echo $loop_number; }?>'<?php echo $loop_option_disabled ?> />
     712                        <input type="text" name="lw_ops[loop_number]" size="5" id="loop_number" style="border:1px solid #406680; border-radius:0 0 0 0;" value='<?php if(isset($loop_number) && $loop_number > 0){ echo esc_html($loop_number); }?>'<?php echo esc_attr($loop_option_disabled) ?> />
    712713                    </td>
    713714                </tr>
     
    733734                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> Do not display ads after single page content?</td>
    734735                    <td>
    735                         <input type="checkbox" value="1" name="lw_ops[nocontentads]" id="nocontentads" <?php if(isset($nocontentads) && $nocontentads == 1) { echo "checked='checked' "; }?>/>
     736                        <input type="checkbox" value="1" name="lw_ops[nocontentads]" id="nocontentads" <?php if(isset($nocontentads) && $nocontentads == 1) { echo esc_attr("checked='checked' "); }?>/>
    736737                    </td>
    737738                </tr>
     
    739740                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;"> Place LinkInTxt as Tags on single pages?</td>
    740741                    <td>
    741                         <input type="checkbox" value="1" name="lw_ops[display_tagged]" <?php if(isset($display_tagged) && $display_tagged == 1) { echo "checked='checked' "; }?>/>
     742                        <input type="checkbox" value="1" name="lw_ops[display_tagged]" <?php if(isset($display_tagged) && $display_tagged == 1) { echo esc_attr("checked='checked' "); }?>/>
    742743                    </td>
    743744                </tr>
     
    745746                    <td style="color:#333333; font-weight:bold; background-color:#EAF2FA;">Disable silent running?</td>
    746747                    <td>
    747                         <input type="checkbox" value="1" name="lw_ops[disable_silent]" id="silent" <?php if(isset($disable_silent) && $disable_silent == 1) { echo "checked='checked' "; }?>/>
     748                        <input type="checkbox" value="1" name="lw_ops[disable_silent]" id="silent" <?php if(isset($disable_silent) && $disable_silent == 1) { echo esc_attr("checked='checked' "); }?>/>
    748749                    </td>
    749750                </tr>
Note: See TracChangeset for help on using the changeset viewer.